Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Products & Pricelists

Entity: product.product

Compute Method: _compute_product_code

View 18.0 View 20.0
Inputs Method Outputs
  • default_code
  • partner_id
  • partner_id.id
  • product_id
  • product_code
- read_access = self.env['ir.model.access'].check('product.supplierinfo', 'read', False)
+ read_access = self.env['product.supplierinfo'].has_access('read')
for product in self:
            product.code = product.default_code
            if read_access:
-                 for supplier_info in product.seller_ids:
-                     if supplier_info.partner_id.id == product._context.get('partner_id'):
+                 allowed_sellers = product.sudo().seller_ids.filtered(
+                     lambda s: not s.company_id or s.company_id in self.env.companies
+                 )
+                 for supplier_info in allowed_sellers:
+                     if supplier_info.partner_id.id == product.env.context.get('partner_id'):
                        if supplier_info.product_id and supplier_info.product_id != product:
                            # Supplier info specific for another variant.
                            continue
                        product.code = supplier_info.product_code or product.default_code
                        if product == supplier_info.product_id:
                            # Supplier info specific for this variant.
                            break
  • code

Back to entity