odoo:TypeError:on\u change\u bill\u id()中的Onchange Functon至少接受7个参数(给定6个)
请注意,我正在尝试使用onchange函数。 下面是python:odoo:TypeError:on\u change\u bill\u id()中的Onchange Functon至少接受7个参数(给定6个),odoo,Odoo,请注意,我正在尝试使用onchange函数。 下面是python: def on_change_bill_id(self, cr, uid, ids, partner_id, account_id, invoice_mode, context=None): print ('------------------------Facturation on change--------------------') var = self.browse(cr, uid, ids, context)
def on_change_bill_id(self, cr, uid, ids, partner_id, account_id, invoice_mode, context=None):
print ('------------------------Facturation on change--------------------')
var = self.browse(cr, uid, ids, context)
print ('account = ' )
print account_id
print ('partner =' )
print partner_id
res = {'value':{
'invoice_line': self.get_inputs2(cr, uid, ids, partner_id, account_id, invoice_mode, context=context),
}
}
print ('-------------------Onchange-----------------------')
return res
和我的xml:
<field name="date_end" on_change="on_change_bill_id(partner_id, account_id, invoice_mode)"/>
问题是,当我只使用:
<field name="date_end" on_change="on_change_bill_id(partner_id, account_id)"/>
一切正常,当我添加发票模式时,我得到:
TypeError:on\u change\u bill\u id()至少接受7个参数(给定6个)
请帮我理解。
提前非常感谢有关参数的问题。我们需要基于.xml侧传递传递值/变量。如果我们传递两个变量,而不是in.py,那么我们必须只有两个变量 例如,如果我们使用这个
<field name="date_end" on_change="on_change_bill_id(partner_id, account_id, invoice_mode)"/>
若您更改xml端并传递两个变量,那个么我们必须在.py端捕获相同的变量
比如说
<field name="date_end" on_change="on_change_bill_id(partner_id, account_id)"/>
您应该尝试更新此行
<field name="date_end" on_change="on_change_bill_id(partner_id, account_id, invoice_mode, context)"/>
非常感谢您的回答,但先生,这正是我所做的,我得到了错误:TypeError:on\u change\u bill\u id()至少需要7个参数(给出6个参数)不,如果您正确升级模块,它将不再给您错误。我已经多次升级模块,但什么都没有发生。如果我无法升级模块,会发生此错误。我多次按upgrade,都出现了相同的错误。请告诉谁可以帮助您首先停止服务器并重新启动,然后再升级模块。请检查两次您的插件路径,并确保您正在更改正确的一个文件。您使用的是哪种型号?
def on_change_bill_id(self, cr, uid, ids, partner_id, account_id, context=None):
#here is your code logic
<field name="date_end" on_change="on_change_bill_id(partner_id, account_id, invoice_mode, context)"/>