Skip to content

purchase_security: seller (product.supplerinfo) access can raise contact access error #2905

@dalonsod

Description

@dalonsod

Due to Contact security restrictions added by this addon, in some situations, restricted users could not save PO lines, when a product with restricted vendor prices are involved. Not sure which the best solution for this could be.

Module

purchase_security

Describe the bug

For a restricted Purchase user (e.g. "See own documents" one), a read access error is raised when a product with seller records is selected, if one of them belongs to a vendor (contact) restricted for the user.

To Reproduce

At least at 17.0, but presumably at other versions as well.

Steps to reproduce the behavior:

  1. From a Purchase "Manager" user, add a Purchase record (Vendor pricelist) to a product A, for a certain vendor V.
  2. Ensure that selected Vendor V has a Purchase Representative set.
  3. From a Purchase "User (own orders)" user that is not vendor V Purchase Representative, open a PO and try to select product A for a new line => a 'read' access error for Contact is raised.

Expected behavior
No error should be raised. Not sure what should Odoo do/select instead.

What should be the proper approach? I've checked that PO line's _suggest_quantity() method (that calls _select_seller() at product module) is the error responsible, so adding here a sudo() could solve it. Other approach should be adding record rules for product.supplierinfo (and hide those that belong to restricted vendors, for this group). Both solutions are not equivalent anyway....

cc @victoralmau @StefanRijnhart

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions