Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][l10n_br_account] fwp 3272 #3441

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions l10n_br_account/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from odoo.exceptions import UserError

from odoo.addons.l10n_br_fiscal.constants.fiscal import (
DOCUMENT_ISSUER_COMPANY,
DOCUMENT_ISSUER_PARTNER,
MODELO_FISCAL_CTE,
MODELO_FISCAL_NFE,
SITUACAO_EDOC_EM_DIGITACAO,
)

Expand All @@ -32,17 +35,17 @@
readonly=False,
)
fiscal_proxy_company_id = fields.Many2one(
string="Fiscal Company",
string="Fiscal Proxy Company",
related="company_id",
readonly=False,
)
fiscal_proxy_currency_id = fields.Many2one(
string="Fiscal Currency",
string="Fiscal Proxy Currency",
related="currency_id",
readonly=False,
)
fiscal_proxy_user_id = fields.Many2one(
string="Fiscal User",
string="Fiscal Proxy User",
related="user_id",
readonly=False,
)
Expand Down Expand Up @@ -179,9 +182,33 @@
self.message_post(body=msg)
return result

def _document_deny(self):
msg = _(

Check warning on line 186 in l10n_br_account/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/document.py#L186

Added line #L186 was not covered by tests
"Canceled due to the denial of document %(document_number)s",
document_number=self.document_number,
)
self.cancel_move_ids()
self.message_post(body=msg)

Check warning on line 191 in l10n_br_account/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/document.py#L190-L191

Added lines #L190 - L191 were not covered by tests

def action_document_confirm(self):
result = super().action_document_confirm()
if not self._context.get("skip_post"):
move_ids = self.move_ids.filtered(lambda move: move.state == "draft")
move_ids._post()
return result

def action_document_back2draft(self):
result = super().action_document_back2draft()

Check warning on line 201 in l10n_br_account/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/document.py#L201

Added line #L201 was not covered by tests
if self.move_ids:
self.move_ids.button_draft()
return result

Check warning on line 204 in l10n_br_account/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/document.py#L203-L204

Added lines #L203 - L204 were not covered by tests

def exec_after_SITUACAO_EDOC_DENEGADA(self, old_state, new_state):
self.ensure_one()
models_cancel_on_deny = [MODELO_FISCAL_NFE, MODELO_FISCAL_CTE]

Check warning on line 208 in l10n_br_account/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/document.py#L207-L208

Added lines #L207 - L208 were not covered by tests
if (
self.document_type_id.code in models_cancel_on_deny
and self.issuer == DOCUMENT_ISSUER_COMPANY
):
self._document_deny()
return super().exec_after_SITUACAO_EDOC_DENEGADA(old_state, new_state)

Check warning on line 214 in l10n_br_account/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account/models/document.py#L213-L214

Added lines #L213 - L214 were not covered by tests
Loading