product_usability: seller_id can not be store as muti-company will be broken

do not store the field as shared product can have different supplier
depending on the company logged
Use compute as related will always pick the first one whatever the
company logged
This commit is contained in:
Sébastien BEAU
2024-05-31 10:00:33 +02:00
parent 5144b039a5
commit 0fa2024dab

View File

@@ -14,7 +14,8 @@ class ProductTemplate(models.Model):
# in v10, that field was defined in procurement_suggest, but we will # in v10, that field was defined in procurement_suggest, but we will
# probably not port procurement_suggest because it is native in v14 # probably not port procurement_suggest because it is native in v14
seller_id = fields.Many2one( seller_id = fields.Many2one(
'res.partner', related='seller_ids.name', store=True, 'res.partner',
compute="_compute_seller_id",
string='Main Supplier') string='Main Supplier')
# in v14, I noticed that the tracking of the fields of product.template # in v14, I noticed that the tracking of the fields of product.template
@@ -33,6 +34,10 @@ class ProductTemplate(models.Model):
company_id = fields.Many2one(tracking=110) company_id = fields.Many2one(tracking=110)
barcode_type = fields.Char(compute='_compute_template_barcode_type') barcode_type = fields.Char(compute='_compute_template_barcode_type')
def _compute_seller_id(self):
for record in self:
record.seller_id = fields.first(record.seller_ids).name
@api.depends('product_variant_ids.barcode') @api.depends('product_variant_ids.barcode')
def _compute_template_barcode_type(self): def _compute_template_barcode_type(self):
ppo = self.env['product.product'] ppo = self.env['product.product']