【问题标题】:OpenERP - why the create() method is called two times during record create?OpenERP - 为什么在创建记录期间两次调用 create() 方法?
【发布时间】:2014-12-09 13:08:34
【问题描述】:

我在 product_product 和 product_template 类中覆盖了 create() 方法。当我使用带有模型 product.product 的视图并尝试通过按保存创建新记录(新产品)时,两个 create() 方法都被调用:首先在 product_product 中,然后在 product_template 中。由于 vals 值不同,这会导致问题。我希望只调用 product_product create() 。这是代码sn-p:

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) 

【问题讨论】:

  • 每个产品都有一个将其链接到模板 (product_tmpl_id) 的必填字段,因此如果您不为其提供现有模板,则必须创建一个新模板。
  • 感谢路德维克的评论。
  • 你的问题可以解决吗?

标签: python openerp odoo


【解决方案1】:

每个产品都有一个将其链接到模板 (product_tmpl_id) 的必填字段,因此如果您不为其提供现有模板,则必须创建一个新模板。 – Ludwik Trammer 12 月 10 日 10:56

【讨论】:

    猜你喜欢
    • 2021-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-10
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多