I added the part number field in product template model
partnumber = fields.Char(
'Part Number', compute='_compute_partnumber',
inverse='_set_partnumber', store=True)
I write the function like internal reference code
@api.depends('product_variant_ids', 'product_variant_ids.partnumber')
def _compute_partnumber(self):
unique_variants = self.filtered(lambda template: len(template.product_variant_ids) == 1)
for template in unique_variants:
template.partnumber = template.product_variant_ids.partnumber
for template in (self - unique_variants):
template.partnumber = ''
@api.one
def _set_partnumber(self):
if len(self.product_variant_ids) == 1:
self.product_variant_ids.partnumber = self.partnumber
I successfully added part number in product form.I used above methods for name get(to get part number in product description)
My problem is the part number could not saved in create method. the field only saved in edit mode.