Remove intrastat from res.country

Remove useless code from intrastat.common
This commit is contained in:
Alexis de Lattre
2021-01-22 18:01:18 +01:00
parent fea0caba24
commit 5a4f6876cc
8 changed files with 5 additions and 183 deletions

View File

@@ -15,10 +15,8 @@
"excludes": ["account_intrastat"],
"data": [
"security/ir.model.access.csv",
"data/country_data.xml",
"views/product_template.xml",
"views/res_partner.xml",
"views/res_country.xml",
"views/res_config_settings.xml",
"views/intrastat.xml",
"views/account_fiscal_position.xml",

View File

@@ -1,87 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="base.fr" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.de" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.at" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.cy" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.dk" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.es" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.ee" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.fi" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.gr" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.hu" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.ie" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.it" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.lv" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.lt" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.lu" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.mt" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.nl" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.pl" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.pt" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.sk" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.cz" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.uk" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.si" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.se" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.ro" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.bg" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.be" model="res.country">
<field name="intrastat" eval="True" />
</record>
<record id="base.hr" model="res.country">
<field name="intrastat" eval="True" />
</record>
</odoo>

View File

@@ -1,4 +1,3 @@
from . import res_country
from . import product_template
from . import res_company
from . import intrastat_common

View File

@@ -9,5 +9,7 @@ class AccountMove(models.Model):
_inherit = "account.move"
intrastat_fiscal_position = fields.Boolean(
related="fiscal_position_id.intrastat", store=True,
string="Intrastat Fiscal Position")
related="fiscal_position_id.intrastat",
store=True,
string="Intrastat Fiscal Position",
)

View File

@@ -25,18 +25,6 @@ class IntrastatCommon(models.AbstractModel):
# use read_group() instead, but then the code depends on
# the line object, so it can't be factorized here
def _check_generate_lines(self):
"""Check wether all requirements are met for generating lines."""
for this in self:
if not this.company_id:
raise UserError(_("Company not yet set on intrastat report."))
company = this.company_id
if not company.country_id:
raise UserError(
_("The country is not set on the company '%s'.") % company.name
)
return True
def _check_generate_xml(self):
for this in self:
if not this.company_id.partner_id.vat:
@@ -44,7 +32,6 @@ class IntrastatCommon(models.AbstractModel):
_("The VAT number is not set for the partner '%s'.")
% this.company_id.partner_id.name
)
return True
@api.model
def _check_xml_schema(self, xml_bytes, xsd_file):

View File

@@ -1,13 +0,0 @@
# Copyright 2011-2020 Akretion France (http://www.akretion.com/)
# @author: <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResCountry(models.Model):
_inherit = "res.country"
intrastat = fields.Boolean(
string="EU Country", help="Set to True for all European Union countries."
)

View File

@@ -4,14 +4,7 @@ from odoo.tests.common import TransactionCase
class TestIntrastatBase(TransactionCase):
"""Tests for this module"""
def test_10_countries(self):
# check if only EU countries have the 'intrastat' bit set
france = self.env.ref("base.fr")
self.assertTrue(france.intrastat)
brazil = self.env.ref("base.br")
self.assertFalse(brazil.intrastat)
def test_20_company(self):
def test_company(self):
# add 'Demo user' to intrastat_remind_user_ids
demo_user = self.env.ref("base.user_demo")
demo_company = self.env.ref("base.main_company")

View File

@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2011-2020 Akretion France (http://www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<!-- Add intrastat field on res_country -->
<record id="view_country_tree" model="ir.ui.view">
<field name="name">intrastat.base.country.tree</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_tree" />
<field name="arch" type="xml">
<field name="code" position="after">
<field name="intrastat" />
</field>
</field>
</record>
<record id="view_country_form" model="ir.ui.view">
<field name="name">intrastat.base.country.form</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form" />
<field name="arch" type="xml">
<field name="code" position="after">
<field name="intrastat" />
</field>
</field>
</record>
<!-- there is no native search view, so I can't inherit -->
<record id="res_country_view_search" model="ir.ui.view">
<field name="name">intrastat.base.country.search</field>
<field name="model">res.country</field>
<field name="arch" type="xml">
<search string="Search Countries">
<field
name="name"
filter_domain="['|', ('name', 'ilike', self), ('code', '=', self)]"
string="Name or Code"
/>
<field name="code" />
<field name="currency_id" />
<filter
name="intrastat"
string="EU Country"
domain="[('intrastat', '=', True)]"
/>
<group string="Group By" name="groupby">
<filter
name="currency_groupby"
string="Currency"
context="{'group_by': 'currency_id'}"
/>
</group>
</search>
</field>
</record>
</odoo>