Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3421 Переглядів

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
серп. 25
2751
3
лют. 25
3958
0
трав. 24
46
1
квіт. 24
3596
4
вер. 23
5147