diff --git a/rma/__manifest__.py b/rma/__manifest__.py
index 2cb7bc58..015ed11d 100644
--- a/rma/__manifest__.py
+++ b/rma/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "RMA (Return Merchandise Authorization)",
- "version": "15.0.1.1.1",
+ "version": "16.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Introduces the return merchandise authorization (RMA) process in odoo",
diff --git a/rma/data/stock_data.xml b/rma/data/stock_data.xml
index f78880a3..d8dfe694 100644
--- a/rma/data/stock_data.xml
+++ b/rma/data/stock_data.xml
@@ -109,7 +109,7 @@
-
+
RMA Customer
10
@@ -119,7 +119,7 @@
-
+
RMA Supplier
10
@@ -129,7 +129,7 @@
-
+
RMA Dropship
10
@@ -144,7 +144,7 @@
pull
-
+
make_to_stock
@@ -155,7 +155,7 @@
pull
-
+
make_to_stock
@@ -165,7 +165,7 @@
RMA → Supplier
pull
-
+
make_to_stock
@@ -176,7 +176,7 @@
Supplier → RMA
pull
-
+
make_to_stock
@@ -186,7 +186,7 @@
Customer → Supplier
pull
-
+
make_to_stock
@@ -196,7 +196,7 @@
Supplier → Customer
pull
-
+
make_to_stock
diff --git a/rma/demo/stock_demo.xml b/rma/demo/stock_demo.xml
index 087e143f..a7554c01 100644
--- a/rma/demo/stock_demo.xml
+++ b/rma/demo/stock_demo.xml
@@ -57,7 +57,7 @@
-
+
RMA Customer
10
@@ -66,7 +66,7 @@
-
+
RMA Supplier
10
@@ -75,7 +75,7 @@
-
+
RMA Dropship
10
@@ -89,7 +89,7 @@
Customer → Supplier
pull
-
+
make_to_stock
@@ -100,7 +100,7 @@
Supplier → Customer
pull
-
+
make_to_stock
diff --git a/rma/migrations/15.0.1.1.0/post-migration.py b/rma/migrations/15.0.1.1.0/post-migration.py
deleted file mode 100644
index ae792b79..00000000
--- a/rma/migrations/15.0.1.1.0/post-migration.py
+++ /dev/null
@@ -1,126 +0,0 @@
-import logging
-
-_logger = logging.getLogger(__name__)
-
-
-def set_rma_customer_operation_property(cr):
- """ """
- cr.execute(
- """
- WITH rma_customer_operation_id_field AS (
- SELECT id FROM ir_model_fields WHERE model='product.template'
- AND name='rma_customer_operation_id'
- )
- INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
- value_reference)
- SELECT 'rma_customer_operation_id', 'many2one', rco.id, ro.company_id,
- CONCAT('product.template,', t.id), CONCAT('rma.operation,', ro.id)
- FROM product_template t JOIN rma_operation ro
- ON t.rma_customer_operation_id = ro.id
- , rma_customer_operation_id_field rco
- WHERE ro.company_id IS NOT NULL
- AND NOT EXISTS(SELECT 1
- FROM ir_property
- WHERE fields_id=rco.id
- AND company_id=ro.company_id
- AND res_id=CONCAT('product.template,', t.id))
- """
- )
- _logger.info(
- "Added %s rma_customer_operation_id_field product properties", cr.rowcount
- )
-
-
-def set_rma_supplier_operation_property(cr):
- """ """
- cr.execute(
- """
- WITH rma_supplier_operation_id_field AS (
- SELECT id FROM ir_model_fields WHERE model='product.template'
- AND name='rma_supplier_operation_id'
- )
- INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
- value_reference)
- SELECT 'rma_supplier_operation_id', 'many2one', rco.id, ro.company_id,
- CONCAT('product.template,', t.id), CONCAT('rma.operation,', ro.id)
- FROM product_template t JOIN rma_operation ro
- ON t.rma_supplier_operation_id = ro.id
- , rma_supplier_operation_id_field rco
- WHERE ro.company_id IS NOT NULL
- AND NOT EXISTS(SELECT 1
- FROM ir_property
- WHERE fields_id=rco.id
- AND company_id=ro.company_id
- AND res_id=CONCAT('product.template,', t.id))
- """
- )
- _logger.info(
- "Added %s rma_supplier_operation_id_field product properties", cr.rowcount
- )
-
-
-def set_rma_customer_operation_category_property(cr):
- """ """
- cr.execute(
- """
- WITH rma_customer_operation_id_field AS (
- SELECT id FROM ir_model_fields WHERE model='product.category'
- AND name='rma_customer_operation_id'
- )
- INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
- value_reference)
- SELECT 'rma_customer_operation_id', 'many2one', rco.id, ro.company_id,
- CONCAT('product.category,', pc.id), CONCAT('rma.operation,', ro.id)
- FROM product_category pc JOIN rma_operation ro
- ON pc.rma_customer_operation_id = ro.id
- , rma_customer_operation_id_field rco
- WHERE ro.company_id IS NOT NULL
- AND NOT EXISTS(SELECT 1
- FROM ir_property
- WHERE fields_id=rco.id
- AND company_id=ro.company_id
- AND res_id=CONCAT('product.category,', pc.id))
- """
- )
- _logger.info(
- "Added %s rma_customer_operation_id_field product category properties",
- cr.rowcount,
- )
-
-
-def set_rma_supplier_operation_category_property(cr):
- """ """
- cr.execute(
- """
- WITH rma_supplier_operation_id_field AS (
- SELECT id FROM ir_model_fields WHERE model='product.category'
- AND name='rma_supplier_operation_id'
- )
- INSERT INTO ir_property(name, type, fields_id, company_id, res_id,
- value_reference)
- SELECT 'rma_supplier_operation_id', 'many2one', rco.id, ro.company_id,
- CONCAT('product.category,', pc.id), CONCAT('rma.operation,', ro.id)
- FROM product_category pc JOIN rma_operation ro
- ON pc.rma_supplier_operation_id = ro.id
- , rma_supplier_operation_id_field rco
- WHERE ro.company_id IS NOT NULL
- AND NOT EXISTS(SELECT 1
- FROM ir_property
- WHERE fields_id=rco.id
- AND company_id=ro.company_id
- AND res_id=CONCAT('product.category,', pc.id))
- """
- )
- _logger.info(
- "Added %s rma_supplier_operation_id_field product category properties",
- cr.rowcount,
- )
-
-
-def migrate(cr, version=None):
- if not version:
- return
- set_rma_customer_operation_property(cr)
- set_rma_supplier_operation_property(cr)
- set_rma_customer_operation_category_property(cr)
- set_rma_supplier_operation_category_property(cr)
diff --git a/rma/models/rma_operation.py b/rma/models/rma_operation.py
index a4a55a24..bd3d0f16 100644
--- a/rma/models/rma_operation.py
+++ b/rma/models/rma_operation.py
@@ -52,13 +52,13 @@ class RmaOperation(models.Model):
default="no",
)
in_route_id = fields.Many2one(
- comodel_name="stock.location.route",
+ comodel_name="stock.route",
string="Inbound Route",
domain=[("rma_selectable", "=", True)],
default=lambda self: self._default_routes(),
)
out_route_id = fields.Many2one(
- comodel_name="stock.location.route",
+ comodel_name="stock.route",
string="Outbound Route",
domain=[("rma_selectable", "=", True)],
default=lambda self: self._default_routes(),
diff --git a/rma/models/rma_order.py b/rma/models/rma_order.py
index df89802c..4dfccad2 100644
--- a/rma/models/rma_order.py
+++ b/rma/models/rma_order.py
@@ -157,13 +157,18 @@ class RmaOrder(models.Model):
if len(self.mapped("rma_line_ids.partner_id")) > 1:
raise UserError(_("All grouped RMA's should have same partner."))
- @api.model
- def create(self, vals):
- if self.env.context.get("supplier") or vals.get("type") == "supplier":
- vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.supplier")
- else:
- vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.customer")
- return super(RmaOrder, self).create(vals)
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ if self.env.context.get("supplier") or vals.get("type") == "supplier":
+ vals["name"] = self.env["ir.sequence"].next_by_code(
+ "rma.order.supplier"
+ )
+ else:
+ vals["name"] = self.env["ir.sequence"].next_by_code(
+ "rma.order.customer"
+ )
+ return super().create(vals_list)
def _view_shipments(self, result, shipments):
# choose the view_mode accordingly
diff --git a/rma/models/rma_order_line.py b/rma/models/rma_order_line.py
index 34e8e574..618ef54f 100644
--- a/rma/models/rma_order_line.py
+++ b/rma/models/rma_order_line.py
@@ -283,7 +283,7 @@ class RmaOrderLine(models.Model):
)
product_tracking = fields.Selection(related="product_id.tracking")
lot_id = fields.Many2one(
- comodel_name="stock.production.lot",
+ comodel_name="stock.lot",
string="Lot/Serial Number",
readonly=True,
states={"draft": [("readonly", False)]},
@@ -372,7 +372,7 @@ class RmaOrderLine(models.Model):
ondelete="cascade",
)
in_route_id = fields.Many2one(
- "stock.location.route",
+ "stock.route",
string="Inbound Route",
required=True,
domain=[("rma_selectable", "=", True)],
@@ -380,7 +380,7 @@ class RmaOrderLine(models.Model):
states={"draft": [("readonly", False)]},
)
out_route_id = fields.Many2one(
- "stock.location.route",
+ "stock.route",
string="Outbound Route",
required=True,
domain=[("rma_selectable", "=", True)],
@@ -513,7 +513,7 @@ class RmaOrderLine(models.Model):
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:
@@ -597,7 +597,7 @@ class RmaOrderLine(models.Model):
self.reference_move_id = False
return True
- def _check_production_lot_assigned(self):
+ def _check_lot_assigned(self):
for rec in self:
if rec.product_id.tracking == "serial" and rec.product_qty != 1:
raise ValidationError(
@@ -609,7 +609,7 @@ class RmaOrderLine(models.Model):
)
def action_rma_to_approve(self):
- self._check_production_lot_assigned()
+ self._check_lot_assigned()
self.write({"state": "to_approve"})
for rec in self:
if rec.product_id.rma_approval_policy == "one_step":
@@ -628,18 +628,19 @@ class RmaOrderLine(models.Model):
self.write({"state": "done"})
return True
- @api.model
- def create(self, vals):
- if not vals.get("name") or vals.get("name") == "/":
- if self.env.context.get("supplier"):
- vals["name"] = self.env["ir.sequence"].next_by_code(
- "rma.order.line.supplier"
- )
- else:
- vals["name"] = self.env["ir.sequence"].next_by_code(
- "rma.order.line.customer"
- )
- return super(RmaOrderLine, self).create(vals)
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ if not vals.get("name") or vals.get("name") == "/":
+ if self.env.context.get("supplier"):
+ vals["name"] = self.env["ir.sequence"].next_by_code(
+ "rma.order.line.supplier"
+ )
+ else:
+ vals["name"] = self.env["ir.sequence"].next_by_code(
+ "rma.order.line.customer"
+ )
+ return super().create(vals_list)
def _get_price_unit(self):
"""The price unit corresponds to the cost of that product"""
diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py
index 3c8f1759..9a839f18 100644
--- a/rma/models/stock_move.py
+++ b/rma/models/stock_move.py
@@ -11,16 +11,17 @@ class StockMove(models.Model):
"rma.order.line", string="RMA line", ondelete="restrict"
)
- @api.model
- def create(self, vals):
- if vals.get("group_id"):
- group = self.env["procurement.group"].browse(vals["group_id"])
- if group.rma_line_id:
- vals["rma_line_id"] = group.rma_line_id.id
- return super(StockMove, self).create(vals)
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ if vals.get("group_id"):
+ group = self.env["procurement.group"].browse(vals["group_id"])
+ if group.rma_line_id:
+ vals["rma_line_id"] = group.rma_line_id.id
+ return super().create(vals_list)
- def _action_assign(self):
- res = super(StockMove, self)._action_assign()
+ def _action_assign(self, force_qty=False):
+ res = super()._action_assign(force_qty=force_qty)
for move in self:
if move.rma_line_id:
move.partner_id = move.rma_line_id.partner_id.id or False
diff --git a/rma/models/stock_warehouse.py b/rma/models/stock_warehouse.py
index 6273c771..1f50e25e 100644
--- a/rma/models/stock_warehouse.py
+++ b/rma/models/stock_warehouse.py
@@ -185,7 +185,7 @@ class StockWarehouse(models.Model):
"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",
"route_id": self.env.ref("rma.route_rma_customer").id,
"picking_type_id": self.rma_cust_in_type_id.id,
@@ -197,7 +197,7 @@ class StockWarehouse(models.Model):
"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",
"route_id": self.env.ref("rma.route_rma_customer").id,
"picking_type_id": self.rma_cust_out_type_id.id,
@@ -209,7 +209,7 @@ class StockWarehouse(models.Model):
"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",
"route_id": self.env.ref("rma.route_rma_supplier").id,
"picking_type_id": self.rma_sup_in_type_id.id,
@@ -221,7 +221,7 @@ class StockWarehouse(models.Model):
"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",
"route_id": self.env.ref("rma.route_rma_supplier").id,
"picking_type_id": self.rma_sup_out_type_id.id,
@@ -264,6 +264,6 @@ class StockWarehouse(models.Model):
class StockLocationRoute(models.Model):
- _inherit = "stock.location.route"
+ _inherit = "stock.route"
rma_selectable = fields.Boolean(string="Selectable on RMA Lines")
diff --git a/rma/report/report_deliveryslip.xml b/rma/report/report_deliveryslip.xml
index 7bf86cf2..961032ba 100644
--- a/rma/report/report_deliveryslip.xml
+++ b/rma/report/report_deliveryslip.xml
@@ -8,7 +8,7 @@
>
| RMA |
diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py
index c4f31728..c5fa272e 100644
--- a/rma/tests/test_rma.py
+++ b/rma/tests/test_rma.py
@@ -108,7 +108,7 @@ class TestRma(common.TransactionCase):
res = rma_line_ids.action_view_in_shipments()
picking = cls.env["stock.picking"].browse(res["res_id"])
picking.action_assign()
- for mv in picking.move_lines:
+ for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
picking._action_done()
return picking
@@ -127,7 +127,7 @@ class TestRma(common.TransactionCase):
res = rma_line_ids.action_view_out_shipments()
picking = cls.env["stock.picking"].browse(res["res_id"])
picking.action_assign()
- for mv in picking.move_lines:
+ for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
picking._action_done()
return picking
@@ -167,7 +167,7 @@ class TestRma(common.TransactionCase):
"""Do picking with only one move on the given date."""
picking.action_confirm()
picking.action_assign()
- for ml in picking.move_lines:
+ for ml in picking.move_ids:
ml.filtered(
lambda m: m.state != "waiting"
).quantity_done = ml.product_uom_qty
@@ -414,7 +414,7 @@ class TestRma(common.TransactionCase):
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
picking = self.env["stock.picking"].browse(res["res_id"])
self.assertEqual(len(picking), 1, "Incorrect number of pickings created")
- moves = picking.move_lines
+ moves = picking.move_ids
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_customer_id.rma_line_ids
lines.refresh()
@@ -474,7 +474,7 @@ class TestRma(common.TransactionCase):
"Wrong qty incoming",
)
picking.action_assign()
- for mv in picking.move_lines:
+ for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
picking._action_done()
lines = self.rma_customer_id.rma_line_ids
@@ -534,7 +534,7 @@ class TestRma(common.TransactionCase):
res = self.rma_customer_id.rma_line_ids.action_view_out_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
picking = self.env["stock.picking"].browse(res["res_id"])
- moves = picking.move_lines
+ moves = picking.move_ids
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_customer_id.rma_line_ids
lines.refresh()
@@ -593,7 +593,7 @@ class TestRma(common.TransactionCase):
"Wrong qty outgoing",
)
picking.action_assign()
- for mv in picking.move_lines:
+ for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
picking._action_done()
lines = self.rma_customer_id.rma_line_ids
@@ -668,7 +668,7 @@ class TestRma(common.TransactionCase):
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
picking = self.env["stock.picking"].browse(res["res_id"])
self.assertEqual(len(picking), 1, "Incorrect number of pickings created")
- moves = picking.move_lines
+ moves = picking.move_ids
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_droship_id.rma_line_ids
lines.refresh()
@@ -767,7 +767,7 @@ class TestRma(common.TransactionCase):
res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
picking = self.env["stock.picking"].browse(res["res_id"])
- moves = picking.move_lines
+ moves = picking.move_ids
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_supplier_id.rma_line_ids
@@ -823,7 +823,7 @@ class TestRma(common.TransactionCase):
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
)
picking.action_assign()
- for mv in picking.move_lines:
+ for mv in picking.move_ids:
mv.quantity_done = mv.product_uom_qty
picking._action_done()
self.assertEqual(
@@ -886,7 +886,7 @@ class TestRma(common.TransactionCase):
pickings = self.env["stock.picking"].browse(res["res_id"])
self.assertEqual(len(pickings), 1, "Incorrect number of pickings created")
picking_in = pickings[0]
- moves = picking_in.move_lines
+ moves = picking_in.move_ids
self.assertEqual(len(moves), 3, "Incorrect number of moves created")
lines = self.rma_supplier_id.rma_line_ids
@@ -925,7 +925,7 @@ class TestRma(common.TransactionCase):
picking_in.action_confirm()
picking_in.action_assign()
for mv in picking_in.move_line_ids:
- mv.qty_done = mv.product_uom_qty
+ mv.qty_done = mv.reserved_uom_qty
picking_in._action_done()
self.assertEqual(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
diff --git a/rma/views/stock_view.xml b/rma/views/stock_view.xml
index 5adf5410..e2e80e67 100644
--- a/rma/views/stock_view.xml
+++ b/rma/views/stock_view.xml
@@ -14,9 +14,9 @@
- stock.location.route.form
+ stock.route.form
- stock.location.route
+ stock.route
diff --git a/rma/wizards/rma_add_serial.py b/rma/wizards/rma_add_serial.py
index 7f142cdb..b271f28e 100644
--- a/rma/wizards/rma_add_serial.py
+++ b/rma/wizards/rma_add_serial.py
@@ -20,7 +20,7 @@ class RmaAddSerialWiz(models.TransientModel):
comodel_name="res.partner",
)
lot_ids = fields.Many2many(
- comodel_name="stock.production.lot",
+ comodel_name="stock.lot",
string="Lots/Serials selected",
)
@@ -76,7 +76,7 @@ class RmaAddSerialWiz(models.TransientModel):
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:
diff --git a/rma/wizards/rma_add_stock_move.py b/rma/wizards/rma_add_stock_move.py
index ce932a7b..408f8a6b 100644
--- a/rma/wizards/rma_add_stock_move.py
+++ b/rma/wizards/rma_add_stock_move.py
@@ -41,7 +41,7 @@ class RmaAddStockMove(models.TransientModel):
compute="_compute_lot_domain",
)
lot_domain_ids = fields.Many2many(
- comodel_name="stock.production.lot",
+ comodel_name="stock.lot",
string="Lots Domain",
compute="_compute_lot_domain",
)
@@ -54,9 +54,7 @@ class RmaAddStockMove(models.TransientModel):
rec.lot_domain_ids = rec.mapped("move_ids.move_line_ids.lot_id").ids
rec.show_lot_filter = bool(rec.lot_domain_ids)
- lot_ids = fields.Many2many(
- comodel_name="stock.production.lot", string="Lots/Serials selected"
- )
+ lot_ids = fields.Many2many(comodel_name="stock.lot", string="Lots/Serials selected")
def select_all(self):
self.ensure_one()
@@ -93,7 +91,7 @@ class RmaAddStockMove(models.TransientModel):
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:
diff --git a/rma/wizards/rma_make_picking.py b/rma/wizards/rma_make_picking.py
index 809a6802..8e254f9c 100644
--- a/rma/wizards/rma_make_picking.py
+++ b/rma/wizards/rma_make_picking.py
@@ -211,7 +211,7 @@ class RmaMakePicking(models.TransientModel):
if picking_type == "incoming":
# Force the reservation of the RMA specific lot for incoming shipments.
# FIXME: still needs fixing, not reserving appropriate serials.
- for move in pickings.move_lines.filtered(
+ for move in pickings.move_ids.filtered(
lambda x: x.state not in ("draft", "cancel", "done")
and x.rma_line_id
and x.product_id.tracking in ("lot", "serial")
diff --git a/rma/wizards/rma_order_line_make_supplier_rma.py b/rma/wizards/rma_order_line_make_supplier_rma.py
index 7845cfb9..bc95899a 100644
--- a/rma/wizards/rma_order_line_make_supplier_rma.py
+++ b/rma/wizards/rma_order_line_make_supplier_rma.py
@@ -94,7 +94,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
else:
operation = self._get_default_operation()
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: