Monday, October 16, 2023
1 change · master
Code cleanup and technical improvements
Common tax calculation logic has been moved into shared external tax modules so Avalara and Brazil tax integrations no longer duplicate the same plumbing. This makes future tax service integrations easier to maintain while preserving the existing customer-facing tax calculation triggers for quotes, invoices, and payment flows.
Original PR description
This commit introduces *external_tax* modules to gather common code in account_avatax* and l10n_br_avatax*. When l10n_br_avatax* was developed some of the code in account_avatax was duplicated.…
This commit introduces *external_tax* modules to gather common code in account_avatax* and l10n_br_avatax*. When l10n_br_avatax* was developed some of the code in account_avatax was duplicated. Concretely this module contains: - triggers that cause a tax computation, apart from manual calculation taxes will be calculated in situations where an end customer is viewing a record (e.g. a quote sent via email) and/or has the opportunity to pay (e.g. /my/quote) - code to set tax amounts on records that support tax calculation (sale.order and account.move at the moment) - filters that help integrations determine on which records tax should be calculated Tax integration modules can now be focused on building and processing requests to external tax calculation services, and don’t need to be concerned with these low-level mechanisms anymore. In order to implement a new service the account.external.tax.mixin can be inherited on models that need tax calculation (typically sale.order and account.move). - _compute_is_tax_computed_externally() should be overridden to return True when appropriate - _get_external_taxes() will be called when appropriate and is the main entry point that should launch the external tax calculation process - _get_line_data_for_external_taxes() should be implemented to return data needed for tax calculation for that particular model - _get_date_for_external_taxes() should be overridden to return the date on which tax calculation should be based Other optional hooks are provided for uncommitting and voiding. Upgrade PR: odoo/upgrade#5151