~unifield-team/unifield-addons/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?xml version="1.0"?>
<openerp>
    <data>
        <!-- Resource: purchase.order -->
        <record model="purchase.order" id="test_purchase_1">
            <field name="name">Test purchase</field>
            <field name="dest_address_id" search="[]" model="res.partner.address"/>
            <field name="pricelist_id" ref="list0"/>
            <field name="partner_id" search="[]" model="res.partner"/>
            <field name="partner_address_id" search="[]" model="res.partner.address"/>
            <field name="location_id" ref="stock.stock_location_stock"/>
            <field name="invoice_method">order</field>
        </record>
        <record model="purchase.order.line" id="test_purchase_1_line_1">
            <field name="order_id" ref="test_purchase_1"/>
            <field name="name">[PC1] Basic PC</field>
            <field name="date_planned" eval="time.strftime('%Y-%m-%d', time.localtime(time.time() + 2 * 86400))" />
            <field name="product_id" ref="product.product_product_pc1"/>
            <field name="product_uom" ref="product.product_uom_unit"/>
            <field name="price_unit">450</field>
            <field name="product_qty">2</field>
        </record>
        <record model="purchase.order.line" id="test_purchase_1_line_3">
            <field name="order_id" ref="test_purchase_1"/>
            <field name="name">[MB1] Mainboard ASUStek A7N8X</field>
            <field name="date_planned" eval="time.strftime('%Y-%m-%d', time.localtime(time.time() + 2 * 86400))" />
            <field name="product_id" ref="product.product_product_mb1"/>
            <field name="product_uom" ref="product.product_uom_unit"/>
            <field name="price_unit">88</field>
            <field name="product_qty">3</field>
        </record>

        <assert model="purchase.order" id="test_purchase_1" string="The amount of Test purchase is correctly computed">
            <test expr="sum([l.price_subtotal for l in order_line]) == amount_untaxed" />
        </assert>

        <workflow model="purchase.order" ref="test_purchase_1" action="purchase_confirm" />

        <assert model="purchase.order" id="test_purchase_1" string="Test purchase is now in progress">
            <test expr="state">approved</test>
        </assert>

        <!-- Treat generated invoice -->
        <assert model="purchase.order" id="test_purchase_1" string="Test purchase has now a corresponding invoice" severity="fatal">
            <test expr="bool(invoice_ids)" />
        </assert>

        <assert model="purchase.order" id="test_purchase_1" string="Test purchase's invoice has the same amount and is currently a draft">
            <test expr="invoice_ids[0].state">draft</test>
        </assert>

        <!-- Disallow analytic distribution verification -->
        <function model="account.invoice" name="write">
            <value model="purchase.order" eval="[obj(ref('test_purchase_1')).invoice_ids[0].id]" />
            <value eval="{'from_yml_test': True, 'document_date': time.strftime('%Y-%m-%d')}"/>
        </function>

        <workflow model="account.invoice" action="invoice_open">
            <value model="purchase.order" eval="obj(ref('test_purchase_1')).invoice_ids[0].id" />
        </workflow>

        <function model="account.invoice" name="pay_and_reconcile">
            <value model="purchase.order" eval="[obj(ref('test_purchase_1')).invoice_ids[0].id]" />
            <value eval="1164" />
            <value eval="ref('account.cash')"/>
            <value eval="ref('account.period_' + str(int(time.strftime('%m'))))" />
            <value eval="ref('account.bank_journal')" />
            <value eval="ref('account.cash')"/>
            <value eval="ref('account.period_' + str(int(time.strftime('%m'))))" />
            <value eval="ref('account.bank_journal')" />
        </function>

        <assert model="purchase.order" id="test_purchase_1" string="Test purchase's invoice is now paid" severity="error">
            <test expr="invoice_ids[0].state">paid</test>
        </assert>

        <!-- Treat generated picking -->
        <assert model="purchase.order" id="test_purchase_1" string="Test purchase has now a corresponding picking" severity="fatal">
            <test expr="len(picking_ids) == 1" />
        </assert>

        <assert model="purchase.order" id="test_purchase_1" string="Test purchase's picking will be sent to the good address" severity="error">
            <test expr="picking_ids[0].address_id == partner_address_id" />
        </assert>

        <!-- Do the same as in wizard_partial_picking lines 143-144 -->
        <function model="stock.picking" name="action_move">
            <value model="purchase.order" eval="[obj(ref('test_purchase_1')).picking_ids[0].id]" />
        </function>

        <workflow model="stock.picking" action="button_done">
            <value model="purchase.order" eval="obj(ref('test_purchase_1')).picking_ids[0].id" />
        </workflow>

        <assert model="purchase.order" id="test_purchase_1" string="Test purchase's picking is now done" severity="error">
            <test expr="picking_ids[0].state">done</test>
        </assert>

        <assert model="purchase.order" id="test_purchase_1" string="Test purchase is now completed" severity="fatal">
            <test expr="state">done</test>
        </assert>
    </data>
</openerp>