diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 7ef60374..02a419ff 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -2,7 +2,7 @@ { 'name': 'Hibou RMAs', - 'version': '14.0.1.0.1', + 'version': '15.0.1.0.0', 'category': 'Warehouse', 'author': 'Hibou Corp.', 'license': 'OPL-1', diff --git a/rma/models/rma.py b/rma/models/rma.py index d059cc2b..1324e179 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -122,6 +122,8 @@ class RMATemplate(models.Model): 'product_uom': l.product_uom_id.id, 'procure_method': self.in_procure_method, 'to_refund': self.in_to_refund, + 'location_id': self.in_location_id.id, + 'location_dest_id': self.in_location_dest_id.id, }) for l in rma.lines.filtered(lambda l: l.product_id.type != 'service')], } @@ -140,6 +142,8 @@ class RMATemplate(models.Model): 'product_uom': l.product_uom_id.id, 'procure_method': self.out_procure_method, 'to_refund': self.out_to_refund, + 'location_id': self.out_location_id.id, + 'location_dest_id': self.out_location_dest_id.id, }) for l in rma.lines.filtered(lambda l: l.product_id.type != 'service')], } diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 99049e27..380e2163 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -80,15 +80,11 @@ class TestRMA(common.TransactionCase): location = self.env.ref('stock.stock_location_stock') location_customer = self.env.ref('stock.stock_location_customers') - adj = self.env['stock.inventory'].create({ - 'name': 'Adjust Out', - 'product_ids': [(4, self.product1.id)], - }) - adj.action_start() - adj.line_ids.write({ - 'product_qty': 0.0, - }) - adj.action_validate() + adjust_to_zero_quant = self.env['stock.quant'].with_context(inventory_mode=True).create({ + 'product_id': self.product1.id, + 'location_id': location.id, + 'inventory_quantity': 0.0 + }).action_apply_inventory() # No Quants after moving inventory out (quant exists with qty == 0 in Odoo 14) quant = self.env['stock.quant'].search([('product_id', '=', self.product1.id), @@ -106,22 +102,13 @@ class TestRMA(common.TransactionCase): 'product_uom_id': self.product1.uom_id.id, 'company_id': self.env.user.company_id.id, }) - adj = self.env['stock.inventory'].create({ - 'name': 'Initial', - 'product_ids': [(4, self.product1.id)], - }) - adj.action_start() - if not adj.line_ids: - _ = self.env['stock.inventory.line'].create({ - 'inventory_id': adj.id, - 'product_id': self.product1.id, - 'location_id': self.env.ref('stock.warehouse0').lot_stock_id.id, - }) - adj.line_ids.write({ - 'product_qty': 1.0, - 'prod_lot_id': lot.id, - }) - adj.action_validate() + + adjust_to_zero_quant = self.env['stock.quant'].with_context(inventory_mode=True).create({ + 'product_id': self.product1.id, + 'location_id': self.env.ref('stock.warehouse0').lot_stock_id.id, + 'inventory_quantity': 1.0, + 'lot_id': lot.id, + }).action_apply_inventory() self.assertEqual(self.product1.qty_available, 1.0) self.assertTrue(lot.quant_ids) @@ -189,6 +176,10 @@ class TestRMA(common.TransactionCase): pack_opt = rma.in_picking_id.move_line_ids[0] self.assertTrue(pack_opt) + # unlink the lot so that we can re-add it later + self.assertTrue(pack_opt.lot_id) + pack_opt.write({'lot_id': False}) + # We cannot check this directly anymore. Instead just try to return the same lot and make sure you can. # self.assertEqual(pack_opt.lot_id, lot)