From 690393f777860b40aa53d42cc8767ef40bd4e0fd Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Mon, 9 Dec 2024 13:08:27 -0300 Subject: [PATCH] [TEST] l10n_br_account: tests --- l10n_br_account/models/fiscal_operation.py | 40 +++++++++++-------- .../views/l10n_br_account_action.xml | 4 +- .../views/l10n_br_account_menu.xml | 12 +++--- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/l10n_br_account/models/fiscal_operation.py b/l10n_br_account/models/fiscal_operation.py index 2720ae25f2e2..67aa7bc895d3 100644 --- a/l10n_br_account/models/fiscal_operation.py +++ b/l10n_br_account/models/fiscal_operation.py @@ -2,7 +2,8 @@ # Copyright (C) 2019 - TODAY Raphaƫl Valyi - Akretion # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from odoo import fields, models +from odoo import _, fields, models +from odoo.exceptions import UserError # from odoo.addons.account.models.account_invoice import TYPE2JOURNAL @@ -66,27 +67,34 @@ def _change_action_view(self, action): def action_create_new(self): action = super().action_create_new() if self.create_account_move: - action["res_model"] = "account.move" - action["view_id"] = self.env.ref("l10n_br_account.fiscal_invoice_form").id - action["context"] = self._change_action_view(action)["context"] + raise UserError( + _( + "This is a fiscal operation that generates account move, please " + "create the document through the Account App" + ) + ) + # action["res_model"] = "account.move" + # action["view_id"] = self.env.ref("l10n_br_account.fiscal_invoice_form").id + # action["context"] = self._change_action_view(action)["context"] return action - def open_action(self): - action = super().open_action() - if self.create_account_move: - return self._change_action_view(action) - return action + # def open_action(self): + # action = super().open_action() + # if self.create_account_move: + # return self._change_action_view(action) + # return action - def _fiscal_document_object(self): - return self.env["account.move"] + # def _fiscal_document_object(self): + # return self.env["account.move"] def _line_domain(self, company, partner, product): domain = super()._line_domain(company=company, partner=partner, product=product) - domain += [ - "|", - ("fiscal_position_id", "=", partner.property_account_position_id.id), - ("fiscal_position_id", "=", False), - ] + if self.create_account_move: + domain += [ + "|", + ("fiscal_position_id", "=", partner.property_account_position_id.id), + ("fiscal_position_id", "=", False), + ] return domain diff --git a/l10n_br_account/views/l10n_br_account_action.xml b/l10n_br_account/views/l10n_br_account_action.xml index 0ea1e1acf3f0..c3780fb1d4ed 100644 --- a/l10n_br_account/views/l10n_br_account_action.xml +++ b/l10n_br_account/views/l10n_br_account_action.xml @@ -13,7 +13,7 @@ /> @@ -52,7 +52,7 @@ /> diff --git a/l10n_br_account/views/l10n_br_account_menu.xml b/l10n_br_account/views/l10n_br_account_menu.xml index 7735d0402b24..f88db10c8847 100644 --- a/l10n_br_account/views/l10n_br_account_menu.xml +++ b/l10n_br_account/views/l10n_br_account_menu.xml @@ -12,25 +12,25 @@ - + - + - + /> -->