Skip to content

Commit

Permalink
[FIX] l10n_br_fiscal: landed inverse for invoice case
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoParadeda authored and rvalyi committed Dec 8, 2024
1 parent 91f28a4 commit e3a68b1
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions l10n_br_fiscal/models/document_mixin_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _inverse_amount_landed_cost(self, field_name):
Set landed costs values to the document lines; rate by amount.
Args:
field_name: "freight_value|insurance_value|other_value"
field_name: "freight_value|insurance_value|other_value"
"""
for record in self.filtered(lambda doc: doc._get_product_amount_lines()):
if (
Expand Down Expand Up @@ -179,14 +179,23 @@ def _inverse_amount_landed_cost(self, field_name):
for line in record._get_product_amount_lines():
line._onchange_fiscal_taxes()
record._fields["amount_total"].compute_value(record)
record.write(
{
name: value
for name, value in record._cache.items()
if record._fields[name].compute == "_amount_all"

# Case Sale, Purchase or POS
vals = {}
for name, value in record._cache.items():
if (
record._fields[name].compute == "_amount_all"
and not record._fields[name].inverse
}
)
):
vals[name] = value
if vals:
record.write(vals)
# Case invoice (account.move has not compute named '_amount_all')
elif hasattr(record, "move_ids"):
record = record.with_context(check_move_validity=False)
record.move_ids.invoice_line_ids._onchange_price_subtotal()
record.move_ids.invoice_line_ids._onchange_mark_recompute_taxes()
record.move_ids._onchange_invoice_line_ids()

def _inverse_amount_freight(self):
return self._inverse_amount_landed_cost("freight_value")
Expand Down

0 comments on commit e3a68b1

Please sign in to comment.