~openerp-community/openerp-product-variant/fix-pep8-and-relative-import

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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<?xml version="1.0" ?>
<openerp>
    <data>

<!--
  "Product variant multi" module for OpenERP
  The licence is in the file __openerp__.py
  @author Alexis de Lattre <alexis.delattre@akretion.com>
  @author Sebastien Beau <sebastien.beau@akretion.com>
-->


        <record id="product_variant" model="ir.actions.act_window">
            <field name="name">Product Variants</field>
            <field name="res_model">product.product</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>

        <record id="product_template" model="ir.actions.act_window">
            <field name="name">Product Templates</field>
            <field name="res_model">product.template</field>
            <field name="view_type">form</field>
            <field name="domain">[('is_multi_variants','=',True)]</field>
            <field name="view_mode">tree,form</field>
        </record>

        <menuitem action="product_template" id="menu_template" parent="stock.menu_stock_product" />

        <menuitem action="product_variant" id="menu_variant" parent="stock.menu_stock_product" />

        <menuitem name="Variant dimensions" id="menu_variant_dimension" parent="stock.menu_product_in_config_stock" />

        <!-- Views from Dimension option -->
        <record id="product_variant_multi_dimension_option_tree" model="ir.ui.view">
            <field name="name">product.variant.multi.dimension.option.tree</field>
            <field name="model">product.variant.dimension.option</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Dimension Options">
                    <field name="dimension_id" invisible="not context.get('dimension_value_main_view', False)" />
                    <field name="name" />
                    <field name="sequence" />
                    <field name="code" />
                </tree>
            </field>
        </record>

        <record id="product_variant_multi_dimension_option_form" model="ir.ui.view">
            <field name="name">product.variant.multi.dimension.option.form</field>
            <field name="model">product.variant.dimension.option</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Dimension Options">
                    <field name="dimension_id" select="1" invisible="not context.get('dimension_option_main_view', False)" />
                    <newline />
                    <field name="sequence" />
                    <field name="name" select="1" />
                    <field name="code" />
                </form>
            </field>
        </record>

        <!-- Default action for Dimension option -->
		<record id="action_dimension_option" model="ir.actions.act_window">
			<field name="name">Dimension Options</field>
			<field name="res_model">product.variant.dimension.option</field>
            <field name="view_type">form</field>
			<field name="view_mode">tree,form</field>
            <field name="context">{'dimension_option_main_view': True}</field>
		</record>

        <!-- Menu entry for Dimension values -->
		<menuitem id="menu_variant_dimension_option" icon="STOCK_JUSTIFY_FILL" parent="menu_variant_dimension" action="action_dimension_option" />



        <!-- Views from Dimension values -->
        <record id="product_variant_multi_dimension_value_tree" model="ir.ui.view">
            <field name="name">product.variant.multi.dimension.value.tree</field>
            <field name="model">product.variant.dimension.value</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Dimension values" editable="top">
                    <field name="product_tmpl_id" select="1" invisible="not context.get('dimension_value_main_view', False)" />
                    <field name="active" />
                    <field name="dimension_id" />
                    <field name="option_id" />
                    <field name="sequence" />
                    <field name="cost_price_extra" />
                    <field name="price_extra" />
                </tree>
            </field>
        </record>

        <record id="product_variant_multi_dimension_value_form" model="ir.ui.view">
            <field name="name">product.variant.multi.dimension.value.form</field>
            <field name="model">product.variant.dimension.value</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Dimension values">
                    <field name="product_tmpl_id" select="1" invisible="not context.get('dimension_value_main_view', False)" />
                    <field name="active" />
                    <field name="dimension_id" />
                    <newline />
                    <field name="option_id" select="1" />
                    <field name="sequence" />
                    <field name="cost_price_extra" select="2" />
                    <field name="price_extra" select="2" />
                    <field name="price_margin" select="2" />
                </form>
            </field>
        </record>

        <!-- Default action for Dimension values -->
		<record id="action_dimension_value" model="ir.actions.act_window">
			<field name="name">Dimension values</field>
			<field name="res_model">product.variant.dimension.value</field>
            <field name="view_type">form</field>
			<field name="view_mode">tree,form</field>
            <field name="context">{'dimension_value_main_view': True}</field>
		</record>

        <!-- Views for Dimension types -->
		<record id="product_variant_multi_dimension_type_tree" model="ir.ui.view">
			<field name="name">product.variant.multi.dimension.type.tree</field>
			<field name="model">product.variant.dimension.type</field>
			<field name="type">tree</field>
			<field name="arch" type="xml">
				<tree string="Dimension Types">
					<field name="name" />
                    <field name="description" />
				</tree>
			</field>
		</record>

		<record id="product_variant_multi_dimension_type_form" model="ir.ui.view">
			<field name="name">product.variant.multi.dimension.type.form</field>
			<field name="model">product.variant.dimension.type</field>
			<field name="type">form</field>
			<field name="arch" type="xml">
				<form string="Dimension Types">
					<field name="name" select="1" />
                    <field name="description" select="2" />
					<field name="sequence" />
					<field name="allow_custom_value" select="2" />
					<field name="mandatory_dimension" select="2" />
					<field name="option_ids" nolabel="1" colspan="4" >
                        <tree editable="bottom" string="Dimension Options">
                            <field name="name" />
                            <field name="code" />
                            <field name="sequence" invisible="1"/>
                        </tree>
                    </field>
				</form>
			</field>
		</record>


        <!-- Default action for Dimension types -->
		<record id="action_dimension_type" model="ir.actions.act_window">
			<field name="name">Dimension types</field>
			<field name="res_model">product.variant.dimension.type</field>
            <field name="view_type">form</field>
			<field name="view_mode">tree,form</field>
            <field name="context">{'dimension_type_main_view': True}</field>
		</record>

        <!-- Menu entry for dimension types -->
		<menuitem id="menu_variant_dimension_types" icon="STOCK_JUSTIFY_FILL" parent="menu_variant_dimension" action="action_dimension_type" />




