我想基于category_id
字段为产品创建一个动态序列。我在product.category
中添加了一个category_code
。但是一旦我在create函数中调用它,它就会返回False
:
class ProductProduct(models.Model):
_inherit = 'product.product'
@api.model
def create(self, vals):
if 'default_code' not in vals or vals['default_code'] == '/':
sequence = self.env.ref('product_sequence.seq_product_auto')
record=super(ProductProduct, self).create(vals)
print self.categ_id.category_code
vals['default_code'] =self.categ_id.category_code + sequence.next_by_id()
return record
试着这样做:
相关问题 更多 >
编程相关推荐