Debian Codegraph @

addons/pos_sale/tests/test_pos_sale_lot.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 import odoo
4 from odoo import fields
5 from odoo.addons.point_of_sale.tests.common import CommonPosTest
6
7
8 @odoo.tests.tagged('post_install', '-at_install')
9 class TestPointOfSaleFlow(CommonPosTest):
10 def test_ship_later_lots(self):
11 self.env.user.group_ids += self.env.ref('account.group_account_manager')
12 self.stock_location = self.company_data['default_warehouse'].lot_stock_id
13 self.twenty_dollars_no_tax.product_variant_id.write({
14 'tracking': 'serial',
15 'is_storable': True,
16 'taxes_id': []
17 })
18 lot_1 = self.env['stock.lot'].create({
19 'name': '1001',
20 'product_id': self.twenty_dollars_no_tax.product_variant_id.id,
21 'company_id': self.env.company.id,
22 })
23 lot_2 = self.env['stock.lot'].create({
24 'name': '1002',
25 'product_id': self.twenty_dollars_no_tax.product_variant_id.id,
26 'company_id': self.env.company.id,
27 })
28 self.env['stock.quant'].with_context(inventory_mode=True).create({
29 'inventory_quantity': 1,
30 'product_id': self.twenty_dollars_no_tax.product_variant_id.id,
31 'location_id': self.stock_location.id,
32 'lot_id': lot_1.id
33 }).action_apply_inventory()
34 self.env['stock.quant'].with_context(inventory_mode=True).create({
35 'inventory_quantity': 1,
36 'product_id': self.twenty_dollars_no_tax.product_variant_id.id,
37 'location_id': self.stock_location.id,
38 'lot_id': lot_2.id
39 }).action_apply_inventory()
40
41 sale_order = self.env['sale.order'].sudo().create({
42 'partner_id': self.partner_stva.id,
43 'order_line': [(0, 0, {
44 'product_id': self.twenty_dollars_no_tax.product_variant_id.id,
45 'name': self.twenty_dollars_no_tax.product_variant_id.name,
46 'price_unit': self.twenty_dollars_no_tax.product_variant_id.lst_price,
47 'product_uom_qty': 2,
48 })],
49 })
50 sale_order.action_confirm()
51 order, _ = self.create_backend_pos_order({
52 'order_data': {
53 'partner_id': self.partner_stva.id,
54 'shipping_date': fields.Date.today(),
55 },
56 'line_data': [{
57 'product_id': self.twenty_dollars_no_tax.product_variant_id.id,
58 'pack_lot_ids': [[0, 0, {'lot_name': lot_1.name}]],
59 'sale_order_line_id': sale_order.order_line[0].id,
60 'sale_order_origin_id': sale_order.id,
61 }],
62 'payment_data': [
63 {'payment_method_id': self.pos_config_usd.payment_method_ids[0].id}
64 ]
65 })
66 self.assertEqual(order.picking_ids.move_line_ids.lot_id, lot_1)