[MIG] intrastat_product: Migration to 11.0

* Small fixes in intrastat_base
* account_tax_template

[UPD] Update intrastat_base.pot
This commit is contained in:
Luc De Meyer
2019-04-17 20:48:49 +02:00
committed by Alexis de Lattre
parent 71ce016036
commit ea11ddb9db
10 changed files with 67 additions and 64 deletions

View File

@@ -1,5 +1,6 @@
# © 2011-2016 Akretion (http://www.akretion.com)
# © 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
# Copyright 2011-2016 Akretion (http://www.akretion.com)
# Copyright 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
# Copyright 2009-2019 Noviat (http://www.noviat.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
@@ -8,7 +9,7 @@
'category': 'Intrastat',
'license': 'AGPL-3',
'summary': 'Base module for Intrastat reporting',
'author': 'Akretion,Odoo Community Association (OCA)',
'author': 'Akretion,Noviat,Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/intrastat',
'depends': ['base_vat', 'account'],
'conflicts': ['report_intrastat'],

View File

@@ -20,7 +20,7 @@ msgid "Activate this option for shipping costs, packaging costs and all services
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:154
#: code:addons/intrastat_base/models/intrastat_common.py:151
#, python-format
msgid "Cannot delete the declaration %s because it is in Done state"
msgstr ""
@@ -36,7 +36,7 @@ msgid "Companies"
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:33
#: code:addons/intrastat_base/models/intrastat_common.py:39
#, python-format
msgid "Company not yet set on intrastat report."
msgstr ""
@@ -70,6 +70,7 @@ msgstr ""
#. module: intrastat_base
#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_exclude_from_intrastat_if_present
#: model:ir.model.fields,field_description:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present
msgid "Exclude invoice line from intrastat if this tax is present"
msgstr ""
@@ -81,6 +82,7 @@ msgstr ""
#. module: intrastat_base
#: model:ir.model.fields,help:intrastat_base.field_account_tax_exclude_from_intrastat_if_present
#: model:ir.model.fields,help:intrastat_base.field_account_tax_template_exclude_from_intrastat_if_present
msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices."
msgstr ""
@@ -177,35 +179,34 @@ msgid "Tax"
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:51
#: model:ir.model,name:intrastat_base.model_account_tax_template
msgid "Templates for Taxes"
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:52
#, python-format
msgid "The VAT number is not set for the partner '%s'."
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:41
#, python-format
msgid "The company currency must be 'EUR', but is currently '%s'."
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:37
#: code:addons/intrastat_base/models/intrastat_common.py:43
#, python-format
msgid "The country is not set on the company '%s'."
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:74
#, python-format
msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s."
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/product_template.py:23
#, python-format
msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'"
msgstr ""
#. module: intrastat_base
#: code:addons/intrastat_base/models/intrastat_common.py:73
#, python-format
msgid "Unknown Error"
msgstr ""
#. module: intrastat_base
#: model:ir.model.fields,field_description:intrastat_base.field_res_company_intrastat_remind_user_ids
#: model:ir.model.fields,field_description:intrastat_base.field_res_config_settings_intrastat_remind_user_ids

View File

