6
6
7
7
8
8
class TestStockWarehouseCalendar (TransactionCase ):
9
-
10
9
def setUp (self ):
11
10
super (TestStockWarehouseCalendar , self ).setUp ()
12
- self .move_obj = self .env ['stock.move' ]
13
- self .company = self .env .ref ('base.main_company' )
14
- self .company_partner = self .env .ref ('base.main_partner' )
15
- self .calendar = self .env .ref ('resource.resource_calendar_std' )
16
- self .supplier_info = self .env ['product.supplierinfo' ]
17
- self .PurchaseOrder = self .env ['purchase.order' ]
18
- self .PurchaseOrderLine = self .env ['purchase.order.line' ]
19
- self .stock_location = self .env ['ir.model.data' ].xmlid_to_object (
20
- 'stock.stock_location_stock' )
21
- self .customer_location = self .env ['ir.model.data' ].xmlid_to_object (
22
- 'stock.stock_location_customers' )
23
- self .picking_type_out = self .env ['ir.model.data' ].xmlid_to_object (
24
- 'stock.picking_type_out' )
25
- self .route_buy = self .env .ref ('purchase_stock.route_warehouse0_buy' ).id
11
+ self .move_obj = self .env ["stock.move" ]
12
+ self .company = self .env .ref ("base.main_company" )
13
+ self .company_partner = self .env .ref ("base.main_partner" )
14
+ self .calendar = self .env .ref ("resource.resource_calendar_std" )
15
+ self .supplier_info = self .env ["product.supplierinfo" ]
16
+ self .PurchaseOrder = self .env ["purchase.order" ]
17
+ self .PurchaseOrderLine = self .env ["purchase.order.line" ]
18
+ self .stock_location = self .env ["ir.model.data" ].xmlid_to_object (
19
+ "stock.stock_location_stock"
20
+ )
21
+ self .customer_location = self .env ["ir.model.data" ].xmlid_to_object (
22
+ "stock.stock_location_customers"
23
+ )
24
+ self .picking_type_out = self .env ["ir.model.data" ].xmlid_to_object (
25
+ "stock.picking_type_out"
26
+ )
27
+ self .route_buy = self .env .ref ("purchase_stock.route_warehouse0_buy" ).id
26
28
27
29
# Create product
28
- self .product = self .env ['product.product' ].create ({
29
- 'name' : 'test product' ,
30
- 'default_code' : 'PRD' ,
31
- 'type' : 'product' ,
32
- 'route_ids' : [(4 , self .ref ('stock.route_warehouse0_mto' )),
33
- (4 , self .ref ('purchase_stock.route_warehouse0_buy' ))]
34
- })
30
+ self .product = self .env ["product.product" ].create (
31
+ {
32
+ "name" : "test product" ,
33
+ "default_code" : "PRD" ,
34
+ "type" : "product" ,
35
+ "route_ids" : [
36
+ (4 , self .ref ("stock.route_warehouse0_mto" )),
37
+ (4 , self .ref ("purchase_stock.route_warehouse0_buy" )),
38
+ ],
39
+ }
40
+ )
35
41
36
42
# Partner and Supplierinfo
37
- self .company_partner .write ({
38
- 'delay_calendar_type' : 'supplier_calendar' ,
39
- 'factory_calendar_id' : self .calendar .id
40
-
41
- })
42
- self .seller_01 = self .supplier_info .create ({
43
- 'name' : self .company_partner .id ,
44
- "product_id" : self .product .id ,
45
- 'product_tmpl_id' : self .product .product_tmpl_id .id ,
46
- 'delay' : 3
47
- })
43
+ self .company_partner .write (
44
+ {
45
+ "delay_calendar_type" : "supplier_calendar" ,
46
+ "factory_calendar_id" : self .calendar .id ,
47
+ }
48
+ )
49
+ self .seller_01 = self .supplier_info .create (
50
+ {
51
+ "name" : self .company_partner .id ,
52
+ "product_id" : self .product .id ,
53
+ "product_tmpl_id" : self .product .product_tmpl_id .id ,
54
+ "delay" : 3 ,
55
+ }
56
+ )
48
57
49
58
def test_01_purchase_order_with_supplier_calendar (self ):
50
59
# Create a customer picking
51
- customer_picking = self .env ['stock.picking' ].create ({
52
- 'location_id' : self .stock_location .id ,
53
- 'location_dest_id' : self .customer_location .id ,
54
- 'partner_id' : self .company_partner .id ,
55
- 'picking_type_id' : self .picking_type_out .id ,
56
- })
60
+ customer_picking = self .env ["stock.picking" ].create (
61
+ {
62
+ "location_id" : self .stock_location .id ,
63
+ "location_dest_id" : self .customer_location .id ,
64
+ "partner_id" : self .company_partner .id ,
65
+ "picking_type_id" : self .picking_type_out .id ,
66
+ }
67
+ )
57
68
58
- customer_move = self .env ['stock.move' ].create ({
59
- 'name' : 'move out' ,
60
- 'location_id' : self .stock_location .id ,
61
- 'location_dest_id' : self .customer_location .id ,
62
- 'product_id' : self .product .id ,
63
- 'product_uom' : self .product .uom_id .id ,
64
- 'product_uom_qty' : 80.0 ,
65
- 'procure_method' : 'make_to_order' ,
66
- 'picking_id' : customer_picking .id ,
67
- 'date_expected' : '2097-01-14 09:00:00' # Monday
68
- })
69
+ customer_move = self .env ["stock.move" ].create (
70
+ {
71
+ "name" : "move out" ,
72
+ "location_id" : self .stock_location .id ,
73
+ "location_dest_id" : self .customer_location .id ,
74
+ "product_id" : self .product .id ,
75
+ "product_uom" : self .product .uom_id .id ,
76
+ "product_uom_qty" : 80.0 ,
77
+ "procure_method" : "make_to_order" ,
78
+ "picking_id" : customer_picking .id ,
79
+ "date_expected" : "2097-01-14 09:00:00" , # Monday
80
+ }
81
+ )
69
82
70
83
customer_move ._action_confirm ()
71
84
72
- purchase_order = self .env ['purchase.order' ].search (
73
- [('partner_id' , '=' , self .company_partner .id )])
74
- self .assertTrue (purchase_order , 'No purchase order created.' )
85
+ purchase_order = self .env ["purchase.order" ].search (
86
+ [("partner_id" , "=" , self .company_partner .id )]
87
+ )
88
+ self .assertTrue (purchase_order , "No purchase order created." )
75
89
date_order = fields .Date .to_date (purchase_order .date_order )
76
- wednesday = fields .Date .to_date (' 2097-01-09 09:00:00' )
90
+ wednesday = fields .Date .to_date (" 2097-01-09 09:00:00" )
77
91
self .assertEqual (date_order , wednesday ) # Wednesday
78
92
79
93
def test_02_purchase_order_supplier_calendar_global_leaves (self ):
80
94
# Global leaves
81
- self .calendar .write ({
82
- 'global_leave_ids' : [
83
- (0 , False , {
84
- 'name' : 'Test' ,
85
- 'date_from' : '2097-01-14' , # Monday
86
- 'date_to' : '2097-01-19' , # Saturday
87
- }),
88
- ],
89
- })
95
+ self .calendar .write (
96
+ {
97
+ "global_leave_ids" : [
98
+ (
99
+ 0 ,
100
+ False ,
101
+ {
102
+ "name" : "Test" ,
103
+ "date_from" : "2097-01-14" , # Monday
104
+ "date_to" : "2097-01-19" , # Saturday
105
+ },
106
+ ),
107
+ ],
108
+ }
109
+ )
90
110
91
111
reference = "2097-01-14 09:00:00" # Monday
92
112
# With calendar
@@ -97,10 +117,9 @@ def test_02_purchase_order_supplier_calendar_global_leaves(self):
97
117
result = self .company_partner .supplier_plan_days (reference_2 , 3 ).date ()
98
118
self .assertEquals (result , next_wednesday )
99
119
# Without calendar
100
- self .company_partner .write ({
101
- 'delay_calendar_type' : 'natural' ,
102
- 'factory_calendar_id' : False
103
- })
120
+ self .company_partner .write (
121
+ {"delay_calendar_type" : "natural" , "factory_calendar_id" : False }
122
+ )
104
123
reference_3 = "2097-01-25 12:00:00" # friday
105
124
result = self .company_partner .supplier_plan_days (reference_3 , 3 ).date ()
106
125
monday = fields .Date .to_date ("2097-01-28" )
0 commit comments