Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0][crm_deduplicate_acl] Deduplicate permission groups #76

Merged
merged 3 commits into from
Feb 29, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
95 changes: 95 additions & 0 deletions crm_deduplicate_acl/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.. 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

========================
Deduplicate Contacts ACL
========================

This module extends the functionality of the CRM contact deduplicator to add
permission groups that allow the matching users to use those tools, not
needing to be the sale settings manager.

Configuration
=============

To configure this module, you need to:

#. Go to *Settings > Users > Users*.
#. Choose a user.
#. Choose the desired permission level in *Appplication > Deduplicate
Contacts*:

- *Manually* allows him to do the manual deduplication process.
- *Automatically* allows him to do the automatic deduplication process.

.. warning::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not well rendered on RST

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope they fix the theme some day. In the mean time it writes "Warning", should be enough don't you think?

captura de pantalla de 2016-02-19 16-43-18

Automatic contact deduplication can easily lead to unwanted results.
Better backup before doing it.

- *Without restrictions* performs the deduplication with admin rigts, to
be able to update objects where the user would normally not have write
rights, and to allow him to merge contacts with different email addresses.

.. warning::
This is an advanced feature, be sure to train the user before enabling
this permission for him.

Usage
=====

To use this module, you need to:

#. Ask your admin to give you the new rigts.
#. Go to *Sales > 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/8.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
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/crm/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
<https://github.com/OCA/
crm/issues/new?body=module:%20
crm_deduplicate_acl%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.
5 changes: 5 additions & 0 deletions crm_deduplicate_acl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# 漏 2016 Antiun Ingenier铆a S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import wizards
24 changes: 24 additions & 0 deletions crm_deduplicate_acl/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# 漏 2016 Antiun Ingenier铆a S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Deduplicate Contacts ACL",
"summary": "Contact deduplication with fine-grained permission control",
"version": "8.0.1.0.0",
"category": "Tools",
"website": "http://www.antiun.com",
"author": "Antiun Ingenier铆a S.L., Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"crm",
],
"data": [
"security/crm_deduplicate_acl_security.xml",
"wizards/partner_merge_view.xml",
],
"images": [
"images/perms.png",
],
}
43 changes: 43 additions & 0 deletions crm_deduplicate_acl/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_deduplicate_acl
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-18 16:30+0000\n"
"PO-Revision-Date: 2016-02-18 17:32+0100\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: es\n"
"X-Generator: Poedit 1.8.6\n"

#. module: crm_deduplicate_acl
#: model:res.groups,name:crm_deduplicate_acl.group_automatically
msgid "Automatically"
msgstr "Autom谩ticamente"

#. module: crm_deduplicate_acl
#: model:ir.module.category,name:crm_deduplicate_acl.category
msgid "Deduplicate Contacts"
msgstr "Deduplicar contactos"

#. module: crm_deduplicate_acl
#: model:res.groups,name:crm_deduplicate_acl.group_manually
msgid "Manually"
msgstr "Manualmente"

#. module: crm_deduplicate_acl
#: model:res.groups,name:crm_deduplicate_acl.group_unrestricted
msgid "Without restrictions"
msgstr "Sin restricciones"

#. module: crm_deduplicate_acl
#: view:base.partner.merge.automatic.wizard:crm_deduplicate_acl.base_partner_merge_automatic_wizard_form
msgid "crm_deduplicate_acl.group_automatically"
msgstr "crm_deduplicate_acl.group_automatically"
Binary file added crm_deduplicate_acl/images/perms.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions crm_deduplicate_acl/security/crm_deduplicate_acl_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 漏 2016 Antiun Ingenier铆a S.L. - Jairo Llopis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->

<openerp>
<data>

<!-- New user group category -->
<record id="category" model="ir.module.category">
<field name="name">Deduplicate Contacts</field>
</record>

<!-- New user groups -->
<record id="group_manually" model="res.groups">
<field name="name">Manually</field>
<field name="category_id" ref="category"/>
</record>

<record id="group_automatically" model="res.groups">
<field name="name">Automatically</field>
<field name="category_id" ref="category"/>
<field name="implied_ids" eval="[(4, ref('group_manually'))]"/>
</record>

<record id="group_unrestricted" model="res.groups">
<field name="name">Without restrictions</field>
<field name="category_id" ref="category"/>
<field name="implied_ids" eval="[(4, ref('group_automatically'))]"/>
</record>

<!-- Respect previous behavior -->
<record id="base.group_system" model="res.groups">
<field name="implied_ids" eval="[(4, ref('group_unrestricted'))]"/>
</record>

<!-- New permission for menuitem -->
<record id="crm.partner_merge_automatic_menu" model="ir.ui.menu">
<field
name="groups_id"
eval="[(4, ref('group_manually'))]"/>
</record>

</data>
</openerp>
Binary file added crm_deduplicate_acl/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions crm_deduplicate_acl/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# 漏 2016 Antiun Ingenier铆a S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import partner_merge
25 changes: 25 additions & 0 deletions crm_deduplicate_acl/wizards/partner_merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# 漏 2016 Antiun Ingenier铆a S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import SUPERUSER_ID, api, models


class BasePartnerMergeAutomaticWizard(models.TransientModel):
_inherit = "base.partner.merge.automatic.wizard"

@api.cr_uid_context
def _merge(self, cr, uid, partner_ids, dst_partner=None, context=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using new API (@api.model)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See known issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can implement this with @api.v7 and @api.v8 methods

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need to duplicate efforts, api takes care of morphing calls from v8.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is the missing model_cr decorator, that has already landed in master. For v8 I could do that, but it's not called from v8 methods anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trick is to make a v7 wrapper, and call to the v8 method from that wrapper, and you do the hard coding all inside the v8 method, with new API. Anyway, it's already merged in the repository by the impatient @rafaelbn 馃槣

"""Allow non-admins to merge partners with different emails."""
# Know if user has unrestricted access
group_unrestricted = self.pool["ir.model.data"].xmlid_to_object(
cr, uid, "crm_deduplicate_acl.group_unrestricted", context)
user = self.pool["res.users"].browse(cr, uid, uid, context)

# Run as admin if so
return super(BasePartnerMergeAutomaticWizard, self)._merge(
cr,
SUPERUSER_ID if group_unrestricted in user.groups_id else uid,
partner_ids,
dst_partner,
context)
31 changes: 31 additions & 0 deletions crm_deduplicate_acl/wizards/partner_merge_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 漏 2016 Antiun Ingenier铆a S.L. - Jairo Llopis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->

<openerp>
<data>

<record id="base_partner_merge_automatic_wizard_form" model="ir.ui.view">
<field name="name">Restrict automatic merge access</field>
<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">
<attribute name="groups">
crm_deduplicate_acl.group_automatically
</attribute>
</xpath>
<xpath expr="//button[@name='update_all_process_cb']"
position="attributes">
<attribute name="groups">
crm_deduplicate_acl.group_automatically
</attribute>
</xpath>
</field>
</record>

</data>
</openerp>