diff --git a/rma/models/res_partner.py b/rma/models/res_partner.py
index f2acd754..89c529ae 100644
--- a/rma/models/res_partner.py
+++ b/rma/models/res_partner.py
@@ -22,4 +22,6 @@ class ResPartner(models.Model):
action = self.env.ref("rma.action_rma_customer_lines")
result = action.sudo().read()[0]
result["context"] = {"search_default_partner_id": self.id}
+ result["domain"] = []
+ result["display_name"] = "Partner RMAs"
return result
diff --git a/rma/models/rma_order_line.py b/rma/models/rma_order_line.py
index f8b3ff6f..7b8b6c2a 100644
--- a/rma/models/rma_order_line.py
+++ b/rma/models/rma_order_line.py
@@ -68,7 +68,7 @@ class RmaOrderLine(models.Model):
if last_usage == "internal" and first_usage != "internal":
moves |= move
elif last_usage == "supplier" and first_usage == "customer":
- moves |= moves
+ moves |= move
return moves
@api.model
@@ -77,7 +77,10 @@ class RmaOrderLine(models.Model):
for move in self.move_ids:
first_usage = move._get_first_usage()
last_usage = move._get_last_usage()
- if first_usage in ("internal", "production") and last_usage != "internal":
+ if first_usage in ("internal", "production") and last_usage in (
+ "customer",
+ "supplier",
+ ):
pickings |= move.picking_id
elif last_usage == "customer" and first_usage == "supplier":
pickings |= move.picking_id
@@ -98,12 +101,30 @@ class RmaOrderLine(models.Model):
product_obj = self.env["uom.uom"]
qty = 0.0
if direction == "in":
- op = ops["="]
- else:
- op = ops["!="]
- for move in rec.move_ids.filtered(
- lambda m: m.state in states and op(m.location_id.usage, rec.type)
- ):
+ moves = rec.move_ids.filtered(
+ lambda m: m.state in states
+ and (
+ m.location_id.usage == "supplier"
+ or m.location_id.usage == "customer"
+ )
+ and (
+ m.location_dest_id.usage == "internal"
+ or m.location_dest_id.usage == "supplier"
+ )
+ )
+ elif direction == "out":
+ moves = rec.move_ids.filtered(
+ lambda m: m.state in states
+ and (
+ m.location_dest_id.usage == "supplier"
+ or m.location_dest_id.usage == "customer"
+ )
+ and (
+ m.location_id.usage == "internal"
+ or m.location_id.usage == "supplier"
+ )
+ )
+ for move in moves:
# If the move is part of a chain don't count it
if direction == "out" and move.move_orig_ids:
continue
diff --git a/rma/views/rma_order_line_view.xml b/rma/views/rma_order_line_view.xml
index eff50667..e37ad287 100644
--- a/rma/views/rma_order_line_view.xml
+++ b/rma/views/rma_order_line_view.xml
@@ -387,7 +387,7 @@
@@ -457,7 +457,7 @@
Customer RMA
rma.order.line
[('type','=', 'customer')]
- {"search_default_assigned_to":uid}
+ {"search_default_assigned_to_filter":1}
tree,form
@@ -468,7 +468,7 @@
[('type','=', 'supplier')]
{"search_default_assigned_to":uid, "supplier":1}
+ >{"search_default_assigned_to_filter":1, "supplier":1}
tree,form
diff --git a/rma/views/stock_view.xml b/rma/views/stock_view.xml
index e2e80e67..cf7b0a4b 100644
--- a/rma/views/stock_view.xml
+++ b/rma/views/stock_view.xml
@@ -18,9 +18,9 @@
stock.route
-
+
+
diff --git a/rma/wizards/rma_make_picking.py b/rma/wizards/rma_make_picking.py
index b962e21a..e066d07f 100644
--- a/rma/wizards/rma_make_picking.py
+++ b/rma/wizards/rma_make_picking.py
@@ -102,17 +102,19 @@ class RmaMakePicking(models.TransientModel):
def _get_procurement_data(self, item, group, qty, picking_type):
line = item.line_id
delivery_address_id = self._get_address(item)
+ location, warehouse, route = False, False, False
if picking_type == "incoming":
if line.customer_to_supplier:
location = self._get_address_location(delivery_address_id, "supplier")
- elif line.supplier_to_customer:
- location = self._get_address_location(delivery_address_id, "customer")
else:
location = line.location_id
warehouse = line.in_warehouse_id
route = line.in_route_id
- else:
- location = self._get_address_location(delivery_address_id, line.type)
+ elif picking_type == "outgoing":
+ if line.supplier_to_customer:
+ location = self._get_address_location(delivery_address_id, "customer")
+ else:
+ location = self._get_address_location(delivery_address_id, line.type)
warehouse = line.out_warehouse_id
route = line.out_route_id
if not route:
@@ -227,7 +229,7 @@ class RmaMakePicking(models.TransientModel):
)
move.move_line_ids.write(
{
- "product_uom_qty": 1,
+ "reserved_uom_qty": 1,
"qty_done": 0,
}
)
diff --git a/rma/wizards/rma_make_picking_view.xml b/rma/wizards/rma_make_picking_view.xml
index d1902fdb..380be500 100644
--- a/rma/wizards/rma_make_picking_view.xml
+++ b/rma/wizards/rma_make_picking_view.xml
@@ -108,26 +108,26 @@
name="%(action_rma_picking_in)d"
string="Create Incoming Shipment"
class="oe_highlight"
- attrs="{'invisible':['|', '|', ('qty_to_receive', '=', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}"
+ attrs="{'invisible':['|', '|', '|', ('qty_to_receive', '=', 0), ('qty_to_receive', '<', 0), ('state', '!=', 'approved'), ('receipt_policy', '=', 'no')]}"
type="action"
/>