diff --git a/partner_sector/README.rst b/partner_sector/README.rst index 714b7b81c..fd6578ede 100644 --- a/partner_sector/README.rst +++ b/partner_sector/README.rst @@ -6,20 +6,20 @@ Partner Sector ============== -This module adds the concept of economic sector for partners. +This module adds secondary industries for partners. Configuration ============= -To manage sectors, you need to: +To manage industries, you need to: -* Go to *Contacts > Configuration > Contacts > Sectors*. +* Go to *Contacts > Configuration > Sectors of Activity*. -By default only companies have sectors. To activate sectors in individuals also, +By default only companies have industries. To activate industries in individuals also, you need to activate the following setting: -* Go to *Settings > General Settings > Partner Sectors > Sector in contacts > Use sector for individuals* +* Go to *Settings > General Settings > Partner Industries > Industry in contacts > Use industry for individuals* Usage @@ -37,15 +37,16 @@ To use this module, you need to: Known issues / Roadmap ====================== -* Add a unique constraint for name per parent sector. +* Add a unique constraint for name per parent industry. 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. +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 smash it by providing detailed and welcomed feedback. Credits ======= @@ -65,6 +66,7 @@ Contributors * Pedro M. Baeza * Luis M. Ontalba * Jordi Ballester Alomar +* Miquel Raïch Maintainer ---------- diff --git a/partner_sector/__manifest__.py b/partner_sector/__manifest__.py index a1f40ed01..b24bca817 100644 --- a/partner_sector/__manifest__.py +++ b/partner_sector/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Partner Sector", - "summary": "Add partner sectors", + "summary": "Add secondary partner industries", "version": "11.0.1.0.0", "category": "Customer Relationship Management", "website": "https://github.com/OCA/partner-contact", @@ -17,8 +17,8 @@ ], "data": [ "security/ir.model.access.csv", - "security/partner_sector_security.xml", - "views/res_partner_sector_view.xml", + "security/partner_industry_security.xml", + "views/res_partner_industry_view.xml", "views/res_partner_view.xml", "views/res_config_settings.xml", ] diff --git a/partner_sector/models/__init__.py b/partner_sector/models/__init__.py index c88809dad..5bceca821 100644 --- a/partner_sector/models/__init__.py +++ b/partner_sector/models/__init__.py @@ -1,5 +1,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import res_partner -from . import res_partner_sector +from . import res_partner_industry from . import res_config_settings diff --git a/partner_sector/models/res_config_settings.py b/partner_sector/models/res_config_settings.py index 3748cc25b..1188aab08 100644 --- a/partner_sector/models/res_config_settings.py +++ b/partner_sector/models/res_config_settings.py @@ -7,8 +7,8 @@ from odoo import fields, models class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' - group_use_partner_sector_for_person = fields.Boolean( - 'Use sector for individuals', - help="Set if you want to be able to use sectors for " + group_use_partner_industry_for_person = fields.Boolean( + 'Use industry for individuals', + help="Set if you want to be able to use industries for " "individuals also.", - implied_group='partner_sector.group_use_partner_sector_for_person') + implied_group='partner_sector.group_use_partner_industry_for_person') diff --git a/partner_sector/models/res_partner.py b/partner_sector/models/res_partner.py index 7ed1d4a5a..1cd0e786b 100644 --- a/partner_sector/models/res_partner.py +++ b/partner_sector/models/res_partner.py @@ -1,5 +1,6 @@ # Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta # Copyright 2016 Tecnativa S.L. - Vicent Cubells +# Copyright 2018 Eficent Business and IT Consulting Services, S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, exceptions, fields, models, _ @@ -8,15 +9,15 @@ from odoo import api, exceptions, fields, models, _ class ResPartner(models.Model): _inherit = 'res.partner' - sector_id = fields.Many2one(comodel_name='res.partner.sector', - string='Main Sector') + industry_id = fields.Many2one(string='Main Industry') - secondary_sector_ids = fields.Many2many( - comodel_name='res.partner.sector', string="Secondary Sectors", - domain="[('id', '!=', sector_id)]") + secondary_industry_ids = fields.Many2many( + comodel_name='res.partner.industry', string="Secondary Industries", + domain="[('id', '!=', industry_id)]") - @api.constrains('sector_id', 'secondary_sector_ids') - def _check_sectors(self): - if self.sector_id in self.secondary_sector_ids: - raise exceptions.UserError(_('The main sector must be different ' - 'from the secondary sectors.')) + @api.constrains('industry_id', 'secondary_industry_ids') + def _check_industries(self): + if self.industry_id in self.secondary_industry_ids: + raise exceptions.UserError( + _('The main industry must be different ' + 'from the secondary industries.')) diff --git a/partner_sector/models/res_partner_sector.py b/partner_sector/models/res_partner_industry.py similarity index 74% rename from partner_sector/models/res_partner_sector.py rename to partner_sector/models/res_partner_industry.py index ddca30935..26c5a953d 100644 --- a/partner_sector/models/res_partner_sector.py +++ b/partner_sector/models/res_partner_industry.py @@ -1,22 +1,22 @@ # Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta # Copyright 2016 Tecnativa S.L. - Vicent Cubells # Copyright 2016 Tecnativa S.L. - Pedro M. Baeza +# Copyright 2018 Eficent Business and IT Consulting Services, S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, exceptions, fields, models, _ -class ResPartnerSector(models.Model): - _name = 'res.partner.sector' +class ResPartnerIndustry(models.Model): + _inherit = 'res.partner.industry' _order = "parent_left" _parent_order = "name" _parent_store = True - _description = "Sector" - name = fields.Char(required=True, translate=True) - parent_id = fields.Many2one(comodel_name='res.partner.sector', + name = fields.Char(required=True) + parent_id = fields.Many2one(comodel_name='res.partner.industry', ondelete='restrict') - child_ids = fields.One2many(comodel_name='res.partner.sector', + child_ids = fields.One2many(comodel_name='res.partner.industry', inverse_name='parent_id', string="Children") parent_left = fields.Integer('Parent Left', index=True) @@ -38,4 +38,4 @@ class ResPartnerSector(models.Model): def _check_parent_id(self): if not self._check_recursion(): raise exceptions.ValidationError( - _('Error! You cannot create recursive sectors.')) + _('Error! You cannot create recursive industries.')) diff --git a/partner_sector/security/ir.model.access.csv b/partner_sector/security/ir.model.access.csv index 0fce0fe55..f5ff379d7 100644 --- a/partner_sector/security/ir.model.access.csv +++ b/partner_sector/security/ir.model.access.csv @@ -1,5 +1,4 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_res_partner_sector_public","res_partner_sector group_public","model_res_partner_sector","base.group_public",1,0,0,0 -"access_res_partner_sector_portal","res_partner_sector group_portal","model_res_partner_sector","base.group_portal",1,0,0,0 -"access_res_partner_sector_group_partner_manager","res_partner_sector group_partner_manager","model_res_partner_sector","base.group_partner_manager",1,1,1,1 -"access_res_partner_sector_group_user","res_partner_sector group_user","model_res_partner_sector","base.group_user",1,0,0,0 +"access_res_partner_industry_public","res_partner_industry group_public","model_res_partner_industry","base.group_public",1,0,0,0 +"access_res_partner_industry_portal","res_partner_industry group_portal","model_res_partner_industry","base.group_portal",1,0,0,0 +"access_res_partner_industry_group_partner_manager","res_partner_industry group_partner_manager","model_res_partner_industry","base.group_partner_manager",1,1,1,1 diff --git a/partner_sector/security/partner_industry_security.xml b/partner_sector/security/partner_industry_security.xml new file mode 100644 index 000000000..2797ea1e3 --- /dev/null +++ b/partner_sector/security/partner_industry_security.xml @@ -0,0 +1,7 @@ + + + + Use industry for individuals + + + diff --git a/partner_sector/security/partner_sector_security.xml b/partner_sector/security/partner_sector_security.xml deleted file mode 100644 index a7d31318b..000000000 --- a/partner_sector/security/partner_sector_security.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Use sector for individuals - - - diff --git a/partner_sector/tests/__init__.py b/partner_sector/tests/__init__.py index 151d9a105..c6dbb5a41 100644 --- a/partner_sector/tests/__init__.py +++ b/partner_sector/tests/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import test_res_partner_sector +from . import test_res_partner_industry diff --git a/partner_sector/tests/test_res_partner_sector.py b/partner_sector/tests/test_res_partner_sector.py index 611d7b189..d4e078760 100644 --- a/partner_sector/tests/test_res_partner_sector.py +++ b/partner_sector/tests/test_res_partner_sector.py @@ -7,33 +7,33 @@ from odoo.tests import common from odoo.exceptions import ValidationError -class TestResPartnerSector(common.SavepointCase): +class TestResPartnerIndustry(common.SavepointCase): @classmethod def setUpClass(cls): - super(TestResPartnerSector, cls).setUpClass() - cls.Sector = cls.env['res.partner.sector'] - cls.sector_main = cls.Sector.create({ + super(TestResPartnerIndustry, cls).setUpClass() + cls.industry_model = cls.env['res.partner.industry'] + cls.industry_main = cls.industry_model.create({ 'name': 'Test', }) - cls.sector_child = cls.Sector.create({ + cls.industry_child = cls.industry_model.create({ 'name': 'Test child', - 'parent_id': cls.sector_main.id, + 'parent_id': cls.industry_main.id, }) - def test_check_sectors(self): + def test_check_industries(self): with self.assertRaises(ValidationError): self.env['res.partner'].create({ 'name': 'Test', - 'sector_id': self.sector_main.id, - 'secondary_sector_ids': [(4, self.sector_main.id)], + 'industry_id': self.industry_main.id, + 'secondary_industry_ids': [(4, self.industry_main.id)], }) def test_check_recursion(self): with self.assertRaises(ValidationError): - self.sector_main.parent_id = self.sector_child.id + self.industry_main.parent_id = self.industry_child.id def test_name(self): self.assertEqual( - self.sector_child.name_get()[0][1], + self.industry_child.name_get()[0][1], "Test / Test child", ) diff --git a/partner_sector/views/res_config_settings.xml b/partner_sector/views/res_config_settings.xml index 92671613a..7dd67890b 100644 --- a/partner_sector/views/res_config_settings.xml +++ b/partner_sector/views/res_config_settings.xml @@ -9,16 +9,21 @@ -

