mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] remove is_child recursive function (use children_ids)
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"author": "Akretion, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"category": "Warehouse",
|
||||
"depends": ["stock"],
|
||||
"depends": ["stock", "stock_location_children"],
|
||||
"license": "AGPL-3",
|
||||
"data": ["views/stock_inventory.xml"],
|
||||
"installable": True,
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
from . import stock_inventory
|
||||
from . import stock_location
|
||||
|
||||
@@ -20,19 +20,20 @@ class StockInventory(models.Model):
|
||||
"the putaway strategy."
|
||||
)
|
||||
)
|
||||
for location in record.location_ids:
|
||||
record.line_ids._generate_putaway_rules(location)
|
||||
record.line_ids._generate_putaway_rules(record.location_ids)
|
||||
|
||||
|
||||
class StockInventoryLine(models.Model):
|
||||
_inherit = "stock.inventory.line"
|
||||
|
||||
def _generate_putaway_rules(self, inventory_location):
|
||||
def _generate_putaway_rules(self, inventory_locations):
|
||||
# Eliminate lines for other IN locations
|
||||
# and eliminate lines where quantity is null
|
||||
self.filtered(
|
||||
lambda x: x.location_id._is_child(inventory_location) and x.product_qty > 0
|
||||
)._update_product_putaway_rule(inventory_location)
|
||||
for location_in in inventory_locations:
|
||||
self.filtered(
|
||||
lambda x: x.product_qty > 0
|
||||
and x.location_id.id in location_in.children_ids.ids
|
||||
)._update_product_putaway_rule(location_in)
|
||||
|
||||
def _update_product_putaway_rule(self, location_in):
|
||||
putaway_rule_obj = self.env["stock.putaway.rule"]
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Copyright 2021 Akretion (https://www.akretion.com).
|
||||
# @author Pierrick Brun <pierrick.brun@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class StockLocation(models.Model):
|
||||
_inherit = "stock.location"
|
||||
|
||||
def _is_child(self, location):
|
||||
self.ensure_one()
|
||||
if self == location:
|
||||
return True
|
||||
elif self.location_id:
|
||||
return self.location_id._is_child(location)
|
||||
else:
|
||||
return False
|
||||
@@ -11,6 +11,7 @@ class TestGeneratePutaway(TransactionCase):
|
||||
ref = self.env.ref
|
||||
# demo data
|
||||
self.inventory_location = ref("stock.stock_location_stock")
|
||||
self.inventory_location._compute_children_ids()
|
||||
self.inventory = self.env["stock.inventory"].create(
|
||||
{
|
||||
"name": "example inventory",
|
||||
|
||||
Reference in New Issue
Block a user