This question has been flagged
1 Reply
2744 Views

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': []})

Avatar
Discard
Best Answer

Hello Cristina.J,

You can use invoice._recompute_tax_lines () to compute taxes

Thanks

Avatar
Discard