diff --git a/l10n_br_sale/models/sale_order.py b/l10n_br_sale/models/sale_order.py index 1006f43634dc..345e4cada79b 100644 --- a/l10n_br_sale/models/sale_order.py +++ b/l10n_br_sale/models/sale_order.py @@ -15,7 +15,8 @@ class SaleOrder(models.Model): @api.model def _default_fiscal_operation(self): - return self.env.company.sale_fiscal_operation_id + if self.env.company.country_id.code == "BR": + return self.env.company.sale_fiscal_operation_id @api.model def _default_copy_note(self): @@ -100,8 +101,10 @@ def _get_amount_lines(self): ) def _compute_amounts(self): """Compute the total amounts of the SO.""" - for order in self: + result = super()._compute_amounts() + for order in self.filtered(lambda ln: ln.fiscal_operation_id): order._compute_fiscal_amount() + return result # TODO v16 override _compute_tax_totals ? diff --git a/l10n_br_sale/models/sale_order_line.py b/l10n_br_sale/models/sale_order_line.py index e7e0ae088922..e1314085ef1a 100644 --- a/l10n_br_sale/models/sale_order_line.py +++ b/l10n_br_sale/models/sale_order_line.py @@ -11,7 +11,8 @@ class SaleOrderLine(models.Model): @api.model def _default_fiscal_operation(self): - return self.env.company.sale_fiscal_operation_id + if self.order_id.fiscal_operation_id: + return self.env.company.sale_fiscal_operation_id @api.model def _fiscal_operation_domain(self): @@ -180,7 +181,7 @@ def _get_protected_fields(self): def _compute_amount(self): """Compute the amounts of the SO line.""" result = super()._compute_amount() - for line in self: + for line in self.filtered(lambda ln: ln.fiscal_operation_id): # Update taxes fields line._update_fiscal_taxes() # Call mixin compute method