Community: Framework mailing list archives

expert-framework@mail.odoo.com

Accessing object method from server action python script

by
Maxim Litnitskiy
- 05/15/2015 09:59:09
Hi dear Community!
I am trying to post a notification to a specially created Sales message group when leads from unknown customers are created.
So that's the code:


env['mail.group'].search([('name','=','Sales')]).message_post(
            type="notification",
            subtype="mt_comment").message_post(
            subject='New order',
            body='<a href="/web#id=%s&view_type=form&model=crm.lead&menu_id=137&action=144">%s</a>' % (object.id, object.name),
            type="notification",
            subtype="mt_comment")

And it gives the following error:

ValueError: "'int' object has no attribute 'message_post'" while evaluating
u'# Available locals:\n#  - time, datetime, dateutil: Python libraries\n#  - env: Odoo Environement\n#  - model: Model of the record on which the action is triggered\n#  - object: Record on which the action is triggered if there is one, otherwise None\n#  - workflow: Workflow engine\n#  - Warning: Warning Exception to use with raise\n# To return an action, assign: action = {...}\n\nenv[\'mail.group\'].search([(\'name\',\'=\',\'Sales\')]).message_post(\n            body="Yes inform me as i belong to manfacture group",            \n            subject="notification about order",            \n            type="notification",\n            subtype="mt_comment").message_post(\n            subject=\'\u041d\u043e\u0432\u044b\u0439 \u0437\u0430\u043a\u0430\u0437\',\n            body=\'<a href="/web#id=%s&view_type=form&model=crm.lead&menu_id=137&action=144">%s</a>\' % (object.id, object.name),\n            type="notification",\n            subtype="mt_comment")'

I cannot understand my it have type of int not object.

Because I can use the following code without errors:

object.message_post(           
            subject="notification about order",            
            type="notification",
            subtype="mt_comment").message_post(
            body='<a href="/web#id=%s&view_type=form&model=crm.lead&menu_id=137&action=144">%s</a>' % (object.id, object.name),
            type="notification",
            subtype="mt_comment")
 

Any clue?
Thanks.

Regards,
Max.