Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [ADD] stock_inventory_security #2189

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from

Conversation

ivantodorovich
Copy link
Contributor

In standard, the inventory adjustments can only be applied by Inventory / Manager users.

This module introduces a new security group named Stock: Inventory Adjustments, which
grants regular stock users the ability to apply inventory adjustments.

@ivantodorovich ivantodorovich force-pushed the 16.0-add-stock-inventory-security branch from e635cd0 to 5383c1b Compare November 7, 2024 16:28
@ivantodorovich ivantodorovich marked this pull request as ready for review November 7, 2024 16:32
Copy link
Contributor

@yankinmax yankinmax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice and well tested, thanks @ivantodorovich

@rousseldenis
Copy link
Contributor

rousseldenis commented Nov 12, 2024

In standard, the inventory adjustments can only be applied by Inventory / Manager users.

This module introduces a new security group named Stock: Inventory Adjustments, which grants regular stock users the ability to apply inventory adjustments.

@ivantodorovich

I suppose you are aware the Odoo standard use case is:

  • The inventory users can count the stock levels.
  • Then, the manager confirm the counted quantity.

@rousseldenis rousseldenis added this to the 16.0 milestone Nov 12, 2024
Copy link

@Camille0907 Camille0907 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically LGTM, I just have a few questions

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, fixed!

@users("inventory", "admin")
def test_inventory_user_lot_action(self):
"""Test that the inventory user gets into inventory mode from lots"""
res = self.product_lot.with_user(self.env.user).action_lot_open_quants()

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I've just realized that there were a copy/paste issue in my comment : my question was not about search_default_my_count but about with_user(self.env.user) -> So, when do you need the with_user, when don't you ?

Copy link
Contributor Author

@ivantodorovich ivantodorovich Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @users decorator will set the user in self.env.

However, recordsets that were already initialized during setUpClass, referenced in variables like self.product_lot, have their own env set, which isn't modified by the decorator.

So, we need to set the user when interacting with them

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okayy thank you for the explanation 👍

@ivantodorovich
Copy link
Contributor Author

In standard, the inventory adjustments can only be applied by Inventory / Manager users.
This module introduces a new security group named Stock: Inventory Adjustments, which grants regular stock users the ability to apply inventory adjustments.

@ivantodorovich

I suppose you are aware the Odoo standard use case is:

  • The inventory users can count the stock levels.
  • Then, the manager confirm the counted quantity.

Hello @rousseldenis ,

Indeed. However here we need to grant non-manager users the ability to apply inventories

@ivantodorovich ivantodorovich force-pushed the 16.0-add-stock-inventory-security branch from 5383c1b to 093072f Compare November 12, 2024 11:57
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants