I want to add products with same barcode but different Companies.
Done everything like at issue :
https://github.com/odoo/odoo/issues/20727
But is not working (maybe because i've got odoo 11).
Tried to overwrite class product.product but no result.
My code :
class CompanyProduct(models.Model):
_inherit = 'product.product'
product_company = fields.Many2one('res.company', 'Company', related='product_tmpl_id.company_id', store=True)
_sql_constraints = [ ('barcode_uniq', 'unique(product_company, barcode)', ("Barcode should be unique by company!")), ]
@api.model
def _auto_init(self):
res = super(CompanyProduct, self)._auto_init()
self._sql_constraints = [('barcode_uniq', 'unique(product_company, barcode)', _("Barcode should be unique by company!")),]
return res
Can you check the same in new database, SQL constraints have such an issue