<!-- TODO remove useless view of product.template in the module product or fusion this view with the existing view in product, it's depend how the inheritage on this view will be managed by the other module-->

                                    <!--TODO add a wizard to add the option-->
                                    <!--<button name="add_some_option" string="Add " type="object" colspan="2"/>-->

        <record id="product_search_form_view_template" model="ir.ui.view">
            <field name="name">product.search.form.template</field>
            <field name="model">product.template</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Product Template">
                   <field name="name"/>
                </search>
            </field>
        </record>


        <record id="product_variant_multi_product_template_form_view" model="ir.ui.view">
            <field name="name">product.variant.multi.product.template.form</field>
            <field name="model">product.template</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="product.product_template_form_view" />
            <field name="arch" type="xml">
                <data>
                    <field name="name" position="after">
                        <field name="is_multi_variants"/>
                    </field>

                    <xpath expr="/form/notebook" position="inside">
                        <page string="Variants">
                                <group colspan="1" col="4" attrs="{'invisible':[('is_multi_variants','=',False)]}">
                                    <field name="dimension_type_ids" nolabel="1" colspan="4" />
                                    <button name="add_all_option" string="Add All Option" type="object" colspan="2"/>
                                    <field name="value_ids" nolabel="1" colspan="4" />
                                </group>
                                <group  colspan="1" col="4" attrs="{'invisible':[('is_multi_variants','=',False)]}">
                                    <field name="variant_model_name" colspan="4"/>
                                    <field name="variant_model_name_separator" colspan="4"/>
                                    <field name="code_generator" colspan="4"/>
							        <field name="variant_track_production" colspan="4"/>
							        <field name="variant_track_incoming" colspan="4"/>
							        <field name="variant_track_outgoing" colspan="4"/>
                                    <field name="do_not_generate_new_variant" colspan="4"/>
                                    <field name="do_not_update_variant" colspan="4"/>
							        <button name="button_generate_variants" string="Generate / Update variants ->" type="object" colspan="4"/>
                                </group>
                                <field name="variant_ids" string="Variants" nolabel="1"  colspan="1">
                                    <tree string="Variants">
                                        <field name="code" />
                                        <field name="name" />
                                        <field name="variants" string="Dimension Values" />
                                    </tree>
                                </field>
                        </page>
                    </xpath>
                </data>
            </field>
        </record>
        
        <!-- TODO remove useless view of product.product in the module product or move this correct view in product, it's depend how the heritage on this view will be managed by the other module -->

        <record id="product_search_form_view_variants" model="ir.ui.view">
            <field name="name">product.search.form.variants</field>
            <field name="model">product.product</field>
            <field name="type">search</field>
            <field name="inherit_id" ref="product.product_search_form_view"/>
            <field name="arch" type="xml">
                <field name="categ_id" position="after">
                    <field name="variants"/>
                </field>
            </field>
        </record>

        <record id="product_variant_form_view" model="ir.ui.view">
            <field name="name">product.variant.form</field>
            <field name="model">product.product</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Product Variant">
                    <field name="name" select="1" required="1"/>
                    <field name="product_tmpl_id" select="1"/>
                    <field name="variants" select="1"/>
                    <field name="default_code" select="1"/>
                    <field name="active" select="1"/>
                    <newline />
                    <notebook colspan="4">
                        <page string="Dimensions">
                            <separator string="Dimension Values" colspan="4"/>
                            <field name="dimension_value_ids" context="{'product_tmpl_id':product_tmpl_id}" nolabel="1" colspan="4"/>
                        </page>
                        <page string="Price">
                            <field name="list_price" string="Template Sale Price" readonly="1"/>
                            <field name="price_margin" select="1"/>
                            <field name="price_extra" select="1"/>
                            <field name="cost_price_extra"/>
                        </page>
                        <page string="Lots">
                            <field name="track_production" />
                            <field name="track_incoming" />
                            <field name="track_outgoing" />
                        </page>
                    </notebook>
                </form>
            </field>
        </record>
      
        <record id="product_variant_tree_view" model="ir.ui.view">
            <field name="name">product.variant.tree</field>
            <field name="model">product.product</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Product Variant">
                    <field name="default_code"/>
                    <field name="name"/>
                    <field name="product_tmpl_id"/>
                    <field name="variants"/>
                    <field name="price_extra"/>
                    <field name="cost_price_extra"/>
                </tree>
            </field>
        </record>
    
        <record id="action_variant_tree" model="ir.actions.act_window.view">
            <field name="sequence" eval="10" />
            <field name="view_mode">tree</field>
            <field name="act_window_id" ref="product_variant" />
            <field name="view_id" ref="product_variant_tree_view" />
        </record>

        <record id="action_variant_form" model="ir.actions.act_window.view">
            <field name="sequence" eval="20" />
            <field name="view_mode">form</field>
            <field name="act_window_id" ref="product_variant" />
            <field name="view_id" ref="product_variant_form_view" />
        </record>

        <record id="product_normal_variant_form_view" model="ir.ui.view">
            <field name="name">product.normal.variant.form</field>
            <field name="model">product.product</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="product.product_normal_form_view" />
            <field name="arch" type="xml">
                <data>
                    <field name="name" position="attributes">
                        <attribute name="required">1</attribute>
                    </field>
                    <field name="standard_price" position="replace">
                        <group name='cost_prices' colspan="2" col="4">
                            <field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
                            <field name="cost_price_extra" groups="product.group_product_variant"/>
                        </group>
                    </field>
                    <group col="2" colspan="2" groups="base.group_extended" position="replace">
                         <group colspan="2" col="6" name="weight" groups="base.group_extended">
                            <field name="is_multi_variants" invisible="1"/>
                            <group colspan="2" col="2">
                                <separator string="Template Weights" colspan="2"/>
                                <field digits="(14, 3)" name="volume" attrs="{'readonly':[('type','=','service')]}"/>
                                <field digits="(14, 3)" name="weight" attrs="{'readonly':[('type','=','service')]}"/>
                                <field digits="(14, 3)" name="weight_net" attrs="{'readonly':[('type','=','service')]}"/>
                            </group>
                            <group colspan="2" col="2" attrs="{'invisible':[('is_multi_variants','=',False)]}">
                                <separator string="Variant Weights" colspan="2"/>
                                <field digits="(14, 3)" name="additional_volume" attrs="{'readonly':[('type','=','service')]}"/>
                                <field digits="(14, 3)" name="additional_weight" attrs="{'readonly':[('type','=','service')]}"/>
                                <field digits="(14, 3)" name="additional_weight_net" attrs="{'readonly':[('type','=','service')]}"/>
                            </group>
                            <group colspan="2" col="2" attrs="{'invisible':[('is_multi_variants','=',False)]}">
                                <separator string="Total Weights" colspan="2"/>
                                <field digits="(14, 3)" name="total_volume"/>
                                <field digits="(14, 3)" name="total_weight"/>
                                <field digits="(14, 3)" name="total_weight_net"/>
                            </group>
                        </group>
                    </group>
                </data>
            </field>
        </record>   
    
    </data>
</openerp>