Skip to content

Commit

Permalink
[MIG] l10n_es_intrastat_report: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep-s73 authored and hildickethan committed Jul 10, 2024
1 parent 276e41a commit ec025fa
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 257 deletions.
2 changes: 1 addition & 1 deletion l10n_es_intrastat_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"website": "https://github.com/OCA/l10n-spain",
"depends": ["intrastat_product", "l10n_es_aeat"],
"conflicts": ["report_intrastat"],
"external_dependencies": {"python": ["xlrd==1.2.0"]},
"data": [
"security/l10n_es_intrastat_report_security.xml",
"security/ir.model.access.csv",
"data/intrastat_transaction.xml",
"data/account_fiscal_position_template.xml",
"views/l10n_es_intrastat_product.xml",
"wizards/l10n_es_intrastat_code_import.xml",
],
Expand Down
11 changes: 0 additions & 11 deletions l10n_es_intrastat_report/data/account_fiscal_position_template.xml

This file was deleted.

5 changes: 1 addition & 4 deletions l10n_es_intrastat_report/hooks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import SUPERUSER_ID, api


def post_init_hook(cr, registry):
def post_init_hook(env):
"""Set the intrastat field of the private fiscal position records.
This is necessary for the intrastat report generation
"""
env = api.Environment(cr, SUPERUSER_ID, {})
items = env["ir.model.data"].search(
[
("model", "=", "account.fiscal.position"),
Expand Down
113 changes: 0 additions & 113 deletions l10n_es_intrastat_report/migrations/16.0.1.0.0/post-migration.py

This file was deleted.

98 changes: 0 additions & 98 deletions l10n_es_intrastat_report/migrations/16.0.1.3.0/post-migration.py

This file was deleted.

1 change: 1 addition & 0 deletions l10n_es_intrastat_report/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import l10n_es_intrastat_product_declaration
from . import stock_location
from . import template_es_common
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def _prepare_grouped_fields(self, fields_to_sum):
vals["partner_vat"] = self.partner_vat
return vals

def _prepare_declaration_line(self):
vals = super()._prepare_declaration_line()
def _prepare_declaration_line(self, line_number):
vals = super()._prepare_declaration_line(line_number)
# Avoid rounding in weight and fiscal value
vals["weight"] = 0.0
vals["amount_company_currency"] = 0.0
Expand Down
15 changes: 15 additions & 0 deletions l10n_es_intrastat_report/models/template_es_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models

from odoo.addons.account.models.chart_template import template


class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"

@template("es_common", model="account.fiscal.position")
def _get_fiscal_position(self):
return {
"fp_intra_private": {"intrastat": "b2c"},
"fp_intra": {"intrastat": "b2b"},
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ def _create_declaration(cls, declaration_type):

@classmethod
def setUpClass(cls, chart_template_ref=None):
chart_template_ref = (
"l10n_es.account_chart_template_common" or chart_template_ref
)
super().setUpClass(chart_template_ref=chart_template_ref)
super().setUpClass(chart_template_ref="es_full")
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
# Set current company to Spanish
intrastat_transport = cls.env["intrastat.transport_mode"].search([], limit=1)
Expand Down Expand Up @@ -157,7 +154,7 @@ def test_post_init_hook(self):
"res_id": fp.id,
}
)
post_init_hook(self.env.cr, None)
post_init_hook(self.env)
fp = self.env["account.fiscal.position"].browse(item.res_id)
self.assertTrue(fp.intrastat)

Expand Down
28 changes: 10 additions & 18 deletions l10n_es_intrastat_report/views/l10n_es_intrastat_product.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record
id="l10n_es_intrastat_product_computation_line_view_form"
model="ir.ui.view"
>
<field name="name">intrastat.product.computation.line.form</field>
<field name="model">intrastat.product.computation.line</field>
<field name="mode">primary</field>
<field
name="inherit_id"
ref="intrastat_product.intrastat_product_computation_line_view_form"
/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<field name="region_id" position="after">
<field name="intrastat_state_id" />
</field>
<field name="incoterm_id" position="attributes">
<attribute name="invisible" />
<attribute
name="attrs"
>{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}</attribute>
<attribute name="invisible">reporting_level != 'extended'</attribute>
<attribute name="required">reporting_level == 'extended'</attribute>
</field>
<field name="invoice_id" position="after">
<field
name="partner_vat"
attrs="{'invisible': [('declaration_type', '!=', 'dispatches')]}"
invisible="declaration_type != 'dispatches'"
/>
</field>
</field>
Expand All @@ -44,9 +42,7 @@
<field name="region_id" position="after">
<field name="intrastat_state_id" />
</field>
<field name="amount_accessory_cost_company_currency" position="attributes">
<attribute name="invisible">1</attribute>/>
</field>
<field name="amount_accessory_cost_company_currency" invisible="True" />
<field name="invoice_id" position="after">
<field name="partner_vat" />
</field>
Expand All @@ -65,15 +61,13 @@
/>
<field name="arch" type="xml">
<field name="incoterm_id" position="attributes">
<attribute name="invisible" />
<attribute
name="attrs"
>{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}</attribute>
<attribute name="invisible">reporting_level != 'extended'</attribute>
<attribute name="required">reporting_level == 'extended'</attribute>
</field>
<field name="hs_code_id" position="after">
<field
name="partner_vat"
attrs="{'invisible': [('declaration_type', '!=', 'dispatches')]}"
invisible="declaration_type != 'dispatches'"
/>
</field>
</field>
Expand Down Expand Up @@ -112,9 +106,7 @@
name="string"
>Spanish Intrastat Product Declaration</attribute>
</form>
<field name="reporting_level" position="attributes">
<attribute name="invisible" />
</field>
<field name="reporting_level" invisible="False" />
</field>
</record>
<record id="l10n_es_intrastat_product_declaration_view_tree" model="ir.ui.view">
Expand Down
Loading

0 comments on commit ec025fa

Please sign in to comment.