Hello Community, I would like to make user can only see his contact but admin can sell all contact.How can I do that. Please suggest me.Thanks you.
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hello GGWP,
You can create a read access record rule for the res.partner model.
With the following domain : [('id', '=', user.partner_id.id)].
And assign that rule to a group of common users not your admin.
Hope it helps.
Hello GGWP,
Please find below code it may help you,
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Step 1: xml Code
<record model="ir.module.category" id="module_category_contact">
        <field name="name">Contacts</field>
        <field name="sequence">20</field>
        <field name="parent_id" eval="False"/>
    </record>
<record id="module_group_allow_contact_menu" model="ir.module.category">
        <field name="name">Contacts</field>
        <field name="parent_id" ref="module_category_contact"/>
    </record>
<record id="group_allow_contact_menu_user" model="res.groups">
        <field name="name">User: Own Documents Only</field>
        <field name="category_id" ref="module_group_allow_contact_menu"/>
    </record>
<record id="group_allow_contact_menu_admin" model="res.groups">
        <field name="name">Administration</field>
        <field name="category_id" ref="module_group_allow_contact_menu"/>
    </record>
Step 2: py Code
class ResPartner(models.Model):
    _inherit = "res.partner"
@api.model
	    def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
	        if self.env.user.has_group('module_name.group_name'):
	            domain += [('user_id', '=', self.env.user.id)]
	        # user_id is field whose string is Salesperson
	        return super(ResPartner, self).search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order)
@api.model
	    def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
	        if self.user_has_groups('module_name.group_name'):
	            if 'user_id' or 'parent_id' or 'country_id' in groupby:
	                domain += [('user_id', '=', self.env.user.id)]
	        return super(ResPartner, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, 
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Prijavi| Related Posts | Odgovori | Prikazi | Aktivnost | |
|---|---|---|---|---|
|  | 0 mar. 22  | 1920 | ||
|  | 1 mar. 18  | 4858 | ||
|  | 0 sep. 22  | 2332 | ||
|  | 2 okt. 24  | 3344 | ||
|  | 0 mar. 15  | 4457 | 