@@ -1,12 +1,16 @@
# © 2010-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2010-2016 Akretion (<alexis.delattre@akretion.com>)
# Copyright 2009-2019 Noviat (http://www.noviat.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, tools, _
from odoo.exceptions import UserError
import base64
from io import BytesIO
from lxml import etree
from sys import exc_info
from traceback import format_exception
import logging
from odoo import api, fields, models, tools, _
from odoo.exceptions import UserError
logger = logging.getLogger(__name__)
@@ -50,43 +54,40 @@ class IntrastatCommon(models.AbstractModel):
return True
@api.model
def _check_xml_schema(self, xml_etree, xsd_file):
def _check_xml_schema(self, xml_string, xsd_file):
'''Validate the XML file against the XSD'''
xsd_etree_obj = etree.parse(
tools.file_open(xsd_file))
tools.file_open(xsd_file, mode='rb'))
official_schema = etree.XMLSchema(xsd_etree_obj)
try:
official_schema.assertValid(xml_etree)
except Exception as e:
# if the validation of the XSD fails, we arrive here
logger = logging.getLogger(__name__)
t = etree.parse(BytesIO(xml_string))
official_schema.assertValid(t)
except (etree.XMLSchemaParseError, etree.DocumentInvalid) as e:
logger.warning(
"The XML file is invalid against the XML Schema Definition")
xml_string = etree.tostring(
xml_etree, pretty_print=True, encoding='UTF-8',
xml_declaration=True).decode()
logger.warning(xml_string)
logger.warning(e)
raise UserError(_(
"The generated XML file is not valid against the official "
"XML Schema Definition. The generated XML file and the "
"full error have been written in the server logs. "
"Here is the error, which may give you an idea on the "
"cause of the problem : %s.")
% str(e))
return True
usererror = '%s\n\n%s' % (e.__class__.__name__, str(e))
raise UserError(usererror)
except Exception:
error = _("Unknown Error")
tb = ''.join(format_exception(*exc_info()))
error += '\n%s' % tb
logger.warning(error)
raise UserError(error)
@api.multi
def _attach_xml_file(self, xml_string, declaration_name):
'''Attach the XML file to the report_intrastat_product/service
object'''
self.ensure_one()
import base64
filename = '%s_%s.xml' % (self.year_month, declaration_name)
attach = self.env['ir.attachment'].create({
'name': filename,
'res_id': self.id,
'res_model': self._name,
'datas': base64.b64encode(xml_string),
'datas': base64.encodestring(xml_string),
'datas_fname': filename})
return attach.id

View File

@@ -1,7 +1,7 @@
# © 2010-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2010-2016 Akretion (<alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, _
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
@@ -19,8 +19,9 @@ class ProductTemplate(models.Model):
def _check_accessory_cost(self):
for this in self:
if this.is_accessory_cost and this.type != 'service':
raise ValidationError(_(
"The option 'Is accessory cost' should only be "
"activated on 'Service' products. You have activated "
"this option for the product '%s' which is of type "
"'%s'") % (this.name, this.type))
raise ValidationError(
_("The option 'Is accessory cost?' should only be "
"activated on 'Service' products. You have activated "
"this option for the product '%s' which is of type "
"'%s'") %
(this.name, this.type))

View File

@@ -1,7 +1,7 @@
# © 2013-2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2013-2017 Akretion (<alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, _
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError

View File

@@ -1,8 +1,8 @@
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
# Copyright 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields
from odoo import fields, models
class ResConfigSettings(models.TransientModel):

View File

@@ -1,7 +1,7 @@
# © 2011-2014 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2011-2014 Akretion (<alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
from odoo import fields, models
class ResCountry(models.Model):

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -12,9 +12,9 @@
<field name="model">account.tax</field>
<field name="inherit_id" ref="account.view_tax_form"/>
<field name="arch" type="xml">
<group name="advanced_booleans" position="inside">
<field name="active" position="before">
<field name="exclude_from_intrastat_if_present"/>
</group>
</field>
</field>
</record>

View File

@@ -15,14 +15,13 @@
<xpath expr="//div[@id='recommended_apps']" position="after">
<h2>Intrastat</h2>
<div class="row mt16 o_settings_container" id="intrastat">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="col-xs-12 col-md-12 o_setting_box">
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<div class="content-group" id="intrastat_content_grp">
<div class="row mt16">
<label for="intrastat_remind_user_ids" class="col-md-5 o_light_label"/>
<field name="intrastat_remind_user_ids" widget="many2many_tags"/>
</div>
</div>
<div class="row">
<label for="intrastat_remind_user_ids" class="col-md-5 o_light_label"/>
<field name="intrastat_remind_user_ids" widget="many2many_tags"/>
</div>
</div>
</div>
</div>