Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX+IMP] l10n_br_sale: Casos Sem Operação Fiscal ou Fora do Brasil #3598

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions l10n_br_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aqui, se for fora do Brasil, a operação na empresa seria False e daria no mesmo não? O codio anterior era até mais simples no caso, não se vale a pena mudar aqui... Perdi algo?


@api.model
def _default_copy_note(self):
Expand Down Expand Up @@ -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 ?

Expand Down
5 changes: 3 additions & 2 deletions l10n_br_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

@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

Check warning on line 15 in l10n_br_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_sale/models/sale_order_line.py#L15

Added line #L15 was not covered by tests

@api.model
def _fiscal_operation_domain(self):
Expand Down Expand Up @@ -180,7 +181,7 @@
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
Expand Down
Loading