-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OCA#18 from guewen/13.0-shopfloor-test-as-user
backend: run tests as a stock user
- Loading branch information
Showing
32 changed files
with
411 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from . import shopfloor_menu | ||
from . import stock_picking_type | ||
from . import shopfloor_profile | ||
from . import stock_inventory | ||
from . import stock_location | ||
from . import stock_move_line | ||
from . import stock_package_level | ||
from . import stock_picking | ||
from . import stock_picking_batch | ||
from . import stock_quant | ||
from . import stock_quant_package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from odoo import models | ||
|
||
|
||
class StockInventory(models.Model): | ||
_inherit = "stock.inventory" | ||
|
||
def user_has_groups(self, groups): | ||
if self.env.context.get("_sf_inventory"): | ||
allow_groups = groups.split(",") | ||
# action_validate checks if the user is a manager, but | ||
# in shopfloor, we want to programmatically create and | ||
# validate inventories under the hood. sudo sets the su | ||
# flag but not the group: allow to bypass the check when | ||
# sudo is used. | ||
if "stock.group_stock_manager" in allow_groups and self.env.su: | ||
return True | ||
return super().user_has_groups(groups) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from odoo import models | ||
|
||
|
||
class StockQuant(models.Model): | ||
_inherit = "stock.quant" | ||
|
||
def _is_inventory_mode(self): | ||
""" Used to control whether a quant was written on or created during an | ||
"inventory session", meaning a mode where we need to create the stock.move | ||
record necessary to be consistent with the `inventory_quantity` field. | ||
""" | ||
# The default method check if we have the stock.group_stock_manager | ||
# group, however, we want to force using this mode from shopfloor | ||
# (cluster picking) when sudo is used and the user is a stock user. | ||
if self.env.context.get("inventory_mode") is True and self.env.su: | ||
return True | ||
return super()._is_inventory_mode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.