[IMP] product: rename field variants_ids to respect odoo typo; add demo data for mrp
authorChristophe Matthieu <chm@odoo.com>
Wed, 28 May 2014 09:46:32 +0000 (11:46 +0200)
committerChristophe Matthieu <chm@odoo.com>
Wed, 28 May 2014 09:46:32 +0000 (11:46 +0200)
addons/mrp/mrp.py
addons/mrp/mrp_demo.xml
addons/mrp/mrp_view.xml
addons/product/product.py

index dbcd769..98e0e9b 100644 (file)
@@ -306,8 +306,8 @@ class mrp_bom(osv.osv):
             if set(map(int,bom_line_id.property_ids or [])) - set(properties or []):
                 continue
             # all bom_line_id variant values must be in the product
-            if bom_line_id.variants_ids:
-                if not product or (set(map(int,bom_line_id.variants_ids or [])) - set(map(int,product.variant_ids))):
+            if bom_line_id.variant_ids:
+                if not product or (set(map(int,bom_line_id.variant_ids or [])) - set(map(int,product.variant_ids))):
                     continue
 
             if bom_line_id.product_id.id in all_prod:
@@ -393,7 +393,7 @@ class mrp_bom_line(osv.osv):
         'property_ids': fields.many2many('mrp.property', string='Properties'),
 
         'bom_id': fields.many2one('mrp.bom', 'Parent BoM', ondelete='cascade', select=True, required=True),
-        'variants_ids': fields.many2many('product.attribute.value', string='Variants', help="BOM Product Variants needed form apply this line."),
+        'variant_ids': fields.many2many('product.attribute.value', string='Variants', help="BOM Product Variants needed form apply this line."),
     }
 
     def _get_uom_id(self, cr, uid, *args):
index d6a3e65..1232d1b 100644 (file)
 
         <record id="mrp_bom_8" model="mrp.bom">
             <field name="name">PC Assemble + 2GB RAM</field>
-            <field name="product_tmpl_id" ref="product.product_product_4_product_template"/>
+            <field name="product_tmpl_id" ref="product.product_product_3_product_template"/>
             <field name="product_uom" ref="product.product_uom_unit"/>
             <field name="sequence">5</field>            
             <field name="type">phantom</field>
             <field name="bom_id" ref="mrp_bom_10"/>
         </record>
 
+        <record id="mrp_bom_11" model="mrp.bom">
+            <field name="name">iPad Retina Display</field>
+            <field name="product_tmpl_id" ref="product.product_product_4_product_template"/>
+            <field name="product_uom" ref="product.product_uom_unit"/>
+            <field name="sequence">1</field>            
+            <field name="type">normal</field>
+        </record>
+        <record id="mrp_bom_line_32" model="mrp.bom.line">
+            <field name="product_id" ref="product.product_product_14"/>
+            <field name="product_qty">1</field>
+            <field name="product_uom" ref="product.product_uom_unit"/>
+            <field name="sequence">1</field>            
+            <field name="type">normal</field>
+            <field name="variant_ids" eval="[(6,0,[ref('product.product_attribute_value_1')])]"/>
+            <field name="bom_id" ref="mrp_bom_11"/>
+        </record>
+        <record id="mrp_bom_line_33" model="mrp.bom.line">
+            <field name="product_id" ref="product.product_product_15"/>
+            <field name="product_qty">1</field>
+            <field name="product_uom" ref="product.product_uom_unit"/>
+            <field name="sequence">2</field>            
+            <field name="type">normal</field>
+            <field name="variant_ids" eval="[(6,0,[ref('product.product_attribute_value_2')])]"/>
+            <field name="bom_id" ref="mrp_bom_11"/>
+        </record>
+        <record id="mrp_bom_line_34" model="mrp.bom.line">
+            <field name="product_id" ref="product.product_product_23"/>
+            <field name="product_qty">1</field>
+            <field name="product_uom" ref="product.product_uom_unit"/>
+            <field name="sequence">3</field>            
+            <field name="type">normal</field>
+            <field name="bom_id" ref="mrp_bom_11"/>
+        </record>
+
+
     <record id="mrp_production_1" model="mrp.production">
         <field name="product_id" ref="product.product_product_4"/>
         <field name="product_uom" ref="product.product_uom_unit"/>
index 6da46f1..c9ee9f6 100644 (file)
                                     <field name="date_start"/>
                                     <field name="date_stop"/>
                                     <field name="routing_id"/>
-                                    <field name="variants_ids" widget="many2many_tags"/>
+                                    <field name="variant_ids" widget="many2many_tags"/>
                                 </tree>
                             </field>
                         </page>
                     <field name="date_start"/>
                     <field name="date_stop"/>
                     <field name="routing_id"/>
-                    <field name="variants_ids" widget="many2many_tags"/>
+                    <field name="variant_ids" widget="many2many_tags"/>
                     <field name="property_ids" widget="many2many_tags"/>
                 </tree>
             </field>
index ea62786..58391d8 100644 (file)
@@ -628,7 +628,7 @@ class product_template(osv.osv):
                     all_variants = temp_variants
 
             # check product
-            variants_ids_to_active = []
+            variant_ids_to_active = []
             variants_active_ids = []
             variants_inactive = []
             for product_id in tmpl_id.product_variant_ids:
@@ -637,11 +637,11 @@ class product_template(osv.osv):
                     variants_active_ids.append(product_id.id)
                     all_variants.pop(all_variants.index(variants))
                     if not product_id.active:
-                        variants_ids_to_active.append(product_id.id)
+                        variant_ids_to_active.append(product_id.id)
                 else:
                     variants_inactive.append(product_id)
-            if variants_ids_to_active:
-                product_obj.write(cr, uid, variants_ids_to_active, {'active': True}, context=ctx)
+            if variant_ids_to_active:
+                product_obj.write(cr, uid, variant_ids_to_active, {'active': True}, context=ctx)
 
             # create new product
             for variant_ids in all_variants: