Skip to content

Commit cbebf69

Browse files
[FIX] rma: bad field reference in rma line
1 parent 8ec430a commit cbebf69

File tree

12 files changed

+38
-42
lines changed

12 files changed

+38
-42
lines changed

rma/models/rma_order.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ def _default_warehouse_id(self):
120120
tracking=True,
121121
default=lambda self: self.env.uid,
122122
)
123+
in_route_id = fields.Many2one(
124+
"stock.route",
125+
string="Inbound Route",
126+
domain=[("rma_selectable", "=", True)],
127+
)
128+
out_route_id = fields.Many2one(
129+
"stock.route",
130+
string="Outbound Route",
131+
domain=[("rma_selectable", "=", True)],
132+
)
123133
in_warehouse_id = fields.Many2one(
124134
comodel_name="stock.warehouse",
125135
string="Inbound Warehouse",

rma/models/rma_order_line.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ def _prepare_rma_line_from_stock_move(self, sm, lot=False):
589589
operation.location_id.id
590590
or operation.in_warehouse_id.lot_rma_id.id
591591
or operation.out_warehouse_id.lot_rma_id.id
592-
or warehouse.lot_rma_id.id
593592
),
594593
}
595594
return data

rma/models/stock_warehouse.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class StockWarehouse(models.Model):
2929
"for this warehouse.",
3030
)
3131
rma_customer_pull_id = fields.Many2one(
32-
comodel_name="stock.location.route",
32+
comodel_name="stock.route",
3333
string="RMA Customer Route",
3434
)
3535
rma_supplier_pull_id = fields.Many2one(
36-
comodel_name="stock.location.route",
36+
comodel_name="stock.route",
3737
string="RMA Supplier Route",
3838
)
3939

@@ -195,7 +195,7 @@ def get_rma_route_customer(self):
195195
"warehouse_id": self.id,
196196
"company_id": self.company_id.id,
197197
"location_src_id": customer_loc.id,
198-
"location_id": self.lot_rma_id.id,
198+
"location_dest_id": self.lot_rma_id.id,
199199
"procure_method": "make_to_stock",
200200
"picking_type_id": self.rma_cust_in_type_id.id,
201201
"active": True,
@@ -212,7 +212,7 @@ def get_rma_route_customer(self):
212212
"warehouse_id": self.id,
213213
"company_id": self.company_id.id,
214214
"location_src_id": self.lot_rma_id.id,
215-
"location_id": customer_loc.id,
215+
"location_dest_id": customer_loc.id,
216216
"procure_method": "make_to_stock",
217217
"picking_type_id": self.rma_cust_out_type_id.id,
218218
"active": True,
@@ -242,7 +242,7 @@ def get_rma_route_supplier(self):
242242
"warehouse_id": self.id,
243243
"company_id": self.company_id.id,
244244
"location_src_id": supplier_loc.id,
245-
"location_id": self.lot_rma_id.id,
245+
"location_dest_id": self.lot_rma_id.id,
246246
"procure_method": "make_to_stock",
247247
"picking_type_id": self.rma_sup_in_type_id.id,
248248
"active": True,
@@ -259,7 +259,7 @@ def get_rma_route_supplier(self):
259259
"warehouse_id": self.id,
260260
"company_id": self.company_id.id,
261261
"location_src_id": self.lot_rma_id.id,
262-
"location_id": supplier_loc.id,
262+
"location_dest_id": supplier_loc.id,
263263
"procure_method": "make_to_stock",
264264
"picking_type_id": self.rma_sup_out_type_id.id,
265265
"active": True,
@@ -271,7 +271,7 @@ def get_rma_route_supplier(self):
271271
return rma_route
272272

273273
def _create_rma_pull(self):
274-
route_obj = self.env["stock.location.route"]
274+
route_obj = self.env["stock.route"]
275275
for wh in self:
276276
if not wh.rma_customer_pull_id:
277277
wh.rma_customer_pull_id = (

rma/tests/test_rma.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,9 @@ def test_08_customer_rma_multi_step(self):
10831083
self.wh.reception_steps = "two_steps"
10841084
self.wh.delivery_steps = "pick_ship"
10851085
cust_in_pull_rule = self.customer_route.rule_ids.filtered(
1086-
lambda r: r.location_id == self.stock_rma_location
1086+
lambda r: r.location_dest_id == self.stock_rma_location
10871087
)
1088-
cust_in_pull_rule.location_id = self.input_location
1088+
cust_in_pull_rule.location_dest_id = self.input_location
10891089
cust_out_pull_rule = self.customer_route.rule_ids.filtered(
10901090
lambda r: r.location_src_id == self.env.ref("rma.location_rma")
10911091
)
@@ -1097,7 +1097,7 @@ def test_08_customer_rma_multi_step(self):
10971097
"action": "pull",
10981098
"warehouse_id": self.wh.id,
10991099
"location_src_id": self.wh.lot_rma_id.id,
1100-
"location_id": self.output_location.id,
1100+
"location_dest_id": self.output_location.id,
11011101
"procure_method": "make_to_stock",
11021102
"route_id": self.customer_route.id,
11031103
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
@@ -1109,7 +1109,7 @@ def test_08_customer_rma_multi_step(self):
11091109
"action": "pull",
11101110
"warehouse_id": self.wh.id,
11111111
"location_src_id": self.output_location.id,
1112-
"location_id": self.customer_location.id,
1112+
"location_dest_id": self.customer_location.id,
11131113
"procure_method": "make_to_order",
11141114
"route_id": self.customer_route.id,
11151115
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
@@ -1121,7 +1121,7 @@ def test_08_customer_rma_multi_step(self):
11211121
"action": "pull",
11221122
"warehouse_id": self.wh.id,
11231123
"location_src_id": self.customer_location.id,
1124-
"location_id": self.input_location.id,
1124+
"location_dest_id": self.input_location.id,
11251125
"procure_method": "make_to_stock",
11261126
"route_id": self.customer_route.id,
11271127
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
@@ -1133,7 +1133,7 @@ def test_08_customer_rma_multi_step(self):
11331133
"action": "pull",
11341134
"warehouse_id": self.wh.id,
11351135
"location_src_id": self.input_location.id,
1136-
"location_id": self.wh.lot_rma_id.id,
1136+
"location_dest_id": self.wh.lot_rma_id.id,
11371137
"procure_method": "make_to_order",
11381138
"route_id": self.customer_route.id,
11391139
"picking_type_id": self.env.ref("stock.picking_type_internal").id,

rma/views/stock_warehouse.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
<field name="arch" type="xml">
88
<xpath expr="//field[@name='wh_output_stock_loc_id']" position="after">
99
<field name="lot_rma_id" />
10-
</xpath>
11-
<field name="resupply_wh_ids" position="after">
1210
<field name="rma_in_this_wh" />
11+
</xpath>
12+
<xpath expr="//field[@name='out_type_id']" position="after">
1313
<field name="rma_customer_pull_id" />
1414
<field name="rma_supplier_pull_id" />
15-
16-
</field>
17-
<xpath expr="//field[@name='out_type_id']" position="after">
1815
<field name="rma_cust_in_type_id" />
1916
<field name="rma_cust_out_type_id" />
2017
<field name="rma_sup_in_type_id" />

rma_account/models/rma_order_line.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def _prepare_rma_line_from_inv_line(self, line):
183183
raise ValidationError(_("Please define an operation first"))
184184

185185
if not operation.in_route_id or not operation.out_route_id:
186-
route = self.env["stock.location.route"].search(
186+
route = self.env["stock.route"].search(
187187
[("rma_selectable", "=", True)], limit=1
188188
)
189189
if not route:
@@ -222,9 +222,7 @@ def _prepare_rma_line_from_inv_line(self, line):
222222
"in_route_id": operation.in_route_id.id or route.id,
223223
"out_route_id": operation.out_route_id.id or route.id,
224224
"location_id": (
225-
operation.location_id.id
226-
or operation.in_warehouse_id.lot_rma_id.id
227-
or warehouse.lot_rma_id.id
225+
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
228226
),
229227
}
230228
return data

rma_account/tests/test_rma_stock_account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def test_08_cost_from_move_multi_step(self):
283283
"action": "pull",
284284
"warehouse_id": self.wh.id,
285285
"location_src_id": self.output_location.id,
286-
"location_id": self.customer_location.id,
286+
"location_dest_id": self.customer_location.id,
287287
"procure_method": "make_to_order",
288288
"route_id": self.customer_route.id,
289289
"picking_type_id": self.env.ref("stock.picking_type_internal").id,
@@ -295,7 +295,7 @@ def test_08_cost_from_move_multi_step(self):
295295
"action": "pull",
296296
"warehouse_id": self.wh.id,
297297
"location_src_id": self.customer_location.id,
298-
"location_id": self.input_location.id,
298+
"location_dest_id": self.input_location.id,
299299
"procure_method": "make_to_stock",
300300
"route_id": self.customer_route.id,
301301
"picking_type_id": self.env.ref("stock.picking_type_internal").id,

rma_account/wizards/rma_add_account_move.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _prepare_rma_line_from_inv_line(self, line):
5656
if not operation:
5757
raise ValidationError(_("Please define an operation first"))
5858
if not operation.in_route_id or not operation.out_route_id:
59-
route = self.env["stock.location.route"].search(
59+
route = self.env["stock.route"].search(
6060
[("rma_selectable", "=", True)], limit=1
6161
)
6262
if not route:
@@ -100,9 +100,7 @@ def _prepare_rma_line_from_inv_line(self, line):
100100
"in_route_id": operation.in_route_id.id or route.id,
101101
"out_route_id": operation.out_route_id.id or route.id,
102102
"location_id": (
103-
operation.location_id.id
104-
or operation.in_warehouse_id.lot_rma_id.id
105-
or warehouse.lot_rma_id.id
103+
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
106104
),
107105
}
108106
return data

rma_purchase/models/rma_order_line.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _prepare_rma_line_from_po_line(self, line):
134134
raise ValidationError(_("Please define an operation first"))
135135

136136
if not operation.in_route_id or not operation.out_route_id:
137-
route = self.env["stock.location.route"].search(
137+
route = self.env["stock.route"].search(
138138
[("rma_selectable", "=", True)], limit=1
139139
)
140140
if not route:
@@ -168,9 +168,7 @@ def _prepare_rma_line_from_po_line(self, line):
168168
"receipt_policy": operation.receipt_policy,
169169
"currency_id": line.currency_id.id,
170170
"location_id": (
171-
operation.location_id.id
172-
or operation.in_warehouse_id.lot_rma_id.id
173-
or warehouse.lot_rma_id.id
171+
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
174172
),
175173
"refund_policy": operation.refund_policy,
176174
"delivery_policy": operation.delivery_policy,

rma_purchase/wizards/rma_add_purchase.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _prepare_rma_line_from_po_line(self, line):
5959
if not operation:
6060
raise ValidationError(_("Please define an operation first"))
6161
if not operation.in_route_id or not operation.out_route_id:
62-
route = self.env["stock.location.route"].search(
62+
route = self.env["stock.route"].search(
6363
[("rma_selectable", "=", True)], limit=1
6464
)
6565
if not route:
@@ -97,9 +97,7 @@ def _prepare_rma_line_from_po_line(self, line):
9797
"out_route_id": operation.out_route_id.id or route,
9898
"receipt_policy": operation.receipt_policy,
9999
"location_id": (
100-
operation.location_id.id
101-
or operation.in_warehouse_id.lot_rma_id.id
102-
or warehouse.lot_rma_id.id
100+
operation.location_id.id or operation.in_warehouse_id.lot_rma_id.id
103101
),
104102
"refund_policy": operation.refund_policy,
105103
"delivery_policy": operation.delivery_policy,

0 commit comments

Comments
 (0)