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