this error appear when test the module
i'm trying to make two level validation on sales order confirm order wont done without the approve art by the sales managaer group so this button sent email,print,confirm will not appear whitout 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_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)"
my python code
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.'),
}
my 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>
thanks in advance
Your write method should pass field value in dictionary datastructure like
write({'is_art_approved', True})
Instead of passing it like:
write('is_art_approved', True)
And in write method ids
is required param but that depends how code is written. more about write methods is here
Bests,
create
or write
methods in odoo requires a dictionary (key:value pairs) of data to be written in the database. From you error code, it shows the wrongly called write method. It should be as follows:
obj.write(cr, uid, ids, {'key':'value'}, context=<<your context>>)
where ids
are the record ids for which you need to update data in the database.
You forgot some parameters or you used too many. the write method should contain the following parameters:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.