diff --git a/l10n_br_account/models/account_move.py b/l10n_br_account/models/account_move.py index 41cca40aba63..7f8b03c2b8e7 100644 --- a/l10n_br_account/models/account_move.py +++ b/l10n_br_account/models/account_move.py @@ -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 diff --git a/l10n_br_account/models/account_move_line.py b/l10n_br_account/models/account_move_line.py index a962e059a9a2..533529f07260 100644 --- a/l10n_br_account/models/account_move_line.py +++ b/l10n_br_account/models/account_move_line.py @@ -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()