Partner Sectors

-
+

Partner Industries

+
- +
-
diff --git a/partner_sector/views/res_partner_industry_view.xml b/partner_sector/views/res_partner_industry_view.xml new file mode 100644 index 000000000..26c2a7878 --- /dev/null +++ b/partner_sector/views/res_partner_industry_view.xml @@ -0,0 +1,29 @@ + + + + + + Industry + res.partner.industry + + + + + + + + + + Industry + res.partner.industry + + + + + + + + + diff --git a/partner_sector/views/res_partner_sector_view.xml b/partner_sector/views/res_partner_sector_view.xml deleted file mode 100644 index 065b75c30..000000000 --- a/partner_sector/views/res_partner_sector_view.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - Sectors - res.partner.sector - form - tree - - - - Partner Sector tree - res.partner.sector - - - - - - - - - - - diff --git a/partner_sector/views/res_partner_view.xml b/partner_sector/views/res_partner_view.xml index b26b025fc..fa4b2084c 100644 --- a/partner_sector/views/res_partner_view.xml +++ b/partner_sector/views/res_partner_view.xml @@ -4,103 +4,109 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> - - Partner form with sector + + Partner form with industry res.partner - - - + - - - - Partner tree with sector + + Partner tree with industry res.partner - - - Partner search with sector + + Partner search with industry res.partner - + - + context="{'group_by': 'industry_id'}"/> - + - - Partner form with sector + + Partner form with industry res.partner - - + + - + {'invisible': 0} - - + + + + + + Partner form with industry + res.partner + + + + {'invisible': 0} - - + + {'invisible': 0} - + {'invisible': 0} - - Partner tree with sector + + Partner tree with industry res.partner - - + + - + {'invisible': 0} - - Partner search with sector + + Partner search with industry res.partner - - + + - +