【发布时间】:2014-06-05 17:17:13
【问题描述】:
我需要重写sale.order.line中定义的product_id_change函数,所以每次更新数量时它都不会改变unit_price。
我知道我必须使用 super,但我不确定它是如何工作的。
谁能帮忙?
谢谢。
【问题讨论】:
标签: overriding openerp onchange
我需要重写sale.order.line中定义的product_id_change函数,所以每次更新数量时它都不会改变unit_price。
我知道我必须使用 super,但我不确定它是如何工作的。
谁能帮忙?
谢谢。
【问题讨论】:
标签: overriding openerp onchange
这很简单,但您需要做几件事(假设 OpenERP 7)
一个典型的模式是调用super然后处理结果。
class MyModel(osv.Model):
_inherit = 'sale.order.line'
def product_id_change(self, cr, uid, ids, ...):
res = super(MyModel, self).product_id_change(cr, uid, ids...)
# do stuff with res.
return res
在 sale_margin.py 文件中的 OpenERP sale_margin 模块中有一个例子。
【讨论】: