Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3412 Widoki

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sty 25
1894
2
wrz 22
9647
2
kwi 22
4686
0
lip 21
7325
1
mar 21
5055