Odoo Help


Add field on dictionary after inheritance

on 5/8/14, 1:52 PM 1,168 views


I have added a new field in sale.order.line form, I want this one to be filled when choosing a product, as it's already done.

So I use inheritance to execute product_id_change, but I don't know how to add my new value in the dictionary returned :

from openerp.osv import fields, osv

class sales_order_detail_field(osv.Model): _name = 'sale.order.line' _inherit = 'sale.order.line'

_columns = {
    'detail': fields.integer('detail', size=5, help='detail'),
    'RA': fields.float('RA', size=5, help='Ristourne acquise'),
    'inv_RA': fields.float('RA', size=5, help='Ristourne acquise'),
    'lot': fields.text('lot', size=6, help='Numero de lot'),

def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False, name='', partner_id=False,
        lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):


    res=super(sales_order_detail_field, self).product_id_change(cr, uid, ids, pricelist, product, qty,
    uom, qty_uos, uos, name, partner_id,
    lang, update_tax, date_order, packaging, fiscal_position, flag, context)

    if partner_id:
        partner_obj = self.pool.get('res.partner')
        inv_RA = partner_obj.browse(cr, uid, partner_id).RA
        res['inv_RA']= inv_RA

    return res

Thanks for your help

Miku Laitinen
On 5/8/14, 2:01 PM

I had the same problem. I debugged the code and found out that the actual values are in the key 'value' of res. Try this:

res['value'].update({'inv_RA': inv_RA})

To the person who downvoted my answer (which was correct): it is good practice to leave a comment about why you don't think this is a good answer. David: Care to mark my answer as accepted?

Miku Laitinen
on 5/9/14, 8:46 AM
On 5/9/14, 8:16 AM

It works, thanks a lot!

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 5/8/14, 1:52 PM
Seen: 1168 times
Last updated: 3/16/15, 8:10 AM