Hi guys,
I'm trying to check if there already is in database brand name ... but it won't work. Would you help me with?
======= c o d e =======
class product_brand(orm.Model):
_name = 'product.brand'
_sql_constraints = [('name_uniq','Check(1=1)','Brand name must be unique!'),] # is this correct ?
_columns = {
'name': fields.char('Brand'),
'description': fields.text('Description', translate=True),
'partner_id': fields.many2one(
'res.partner',
'partner',
help='Select a partner for this brand if it exists.',
ondelete='restrict'),
'logo': fields.binary('Logo File'),
}
class product_template(orm.Model):
_inherit = 'product.template'
# or should it be placed here ?
_columns = {
'product_brand_id': fields.many2one(
'product.brand',
'Brand', help='Select a brand for this product.', ondelete='restrict'),
}