odoo-addon-l10n-es-atc-mod415 16.0.1.0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/l10n_es_atc_mod415/README.rst +87 -0
- odoo/addons/l10n_es_atc_mod415/__init__.py +3 -0
- odoo/addons/l10n_es_atc_mod415/__manifest__.py +30 -0
- odoo/addons/l10n_es_atc_mod415/data/mail_template_data.xml +94 -0
- odoo/addons/l10n_es_atc_mod415/data/tax_code_map_mod415_data.xml +91 -0
- odoo/addons/l10n_es_atc_mod415/i18n/es.po +1687 -0
- odoo/addons/l10n_es_atc_mod415/i18n/l10n_es_atc_mod415.pot +1075 -0
- odoo/addons/l10n_es_atc_mod415/models/__init__.py +5 -0
- odoo/addons/l10n_es_atc_mod415/models/account_move.py +17 -0
- odoo/addons/l10n_es_atc_mod415/models/mod415.py +241 -0
- odoo/addons/l10n_es_atc_mod415/models/res_partner.py +24 -0
- odoo/addons/l10n_es_atc_mod415/readme/CONTRIBUTORS.rst +2 -0
- odoo/addons/l10n_es_atc_mod415/readme/DESCRIPTION.rst +3 -0
- odoo/addons/l10n_es_atc_mod415/readme/INSTALL.rst +0 -0
- odoo/addons/l10n_es_atc_mod415/security/ir.model.access.csv +5 -0
- odoo/addons/l10n_es_atc_mod415/security/mod_415_security.xml +9 -0
- odoo/addons/l10n_es_atc_mod415/static/description/icon.png +0 -0
- odoo/addons/l10n_es_atc_mod415/static/description/index.html +424 -0
- odoo/addons/l10n_es_atc_mod415/tests/__init__.py +3 -0
- odoo/addons/l10n_es_atc_mod415/tests/test_l10n_es_atc_mod415.py +213 -0
- odoo/addons/l10n_es_atc_mod415/views/account_move_view.xml +13 -0
- odoo/addons/l10n_es_atc_mod415/views/mod415_templates.xml +63 -0
- odoo/addons/l10n_es_atc_mod415/views/mod415_view.xml +137 -0
- odoo/addons/l10n_es_atc_mod415/views/report_415_partner.xml +22 -0
- odoo/addons/l10n_es_atc_mod415/views/res_partner_view.xml +18 -0
- odoo_addon_l10n_es_atc_mod415-16.0.1.0.0.2.dist-info/METADATA +108 -0
- odoo_addon_l10n_es_atc_mod415-16.0.1.0.0.2.dist-info/RECORD +29 -0
- odoo_addon_l10n_es_atc_mod415-16.0.1.0.0.2.dist-info/WHEEL +5 -0
- odoo_addon_l10n_es_atc_mod415-16.0.1.0.0.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright 2018 PESOL - Angel Moya <info@pesol.es>
|
|
2
|
+
# Copyright 2019 Tecnativa - Pedro M. Baeza
|
|
3
|
+
# Copyright 2014-2023 Binhex - Nicolás Ramos (http://binhex.es)
|
|
4
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
5
|
+
|
|
6
|
+
from odoo import fields, models
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AccountMove(models.Model):
|
|
10
|
+
_inherit = "account.move"
|
|
11
|
+
|
|
12
|
+
not_in_mod415 = fields.Boolean(
|
|
13
|
+
"Force not included in 415 report",
|
|
14
|
+
help="If you mark this field, this invoice will not be included in "
|
|
15
|
+
"any ATC 415 model report.",
|
|
16
|
+
default=False,
|
|
17
|
+
)
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Copyright 2014-2023 Binhex - Nicolás Ramos (http://binhex.es)
|
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
from odoo import _, api, fields, models
|
|
6
|
+
|
|
7
|
+
KEY_TAX_MAPPING = {
|
|
8
|
+
"A": "l10n_es_atc_mod415.atc_mod415_map_a",
|
|
9
|
+
"B": "l10n_es_atc_mod415.atc_mod415_map_b",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class L10nEsAtcMod415Report(models.Model):
|
|
14
|
+
_inherit = "l10n.es.aeat.mod347.report"
|
|
15
|
+
_name = "l10n.es.atc.mod415.report"
|
|
16
|
+
_description = "ATC 415 Report"
|
|
17
|
+
_period_yearly = True
|
|
18
|
+
_period_quarterly = False
|
|
19
|
+
_period_monthly = False
|
|
20
|
+
_aeat_number = "415"
|
|
21
|
+
|
|
22
|
+
number = fields.Char(default="415")
|
|
23
|
+
partner_record_ids = fields.One2many(
|
|
24
|
+
comodel_name="l10n.es.atc.mod415.partner_record",
|
|
25
|
+
inverse_name="report_id",
|
|
26
|
+
string="Partner Records",
|
|
27
|
+
)
|
|
28
|
+
real_estate_record_ids = fields.One2many(
|
|
29
|
+
comodel_name="l10n.es.atc.mod415.real_estate_record",
|
|
30
|
+
inverse_name="report_id",
|
|
31
|
+
string="Real Estate Records",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def btn_list_records(self):
|
|
35
|
+
return {
|
|
36
|
+
"domain": "[('report_id','in'," + str(self.ids) + ")]",
|
|
37
|
+
"name": _("Partner records"),
|
|
38
|
+
"view_mode": "tree,form",
|
|
39
|
+
"res_model": "l10n.es.atc.mod415.partner_record",
|
|
40
|
+
"type": "ir.actions.act_window",
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def _account_move_line_domain(self, taxes):
|
|
44
|
+
"""Return domain for searching move lines.
|
|
45
|
+
|
|
46
|
+
:param: taxes: Taxes to look for in move lines.
|
|
47
|
+
"""
|
|
48
|
+
return [
|
|
49
|
+
("partner_id.not_in_mod415", "=", False),
|
|
50
|
+
("move_id.not_in_mod415", "=", False),
|
|
51
|
+
("date", ">=", self.date_start),
|
|
52
|
+
("date", "<=", self.date_end),
|
|
53
|
+
"|",
|
|
54
|
+
("tax_ids", "in", taxes.ids),
|
|
55
|
+
("tax_line_id", "in", taxes.ids),
|
|
56
|
+
("parent_state", "=", "posted"),
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
def _create_partner_records(self, key, map_ref, partner_record=None):
|
|
60
|
+
sign = -1 if key == "B" else 1
|
|
61
|
+
partner_record_obj = self.env["l10n.es.atc.mod415.partner_record"]
|
|
62
|
+
partner_obj = self.env["res.partner"]
|
|
63
|
+
map_line = self.env.ref(map_ref)
|
|
64
|
+
taxes = self._get_taxes(map_line)
|
|
65
|
+
domain = self._account_move_line_domain(taxes)
|
|
66
|
+
if partner_record:
|
|
67
|
+
domain += [("partner_id", "=", partner_record.partner_id.id)]
|
|
68
|
+
groups = self.env["account.move.line"].read_group(
|
|
69
|
+
domain,
|
|
70
|
+
["partner_id", "balance"],
|
|
71
|
+
["partner_id"],
|
|
72
|
+
)
|
|
73
|
+
filtered_groups = list(
|
|
74
|
+
filter(lambda d: abs(d["balance"]) > self.operations_limit, groups)
|
|
75
|
+
)
|
|
76
|
+
for group in filtered_groups:
|
|
77
|
+
partner = partner_obj.browse(group["partner_id"][0])
|
|
78
|
+
vals = {
|
|
79
|
+
"report_id": self.id,
|
|
80
|
+
"partner_id": partner.id,
|
|
81
|
+
"representative_vat": "",
|
|
82
|
+
"operation_key": key,
|
|
83
|
+
"amount": sign * group["balance"],
|
|
84
|
+
}
|
|
85
|
+
vals.update(self._get_partner_347_identification(partner))
|
|
86
|
+
move_groups = self.env["account.move.line"].read_group(
|
|
87
|
+
group["__domain"],
|
|
88
|
+
["move_id", "balance"],
|
|
89
|
+
["move_id"],
|
|
90
|
+
)
|
|
91
|
+
vals["move_record_ids"] = [
|
|
92
|
+
(
|
|
93
|
+
0,
|
|
94
|
+
0,
|
|
95
|
+
{
|
|
96
|
+
"move_id": move_group["move_id"][0],
|
|
97
|
+
"amount": sign * move_group["balance"],
|
|
98
|
+
},
|
|
99
|
+
)
|
|
100
|
+
for move_group in move_groups
|
|
101
|
+
]
|
|
102
|
+
if partner_record:
|
|
103
|
+
vals["move_record_ids"][0:0] = [
|
|
104
|
+
(2, x) for x in partner_record.move_record_ids.ids
|
|
105
|
+
]
|
|
106
|
+
partner_record.write(vals)
|
|
107
|
+
else:
|
|
108
|
+
partner_record_obj.create(vals)
|
|
109
|
+
|
|
110
|
+
def _create_cash_moves(self):
|
|
111
|
+
partner_obj = self.env["res.partner"]
|
|
112
|
+
move_line_obj = self.env["account.move.line"]
|
|
113
|
+
cash_journals = self.env["account.journal"].search(
|
|
114
|
+
[("type", "=", "cash")],
|
|
115
|
+
)
|
|
116
|
+
if not cash_journals:
|
|
117
|
+
return
|
|
118
|
+
domain = [
|
|
119
|
+
("account_id.account_type", "=", "asset_receivable"),
|
|
120
|
+
("journal_id", "in", cash_journals.ids),
|
|
121
|
+
("date", ">=", self.date_start),
|
|
122
|
+
("date", "<=", self.date_end),
|
|
123
|
+
("partner_id.not_in_mod415", "=", False),
|
|
124
|
+
]
|
|
125
|
+
cash_groups = move_line_obj.read_group(
|
|
126
|
+
domain, ["partner_id", "balance"], ["partner_id"]
|
|
127
|
+
)
|
|
128
|
+
for cash_group in cash_groups:
|
|
129
|
+
partner = partner_obj.browse(cash_group["partner_id"][0])
|
|
130
|
+
partner_record_obj = self.env["l10n.es.atc.mod415.partner_record"]
|
|
131
|
+
amount = abs(cash_group["balance"])
|
|
132
|
+
if amount > self.received_cash_limit:
|
|
133
|
+
move_lines = move_line_obj.search(cash_group["__domain"])
|
|
134
|
+
partner_record = partner_record_obj.search(
|
|
135
|
+
[
|
|
136
|
+
("partner_id", "=", partner.id),
|
|
137
|
+
("operation_key", "=", "B"),
|
|
138
|
+
("report_id", "=", self.id),
|
|
139
|
+
]
|
|
140
|
+
)
|
|
141
|
+
if partner_record:
|
|
142
|
+
partner_record.write(
|
|
143
|
+
{
|
|
144
|
+
"cash_record_ids": [(6, 0, move_lines.ids)],
|
|
145
|
+
"cash_amount": amount,
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
else:
|
|
149
|
+
vals = {
|
|
150
|
+
"report_id": self.id,
|
|
151
|
+
"partner_id": partner.id,
|
|
152
|
+
"representative_vat": "",
|
|
153
|
+
"operation_key": "B",
|
|
154
|
+
"amount": 0,
|
|
155
|
+
"cash_amount": amount,
|
|
156
|
+
"cash_record_ids": [(6, 0, move_lines.ids)],
|
|
157
|
+
}
|
|
158
|
+
vals.update(self._get_partner_347_identification(partner))
|
|
159
|
+
partner_record_obj.create(vals)
|
|
160
|
+
|
|
161
|
+
def calculate(self):
|
|
162
|
+
for report in self:
|
|
163
|
+
# Delete previous partner records
|
|
164
|
+
report.partner_record_ids.unlink()
|
|
165
|
+
with self.env.norecompute():
|
|
166
|
+
self._create_partner_records("A", KEY_TAX_MAPPING["A"])
|
|
167
|
+
self._create_partner_records("B", KEY_TAX_MAPPING["B"])
|
|
168
|
+
self._create_cash_moves()
|
|
169
|
+
self.flush_model()
|
|
170
|
+
report.partner_record_ids.calculate_quarter_totals()
|
|
171
|
+
return True
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class L10nEsAtcMod415PartnerRecord(models.Model):
|
|
175
|
+
_inherit = "l10n.es.aeat.mod347.partner_record"
|
|
176
|
+
_name = "l10n.es.atc.mod415.partner_record"
|
|
177
|
+
_description = "Partner Record"
|
|
178
|
+
_rec_name = "partner_vat"
|
|
179
|
+
_order = "check_ok asc,id"
|
|
180
|
+
|
|
181
|
+
@api.model
|
|
182
|
+
def _default_record_id(self):
|
|
183
|
+
return self.env.context.get("report_id", False)
|
|
184
|
+
|
|
185
|
+
report_id = fields.Many2one(
|
|
186
|
+
comodel_name="l10n.es.atc.mod415.report",
|
|
187
|
+
string="Modelo 415",
|
|
188
|
+
ondelete="cascade",
|
|
189
|
+
default=_default_record_id,
|
|
190
|
+
)
|
|
191
|
+
move_record_ids = fields.One2many(
|
|
192
|
+
comodel_name="l10n.es.atc.mod415.move.record",
|
|
193
|
+
inverse_name="partner_record_id",
|
|
194
|
+
string="Move records",
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
@api.model
|
|
198
|
+
def _get_partner_report_email_template(self):
|
|
199
|
+
return self.env.ref("l10n_es_atc_mod415.email_template_415")
|
|
200
|
+
|
|
201
|
+
def button_print(self):
|
|
202
|
+
return self.env.ref("l10n_es_atc_mod415.415_partner").report_action(self)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class L10nEsAtcMod415RealStateRecord(models.Model):
|
|
206
|
+
_inherit = "l10n.es.aeat.mod347.real_estate_record"
|
|
207
|
+
_name = "l10n.es.atc.mod415.real_estate_record"
|
|
208
|
+
_description = "Real Estate Record"
|
|
209
|
+
_rec_name = "reference"
|
|
210
|
+
_order = "check_ok asc,id"
|
|
211
|
+
|
|
212
|
+
@api.model
|
|
213
|
+
def _default_record_id(self):
|
|
214
|
+
return self.env.context.get("report_id", False)
|
|
215
|
+
|
|
216
|
+
report_id = fields.Many2one(
|
|
217
|
+
comodel_name="l10n.es.atc.mod415.report",
|
|
218
|
+
string="Modelo 415",
|
|
219
|
+
ondelete="cascade",
|
|
220
|
+
index=1,
|
|
221
|
+
default=_default_record_id,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class L10nEsAtcMod415MoveRecord(models.Model):
|
|
226
|
+
_inherit = "l10n.es.aeat.mod347.move.record"
|
|
227
|
+
_name = "l10n.es.atc.mod415.move.record"
|
|
228
|
+
_description = "Move Record"
|
|
229
|
+
|
|
230
|
+
@api.model
|
|
231
|
+
def _default_partner_record(self):
|
|
232
|
+
return self.env.context.get("partner_record_id", False)
|
|
233
|
+
|
|
234
|
+
partner_record_id = fields.Many2one(
|
|
235
|
+
comodel_name="l10n.es.atc.mod415.partner_record",
|
|
236
|
+
string="Partner record",
|
|
237
|
+
required=True,
|
|
238
|
+
ondelete="cascade",
|
|
239
|
+
index=True,
|
|
240
|
+
default=_default_partner_record,
|
|
241
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright 2018 PESOL - Angel Moya <info@pesol.es>
|
|
2
|
+
# Copyright 2019 Tecnativa - Pedro M. Baeza
|
|
3
|
+
# Copyright 2014-2023 Binhex - Nicolás Ramos (http://binhex.es)
|
|
4
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
5
|
+
|
|
6
|
+
from odoo import api, fields, models
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ResPartner(models.Model):
|
|
10
|
+
_inherit = "res.partner"
|
|
11
|
+
|
|
12
|
+
not_in_mod415 = fields.Boolean(
|
|
13
|
+
"Not included in 415 report",
|
|
14
|
+
help="If you mark this field, this partner will not be included in "
|
|
15
|
+
"any ATC 415 model report, independently from the total "
|
|
16
|
+
"amount of its operations.",
|
|
17
|
+
default=False,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
@api.model
|
|
21
|
+
def _commercial_fields(self):
|
|
22
|
+
res = super()._commercial_fields()
|
|
23
|
+
res += ["not_in_mod415"]
|
|
24
|
+
return res
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
|
2
|
+
"access_l10n_es_atc_mod415_manager","l10n_es_atc_mod415 manager","model_l10n_es_atc_mod415_report","l10n_es_atc.group_account_atc",1,1,1,1
|
|
3
|
+
"access_l10n_es_atc_mod415_partner_manager","l10n_es_atc_mod415_partner manager","model_l10n_es_atc_mod415_partner_record","l10n_es_atc.group_account_atc",1,1,1,1
|
|
4
|
+
"access_l10n_es_atc_mod415_real_estate_manager","l10n_es_atc_mod415_real_estate manager","model_l10n_es_atc_mod415_real_estate_record","l10n_es_atc.group_account_atc",1,1,1,1
|
|
5
|
+
"access_l10n_es_atc_mod415_move_manager","l10n_es_atc_mod415_move manager","model_l10n_es_atc_mod415_move_record","l10n_es_atc.group_account_atc",1,1,1,1
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<odoo>
|
|
3
|
+
<record id="l10n_es_atc_mod415_report_rule" model="ir.rule">
|
|
4
|
+
<field name="name">ATC Mod 415 multi-company</field>
|
|
5
|
+
<field ref="model_l10n_es_atc_mod415_report" name="model_id" />
|
|
6
|
+
<field eval="True" name="global" />
|
|
7
|
+
<field name="domain_force">[('company_id', 'in', company_ids + [False])]</field>
|
|
8
|
+
</record>
|
|
9
|
+
</odoo>
|
|
Binary file
|