【问题标题】:Odoo set Sequence in Product Code and Product BarcodeOdoo 在产品代码和产品条形码中设置序列
【发布时间】:2019-02-16 05:35:18
【问题描述】:

我创建了新字段 Product CodeProduct Barcode 用于在创建 Product Variant 时使用。我在 product.templateproduct.product 中创建了此字段,然后在 Product Template 中创建产品时使用Product CodeProduct Barcode,我想为Product Variants 创建一个序列化的Product CodeProduct Barcode,它们将在product.product 之下。 例如:如果我们在Product Template 中将abc 赋予Product Code 并且它有3 个变体,则Product Template 中的Product Code 应该分别为abc-1,abc-2,abc-3。 数据传递,一切都完成了,但在我的逻辑中,如果我们删除一个变体并添加另一个变体,它就有可能以相同的名称出现。 例如:如果我们删除变量 abc-1 并添加另一个变量,它的 Product Code 将变为 abc-3(已经可用)

代码

for variant_ids in to_create_variants:
    if self.product_variant_count == 0 :
        count = count + 1
    else :
        count = self.product_variant_count + 1
        new_variant = Product.create({
                        'product_tmpl_id': tmpl_id.id,
                        'attribute_value_ids': [(6, 0, variant_ids.ids)],
                        'xn_product_code' :  str(tmpl_id.xn_product_code_tmpl) +  "-" + str(count),
                        'xn_product_barcode' : str(tmpl_id.xn_product_barcode_tmpl) + "-" + str(count) 
                    })

【问题讨论】:

    标签: odoo odoo-10 odoo-11


    【解决方案1】:

    我通过向Product Template 添加一个额外的计数字段解决了这个问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-11
      • 1970-01-01
      • 2012-07-02
      相关资源
      最近更新 更多