1
votes

I added a new date field in the quotation form via the developer's mode. Now i want to get the field's value by retrieving it via python. The problem is that the string it is retrieving is 'False', a boolean value, i checked it. My code is correct because when i retrieved an existing date field on the form, it is retrieving it correctly. The problem is arising only with the custom field that i added. How can i solve this? i am using openerp 7....

 prod_obj = self.pool.get('sale.order')
 products_ids = prod_obj.browse(cr, uid,uid,context=context)
 expected_date = products_ids['x_expected_payment_date']

'x_expected_payment_date' is the custom field i added. it is displaying correctly on the form btw.

1

1 Answers

1
votes

You are browsing the sale order using the user ID so I presume you are getting a sale order that doesn't have a date set (or doesn't exist).

Try:

 sale_order = self.pool.get('sale.order').browse(cr, uid, my_sale_order_id, context=context)
 expected_date = sale_order.x_expected_payment_date

Note I assume you have your sale order id (my_sale_order_id) somewhere.

Also note that this code assumes it is an int or long. If you pass browse a single ID, you get a single browse record back; if you pass it a list of IDs you get a list of browse records back.