From 2ef86e76aaeb9f08b7868d7cd31aa718c959a8dc Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Sun, 5 Aug 2018 14:38:54 +0200 Subject: [PATCH 1/3] partner_sector: allow to use in individuals --- partner_sector/README.rst | 13 ++++- partner_sector/__openerp__.py | 5 +- partner_sector/models/__init__.py | 2 + partner_sector/models/base_config_settings.py | 14 +++++ partner_sector/models/sale_config_settings.py | 14 +++++ .../security/partner_sector_security.xml | 11 ++++ partner_sector/views/base_config_settings.xml | 23 ++++++++ partner_sector/views/res_partner_view.xml | 55 +++++++++++++++++++ partner_sector/views/sale_config_settings.xml | 21 +++++++ 9 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 partner_sector/models/base_config_settings.py create mode 100644 partner_sector/models/sale_config_settings.py create mode 100644 partner_sector/security/partner_sector_security.xml create mode 100644 partner_sector/views/base_config_settings.xml create mode 100644 partner_sector/views/sale_config_settings.xml diff --git a/partner_sector/README.rst b/partner_sector/README.rst index 684172e7e..29bc8b09e 100644 --- a/partner_sector/README.rst +++ b/partner_sector/README.rst @@ -16,6 +16,16 @@ To manage sectors, you need to: * Go to *Sales > Configuration > Address Book > Sectors*. +By default only companies have sectors. To activate sectors in individuals also, +you need to activate the following setting: + +* Go to *Settings > General Settings > Sector in contacts > Use sector for individuals* + +Or, if you have *Sales* or *CRM* modules installed: + +* Go to *Sales > Configuration > Settings > Partner Sector > Use sector for individuals* + + Usage ===== @@ -24,8 +34,6 @@ To use this module, you need to: * Go to any partner's form. -Only companies have sectors. - .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot @@ -55,6 +63,7 @@ Contributors * Javier Iniesta * Vicent Cubells * Pedro M. Baeza +* Jordi Ballester Alomar Maintainer ---------- diff --git a/partner_sector/__openerp__.py b/partner_sector/__openerp__.py index 41badc2df..c5d4626f6 100644 --- a/partner_sector/__openerp__.py +++ b/partner_sector/__openerp__.py @@ -14,11 +14,14 @@ "application": False, "installable": True, "depends": [ - "base", + "base_setup", ], "data": [ "security/ir.model.access.csv", + "security/partner_sector_security.xml", "views/res_partner_sector_view.xml", "views/res_partner_view.xml", + "views/base_config_settings.xml", + "views/sale_config_settings.xml" ] } diff --git a/partner_sector/models/__init__.py b/partner_sector/models/__init__.py index 7976185ff..a265df98f 100644 --- a/partner_sector/models/__init__.py +++ b/partner_sector/models/__init__.py @@ -5,3 +5,5 @@ from . import res_partner from . import res_partner_sector +from . import base_config_settings +from . import sale_config_settings diff --git a/partner_sector/models/base_config_settings.py b/partner_sector/models/base_config_settings.py new file mode 100644 index 000000000..a77894dcc --- /dev/null +++ b/partner_sector/models/base_config_settings.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Eficent Business and IT Consulting Services, S.L. + +from openerp import fields, models + + +class BaseConfigSettings(models.TransientModel): + _inherit = 'base.config.settings' + + group_use_partner_sector_for_person = fields.Boolean( + 'Use sector for individuals', + help="Set if you want to be able use sectors for " + "individuals also.", + implied_group='partner_sector.group_use_partner_sector_for_person') diff --git a/partner_sector/models/sale_config_settings.py b/partner_sector/models/sale_config_settings.py new file mode 100644 index 000000000..a5c5e6802 --- /dev/null +++ b/partner_sector/models/sale_config_settings.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Eficent Business and IT Consulting Services, S.L. + +from openerp import fields, models + + +class SaleConfigSettings(models.TransientModel): + _inherit = 'sale.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 " + "individuals also.", + implied_group='partner_sector.group_use_partner_sector_for_person') diff --git a/partner_sector/security/partner_sector_security.xml b/partner_sector/security/partner_sector_security.xml new file mode 100644 index 000000000..3258c1e5f --- /dev/null +++ b/partner_sector/security/partner_sector_security.xml @@ -0,0 +1,11 @@ + + + + + + + Use sector for individuals + + + + diff --git a/partner_sector/views/base_config_settings.xml b/partner_sector/views/base_config_settings.xml new file mode 100644 index 000000000..5ee26cee5 --- /dev/null +++ b/partner_sector/views/base_config_settings.xml @@ -0,0 +1,23 @@ + + + + + + General Settings + base.config.settings + + + + + + + + + + + diff --git a/partner_sector/views/res_partner_view.xml b/partner_sector/views/res_partner_view.xml index 2f433196f..bfe9c6325 100644 --- a/partner_sector/views/res_partner_view.xml +++ b/partner_sector/views/res_partner_view.xml @@ -15,6 +15,14 @@ + + + + + @@ -50,4 +58,51 @@ + + + + Partner form with sector + res.partner + + + + + {'invisible': 0} + + + {'invisible': 0} + + + {'invisible': 0} + + + {'invisible': 0} + + + + + + Partner tree with sector + res.partner + + + + + {'invisible': 0} + + + + + + Partner search with sector + res.partner + + + + + + + + + diff --git a/partner_sector/views/sale_config_settings.xml b/partner_sector/views/sale_config_settings.xml new file mode 100644 index 000000000..16763ac1a --- /dev/null +++ b/partner_sector/views/sale_config_settings.xml @@ -0,0 +1,21 @@ + + + + + partner sector settings + sale.config.settings + + +
+ + +
+
+
+
+
From 09325517c47738a129b4d042edd4e0cf5df48ec7 Mon Sep 17 00:00:00 2001 From: mreficent Date: Mon, 20 Aug 2018 13:22:11 +0200 Subject: [PATCH 2/3] [IMP] partner_sector: pump version --- partner_sector/README.rst | 20 +++++++++++++------- partner_sector/__openerp__.py | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/partner_sector/README.rst b/partner_sector/README.rst index 29bc8b09e..441582cca 100644 --- a/partner_sector/README.rst +++ b/partner_sector/README.rst @@ -1,6 +1,6 @@ -.. 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 +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 ============== Partner Sector @@ -48,13 +48,19 @@ Known issues / Roadmap 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 ======= +Images +------ + +* Odoo Community Association: `Icon `_. + Contributors ------------ @@ -78,4 +84,4 @@ 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 http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_sector/__openerp__.py b/partner_sector/__openerp__.py index c5d4626f6..53dba5a55 100644 --- a/partner_sector/__openerp__.py +++ b/partner_sector/__openerp__.py @@ -6,9 +6,9 @@ { "name": "Partner Sector", "summary": "Add partner sectors", - "version": "9.0.1.1.2", + "version": "9.0.2.0.0", "category": "Customer Relationship Management", - "website": "http://www.tecnativa.com", + "website": "https://github.com/OCA/partner-contact", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, From 7d56c21accd695e6c04f0422be0f4b77595e4c36 Mon Sep 17 00:00:00 2001 From: mreficent Date: Mon, 20 Aug 2018 13:36:31 +0200 Subject: [PATCH 3/3] [FIX] Correct pylint in all partner_sector repo --- partner_changeset/README.rst | 2 +- partner_changeset/models/res_partner.py | 15 +++---- .../models/res_partner_changeset.py | 40 +++++++++---------- partner_contact_height/README.rst | 7 +--- partner_contact_nutrition/README.rst | 7 +--- partner_contact_weight/README.rst | 7 +--- partner_identification/README.rst | 2 +- partner_identification/__openerp__.py | 8 ++-- 8 files changed, 37 insertions(+), 51 deletions(-) diff --git a/partner_changeset/README.rst b/partner_changeset/README.rst index 8b9ab712b..1d0d46887 100644 --- a/partner_changeset/README.rst +++ b/partner_changeset/README.rst @@ -136,7 +136,7 @@ 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 smash it by providing detailed and welcomed feedback. Credits ======= diff --git a/partner_changeset/models/res_partner.py b/partner_changeset/models/res_partner.py index fa6da68d3..0a85815b2 100644 --- a/partner_changeset/models/res_partner.py +++ b/partner_changeset/models/res_partner.py @@ -14,16 +14,16 @@ class ResPartner(models.Model): readonly=True) count_pending_changesets = fields.Integer( string='Changes', - compute='_count_pending_changesets', + compute='_compute_count_pending_changesets', search='_search_count_pending_changesets') - @api.one @api.depends('changeset_ids', 'changeset_ids.state') - def _count_pending_changesets(self): - changesets = self.changeset_ids.filtered( - lambda rev: rev.state == 'draft' and rev.partner_id == self - ) - self.count_pending_changesets = len(changesets) + def _compute_count_pending_changesets(self): + for res in self: + changesets = res.changeset_ids.filtered( + lambda rev: rev.state == 'draft' and rev.partner_id == res + ) + res.count_pending_changesets = len(changesets) @api.multi def write(self, values): @@ -39,6 +39,7 @@ class ResPartner(models.Model): def _search_count_pending_changesets(self, operator, value): if operator not in ('=', '!=', '<', '<=', '>', '>=', 'in', 'not in'): return [] + # pylint: disable=sql-injection query = ("SELECT p.id " "FROM res_partner p " "INNER JOIN res_partner_changeset r ON r.partner_id = p.id " diff --git a/partner_changeset/models/res_partner_changeset.py b/partner_changeset/models/res_partner_changeset.py index 380096456..e53f7c9c2 100644 --- a/partner_changeset/models/res_partner_changeset.py +++ b/partner_changeset/models/res_partner_changeset.py @@ -52,14 +52,14 @@ class ResPartnerChangeset(models.Model): models = self.env['ir.model'].search([]) return [(model.model, model.name) for model in models] - @api.one @api.depends('change_ids', 'change_ids.state') def _compute_state(self): - if all(change.state in ('done', 'cancel') for change - in self.mapped('change_ids')): - self.state = 'done' - else: - self.state = 'draft' + for res in self: + if all(change.state in ('done', 'cancel') for change + in res.mapped('change_ids')): + res.state = 'done' + else: + res.state = 'draft' @api.multi def apply(self): @@ -306,25 +306,25 @@ class ResPartnerChangesetChange(models.Model): _old_value_fields + _new_value_fields) - @api.one @api.depends('changeset_id.partner_id') def _compute_origin_values(self): - field_name = self.get_field_for_type(self.field_id, 'origin') - if self.state == 'draft': - value = self.changeset_id.partner_id[self.field_id.name] - else: - old_field = self.get_field_for_type(self.field_id, 'old') - value = self[old_field] - setattr(self, field_name, value) + for res in self: + field_name = res.get_field_for_type(res.field_id, 'origin') + if res.state == 'draft': + value = res.changeset_id.partner_id[res.field_id.name] + else: + old_field = res.get_field_for_type(res.field_id, 'old') + value = res[old_field] + setattr(res, field_name, value) - @api.one @api.depends(lambda self: self._value_fields) def _compute_value_display(self): - for prefix in ('origin', 'new'): - value = getattr(self, 'get_%s_value' % prefix)() - if self.field_id.ttype == 'many2one' and value: - value = value.display_name - setattr(self, '%s_value_display' % prefix, value) + for res in self: + for prefix in ('origin', 'new'): + value = getattr(res, 'get_%s_value' % prefix)() + if res.field_id.ttype == 'many2one' and value: + value = value.display_name + setattr(res, '%s_value_display' % prefix, value) @api.model def get_field_for_type(self, field, prefix): diff --git a/partner_contact_height/README.rst b/partner_contact_height/README.rst index 59ff1bf92..49095021f 100644 --- a/partner_contact_height/README.rst +++ b/partner_contact_height/README.rst @@ -21,11 +21,6 @@ To use this module, you need to: :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/134/9.0 -Known issues / Roadmap -====================== - -* ... - Bug Tracker =========== @@ -60,4 +55,4 @@ 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. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_contact_nutrition/README.rst b/partner_contact_nutrition/README.rst index 2319a04c0..2293be293 100644 --- a/partner_contact_nutrition/README.rst +++ b/partner_contact_nutrition/README.rst @@ -26,11 +26,6 @@ To use this module, you need to: :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/134/9.0 -Known issues / Roadmap -====================== - -* ... - Bug Tracker =========== @@ -65,4 +60,4 @@ 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. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_contact_weight/README.rst b/partner_contact_weight/README.rst index 5a1e514ec..4d1fcf479 100644 --- a/partner_contact_weight/README.rst +++ b/partner_contact_weight/README.rst @@ -21,11 +21,6 @@ To use this module, you need to: :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/134/9.0 -Known issues / Roadmap -====================== - -* ... - Bug Tracker =========== @@ -60,4 +55,4 @@ 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. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_identification/README.rst b/partner_identification/README.rst index 891529c36..1b1a59862 100644 --- a/partner_identification/README.rst +++ b/partner_identification/README.rst @@ -15,7 +15,7 @@ and vary from country to country. * Fiscal ID's * Membership numbers * Driver license -* ... +* … Installation diff --git a/partner_identification/__openerp__.py b/partner_identification/__openerp__.py index 11c0f0d9e..340f13613 100644 --- a/partner_identification/__openerp__.py +++ b/partner_identification/__openerp__.py @@ -19,10 +19,10 @@ 'security/ir.model.access.csv', ], 'author': 'ChriCar Beteiligungs- und Beratungs- GmbH, ' - 'Antiun Ingeniería S.L.', - 'Camptocamp,' - 'ACSONE SA/NV,' - 'Odoo Community Association (OCA)' + 'Antiun Ingeniería S.L., ' + 'Camptocamp, ' + 'ACSONE SA/NV, ' + 'Odoo Community Association (OCA)', 'website': 'https://odoo-community.org/', 'license': 'AGPL-3', 'installable': True,