diff --git a/crm_usability/__init__.py b/crm_usability/__init__.py new file mode 100644 index 0000000..3b4c3ed --- /dev/null +++ b/crm_usability/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import wizard diff --git a/crm_usability/__openerp__.py b/crm_usability/__openerp__.py new file mode 100644 index 0000000..a7e9c0c --- /dev/null +++ b/crm_usability/__openerp__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# © 2016 Akretion (http://www.akretion.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# @author Alexis de Lattre + +{ + 'name': 'CRM Usability', + 'version': '8.0.1.0.0', + 'category': 'Customer Relationship Management', + 'license': 'AGPL-3', + 'summary': 'CRM usability enhancements', + 'description': """ +CRM Usability +============= + +Some enhancements in the *Merge Partners* wizard: + +* take into account the unaccent option of the server config file +* add optional group by on 'customer' and 'supplier' (active by default) + +This module has been written by Alexis de Lattre from Akretion +. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['crm'], + 'data': ['wizard/base_partner_merge_view.xml'], + 'installable': True, +} diff --git a/crm_usability/wizard/__init__.py b/crm_usability/wizard/__init__.py new file mode 100644 index 0000000..a93a5ab --- /dev/null +++ b/crm_usability/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import base_partner_merge diff --git a/crm_usability/wizard/base_partner_merge.py b/crm_usability/wizard/base_partner_merge.py new file mode 100644 index 0000000..d84fe8a --- /dev/null +++ b/crm_usability/wizard/base_partner_merge.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# © 2016 Akretion (http://www.akretion.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# @author Alexis de Lattre + +from openerp import models, fields, tools + + +class MergePartnerAutomatic(models.TransientModel): + _inherit = 'base.partner.merge.automatic.wizard' + + group_by_customer = fields.Boolean('Customer', default=True) + group_by_supplier = fields.Boolean('Supplier', default=True) + + def _generate_query(self, fields, maximum_group=100): + sql = super(MergePartnerAutomatic, self)._generate_query( + fields, maximum_group=maximum_group) + name_sql_original = 'lower(name)' + if name_sql_original in sql: + if tools.config.get('unaccent', False): + sql = sql.replace( + name_sql_original, + "unaccent(lower(replace(name, ' ', '')))") + else: + sql = sql.replace( + name_sql_original, + "lower(replace(name, ' ', ''))") + + return sql diff --git a/crm_usability/wizard/base_partner_merge_view.xml b/crm_usability/wizard/base_partner_merge_view.xml new file mode 100644 index 0000000..781eb99 --- /dev/null +++ b/crm_usability/wizard/base_partner_merge_view.xml @@ -0,0 +1,23 @@ + + + + + + + rvip.base.partner.merge.automatic.wizard.form + base.partner.merge.automatic.wizard + + + + + + + + + + + + + + +