Skip to content

Commit

Permalink
[FIX] force imported move to have proper UOM
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed Apr 19, 2024
1 parent a0a91a0 commit 3fde373
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 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 @@ -812,4 +812,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
5 changes: 5 additions & 0 deletions l10n_br_account/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,3 +646,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 3fde373

Please sign in to comment.