From 0f745133af8695bd013871758d2bb6e138744ca4 Mon Sep 17 00:00:00 2001 From: "Luis M. Ontalba" Date: Tue, 30 May 2017 14:47:55 +0200 Subject: [PATCH] [MIG] crm_deduplicate_acl: Migration to 10.0 --- partner_deduplicate_acl/README.rst | 7 +- partner_deduplicate_acl/__init__.py | 2 - .../{__openerp__.py => __manifest__.py} | 2 +- partner_deduplicate_acl/i18n/hr.po | 59 ++++++++++-- partner_deduplicate_acl/i18n/nl_NL.po | 87 ++++++++++++++++++ partner_deduplicate_acl/i18n/pt_BR.po | 51 +++++++++-- partner_deduplicate_acl/i18n/tr.po | 58 ++++++++++-- .../views/base_partner_merge_view.xml | 3 +- partner_deduplicate_acl/wizards/__init__.py | 2 - .../wizards/partner_merge.py | 90 ++++++++++++++++--- .../wizards/partner_merge_view.xml | 4 +- 11 files changed, 317 insertions(+), 48 deletions(-) rename partner_deduplicate_acl/{__openerp__.py => __manifest__.py} (96%) create mode 100644 partner_deduplicate_acl/i18n/nl_NL.po diff --git a/partner_deduplicate_acl/README.rst b/partner_deduplicate_acl/README.rst index c924ca5da..b4fa43db1 100644 --- a/partner_deduplicate_acl/README.rst +++ b/partner_deduplicate_acl/README.rst @@ -42,17 +42,15 @@ Usage To use this module, you need to: #. Ask your admin to give you the new rights. -#. Go to *Sales > Tools > Deduplicate Contacts* as usual. +#. Go to *CRM > Tools > Deduplicate Contacts* as usual. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/111/9.0 + :target: https://runbot.odoo-community.org/runbot/111/10.0 Known issues / Roadmap ====================== -* Wizard's code is partially written in old API because somehow [possibly] - the upstream's ``@mute_logger`` decorator prevents API from doing its magic. Bug Tracker =========== @@ -79,6 +77,7 @@ Contributors * Jairo Llopis * Vicent Cubells * Pedro M. Baeza +* Luis M. Ontalba Maintainer ---------- diff --git a/partner_deduplicate_acl/__init__.py b/partner_deduplicate_acl/__init__.py index e2a6315db..f8944f05c 100644 --- a/partner_deduplicate_acl/__init__.py +++ b/partner_deduplicate_acl/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# © 2016 Tecnativa, S.L. - Jairo Llopis -# © 2016 Tecnativa, S.L. - Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import wizards diff --git a/partner_deduplicate_acl/__openerp__.py b/partner_deduplicate_acl/__manifest__.py similarity index 96% rename from partner_deduplicate_acl/__openerp__.py rename to partner_deduplicate_acl/__manifest__.py index f4673ce49..57588c75e 100644 --- a/partner_deduplicate_acl/__openerp__.py +++ b/partner_deduplicate_acl/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Deduplicate Contacts ACL", "summary": "Contact deduplication with fine-grained permission control", - "version": "9.0.1.1.0", + "version": "10.0.1.0.0", "category": "Tools", "website": "http://www.tecnativa.com", "author": "Tecnativa, " diff --git a/partner_deduplicate_acl/i18n/hr.po b/partner_deduplicate_acl/i18n/hr.po index bab09bae8..2153af29b 100644 --- a/partner_deduplicate_acl/i18n/hr.po +++ b/partner_deduplicate_acl/i18n/hr.po @@ -3,14 +3,15 @@ # * crm_deduplicate_acl # # Translators: -# OCA Transbot , 2016 +# OCA Transbot , 2017 +# Bole , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-07 03:39+0000\n" -"PO-Revision-Date: 2016-12-07 03:39+0000\n" -"Last-Translator: OCA Transbot , 2016\n" +"POT-Creation-Date: 2017-07-08 01:22+0000\n" +"PO-Revision-Date: 2017-07-08 01:22+0000\n" +"Last-Translator: Bole , 2017\n" "Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,6 +19,16 @@ msgstr "" "Language: hr\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:46 +#, python-format +msgid "" +"All contacts must have the same email. Only the Administrator can merge " +"contacts with different emails." +msgstr "" +"Svi kontakti moraju imati isti e-mail, samo administrator može spajati " +"kontakte sa različitim mailovima." + #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_automatically msgid "Automatically" @@ -29,22 +40,56 @@ msgstr "Automatski" msgid "Deduplicate Contacts" msgstr "Ukloni duple kontakte" +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:28 +#, python-format +msgid "" +"For safety reasons, you cannot merge more than 3 contacts together. You can " +"re-open the wizard several times if needed." +msgstr "" +"Iz sigurnosnih razloga nije moguće spajati više od 3 kontakta. Možete " +"pokrenuti čarobnjaka za spajanje više puta ukoliko je potrebno." + #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_manually msgid "Manually" msgstr "Ručno" +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:81 +#, python-format +msgid "Merged with the following partners:" +msgstr "Spojen sa sljedećim partnerima:" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:69 +#, python-format +msgid "" +"Only the destination contact may be linked to existing Journal Items. Please" +" ask the Administrator if you need to merge several contacts linked to " +"existing Journal Items." +msgstr "" +"Samo odredišni kontakt može biti povezan sa postojećim stavkama dnevnika. " +"Molimo zamolite administratora ukoliko je potrebno spojiti nekoliko " +"kontakata povezanih sa postojećim stavkama dnevnika." + #. module: crm_deduplicate_acl #: model:ir.ui.menu,name:crm_deduplicate_acl.root_menu msgid "Tools" -msgstr "" +msgstr "Alati" #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_unrestricted msgid "Without restrictions" msgstr "Bez ograničenja" +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:38 +#, python-format +msgid "You cannot merge a contact with one of his parent." +msgstr "Nije moguće spojiti kontakt sa svojim nadređenim." + #. module: crm_deduplicate_acl #: model:ir.model,name:crm_deduplicate_acl.model_base_partner_merge_automatic_wizard msgid "base.partner.merge.automatic.wizard" -msgstr "" +msgstr "base.partner.merge.automatic.wizard" diff --git a/partner_deduplicate_acl/i18n/nl_NL.po b/partner_deduplicate_acl/i18n/nl_NL.po new file mode 100644 index 000000000..aaf3cf59b --- /dev/null +++ b/partner_deduplicate_acl/i18n/nl_NL.po @@ -0,0 +1,87 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_deduplicate_acl +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-04 15:47+0000\n" +"PO-Revision-Date: 2017-12-04 15:47+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl_NL\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:46 +#, python-format +msgid "" +"All contacts must have the same email. Only the Administrator can merge " +"contacts with different emails." +msgstr "" + +#. module: crm_deduplicate_acl +#: model:res.groups,name:crm_deduplicate_acl.group_automatically +msgid "Automatically" +msgstr "Automatisch" + +#. module: crm_deduplicate_acl +#: model:ir.module.category,name:crm_deduplicate_acl.category +#: model:ir.ui.menu,name:crm_deduplicate_acl.partner_merge_automatic_menu +msgid "Deduplicate Contacts" +msgstr "Ontdubbel Relaties" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:28 +#, python-format +msgid "" +"For safety reasons, you cannot merge more than 3 contacts together. You can " +"re-open the wizard several times if needed." +msgstr "" + +#. module: crm_deduplicate_acl +#: model:res.groups,name:crm_deduplicate_acl.group_manually +msgid "Manually" +msgstr "Handmatig" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:81 +#, python-format +msgid "Merged with the following partners:" +msgstr "Samengevoegd met de volgende contacten:" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:69 +#, python-format +msgid "" +"Only the destination contact may be linked to existing Journal Items. Please" +" ask the Administrator if you need to merge several contacts linked to " +"existing Journal Items." +msgstr "" + +#. module: crm_deduplicate_acl +#: model:ir.ui.menu,name:crm_deduplicate_acl.root_menu +msgid "Tools" +msgstr "" + +#. module: crm_deduplicate_acl +#: model:res.groups,name:crm_deduplicate_acl.group_unrestricted +msgid "Without restrictions" +msgstr "Zonder beperkingen" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:38 +#, python-format +msgid "You cannot merge a contact with one of his parent." +msgstr "Je kan geen relatie samenvoegen met één van haar ouders." + +#. module: crm_deduplicate_acl +#: model:ir.model,name:crm_deduplicate_acl.model_base_partner_merge_automatic_wizard +msgid "base.partner.merge.automatic.wizard" +msgstr "base.partner.merge.automatic.wizard" diff --git a/partner_deduplicate_acl/i18n/pt_BR.po b/partner_deduplicate_acl/i18n/pt_BR.po index b347a75a1..82054b8cb 100644 --- a/partner_deduplicate_acl/i18n/pt_BR.po +++ b/partner_deduplicate_acl/i18n/pt_BR.po @@ -3,15 +3,15 @@ # * crm_deduplicate_acl # # Translators: -# OCA Transbot , 2016 -# danimaribeiro , 2016 +# OCA Transbot , 2017 +# falexandresilva , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-07 03:39+0000\n" -"PO-Revision-Date: 2016-12-07 03:39+0000\n" -"Last-Translator: danimaribeiro , 2016\n" +"POT-Creation-Date: 2017-06-19 02:41+0000\n" +"PO-Revision-Date: 2017-06-19 02:41+0000\n" +"Last-Translator: falexandresilva , 2017\n" "Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -19,10 +19,18 @@ msgstr "" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:46 +#, python-format +msgid "" +"All contacts must have the same email. Only the Administrator can merge " +"contacts with different emails." +msgstr "" + #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_automatically msgid "Automatically" -msgstr "" +msgstr "Automaticamente" #. module: crm_deduplicate_acl #: model:ir.module.category,name:crm_deduplicate_acl.category @@ -30,9 +38,32 @@ msgstr "" msgid "Deduplicate Contacts" msgstr "Deduplicar contatos" +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:28 +#, python-format +msgid "" +"For safety reasons, you cannot merge more than 3 contacts together. You can " +"re-open the wizard several times if needed." +msgstr "" + #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_manually msgid "Manually" +msgstr "Manualmente" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:81 +#, python-format +msgid "Merged with the following partners:" +msgstr "" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:69 +#, python-format +msgid "" +"Only the destination contact may be linked to existing Journal Items. Please" +" ask the Administrator if you need to merge several contacts linked to " +"existing Journal Items." msgstr "" #. module: crm_deduplicate_acl @@ -43,6 +74,12 @@ msgstr "Ferramentas" #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_unrestricted msgid "Without restrictions" +msgstr "Sem restrições" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:38 +#, python-format +msgid "You cannot merge a contact with one of his parent." msgstr "" #. module: crm_deduplicate_acl diff --git a/partner_deduplicate_acl/i18n/tr.po b/partner_deduplicate_acl/i18n/tr.po index c7b87e6a4..66140f1bf 100644 --- a/partner_deduplicate_acl/i18n/tr.po +++ b/partner_deduplicate_acl/i18n/tr.po @@ -3,14 +3,15 @@ # * crm_deduplicate_acl # # Translators: -# Ahmet Altinisik , 2016 +# OCA Transbot , 2017 +# Ediz Duman , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-24 01:15+0000\n" -"PO-Revision-Date: 2016-12-24 01:15+0000\n" -"Last-Translator: Ahmet Altinisik , 2016\n" +"POT-Creation-Date: 2017-06-10 03:36+0000\n" +"PO-Revision-Date: 2017-06-10 03:36+0000\n" +"Last-Translator: Ediz Duman , 2017\n" "Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,31 +19,70 @@ msgstr "" "Language: tr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:46 +#, python-format +msgid "" +"All contacts must have the same email. Only the Administrator can merge " +"contacts with different emails." +msgstr "" + #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_automatically msgid "Automatically" -msgstr "" +msgstr "Otomatikman" #. module: crm_deduplicate_acl #: model:ir.module.category,name:crm_deduplicate_acl.category #: model:ir.ui.menu,name:crm_deduplicate_acl.partner_merge_automatic_menu msgid "Deduplicate Contacts" -msgstr "Çift kayıtlı kişileri birleştir" +msgstr "Çift Kayıtlı Kontakları Birleştir" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:28 +#, python-format +msgid "" +"For safety reasons, you cannot merge more than 3 contacts together. You can " +"re-open the wizard several times if needed." +msgstr "" +"Güvenlik nedeniyle, en fazla 3 kişiyi birleştirebilirsiniz. Gerekirse birkaç" +" kez sihirbazını yeniden açabilirsiniz." #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_manually msgid "Manually" +msgstr "Manuel" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:81 +#, python-format +msgid "Merged with the following partners:" +msgstr "Aşağıdaki iş ortaklarla birleştirildi:" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:69 +#, python-format +msgid "" +"Only the destination contact may be linked to existing Journal Items. Please" +" ask the Administrator if you need to merge several contacts linked to " +"existing Journal Items." msgstr "" #. module: crm_deduplicate_acl #: model:ir.ui.menu,name:crm_deduplicate_acl.root_menu msgid "Tools" -msgstr "" +msgstr "Araçlar" #. module: crm_deduplicate_acl #: model:res.groups,name:crm_deduplicate_acl.group_unrestricted msgid "Without restrictions" -msgstr "" +msgstr "Kısıtlama olmaksızın" + +#. module: crm_deduplicate_acl +#: code:addons/crm_deduplicate_acl/wizards/partner_merge.py:38 +#, python-format +msgid "You cannot merge a contact with one of his parent." +msgstr "Bir kontağın kendi üst kontağı ile birleştiremezsiniz." #. module: crm_deduplicate_acl #: model:ir.model,name:crm_deduplicate_acl.model_base_partner_merge_automatic_wizard diff --git a/partner_deduplicate_acl/views/base_partner_merge_view.xml b/partner_deduplicate_acl/views/base_partner_merge_view.xml index bc0fea30f..5d43b1ca1 100644 --- a/partner_deduplicate_acl/views/base_partner_merge_view.xml +++ b/partner_deduplicate_acl/views/base_partner_merge_view.xml @@ -4,7 +4,8 @@ Copyright 2017 Tecnativa - Pedro M. Baeza License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> - + 3: + raise UserError(_("For safety reasons, you cannot merge more than" + " 3 contacts together. You can re-open" + " the wizard several times if needed.")) + + # check if the list of partners to merge contains child/parent relation + child_ids = self.env['res.partner'] + for partner_id in partner_ids: + child_ids |= Partner.search( + [('id', 'child_of', [partner_id.id])]) - partner_id + if partner_ids & child_ids: + raise UserError(_("You cannot merge a contact with one" + " of his parent.")) + + user = self.env.user + + if SUPERUSER_ID != self.env.uid and not user.has_group( + 'crm_deduplicate_acl.group_unrestricted') and\ + len(set(partner.email for partner in partner_ids)) > 1: + raise UserError(_("All contacts must have the same email." + " Only the Administrator can merge contacts" + " with different emails.")) + + # remove dst_partner from partners to merge + if dst_partner and dst_partner in partner_ids: + src_partners = partner_ids - dst_partner + else: + ordered_partners = self._get_ordered_partner(partner_ids.ids) + dst_partner = ordered_partners[-1] + src_partners = ordered_partners[:-1] + _logger.info("dst_partner: %s", dst_partner.id) + + # FIXME: is it still required to make and exception for + # account.move.line since accounting v9.0 ? + if SUPERUSER_ID != self.env.uid and not user.has_group( + 'crm_deduplicate_acl.group_unrestricted') and\ + 'account.move.line' in self.env and\ + self.env[ + 'account.move.line' + ].sudo().search([('partner_id', 'in', [partner.id for + partner in src_partners + ])]): + raise UserError(_("Only the destination contact may be linked to" + " existing Journal Items. Please ask the" + " Administrator if you need to merge several" + " contacts linked to existing Journal Items.")) + + # call sub methods to do the merge + self._update_foreign_keys(src_partners, dst_partner) + self._update_reference_fields(src_partners, dst_partner) + self._update_values(src_partners, dst_partner) + + _logger.info('(uid = %s) merged the partners %r with %s', + self._uid, src_partners.ids, dst_partner.id) + dst_partner.message_post(body='%s %s' % (_( + "Merged with the following partners:"), ", ".join( + '%s <%s> (ID %s)' % (p.name, p.email or 'n/a', p.id) + for p in src_partners))) + + # delete source partner, since they are merged + src_partners.unlink() diff --git a/partner_deduplicate_acl/wizards/partner_merge_view.xml b/partner_deduplicate_acl/wizards/partner_merge_view.xml index c4a556cc7..ed0839ba3 100644 --- a/partner_deduplicate_acl/wizards/partner_merge_view.xml +++ b/partner_deduplicate_acl/wizards/partner_merge_view.xml @@ -9,10 +9,10 @@ base.partner.merge.automatic.wizard - + crm_deduplicate_acl.group_automatically - + crm_deduplicate_acl.group_automatically