gpt4 book ai didi

python - Odoo, python : ValueError: write() got multiple values for keyword argument 'context'

转载 作者:行者123 更新时间:2023-11-28 21:49:04 27 4
gpt4 key购买 nike

测试模块时出现此错误

我正在尝试对销售订单进行两级验证确认订单不会在没有批准艺术的情况下完成由销售经理小组发送,因此发送电子邮件、打印、确认的按钮不会出现,除非先批准

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)"

我的python代码

from openerp.osv import osv, fields
class salesapproval_sale_order(osv.Model):
_inherit = 'sale.order'
_columns = {
'state': fields.selection(
[('cancel', 'Cancelled'),('draft', 'Draft'),('confirmed', 'Confirmed'),('exception', 'Exception'),('done', 'Done')],
'Status', required=True, readonly=True, copy=False,
help='* The \'Draft\' status is set when the related sales order in draft status. \
\n* The \'Confirmed\' status is set when the related sales order is confirmed. \
\n* The \'Exception\' status is set when the related sales order is set as exception. \
\n* The \'Done\' status is set when the sales order line has been picked. \
\n* The \'Cancelled\' status is set when a user cancel the sales order related.'),

}

我的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 方法应该像这样在字典数据结构中传递字段值

write({'is_art_approved', True})

而不是像这样传递它:

write('is_art_approved', True)

并且在 write 方法中 ids 是必需的参数,但这取决于代码的编写方式。更多关于写入方法的信息是 here

最佳,

关于python - Odoo, python : ValueError: write() got multiple values for keyword argument 'context' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34111155/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com