diff --git a/mrp_multi_level/models/product_mrp_area.py b/mrp_multi_level/models/product_mrp_area.py index 5dec8455b..e1d845434 100644 --- a/mrp_multi_level/models/product_mrp_area.py +++ b/mrp_multi_level/models/product_mrp_area.py @@ -224,3 +224,38 @@ class ProductMRPArea(models.Model): lambda r: r.main_supplierinfo_id and r.supply_method == "buy" ): rec.mrp_minimum_order_qty = rec.main_supplierinfo_id.min_qty + + def _in_stock_moves_domain(self): + self.ensure_one() + locations = self.mrp_area_id._get_locations() + return [ + ("product_id", "=", self.product_id.id), + ("state", "not in", ["done", "cancel"]), + ("product_qty", ">", 0.00), + ("location_id", "not in", locations.ids), + ("location_dest_id", "in", locations.ids), + ] + + def _out_stock_moves_domain(self): + self.ensure_one() + locations = self.mrp_area_id._get_locations() + return [ + ("product_id", "=", self.product_id.id), + ("state", "not in", ["done", "cancel"]), + ("product_qty", ">", 0.00), + ("location_id", "in", locations.ids), + ("location_dest_id", "not in", locations.ids), + ] + + def action_view_stock_moves(self, domain): + self.ensure_one() + action = self.env.ref("stock.stock_move_action").read()[0] + action["domain"] = domain + action["context"] = {} + return action + + def action_view_incoming_stock_moves(self): + return self.action_view_stock_moves(self._in_stock_moves_domain()) + + def action_view_outgoing_stock_moves(self): + return self.action_view_stock_moves(self._out_stock_moves_domain()) diff --git a/mrp_multi_level/views/product_mrp_area_views.xml b/mrp_multi_level/views/product_mrp_area_views.xml index 1c4237ed0..e320d0cd4 100644 --- a/mrp_multi_level/views/product_mrp_area_views.xml +++ b/mrp_multi_level/views/product_mrp_area_views.xml @@ -31,7 +31,22 @@
-
+
+
", 0.00), - ("location_id", "not in", locations.ids), - ("location_dest_id", "in", locations.ids), - ] - - @api.model - def _out_stock_moves_domain(self, product_mrp_area): - locations = product_mrp_area.mrp_area_id._get_locations() - return [ - ("product_id", "=", product_mrp_area.product_id.id), - ("state", "not in", ["done", "cancel"]), - ("product_qty", ">", 0.00), - ("location_id", "in", locations.ids), - ("location_dest_id", "not in", locations.ids), - ] - @api.model def _init_mrp_move_from_stock_move(self, product_mrp_area): move_obj = self.env["stock.move"] mrp_move_obj = self.env["mrp.move"] - in_domain = self._in_stock_moves_domain(product_mrp_area) + in_domain = product_mrp_area._in_stock_moves_domain() in_moves = move_obj.search(in_domain) - out_domain = self._out_stock_moves_domain(product_mrp_area) + out_domain = product_mrp_area._out_stock_moves_domain() out_moves = move_obj.search(out_domain) if in_moves: for move in in_moves: