Skip to content

Commit

Permalink
Merge pull request #337 from Vauxoo/17.0
Browse files Browse the repository at this point in the history
Syncing from upstream Vauxoo/addons-vauxoo (17.0)
  • Loading branch information
bt-admin authored Jul 27, 2024
2 parents df6ae5d + dc8e7b5 commit 8dc59aa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions default_warehouse_from_sale_team/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import fields, models
from odoo import api, fields, models


class StockWarehouse(models.Model):
Expand All @@ -16,11 +16,17 @@ def _access_unallowed_current_user_salesteams(self):
In some cases, it's required to grant access to warehouses not allowed for the current user, e.g.
when an inventory rule is triggered that involves other warehouses.
"""
rule_warehouse = self.env.ref("default_warehouse_from_sale_team.rule_default_warehouse_wh")
warehouses = self.exists()
allowed_rules = self._get_salesteam_record_rules()
failed_rules = self.env["ir.rule"]._get_failing(warehouses, mode="read")
return (
warehouses
and not self.env.su
and warehouses.check_access_rights("read", raise_exception=False)
and self.env["ir.rule"]._get_failing(warehouses, mode="read") == rule_warehouse
and failed_rules
and not failed_rules - allowed_rules
)

@api.model
def _get_salesteam_record_rules(self):
return self.env.ref("default_warehouse_from_sale_team.rule_default_warehouse_wh")

0 comments on commit 8dc59aa

Please sign in to comment.