Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5130 Widoki

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"

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
1
wrz 22
2314
4
maj 18
11257
1
sty 16
21171
1
lis 24
39753
0
mar 23
5318