Skip to content

Commit

Permalink
[FIX] force imported account move to have proper UOM
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed Nov 14, 2023
1 parent 24a03b7 commit b1dc5a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions l10n_br_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,4 +854,7 @@ def import_fiscal_document(
line_form.fiscal_operation_id = self.fiscal_operation_id
line_form.fiscal_document_line_id = line
move_form.save()
move = self.env["account.move"].browse(move_form.id)
for line in move.invoice_line_ids:
line.product_uom_id = line.fiscal_document_line_id.uom_id.id
return move_form
7 changes: 5 additions & 2 deletions l10n_br_account/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,6 @@ def _onchange_fiscal_document_line_id(self):
setattr(self, field, value[0])
else:
setattr(self, field, value)
# override the default product uom (set by the onchange):
self.product_uom_id = self.fiscal_document_line_id.uom_id.id

@api.onchange("fiscal_tax_ids")
def _onchange_fiscal_tax_ids(self):
Expand Down Expand Up @@ -676,3 +674,8 @@ def _get_amount_credit_debit_model(
"debit": balance > 0.0 and balance or 0.0,
"credit": balance < 0.0 and -balance or 0.0,
}

@api.constrains("product_uom_id")
def _check_product_uom_category_id(self):
not_imported = self.filtered(lambda line: not line._is_imported())
return super(AccountMoveLine, not_imported)._check_product_uom_category_id()

0 comments on commit b1dc5a2

Please sign in to comment.