diff --git a/addons/sale/sale_demo.xml b/addons/sale/sale_demo.xml index 3828c17048c..c6b5dd5fa6d 100644 --- a/addons/sale/sale_demo.xml +++ b/addons/sale/sale_demo.xml @@ -37,7 +37,7 @@ make_to_stock - + [PC3] Medium PC @@ -67,6 +67,7 @@ + picking @@ -100,6 +101,7 @@ + prepaid diff --git a/addons/sale/test/process/postpaid_order_policy.yml b/addons/sale/test/process/postpaid_order_policy.yml index e7e5e304f77..35c5d7122f9 100644 --- a/addons/sale/test/process/postpaid_order_policy.yml +++ b/addons/sale/test/process/postpaid_order_policy.yml @@ -1,34 +1,51 @@ - - In order to test the Sale order flow, I compute the total of the listed products. + In order to test the Sale order flow, I compute the total of the listed products for Quotation1. "New server config + material" product price is 123.20 and ordered 1 'PCE' "Basic PC" product price is 450.50 and ordered 3 'PCE' "Medium PC" product price is 900 and ordered 5 'PCE' "Mainboard ASUStek A7N8X" product price is 88 and ordered 5 'PCE' So, Total should be [(123.20*1)+(450.50*3)+(900*5)+(88*5)] = 6414.70 - - I check the total untaxed amount of the Quotation is correctly computed + I check the total untaxed amount of the Quotation1 is correctly computed - !assert {model: sale.order, id: order, string: The amount of the Quotation is not correctly computed}: - sum([l.price_subtotal for l in order_line]) == amount_untaxed - - I confirm the Quotation. + I confirm the Quotation1. - !workflow {model: sale.order, action: order_confirm, ref: order} - - I check the "In Progress" status after confirmed Quotation. + I confirm the Quotation2. - - !assert {model: sale.order, id: order}: - - state == 'progress' + !workflow {model: sale.order, action: order_confirm, ref: order2} - - I check that Packing details after confirmed Quotation. + I confirm the Quotation3. +- + !workflow {model: sale.order, action: order_confirm, ref: order3} +- + I confirm the Quotation4. +- + !workflow {model: sale.order, action: order_confirm, ref: order4} +- + After confirmed Quotation, I check the Packing as well as Invoice created in related sale orders . +- + !python {model: sale.order}: | + sale_order1 = self.browse(cr, uid, ref("order")) + sale_order2 = self.browse(cr, uid, ref("order2")) + sale_order3 = self.browse(cr, uid, ref("order3")) + sale_order4 = self.browse(cr, uid, ref("order4")) + assert sale_order1.picking_ids, "Picking not created for sale order1" + assert sale_order4.picking_ids, "Picking not created for sale order4" + assert sale_order2.picking_ids, "Picking not created for sale order2" + assert sale_order3.invoice_ids, "Invoice not created for sale order3" +- + I check that Packing details after confirmed Quotation1. - !python {model: sale.order}: | from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT sale_order = self.browse(cr, uid, ref("order")) - assert len(sale_order.picking_ids) >= 1, "Packing should be one" - for picking in sale_order.picking_ids: assert picking.state == "auto" or "confirmed", "Packing state should be in waitting state" assert picking.origin == sale_order.name,"Packing Name is not correspond with sale order" @@ -39,22 +56,21 @@ assert picking.note == sale_order.note,"Notes is not correspond with sale order" assert picking.invoice_state == (sale_order.order_policy=='picking' and '2binvoiced') or 'none',"Invoice state is not correspond with sale order" assert picking.company_id.id == sale_order.company_id.id,"Company is not correspond with sale order" - for index in range(0,len(picking.move_lines)): - location_id = sale_order.shop_id.warehouse_id.lot_stock_id.id - output_id = sale_order.shop_id.warehouse_id.lot_output_id.id - date_planned = datetime.strptime(sale_order.date_order, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=sale_order.order_line[index].delay or 0.0) - date_planned = (date_planned - timedelta(days=sale_order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT) - assert picking.move_lines[index].name == sale_order.order_line[index].name[:64],"Name is not correspond" - assert picking.move_lines[index].product_id.id == sale_order.order_line[index].product_id.id,"Product is not correspond" - assert picking.move_lines[index].date == date_planned,"Plane date is not correspond" - assert picking.move_lines[index].date_expected == date_planned,"Expected date is not correspond" - assert picking.move_lines[index].product_qty == sale_order.order_line[index].product_uom_qty,"Product Quantity is not correspond" - assert picking.move_lines[index].product_uom.id == sale_order.order_line[index].product_uom.id,"Product UOM is not correspond" - assert picking.move_lines[index].product_uos_qty == sale_order.order_line[index].product_uos_qty,"Product UOS Quantity is not correspond" - assert picking.move_lines[index].product_uos == (sale_order.order_line[index].product_uos and sale_order.order_line[index].product_uos.id) or sale_order.order_line[index].product_uom.id,"Product UOS is not correspond" - assert picking.move_lines[index].product_packaging.id == sale_order.order_line[index].product_packaging.id,"Product packaging is not correspond" - assert picking.move_lines[index].address_id.id == sale_order.order_line[index].address_allotment_id.id or sale_order.partner_shipping_id.id,"Address is not correspond" - assert picking.move_lines[index].location_id.id == location_id,"Source Location is not correspond" - assert picking.move_lines[index].note == sale_order.order_line[index].notes,"Notes is not correspond" - assert picking.move_lines[index].company_id.id == sale_order.company_id.id,"Company is not correspond" - assert picking.move_lines[index].price_unit == sale_order.order_line[index].product_id.standard_price or 0.0,"Price Unit is not correspond" + + location_id = sale_order.shop_id.warehouse_id.lot_stock_id.id + for move in picking.move_lines: + for order in sale_order.order_line: + if move.name == order.name: + assert move.name == order.name[:64],"Name is not correspond" + assert move.product_id.id == order.product_id.id,"Product is not correspond" + assert move.product_qty == order.product_uom_qty,"Product Quantity is not correspond" + assert move.product_uom.id == order.product_uom.id,"Product UOM is not correspond" + assert move.product_uos_qty == order.product_uos_qty,"Product UOS Quantity is not correspond" + assert move.product_uos == (order.product_uos and order.product_uos.id) or order.product_uom.id,"Product UOS is not correspond" + assert move.product_packaging.id == order.product_packaging.id,"Product packaging is not correspond" + assert move.address_id.id == order.address_allotment_id.id or sale_order.partner_shipping_id.id,"Address is not correspond" + assert move.location_id.id == location_id,"Source Location is not correspond" + assert move.note == order.notes,"Notes is not correspond" + assert move.company_id.id == sale_order.company_id.id,"Company is not correspond" + assert move.price_unit == order.product_id.standard_price or 0.0,"Price Unit is not correspond" +