İçereği Atla
Menü
Bu soru işaretlendi
5208 Görünümler

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
Vazgeç

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eyl 22
2363
4
May 18
11327
1
Oca 16
21226
1
Kas 24
39977
0
Mar 23
5404