mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
[MIG] intrastat_product: Migration to 11.0
This commit is contained in:
committed by
João Marques
parent
2aed9bca6e
commit
f094100eae
@@ -1,22 +1,25 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# © 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
# © 2009-2017 Noviat (http://www.noviat.com)
|
||||||
|
# © 2018 brain-tec AG (http://www.braintec-group.com)
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
# @author Kumar Aberer <kumar.aberer@braintec-group.com>
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Intrastat Product',
|
'name': 'Intrastat Product',
|
||||||
'version': '10.0.1.1.0',
|
'version': '11.0.1.1.0',
|
||||||
'category': 'Intrastat',
|
'category': 'Intrastat',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Base module for Intrastat Product',
|
'summary': 'Base module for Intrastat Product',
|
||||||
'author': 'Akretion, Noviat, Odoo Community Association (OCA)',
|
'author': 'brain-tec AG, Akretion, Noviat, '
|
||||||
|
'Odoo Community Association (OCA)',
|
||||||
'depends': [
|
'depends': [
|
||||||
'intrastat_base',
|
'intrastat_base',
|
||||||
'product_harmonized_system',
|
'product_harmonized_system',
|
||||||
'sale_stock',
|
'sale_stock',
|
||||||
'purchase',
|
'purchase',
|
||||||
],
|
],
|
||||||
'conflicts': ['report_intrastat'],
|
'conflicts': ['report_intrastat'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/hs_code.xml',
|
'views/hs_code.xml',
|
||||||
@@ -25,7 +28,7 @@
|
|||||||
'views/intrastat_transaction.xml',
|
'views/intrastat_transaction.xml',
|
||||||
'views/intrastat_transport_mode.xml',
|
'views/intrastat_transport_mode.xml',
|
||||||
'views/intrastat_product_declaration.xml',
|
'views/intrastat_product_declaration.xml',
|
||||||
'views/account_config_settings.xml',
|
'views/res_config_settings.xml',
|
||||||
'views/account_invoice.xml',
|
'views/account_invoice.xml',
|
||||||
'views/sale_order.xml',
|
'views/sale_order.xml',
|
||||||
'views/stock_warehouse.xml',
|
'views/stock_warehouse.xml',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from . import res_company
|
from . import res_company
|
||||||
from . import account_config_settings
|
from . import res_config_settings
|
||||||
from . import account_invoice
|
from . import account_invoice
|
||||||
from . import hs_code
|
from . import hs_code
|
||||||
from . import intrastat_product_declaration
|
from . import intrastat_product_declaration
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
(10, '10'),
|
(10, '10'),
|
||||||
(11, '11'),
|
(11, '11'),
|
||||||
(12, '12')
|
(12, '12')
|
||||||
], string='Month', required=True,
|
], string='Month', required=True,
|
||||||
default=_get_month)
|
default=_get_month)
|
||||||
year_month = fields.Char(
|
year_month = fields.Char(
|
||||||
compute='_compute_year_month', string='Period', readonly=True,
|
compute='_compute_year_month', string='Period', readonly=True,
|
||||||
@@ -142,7 +142,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
('done', 'Done'),
|
('done', 'Done'),
|
||||||
], string='State', readonly=True, track_visibility='onchange',
|
], string='State', readonly=True, track_visibility='onchange',
|
||||||
copy=False, default='draft',
|
copy=False, default='draft',
|
||||||
help="State of the declaration. When the state is set to 'Done', "
|
help="State of the declaration. When the state is set to 'Done', "
|
||||||
"the parameters become read-only.")
|
"the parameters become read-only.")
|
||||||
@@ -251,7 +251,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
note = "\n" + _(
|
note = "\n" + _(
|
||||||
"Missing unit of measure on the line with %d "
|
"Missing unit of measure on the line with %d "
|
||||||
"product(s) '%s' on invoice '%s'."
|
"product(s) '%s' on invoice '%s'."
|
||||||
) % (line_qty, product.name_get()[0][1], invoice.number)
|
) % (line_qty, product.name_get()[0][1], invoice.number)
|
||||||
note += "\n" + _(
|
note += "\n" + _(
|
||||||
"Please adjust this line manually.")
|
"Please adjust this line manually.")
|
||||||
self._note += note
|
self._note += note
|
||||||
@@ -263,12 +263,12 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
note = "\n" + _(
|
note = "\n" + _(
|
||||||
"Conversion from Intrastat Supplementary Unit '%s' to "
|
"Conversion from Intrastat Supplementary Unit '%s' to "
|
||||||
"Unit of Measure is not implemented yet."
|
"Unit of Measure is not implemented yet."
|
||||||
) % intrastat_unit_id.name
|
) % intrastat_unit_id.name
|
||||||
note += "\n" + _(
|
note += "\n" + _(
|
||||||
"Please correct the Intrastat Supplementary Unit "
|
"Please correct the Intrastat Supplementary Unit "
|
||||||
"settings and regenerate the lines or adjust the lines "
|
"settings and regenerate the lines or adjust the lines "
|
||||||
"with Intrastat Code '%s' manually"
|
"with Intrastat Code '%s' manually"
|
||||||
) % hs_code.display_name
|
) % hs_code.display_name
|
||||||
self._note += note
|
self._note += note
|
||||||
return weight, suppl_unit_qty
|
return weight, suppl_unit_qty
|
||||||
if target_uom.category_id == source_uom.category_id:
|
if target_uom.category_id == source_uom.category_id:
|
||||||
@@ -278,7 +278,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
note = "\n" + _(
|
note = "\n" + _(
|
||||||
"Conversion from unit of measure '%s' to '%s' "
|
"Conversion from unit of measure '%s' to '%s' "
|
||||||
"is not implemented yet."
|
"is not implemented yet."
|
||||||
) % (source_uom.name, target_uom.name)
|
) % (source_uom.name, target_uom.name)
|
||||||
note += "\n" + _(
|
note += "\n" + _(
|
||||||
"Please correct the unit of measure settings and "
|
"Please correct the unit of measure settings and "
|
||||||
"regenerate the lines or adjust the impacted "
|
"regenerate the lines or adjust the impacted "
|
||||||
@@ -294,7 +294,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
if not product.weight: # re-create weight_net ?
|
if not product.weight: # re-create weight_net ?
|
||||||
note = "\n" + _(
|
note = "\n" + _(
|
||||||
"Missing net weight on product %s."
|
"Missing net weight on product %s."
|
||||||
) % product.name_get()[0][1]
|
) % product.name_get()[0][1]
|
||||||
note += "\n" + _(
|
note += "\n" + _(
|
||||||
"Please correct the product record and regenerate "
|
"Please correct the product record and regenerate "
|
||||||
"the lines or adjust the impacted lines manually")
|
"the lines or adjust the impacted lines manually")
|
||||||
@@ -312,7 +312,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
note = "\n" + _(
|
note = "\n" + _(
|
||||||
"Conversion from unit of measure '%s' to 'Kg' "
|
"Conversion from unit of measure '%s' to 'Kg' "
|
||||||
"is not implemented yet. It is needed for product '%s'."
|
"is not implemented yet. It is needed for product '%s'."
|
||||||
) % (source_uom.name, product.name_get()[0][1])
|
) % (source_uom.name, product.name_get()[0][1])
|
||||||
note += "\n" + _(
|
note += "\n" + _(
|
||||||
"Please correct the unit of measure settings and "
|
"Please correct the unit of measure settings and "
|
||||||
"regenerate the lines or adjust the impacted lines "
|
"regenerate the lines or adjust the impacted lines "
|
||||||
@@ -373,22 +373,22 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
transport = inv_line.invoice_id.intrastat_transport_id \
|
transport = inv_line.invoice_id.intrastat_transport_id \
|
||||||
or self.company_id.intrastat_transport_id
|
or self.company_id.intrastat_transport_id
|
||||||
if not transport:
|
if not transport:
|
||||||
msg = _(
|
msg = _(
|
||||||
"The default Intrastat Transport Mode "
|
"The default Intrastat Transport Mode "
|
||||||
"of the Company is not set, "
|
"of the Company is not set, "
|
||||||
"please configure it first.")
|
"please configure it first.")
|
||||||
self._company_warning(msg)
|
self._company_warning(msg)
|
||||||
return transport
|
return transport
|
||||||
|
|
||||||
def _get_incoterm(self, inv_line):
|
def _get_incoterm(self, inv_line):
|
||||||
incoterm = inv_line.invoice_id.incoterms_id \
|
incoterm = inv_line.invoice_id.incoterms_id \
|
||||||
or self.company_id.intrastat_incoterm_id
|
or self.company_id.intrastat_incoterm_id
|
||||||
if not incoterm:
|
if not incoterm:
|
||||||
msg = _(
|
msg = _(
|
||||||
"The default Incoterm "
|
"The default Incoterm "
|
||||||
"of the Company is not set, "
|
"of the Company is not set, "
|
||||||
"please configure it first.")
|
"please configure it first.")
|
||||||
self._company_warning(msg)
|
self._company_warning(msg)
|
||||||
return incoterm
|
return incoterm
|
||||||
|
|
||||||
def _get_product_origin_country(self, inv_line):
|
def _get_product_origin_country(self, inv_line):
|
||||||
@@ -558,14 +558,14 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
'product_origin_country_id':
|
'product_origin_country_id':
|
||||||
product_origin_country.id or False,
|
product_origin_country.id or False,
|
||||||
'region_id': region and region.id or False,
|
'region_id': region and region.id or False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# extended declaration
|
# extended declaration
|
||||||
if self._extended:
|
if self._extended:
|
||||||
transport = self._get_transport(inv_line)
|
transport = self._get_transport(inv_line)
|
||||||
line_vals.update({
|
line_vals.update({
|
||||||
'transport_id': transport.id,
|
'transport_id': transport.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
self._update_computation_line_vals(inv_line, line_vals)
|
self._update_computation_line_vals(inv_line, line_vals)
|
||||||
|
|
||||||
@@ -601,7 +601,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
'kg_uom': self.env.ref('product.product_uom_kgm'),
|
'kg_uom': self.env.ref('product.product_uom_kgm'),
|
||||||
'pce_uom_categ': self.env.ref('product.product_uom_categ_unit'),
|
'pce_uom_categ': self.env.ref('product.product_uom_categ_unit'),
|
||||||
'pce_uom': self.env.ref('product.product_uom_unit')
|
'pce_uom': self.env.ref('product.product_uom_unit')
|
||||||
}
|
}
|
||||||
return uom_refs[ref]
|
return uom_refs[ref]
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -662,11 +662,11 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
'region': computation_line.region_id.id or False,
|
'region': computation_line.region_id.id or False,
|
||||||
'product_origin_country':
|
'product_origin_country':
|
||||||
computation_line.product_origin_country_id.id or False,
|
computation_line.product_origin_country_id.id or False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def group_line_hashcode(self, computation_line):
|
def group_line_hashcode(self, computation_line):
|
||||||
hc_fields = self._group_line_hashcode_fields(computation_line)
|
hc_fields = self._group_line_hashcode_fields(computation_line)
|
||||||
hashcode = '-'.join([unicode(f) for f in hc_fields.itervalues()])
|
hashcode = '-'.join([str(f) for f in hc_fields.values()])
|
||||||
return hashcode
|
return hashcode
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -686,7 +686,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
else:
|
else:
|
||||||
dl_group[hashcode] = [cl]
|
dl_group[hashcode] = [cl]
|
||||||
ipdl = self.declaration_line_ids
|
ipdl = self.declaration_line_ids
|
||||||
for cl_lines in dl_group.values():
|
for cl_lines in list(dl_group.values()):
|
||||||
vals = ipdl._prepare_declaration_line(cl_lines)
|
vals = ipdl._prepare_declaration_line(cl_lines)
|
||||||
declaration_line = ipdl.create(vals)
|
declaration_line = ipdl.create(vals)
|
||||||
for cl in cl_lines:
|
for cl in cl_lines:
|
||||||
@@ -893,7 +893,7 @@ class IntrastatProductDeclarationLine(models.Model):
|
|||||||
'product_origin_country_id':
|
'product_origin_country_id':
|
||||||
computation_line.product_origin_country_id.id,
|
computation_line.product_origin_country_id.id,
|
||||||
'amount_company_currency': 0.0,
|
'amount_company_currency': 0.0,
|
||||||
}
|
}
|
||||||
for field in fields_to_sum:
|
for field in fields_to_sum:
|
||||||
vals[field] = 0.0
|
vals[field] = 0.0
|
||||||
return vals
|
return vals
|
||||||
@@ -902,7 +902,7 @@ class IntrastatProductDeclarationLine(models.Model):
|
|||||||
fields_to_sum = [
|
fields_to_sum = [
|
||||||
'weight',
|
'weight',
|
||||||
'suppl_unit_qty',
|
'suppl_unit_qty',
|
||||||
]
|
]
|
||||||
return fields_to_sum
|
return fields_to_sum
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
from odoo import models, fields
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
class AccountConfigSettings(models.TransientModel):
|
class ResConfigSettings(models.TransientModel):
|
||||||
_inherit = 'account.config.settings'
|
_inherit = 'res.config.settings'
|
||||||
|
|
||||||
intrastat_incoterm_id = fields.Many2one(
|
intrastat_incoterm_id = fields.Many2one(
|
||||||
related='company_id.intrastat_incoterm_id')
|
related='company_id.intrastat_incoterm_id')
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<record id="view_account_config_settings" model="ir.ui.view">
|
|
||||||
<field name="name">intrastat.account.config.settings.form</field>
|
|
||||||
<field name="model">account.config.settings</field>
|
|
||||||
<field name="inherit_id" ref="intrastat_base.view_account_config_settings"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<group name="intrastat" position="inside">
|
|
||||||
<field name="intrastat" invisible="1"/>
|
|
||||||
<field name="intrastat_arrivals"/>
|
|
||||||
<field name="intrastat_dispatches"/>
|
|
||||||
<field name="intrastat_transaction_out_invoice"/>
|
|
||||||
<field name="intrastat_transaction_out_refund"/>
|
|
||||||
<field name="intrastat_transaction_in_invoice"/>
|
|
||||||
<field name="intrastat_transaction_in_refund"/>
|
|
||||||
<field name="intrastat_region_id" domain="[('country_id','=', country_id)]" invisible="1"/>
|
|
||||||
<field name="intrastat_transport_id"
|
|
||||||
attrs="{'required': [('intrastat', '=', 'extended')], 'invisible': [('intrastat', '!=', 'extended')]}"/>
|
|
||||||
<field name="intrastat_incoterm_id" invisible="1"/>
|
|
||||||
<field name="intrastat_accessory_costs" invisible="1"/>
|
|
||||||
</group>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
62
intrastat_product/views/res_config_settings.xml
Normal file
62
intrastat_product/views/res_config_settings.xml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
© 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_res_config_settings" model="ir.ui.view">
|
||||||
|
<field name="name">intrastat.account.config.settings.form</field>
|
||||||
|
<field name="model">res.config.settings</field>
|
||||||
|
<field name="inherit_id" ref="intrastat_base.view_intrastat_res_config_settings"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
|
||||||
|
|
||||||
|
<xpath expr="//div[@id='intrastat']" position="inside">
|
||||||
|
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<div class="content-group">
|
||||||
|
<div class="row mt16">
|
||||||
|
<label for="intrastat_arrivals" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_arrivals"/>
|
||||||
|
|
||||||
|
<label for="intrastat_dispatches" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_dispatches"/>
|
||||||
|
|
||||||
|
<label for="intrastat_transport_id" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_transport_id"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//div[@id='intrastat']" position="after">
|
||||||
|
<div class="row mt16 o_settings_container" id="intrastat_ext">
|
||||||
|
<label for="intrastat_incoterm_id" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_incoterm_id"/>
|
||||||
|
|
||||||
|
<label for="intrastat_transaction_out_invoice" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_transaction_out_invoice"/>
|
||||||
|
|
||||||
|
<label for="intrastat_transaction_out_refund" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_transaction_out_refund"/>
|
||||||
|
|
||||||
|
<label for="intrastat_transaction_in_invoice" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_transaction_in_invoice"/>
|
||||||
|
|
||||||
|
<label for="intrastat_transaction_in_refund" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_transaction_in_refund"/>
|
||||||
|
|
||||||
|
<label for="intrastat_accessory_costs" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_accessory_costs"/>
|
||||||
|
|
||||||
|
<field name="intrastat_region_id" invisible="1"/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user