2
I create a product category
4
!record {model: product.category, id: prod_cat1}:
7
I create the product P1
9
!record {model: product.product, id: product1}:
15
procure_method: make_to_order
16
property_stock_inventory: stock.location_inventory
17
property_stock_procurement: stock.location_procurement
18
property_stock_production: stock.location_production
23
uom_id: product.product_uom_unit
24
uom_po_id: product.product_uom_unit
34
I create the product P2
36
!record {model: product.product, id: product2}:
42
procure_method: make_to_order
43
property_stock_inventory: stock.location_inventory
44
property_stock_procurement: stock.location_procurement
45
property_stock_production: stock.location_production
50
uom_id: product.product_uom_unit
51
uom_po_id: product.product_uom_unit
61
I create the product P3
63
!record {model: product.product, id: product3}:
69
procure_method: make_to_order
70
property_stock_inventory: stock.location_inventory
71
property_stock_procurement: stock.location_procurement
72
property_stock_production: stock.location_production
77
uom_id: product.product_uom_unit
78
uom_po_id: product.product_uom_unit
88
I create the product P4
90
!record {model: product.product, id: product4}:
96
procure_method: make_to_stock
97
property_stock_inventory: stock.location_inventory
98
property_stock_procurement: stock.location_procurement
99
property_stock_production: stock.location_production
101
standard_price: 70.00
104
uom_id: product.product_uom_unit
105
uom_po_id: product.product_uom_unit
111
I create a sale order for this 4 products
113
!record {model: sale.order, id: so1}:
115
company_id: base.main_company
116
picking_policy: direct
118
invoice_quantity: order
119
partner_order_id: res_partner_address_0
120
partner_invoice_id: res_partner_address_0
121
partner_shipping_id: res_partner_address_0
122
partner_id: res_partner_a0
123
pricelist_id: product.list0
128
product_uom: product.product_uom_unit
138
product_uom: product.product_uom_unit
148
product_uom: product.product_uom_unit
158
product_uom: product.product_uom_unit
167
I confirm this sale order
169
!workflow {model: sale.order, action: order_confirm, ref: so1}
173
!python {model: procurement.order}: |
174
self.run_scheduler(cr, uid)
176
I check if a PO lines has been created
178
!python {model: purchase.order.line}: |
179
p4_line_ids = self.search(cr, uid, [('product_id', '=', ref('product4'))])
180
assert not p4_line_ids, "A line has been created for the product P4"
181
p1_line_ids = self.search(cr, uid, [('product_id', '=', ref('product1'))])
182
assert len(p1_line_ids) == 1, "No line created for the product P1"
183
p2_line_ids = self.search(cr, uid, [('product_id', '=', ref('product2'))])
184
assert len(p2_line_ids) == 1, "No line created for the product P2"
185
p3_line_ids = self.search(cr, uid, [('product_id', '=', ref('product3'))])
186
assert len(p3_line_ids) == 1, "NO line created for the product P3"
188
p1_line = self.browse(cr, uid, p1_line_ids[0])
189
p2_line = self.browse(cr, uid, p2_line_ids[0])
190
p3_line = self.browse(cr, uid, p3_line_ids[0])
191
assert p1_line.order_id.id == p2_line.order_id.id, "The system has generated 2 PO for P1 and P2 instead of only one"
192
assert p3_line.order_id.id != p1_line.order_id.id, "The system has generated one PO for P1 and P3 instead of 2"