2 In order to test to merge two purchase order,I start by creating a new product 'Nokia3110c'
4 !record {model: product.product, id: product_product_nokia3110c}:
5 categ_id: 'product.product_category_3'
10 procure_method: make_to_order
11 property_stock_inventory: stock.location_inventory
12 property_stock_procurement: stock.location_procurement
13 property_stock_production: stock.location_production
15 standard_price: 5000.0
18 uom_id: product.product_uom_unit
19 uom_po_id: product.product_uom_unit
25 In order to test the merge purchase order flow,I create a new record where "invoice_method" is From Order.
27 I create first purchase order for Nokia3110c.
29 !record {model: purchase.order, id: purchase_order_po_nokia1}:
30 company_id: base.main_company
31 date_order: !eval time.strftime('%Y-%m-%d')
33 location_id: stock.stock_location_stock
35 - date_planned: !eval time.strftime('%Y-%m-%d')
38 product_id: 'product_product_nokia3110c'
40 product_uom: product.product_uom_unit
42 partner_address_id: base.res_partner_address_7
43 partner_id: base.res_partner_4
44 pricelist_id: purchase.list0
46 Initially first purchase order is in the draft state.
48 !assert {model: purchase.order, id: purchase_order_po_nokia1}:
51 I create second purchase order for Nokia3110c with same supplier,have same stock location, same pricelist as First Purchase order of Nokia3110.
53 !record {model: purchase.order, id: purchase_order_po_nokia2}:
54 company_id: base.main_company
55 date_order: !eval time.strftime('%Y-%m-%d')
57 location_id: stock.stock_location_stock
59 - date_planned: !eval time.strftime('%Y-%m-%d')
62 product_id: 'product_product_nokia3110c'
64 product_uom: product.product_uom_unit
66 partner_address_id: base.res_partner_address_7
67 partner_id: base.res_partner_4
68 pricelist_id: purchase.list0
70 Initially second purchase order is in the draft state.
72 !assert {model: purchase.order, id: purchase_order_po_nokia2}:
75 I have merged first and second purchase order which are in draft state, belong to the same supplier,have same stock location, same pricelist.
77 !python {model: purchase.order.group}: |
78 ids = [ref("purchase_order_po_nokia1"),ref("purchase_order_po_nokia2")]
79 self.fields_view_get(cr, uid, context={'active_ids': ids})
80 self.merge_orders(cr, uid, [1], context={'active_ids': ids})