Browse Source

[MIG] crm_deduplicate_acl: Migration to 10.0

pull/721/head
Luis M. Ontalba 7 years ago
committed by Pedro M. Baeza
parent
commit
0f745133af
  1. 7
      partner_deduplicate_acl/README.rst
  2. 2
      partner_deduplicate_acl/__init__.py
  3. 2
      partner_deduplicate_acl/__manifest__.py
  4. 59
      partner_deduplicate_acl/i18n/hr.po
  5. 87
      partner_deduplicate_acl/i18n/nl_NL.po
  6. 51
      partner_deduplicate_acl/i18n/pt_BR.po
  7. 58
      partner_deduplicate_acl/i18n/tr.po
  8. 3
      partner_deduplicate_acl/views/base_partner_merge_view.xml
  9. 2
      partner_deduplicate_acl/wizards/__init__.py
  10. 90
      partner_deduplicate_acl/wizards/partner_merge.py
  11. 4
      partner_deduplicate_acl/wizards/partner_merge_view.xml

7
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 <jairo.llopis@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Luis M. Ontalba <luis.martinez@tecnativa.com>
Maintainer
----------

2
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

2
partner_deduplicate_acl/__openerp__.py → 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, "

59
partner_deduplicate_acl/i18n/hr.po

@ -3,14 +3,15 @@
# * crm_deduplicate_acl
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2016
# OCA Transbot <transbot@odoo-community.org>, 2017
# Bole <bole@dajmi5.com>, 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 <transbot@odoo-community.org>, 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 <bole@dajmi5.com>, 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"

87
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 <hageman.p@gmail.com>, 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 <hageman.p@gmail.com>, 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"

51
partner_deduplicate_acl/i18n/pt_BR.po

@ -3,15 +3,15 @@
# * crm_deduplicate_acl
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2016
# danimaribeiro <danimaribeiro@gmail.com>, 2016
# OCA Transbot <transbot@odoo-community.org>, 2017
# falexandresilva <falexandresilva@gmail.com>, 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 <danimaribeiro@gmail.com>, 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 <falexandresilva@gmail.com>, 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

58
partner_deduplicate_acl/i18n/tr.po

@ -3,14 +3,15 @@
# * crm_deduplicate_acl
#
# Translators:
# Ahmet Altinisik <aaltinisik@altinkaya.com.tr>, 2016
# OCA Transbot <transbot@odoo-community.org>, 2017
# Ediz Duman <neps1192@gmail.com>, 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 <aaltinisik@altinkaya.com.tr>, 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 <neps1192@gmail.com>, 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

3
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). -->
<odoo>
<menuitem id='root_menu' name='Tools' parent='base.menu_base_partner' sequence="25"/>
<menuitem id='root_menu' name='Tools'
parent='sales_team.menu_base_partner' sequence="25"/>
<menuitem id='partner_merge_automatic_menu'
action='crm.action_partner_deduplicate'
groups='group_automatically'

2
partner_deduplicate_acl/wizards/__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 partner_merge

90
partner_deduplicate_acl/wizards/partner_merge.py

@ -3,21 +3,85 @@
# © 2016 Tecnativa, S.L. - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import SUPERUSER_ID, models
from odoo import _, SUPERUSER_ID, models
from odoo.exceptions import UserError
import logging
_logger = logging.getLogger('base.partner.merge')
class BasePartnerMergeAutomaticWizard(models.TransientModel):
_inherit = "base.partner.merge.automatic.wizard"
def _merge(self, cr, uid, partner_ids, dst_partner=None, context=None):
"""Allow non-admins to merge partners"""
user = self.pool["res.users"].browse(cr, uid, uid, context=context)
return super(BasePartnerMergeAutomaticWizard, self)._merge(
cr,
SUPERUSER_ID if user.has_group(
'crm_deduplicate_acl.group_unrestricted') else uid,
partner_ids,
dst_partner=dst_partner,
context=context
)
def _merge(self, partner_ids, dst_partner=None):
""" private implementation of merge partner
:param partner_ids : ids of partner to merge
:param dst_partner : record of destination res.partner
"""
Partner = self.env['res.partner']
partner_ids = Partner.browse(partner_ids).exists()
if len(partner_ids) < 2:
return
if len(partner_ids) > 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()

4
partner_deduplicate_acl/wizards/partner_merge_view.xml

@ -9,10 +9,10 @@
<field name="model">base.partner.merge.automatic.wizard</field>
<field name="inherit_id" ref="crm.base_partner_merge_automatic_wizard_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='automatic_process_cb']" position="attributes">
<xpath expr="//button[@name='action_start_automatic_process']" position="attributes">
<attribute name="groups">crm_deduplicate_acl.group_automatically</attribute>
</xpath>
<xpath expr="//button[@name='update_all_process_cb']" position="attributes">
<xpath expr="//button[@name='action_update_all_process']" position="attributes">
<attribute name="groups">crm_deduplicate_acl.group_automatically</attribute>
</xpath>
</field>

Loading…
Cancel
Save