# -*- encoding: utf-8 -*- ################################################################################# # # # product_genre for OpenERP # # Author: Victor Obrist # # contact: victor@paraguayenlaweb.com # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU Affero General Public License as # # published by the Free Software Foundation, either version 3 of the # # License, or (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU Affero General Public License for more details. # # # # You should have received a copy of the GNU Affero General Public License # # along with this program. If not, see . # # # ################################################################################# from openerp.osv import orm, fields class product_genre(orm.Model): _name = 'product.genre' _columns = { 'name': fields.char('Genre Name'), # 'code': fields.integer('Genre Code', size=1, translate=True, required=True, help='Code for barcode generator'), 'reference': fields.char('Reference', size=1, translate=True, required=True, help='Reference for the product internal reference.'\ 'One character lenght.'\ 'E.g.: for Male could be M'), } def onchange_case(self, cr, uid, ids, reference): result = {'value': { 'reference': str(reference).upper() } } return result _sql_constraints = [ ('reference_genre_uniq', 'unique (reference)', 'La referencia del género debe ser única!') ] class product_template(orm.Model): _inherit = 'product.template' _columns = { 'product_genre_id': fields.many2one( 'product.genre', 'Genero', help='Select a genre for this product.', ondelete='restrict', required=True) }