Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Inventory
Entity: stock.warehouse.orderpoint
Compute Method: _compute_rules
| Inputs | Method | Outputs |
|---|---|---|
|
orderpoints_to_compute = self.filtered(lambda orderpoint: orderpoint.product_id and orderpoint.location_id)
rules_cache = {}
+ routes_cache = {}
for orderpoint in orderpoints_to_compute:
- all_product_routes = orderpoint.product_id.route_ids | orderpoint.product_id.categ_id.total_route_ids | orderpoint.product_id.get_total_routes()
+ # Get routes from cache
+ actions = orderpoint.product_id.get_routes_actions()
+ total_routes = self.env['stock.route']
+ for action in actions:
+ if action not in routes_cache:
+ routes_cache[action] = self.env['stock.rule'].search([('action', '=', action)]).route_id
+ total_routes |= routes_cache[action]
+
+ all_product_routes = orderpoint.product_id.route_ids | orderpoint.product_id.categ_id.total_route_ids | total_routes
cache_key = (orderpoint.location_id, orderpoint.route_id, all_product_routes)
rule_ids = rules_cache.get(cache_key) or orderpoint.product_id._get_rules_from_location(
orderpoint.location_id, route_ids=orderpoint.route_id
)
orderpoint.rule_ids = rule_ids
rules_cache[cache_key] = rule_ids
(self - orderpoints_to_compute).rule_ids = False
|
|
