Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3400 Visualizzazioni

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.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
gen 25
1889
2
set 22
9636
2
apr 22
4683
0
lug 21
7323
1
mar 21
5053