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

Inputs Method Outputs
  • default_code
  • partner_id
  • partner_id.id
  • product_id
  • product_code
read_access = self.env['product.supplierinfo'].has_access('read')
for product in self:
            product.code = product.default_code
            if read_access:
                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

Back to entity