Skip to content

Commit a60de21

Browse files
committed
Merge PR #4109 into 16.0
Signed-off-by pedrobaeza
2 parents 8317305 + 43b41ba commit a60de21

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

l10n_es_intrastat_report/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Contributors
161161
* Pedro M. Baeza
162162
* João Marques
163163
* Víctor Martínez
164+
* Juan Carlos Oñate
164165

165166
* `Sygel <https://www.sygel.es>`__:
166167

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def _get_intrastat_state(self, inv_line):
3434

3535
def _update_computation_line_vals(self, inv_line, line_vals, notedict):
3636
result = super()._update_computation_line_vals(inv_line, line_vals, notedict)
37+
if self.company_id.country_id.code != "ES":
38+
return result
3739
intrastat_state = self._get_intrastat_state(inv_line)
3840
if intrastat_state:
3941
line_vals["intrastat_state_id"] = intrastat_state.id
@@ -71,6 +73,8 @@ def _prepare_invoice_domain(self):
7173
- companies subject to arrivals or dispatches only
7274
"""
7375
domain = super()._prepare_invoice_domain()[:-1]
76+
if self.company_id.country_id.code != "ES":
77+
return super()._prepare_invoice_domain()
7478
if self.declaration_type == "arrivals":
7579
domain.append(("move_type", "in", ("in_invoice", "out_refund")))
7680
elif self.declaration_type == "dispatches":
@@ -82,6 +86,8 @@ def _generate_xml(self):
8286

8387
def _attach_xml_file(self, xml_string, declaration_name):
8488
attach_id = super()._attach_xml_file(xml_string, declaration_name)
89+
if self.company_id.country_id.code != "ES":
90+
return attach_id
8591
self.ensure_one()
8692
attach = self.env["ir.attachment"].browse(attach_id)
8793
filename = "{}_{}.csv".format(self.year_month, declaration_name)
@@ -158,19 +164,21 @@ def create_xls(self):
158164
"data": {"dynamic_report": True},
159165
}
160166

161-
@api.model
162167
def _xls_computation_line_fields(self):
163168
res = super()._xls_computation_line_fields()
169+
if self.company_id.country_id.code != "ES":
170+
return res
164171
if (
165172
self.env.context.get("declaration_type", False) == "dispatches"
166173
and int(self.env.context.get("declaration_year", 0)) >= 2022
167174
):
168175
res.append("partner_vat")
169176
return res
170177

171-
@api.model
172178
def _xls_declaration_line_fields(self):
173179
res = super()._xls_declaration_line_fields()
180+
if self.company_id.country_id.code != "ES":
181+
return res
174182
if (
175183
self.env.context.get("declaration_type", False) == "dispatches"
176184
and int(self.env.context.get("declaration_year", 0)) >= 2022
@@ -190,6 +198,8 @@ class IntrastatProductComputationLine(models.Model):
190198

191199
def _prepare_grouped_fields(self, fields_to_sum):
192200
vals = super()._prepare_grouped_fields(fields_to_sum)
201+
if self.company_id.country_id.code != "ES":
202+
return vals
193203
vals["intrastat_state_id"] = self.intrastat_state_id.id
194204
# TODO: Move set incoterm_id to intrastat_product
195205
vals["incoterm_id"] = self.incoterm_id.id
@@ -199,6 +209,8 @@ def _prepare_grouped_fields(self, fields_to_sum):
199209

200210
def _prepare_declaration_line(self):
201211
vals = super()._prepare_declaration_line()
212+
if self.company_id.country_id.code != "ES":
213+
return vals
202214
# Avoid rounding in weight and fiscal value
203215
vals["weight"] = 0.0
204216
vals["amount_company_currency"] = 0.0
@@ -215,6 +227,8 @@ def _prepare_declaration_line(self):
215227
@api.model
216228
def _group_line_hashcode_fields(self):
217229
res = super()._group_line_hashcode_fields()
230+
if self.company_id.country_id.code != "ES":
231+
return res
218232
res["intrastat_state_id"] = self.intrastat_state_id.id
219233
if self.declaration_type == "dispatches" and int(self.parent_id.year) >= 2022:
220234
res["partner_vat"] = self.partner_vat

l10n_es_intrastat_report/readme/CONTRIBUTORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Pedro M. Baeza
88
* João Marques
99
* Víctor Martínez
10+
* Juan Carlos Oñate
1011

1112
* `Sygel <https://www.sygel.es>`__:
1213

l10n_es_intrastat_report/static/description/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
513513
<li>Pedro M. Baeza</li>
514514
<li>João Marques</li>
515515
<li>Víctor Martínez</li>
516+
<li>Juan Carlos Oñate</li>
516517
</ul>
517518
</li>
518519
<li><a class="reference external" href="https://www.sygel.es">Sygel</a>:<ul>

l10n_es_intrastat_report/views/l10n_es_intrastat_product.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,4 @@
165165
</graph>
166166
</field>
167167
</record>
168-
<record
169-
id="l10n_es_intrastat_product_declaration_action"
170-
model="ir.actions.act_window"
171-
>
172-
<field name="name">Spanish Intrastat Product Declaration</field>
173-
<field name="res_model">intrastat.product.declaration</field>
174-
<field name="view_mode">tree,form,graph</field>
175-
</record>
176-
<menuitem
177-
id="l10n_es_intrastat_product_declaration_menu"
178-
parent="intrastat_base.menu_intrastat_base_root"
179-
action="l10n_es_intrastat_product_declaration_action"
180-
/>
181168
</odoo>

0 commit comments

Comments
 (0)