- In order to test to merge two purchase order,I start by creating a new product 'Nokia3110c' - !record {model: product.product, id: product_product_nokia3110c}: categ_id: 'product.product_category_3' cost_method: standard mes_type: fixed name: NOKIA 3110c price_margin: 1.0 procure_method: make_to_order property_stock_inventory: stock.location_inventory property_stock_procurement: stock.location_procurement property_stock_production: stock.location_production seller_delay: '1' standard_price: 5000.0 supply_method: buy type: product uom_id: product.product_uom_unit uom_po_id: product.product_uom_unit volume: 0.0 warranty: 0.0 weight: 0.0 weight_net: 0.0 - In order to test the merge purchase order flow,I create a new record where "invoice_method" is From Order. - I create first purchase order for Nokia3110c. - !record {model: purchase.order, id: purchase_order_po_nokia1}: company_id: base.main_company date_order: !eval time.strftime('%Y-%m-%d') invoice_method: order location_id: stock.stock_location_stock order_line: - date_planned: !eval time.strftime('%Y-%m-%d') name: NOKIA 3110c price_unit: 100.0 product_id: 'product_product_nokia3110c' product_qty: 10.0 product_uom: product.product_uom_unit state: draft partner_address_id: base.res_partner_address_7 partner_id: base.res_partner_4 pricelist_id: purchase.list0 - Initially first purchase order is in the draft state. - !assert {model: purchase.order, id: purchase_order_po_nokia1}: - state == 'draft' - I create second purchase order for Nokia3110c with same supplier,have same stock location, same pricelist as First Purchase order of Nokia3110. - !record {model: purchase.order, id: purchase_order_po_nokia2}: company_id: base.main_company date_order: !eval time.strftime('%Y-%m-%d') invoice_method: order location_id: stock.stock_location_stock order_line: - date_planned: !eval time.strftime('%Y-%m-%d') name: NOKIA 3110c price_unit: 100.0 product_id: 'product_product_nokia3110c' product_qty: 20.0 product_uom: product.product_uom_unit state: draft partner_address_id: base.res_partner_address_7 partner_id: base.res_partner_4 pricelist_id: purchase.list0 - Initially second purchase order is in the draft state. - !assert {model: purchase.order, id: purchase_order_po_nokia2}: - state == 'draft' - I have merged first and second purchase order which are in draft state, belong to the same supplier,have same stock location, same pricelist. - !python {model: purchase.order.group}: | ids = [ref("purchase_order_po_nokia1"),ref("purchase_order_po_nokia2")] self.fields_view_get(cr, uid, context={'active_ids': ids}) self.merge_orders(cr, uid, [1], context={'active_ids': ids})