diff --git a/product_harmonized_system/__manifest__.py b/product_harmonized_system/__manifest__.py index 466492272..7e51605c9 100644 --- a/product_harmonized_system/__manifest__.py +++ b/product_harmonized_system/__manifest__.py @@ -1,6 +1,6 @@ -# Copyright 2018-2020 brain-tec AG (http://www.braintec-group.com) -# Copyright 2011-2020 Akretion (http://www.akretion.com) -# Copyright 2009-2020 Noviat (http://www.noviat.com) +# Copyright 2018-2021 brain-tec AG (http://www.braintec-group.com) +# Copyright 2011-2021 Akretion (http://www.akretion.com) +# Copyright 2009-2021 Noviat (http://www.noviat.com) # @author Benjamin Henquet # @author Kumar Aberer # @author Alexis de Lattre @@ -9,7 +9,7 @@ { "name": "Product Harmonized System Codes", - "version": "14.0.2.0.0", + "version": "15.0.1.0.0", "category": "Reporting", "license": "AGPL-3", "summary": "Base module for Product Import/Export reports", diff --git a/product_harmonized_system/demo/product_demo.xml b/product_harmonized_system/demo/product_demo.xml index 902f4a8c7..e9886a736 100644 --- a/product_harmonized_system/demo/product_demo.xml +++ b/product_harmonized_system/demo/product_demo.xml @@ -1,6 +1,6 @@ diff --git a/product_harmonized_system/migrations/14.0.2.0.0/post-migration.py b/product_harmonized_system/migrations/14.0.2.0.0/post-migration.py deleted file mode 100644 index 2319cf261..000000000 --- a/product_harmonized_system/migrations/14.0.2.0.0/post-migration.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2021 Akretion France (http://www.akretion.com/) -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import SUPERUSER_ID, api - - -def migrate(cr, version): - if not version: - return - - with api.Environment.manage(): - env = api.Environment(cr, SUPERUSER_ID, {}) - pc_field_id = env.ref( - "product_harmonized_system.field_product_category__hs_code_id" - ).id - cr.execute( - """ - UPDATE product_category pc - SET hs_code_id=SUBSTRING(ip.value_reference, 9, 99)::int - FROM ir_property ip - WHERE ip.res_id like 'product.category,%%' AND - SUBSTRING(ip.res_id, 18, 99)::int=pc.id AND - ip.name='hs_code_id' AND - ip.value_reference IS NOT null AND - ip.fields_id=%s - """, - (pc_field_id,), - ) - pt_field_id = env.ref( - "product_harmonized_system.field_product_template__hs_code_id" - ).id - cr.execute( - """ - UPDATE product_template pt - SET hs_code_id=SUBSTRING(ip.value_reference, 9, 99)::int - FROM ir_property ip - WHERE ip.res_id like 'product.template,%%' AND - SUBSTRING(ip.res_id, 18, 99)::int=pt.id AND - ip.name='hs_code_id' AND - ip.value_reference IS NOT null AND - ip.fields_id=%s - """, - (pt_field_id,), - ) diff --git a/product_harmonized_system/models/hs_code.py b/product_harmonized_system/models/hs_code.py index 245cb3d64..ed94f9b25 100644 --- a/product_harmonized_system/models/hs_code.py +++ b/product_harmonized_system/models/hs_code.py @@ -1,9 +1,11 @@ -# Copyright 2011-2020 Akretion France (http://www.akretion.com) -# Copyright 2009-2020 Noviat (http://www.noviat.com) +# Copyright 2011-2021 Akretion France (http://www.akretion.com) +# Copyright 2009-2021 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from textwrap import shorten + from odoo import api, fields, models @@ -34,7 +36,7 @@ class HSCode(models.Model): company_id = fields.Many2one( "res.company", string="Company", - default=lambda self: self._default_company_id(), + # by default, company_id=False on this object ) product_categ_ids = fields.One2many( comodel_name="product.category", @@ -51,10 +53,6 @@ class HSCode(models.Model): product_categ_count = fields.Integer(compute="_compute_product_categ_count") product_tmpl_count = fields.Integer(compute="_compute_product_tmpl_count") - @api.model - def _default_company_id(self): - return self.env.company - @api.depends("local_code") def _compute_hs_code(self): for this in self: @@ -81,7 +79,7 @@ def name_get(self): name = this.local_code if this.description: name += " " + this.description - name = len(name) > 55 and name[:55] + "..." or name + name = shorten(name, 55) res.append((this.id, name)) return res diff --git a/product_harmonized_system/models/product_category.py b/product_harmonized_system/models/product_category.py index 89d10a311..5004fa19e 100644 --- a/product_harmonized_system/models/product_category.py +++ b/product_harmonized_system/models/product_category.py @@ -1,5 +1,5 @@ -# Copyright 2011-2020 Akretion France (http://www.akretion.com) -# Copyright 2009-2020 Noviat (http://www.noviat.com) +# Copyright 2011-2021 Akretion France (http://www.akretion.com) +# Copyright 2009-2021 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -13,9 +13,6 @@ class ProductCategory(models.Model): hs_code_id = fields.Many2one( "hs.code", string="H.S. Code", - # company_dependent updated from True to False in 14.0.2.0.0 - # migration scripts provided - company_dependent=False, ondelete="restrict", help="Harmonised System Code. If this code is not " "set on the product itself, it will be read here, on the " diff --git a/product_harmonized_system/models/product_template.py b/product_harmonized_system/models/product_template.py index 4670cfc74..119d90e86 100644 --- a/product_harmonized_system/models/product_template.py +++ b/product_harmonized_system/models/product_template.py @@ -1,5 +1,5 @@ -# Copyright 2011-2020 Akretion (http://www.akretion.com) -# Copyright 2009-2020 Noviat (http://www.noviat.com) +# Copyright 2011-2021 Akretion (http://www.akretion.com) +# Copyright 2009-2021 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -13,9 +13,6 @@ class ProductTemplate(models.Model): hs_code_id = fields.Many2one( "hs.code", string="H.S. Code", - # company_dependent updated from True to False in 14.0.2.0.0 - # migration scripts provided - company_dependent=False, ondelete="restrict", help="Harmonised System Code. Nomenclature is " "available from the World Customs Organisation, see " diff --git a/product_harmonized_system/views/hs_code.xml b/product_harmonized_system/views/hs_code.xml index 3672f13fd..610c3ffbf 100644 --- a/product_harmonized_system/views/hs_code.xml +++ b/product_harmonized_system/views/hs_code.xml @@ -1,6 +1,6 @@ @@ -10,7 +10,7 @@ hs.code.search hs.code - + hs.code.tree hs.code - + @@ -54,7 +54,7 @@ hs.code.form hs.code -
+ - hs_code.product.template.form product.template @@ -22,5 +21,18 @@ /> - + + + product.template + + + + + + + diff --git a/product_harmonized_system_delivery/__manifest__.py b/product_harmonized_system_delivery/__manifest__.py index 5415e85aa..28e159803 100644 --- a/product_harmonized_system_delivery/__manifest__.py +++ b/product_harmonized_system_delivery/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 2018-2020 Akretion France (http://www.akretion.com) +# Copyright 2018-2021 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Product Harmonized System Codes - Delivery", - "version": "14.0.1.1.0", + "version": "15.0.1.0.0", "category": "Reporting", "license": "AGPL-3", "summary": "Hide native hs_code field provided by the delivery module", diff --git a/product_harmonized_system_delivery/models/__init__.py b/product_harmonized_system_delivery/models/__init__.py index 9649db77a..e8fa8f6bf 100644 --- a/product_harmonized_system_delivery/models/__init__.py +++ b/product_harmonized_system_delivery/models/__init__.py @@ -1 +1 @@ -from . import product +from . import product_template diff --git a/product_harmonized_system_delivery/models/product.py b/product_harmonized_system_delivery/models/product.py deleted file mode 100644 index 5b65cf2c7..000000000 --- a/product_harmonized_system_delivery/models/product.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2017 Camptocamp SA -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import fields, models - - -class ProductTemplate(models.Model): - _inherit = "product.template" - - # this field cannot be stored because hs_code_id is company dependent - hs_code = fields.Char(related="hs_code_id.hs_code", readonly=True, store=False) diff --git a/product_harmonized_system_delivery/models/product_template.py b/product_harmonized_system_delivery/models/product_template.py new file mode 100644 index 000000000..f2e6500ad --- /dev/null +++ b/product_harmonized_system_delivery/models/product_template.py @@ -0,0 +1,10 @@ +# Copyright 2017-2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + hs_code = fields.Char(related="hs_code_id.hs_code", store=True) diff --git a/product_harmonized_system_delivery/views/product_template.xml b/product_harmonized_system_delivery/views/product_template.xml index 2b068b3ac..3dac33c0a 100644 --- a/product_harmonized_system_delivery/views/product_template.xml +++ b/product_harmonized_system_delivery/views/product_template.xml @@ -1,6 +1,6 @@ diff --git a/product_harmonized_system_stock/__manifest__.py b/product_harmonized_system_stock/__manifest__.py index 2039eae2c..2d2acc1df 100644 --- a/product_harmonized_system_stock/__manifest__.py +++ b/product_harmonized_system_stock/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 2019-2020 Akretion France (http://www.akretion.com) +# Copyright 2019-2021 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Product Harmonized System (menu entry)", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "category": "Reporting", "license": "AGPL-3", "summary": "Adds a menu entry for H.S. codes", diff --git a/product_harmonized_system_stock/views/hs_code_menu.xml b/product_harmonized_system_stock/views/hs_code_menu.xml index 11e1dc5f9..72ee915d7 100644 --- a/product_harmonized_system_stock/views/hs_code_menu.xml +++ b/product_harmonized_system_stock/views/hs_code_menu.xml @@ -1,6 +1,6 @@ diff --git a/setup/product_harmonized_system/odoo/addons/product_harmonized_system b/setup/product_harmonized_system/odoo/addons/product_harmonized_system new file mode 120000 index 000000000..40ab03b0b --- /dev/null +++ b/setup/product_harmonized_system/odoo/addons/product_harmonized_system @@ -0,0 +1 @@ +../../../../product_harmonized_system \ No newline at end of file diff --git a/setup/product_harmonized_system/setup.py b/setup/product_harmonized_system/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/product_harmonized_system/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/product_harmonized_system_delivery/odoo/addons/product_harmonized_system_delivery b/setup/product_harmonized_system_delivery/odoo/addons/product_harmonized_system_delivery new file mode 120000 index 000000000..61e2d97d1 --- /dev/null +++ b/setup/product_harmonized_system_delivery/odoo/addons/product_harmonized_system_delivery @@ -0,0 +1 @@ +../../../../product_harmonized_system_delivery \ No newline at end of file diff --git a/setup/product_harmonized_system_delivery/setup.py b/setup/product_harmonized_system_delivery/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/product_harmonized_system_delivery/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/product_harmonized_system_stock/odoo/addons/product_harmonized_system_stock b/setup/product_harmonized_system_stock/odoo/addons/product_harmonized_system_stock new file mode 120000 index 000000000..a8f278777 --- /dev/null +++ b/setup/product_harmonized_system_stock/odoo/addons/product_harmonized_system_stock @@ -0,0 +1 @@ +../../../../product_harmonized_system_stock \ No newline at end of file diff --git a/setup/product_harmonized_system_stock/setup.py b/setup/product_harmonized_system_stock/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/product_harmonized_system_stock/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)