Skip to content

Commit

Permalink
[FIX] rma: bad field reference in rma line
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed May 8, 2024
1 parent cfdba45 commit 305bb6f
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 42 deletions.
1 change: 0 additions & 1 deletion rma/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ def _prepare_rma_line_from_stock_move(self, sm, lot=False):
operation.location_id.id
or operation.in_warehouse_id.lot_rma_id.id
or operation.out_warehouse_id.lot_rma_id.id
or warehouse.lot_rma_id.id
),
}
return data
Expand Down
14 changes: 7 additions & 7 deletions rma/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class StockWarehouse(models.Model):
"for this warehouse.",
)
rma_customer_pull_id = fields.Many2one(
comodel_name="stock.location.route",
comodel_name="stock.route",
string="RMA Customer Route",
)
rma_supplier_pull_id = fields.Many2one(
comodel_name="stock.location.route",
comodel_name="stock.route",
string="RMA Supplier Route",
)

Expand Down Expand Up @@ -196,7 +196,7 @@ def get_rma_route_customer(self):
"warehouse_id": self.id,
"company_id": self.company_id.id,
"location_src_id": customer_loc.id,
"location_id": self.lot_rma_id.id,
"location_dest_id": self.lot_rma_id.id,
"procure_method": "make_to_stock",
"picking_type_id": self.rma_cust_in_type_id.id,
"active": True,
Expand All @@ -213,7 +213,7 @@ def get_rma_route_customer(self):
"warehouse_id": self.id,
"company_id": self.company_id.id,
"location_src_id": self.lot_rma_id.id,
"location_id": customer_loc.id,
"location_dest_id": customer_loc.id,
"procure_method": "make_to_stock",
"picking_type_id": self.rma_cust_out_type_id.id,
"active": True,
Expand Down Expand Up @@ -243,7 +243,7 @@ def get_rma_route_supplier(self):
"warehouse_id": self.id,
"company_id": self.company_id.id,
"location_src_id": supplier_loc.id,
"location_id": self.lot_rma_id.id,
"location_dest_id": self.lot_rma_id.id,
"procure_method": "make_to_stock",
"picking_type_id": self.rma_sup_in_type_id.id,
"active": True,
Expand All @@ -260,7 +260,7 @@ def get_rma_route_supplier(self):
"warehouse_id": self.id,
"company_id": self.company_id.id,
"location_src_id": self.lot_rma_id.id,
"location_id": supplier_loc.id,
"location_dest_id": supplier_loc.id,
"procure_method": "make_to_stock",
"picking_type_id": self.rma_sup_out_type_id.id,
"active": True,
Expand All @@ -272,7 +272,7 @@ def get_rma_route_supplier(self):
return rma_route

def _create_rma_pull(self):
route_obj = self.env["stock.location.route"]
route_obj = self.env["stock.route"]
for wh in self:
if not wh.rma_customer_pull_id:
wh.rma_customer_pull_id = (
Expand Down
12 changes: 6 additions & 6 deletions rma/tests/test_rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,9 +1083,9 @@ def test_08_customer_rma_multi_step(self):
self.wh.reception_steps = "two_steps"
self.wh.delivery_steps = "pick_ship"
cust_in_pull_rule = self.customer_route.rule_ids.filtered(
lambda r: r.location_id == self.stock_rma_location
lambda r: r.location_dest_id == self.stock_rma_location
)
cust_in_pull_rule.location_id = self.input_location
cust_in_pull_rule.location_dest_id = self.input_location
cust_out_pull_rule = self.customer_route.rule_ids.filtered(
lambda r: r.location_src_id == self.env.ref("rma.location_rma")
)
Expand All @@ -1097,7 +1097,7 @@ def test_08_customer_rma_multi_step(self):
"action": "pull",
"warehouse_id": self.wh.id,
"location_src_id": self.wh.lot_rma_id.id,
"location_id": self.output_location.id,
"location_dest_id": self.output_location.id,
"procure_method": "make_to_stock",
"route_id": self.customer_route.id,
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
Expand All @@ -1109,7 +1109,7 @@ def test_08_customer_rma_multi_step(self):
"action": "pull",
"warehouse_id": self.wh.id,
"location_src_id": self.output_location.id,
"location_id": self.customer_location.id,
"location_dest_id": self.customer_location.id,
"procure_method": "make_to_order",
"route_id": self.customer_route.id,
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
Expand All @@ -1121,7 +1121,7 @@ def test_08_customer_rma_multi_step(self):
"action": "pull",
"warehouse_id": self.wh.id,
"location_src_id": self.customer_location.id,
"location_id": self.input_location.id,
"location_dest_id": self.input_location.id,
"procure_method": "make_to_stock",
"route_id": self.customer_route.id,
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
Expand All @@ -1133,7 +1133,7 @@ def test_08_customer_rma_multi_step(self):
"action": "pull",
"warehouse_id": self.wh.id,
"location_src_id": self.input_location.id,
"location_id": self.wh.lot_rma_id.id,
"location_dest_id": self.wh.lot_rma_id.id,
"procure_method": "make_to_order",
"route_id": self.customer_route.id,
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
Expand Down
7 changes: 2 additions & 5 deletions rma/views/stock_warehouse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='wh_output_stock_loc_id']" position="after">
<field name="lot_rma_id" />
</xpath>
<field name="resupply_wh_ids" position="after">
<field name="rma_in_this_wh" />
</xpath>
<xpath expr="//field[@name='out_type_id']" position="after">
<field name="rma_customer_pull_id" />
<field name="rma_supplier_pull_id" />

