Odoo,Python:ValueError:write()为关键字参数';上下文';
测试模块时出现此错误 我正在尝试对销售订单进行两级验证 确认未经批准的订单将无法完成 由sales managaer group发送,因此此按钮发送电子邮件、打印、确认将不会显示,而不显示approve firstOdoo,Python:ValueError:write()为关键字参数';上下文';,python,openerp,openerp-8,Python,Openerp,Openerp 8,测试模块时出现此错误 我正在尝试对销售订单进行两级验证 确认未经批准的订单将无法完成 由sales managaer group发送,因此此按钮发送电子邮件、打印、确认将不会显示,而不显示approve first Traceback (most recent call last): File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 537, in _handle_e
Traceback (most recent call last):
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 537, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 574, in dispatch
result = self._call_function(**self.params)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 310, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 307, in checked_call
return self.endpoint(*a, **kw)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 803, in __call__
return self.method(*args, **kw)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 403, in response_wrap
response = f(*args, **kw)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/addons/web/controllers/main.py", line 955, in exec_workflow
return request.session.exec_workflow(model, id, signal)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 1111, in exec_workflow
r = self.proxy('object').exec_workflow(self.db, self.uid, self.password, model, signal, id)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 879, in proxy_method
result = dispatch_rpc(self.service_name, method, args)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/http.py", line 115, in dispatch_rpc
result = dispatch(method, params)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/service/model.py", line 37, in dispatch
res = fn(db, uid, *params)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/service/model.py", line 188, in exec_workflow
return exec_workflow_cr(cr, uid, obj, signal, *args)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/service/model.py", line 182, in exec_workflow_cr
return execute_cr(cr, uid, obj, 'signal_workflow', [res_id], signal)[res_id]
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/service/model.py", line 164, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/api.py", line 256, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/models.py", line 3572, in signal_workflow
result[res_id] = workflow.trg_validate(uid, self._name, res_id, signal, cr)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/__init__.py", line 85, in trg_validate
return WorkflowService.new(cr, uid, res_type, res_id).validate(signal)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/service.py", line 91, in validate
res2 = wi.validate(signal)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/instance.py", line 80, in validate
wi.process(signal=signal, force_running=force_running, stack=stack)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 120, in process
ok = self._split_test(activity['split_mode'], signal, stack)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 248, in _split_test
self._join_test(t[0], t[1], stack)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 257, in _join_test
WorkflowItem.create(self.session, self.record, activity, inst_id, stack=stack)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 95, in create
workflow_item.process(stack=stack)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 116, in process
if not self._execute(activity, stack):
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 162, in _execute
returned_action = self.wkf_expr_execute(activity)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 313, in wkf_expr_execute
return self.wkf_expr_eval_expr(activity['action'])
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/workflow/workitem.py", line 291, in wkf_expr_eval_expr
result = eval(line, env, nocopy=True)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/tools/safe_eval.py", line 314, in safe_eval
return eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/api.py", line 254, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/api.py", line 580, in new_api
result = method(self._model, cr, uid, self.ids, *args, **old_kwargs)
ValueError: "write() got multiple values for keyword argument 'context'" while evaluating
u"write('is_art_approved', True)"
我的xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="sale_view_order_form" model="ir.ui.view">
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<button name="print_quotation" position="after">
<button name="approve_art" string="Approve Art"
states="draft,sent" groups="base.group_user"/>
</button>
<button name="action_button_confirm" position="attributes">
<attribute name="states">art_approved</attribute>
</button>
<button name="print_quotation" position="attributes">
<attribute name="states">draft,sent,art_approved</attribute>
</button>
<button name="cancel" position="attributes">
<attribute name="states">draft,sent,art_approved</attribute>
</button>
</field>
</record>
</data>
</openerp>
销售订单
艺术组批准
起草、发送、批准
起草、发送、批准
提前感谢您的写入方法应该传递字典数据结构中的字段值,如
write({'is_art_approved', True})
而不是像这样传递它:
write('is_art_approved', True)
在写方法中,ids
是必需的参数,但这取决于代码的编写方式。有关写入方法的更多信息,请参阅
最好的是,odoo中的
创建
或写入方法需要在数据库中写入数据的字典(键:值对)。从错误代码中,它显示了错误调用的write方法。其内容应如下:
obj.write(cr, uid, ids, {'key':'value'}, context=<<your context>>)
obj.write(cr,uid,id,{'key':'value'},context=)
其中,
id
是需要更新数据库中数据的记录id。您忘记了一些参数或使用了太多参数。
写入方法应包含以下参数:
cr #used database cursor
uid #logged in user
ids #id from the object youŕe writing to
data #dictionary of data that has to be written
context #the given context
代码似乎不完整,您是否也可以包含您的业务逻辑。请添加完整的错误回溯。在您面临错误的位置发布全部代码。添加请检查帖子
cr #used database cursor
uid #logged in user
ids #id from the object youŕe writing to
data #dictionary of data that has to be written
context #the given context