Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
5411 Näkymät

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
Hylkää

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

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
syysk. 22
2517
4
toukok. 18
11536
1
tammik. 16
21475
1
marrask. 24
40364
0
maalisk. 23
5595