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

Automated Action update field [Closed]

By
Landon Gilbert-Bland
on 4/15/13, 6:21 PM 1,616 views

The Question has been closed

by
Sudhir Arya (SA)
on 04/18/2013 05:10:16

I am trying to update a custom field in crm.lead using automated actions. The code I have looks like this:

# You can use the following variables:
#  - self: ORM model of the record on which the action is triggered
#  - object: browse_record of the record on which the action is triggered if there is one, otherwise None
#  - pool: ORM model pool (i.e. self.pool)
#  - time: Python time module
#  - cr: database cursor
#  - uid: current user id
#  - context: current context
# If you plan to return an action, assign: action = {...}

self.write(cr, uid, object, {'custom_field': 'test'}, context)

This is the error I get (I can get the full traceback if it would be helpful):

TypeError: argument 2 to map() must support iteration

I have tried setting object to [object] and verifying that object is not None but it still errors out. If I pass in an empty list instead of object to .write() then it doesn't error out, but my field doesn't get updated, which is understandable. Can anyone point me in the direction of what I am doing wrong here?

Thanks

3

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 4/16/13, 2:12 AM

In write method you must pass ID or list of IDs. You are facing error because you are passing browse record instead of ID.

Try this:

if object: self.write(cr, uid, [object.id], {'custom_field': 'test'}, context=context)

wow its really helpful me too today.. Arya, please advice me on this http://help.openerp.com/question/12486/how-to-set-field-as-readonly-by-function/

priyankahdp
on 4/20/13, 3:18 AM

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 4/15/13, 6:21 PM
Seen: 1616 times
Last updated: 3/16/15, 8:10 AM