~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to purchase_followup/test/split_flow.yml

  • Committer: jf
  • Date: 2011-05-16 09:55:17 UTC
  • mfrom: (129.1.1 unifield-wm)
  • Revision ID: jf@tempo4-20110516095517-giuzv2mouka39jb8
UF-270 Advance return in a currency that is not the functional currency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
-
2
 
  In order to test the purchase order followup in a
3
 
  split move flow, we will create a purchase order with
4
 
  one line, confirm it and see the result in the followup
5
 
  tool. Confirm partially the move and see the changes in 
6
 
  the followup tool.
7
 
-
8
 
    I create supplier
9
 
-
10
 
  !record {model: res.partner, id: supplier_split_flow}:
11
 
    name: S1
12
 
    supplier: True
13
 
-
14
 
    I create the address for the supplier
15
 
-
16
 
  !record {model: res.partner.address, id: address_split_flow}:
17
 
    name: S1
18
 
    partner_id: supplier_split_flow
19
 
-
20
 
  I create a product category
21
 
-
22
 
  !record {model: product.category, id: prod_cat_split_flow}:
23
 
    name: Categ1
24
 
-
25
 
    I create the product
26
 
-
27
 
  !record {model: product.product, id: product_split_flow}:
28
 
    categ_id: prod_cat_split_flow
29
 
    cost_method: standard
30
 
    mes_type: fixed
31
 
    name: P1
32
 
    price_margin: 2.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: 75.00
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 a new Purchase order
49
 
-
50
 
  !record {model: purchase.order, id: po_split_flow}:
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
 
    partner_address_id: address_split_flow
56
 
    partner_id: supplier_split_flow
57
 
    pricelist_id: purchase.list0
58
 
-
59
 
  I create a line for the Purchase order
60
 
-
61
 
  !record {model: purchase.order.line, id: pol_split_flow}:
62
 
    product_uom: product.product_uom_unit
63
 
    product_id: product_split_flow
64
 
    order_id: po_split_flow
65
 
    price_unit: 1.30
66
 
    product_qty: 10
67
 
    name: P1
68
 
    date_planned: !eval time.strftime('%Y-%m-%d')
69
 
70
 
  I confirm the purchase order
71
 
-
72
 
  !python {model: purchase.order}: |
73
 
    import netsvc
74
 
    wf_service = netsvc.LocalService("workflow")
75
 
    wf_service.trg_validate(uid, 'purchase.order', ref('po_split_flow'), 'purchase_confirm', cr)
76
 
    wf_service.trg_validate(uid, 'purchase.order', ref('po_split_flow'), 'purchase_approve', cr)
77
 
-
78
 
  I launch the purchase followup wizard
79
 
-
80
 
  !python {model: ir.actions.server}: |
81
 
    context = {'active_id':  ref('po_split_flow'),
82
 
               'active_ids': [ref('po_split_flow')]}
83
 
    res = self.run(cr, uid, [ref('action_purchase_order_follow_up')], context)
84
 
    assert res != False, "Error on ir.actions.server launching"
85
 
-
86
 
  I check if the wizard is related to the purchase order and if the information are ok
87
 
-
88
 
  !python {model: purchase.order.followup}: |
89
 
    wiz_ids = self.search(cr, uid, [('order_id', '=', ref('po_split_flow'))])
90
 
    assert wiz_ids, "The created wizard is not linked to the Purchase Order"
91
 
    for wiz in self.browse(cr, uid, wiz_ids, context=context):
92
 
      assert len(wiz.line_ids) == 1, "Number of lines in the follow-up not corresponding to the number of lines in the purchase order"
93
 
      for line in wiz.line_ids:
94
 
        assert line.line_name == 1, "Line name is not equal to the name of the PO line"
95
 
        assert line.line_product_id.id == ref('product_split_flow'), "Product on the line isn't the product in the PO line"
96
 
        assert line.line_product_qty == 10.0, "The product qty of the line is different than the qty in the PO line"
97
 
        assert line.line_uom_id.id == ref('product.product_uom_unit'), "The UoM of the line is different than the UoM of the PO line"
98
 
        # TODO: 
99
 
        #assert line.line_confirmed_date == 1, ""
100
 
        assert line.line_shipped_rate == 0.00, "Shipped rate on the followup is different than the shipped rate of the PO"
101
 
        assert not line.move_product_id, "Product of the move is displayed"
