Python OpenERP-为什么在记录创建过程中调用create()方法两次?
我已在我的product_product和product_template类中重写了create方法。当我对model product.product使用view并尝试通过按Save创建新记录new product时,两种创建方法都会被调用:首先在product\u product中,然后在product\u模板中。由于VAL值不同,这会导致问题。我希望只调用product_product create。以下是代码片段:Python OpenERP-为什么在记录创建过程中调用create()方法两次?,python,openerp,odoo,Python,Openerp,Odoo,我已在我的product_product和product_template类中重写了create方法。当我对model product.product使用view并尝试通过按Save创建新记录new product时,两种创建方法都会被调用:首先在product\u product中,然后在product\u模板中。由于VAL值不同,这会导致问题。我希望只调用product_product create。以下是代码片段: class product_product(osv.Model):
class product_product(osv.Model):
_inherit = 'product.product'
def create(self, cr, uid, vals, context=None):
# ... validation code
return super(product_product, self).create(cr, uid, vals, context=context)
class product_template(osv.Model):
_inherit = 'product.template'
def create(self, cr, uid, vals, context=None):
# ... validation code
return super(product_template, self).create(cr, uid, vals, context=context)
每个产品都有一个必填字段,将其链接到模板产品\u tmpl\u id,因此,如果您没有为其提供现有模板,则必须创建一个新模板Ludwik Trammer 12月10日10:56每个产品都有一个必填字段,将其链接到模板产品\u tmpl\u id,因此如果您没有为其提供现有模板,则必须创建一个新模板。感谢Ludwik的评论。您能解决您的问题吗?