在'order.sale'中计算我需要在函数上调用的总税额。但问题在于单击“保存”按钮而不是只有该函数必须调用。
答案 0 :(得分:0)
如果要在单击保存按钮时调用函数,则需要覆盖write和create方法,如下所示:
#using the old api:
def create(self, cr, uid, vals, context=None):
self.your_function(parameters)
return super(sale_order, self).create(cr, uid, vals, context=ctx)
def write(self, cr, uid, ids, vals, context=None):
self.your_function(parameters)
return super(sale_order, self).write(cr, uid, ids, vals, context=context)
我希望这能帮到你!
答案 1 :(得分:0)
您可以覆盖重新计算税额的button_dummy
方法,并在点击(update)按钮后添加您的逻辑。
@api.multi
def button_dummy(self):
res = super(sale_order, self).button_dummy()
# Add your logic here
return res