Commits

grasbauer committed 1660912

preparing release 2.4

  • Participants
  • Parent commits ab7dc82

Comments (0)

Files changed (3)

configuration.xml

     -->
 <tryton>
     <data>
+    
         <menuitem name="Variant Configuration" 
             parent="product.menu_main_product"
-            sequence="10" id="menu_product_configuration" 
-            groups="product.group_product_admin"/>
+            sequence="10" 
+            id="menu_product_configuration" 
+            />
+            
+        <record model="ir.ui.menu-res.group"
+            id="menu_product_configuration_group">
+            <field name="menu" ref="menu_product_configuration"/>
+            <field name="group" ref="product.group_product_admin"/>
+        </record>
 
         <record model="ir.ui.view" id="configuration_view_form">
             <field name="model">variant.configuration</field>
             <field name="act_window" ref="act_variant_configuration_form"/>
         </record>
         
-        <menuitem parent="menu_product_configuration" id="menu_variant_configuration"
+        <menuitem parent="menu_product_configuration" 
+            id="menu_variant_configuration"
             action="act_variant_configuration_form"
             sequence="10" icon="tryton-list"
-            groups="product.group_product_admin"/>
+            />
+        <record model="ir.ui.menu-res.group"
+            id="menu_variant_configuration_group">
+            <field name="menu" ref="menu_variant_configuration"/>
+            <field name="group" ref="product.group_product_admin"/>
+        </record>
 
     </data>
 </tryton>
 #this repository contains the full copyright notices and license terms.
 import copy
 import itertools
-
+from trytond.pool import Pool
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.pyson import Eval, Greater, Or, And, Not, Bool, PYSONEncoder
 from trytond.transaction import Transaction
         })
 
     def create(self, values):
-        if not values.get('template'):
+        if values.has_key('template') and not values['template']:
             values = values.copy()
             values.pop('template')
         return super(Product, self).create(values)
             'generate_variants': True,
         })
 
+        self._buttons.update({
+                'generate_variants': {
+                    'invisible':Eval('template'),
+                    }
+            })
+
         for column in self._columns.itervalues():
             already = False
             if 'readonly' in column.states:
         return [('id', 'in', res)]
 
     def create_code(self, basecode, variant):
-        config_obj = self.pool.get('product.variant.configuration')
+        config_obj = Pool().get('product.variant.configuration')
         config = config_obj.browse(1)
-        sep = config.code_seperator or ''
+        sep = config.code_separator or ''
         code = '%s%s' % (basecode or '', ['', sep][bool(basecode)])
         code = code + sep.join(i.code for i in variant)
         return code
 
     def create_product(self, template, variant):
         "create the product"
-        product_obj = self.pool.get('product.product')
-        value_obj = self.pool.get('product.product-attribute.value')
+        pool = Pool()
+        product_obj = pool.get('product.product')
+        value_obj = pool.get('product.product-attribute.value')
         code = self.create_code(template.basecode, variant)
         new_id = product_obj.create({'template':template.id,
             'code':code})
             value_obj.create({'product':new_id, 'value':value.id})
         return True
 
+    @ModelView.button
     def generate_variants(self, ids):
         """generate variants"""
         if not ids:
-            return {}
-        res = {}
+            return False
         for template in self.browse(ids):
             if not template.attributes:
                 continue
             for variant in variants:
                 if not variant in already:
                     self.create_product(template, variant)
-        return res
+        return True
 
 Template()
 
             <field name="arch" type="xml">
                 <![CDATA[
                 <data>
+                 <xpath
+                        expr="/form/label[@name='basecode']"
+                        position="replace"/>
                     <xpath
-                        expr="/form/notebook/page[@id=&quot;general&quot;]/label[@name=&quot;code&quot;]"
-                        position="before">
+                        expr="/form/field[@name='basecode']"
+                        position="replace">
                         <label name="template"/>
                         <field name="template"/>
                         <label name="variant"/>
                         <field name="variant"/>
                     </xpath>
-                   
+                   <xpath expr="/form/notebook/page[@id='general']/field[@name='description']"
+                        position="after">
+                        <field name="attribute_values" colspan="4"/>
+                    </xpath>
+                    <xpath expr="/form/notebook/page[@id='products']"
+                        position="replace"/>      
                 </data>
                 ]]>
             </field>
                     <xpath
                         expr="/tree/field[@name=&quot;variant&quot;]"
                         position="replace"/>
+                    
                 </data>
                 ]]>
             </field>
                         <label name="basecode"/>
                         <field name="basecode"/>
                     </xpath>
-                    <xpath expr="/form/notebook/page[@id=&quot;general&quot;]"
-                        position="after">
-                        <page id="attribute_values" string="Attribute Values"
-                            states="{'invisible': 
-                                Or(Not(Bool(Eval('attribute_values'))),
-                                Not(Bool(Eval('variant'))))}">
-                            <field name="attribute_values"/>
-                        </page>
-                    </xpath>
+                    
                     <xpath expr="/form/notebook/page[@id=&quot;general&quot;]"
                         position="after">
                         <page string="Basedescription" col="4" id="description"
                     </xpath>
                     <xpath expr="/form/notebook/page[@id=&quot;general&quot;]"
                         position="after">
-                        <page string="Variants" col="4" id="products"
-                            states="{'invisible': Bool(Eval('template'))}">
+                        <page string="Variants" col="4" id="products">
                             <field name="products" colspan="4"/>
                             <field name="attributes" colspan="4"/>
                             <button name="generate_variants" 
         <record model="ir.action.act_window" id="act_template_form">
             <field name="name">Product Template</field>
             <field name="res_model">product.template</field>
-            <field name="search_value">{'variant': ['=', True]}</field>
+            <field name="search_value">[('variant','=', True)]</field>
         </record>
 
         <record model="ir.action.act_window.view" id="act_template_list_view">
                 ]]>
             </field>
         </record>
-
+        
         <menuitem name="Product Attributes" id="menu_product_attribute"
             parent="menu_product_configuration" sequence="10"
-            action="act_product_attribute_form" groups="product.group_product_admin"/>
+            action="act_product_attribute_form"/>
+        
+        <record model="ir.ui.menu-res.group"
+            id="menu_product_attribute_group">
+            <field name="menu" ref="menu_product_attribute"/>
+            <field name="group" ref="product.group_product_admin"/>
+        </record>
 
         <record model="ir.ui.view" id="product_attribute_value_view_form">
             <field name="model">product.attribute.value</field>