[IMP] base: Add support for private addresses
This is a backport of commit https://github.com/odoo/odoo/commit/2f15a5fa647d55df36c9019df467802a3aa9b4e3 Purpose ======= Add the possibility to create private addresses, only accessible for a subset of users. Specification ============= - Add a new 'Private' partner type - Add a res.groups in base 'Access to Private Addresses' - Add ir.rules for the following behavior: - Every employees/internal users can read non-private addresses - Only users in group_private_addresses can access private addresses - Add in base a simplified form view for private addresses The following points won't be backported: - A HR Officer is automatically granted in group_private_addresses - Use the simplified form view to open the address_home_id form on employees That's because it requires to update 'base' to make it work. If a user only update 'hr', this will break his instance while 'base' isn't updated. But these modifications can be applied manually quite easily.
This commit is contained in:
@@ -212,7 +212,8 @@ class res_partner(osv.Model, format_address):
|
||||
[('contact', 'Contact'),
|
||||
('invoice', 'Invoice address'),
|
||||
('delivery', 'Shipping address'),
|
||||
('other', 'Other address')], 'Address Type',
|
||||
('other', 'Other address'),
|
||||
("private", "Private Address")], string='Address Type',
|
||||
help="Used to select automatically the right address according to the context in sales and purchases documents."),
|
||||
'street': fields.char('Street'),
|
||||
'street2': fields.char('Street2'),
|
||||
|
||||
@@ -330,6 +330,50 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Special restricted view for private address, with limited "named" info that
|
||||
can be traced back to the employee -->
|
||||
<record id="res_partner_view_form_private" model="ir.ui.view">
|
||||
<field name="name">res.partner.view.form.private</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="priority" eval="300"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Private Address Form">
|
||||
<sheet>
|
||||
<field name="type" invisible="1"/>
|
||||
<label for="name" class="oe_editonly"/>
|
||||
<field name="name" required="0"/>
|
||||
<group>
|
||||
<group>
|
||||
<label for="street" string="Address"/>
|
||||
<div>
|
||||
<div class="o_address_format" name="div_address">
|
||||
<field name="street" placeholder="Street..." class="o_address_street"/>
|
||||
<field name="street2" placeholder="Street 2..." class="o_address_street"/>
|
||||
<field name="city" placeholder="City" class="o_address_city"/>
|
||||
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}' context="{'country_id': country_id, 'zip': zip}"/>
|
||||
<field name="zip" placeholder="ZIP" class="o_address_zip"/>
|
||||
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
<field name="phone" widget="phone"/>
|
||||
<field name="mobile" widget="phone"/>
|
||||
<field name="email"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="Bank Accounts">
|
||||
<field name="bank_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="acc_number"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_res_partner_filter" model="ir.ui.view">
|
||||
<field name="name">res.partner.select</field>
|
||||
<field name="model">res.partner</field>
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
<field name="name">Contact Creation</field>
|
||||
</record>
|
||||
|
||||
<record id="group_private_addresses" model="res.groups">
|
||||
<field name="name">Access to Private Addresses</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
A group dedicated to the portal users, making groups
|
||||
restrictions more convenient.
|
||||
@@ -153,6 +157,37 @@
|
||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
<!-- Security restriction for private addresses -->
|
||||
<record id="res_partner_rule_private_employee" model="ir.rule">
|
||||
<field name="name">res.partner.rule.private.employee</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
<field name="domain_force">
|
||||
[('type', '!=', 'private')]
|
||||
</field>
|
||||
<field name="groups" eval="[
|
||||
(4, ref('base.group_user')),
|
||||
]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
<!-- Relex previous rule for group_private_addresses -->
|
||||
<record id="res_partner_rule_private_group" model="ir.rule">
|
||||
<field name="name">res.partner.rule.private.group</field>
|
||||
<field name="model_id" ref="base.model_res_partner"/>
|
||||
<field name="domain_force">
|
||||
[('type', '=', 'private')]
|
||||
</field>
|
||||
<field name="groups" eval="[
|
||||
(4, ref('base.group_private_addresses'))
|
||||
]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user