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
33
international_status: itc
35
I create the product P2
37
!record {model: product.product, id: product2}:
43
procure_method: make_to_order
44
property_stock_inventory: stock.location_inventory
45
property_stock_procurement: stock.location_procurement
46
property_stock_production: stock.location_production
51
uom_id: product.product_uom_unit
52
uom_po_id: product.product_uom_unit
61
international_status: itc
63
I create the product P3
65
!record {model: product.product, id: product3}:
71
procure_method: make_to_order
72
property_stock_inventory: stock.location_inventory
73
property_stock_procurement: stock.location_procurement
74
property_stock_production: stock.location_production
79
uom_id: product.product_uom_unit
80
uom_po_id: product.product_uom_unit
89
international_status: itc
91
I create the product P4
93
!record {model: product.product, id: product4}:
99
procure_method: make_to_stock
100
property_stock_inventory: stock.location_inventory
101
property_stock_procurement: stock.location_procurement
102
property_stock_production: stock.location_production
104
standard_price: 70.00
107
uom_id: product.product_uom_unit
108
uom_po_id: product.product_uom_unit
113
international_status: itc
115
I create a sale order for this 4 products
117
!record {model: sale.order, id: so1}:
119
company_id: base.main_company
120
picking_policy: direct
122
invoice_quantity: order
123
partner_order_id: res_partner_address_0
124
partner_invoice_id: res_partner_address_0
125
partner_shipping_id: res_partner_address_0
126
partner_id: res_partner_a0
127
pricelist_id: product.list0
132
product_uom: product.product_uom_unit
142
product_uom: product.product_uom_unit
152
product_uom: product.product_uom_unit
162
product_uom: product.product_uom_unit
171
I confirm this sale order
173
!workflow {model: sale.order, action: order_confirm, ref: so1}
177
!python {model: procurement.order}: |
178
self.run_scheduler(cr, uid)
180
I check if a PO lines has been created
182
!python {model: purchase.order.line}: |
183
p4_line_ids = self.search(cr, uid, [('product_id', '=', ref('product4'))])
184
assert not p4_line_ids, "A line has been created for the product P4"
185
p1_line_ids = self.search(cr, uid, [('product_id', '=', ref('product1'))])
186
assert len(p1_line_ids) == 1, "No line created for the product P1"
187
p2_line_ids = self.search(cr, uid, [('product_id', '=', ref('product2'))])
188
assert len(p2_line_ids) == 1, "No line created for the product P2"
189
p3_line_ids = self.search(cr, uid, [('product_id', '=', ref('product3'))])
190
assert len(p3_line_ids) == 1, "NO line created for the product P3"
192
p1_line = self.browse(cr, uid, p1_line_ids[0])
193
p2_line = self.browse(cr, uid, p2_line_ids[0])
194
p3_line = self.browse(cr, uid, p3_line_ids[0])
195
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"
196
assert p3_line.order_id.id != p1_line.order_id.id, "The system has generated one PO for P1 and P3 instead of 2"