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

Add field on dictionary after inheritance

By
David Verove
on 5/8/14, 1:52 PM 775 views

Hello,

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={}

    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

2
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
0
David Verove
On 5/9/14, 8:16 AM

It works, thanks a lot!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

0 follower(s)

Stats

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