Skip to content

[18.0][product_cost_security] Unable to change picked on stock move without product cost read rights #2256

@uvid-ivan

Description

@uvid-ivan

Module

product_cost_security

Describe the bug

The module prevents changin boolean field "picked" on stock.move.line when installed for users without read access to product cost fields. Inventory users should be able to change field "picked" on stock.move even if they are not allowed to see product costs.

amount = - unit_amount * self.product_id.standard_price

Since standard_price requires read access on the product cost, this raises an AccessError for users without required rights when product_cost_security is installed.
It seems that this call should likely use sudo() and price saved in cache as it was resolved in issue #2115
However, i am not sure if any other change should be made along this.

Image

To Reproduce

Affected versions: 18.0.1.0.0

Steps to reproduce the behavior:

  1. Start new odoo18 database
  2. Login as admin
  3. Install modules: project_stock_account, product_cost_security
  4. Give admin user permission for Analytic Accounting
  5. Activate developer mode
  6. Enable Analytic Costs on operation type
  7. Create/edit stock.picking with operation type from previous step and add project
  8. In stock.picking lines, select "picked" field to be shown
  9. In stock.picking lines, change boolean field "picked" and save document
    Result:
    Saving "picked" field fails with an access error when reading product_id.standard_price.

Expected behavior
Changing boolean field "picked" on stock move should succeed for users without product cost access rights. The module should not block standard stock operations.

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