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

« back to all changes in this revision

Viewing changes to analytic_distribution_supply/test/commitment.yml

  • Committer: Quentin THEURET
  • Date: 2016-03-04 12:15:00 UTC
  • Revision ID: qt@tempo-consulting.fr-20160304121500-u2ay8zrf83ih9fu3
US-826 [IMP] Change the way to check if products is not consistent on add multiple line wizard

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-
 
2
  I create a regular purchase order
 
3
-
 
4
  !record {model: purchase.order, id: purchase_order_po0}:
 
5
    amount_tax: 0.0
 
6
    amount_total: 1.0
 
7
    amount_untaxed: 1.0
 
8
    company_id: base.main_company
 
9
    date_order: !eval time.strftime('%Y-%m-%d')
 
10
    invoice_method: picking
 
11
    location_id: stock.stock_location_stock
 
12
    minimum_planned_date: !eval time.strftime('%Y-%m-%d')
 
13
    partner_address_id: res_partner_address_0
 
14
    partner_id: res_partner_africom0
 
15
    pricelist_id: purchase.list0
 
16
    from_yml_test: False
 
17
    delivery_confirmed_date: !eval time.strftime('%Y-%m-%d')
 
18
    analytic_distribution_id: global_distrib_1
 
19
-
 
20
  Then I add an order line to this purchase
 
21
-
 
22
  !record {model: purchase.order.line, id: purchase_order_line_camembert0}:
 
23
    company_id: base.main_company
 
24
    date_planned: !eval time.strftime('%Y-%m-%d')
 
25
    order_id: purchase_order_po0
 
26
    partner_id: res_partner_africom0
 
27
    price_unit: 100
 
28
    product_id: product_product_camembert0
 
29
    product_qty: 1.0
 
30
    product_uom: product.product_uom_unit
 
31
    state: draft
 
32
    analytic_distribution_id: global_distrib_1
 
33
-
 
34
  We confirm the purchase
 
35
-
 
36
  !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po0}
 
37
-
 
38
  We validate the purchase
 
39
-
 
40
  !workflow {model: purchase.order, action: purchase_approve, ref: purchase_order_po0}
 
41
-
 
42
  We check that a commitment have been created for this PO 0. Then check commitment <-> PO link.
 
43
-
 
44
  !python {model: account.commitment}: |
 
45
    search_ids = self.search(cr, uid, [('purchase_id', '=', ref("purchase_order_po0"))])
 
46
    assert search_ids != False, "No commitment found"
 
47
    purchase = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_po0"))
 
48
    for id in search_ids:
 
49
        assert id in [x.id for x in purchase.commitment_ids], "No link between commitments and PO"
 
50
-
 
51
  I create a PO with an Intermission partner.
 
52
-
 
53
  !record {model: purchase.order, id: purchase_order_po1}:
 
54
    amount_tax: 0.0
 
55
    amount_total: 1.0
 
56
    amount_untaxed: 1.0
 
57
    company_id: base.main_company
 
58
    date_order: !eval time.strftime('%Y-%m-%d')
 
59
    invoice_method: picking
 
60
    location_id: stock.stock_location_stock
 
61
    minimum_planned_date: !eval time.strftime('%Y-%m-%d')
 
62
    partner_address_id: res_partner_address_42
 
63
    partner_id: res_partner_mission_42
 
64
    pricelist_id: purchase.list0
 
65
    from_yml_test: False
 
66
    delivery_confirmed_date: !eval time.strftime('%Y-%m-%d')
 
67
    analytic_distribution_id: global_distrib_1
 
68
-
 
69
  Then I add an order line to this purchase
 
70
-
 
71
  !record {model: purchase.order.line, id: purchase_order_line_book_0}:
 
72
    company_id: base.main_company
 
73
    date_planned: !eval time.strftime('%Y-%m-%d')
 
74
    order_id: purchase_order_po1
 
75
    partner_id: res_partner_africom0
 
76
    price_unit: 100
 
77
    product_id: product_product_book0
 
78
    product_qty: 1.0
 
79
    product_uom: product.product_uom_unit
 
80
    state: draft
 
81
    analytic_distribution_id: global_distrib_1
 
82
-
 
83
  We confirm the purchase
 
84
-
 
85
  !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po1}
 
86
-
 
87
  We validate the purchase
 
88
-
 
89
  !workflow {model: purchase.order, action: purchase_approve, ref: purchase_order_po1}
 
90
-
 
91
  We check that NO commitments have been created for this PO 1. Then check commitment <-> PO link.
 
92
-
 
93
  !python {model: account.commitment}: |
 
94
    search_ids = self.search(cr, uid, [('purchase_id', '=', ref("purchase_order_po1"))])
 
95
    assert search_ids == [], "Commitment found. This should not!"
 
96
    purchase = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_po1"))
 
97
    commitment_ids = [x.id for x in purchase.commitment_ids]
 
98
    assert not commitment_ids, "This PO shouln't have ANY commitment!"