Skip to Content
Menu
This question has been flagged
1 Reply
845 Views

Hello,

I want to restrict users from accessing venders details from POS screen but they need to give access to clients details.

Avatar
Discard
Best Answer

Restricting users from accessing vendor details in POS (Point of Sale) V17 while allowing access to client details can be managed through a combination of access rights, record rules, and slight modifications to the POS screen. Here's how you can achieve this:

1. Understand the Default POS Behavior

By default, the Point of Sale module uses the res.partner model for both vendors and customers (clients). To restrict access to vendor details specifically, you need to define rules that:

  • Distinguish vendors from customers.
  • Prevent the POS user from accessing vendor records.

2. Steps to Restrict Access to Vendor Details

A. Create a Security Group for POS Users

  1. Go to Settings > Users & Companies > Groups.
  2. Create a new group, e.g., POS Limited Access.
  3. Assign this group to the POS users who should have restricted access.

B. Add a Field to Identify Vendors

To distinguish vendors from customers, use the supplier_rank field on res.partner.

  • Vendors have supplier_rank > 0, while customers usually have customer_rank > 0.

C. Create a Record Rule

Define a record rule that restricts access to vendor records for the POS Limited Access group.

  1. Go to Settings > Technical > Security > Record Rules.
  2. Create a new rule:
    • Model: res.partner.
    • Rule Definition: Restrict access to non-vendor records:
      ['|', ('supplier_rank', '=', 0), ('supplier_rank', '=', False)]
      
    • Applies To: Check Read only.
    • Groups: Assign the rule to the POS Limited Access group.

This rule ensures that users in the POS Limited Access group can only see partners who are not vendors.

D. Assign the Group to POS Users

  1. Go to Settings > Users & Companies > Users.
  2. Assign the POS Limited Access group to the relevant users.

3. Restrict Vendor Access in the POS Interface

The above steps restrict access to vendor records at the backend level. However, in the POS interface, you may need to customize the displayed data to ensure vendor details are not accessible.

Customize POS to Filter Only Customers

  1. Filter Customer Records: Modify the models definition in the POS JavaScript to only load customers (customer_rank > 0).
    Example:
    /** @odoo-module **/
    
    import PosDB from 'point_of_sale.models';
    
    const PosModelSuper = PosDB.prototype.models;
    PosDB.prototype.models = PosModelSuper.map(model => {
        if (model.model === 'res.partner') {
            model.domain = [['customer_rank', '>', 0]];
        }
        return model;
    });
    
    • Place this code in a custom module or inject it into the POS initialization.
  2. Prevent Access to Vendor Details: If there are additional screens or buttons in POS leading to vendor details, ensure those buttons or views are hidden for users with the POS Limited Access group.

4. Test the Configuration

  1. As an Admin:
    • Log in as an admin and verify that all partner records (both vendors and customers) are accessible.
  2. As a Restricted User:
    • Log in as a POS user with the POS Limited Access group.
    • Check the following:
      • Vendors are not visible in partner lists or searches.
      • Customers are fully accessible.
  3. POS Interface:
    • Start a POS session and confirm that only customers are displayed in the customer search or list.

5. Optional Enhancements

A. Add a Filter in Partner Lists

To explicitly show only customers in the POS interface, add a filter button that automatically applies customer_rank > 0.

B. Restrict Vendor Access in Other Modules

If POS users also have access to modules like Purchases or Contacts, ensure similar record rules are applied there.

Conclusion

By implementing the above steps, you can effectively restrict POS users from accessing vendor details while still allowing access to customer details. Let me know if you need further guidance or code snippets for customization!

Avatar
Discard