mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
Add new module product_harmonized_system_delivery (hide native hs_code field)
Finalize port to v11
This commit is contained in:
@@ -12,3 +12,13 @@ class AccountTax(models.Model):
|
|||||||
help="If this tax is present on an invoice line, this invoice "
|
help="If this tax is present on an invoice line, this invoice "
|
||||||
"line will be skipped when generating Intrastat Product or "
|
"line will be skipped when generating Intrastat Product or "
|
||||||
"Service lines from invoices.")
|
"Service lines from invoices.")
|
||||||
|
|
||||||
|
|
||||||
|
class AccountTaxTemplate(models.Model):
|
||||||
|
_inherit = "account.tax.template"
|
||||||
|
|
||||||
|
exclude_from_intrastat_if_present = fields.Boolean(
|
||||||
|
string='Exclude invoice line from intrastat if this tax is present',
|
||||||
|
help="If this tax is present on an invoice line, this invoice "
|
||||||
|
"line will be skipped when generating Intrastat Product or "
|
||||||
|
"Service lines from invoices.")
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
from odoo import models, fields, api, tools, _
|
from odoo import models, fields, api, tools, _
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
import base64
|
||||||
|
from lxml import etree
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -48,25 +50,25 @@ class IntrastatCommon(models.AbstractModel):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _check_xml_schema(self, xml_string, xsd_file):
|
def _check_xml_schema(self, xml_etree, xsd_file):
|
||||||
'''Validate the XML file against the XSD'''
|
'''Validate the XML file against the XSD'''
|
||||||
from lxml import etree
|
|
||||||
from io import StringIO
|
|
||||||
xsd_etree_obj = etree.parse(
|
xsd_etree_obj = etree.parse(
|
||||||
tools.file_open(xsd_file))
|
tools.file_open(xsd_file))
|
||||||
official_schema = etree.XMLSchema(xsd_etree_obj)
|
official_schema = etree.XMLSchema(xsd_etree_obj)
|
||||||
try:
|
try:
|
||||||
t = etree.parse(StringIO(xml_string))
|
official_schema.assertValid(xml_etree)
|
||||||
official_schema.assertValid(t)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# if the validation of the XSD fails, we arrive here
|
# if the validation of the XSD fails, we arrive here
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"The XML file is invalid against the XML Schema Definition")
|
"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(xml_string)
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
raise UserError(
|
raise UserError(_(
|
||||||
_("The generated XML file is not valid against the official "
|
"The generated XML file is not valid against the official "
|
||||||
"XML Schema Definition. The generated XML file and the "
|
"XML Schema Definition. The generated XML file and the "
|
||||||
"full error have been written in the server logs. "
|
"full error have been written in the server logs. "
|
||||||
"Here is the error, which may give you an idea on the "
|
"Here is the error, which may give you an idea on the "
|
||||||
@@ -79,13 +81,12 @@ class IntrastatCommon(models.AbstractModel):
|
|||||||
'''Attach the XML file to the report_intrastat_product/service
|
'''Attach the XML file to the report_intrastat_product/service
|
||||||
object'''
|
object'''
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
import base64
|
|
||||||
filename = '%s_%s.xml' % (self.year_month, declaration_name)
|
filename = '%s_%s.xml' % (self.year_month, declaration_name)
|
||||||
attach = self.env['ir.attachment'].create({
|
attach = self.env['ir.attachment'].create({
|
||||||
'name': filename,
|
'name': filename,
|
||||||
'res_id': self.id,
|
'res_id': self.id,
|
||||||
'res_model': self._name,
|
'res_model': self._name,
|
||||||
'datas': base64.encodestring(xml_string),
|
'datas': base64.b64encode(xml_string),
|
||||||
'datas_fname': filename})
|
'datas_fname': filename})
|
||||||
return attach.id
|
return attach.id
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
<field name="model">account.tax</field>
|
<field name="model">account.tax</field>
|
||||||
<field name="inherit_id" ref="account.view_tax_form"/>
|
<field name="inherit_id" ref="account.view_tax_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="active" position="before">
|
<group name="advanced_booleans" position="inside">
|
||||||
<field name="exclude_from_intrastat_if_present"/>
|
<field name="exclude_from_intrastat_if_present"/>
|
||||||
</field>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,15 @@
|
|||||||
<div class="row mt16 o_settings_container" id="intrastat">
|
<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-6 o_setting_box">
|
||||||
<div class="o_setting_right_pane">
|
<div class="o_setting_right_pane">
|
||||||
<label for="intrastat_remind_user_ids"/>
|
<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"/>
|
<field name="intrastat_remind_user_ids" widget="many2many_tags"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user