diff --git a/intrastat_product/__manifest__.py b/intrastat_product/__manifest__.py index 92dedc1..8b79805 100644 --- a/intrastat_product/__manifest__.py +++ b/intrastat_product/__manifest__.py @@ -1,5 +1,5 @@ # Copyright 2011-2017 Akretion (http://www.akretion.com) -# Copyright 2009-2019 Noviat (http://www.noviat.com) +# Copyright 2009-2020 Noviat (http://www.noviat.com) # Copyright 2018 brain-tec AG (http://www.braintec-group.com) # @author Alexis de Lattre # @author Luc de Meyer diff --git a/intrastat_product/models/account_move.py b/intrastat_product/models/account_move.py index e84b841..5576b0a 100644 --- a/intrastat_product/models/account_move.py +++ b/intrastat_product/models/account_move.py @@ -1,5 +1,5 @@ # Copyright 2011-2017 Akretion France (http://www.akretion.com) -# Copyright 2009-2018 Noviat (http://www.noviat.com) +# Copyright 2009-2020 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer @@ -58,9 +58,7 @@ class AccountMove(models.Model): @api.model def _default_src_dest_region_id(self): - rco = self.env["res.company"] - company = rco._company_default_get() - return company.intrastat_region_id + return self.env.company.intrastat_region_id class AccountMoveLine(models.Model): diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index be35e25..b454d3e 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -5,6 +5,7 @@ import logging from datetime import date, datetime + from dateutil.relativedelta import relativedelta from odoo import _, api, fields, models @@ -40,7 +41,7 @@ class IntrastatProductDeclaration(models.Model): comodel_name="res.company", string="Company", readonly=True, - default=lambda self: self.env["res.company"]._company_default_get(), + default=lambda self: self._default_company_id(), ) company_country_code = fields.Char( compute="_compute_company_country_code", @@ -148,6 +149,10 @@ class IntrastatProductDeclaration(models.Model): ) valid = fields.Boolean(compute="_compute_check_validity", string="Valid") + @api.model + def _default_company_id(self): + return self.env.company + @api.model def _get_type(self): res = [] diff --git a/intrastat_product/models/intrastat_region.py b/intrastat_product/models/intrastat_region.py index 74e28ed..648db55 100644 --- a/intrastat_product/models/intrastat_region.py +++ b/intrastat_product/models/intrastat_region.py @@ -1,7 +1,7 @@ -# Copyright 2009-2018 Noviat nv/sa (www.noviat.com). +# Copyright 2009-2020 Noviat nv/sa (www.noviat.com). # @author Luc de Meyer -from odoo import fields, models +from odoo import api, fields, models class IntrastatRegion(models.Model): @@ -24,5 +24,9 @@ class IntrastatRegion(models.Model): company_id = fields.Many2one( comodel_name="res.company", string="Company", - default=lambda self: self.env["res.company"]._company_default_get(), + default=lambda self: self._default_company_id(), ) + + @api.model + def _default_company_id(self): + return self.env.company diff --git a/intrastat_product/models/intrastat_transaction.py b/intrastat_product/models/intrastat_transaction.py index 9267805..7dfbbae 100644 --- a/intrastat_product/models/intrastat_transaction.py +++ b/intrastat_product/models/intrastat_transaction.py @@ -1,5 +1,5 @@ # Copyright 2011-2017 Akretion France (http://www.akretion.com) -# Copyright 2009-2018 Noviat (http://www.noviat.com) +# Copyright 2009-2020 Noviat (http://www.noviat.com) # @author Alexis de Lattre # @author Luc de Meyer @@ -23,9 +23,13 @@ class IntrastatTransaction(models.Model): company_id = fields.Many2one( comodel_name="res.company", string="Company", - default=lambda self: self.env["res.company"]._company_default_get(), + default=lambda self: self._default_company_id(), ) + @api.model + def _default_company_id(self): + return self.env.company + @api.depends("code", "description") def name_get(self): res = [] diff --git a/intrastat_product_generic/__manifest__.py b/intrastat_product_generic/__manifest__.py index e261070..7a136d1 100644 --- a/intrastat_product_generic/__manifest__.py +++ b/intrastat_product_generic/__manifest__.py @@ -1,20 +1,14 @@ -# Copyright 2009-2018 Noviat. +# Copyright 2009-2020 Noviat. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Generic Intrastat Product Declaration', - 'version': '12.0.1.0.0', - 'category': 'Accounting & Finance', - 'website': 'https://github.com/OCA/intrastat', - 'author': 'Noviat,' - 'Odoo Community Association (OCA)', - 'license': 'AGPL-3', - 'installable': True, - 'depends': [ - 'intrastat_product', - ], - 'data': [ - 'security/intrastat_security.xml', - 'views/intrastat_product.xml' - ], + "name": "Generic Intrastat Product Declaration", + "version": "13.0.1.0.0", + "category": "Accounting & Finance", + "website": "https://github.com/OCA/intrastat", + "author": "Noviat," "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["intrastat_product"], + "data": ["security/intrastat_security.xml", "views/intrastat_product.xml"], }