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

Get current value [on_change]

By
dhosy
on 12/31/13, 7:02 AM 888 views

Hi everyone,

I have a on_change on a one2many to return the current sum : ProductA qty:5 ProductB qty:2 Sum :7 (5+2)

Code :

    def on_change_supply(self, cr, uid, ids, supply_list, context=None):
        values = { }
        for item in supply_list:
              total=total+item[2]['qty']
        values['sum']=total
        return {'value' : values}

But by this way i have only the current edit line: If i edit the ProductA qty i will get something like supply_list=[[1, 21, {'qty':3}], [4, 22, False]]

So i must read the qty for my Product_id 22 to get it. Is there another way to get all current value on screen? To avoid to check if i have to read to get my value or not

for value in self.browse(cr, uid, ids): column1_value = val.column1 # Using Browse method and current record ID to get all the values

Prakash
on 12/31/13, 7:10 AM

Yes but if i use : item=self.browse(cr, uid, ids,) for supply in item.supply_ids: I will not have the new edit value (3) but the value on db (5) for the ProductA

dhosy
on 12/31/13, 7:57 AM

ID is table column value using dot notation you can get product ID

Prakash
on 12/31/13, 8:24 AM

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

1 follower(s)

Stats

Asked: 12/31/13, 7:02 AM
Seen: 888 times
Last updated: 3/16/15, 8:10 AM