Skip to content

Commit

Permalink
Merge PR #3352 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by antoniospneto
  • Loading branch information
OCA-git-bot committed Sep 10, 2024
2 parents 32fa12c + 136942a commit f6a4731
Show file tree
Hide file tree
Showing 68 changed files with 2,402 additions and 399 deletions.
5 changes: 3 additions & 2 deletions l10n_br_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Brazilian Localization Account",
"name": "Invoicing and accounting entries for Brazil",
"summary": "Invoicing and accounting entries for Brazil",
"category": "Localisation",
"license": "AGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-brazil",
"version": "15.0.2.8.0",
"version": "15.0.2.9.0",
"development_status": "Beta",
"maintainers": ["renatonlima", "rvalyi"],
"depends": [
Expand Down
35 changes: 6 additions & 29 deletions l10n_br_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,35 +596,12 @@ def action_document_back2draft(self):
move.button_cancel()
move.button_draft()

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

self.mapped("fiscal_document_id").filtered(
lambda d: d.document_type_id
).action_document_confirm()

# TODO FIXME
# Deixar a migração das funcionalidades do refund por último.
# Verificar se ainda haverá necessidade desse código.

# for record in self.filtered(lambda i: i.refund_move_id):
# if record.state == "open":
# # Ao confirmar uma fatura/documento fiscal se é uma devolução
# # é feito conciliado com o documento de origem para abater
# # o valor devolvido pelo documento de refund
# to_reconcile_lines = self.env["account.move.line"]
# for line in record.move_id.line_ids:
# if line.account_id.id == record.account_id.id:
# to_reconcile_lines += line
# if line.reconciled:
# line.remove_move_reconcile()
# for line in record.refund_move_id.move_id.line_ids:
# if line.account_id.id == record.refund_move_id.account_id.id:
# to_reconcile_lines += line

# to_reconcile_lines.filtered(lambda l: l.reconciled).reconcile()

return result
def _post(self, soft=True):
for move in self.with_context(skip_post=True):
move.fiscal_document_ids.filtered(
lambda d: d.document_type_id
).action_document_confirm()
return super()._post(soft=soft)

def view_xml(self):
self.ensure_one_doc()
Expand Down
7 changes: 7 additions & 0 deletions l10n_br_account/models/fiscal_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,10 @@ def _document_correction(self, justificative):
msg = "Carta de correção: {}".format(justificative)
self.message_post(body=msg)
return result

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
1 change: 0 additions & 1 deletion l10n_br_account/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import account_move_reversal
from . import wizard_document_invalidate
13 changes: 0 additions & 13 deletions l10n_br_account/wizards/wizard_document_invalidate.py

This file was deleted.

14 changes: 2 additions & 12 deletions l10n_br_fiscal/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

{
"name": "Módulo fiscal brasileiro",
"summary": "Brazilian fiscal core module.",
"summary": "Fiscal module/tax engine for Brazil",
"category": "Localisation",
"license": "AGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"maintainers": ["renatonlima"],
"website": "https://github.com/OCA/l10n-brazil",
"development_status": "Production/Stable",
"version": "15.0.1.20.4",
"version": "15.0.2.0.0",
"depends": [
"product",
"l10n_br_base",
Expand Down Expand Up @@ -84,16 +84,6 @@
"views/invalidate_number_view.xml",
"views/city_taxation_code.xml",
"views/operation_dashboard_view.xml",
"views/document_event_view.xml",
# Reports
"views/document_event_report.xml",
"views/document_event_template.xml",
# Wizards
"wizards/document_cancel_wizard.xml",
"wizards/document_correction_wizard.xml",
"wizards/document_status_wizard.xml",
"wizards/invalidate_number_wizard.xml",
"wizards/document_import_wizard_mixin.xml",
# Actions
"views/l10n_br_fiscal_action.xml",
# Menus
Expand Down
25 changes: 25 additions & 0 deletions l10n_br_fiscal/migrations/16.0.2.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2024 - TODAY - Raphaël Valyi - Akretion <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade

to_install = "l10n_br_fiscal_edi"


def install_new_modules(cr):
sql = f"""
UPDATE ir_module_module
SET state='to install'
WHERE name = '{to_install}' AND state='uninstalled'
"""
openupgrade.logged_query(cr, sql)


@openupgrade.migrate()
def migrate(env, version):
install_new_modules(env.cr)
query = """
DELETE FROM ir_model_fields
WHERE model = 'l10n_br_fiscal.document.electronic'
"""
openupgrade.logged_query(env.cr, query)
3 changes: 0 additions & 3 deletions l10n_br_fiscal/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
from . import data_abstract
from . import data_product_abstract
from . import data_ncm_nbs_abstract
from . import document_workflow
from . import document_fiscal_mixin_methods
from . import document_fiscal_mixin_fields
from . import document_fiscal_mixin
from . import document_move_mixin
from . import document_fiscal_line_mixin_methods
from . import document_fiscal_line_mixin
from . import document_event
from . import document_eletronic
from . import invalidate_number
from . import comment
from . import ibpt
Expand Down
82 changes: 62 additions & 20 deletions l10n_br_fiscal/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from odoo.exceptions import ValidationError

from ..constants.fiscal import (
DOCUMENT_ISSUER,
DOCUMENT_ISSUER_COMPANY,
DOCUMENT_ISSUER_DICT,
DOCUMENT_ISSUER_PARTNER,
Expand All @@ -20,10 +21,13 @@
MODELO_FISCAL_NFCE,
MODELO_FISCAL_NFE,
MODELO_FISCAL_NFSE,
SITUACAO_EDOC,
SITUACAO_EDOC_AUTORIZADA,
SITUACAO_EDOC_CANCELADA,
SITUACAO_EDOC_DENEGADA,
SITUACAO_EDOC_EM_DIGITACAO,
SITUACAO_EDOC_INUTILIZADA,
SITUACAO_FISCAL,
)


Expand All @@ -49,7 +53,6 @@ class Document(models.Model):
_name = "l10n_br_fiscal.document"
_inherit = [
"l10n_br_fiscal.document.mixin.fields",
"l10n_br_fiscal.document.electronic",
"l10n_br_fiscal.document.move.mixin",
"mail.thread",
]
Expand All @@ -62,6 +65,25 @@ class Document(models.Model):
index=True,
)

state_edoc = fields.Selection(
selection=SITUACAO_EDOC,
string="Situação e-doc",
default=SITUACAO_EDOC_EM_DIGITACAO,
copy=False,
required=True,
readonly=True,
# tracking=True,
index=True,
)

state_fiscal = fields.Selection(
selection=SITUACAO_FISCAL,
string="Situação Fiscal",
copy=False,
# tracking=True,
index=True,
)

fiscal_operation_id = fields.Many2one(
domain="[('state', '=', 'approved'), "
"'|', ('fiscal_operation_type', '=', fiscal_operation_type),"
Expand Down Expand Up @@ -140,23 +162,6 @@ class Document(models.Model):
default=EDOC_PURPOSE_NORMAL,
)

event_ids = fields.One2many(
comodel_name="l10n_br_fiscal.event",
inverse_name="document_id",
string="Events",
copy=False,
readonly=True,
)

correction_event_ids = fields.One2many(
comodel_name="l10n_br_fiscal.event",
inverse_name="document_id",
domain=[("type", "=", "14")],
string="Correction Events",
copy=False,
readonly=True,
)

document_type = fields.Char(
string="Document Type Code",
related="document_type_id.code",
Expand All @@ -171,10 +176,16 @@ class Document(models.Model):
copy=False,
)

# Você não vai poder fazer isso em modelos que já tem state
# TODO Porque não usar o campo state do fiscal.document???
# this related "state" field is required for the status bar widget
# while state_edoc avoids colliding with the state field
# of objects where the fiscal mixin might be injected.
state = fields.Selection(related="state_edoc", string="State")

issuer = fields.Selection(
selection=DOCUMENT_ISSUER,
default=DOCUMENT_ISSUER_COMPANY,
)

document_subsequent_ids = fields.One2many(
comodel_name="l10n_br_fiscal.subsequent.document",
inverse_name="source_document_id",
Expand Down Expand Up @@ -404,6 +415,37 @@ def action_create_return(self):

return action

# the following actions are meant to be implemented in other modules such as
# l10n_br_fiscal_edi. They are defined here so they can be overriden in modules
# that don't depend on l10n_br_fiscal_edi (such as l10n_br_account).
def view_pdf(self):
pass

def view_xml(self):
pass

def action_document_confirm(self):
pass

def action_document_send(self):
pass

def action_document_back2draft(self):
pass

def action_document_cancel(self):
pass

def action_document_invalidate(self):
pass

def action_document_correction(self):
pass

def exec_after_SITUACAO_EDOC_DENEGADA(self, old_state, new_state):
# see https://github.com/OCA/l10n-brazil/pull/3272
pass

def _get_email_template(self, state):
self.ensure_one()
return self.document_type_id.document_email_ids.search(
Expand Down
44 changes: 0 additions & 44 deletions l10n_br_fiscal/models/invalidate_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,50 +82,6 @@ class InvalidateNumber(models.Model):
default="draft",
)

event_ids = fields.One2many(
comodel_name="l10n_br_fiscal.event",
inverse_name="invalidate_number_id",
string="Events",
readonly=True,
states={"done": [("readonly", True)]},
)

# Authorization Event Related Fields
authorization_event_id = fields.Many2one(
comodel_name="l10n_br_fiscal.event",
string="Authorization Event",
readonly=True,
copy=False,
)

authorization_date = fields.Datetime(
string="Authorization Date",
readonly=True,
related="authorization_event_id.protocol_date",
)

authorization_protocol = fields.Char(
string="Authorization Protocol",
related="authorization_event_id.protocol_number",
readonly=True,
)

send_file_id = fields.Many2one(
comodel_name="ir.attachment",
related="authorization_event_id.file_request_id",
string="Send Document File XML",
ondelete="restrict",
readonly=True,
)

authorization_file_id = fields.Many2one(
comodel_name="ir.attachment",
related="authorization_event_id.file_response_id",
string="Authorization File XML",
ondelete="restrict",
readonly=True,
)

@api.constrains("number_start", "number_end")
def _check_range(self):
for record in self:
Expand Down
5 changes: 0 additions & 5 deletions l10n_br_fiscal/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,9 @@
"uom_alternative_user","UOM alternative for User","model_uom_uom_alternative","l10n_br_fiscal.group_user",1,0,0,0
"uom_alternative_manager","UOM alternative for Manager","model_uom_uom_alternative","l10n_br_fiscal.group_manager",1,0,0,0
"uom_alternative_maintenance","UOM alternative for Maintenance","model_uom_uom_alternative","l10n_br_fiscal.group_data_maintenance",1,1,1,1
"l10n_br_fiscal_event_user","Fiscal Document Event for User","model_l10n_br_fiscal_event","l10n_br_fiscal.group_user",1,1,1,0
"l10n_br_fiscal_invalidate_number_user","user_l10n_br_fiscal_invalidate_number","model_l10n_br_fiscal_invalidate_number","l10n_br_fiscal.group_user",1,0,0,0
"l10n_br_fiscal_invalidate_number_manager","manager_l10n_br_fiscal_invalidate_number","model_l10n_br_fiscal_invalidate_number","l10n_br_fiscal.group_manager",1,1,1,1
"l10n_br_fiscal_city_taxation_code_user","Fiscal City Taxation Code for User","model_l10n_br_fiscal_city_taxation_code","l10n_br_fiscal.group_user",1,1,1,0
"l10n_br_fiscal_city_taxation_code_manager","Fiscal City Taxation Code for Manager","model_l10n_br_fiscal_city_taxation_code","l10n_br_fiscal.group_user",1,1,1,1
"l10n_br_fiscal_base_wizard_mixin_user",l10n_br_fiscal_base_wizard_mixin,model_l10n_br_fiscal_base_wizard_mixin,base.group_user,1,1,1,1
"l10n_br_fiscal_document_cancel_wizard_user",l10n_br_fiscal_document_cancel_wizard,model_l10n_br_fiscal_document_cancel_wizard,base.group_user,1,1,1,1
"l10n_br_fiscal_document_correction_wizard_user",l10n_br_fiscal_document_correction_wizard,model_l10n_br_fiscal_document_correction_wizard,base.group_user,1,1,1,1
"l10n_br_fiscal_document_status_wizard_user",l10n_br_fiscal_document_status_wizard,model_l10n_br_fiscal_document_status_wizard,base.group_user,1,1,1,1
"l10n_br_fiscal_invalidate_number_wizard_user",l10n_br_fiscal_invalidate_number_wizard,model_l10n_br_fiscal_invalidate_number_wizard,base.group_user,1,1,1,1
"l10n_br_fiscal_document_import_wizard_mixin_user",l10n_br_fiscal_document_import_wizard_mixin_user,model_l10n_br_fiscal_document_import_wizard_mixin,base.group_user,1,1,1,1
1 change: 0 additions & 1 deletion l10n_br_fiscal/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
test_service_type,
test_subsequent_operation,
test_uom_uom,
test_workflow,
)
Loading

0 comments on commit f6a4731

Please sign in to comment.