首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >产品代码和产品条码中的Odoo集合序列

产品代码和产品条码中的Odoo集合序列
EN

Stack Overflow用户
提问于 2019-02-16 05:35:18
回答 1查看 152关注 0票数 0

我已经创建了新的字段Product CodeProduct Barcode,以便在创建Product Variant时使用,我在product.templateproduct.product中创建了这个字段,然后在使用Product CodeProduct BarcodeProduct Template中创建产品时,我希望为Product VariantsProduct Variants创建一个排序Product CodeProduct Barcode,这些字段将出现在product.product下。例:如果我们把abc作为Product CodeProduct Template中,并且它有3个变体,那么Product Template中的Product Code应该分别作为abc-1、abc-2,abc-3。数据传递和所有操作都完成了,但是在我的逻辑中,如果我们删除一个变体并添加另一个变体,它就有可能以相同的名称出现。如果我们删除变体abc-1并添加另一个变体,它的Product Code将以abc-3 (已经可用)的形式出现。

代码

代码语言:javascript
复制
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) 
                    })
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-18 08:00:03

我通过在Product Template中添加一个额外的计数字段来解决这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54720230

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档