102
 
        assert not line.move_product_qty, "Product of the move is displayed"
103
 
        assert not line.move_uom_id, "Product of the move is displayed"
104
 
        assert line.move_state == 'Available', 'State of the move is incorrect in the followup line'
105
 
    self.unlink(cr, uid, wiz_ids, context=context)
106
 
-
107
 
  Confirm partially the move (create a back order)
108
 
-
109
 
  !python {model: stock.picking }: |
110
 
   import time
111
 
   pick_ids = self.search(cr, uid, [('purchase_id', '=', ref('po_split_flow'))])
112
 
   pick=self.browse(cr,uid,pick_ids[0])
113
 
   move =pick.move_lines[0]
114
 
   partial_datas = {
115
 
          'partner_id':pick.address_id.partner_id.id,
116
 
           'address_id': pick.address_id.id,
117
 
           'delivery_date' : time.strftime('%Y-%m-%d')
118
 
            }
119
 
   partial_datas['move%s'%(move.id)]= {
120
 
          'product_id': move.product_id,
121
 
          'product_qty': 3,
122
 
          'product_uom': move.product_uom.id,
123
 
      }
124
 
   self.do_partial(cr, uid, [pick_ids[0]],partial_datas)
125
 
-
126
 
  I launch the purchase followup wizard
127
 
-
128
 
  !python {model: ir.actions.server}: |
129
 
    context = {'active_id':  ref('po_split_flow'),
130
 
               'active_ids': [ref('po_split_flow')]}
131
 
    res = self.run(cr, uid, [ref('action_purchase_order_follow_up')], context)
132
 
    assert res != False, "Error on ir.actions.server launching"
133
 
-
134
 
  I check if the wizard is related to the purchase order and if the information are ok
135
 
-
136
 
  !python {model: purchase.order.followup}: |
137
 
    wiz_ids = self.search(cr, uid, [('order_id', '=', ref('po_split_flow'))])
138
 
    assert wiz_ids, "The created wizard is not linked to the Purchase Order"
139
 
    for wiz in self.browse(cr, uid, wiz_ids):
140
 
      assert len(wiz.line_ids) == 2, "Number of lines in the follow-up not corresponding to the number of lines in the purchase order (2 :: %s)" % len(wiz.line_ids)
141
 
      for line in wiz.line_ids:
142
 
        if line.move_id.product_qty == 7.00:
143
 
          assert line.line_name == 1, "Line name is not equal to the name of the PO line"
144
 
          assert line.line_product_id.id == ref('product_split_flow'), "Product on the line isn't the product in the PO line"
145
 
          assert line.line_product_qty == 10.0, "The product qty of the line is different than the qty in the PO line"
146
 
          assert line.line_uom_id.id == ref('product.product_uom_unit'), "The UoM of the line is different than the UoM of the PO line"
147
 
          # TODO: 
148
 
          #assert line.line_confirmed_date == 1, ""
149
 
          assert line.line_shipped_rate == 30.00, "Shipped rate on the followup is different than the shipped rate of the PO"
150
 
          assert not line.move_product_id, "Product of the move is displayed"
151
 
          assert line.move_product_qty == '7.00', "Product qty is not equal to 7.00"
152
 
          assert not line.move_uom_id, "Product of the move is displayed"
153
 
          assert line.move_state == 'Available', 'State of the move is incorrect in the followup line'
154
 
        else:
155
 
          assert line.line_name == 1, "Line name is not equal to the name of the PO line"
156
 
          assert not line.line_product_id.id, "Product of PO line is displayed in follow-up"
157
 
          assert not line.line_product_qty, "The product qty of the line is different than the qty in the PO line"
158
 
          assert not line.line_uom_id.id, "The UoM of the line is different than the UoM of the PO line"
159
 
          # TODO: 
160
 
          #assert line.line_confirmed_date == 1, ""
161
 
          assert line.line_shipped_rate == 'no-progressbar', "Shipped rate is displayed"
162
 
          assert not line.move_product_id, "Product of the move is displayed"
163
 
          assert line.move_product_qty == '3.00', "Product qty is not equal to 3.00"
164
 
          assert not line.move_uom_id, "Product of the move is displayed"
165
 
          assert line.move_state == 'Closed', 'State of the move is incorrect in the followup line (Closed :: %s)' % line.move_state
166
 
    self.unlink(cr, uid, wiz_ids, context=context)