コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3403 ビュー

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.

アバター
破棄
関連投稿 返信 ビュー 活動
1
1月 25
1892
2
9月 22
9644
2
4月 22
4684
0
7月 21
7323
1
3月 21
5053