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

[16.0][IMP] (l10n_es_aeat_mod303, l10n_es_aeat_mod390): Valores por defecto en compañias #3918

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions l10n_es_aeat_mod303/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"data/l10n.es.aeat.mod303.report.activity.code.csv",
"views/mod303_view.xml",
"views/l10n_es_aeat_mod303_report_activity_code_data_views.xml",
"views/res_company.xml",
"security/l10n_es_aeat_mod303_security.xml",
"security/ir.model.access.csv",
],
Expand Down
1 change: 1 addition & 0 deletions l10n_es_aeat_mod303/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import mod303
from . import res_company
98 changes: 86 additions & 12 deletions l10n_es_aeat_mod303/models/mod303.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,68 +217,92 @@ class L10nEsAeatMod303Report(models.Model):
main_activity_code = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
domain=ACTIVITY_CODE_DOMAIN,
states=NON_EDITABLE_ON_DONE,
string="Código actividad principal",
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
main_activity_iae = fields.Char(
states=NON_EDITABLE_ON_DONE,
string="Epígrafe I.A.E. actividad principal",
size=4,
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_first_activity_code = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
domain=ACTIVITY_CODE_DOMAIN,
states=NON_EDITABLE_ON_DONE,
string="Código 1ª actividad",
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_first_activity_iae = fields.Char(
string="Epígrafe I.A.E. 1ª actividad",
states=NON_EDITABLE_ON_DONE,
size=4,
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_second_activity_code = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
domain=ACTIVITY_CODE_DOMAIN,
states=NON_EDITABLE_ON_DONE,
string="Código 2ª actividad",
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_second_activity_iae = fields.Char(
string="Epígrafe I.A.E. 2ª actividad",
states=NON_EDITABLE_ON_DONE,
size=4,
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_third_activity_code = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
domain=ACTIVITY_CODE_DOMAIN,
states=NON_EDITABLE_ON_DONE,
string="Código 3ª actividad",
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_third_activity_iae = fields.Char(
string="Epígrafe I.A.E. 3ª actividad",
states=NON_EDITABLE_ON_DONE,
size=4,
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_fourth_activity_code = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
domain=ACTIVITY_CODE_DOMAIN,
states=NON_EDITABLE_ON_DONE,
string="Código 4ª actividad",
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_fourth_activity_iae = fields.Char(
string="Epígrafe I.A.E. 4ª actividad",
states=NON_EDITABLE_ON_DONE,
size=4,
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_fifth_activity_code = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
domain=ACTIVITY_CODE_DOMAIN,
states=NON_EDITABLE_ON_DONE,
string="Código 5ª actividad",
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
other_fifth_activity_iae = fields.Char(
string="Epígrafe I.A.E. 5ª actividad",
states=NON_EDITABLE_ON_DONE,
size=4,
readonly=False,
compute="_compute_activities_and_iae",
store=True,
)
casilla_88 = fields.Float(
string="[88] Total volumen operaciones",
Expand Down Expand Up @@ -499,6 +523,56 @@ def _compute_result_type(self):
else:
report.result_type = "C"

@api.depends("exonerated_390", "company_id")
def _compute_activities_and_iae(self):
for record in self:
if record.exonerated_390 != "2":
record.main_activity_code = record.company_id.main_activity_code_id
record.main_activity_iae = record.company_id.main_activity_iae
record.other_first_activity_code = (
record.company_id.other_first_activity_code_id
)
record.other_first_activity_iae = (
record.company_id.other_first_activity_iae
)
record.other_second_activity_code = (
record.company_id.other_second_activity_code_id
)
record.other_second_activity_iae = (
record.company_id.other_second_activity_iae
)
record.other_third_activity_code = (
record.company_id.other_third_activity_code_id
)
record.other_third_activity_iae = (
record.company_id.other_third_activity_iae
)
record.other_fourth_activity_code = (
record.company_id.other_fourth_activity_code_id
)
record.other_fourth_activity_iae = (
record.company_id.other_fourth_activity_iae
)
record.other_fifth_activity_code = (
record.company_id.other_fifth_activity_code_id
)
record.other_fifth_activity_iae = (
record.company_id.other_fifth_activity_iae
)
else:
record.main_activity_code = False
record.main_activity_iae = False
record.other_first_activity_code = False
record.other_first_activity_iae = False
record.other_second_activity_code = False
record.other_second_activity_iae = False
record.other_third_activity_code = False
record.other_third_activity_iae = False
record.other_fourth_activity_code = False
record.other_fourth_activity_iae = False
record.other_fifth_activity_code = False
record.other_fifth_activity_iae = False

@api.onchange("statement_type")
def onchange_type(self):
if self.statement_type != "C":
Expand Down
56 changes: 56 additions & 0 deletions l10n_es_aeat_mod303/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2024 Moduon Team - Emilio Pascual

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

main_activity_code_id = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
string="Código actividad principal",
)
main_activity_iae = fields.Char(
string="Epígrafe I.A.E. actividad principal",
size=4,
)
other_first_activity_code_id = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
string="Código 1ª actividad",
)
other_first_activity_iae = fields.Char(
string="Epígrafe I.A.E. 1ª actividad",
size=4,
)
other_second_activity_code_id = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
string="Código 2ª actividad",
)
other_second_activity_iae = fields.Char(
string="Epígrafe I.A.E. 2ª actividad",
size=4,
)
other_third_activity_code_id = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
string="Código 3ª actividad",
)
other_third_activity_iae = fields.Char(
string="Epígrafe I.A.E. 3ª actividad",
size=4,
)
other_fourth_activity_code_id = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
string="Código 4ª actividad",
)
other_fourth_activity_iae = fields.Char(
string="Epígrafe I.A.E. 4ª actividad",
size=4,
)
other_fifth_activity_code_id = fields.Many2one(
comodel_name="l10n.es.aeat.mod303.report.activity.code",
string="Código 5ª actividad",
)
other_fifth_activity_iae = fields.Char(
string="Epígrafe I.A.E. 5ª actividad",
size=4,
)
90 changes: 90 additions & 0 deletions l10n_es_aeat_mod303/tests/test_l10n_es_aeat_mod303.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,3 +617,93 @@ def test_model_303_negative_special_case(self):
self.model303.date_end = "2020-03-31"
self.model303.button_calculate()
self._check_tax_lines()

def test_default_values_in_company(self):
self.company.update(
{
"main_activity_code_id": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A01"
),
"main_activity_iae": "A01",
"other_first_activity_code_id": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A02"
),
"other_first_activity_iae": "A02",
"other_second_activity_code_id": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A03"
),
"other_second_activity_iae": "A03",
"other_third_activity_code_id": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A04"
),
"other_third_activity_iae": "A04",
"other_fourth_activity_code_id": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A05"
),
"other_fourth_activity_iae": "A05",
"other_fifth_activity_code_id": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_B01"
),
"other_fifth_activity_iae": "B01",
}
)
model303_2024_4T = self.model303.copy(
{
"name": "9994002024303",
"period_type": "4T",
"date_start": "2024-09-01",
"date_end": "2024-12-31",
}
)
model303_2024_4T.exonerated_390 = "1"
self.assertRecordValues(
model303_2024_4T,
[
{
"main_activity_code": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A01"
).id,
"main_activity_iae": "A01",
"other_first_activity_code": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A02"
).id,
"other_first_activity_iae": "A02",
"other_second_activity_code": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A03"
).id,
"other_second_activity_iae": "A03",
"other_third_activity_code": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A04"
).id,
"other_third_activity_iae": "A04",
"other_fourth_activity_code": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_A05"
).id,
"other_fourth_activity_iae": "A05",
"other_fifth_activity_code": self.env.ref(
"l10n_es_aeat_mod303.aeat_mod303_activity_code_B01"
).id,
"other_fifth_activity_iae": "B01",
}
],
)
model303_2024_4T.exonerated_390 = "2"
self.assertRecordValues(
model303_2024_4T,
[
{
"main_activity_code": False,
"main_activity_iae": False,
"other_first_activity_code": False,
"other_first_activity_iae": False,
"other_second_activity_code": False,
"other_second_activity_iae": False,
"other_third_activity_code": False,
"other_third_activity_iae": False,
"other_fourth_activity_code": False,
"other_fourth_activity_iae": False,
"other_fifth_activity_code": False,
"other_fifth_activity_iae": False,
}
],
)
Loading
Loading