From 0080f6f432648eafa1a75bdebb945236e320c32a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 28 Jun 2016 10:48:28 +0200 Subject: [PATCH 1/6] base_continent: port to new API + usability enhancements Update to latest OCA coding standards Add README.rst --- base_continent/README.rst | 59 +++++++++++++++ base_continent/__init__.py | 25 +------ base_continent/__openerp__.py | 31 ++------ base_continent/base_continent.py | 34 --------- base_continent/base_continent_view.xml | 73 ------------------- base_continent/country.py | 30 -------- .../continent_data.xml} | 0 base_continent/models/__init__.py | 5 ++ base_continent/models/base_continent.py | 18 +++++ base_continent/models/country.py | 12 +++ base_continent/models/partner.py | 13 ++++ base_continent/partner.py | 34 --------- base_continent/views/continent.xml | 41 +++++++++++ base_continent/views/country.xml | 29 ++++++++ base_continent/views/partner.xml | 28 +++++++ 15 files changed, 215 insertions(+), 217 deletions(-) create mode 100644 base_continent/README.rst delete mode 100644 base_continent/base_continent.py delete mode 100644 base_continent/base_continent_view.xml delete mode 100644 base_continent/country.py rename base_continent/{base_continent_data.xml => data/continent_data.xml} (100%) create mode 100644 base_continent/models/__init__.py create mode 100644 base_continent/models/base_continent.py create mode 100644 base_continent/models/country.py create mode 100644 base_continent/models/partner.py delete mode 100644 base_continent/partner.py create mode 100644 base_continent/views/continent.xml create mode 100644 base_continent/views/country.xml create mode 100644 base_continent/views/partner.xml diff --git a/base_continent/README.rst b/base_continent/README.rst new file mode 100644 index 000000000..b4a8eaabf --- /dev/null +++ b/base_continent/README.rst @@ -0,0 +1,59 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============== +Base Continent +============== + +This module adds a *Continent* object (res.continent) and a link between continents and countries. It also adds a continent field on partners (automatically set if a country has been selected on the partner). + +Configuration +============= + +Go to the menu *Sales > Configuration > Address Book > Localization > Continents* to see the list of continents and assign countries to continents. + +Usage +===== + +You can now group partners per continent. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/134/8.0 + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Contributors +------------ + +* Romain Deheele + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/base_continent/__init__.py b/base_continent/__init__.py index 89a35d724..cde864bae 100644 --- a/base_continent/__init__.py +++ b/base_continent/__init__.py @@ -1,24 +1,3 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Author: Romain Deheele -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- -from . import base_continent -from . import country -from . import partner +from . import models diff --git a/base_continent/__openerp__.py b/base_continent/__openerp__.py index adbec72f2..2f9b0d73d 100644 --- a/base_continent/__openerp__.py +++ b/base_continent/__openerp__.py @@ -1,41 +1,26 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Author: Romain Deheele -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2014-2016 Camptocamp SA (Author: Romain Deheele) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Continent management', - 'version': '8.0.1.0.0', + 'version': '8.0.1.0.1', 'depends': ['base'], 'author': "Camptocamp,Odoo Community Association (OCA)", 'license': 'AGPL-3', 'description': """ -This module introduces continent management. +This module introduces continent management ============================================ Links continents to countries, adds continent field on partner form """, 'category': 'Generic Modules/Base', 'data': [ - 'base_continent_view.xml', - 'base_continent_data.xml', + 'views/continent.xml', + 'views/country.xml', + 'views/partner.xml', + 'data/continent_data.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/base_continent/base_continent.py b/base_continent/base_continent.py deleted file mode 100644 index c48051841..000000000 --- a/base_continent/base_continent.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Romain Deheele -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.osv.orm import Model -from openerp.osv import fields - - -class Continent(Model): - _name = 'res.continent' - _description = 'Continent' - _columns = { - 'name': fields.char('Continent Name', size=64, - help='The full name of the continent.', - required=True, translate=True), - } - _order = 'name' diff --git a/base_continent/base_continent_view.xml b/base_continent/base_continent_view.xml deleted file mode 100644 index 7522bbf01..000000000 --- a/base_continent/base_continent_view.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - res.country.tree.add_continent - res.country - - - - - - - - - - - res.country.form.add_continent - res.country - - - - - - - - - - res.continent.tree - res.continent - - - - - - - - - res.continent.form - res.continent - -
- - - -
-
-
- - - Continents - ir.actions.act_window - res.continent - form - Display and manage the list of all continents that can be assigned to your partner records. - - - - - - - res.partner.form.add_continent - res.partner - - - - - - - - -
-
diff --git a/base_continent/country.py b/base_continent/country.py deleted file mode 100644 index b4395763b..000000000 --- a/base_continent/country.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Romain Deheele -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.osv.orm import Model -from openerp.osv import fields - - -class Country(Model): - _inherit = 'res.country' - _columns = { - 'continent_id': fields.many2one('res.continent', 'Continent'), - } diff --git a/base_continent/base_continent_data.xml b/base_continent/data/continent_data.xml similarity index 100% rename from base_continent/base_continent_data.xml rename to base_continent/data/continent_data.xml diff --git a/base_continent/models/__init__.py b/base_continent/models/__init__.py new file mode 100644 index 000000000..7403f56be --- /dev/null +++ b/base_continent/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- + +from . import base_continent +from . import country +from . import partner diff --git a/base_continent/models/base_continent.py b/base_continent/models/base_continent.py new file mode 100644 index 000000000..011b4faec --- /dev/null +++ b/base_continent/models/base_continent.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Camptocamp SA (Author: Romain Deheele) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields + + +class Continent(models.Model): + _name = 'res.continent' + _description = 'Continent' + _order = 'name' + + name = fields.Char( + string='Continent Name', + help='The full name of the continent.', + required=True, translate=True) + country_ids = fields.One2many( + 'res.country', 'continent_id', string="Countries") diff --git a/base_continent/models/country.py b/base_continent/models/country.py new file mode 100644 index 000000000..6e2e3cb8f --- /dev/null +++ b/base_continent/models/country.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Camptocamp SA (Author: Romain Deheele) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields + + +class Country(models.Model): + _inherit = 'res.country' + + continent_id = fields.Many2one( + 'res.continent', string='Continent', ondelete='restrict') diff --git a/base_continent/models/partner.py b/base_continent/models/partner.py new file mode 100644 index 000000000..434770013 --- /dev/null +++ b/base_continent/models/partner.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# © 2014-2016 Camptocamp SA (Author: Romain Deheele) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields + + +class Partner(models.Model): + _inherit = 'res.partner' + + continent_id = fields.Many2one( + 'res.continent', related='country_id.continent_id', + string='Continent', readonly=True, store=True) diff --git a/base_continent/partner.py b/base_continent/partner.py deleted file mode 100644 index a5656652c..000000000 --- a/base_continent/partner.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Romain Deheele -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.osv.orm import Model -from openerp.osv import fields - - -class Partner(Model): - _inherit = 'res.partner' - _columns = { - 'continent_id': fields.related('country_id', 'continent_id', - type='many2one', - relation='res.continent', - string='Continent', - readonly=True, store=True), - } diff --git a/base_continent/views/continent.xml b/base_continent/views/continent.xml new file mode 100644 index 000000000..1bb0519b2 --- /dev/null +++ b/base_continent/views/continent.xml @@ -0,0 +1,41 @@ + + + + + + res.continent.tree + res.continent + + + + + + + + + res.continent.form + res.continent + +
+ + + + + + +
+
+
+ + + Continents + res.continent + tree,form + Display and manage the list of all continents that can be assigned to your partner records. + + + + + +
+
diff --git a/base_continent/views/country.xml b/base_continent/views/country.xml new file mode 100644 index 000000000..20a6a95ef --- /dev/null +++ b/base_continent/views/country.xml @@ -0,0 +1,29 @@ + + + + + + res.country.tree.add_continent + res.country + + + + + + + + + + + res.country.form.add_continent + res.country + + + + + + + + + + diff --git a/base_continent/views/partner.xml b/base_continent/views/partner.xml new file mode 100644 index 000000000..9705c1d98 --- /dev/null +++ b/base_continent/views/partner.xml @@ -0,0 +1,28 @@ + + + + + + res.partner.form.add_continent + res.partner + + + + + + + + + + res.partner.form.add_continent + res.partner + + + + + + + + + + From 276fae4b2a370fddf444d94e8d3b8797858819c5 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 28 Jun 2016 10:52:52 +0200 Subject: [PATCH 2/6] Remove description from __openerp__.py --- base_continent/__openerp__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/base_continent/__openerp__.py b/base_continent/__openerp__.py index 2f9b0d73d..ed52e1714 100644 --- a/base_continent/__openerp__.py +++ b/base_continent/__openerp__.py @@ -9,12 +9,6 @@ 'depends': ['base'], 'author': "Camptocamp,Odoo Community Association (OCA)", 'license': 'AGPL-3', - 'description': """ -This module introduces continent management -============================================ -Links continents to countries, -adds continent field on partner form -""", 'category': 'Generic Modules/Base', 'data': [ 'views/continent.xml', From d66d0555ac5784cf07706c6301249d7254eaee2a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 28 Jun 2016 10:58:51 +0200 Subject: [PATCH 3/6] XML Code cleanup --- base_continent/views/continent.xml | 5 ++++- base_continent/views/country.xml | 9 ++++----- base_continent/views/partner.xml | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/base_continent/views/continent.xml b/base_continent/views/continent.xml index 1bb0519b2..dc031771a 100644 --- a/base_continent/views/continent.xml +++ b/base_continent/views/continent.xml @@ -34,7 +34,10 @@ Display and manage the list of all continents that can be assigned to your partner records. - + diff --git a/base_continent/views/country.xml b/base_continent/views/country.xml index 20a6a95ef..1a8d87ac7 100644 --- a/base_continent/views/country.xml +++ b/base_continent/views/country.xml @@ -1,11 +1,11 @@ - - + + res.country.tree.add_continent res.country - + @@ -13,8 +13,7 @@ - - + res.country.form.add_continent res.country diff --git a/base_continent/views/partner.xml b/base_continent/views/partner.xml index 9705c1d98..19267f675 100644 --- a/base_continent/views/partner.xml +++ b/base_continent/views/partner.xml @@ -2,7 +2,7 @@ - + res.partner.form.add_continent res.partner @@ -14,7 +14,7 @@ - res.partner.form.add_continent + res.partner.filter.add_continent res.partner From 13b0533ca2236267cc376b3ff07530955140b403 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 28 Jun 2016 11:36:24 +0200 Subject: [PATCH 4/6] Update README with remarks of Eric Caudal --- base_continent/README.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/base_continent/README.rst b/base_continent/README.rst index b4a8eaabf..eda08ea1c 100644 --- a/base_continent/README.rst +++ b/base_continent/README.rst @@ -29,19 +29,21 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed `feedback -`_. +help us smashing it by providing a detailed and welcomed feedback. Credits ======= +Images +------ + +* Odoo Community Association: `Icon `_. + Contributors ------------ * Romain Deheele +* Alexis de Lattre Maintainer ---------- From d7a950e0ea9531098502bf99c60d0fb9de7ef845 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 28 Jun 2016 16:20:03 +0200 Subject: [PATCH 5/6] Assign a continent for each country --- base_continent/__openerp__.py | 1 + base_continent/data/country_data.xml | 1021 ++++++++++++++++++++++++++ 2 files changed, 1022 insertions(+) create mode 100644 base_continent/data/country_data.xml diff --git a/base_continent/__openerp__.py b/base_continent/__openerp__.py index ed52e1714..d3e2c2b9a 100644 --- a/base_continent/__openerp__.py +++ b/base_continent/__openerp__.py @@ -15,6 +15,7 @@ 'views/country.xml', 'views/partner.xml', 'data/continent_data.xml', + 'data/country_data.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/base_continent/data/country_data.xml b/base_continent/data/country_data.xml new file mode 100644 index 000000000..6d9fe09c5 --- /dev/null +++ b/base_continent/data/country_data.xml @@ -0,0 +1,1021 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ff2fa4220f2cbd1b89279e75cde75efe3a279dca Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 2 Jul 2016 21:01:04 +0200 Subject: [PATCH 6/6] FIX infinite loop --- base_partner_sequence/__openerp__.py | 2 +- base_partner_sequence/models/partner.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/base_partner_sequence/__openerp__.py b/base_partner_sequence/__openerp__.py index be79f9951..f4799fefd 100644 --- a/base_partner_sequence/__openerp__.py +++ b/base_partner_sequence/__openerp__.py @@ -34,5 +34,5 @@ 'views/partner_view.xml', ], "active": False, - "installable": True + "installable": True, } diff --git a/base_partner_sequence/models/partner.py b/base_partner_sequence/models/partner.py index 8a6f84274..42ff65159 100644 --- a/base_partner_sequence/models/partner.py +++ b/base_partner_sequence/models/partner.py @@ -23,13 +23,15 @@ class ResPartner(models.Model): """ if not vals and not partner_id: raise Exception('Either field values or an id must be provided.') - vals = vals or {} + if vals is None: + vals = {} + values = vals.copy() # only assign a 'ref' to commercial partners if partner_id: partner = self.browse(partner_id) - vals.setdefault('is_company', partner.is_company) - vals.setdefault('parent_id', partner.parent_id.id) - return vals.get('is_company') or not vals.get('parent_id') + values.setdefault('is_company', partner.is_company) + values.setdefault('parent_id', partner.parent_id.id) + return values.get('is_company') or not values.get('parent_id') @api.model def _commercial_fields(self):