Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[V9] Message_Post Error

By
Andreas
on 10/20/15, 10:40 AM 433 views

I'm trying to add message (log an internal note) when user call inherit function.

But my code can't working.

from openerp import models, fields, api, tools
from openerp.tools.translate import _

class res_partner(models.Model):

_inherit = 'res.partner'

STATE_SELECTION = [
('draft', 'Request Approval'),
('approved', 'Approved'),

]
state = fields.Selection(STATE_SELECTION, 'Status', readonly=True,
help="Request Approval Record "
"Approved Record. ",
select=True,default='draft')

@api.multi
def write(self, vals):
if self.state == 'approved':
vals.update({'state':'draft'})
cr = self.env.cr
uid = self.env.uid
ids = self.ids
context = None
changes = []
changes.append(_("Record Updated from '%s' to '%s'") %("Approved", "Request Approval"))
self.message_post(cr, uid, [ids], body=", ".join(changes), context=context)
return super(res_partner, self).write(vals)

@api.multi
def button_approved(self, vals):
self.write({'state': 'approved'})
cr = self.env.cr
uid = self.env.uid
ids = self.ids
context = None
changes = []
changes.append(_("Record Updated from '%s' to '%s'") %("Request Approval", "Approved"))
self.message_post(cr, uid, [ids], body=", ".join(changes), context=context)

Error message:

File "/usr/lib/python2.7/site-packages/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/openerp/addons/web/controllers/main.py", line 962, in checked_call
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/openerp/api.py", line 223, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/openerp/api.py", line 345, in old_api
result = method(recs, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/openerp/addons/customer_approval/models.py", line 54, in button_approved
self.message_post(cr, uid, [ids], body=", ".join(changes), context=context)
File "/usr/lib/python2.7/site-packages/openerp/api.py", line 221, in wrapper
return new_api(self, *args, **kwargs)
TypeError: message_post() got multiple values for keyword argument 'body'

Any idea or help or solution for this problem?


Thanks and Regards,

Andreas

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/20/15, 10:40 AM
Seen: 433 times
Last updated: 10/20/15, 10:40 AM