Browse Source

Merge pull request #50 from mdietrichc2c/partner-merge-rights

Add user rights to limit access to certain users (and give all rights to others)
pull/62/head
Pedro M. Baeza 10 years ago
parent
commit
b006947b91
  1. 2
      base_partner_merge/__openerp__.py
  2. 34
      base_partner_merge/base_partner_merge.py
  3. 6
      base_partner_merge/base_partner_merge_view.xml
  4. 11
      base_partner_merge/security/security.xml

2
base_partner_merge/__openerp__.py

@ -10,7 +10,7 @@ backport module, to be removed when we switch to saas2 on the private servers
'base',
],
'data': [
'security/ir.model.access.csv',
'security/security.xml',
'base_partner_merge_view.xml',
],
'installable': True,

34
base_partner_merge/base_partner_merge.py

@ -340,6 +340,16 @@ class MergePartnerAutomatic(orm.TransientModel):
partner_ids = proxy.exists(cr, uid, list(partner_ids),
context=context)
if not self.pool['res.users'].has_group(
cr, uid, 'base_partner_merge.group_partner_merge'
):
raise orm.except_orm(
_('Error'),
_("You do not belong to the 'Partner Merge' group. "
"Please contact the Administrator to get access to "
"the partner merge functionality."))
if len(partner_ids) < 2:
return
@ -350,10 +360,9 @@ class MergePartnerAutomatic(orm.TransientModel):
"together. You can re-open the wizard several times if "
"needed."))
if (openerp.SUPERUSER_ID != uid
and len(set(partner.email for partner
in proxy.browse(cr, uid, partner_ids,
context=context))) > 1):
if (len(set(partner.email for partner
in proxy.browse(cr, uid, partner_ids,
context=context))) > 1):
raise orm.except_orm(
_('Error'),
_("All contacts must have the same email. Only the "
@ -372,23 +381,6 @@ class MergePartnerAutomatic(orm.TransientModel):
src_partners = ordered_partners[:-1]
_logger.info("dst_partner: %s", dst_partner.id)
if (openerp.SUPERUSER_ID != uid
and self._model_is_installed(cr, uid, 'account.move.line',
context=context)
and self.pool.get('account.move.line'
).search(cr, openerp.SUPERUSER_ID,
[('partner_id',
'in',
[partner.id for partner
in src_partners])],
context=context)):
raise orm.except_orm(
_('Error'),
_("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_it = lambda function: function(cr, uid, src_partners,
dst_partner, context=context)

6
base_partner_merge/base_partner_merge_view.xml

@ -2,7 +2,7 @@
<openerp>
<data>
<!-- the sequence of the configuration sub menu is 30 -->
<menuitem id='root_menu' name='Tools' parent='base.menu_base_partner' sequence="25"/>
<menuitem id='root_menu' name='Tools' parent='base.menu_base_partner' sequence="25" groups='group_partner_merge'/>
<record model="ir.actions.act_window" id="base_partner_merge_automatic_act">
<field name="name">Deduplicate Contacts</field>
@ -15,7 +15,7 @@
<menuitem id='partner_merge_automatic_menu'
action='base_partner_merge_automatic_act'
groups='base.group_system'
groups='group_partner_merge'
parent='root_menu' />
<record model='ir.ui.view' id='base_partner_merge_automatic_wizard_form'>
@ -116,7 +116,7 @@
</record>
<act_window id="action_partner_merge" res_model="base.partner.merge.automatic.wizard" src_model="res.partner"
target="new" multi="True" key2="client_action_multi" view_mode="form" name="Automatic Merge"/>
target="new" multi="True" key2="client_action_multi" view_mode="form" name="Automatic Merge" groups="group_partner_merge"/>
</data>

11
base_partner_merge/security/security.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="res.groups" id="group_partner_merge">
<field name="name">Partner Merge</field>
</record>
<record model="res.groups" id="base.group_system">
<field name="implied_ids" eval="[(4, ref('group_partner_merge'))]"/>
</record>
</data>
</openerp>
Loading…
Cancel
Save