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

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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
    
        <!-- Here we just add a boolean in the page 'Delivery and invoicing' of the purchase order form notebook -->
        <record id="purchase_cross_docking_form_view2" model="ir.ui.view">
            <field name="name">purchase.cross.docking.form.view2</field>
            <field name="model">purchase.order</field>
            <field name="type">form</field>
            <field name="priority">16</field>
            <field name="inherit_id" ref="purchase_override.purchase_order_type_form_view" />
            <field name="arch" type="xml">
                <data>
                    <xpath expr="/form/group/field[@name='categ']" position="replace" >
                        <field name="categ" on_change="onchange_categ(categ, warehouse_id, cross_docking_ok, location_id)" />
                    </xpath>
                </data>
            </field>
        </record>

        <record id="purchase_cross_docking_form_view" model="ir.ui.view">
            <field name="name">purchase.cross.docking.form.view</field>
            <field name="model">purchase.order</field>
            <field name="type">form</field>
            <field name="priority">16</field>
            <field name="inherit_id" ref="purchase.purchase_order_form" />
            <field name="arch" type="xml">
                <data>
                    <xpath expr="/form/notebook/page[@string='Delivery &amp; Invoicing']/group/field[@name='location_id']" position="before" >
                        <field name="cross_docking_ok"
                            attrs="{'readonly':['|', '|', '|', ('unallocation_ok', '=', True), ('order_type', '=', 'direct'), ('allocation_setup', '=', 'unallocated'), ('state', '!=', 'draft')]}"
                            on_change="onchange_cross_docking_ok(cross_docking_ok, warehouse_id, categ)"
                        />
                    </xpath>
                    <field name="location_id" position= "replace">
                        <field name="location_id" 
                        domain="[('usage', '=', 'internal')]"
                        attrs="{'readonly':['|', ('state', 'in', ['rfq_updated', 'done', 'cancel', 'confirmed', 'approved', 'except_picking', 'except_invoice', 'confirmed_wait']), '|',('cross_docking_ok','=', True), ('categ', 'in', ['service', 'transport'])], 'invisible': [('order_type', '=', 'direct')]}"
                        on_change="onchange_location_id(location_id,categ)"/>
                    </field>
                </data>
            </field>
        </record>
        
        <!-- Here we add 'purchase_id' in the context for defining a 'default_get'
         when we want to create a new stock move directly in the delivery form -->
        <record id="stock_picking_cross_docking_form_view" model="ir.ui.view">
            <field name="name">stock.picking.in.form.cross.docking</field>
            <field name="model">stock.picking</field>
            <field name="type">form</field>
            <field name="priority">16</field>
            <field name="inherit_id" ref="stock.view_picking_in_form" />
            <field name="arch" type="xml">
                <data>
                    <xpath expr="/form/notebook/page[@string='General Information']/field[@name='move_lines']" position="attributes" >
                        <attribute name="default_get">{'purchase_id': purchase_id, 'reason_type_id': reason_type_id, 'warehouse_id': warehouse_id, 'address_in_id': address_id} </attribute>
                    </xpath>
                </data>
            </field>
        </record>
        
        <!-- Delivery Orders : we add 2 buttons and play with attrs to change the source location-->
        <record id="view_picking_out_cross_docking_form" model="ir.ui.view">
            <field name="name">view.picking.out.cross.docking</field>
            <field name="model">stock.picking</field>
            <field name="type">form</field>
            <field name="priority">16</field>
            <field name="inherit_id" ref="stock.view_picking_out_form" />
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//tree[@string='Stock Moves']//field[@name='location_id']" position="after" >
                        <field name="product_type" invisible="1" />
                        <button name="button_cross_docking" string="Cross docking" type="object" icon="gtk-select-color"
                        attrs="{'invisible':['|', '|', '|', ('product_type', 'in', ['consu', 'service_recep']), ('allocation_setup', '=', 'unallocated'),('move_cross_docking_ok','=', True), ('state', 'in', ('done','cancel'))]}" />
                        <button name="button_stock" string="Stock" type="object" icon="gtk-media-play"
                        attrs="{'invisible':['|', '|', ('product_type', 'in', ['consu', 'service_recep']), ('move_cross_docking_ok','=', False), ('state', 'in', ('done','cancel'))]}" />
                        <field name="move_cross_docking_ok" invisible='1'/>
                        <field name="allocation_setup" invisible="1" />
                    </xpath>
                    <xpath expr="/form/notebook/page[@string='Products']/group/field[@name='state']" position="after" >
                        <button name="button_cross_docking_all" string="Cross docking" type="object" icon="gtk-select-color"
                        attrs="{'invisible':['|', '|', ('allocation_setup', '=', 'unallocated'), ('cross_docking_ok','=', True), ('state', 'in', ('done','cancel'))]}" />
                        <button name="button_stock_all" string="Stock" type="object" icon="gtk-media-play"
                        attrs="{'invisible':['|', ('cross_docking_ok','=', False), ('state', 'in', ('done','cancel'))]}" />
                        <field name="allocation_setup" invisible="1" />
                    </xpath>
                </data>
            </field>
        </record>
        
        <!-- Picking Tickets (same feature as delivery order): we add 2 buttons and play with attrs to change the source location -->
        <record id="view_picking_ticket_cross_docking_form" model="ir.ui.view">
            <field name="name">picking.ticket.cross.docking</field>
            <field name="model">stock.picking</field>
            <field name="type">form</field>
            <field name="priority">16</field>
            <field name="inherit_id" ref="msf_outgoing.view_picking_ticket_form" />
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//tree[@string='Stock Moves']//field[@name='location_id']" position="after" >
                        <field name="product_type" invisible="1" />
                        <button name="button_cross_docking" string="Cross docking" type="object" icon="gtk-select-color"  
                        attrs="{'invisible':['|', '|', '|', ('product_type', 'in', ['consu', 'service_recep']), ('allocation_setup', '=', 'unallocated'),('move_cross_docking_ok','=', True), ('state', 'in', ('done','cancel'))]}" />
                        <button name="button_stock" string="Stock" type="object" icon="gtk-media-play"  
                        attrs="{'invisible':['|', '|', ('product_type', 'in', ['consu', 'service_recep']), ('move_cross_docking_ok','=', False), ('state', 'in', ('done','cancel'))]}" />
                        <field name="move_cross_docking_ok" invisible='1'/>
                        <field name="allocation_setup" invisible="1" />
                    </xpath>
                    <xpath expr="/form/notebook/page[@string='Products']/group/field[@name='state']" position="after" >
                        <button name="button_cross_docking_all" string="Cross docking" type="object" icon="gtk-select-color"  
                        attrs="{'invisible':['|', '|', ('allocation_setup', '=', 'unallocated'),('cross_docking_ok','=', True), ('state', 'in', ('done','cancel'))]}" />
                        <button name="button_stock_all" string="Stock" type="object" icon="gtk-media-play"  
                        attrs="{'invisible':['|', ('cross_docking_ok','=', False), ('state', 'in', ('done','cancel'))]}" />
                        <field name="cross_docking_ok" invisible='1'/>
                        <field name="allocation_setup" invisible="1" />
                    </xpath>
                </data>
            </field>
        </record>
        
        <!-- Pre-Packing Lists (same feature as delivery order): we add 2 buttons and play with attrs to change the source location -->
        <record id="view_ppl_cross_docking_form" model="ir.ui.view">
            <field name="name">ppl.cross.docking</field>
            <field name="model">stock.picking</field>
            <field name="type">form</field>
            <field name="priority">16</field>
            <field name="inherit_id" ref="msf_outgoing.view_ppl_form" />
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//tree[@string='Stock Moves']//field[@name='location_id']" position="after" >
                        <button name="button_cross_docking" string="Cross docking" type="object" icon="gtk-select-color"  
                        attrs="{'invisible':['|', '|', '|', ('allocation_setup', '=', 'unallocated'), ('move_cross_docking_ok','=', True), ('state', 'in', ('done','cancel')), ('subtype', '=', 'ppl')]}" />
                        <button name="button_stock" string="Stock" type="object" icon="gtk-media-play"  
                        attrs="{'invisible':['|', ('move_cross_docking_ok','=', False),'|', ('state', 'in', ('done','cancel')), ('subtype', '=', 'ppl')]}" />
                        <field name="move_cross_docking_ok" invisible='1'/>
                        <field name="allocation_setup" invisible="1" />
                    </xpath>
                    <xpath expr="/form/notebook/page[@string='Products']/group/field[@name='state']" position="after" >
                        <button name="button_cross_docking_all" string="Cross docking" type="object" icon="gtk-select-color"  
                        attrs="{'invisible':['|', '|', '|', ('cross_docking_ok','=', True), ('allocation_setup', '=', 'unallocated'), ('state', 'in', ('done','cancel')), ('subtype', '=', 'ppl')]}" />
                        <button name="button_stock_all" string="Stock" type="object" icon="gtk-media-play"  
                        attrs="{'invisible':['|', '|', ('cross_docking_ok','=', False), ('state', 'in', ('done','cancel')), ('subtype', '=', 'ppl')]}" />
                        <field name="cross_docking_ok" invisible='1' />
                        <field name="allocation_setup" invisible="1" />
                    </xpath>
                </data>
            </field>
        </record>
         
        <!-- We update the form view of stock.location to display the boolean "cross_docking" for cross_docking location-->
        <record id="view_location_form" model="ir.ui.view">
            <field name="name">stock.location.form</field>
            <field name="model">stock.location</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="stock.view_location_form" />
            <field name="arch" type="xml">
                <data>
                    <field name="scrap_location" position="after">
                        <field name="cross_docking_location_ok" />
                    </field>
                </data>
            </field>
        </record>
         
    </data>
</openerp>