Best Python code snippet using playwright-python
test_inventory.py
Source:test_inventory.py
...26 as expected.27 """28 # make some stock29 self.env['stock.quant']._update_available_quantity(self.product1, self.stock_location, 100)30 self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 1.0)31 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 100.0)32 # remove them with an inventory adjustment33 inventory = self.env['stock.inventory'].create({34 'name': 'remove product1',35 'filter': 'product',36 'location_id': self.stock_location.id,37 'product_id': self.product1.id,38 })39 inventory.action_start()40 self.assertEqual(len(inventory.line_ids), 1)41 self.assertEqual(inventory.line_ids.theoretical_qty, 100)42 inventory.line_ids.product_qty = 0 # Put the quantity back to 043 inventory.action_validate()44 # check45 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 0.0)46 self.assertEqual(sum(self.env['stock.quant']._gather(self.product1, self.stock_location).mapped('quantity')), 0.0)47 def test_inventory_2(self):48 """ Check that adding a tracked product through an inventory adjustment work as expected.49 """50 inventory = self.env['stock.inventory'].create({51 'name': 'remove product1',52 'filter': 'product',53 'location_id': self.stock_location.id,54 'product_id': self.product2.id,55 'exhausted': True, # should be set by an onchange56 })57 inventory.action_start()58 self.assertEqual(len(inventory.line_ids), 1)59 self.assertEqual(inventory.line_ids.theoretical_qty, 0)60 lot1 = self.env['stock.production.lot'].create({61 'name': 'sn2',62 'product_id': self.product2.id,63 })64 inventory.line_ids.prod_lot_id = lot165 inventory.line_ids.product_qty = 166 inventory.action_validate()67 # check68 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, lot_id=lot1), 1.0)69 self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location, lot_id=lot1)), 1.0)70 self.assertEqual(lot1.product_qty, 1.0)71 def test_inventory_3(self):72 """ Check that it's not posisble to have multiple products with a serial number through an73 inventory adjustment74 """75 inventory = self.env['stock.inventory'].create({76 'name': 'remove product1',77 'filter': 'product',78 'location_id': self.stock_location.id,79 'product_id': self.product2.id,80 'exhausted': True, # should be set by an onchange81 })82 inventory.action_start()83 self.assertEqual(len(inventory.line_ids), 1)84 self.assertEqual(inventory.line_ids.theoretical_qty, 0)85 lot1 = self.env['stock.production.lot'].create({86 'name': 'sn2',87 'product_id': self.product2.id,88 })89 inventory.line_ids.prod_lot_id = lot190 inventory.line_ids.product_qty = 291 with self.assertRaises(ValidationError):92 inventory.action_validate()93 def test_inventory_4(self):94 """ Check that even if a product is tracked by serial number, it's possible to add95 untracked one in an inventory adjustment.96 """97 inventory = self.env['stock.inventory'].create({98 'name': 'remove product1',99 'filter': 'product',100 'location_id': self.stock_location.id,101 'product_id': self.product2.id,102 'exhausted': True, # should be set by an onchange103 })104 inventory.action_start()105 self.assertEqual(len(inventory.line_ids), 1)106 self.assertEqual(inventory.line_ids.theoretical_qty, 0)107 lot1 = self.env['stock.production.lot'].create({108 'name': 'sn2',109 'product_id': self.product2.id,110 })111 inventory.line_ids.prod_lot_id = lot1112 inventory.line_ids.product_qty = 1113 self.env['stock.inventory.line'].create({114 'inventory_id': inventory.id,115 'product_id': self.product2.id,116 'product_uom_id': self.uom_unit.id,117 'product_qty': 10,118 'location_id': self.stock_location.id,119 })120 res_dict_for_warning_lot = inventory.action_validate()121 wizard_warning_lot = self.env[(res_dict_for_warning_lot.get('res_model'))].browse(res_dict_for_warning_lot.get('res_id'))122 wizard_warning_lot.action_confirm()123 # check124 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, lot_id=lot1, strict=True), 1.0)125 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location, strict=True), 10.0)126 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product2, self.stock_location), 11.0)127 self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location, lot_id=lot1, strict=True)), 1.0)128 self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location, strict=True)), 1.0)129 self.assertEqual(len(self.env['stock.quant']._gather(self.product2, self.stock_location)), 2.0)130 def test_inventory_5(self):131 """ Check that assigning an owner does work.132 """133 owner1 = self.env['res.partner'].create({'name': 'test_inventory_5'})134 inventory = self.env['stock.inventory'].create({135 'name': 'remove product1',136 'filter': 'product',137 'location_id': self.stock_location.id,138 'product_id': self.product1.id,139 'exhausted': True,140 })141 inventory.action_start()142 self.assertEqual(len(inventory.line_ids), 1)143 self.assertEqual(inventory.line_ids.theoretical_qty, 0)144 inventory.line_ids.partner_id = owner1145 inventory.line_ids.product_qty = 5146 inventory.action_validate()147 quant = self.env['stock.quant']._gather(self.product1, self.stock_location)148 self.assertEqual(len(quant), 1)149 self.assertEqual(quant.quantity, 5)150 self.assertEqual(quant.owner_id.id, owner1.id)151 def test_inventory_6(self):152 """ Test that for chained moves, making an inventory adjustment to reduce a quantity that153 has been reserved correctly free the reservation. After that, add products in stock and check154 that they're used if the user encodes more than what's available through the chain155 """156 # add 10 products in stock157 inventory = self.env['stock.inventory'].create({158 'name': 'add 10 products 1',159 'filter': 'product',160 'location_id': self.stock_location.id,161 'product_id': self.product1.id,162 'exhausted': True, # should be set by an onchange163 })164 inventory.action_start()165 inventory.line_ids.product_qty = 10166 inventory.action_validate()167 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 10.0)168 # Make a chain of two moves, validate the first and check that 10 products are reserved169 # in the second one.170 move_stock_pack = self.env['stock.move'].create({171 'name': 'test_link_2_1',172 'location_id': self.stock_location.id,173 'location_dest_id': self.pack_location.id,174 'product_id': self.product1.id,175 'product_uom': self.uom_unit.id,176 'product_uom_qty': 10.0,177 })178 move_pack_cust = self.env['stock.move'].create({179 'name': 'test_link_2_2',180 'location_id': self.pack_location.id,181 'location_dest_id': self.customer_location.id,182 'product_id': self.product1.id,183 'product_uom': self.uom_unit.id,184 'product_uom_qty': 10.0,185 })186 move_stock_pack.write({'move_dest_ids': [(4, move_pack_cust.id, 0)]})187 move_pack_cust.write({'move_orig_ids': [(4, move_stock_pack.id, 0)]})188 (move_stock_pack + move_pack_cust)._action_confirm()189 move_stock_pack._action_assign()190 self.assertEqual(move_stock_pack.state, 'assigned')191 move_stock_pack.move_line_ids.qty_done = 10192 move_stock_pack._action_done()193 self.assertEqual(move_stock_pack.state, 'done')194 self.assertEqual(move_pack_cust.state, 'assigned')195 self.assertEqual(self.env['stock.quant']._gather(self.product1, self.pack_location).quantity, 10.0)196 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.pack_location), 0.0)197 # Make and inventory adjustment and remove two products from the pack location. This should198 # free the reservation of the second move.199 inventory = self.env['stock.inventory'].create({200 'name': 'remove 2 products 1',201 'filter': 'product',202 'location_id': self.pack_location.id,203 'product_id': self.product1.id,204 })205 inventory.action_start()206 inventory.line_ids.product_qty = 8207 inventory.action_validate()208 self.assertEqual(self.env['stock.quant']._gather(self.product1, self.pack_location).quantity, 8.0)209 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.pack_location), 0)210 self.assertEqual(move_pack_cust.state, 'partially_available')211 self.assertEqual(move_pack_cust.reserved_availability, 8)212 # If the user tries to assign again, only 8 products are available and thus the reservation213 # state should not change.214 move_pack_cust._action_assign()215 self.assertEqual(move_pack_cust.state, 'partially_available')216 self.assertEqual(move_pack_cust.reserved_availability, 8)217 # Make a new inventory adjustment and bring two now products.218 inventory = self.env['stock.inventory'].create({219 'name': 'remove 2 products 1',220 'filter': 'product',221 'location_id': self.pack_location.id,222 'product_id': self.product1.id,223 })224 inventory.action_start()225 inventory.line_ids.product_qty = 10226 inventory.action_validate()227 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.pack_location), 2)228 # Nothing should have changed for our pack move229 self.assertEqual(move_pack_cust.state, 'partially_available')230 self.assertEqual(move_pack_cust.reserved_availability, 8)231 # Running _action_assign will now find the new available quantity. Indeed, as the products232 # are not discernabl (not lot/pack/owner), even if the new available quantity is not directly233 # brought by the chain, the system fill take them into account.234 move_pack_cust._action_assign()235 self.assertEqual(move_pack_cust.state, 'assigned')236 # move all the things237 move_pack_cust.move_line_ids.qty_done = 10238 move_stock_pack._action_done()239 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.pack_location), 0)240 def test_inventory_7(self):241 """ Check that duplicated quants create a single inventory line.242 """243 owner1 = self.env['res.partner'].create({'name': 'test_inventory_7'})244 vals = {245 'product_id': self.product1.id,246 'product_uom_id': self.uom_unit.id,247 'owner_id': owner1.id,248 'location_id': self.stock_location.id,249 'quantity': 1,250 'reserved_quantity': 0,251 }252 self.env['stock.quant'].create(vals)253 self.env['stock.quant'].create(vals)254 self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 2.0)255 self.assertEqual(self.env['stock.quant']._get_available_quantity(self.product1, self.stock_location), 2.0)256 257 inventory = self.env['stock.inventory'].create({258 'name': 'product1',259 'filter': 'product',260 'location_id': self.stock_location.id,261 'product_id': self.product1.id,262 })263 inventory.action_start()264 self.assertEqual(len(inventory.line_ids), 1)...
test_batch_picking.py
Source:test_batch_picking.py
...65 self.picking_client_2.move_lines.quantity_done = 1066 self.batch.done()67 self.assertEqual(self.picking_client_1.state, 'done', 'Picking 1 should be done')68 self.assertEqual(self.picking_client_2.state, 'done', 'Picking 2 should be done')69 quant_A = self.env['stock.quant']._gather(self.productA, self.stock_location)70 quant_B = self.env['stock.quant']._gather(self.productB, self.stock_location)71 # ensure that quantity for picking has been moved72 self.assertFalse(sum(quant_A.mapped('quantity')))73 self.assertFalse(sum(quant_B.mapped('quantity')))74 def test_simple_batch_with_wizard(self):75 """ Test a simple batch picking with all quantity for picking available.76 The user use the wizard in order to complete automatically the quantity_done to77 the initial demand (or reserved quantity in this test).78 """79 self.env['stock.quant']._update_available_quantity(self.productA, self.stock_location, 10.0)80 self.env['stock.quant']._update_available_quantity(self.productB, self.stock_location, 10.0)81 # confirm batch, picking should be assigned82 self.batch.confirm_picking()83 self.assertEqual(self.picking_client_1.state, 'assigned', 'Picking 1 should be reserved')84 self.assertEqual(self.picking_client_2.state, 'assigned', 'Picking 2 should be reserved')85 # There should be a wizard asking to process picking without quantity done86 immediate_transfer_wizard_dict = self.batch.done()87 self.assertTrue(immediate_transfer_wizard_dict)88 immediate_transfer_wizard = self.env[(immediate_transfer_wizard_dict.get('res_model'))].browse(immediate_transfer_wizard_dict.get('res_id'))89 self.assertEqual(len(immediate_transfer_wizard.pick_ids), 2)90 immediate_transfer_wizard.process()91 self.assertEqual(self.picking_client_1.state, 'done', 'Picking 1 should be done')92 self.assertEqual(self.picking_client_2.state, 'done', 'Picking 2 should be done')93 quant_A = self.env['stock.quant']._gather(self.productA, self.stock_location)94 quant_B = self.env['stock.quant']._gather(self.productB, self.stock_location)95 # ensure that quantity for picking has been moved96 self.assertFalse(sum(quant_A.mapped('quantity')))97 self.assertFalse(sum(quant_B.mapped('quantity')))98 def test_batch_with_backorder_wizard(self):99 """ Test a simple batch picking with only one quantity fully available.100 The user will set by himself the quantity reserved for each picking and101 run the picking batch. There should be a wizard asking for a backorder.102 """103 self.env['stock.quant']._update_available_quantity(self.productA, self.stock_location, 5.0)104 self.env['stock.quant']._update_available_quantity(self.productB, self.stock_location, 10.0)105 # confirm batch, picking should be assigned106 self.batch.confirm_picking()107 self.assertEqual(self.picking_client_1.state, 'assigned', 'Picking 1 should be ready')108 self.assertEqual(self.picking_client_2.state, 'assigned', 'Picking 2 should be ready')109 self.picking_client_1.move_lines.quantity_done = 5110 self.picking_client_2.move_lines.quantity_done = 10111 # There should be a wizard asking to process picking without quantity done112 back_order_wizard_dict = self.batch.done()113 self.assertTrue(back_order_wizard_dict)114 back_order_wizard = self.env[(back_order_wizard_dict.get('res_model'))].browse(back_order_wizard_dict.get('res_id'))115 self.assertEqual(len(back_order_wizard.pick_ids), 1)116 self.assertEqual(self.picking_client_2.state, 'done', 'Picking 2 should be done')117 back_order_wizard.process()118 self.assertEqual(self.picking_client_1.state, 'done', 'Picking 1 should be done')119 self.assertEqual(self.picking_client_1.move_lines.product_uom_qty, 5, 'initial demand should be 5 after picking split')120 self.assertTrue(self.env['stock.picking'].search([('backorder_id', '=', self.picking_client_1.id)]), 'no back order created')121 quant_A = self.env['stock.quant']._gather(self.productA, self.stock_location)122 quant_B = self.env['stock.quant']._gather(self.productB, self.stock_location)123 # ensure that quantity for picking has been moved124 self.assertFalse(sum(quant_A.mapped('quantity')))125 self.assertFalse(sum(quant_B.mapped('quantity')))126 def test_batch_with_immediate_transfer_and_backorder_wizard(self):127 """ Test a simple batch picking with only one product fully available.128 Everything should be automatically. First one backorder in order to set quantity_done129 to reserved quantity. After a second wizard asking for a backorder for the quantity that130 has not been fully transfered.131 """132 self.env['stock.quant']._update_available_quantity(self.productA, self.stock_location, 5.0)133 self.env['stock.quant']._update_available_quantity(self.productB, self.stock_location, 10.0)134 # confirm batch, picking should be assigned135 self.batch.confirm_picking()136 self.assertEqual(self.picking_client_1.state, 'assigned', 'Picking 1 should be ready')137 self.assertEqual(self.picking_client_2.state, 'assigned', 'Picking 2 should be ready')138 # There should be a wizard asking to process picking without quantity done139 immediate_transfer_wizard_dict = self.batch.done()140 self.assertTrue(immediate_transfer_wizard_dict)141 immediate_transfer_wizard = self.env[(immediate_transfer_wizard_dict.get('res_model'))].browse(immediate_transfer_wizard_dict.get('res_id'))142 self.assertEqual(len(immediate_transfer_wizard.pick_ids), 2)143 back_order_wizard_dict = immediate_transfer_wizard.process()144 self.assertTrue(back_order_wizard_dict)145 back_order_wizard = self.env[(back_order_wizard_dict.get('res_model'))].browse(back_order_wizard_dict.get('res_id'))146 self.assertEqual(len(back_order_wizard.pick_ids), 1)147 back_order_wizard.process()148 self.assertEqual(self.picking_client_1.state, 'done', 'Picking 1 should be done')149 self.assertEqual(self.picking_client_1.move_lines.product_uom_qty, 5, 'initial demand should be 5 after picking split')150 self.assertTrue(self.env['stock.picking'].search([('backorder_id', '=', self.picking_client_1.id)]), 'no back order created')151 quant_A = self.env['stock.quant']._gather(self.productA, self.stock_location)152 quant_B = self.env['stock.quant']._gather(self.productB, self.stock_location)153 # ensure that quantity for picking has been moved154 self.assertFalse(sum(quant_A.mapped('quantity')))155 self.assertFalse(sum(quant_B.mapped('quantity')))156 def test_batch_with_immediate_transfer_and_backorder_wizard_with_manual_operations(self):157 """ Test a simple batch picking with only one quantity fully available.158 The user set the quantity done only for the partially available picking.159 The test should run the immediate transfer for the first picking and then160 the backorder wizard for the second picking.161 """162 self.env['stock.quant']._update_available_quantity(self.productA, self.stock_location, 5.0)163 self.env['stock.quant']._update_available_quantity(self.productB, self.stock_location, 10.0)164 # confirm batch, picking should be assigned165 self.batch.confirm_picking()166 self.assertEqual(self.picking_client_1.state, 'assigned', 'Picking 1 should be ready')167 self.assertEqual(self.picking_client_2.state, 'assigned', 'Picking 2 should be ready')168 self.picking_client_1.move_lines.quantity_done = 5169 # There should be a wizard asking to process picking without quantity done170 immediate_transfer_wizard_dict = self.batch.done()171 self.assertTrue(immediate_transfer_wizard_dict)172 immediate_transfer_wizard = self.env[(immediate_transfer_wizard_dict.get('res_model'))].browse(immediate_transfer_wizard_dict.get('res_id'))173 self.assertEqual(len(immediate_transfer_wizard.pick_ids), 1)174 back_order_wizard_dict = immediate_transfer_wizard.process()175 self.assertTrue(back_order_wizard_dict)176 back_order_wizard = self.env[(back_order_wizard_dict.get('res_model'))].browse(back_order_wizard_dict.get('res_id'))177 self.assertEqual(len(back_order_wizard.pick_ids), 1)178 back_order_wizard.process()179 self.assertEqual(self.picking_client_1.state, 'done', 'Picking 1 should be done')180 self.assertEqual(self.picking_client_1.move_lines.product_uom_qty, 5, 'initial demand should be 5 after picking split')181 self.assertTrue(self.env['stock.picking'].search([('backorder_id', '=', self.picking_client_1.id)]), 'no back order created')182 quant_A = self.env['stock.quant']._gather(self.productA, self.stock_location)183 quant_B = self.env['stock.quant']._gather(self.productB, self.stock_location)184 # ensure that quantity for picking has been moved185 self.assertFalse(sum(quant_A.mapped('quantity')))...
mappings.py
Source:mappings.py
...39 # Note: torch.split does not create contiguous tensors by default.40 rank = get_model_parallel_rank()41 output = input_list[rank].contiguous()42 return output43def _gather(input_):44 """Gather tensors and concatinate along the last dimension."""45 world_size = get_model_parallel_world_size()46 # Bypass the function if we are using only 1 GPU.47 if world_size==1:48 return input_49 # Size and dimension.50 last_dim = input_.dim() - 151 rank = get_model_parallel_rank()52 tensor_list = [torch.empty_like(input_) for _ in range(world_size)]53 tensor_list[rank] = input_54 timers = get_timers()55 timers('_gather inside').start()56 torch.distributed.all_gather(tensor_list, input_, group=get_model_parallel_group())57 timers('_gather inside').stop()58 # Note: torch.cat already creates a contiguous tensor.59 output = torch.cat(tensor_list, dim=last_dim).contiguous()60 return output61class _CopyToModelParallelRegion(torch.autograd.Function):62 """Pass the input to the model parallel region."""63 @staticmethod64 def symbolic(graph, input_):65 return input_66 67 @staticmethod68 def forward(ctx, input_):69 return input_70 @staticmethod71 def backward(ctx, grad_output):72 timers = get_timers()73 timers('CopyToModelParallelRegion BACKWARD _reduce').start()74 x = _reduce(grad_output)75 timers('CopyToModelParallelRegion BACKWARD _reduce').stop()76 return x77 #return _reduce(grad_output)78class _ReduceFromModelParallelRegion(torch.autograd.Function):79 """All-redcue the input from the model parallel region."""80 @staticmethod81 def symbolic(graph, input_):82 timers = get_timers()83 timers('ReduceFromModelParallelRegion SYMBOLIC _reduce').start()84 x = _reduce(input_)85 timers('ReduceFromModelParallelRegion SYMBOLIC _reduce').stop()86 return x87 #return _reduce(input_)88 89 @staticmethod90 def forward(ctx, input_):91 timers = get_timers()92 timers('ReduceFromModelParallelRegion FORWARD _reduce').start()93 x=_reduce(input_)94 timers('ReduceFromModelParallelRegion FORWARD _reduce').stop()95 return x96 #return _reduce(input_)97 @staticmethod98 def backward(ctx, grad_output):99 return grad_output100class _ScatterToModelParallelRegion(torch.autograd.Function):101 """Split the input and keep only the corresponding chuck to the rank."""102 @staticmethod103 def symbolic(graph, input_):104 return _split(input_)105 @staticmethod106 def forward(ctx, input_):107 return _split(input_)108 @staticmethod109 def backward(ctx, grad_output):110 timers = get_timers()111 timers('ScatterToModelParallelRegion BACKWARD _gather').start()112 x = _gather(grad_output)113 timers('ScatterToModelParallelRegion BACKWARD _gather').stop()114 return x115# return _gather(grad_output)116class _GatherFromModelParallelRegion(torch.autograd.Function):117 """Gather the input from model parallel region and concatinate."""118 @staticmethod119 def symbolic(graph, input_):120 timers = get_timers()121 timers('GatherFromModelParallelRegion SYMBOLIC _gather').start()122 x = _gather(input_)123 timers('GatherFromModelParallelRegion SYMBOLIC _gather').stop()124 return x125 126 @staticmethod127 def forward(ctx, input_):128 timers = get_timers()129 timers('GatherFromModelParallelRegion FORWARD _gather').start()130 x = _gather(input_)131 timers('GatherFromModelParallelRegion FORWARD _gather').stop()132 return x133 @staticmethod134 def backward(ctx, grad_output):135# timers = get_timers()136# timers('GatherFromModelParallelRegion BACKWARD _gather').start()137 x = _split(grad_output)138# timers('GatherFromModelParallelRegion BACKWARD _gather').stop()139 return x140# return _split(grad_output)141# -----------------142# Helper functions.143# -----------------144def copy_to_model_parallel_region(input_):...
test_robustness.py
Source:test_robustness.py
...36 })37 move1._action_confirm()38 move1._action_assign()39 self.assertEqual(move1.state, 'assigned')40 quant = self.env['stock.quant']._gather(41 self.product1,42 self.stock_location,43 )44 # assert the reservation45 self.assertEqual(quant.reserved_quantity, 12)46 self.assertEqual(move1.product_qty, 12)47 # change the factor48 with self.assertRaises(UserError):49 with self.cr.savepoint():50 move1.product_uom.factor = 0.0551 # assert the reservation52 self.assertEqual(quant.reserved_quantity, 12)53 self.assertEqual(move1.state, 'assigned')54 self.assertEqual(move1.product_qty, 12)55 # unreserve56 move1._do_unreserve()57 def test_location_usage(self):58 """ Changing the usage of a location shouldn't be allowed while59 quantities are reserved, else the existing move lines won't be60 consistent with the `reserved_quantity` on the quants.61 """62 # change stock usage63 self.stock_location.scrap_location = True64 # make some stock65 self.env['stock.quant']._update_available_quantity(66 self.product1,67 self.stock_location,68 1,69 )70 # reserve a unit71 move1 = self.env['stock.move'].create({72 'name': 'test_location_archive',73 'location_id': self.stock_location.id,74 'location_dest_id': self.customer_location.id,75 'product_id': self.product1.id,76 'product_uom': self.uom_unit.id,77 'product_uom_qty': 1,78 })79 move1._action_confirm()80 move1._action_assign()81 self.assertEqual(move1.state, 'assigned')82 quant = self.env['stock.quant']._gather(83 self.product1,84 self.stock_location,85 )86 # assert the reservation87 self.assertEqual(quant.reserved_quantity, 0) # reservation is bypassed in scrap location88 self.assertEqual(move1.product_qty, 1)89 # change the stock usage90 with self.assertRaises(UserError):91 with self.cr.savepoint():92 self.stock_location.scrap_location = False93 # unreserve94 move1._do_unreserve()95 def test_package_unpack(self):96 """ Unpack a package that contains quants with a reservation97 should also remove the package on the reserved move lines.98 """99 package = self.env['stock.quant.package'].create({100 'name': 'Shell Helix HX7 10W30',101 })102 self.env['stock.quant']._update_available_quantity(103 self.product1,104 self.stock_location,105 10,106 package_id=package107 )108 # reserve a dozen109 move1 = self.env['stock.move'].create({110 'name': 'test_uom_rounding',111 'location_id': self.stock_location.id,112 'location_dest_id': self.customer_location.id,113 'product_id': self.product1.id,114 'product_uom': self.uom_unit.id,115 'product_uom_qty': 10,116 })117 move1._action_confirm()118 move1._action_assign()119 move1.result_package_id = False120 package.unpack()121 # unreserve122 move1._do_unreserve()123 self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location)), 1)124 self.assertEqual(len(self.env['stock.quant']._gather(self.product1, self.stock_location, package_id=package)), 0)...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!