</field>
<xpath expr="//field[@name='out_type_id']" position="after">
<field name="rma_cust_in_type_id" />
<field name="rma_cust_out_type_id" />
<field name="rma_sup_in_type_id" />
Expand Down
6 changes: 2 additions & 4 deletions rma_account/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _prepare_rma_line_from_inv_line(self, line):
raise ValidationError(_("Please define an operation first"))

if not operation.in_route_id or not operation.out_route_id:
route = self.env["stock.location.route"].search(
route = self.env["stock.route"].search(
[("rma_selectable", "=", True)], limit=1
)
if not route:
Expand Down Expand Up @@ -222,9 +222,7 @@ def _prepare_rma_line_from_inv_line(self, line):
"in_route_id": operation.in_route_id.id or route.id,
"out_route_id": operation.out_route_id.id or route.id,
"location_id": (
operation.location_id.id
or operation.in_warehouse_id.lot_rma_id.id
or warehouse.lot_rma_id.id
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
),
}
return data
Expand Down
4 changes: 2 additions & 2 deletions rma_account/tests/test_rma_stock_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def test_08_cost_from_move_multi_step(self):
"action": "pull",
"warehouse_id": self.wh.id,
"location_src_id": self.output_location.id,
"location_id": self.customer_location.id,
"location_dest_id": self.customer_location.id,
"procure_method": "make_to_order",
"route_id": self.customer_route.id,
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
Expand All @@ -295,7 +295,7 @@ def test_08_cost_from_move_multi_step(self):
"action": "pull",
"warehouse_id": self.wh.id,
"location_src_id": self.customer_location.id,
"location_id": self.input_location.id,
"location_dest_id": self.input_location.id,
"procure_method": "make_to_stock",
"route_id": self.customer_route.id,
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
Expand Down
6 changes: 2 additions & 4 deletions rma_account/wizards/rma_add_account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _prepare_rma_line_from_inv_line(self, line):
if not operation:
raise ValidationError(_("Please define an operation first"))
if not operation.in_route_id or not operation.out_route_id:
route = self.env["stock.location.route"].search(
route = self.env["stock.route"].search(
[("rma_selectable", "=", True)], limit=1
)
if not route:
Expand Down Expand Up @@ -100,9 +100,7 @@ def _prepare_rma_line_from_inv_line(self, line):
"in_route_id": operation.in_route_id.id or route.id,
"out_route_id": operation.out_route_id.id or route.id,
"location_id": (
operation.location_id.id
or operation.in_warehouse_id.lot_rma_id.id
or warehouse.lot_rma_id.id
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
),
}
return data
Expand Down
6 changes: 2 additions & 4 deletions rma_purchase/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _prepare_rma_line_from_po_line(self, line):
raise ValidationError(_("Please define an operation first"))

if not operation.in_route_id or not operation.out_route_id:
route = self.env["stock.location.route"].search(
route = self.env["stock.route"].search(
[("rma_selectable", "=", True)], limit=1
)
if not route:
Expand Down Expand Up @@ -168,9 +168,7 @@ def _prepare_rma_line_from_po_line(self, line):
"receipt_policy": operation.receipt_policy,
"currency_id": line.currency_id.id,
"location_id": (
operation.location_id.id
or operation.in_warehouse_id.lot_rma_id.id
or warehouse.lot_rma_id.id
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
),
"refund_policy": operation.refund_policy,
"delivery_policy": operation.delivery_policy,
Expand Down
6 changes: 2 additions & 4 deletions rma_purchase/wizards/rma_add_purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _prepare_rma_line_from_po_line(self, line):
if not operation:
raise ValidationError(_("Please define an operation first"))
if not operation.in_route_id or not operation.out_route_id:
route = self.env["stock.location.route"].search(
route = self.env["stock.route"].search(
[("rma_selectable", "=", True)], limit=1
)
if not route:
Expand Down Expand Up @@ -97,9 +97,7 @@ def _prepare_rma_line_from_po_line(self, line):
"out_route_id": operation.out_route_id.id or route,
"receipt_policy": operation.receipt_policy,
"location_id": (
operation.location_id.id
or operation.in_warehouse_id.lot_rma_id.id
or warehouse.lot_rma_id.id
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
),
"refund_policy": operation.refund_policy,
"delivery_policy": operation.delivery_policy,
Expand Down
6 changes: 2 additions & 4 deletions rma_sale/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _prepare_rma_line_from_sale_order_line(self, line):
if not operation:
raise ValidationError(_("Please define an operation first"))
if not operation.in_route_id or not operation.out_route_id:
route = self.env["stock.location.route"].search(
route = self.env["stock.route"].search(
[("rma_selectable", "=", True)], limit=1
)
if not route:
Expand Down Expand Up @@ -153,9 +153,7 @@ def _prepare_rma_line_from_sale_order_line(self, line):
"receipt_policy": operation.receipt_policy,
"currency_id": line.currency_id.id,
"location_id": (
operation.location_id.id
or operation.in_warehouse_id.lot_rma_id.id
or warehouse.lot_rma_id.id
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
),
"refund_policy": operation.refund_policy,
"delivery_policy": operation.delivery_policy,
Expand Down
2 changes: 1 addition & 1 deletion rma_sale/wizards/rma_add_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _prepare_rma_line_from_sale_order_line(self, line, lot=None):
if not operation:
raise ValidationError(_("Please define an operation first"))
if not operation.in_route_id or not operation.out_route_id:
route = self.env["stock.location.route"].search(
route = self.env["stock.route"].search(
[("rma_selectable", "=", True)], limit=1
)
if not route:
Expand Down

0 comments on commit 305bb6f

Please sign in to comment.