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 -*-
|
||||
# © 2011-2017 Akretion (http://www.akretion.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 Luc de Meyer <info@noviat.com>
|
||||
# @author Kumar Aberer <kumar.aberer@braintec-group.com>
|
||||
|
||||
{
|
||||
'name': 'Intrastat Product',
|
||||
'version': '10.0.1.1.0',
|
||||
'version': '11.0.1.1.0',
|
||||
'category': 'Intrastat',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Base module for Intrastat Product',
|
||||
'author': 'Akretion, Noviat, Odoo Community Association (OCA)',
|
||||
'author': 'brain-tec AG, Akretion, Noviat, '
|
||||
'Odoo Community Association (OCA)',
|
||||
'depends': [
|
||||
'intrastat_base',
|
||||
'product_harmonized_system',
|
||||
'sale_stock',
|
||||
'purchase',
|
||||
],
|
||||
],
|
||||
'conflicts': ['report_intrastat'],
|
||||
'data': [
|
||||
'views/hs_code.xml',
|
||||
@@ -25,7 +28,7 @@
|
||||
'views/intrastat_transaction.xml',
|
||||
'views/intrastat_transport_mode.xml',
|
||||
'views/intrastat_product_declaration.xml',
|
||||
'views/account_config_settings.xml',
|
||||
'views/res_config_settings.xml',
|
||||
'views/account_invoice.xml',
|
||||
'views/sale_order.xml',
|
||||
'views/stock_warehouse.xml',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import res_company
|
||||
from . import account_config_settings
|
||||
from . import res_config_settings
|
||||
from . import account_invoice
|
||||
from . import hs_code
|
||||
from . import intrastat_product_declaration
|
||||
|
||||
@@ -102,7 +102,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
(10, '10'),
|
||||
(11, '11'),
|
||||
(12, '12')
|
||||
], string='Month', required=True,
|
||||
], string='Month', required=True,
|
||||
default=_get_month)
|
||||
year_month = fields.Char(
|
||||
compute='_compute_year_month', string='Period', readonly=True,
|
||||
@@ -142,7 +142,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('done', 'Done'),
|
||||
], string='State', readonly=True, track_visibility='onchange',
|
||||
], string='State', readonly=True, track_visibility='onchange',
|
||||
copy=False, default='draft',
|
||||
help="State of the declaration. When the state is set to 'Done', "
|
||||
"the parameters become read-only.")
|
||||
@@ -251,7 +251,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
note = "\n" + _(
|
||||
"Missing unit of measure on the line with %d "
|
||||
"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" + _(
|
||||
"Please adjust this line manually.")
|
||||
self._note += note
|
||||
@@ -263,12 +263,12 @@ class IntrastatProductDeclaration(models.Model):
|
||||
note = "\n" + _(
|
||||
"Conversion from Intrastat Supplementary Unit '%s' to "
|
||||
"Unit of Measure is not implemented yet."
|
||||
) % intrastat_unit_id.name
|
||||
) % intrastat_unit_id.name
|
||||
note += "\n" + _(
|
||||
"Please correct the Intrastat Supplementary Unit "
|
||||
"settings and regenerate the lines or adjust the lines "
|
||||
"with Intrastat Code '%s' manually"
|
||||
) % hs_code.display_name
|
||||
) % hs_code.display_name
|
||||
self._note += note
|
||||
return weight, suppl_unit_qty
|
||||
if target_uom.category_id == source_uom.category_id:
|
||||
@@ -278,7 +278,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
note = "\n" + _(
|
||||
"Conversion from unit of measure '%s' to '%s' "
|
||||
"is not implemented yet."
|
||||
) % (source_uom.name, target_uom.name)
|
||||
) % (source_uom.name, target_uom.name)
|
||||
note += "\n" + _(
|
||||
"Please correct the unit of measure settings and "
|
||||
"regenerate the lines or adjust the impacted "
|
||||
@@ -294,7 +294,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
if not product.weight: # re-create weight_net ?
|
||||
note = "\n" + _(
|
||||
"Missing net weight on product %s."
|
||||
) % product.name_get()[0][1]
|
||||
) % product.name_get()[0][1]
|
||||
note += "\n" + _(
|
||||
"Please correct the product record and regenerate "
|
||||
"the lines or adjust the impacted lines manually")
|
||||
@@ -312,7 +312,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
note = "\n" + _(
|
||||
"Conversion from unit of measure '%s' to 'Kg' "
|
||||
"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" + _(
|
||||
"Please correct the unit of measure settings and "
|
||||
"regenerate the lines or adjust the impacted lines "
|
||||
@@ -373,22 +373,22 @@ class IntrastatProductDeclaration(models.Model):
|
||||
transport = inv_line.invoice_id.intrastat_transport_id \
|
||||
or self.company_id.intrastat_transport_id
|
||||
if not transport:
|
||||
msg = _(
|
||||
"The default Intrastat Transport Mode "
|
||||
"of the Company is not set, "
|
||||
"please configure it first.")
|
||||
self._company_warning(msg)
|
||||
msg = _(
|
||||
"The default Intrastat Transport Mode "
|
||||
"of the Company is not set, "
|
||||
"please configure it first.")
|
||||
self._company_warning(msg)
|
||||
return transport
|
||||
|
||||
def _get_incoterm(self, inv_line):
|
||||
incoterm = inv_line.invoice_id.incoterms_id \
|
||||
or self.company_id.intrastat_incoterm_id
|
||||
if not incoterm:
|
||||
msg = _(
|
||||
"The default Incoterm "
|
||||
"of the Company is not set, "
|
||||
"please configure it first.")
|
||||
self._company_warning(msg)
|
||||
msg = _(
|
||||
"The default Incoterm "
|
||||
"of the Company is not set, "
|
||||
"please configure it first.")
|
||||
self._company_warning(msg)
|
||||
return incoterm
|
||||
|
||||
def _get_product_origin_country(self, inv_line):
|
||||
@@ -558,14 +558,14 @@ class IntrastatProductDeclaration(models.Model):
|
||||
'product_origin_country_id':
|
||||
product_origin_country.id or False,
|
||||
'region_id': region and region.id or False,
|
||||
}
|
||||
}
|
||||
|
||||
# extended declaration
|
||||
if self._extended:
|
||||
transport = self._get_transport(inv_line)
|
||||
line_vals.update({
|
||||
'transport_id': transport.id,
|
||||
})
|
||||
})
|
||||
|
||||
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'),
|
||||
'pce_uom_categ': self.env.ref('product.product_uom_categ_unit'),
|
||||
'pce_uom': self.env.ref('product.product_uom_unit')
|
||||
}
|
||||
}
|
||||
return uom_refs[ref]
|
||||
|
||||
@api.multi
|
||||
@@ -662,11 +662,11 @@ class IntrastatProductDeclaration(models.Model):
|
||||
'region': computation_line.region_id.id or False,
|
||||
'product_origin_country':
|
||||
computation_line.product_origin_country_id.id or False,
|
||||
}
|
||||
}
|
||||
|
||||
def group_line_hashcode(self, 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
|
||||
|
||||
@api.multi
|
||||
@@ -686,7 +686,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
else:
|
||||
dl_group[hashcode] = [cl]
|
||||
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)
|
||||
declaration_line = ipdl.create(vals)
|
||||
for cl in cl_lines:
|
||||
@@ -893,7 +893,7 @@ class IntrastatProductDeclarationLine(models.Model):
|
||||
'product_origin_country_id':
|
||||
computation_line.product_origin_country_id.id,
|
||||
'amount_company_currency': 0.0,
|
||||
}
|
||||
}
|
||||
for field in fields_to_sum:
|
||||
vals[field] = 0.0
|
||||
return vals
|
||||
@@ -902,7 +902,7 @@ class IntrastatProductDeclarationLine(models.Model):
|
||||
fields_to_sum = [
|
||||
'weight',
|
||||
'suppl_unit_qty',
|
||||
]
|
||||
]
|
||||
return fields_to_sum
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class AccountConfigSettings(models.TransientModel):
|
||||
_inherit = 'account.config.settings'
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
intrastat_incoterm_id = fields.Many2one(
|
||||
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