Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
5227 Prikazi

Here is my code:

 barcode_ids = fields.One2many('product.template.barcode','product_id','barcode',store=True ,compute='_compute_barcode',inverse='_set_barcode')#Нэмэлтээр бар код үүсгэх
  @api.depends('product_variant_ids', 'product_variant_ids.barcode_ids')
  def _compute_barcode(self):
  unique_variants = self.filtered(lambda template: len(template.product_variant_ids) == 1)
  for template in unique_variants:
  template.barcode_ids.barcode = template.product_variant_ids.barcode_ids.barcode
  for template in (self-unique_variants):
  template.barcode_ids.barcode = ''
  @api.one
  def _set_barcode(self):
  if len(self.product_variant_ids) == 1:
  for line in self:
  line.product_variant_ids.barcode_ids.barcode = self.barcode_ids.barcode
class ProductTemplateBarcode(models.Model):
  _name = 'product.template.barcode'
  barcode = fields.Char('Barcode',store=True)
  product_id = fields.Many2one('product.product',store=True)

error is:

ValueError: Expected singleton: product.template.barcode(29, <odoo.models.NewId object at 0x7f7b7c4ff6d0>)

How to fix?  Can any one guide me please
\\My goal is "The barcode adds to the product bar and does not add to the product"

                        "The barcode adds to the product and add to the product variant"

Avatar
Opusti

you have too many results. it says " I want one,don't throw everything at once" means iterate through....

Related Posts Odgovori Prikazi Aktivnost
1
sep. 22
2366
4
maj 18
11346
1
jan. 16
21250
1
nov. 24
40008
0
mar. 23
5421