Showing posts with label Odoo. Show all posts
Showing posts with label Odoo. Show all posts

Wednesday, 26 October 2016

Best way to create See Own Customers rule in Odoo


Odoo does not provide by default a rule to limit users to see their own customers, at least at the time when I am writing this article. So many people are asking the question in different odoo forums, how they can limit users to see their own customer similar to the See Own Leads group rules of the Sale.

For the answer of this question, many have suggested  to create a record rule from Odoo Settings --> Technical --> Security --> Record Rules like ir.ui.view.custom object. Set the object as res.partner and Add related domain in Domain section as:



['|', ('user_id', '=', user.id), ('user_id', '=', False)]

like in the answers in this post and this and this

This is valid domain but I am not the one who suggest this domain on record rule for such use case, since the problem with this is that the res.partner object is not just for customers, its also has records for companies, users as well as suppliers. So what this domain does is it limit all that other records too. It is also possible that you will also got such access errors on different other objects as I got in sale module while approaching sale dashboard:





The requested operation cannot be completed due to security restrictions. Please contact your system administrator.
(Document type: res.users, Operation: read)


Hence we need a way to exclude all other than customer record from this domain.

This domain will I think is best suited if you want to limit just customers:


['|', '|', '|', ('user_id', '=', user.id), ('user_id', '=', False), ('create_uid', '=', user.id), ('customer','=',False)]

and to apply this via code :


<record model="ir.rule" id="custom_rule_see_own_customer">
    <field name="name">custom.rule.see.own.customer</field>
    <field name="model_id" ref="base.model_res_partner"/>
    <field name="domain_force">ABOVE DOMAIN HERE</field>
    <field name="groups" eval="[(4,ref('base.group_sale_salesman'))]"/>
    <field name="perm_read" eval="True"/>
    <field name="perm_write" eval="True"/> 
    <field name="perm_unlink" eval="True"/> 
    <field name="perm_create" eval="True"/>
</record>

Wednesday, 16 September 2015

How to configure hierarchy Sales Team Structure in Odoo / OpenERP

Often times while following OpenERP/Odoo for sales management, it is our requirement to have a proper team hierarchy with the secure desired flow of information. For that Odoo provides us the ability to create our own sales teams with the desired access control for the flow of information in the team hierarchy. In this tutorial we will use use the default Odoo provided roles or group. For the one who wants to customize the access control as per his/her requirement, he/she have to create their own security rules etc.

One of major concerns for the Odoo users is to easily configure the sales team, since Odoo have the poorest documentation [as per the online sorcerers :) ]. So to configure your sales teams properly, likely this tutorial will helps you.

In this tutorial I am considering this sales team hierarchy:
  • Sales Manager (Team Leader)
    • Sales Person 
      • Sales And Quotations

Setting proper sales team configurations can solve the mentioned problems.
Sales Teams can be configured by the following steps:
  • Create Sales Teams: Go to Sales Tab Configuration Sales Teams.  Give the newly created sales team some desired name like Team A.
  • Set Team Leader (Sale Manger) for Sales Team. From Sales Configuration Sales Team. Make sure that the Team Leader has proper access rights (instructions are given below for setting access rights.
  • Assigning Team members of that Sales team. Add some users as a team member to new sales team. Each user should have proper access rights. (Instructions are given below).
  • Set Sales Person and Sales Team on Quotations and Sales Orders. Now as our sales team is created, it’s time to associate some sales and quotation to our sales team. To do this one should set Sales Person and Sales Team while creating new Quotations and Sale order. Set Sales Team from the Other Information Tab.

How to set access rights For Team Leader & Sales Person: 

To configure access rights: settings users user access rights

  • For Team Leader set sales value to Manager 
  • For Team Leader set sales value to See Own Leads