[IMP]: use datetime.timedelta instead of relativedelta
[odoo/odoo.git] / addons / purchase / test / purchase_order_cancel_draft.yml
1 -
2   In order to test to Cancel purchase order from Approved State,I start by creating a new product 'Pen Drive1'
3 -
4  !record {model: product.product, id: product_product_pendrive1}:
5     categ_id: 'product.product_category_3'
6     cost_method: standard
7     mes_type: fixed
8     name: Pen Drive
9     price_margin: 1.0
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
14     seller_delay: '1'
15     standard_price: 500.0
16     supply_method: buy
17     type: product
18     uom_id: product.product_uom_unit
19     uom_po_id: product.product_uom_unit
20     volume: 0.0
21     warranty: 0.0
22     weight: 0.0
23     weight_net: 0.0
24 -
25   Create second  new product 'Pen Drive2'
26 -
27  !record {model: product.product, id: product_product_pendrive2}:
28     categ_id: 'product.product_category_3'
29     cost_method: standard
30     mes_type: fixed
31     name: Pen Drive 2
32     price_margin: 1.0
33     procure_method: make_to_order
34     property_stock_inventory: stock.location_inventory
35     property_stock_procurement: stock.location_procurement
36     property_stock_production: stock.location_production
37     seller_delay: '1'
38     standard_price: 500.0
39     supply_method: buy
40     type: product
41     uom_id: product.product_uom_unit
42     uom_po_id: product.product_uom_unit
43     volume: 0.0
44     warranty: 0.0
45     weight: 0.0
46     weight_net: 0.0
47 -
48   I create first purchase order for Pen Drive1 where "invoice_method" is From Order.
49 -
50   !record {model: purchase.order, id: purchase_order_pendrive1}:
51     company_id: base.main_company
52     date_order: !eval time.strftime('%Y-%m-%d')
53     invoice_method: order
54     location_id: stock.stock_location_stock
55     order_line:
56       - date_planned: !eval time.strftime('%Y-%m-%d')
57         name: Pen Drive
58         price_unit: 100.0
59         product_id: 'product_product_pendrive1'
60         product_qty: 10.0
61         product_uom: product.product_uom_unit
62         state: draft
63     partner_address_id: base.res_partner_address_7
64     partner_id: base.res_partner_4
65     pricelist_id: purchase.list0
66 -
67   Initially  purchase order is in the draft state.
68 -
69   !assert {model: purchase.order, id: purchase_order_pendrive1}:
70     - state == 'draft'
71 -
72   I confirm the purchase order for Pen Drive1.
73 -
74   !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_pendrive1}
75 -
76   I check that the order which was initially in the draft state has transmit to confirm state.
77 -
78   !assert {model: purchase.order, id: purchase_order_pendrive1}:
79     - state == 'approved'
80 -
81   I have to first cancel Picking of Approved Purchase order .
82 -
83   !python {model: stock.picking}: |
84     from tools.translate import _
85     search_ids=self.search(cr, uid, [('purchase_id', '=', ref("purchase_order_pendrive1"))])
86     self.action_cancel(cr, uid, search_ids)
87 -
88   Now I have to cancel confirm  purchase order for Pen Drive1.
89 -
90   !python {model: purchase.order}: |
91     self.action_cancel(cr, uid, [ref("purchase_order_pendrive1")])
92 -
93   I check that the order which was in approved state has transmit to cancel state.
94 -
95   !assert {model: purchase.order, id: purchase_order_pendrive1}:
96     - state == 'cancel'
97 -
98   Now again set purchase order for Pen Drive1 to draft state.
99 -
100   !python {model: purchase.order}: |
101     self.action_cancel_draft(cr, uid, [ref("purchase_order_pendrive1")])   
102 -
103   I check that the First purchase order is in draft state.
104 -
105   !assert {model: purchase.order, id: purchase_order_pendrive1}:
106     - state == 'draft'
107 -
108   I test for Copy and Delete Perchase order in Draft state.
109 -
110   !python {model: purchase.order}: |
111     from tools.translate import _
112     copy_id = self.copy(cr, uid, ref("purchase_order_pendrive1"))   
113     self.unlink(cr, uid, [copy_id])   
114 -
115   I create Second purchase order for Pen Drive1 where "invoice_method" is From Order.
116 -
117   !record {model: purchase.order, id: purchase_order_pendrive2}:
118     company_id: base.main_company
119     date_order: !eval time.strftime('%Y-%m-%d')
120     invoice_method: order
121     location_id: stock.stock_location_stock
122     order_line:
123       - date_planned: !eval time.strftime('%Y-%m-%d')
124         name: Pen Drive
125         price_unit: 100.0
126         product_id: 'product_product_pendrive1'
127         product_qty: 10.0
128         product_uom: product.product_uom_unit
129         state: draft
130     partner_address_id: base.res_partner_address_7
131     partner_id: base.res_partner_4
132     pricelist_id: purchase.list0
133 -
134   Initially  Second purchase order is in the draft state.
135 -
136   !assert {model: purchase.order, id: purchase_order_pendrive2}:
137     - state == 'draft'
138 -
139   I have merged first and second purchase order which are in draft state, belong to the same supplier,have same stock location, same pricelist.
140 -
141   !python {model: purchase.order.group}: |
142     ids = [ref("purchase_order_pendrive1"),ref("purchase_order_pendrive2")]
143     self.fields_view_get(cr, uid, context={'active_ids': ids})  
144     self.merge_orders(cr, uid, [1], context={'active_ids': ids})
145
146