mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
[REF] intrastat_base: major update intrastat V3
This commit is contained in:
committed by
Alexis de Lattre
parent
6f94b5197a
commit
c3569b2236
@@ -1,3 +1,9 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
|
||||
=====================
|
||||
Intrastat Base Module
|
||||
=====================
|
||||
|
||||
@@ -12,16 +18,39 @@ such as:
|
||||
- *l10n_be_intrastat_product*:
|
||||
the module for the Intrastat Declaration for Belgium.
|
||||
|
||||
These country-specific modules can be found in the OCA localization for those countries.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
WARNING:
|
||||
|
||||
This module conflicts with the module *report_intrastat* from the official addons.
|
||||
If you have already installed the module *report_intrastat*,
|
||||
you should uninstall it first before installing this module.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To create H.S. codes, go to the menu *Sales > Configuration > Product Categories and Attributes > H.S. Codes*.
|
||||
|
||||
Then you will be able to set the H.S. code on an product (under the *Information* tab) or on a product category. On the product form, you will also be able to set the *Country of Origin* of a product (for example, if the product is *made in China*, select *China* as *Country of Origin*).
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/91/8.0
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/
|
||||
account-financial-reporting/issues/new?body=module:%20
|
||||
intrastat_base%0Aversion:%20
|
||||
8.0.1.2%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
@@ -29,16 +58,18 @@ Contributors
|
||||
------------
|
||||
|
||||
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
|
||||
* Luc De Meyer, Noviat <info@noviat.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: http://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit http://odoo-community.org.
|
||||
|
||||
@@ -20,8 +20,4 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import country
|
||||
from . import product
|
||||
from . import tax
|
||||
from . import company
|
||||
from . import intrastat_common
|
||||
from . import models
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
{
|
||||
'name': 'Intrastat Reporting Base',
|
||||
'version': '1.1',
|
||||
'version': '1.2',
|
||||
'category': 'Intrastat',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Base module for Intrastat reporting',
|
||||
@@ -31,14 +31,16 @@
|
||||
'depends': ['base_vat'],
|
||||
'conflicts': ['report_intrastat'],
|
||||
'data': [
|
||||
'country_data.xml',
|
||||
'product_view.xml',
|
||||
'partner_view.xml',
|
||||
'country_view.xml',
|
||||
'tax_view.xml',
|
||||
'company_view.xml',
|
||||
'intrastat_view.xml',
|
||||
'data/country_data.xml',
|
||||
'views/product_template.xml',
|
||||
'views/res_partner.xml',
|
||||
'views/res_country.xml',
|
||||
'views/account_tax.xml',
|
||||
'views/res_company.xml',
|
||||
'views/intrastat.xml',
|
||||
],
|
||||
'demo': [
|
||||
'demo/intrastat_demo.xml',
|
||||
],
|
||||
'demo': ['intrastat_demo.xml'],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
27
intrastat_base/models/__init__.py
Normal file
27
intrastat_base/models/__init__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Report intrastat base module for Odoo
|
||||
# Copyright (C) 2011-2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import res_country
|
||||
from . import product_template
|
||||
from . import account_tax
|
||||
from . import res_company
|
||||
from . import intrastat_common
|
||||
@@ -85,14 +85,16 @@ class IntrastatCommon(models.AbstractModel):
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def _check_xml_schema(self, xml_root, xml_string, xsd_file):
|
||||
def _check_xml_schema(self, xml_string, xsd_file):
|
||||
'''Validate the XML file against the XSD'''
|
||||
from lxml import etree
|
||||
from StringIO import StringIO
|
||||
xsd_etree_obj = etree.parse(
|
||||
tools.file_open(xsd_file))
|
||||
official_schema = etree.XMLSchema(xsd_etree_obj)
|
||||
try:
|
||||
official_schema.assertValid(xml_root)
|
||||
t = etree.parse(StringIO(xml_string))
|
||||
official_schema.assertValid(t)
|
||||
except Exception, e:
|
||||
# if the validation of the XSD fails, we arrive here
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -124,6 +126,13 @@ class IntrastatCommon(models.AbstractModel):
|
||||
'datas_fname': filename})
|
||||
return attach.id
|
||||
|
||||
@api.multi
|
||||
def _unlink_attachments(self):
|
||||
atts = self.env['ir.attachment'].search(
|
||||
[('res_model', '=', self._name),
|
||||
('res_id', '=', self.id)])
|
||||
atts.unlink()
|
||||
|
||||
@api.model
|
||||
def _open_attach_view(self, attach_id, title='XML file'):
|
||||
'''Returns an action which opens the form view of the
|
||||
@@ -140,6 +149,20 @@ class IntrastatCommon(models.AbstractModel):
|
||||
}
|
||||
return action
|
||||
|
||||
@api.multi
|
||||
def _generate_xml(self):
|
||||
"""
|
||||
Inherit this method in the localization module
|
||||
to generate the INTRASTAT Declaration XML file
|
||||
|
||||
Returns:
|
||||
string with XML data
|
||||
|
||||
Call the _check_xml_schema() method
|
||||
before returning the XML string.
|
||||
"""
|
||||
return False
|
||||
|
||||
@api.one
|
||||
def send_reminder_email(self, mail_template_xmlid):
|
||||
mail_template = self.env.ref(mail_template_xmlid)
|
||||
@@ -27,16 +27,6 @@ from openerp.exceptions import ValidationError
|
||||
class ResCompany(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
@api.one
|
||||
@api.depends(
|
||||
'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email')
|
||||
def _compute_intrastat_email_list(self):
|
||||
emails = []
|
||||
for user in self.intrastat_remind_user_ids:
|
||||
if user.email:
|
||||
emails.append(user.email)
|
||||
self.intrastat_email_list = ','.join(emails)
|
||||
|
||||
intrastat_remind_user_ids = fields.Many2many(
|
||||
'res.users', column1='company_id', column2='user_id',
|
||||
string="Users Receiving the Intrastat Reminder",
|
||||
@@ -46,6 +36,16 @@ class ResCompany(models.Model):
|
||||
compute='_compute_intrastat_email_list',
|
||||
string='List of emails of Users Receiving the Intrastat Reminder')
|
||||
|
||||
@api.one
|
||||
@api.depends(
|
||||
'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email')
|
||||
def _compute_intrastat_email_list(self):
|
||||
emails = []
|
||||
for user in self.intrastat_remind_user_ids:
|
||||
if user.email:
|
||||
emails.append(user.email)
|
||||
self.intrastat_email_list = ','.join(emails)
|
||||
|
||||
@api.one
|
||||
@api.constrains('intrastat_remind_user_ids')
|
||||
def _check_intrastat_remind_users(self):
|
||||
@@ -17,7 +17,7 @@
|
||||
parent="account.menu_finance_configuration" sequence="50"/>
|
||||
|
||||
|
||||
<record id="intrastat_result_view" model="ir.ui.view">
|
||||
<record id="intrastat_result_view_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.result_view_form</field>
|
||||
<field name="model">intrastat.result.view</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -32,7 +32,7 @@
|
||||
</record>
|
||||
|
||||
<!-- there is no native search view, so I can't inherit -->
|
||||
<record id="view_country_search" model="ir.ui.view">
|
||||
<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">
|
||||
Reference in New Issue
Block a user