跳至内容
菜单
此问题已终结
1 回复
3429 查看

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
2753
3
2月 25
3964
0
5月 24
46
1
4月 24
3596
4
9月 23
5149