From e37b51a017ce01ae1ccd054c05603a67fbc1ba73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Gonz=C3=A1lez=20=5BVauxoo=5D?= Date: Wed, 18 Mar 2020 00:10:40 -0600 Subject: [PATCH] [IMP] company_country: Don't create DB table for model (#1791) That model is intended only to set config and has no fields, so there is no need for creating a DB table for it. This is achieved by switching the model type from transient to abstract. --- company_country/__manifest__.py | 2 +- .../migrations/12.0.1.0.2/pre-migration.py | 18 ++++++++++++++++++ company_country/models/res_config.py | 2 +- company_country/readme/CONTRIBUTORS.rst | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 company_country/migrations/12.0.1.0.2/pre-migration.py diff --git a/company_country/__manifest__.py b/company_country/__manifest__.py index a767139d1..efc46afa7 100644 --- a/company_country/__manifest__.py +++ b/company_country/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Company Country", "summary": "Set country to main company", - "version": "12.0.1.0.1", + "version": "12.0.1.0.2", "category": "base", "website": "https://github.com/OCA/server-tools/tree/12.0/company_country", "maintainers": ['moylop260', 'luisg123v'], diff --git a/company_country/migrations/12.0.1.0.2/pre-migration.py b/company_country/migrations/12.0.1.0.2/pre-migration.py new file mode 100644 index 000000000..4ee127089 --- /dev/null +++ b/company_country/migrations/12.0.1.0.2/pre-migration.py @@ -0,0 +1,18 @@ +import logging +from psycopg2.extensions import AsIs + +from odoo import tools + + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + drop_table_model_company_country(cr) + + +def drop_table_model_company_country(cr): + tablename = 'company_country_config_settings' + if tools.table_exists(cr, tablename): + _logger.info("Dropping table %s", tablename) + cr.execute("DROP TABLE IF EXISTS %s;", (AsIs(tablename),)) diff --git a/company_country/models/res_config.py b/company_country/models/res_config.py index 18970e5a4..235ee26d5 100644 --- a/company_country/models/res_config.py +++ b/company_country/models/res_config.py @@ -9,7 +9,7 @@ from odoo.exceptions import ValidationError _logger = logging.getLogger(__name__) -class CompanyCountryConfigSettings(models.TransientModel): +class CompanyCountryConfigSettings(models.AbstractModel): _name = 'company.country.config.settings' _description = 'Company Country Configuration Settings' diff --git a/company_country/readme/CONTRIBUTORS.rst b/company_country/readme/CONTRIBUTORS.rst index 230f2b69b..a1d3375c2 100644 --- a/company_country/readme/CONTRIBUTORS.rst +++ b/company_country/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Moisés López +* Luis González