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

What is the V14 equivalent of function compute_taxes() from V10 which is is used in other module to compute the taxes on a fresh invoice created. Thanks.

 def compute_taxes(self):
        """Function used in other module to compute the taxes on a fresh invoice created (onchanges did not applied)"""
        account_invoice_tax = self.env['account.invoice.tax']
        ctx = dict(self._context)
        for invoice in self:
            # Delete non-manual tax lines
            self._cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s AND manual is False", (invoice.id,))
            if self._cr.rowcount:
                self.invalidate_cache()

            # Generate one tax line per tax, however many invoice lines it's applied to
            tax_grouped = invoice.get_taxes_values()

            # Create new tax lines
            for tax in tax_grouped.values():
                account_invoice_tax.create(tax)

        # dummy write on self to trigger recomputations
        return self.with_context(ctx).write({'invoice_line_ids': []})

アバター
破棄
最善の回答

Hello Cristina.J,

You can use invoice._recompute_tax_lines () to compute taxes

Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
2
8月 25
2755
3
2月 25
3969
0
5月 24
46
1
4月 24
3597
4
9月 23
5154