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

How to update a value for all the entries in a one2many field on button click?

By
Mircea
on 1/13/15, 8:42 AM 422 views

I'm trying to make it so that when I click a button on an invoice, to update the individual unit price for each invoice line by a factor specified in a custom field. I know how to put the button, and define the fields and all that, but I can't seem to figure out the python code that i need to put in my function. I've managed to create this:

    def button_convert_unitprice(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        for id in ids:
            lines = self.browse(cr, uid, id, context=context).invoice_line
            val=self.browse(cr, uid, id, context=context).x_multiplier
            for line in lines:
                line.price_unit=line.price_unit*val
        self.button_reset_taxes(cr, uid, ids, context)
        return True

Unfortunately it doesn't do aything but refresh the page, and I'm completely lost in this odoo syntax. Can someone please point me the right direction with a working example somewhere? I know this is usualy done by onchange events, but I need it to be manually on click.

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: 1/13/15, 8:42 AM
Seen: 422 times
Last updated: 3/16/15, 8:10 AM