Skip to content
Merged
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_intrastat_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Contributors
* Pedro M. Baeza
* João Marques
* Víctor Martínez
* Juan Carlos Oñate

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

def _update_computation_line_vals(self, inv_line, line_vals, notedict):
result = super()._update_computation_line_vals(inv_line, line_vals, notedict)
if self.company_id.country_id.code != "ES":
return result

Check warning on line 38 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L38

Added line #L38 was not covered by tests
intrastat_state = self._get_intrastat_state(inv_line)
if intrastat_state:
line_vals["intrastat_state_id"] = intrastat_state.id
Expand Down Expand Up @@ -71,6 +73,8 @@
- companies subject to arrivals or dispatches only
"""
domain = super()._prepare_invoice_domain()[:-1]
if self.company_id.country_id.code != "ES":
return super()._prepare_invoice_domain()

Check warning on line 77 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L77

Added line #L77 was not covered by tests
if self.declaration_type == "arrivals":
domain.append(("move_type", "in", ("in_invoice", "out_refund")))
elif self.declaration_type == "dispatches":
Expand All @@ -82,6 +86,8 @@

def _attach_xml_file(self, xml_string, declaration_name):
attach_id = super()._attach_xml_file(xml_string, declaration_name)
if self.company_id.country_id.code != "ES":
return attach_id

Check warning on line 90 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L90

Added line #L90 was not covered by tests
self.ensure_one()
attach = self.env["ir.attachment"].browse(attach_id)
filename = "{}_{}.csv".format(self.year_month, declaration_name)
Expand Down Expand Up @@ -158,19 +164,21 @@
"data": {"dynamic_report": True},
}

@api.model
def _xls_computation_line_fields(self):
res = super()._xls_computation_line_fields()
if self.company_id.country_id.code != "ES":
Comment thread
juancarlosonate-tecnativa marked this conversation as resolved.
return res

Check warning on line 170 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L170

Added line #L170 was not covered by tests
if (
self.env.context.get("declaration_type", False) == "dispatches"
and int(self.env.context.get("declaration_year", 0)) >= 2022
):
res.append("partner_vat")
return res

@api.model
def _xls_declaration_line_fields(self):
res = super()._xls_declaration_line_fields()
if self.company_id.country_id.code != "ES":
return res

Check warning on line 181 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L181

Added line #L181 was not covered by tests
if (
self.env.context.get("declaration_type", False) == "dispatches"
and int(self.env.context.get("declaration_year", 0)) >= 2022
Expand All @@ -190,6 +198,8 @@

def _prepare_grouped_fields(self, fields_to_sum):
vals = super()._prepare_grouped_fields(fields_to_sum)
if self.company_id.country_id.code != "ES":
return vals

Check warning on line 202 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L202

Added line #L202 was not covered by tests
vals["intrastat_state_id"] = self.intrastat_state_id.id
# TODO: Move set incoterm_id to intrastat_product
vals["incoterm_id"] = self.incoterm_id.id
Expand All @@ -199,6 +209,8 @@

def _prepare_declaration_line(self):
vals = super()._prepare_declaration_line()
if self.company_id.country_id.code != "ES":
return vals

Check warning on line 213 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L213

Added line #L213 was not covered by tests
# Avoid rounding in weight and fiscal value
vals["weight"] = 0.0
vals["amount_company_currency"] = 0.0
Expand All @@ -215,6 +227,8 @@
@api.model
def _group_line_hashcode_fields(self):
res = super()._group_line_hashcode_fields()
if self.company_id.country_id.code != "ES":
return res

Check warning on line 231 in l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py

View check run for this annotation

Codecov / codecov/patch

l10n_es_intrastat_report/models/l10n_es_intrastat_product_declaration.py#L231

Added line #L231 was not covered by tests
res["intrastat_state_id"] = self.intrastat_state_id.id
if self.declaration_type == "dispatches" and int(self.parent_id.year) >= 2022:
res["partner_vat"] = self.partner_vat
Expand Down
1 change: 1 addition & 0 deletions l10n_es_intrastat_report/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Pedro M. Baeza
* João Marques
* Víctor Martínez
* Juan Carlos Oñate

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

Expand Down
1 change: 1 addition & 0 deletions l10n_es_intrastat_report/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<li>Pedro M. Baeza</li>
<li>João Marques</li>
<li>Víctor Martínez</li>
<li>Juan Carlos Oñate</li>
</ul>
</li>
<li><a class="reference external" href="https://www.sygel.es">Sygel</a>:<ul>
Expand Down
13 changes: 0 additions & 13 deletions l10n_es_intrastat_report/views/l10n_es_intrastat_product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,4 @@
</graph>
</field>
</record>
<record
id="l10n_es_intrastat_product_declaration_action"
model="ir.actions.act_window"
>
<field name="name">Spanish Intrastat Product Declaration</field>
<field name="res_model">intrastat.product.declaration</field>
<field name="view_mode">tree,form,graph</field>
</record>
<menuitem
id="l10n_es_intrastat_product_declaration_menu"
parent="intrastat_base.menu_intrastat_base_root"
action="l10n_es_intrastat_product_declaration_action"
/>
</odoo>