[FIX] product: don't create new variants if the product.template is create by product.product.
This commit is contained in:
parent
aacde7984f
commit
d24aede8d7
|
@ -663,7 +663,8 @@ class product_template(osv.osv):
|
|||
def create(self, cr, uid, vals, context=None):
|
||||
''' Store the initial standard price in order to be able to retrieve the cost of a product template for a given date'''
|
||||
product_template_id = super(product_template, self).create(cr, uid, vals, context=context)
|
||||
self.create_variant_ids(cr, uid, [product_template_id], context=context)
|
||||
if not context or "create_product_product" not in context:
|
||||
self.create_variant_ids(cr, uid, [product_template_id], context=context)
|
||||
self._set_standard_price(cr, uid, product_template_id, vals.get('standard_price', 0.0), context=context)
|
||||
return product_template_id
|
||||
|
||||
|
@ -1045,6 +1046,12 @@ class product_product(osv.osv):
|
|||
'res_id': product.product_tmpl_id.id,
|
||||
'target': 'new'}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
context.update(create_product_product=True)
|
||||
return super(product_product, self).create(cr, uid, vals, context=context)
|
||||
|
||||
|
||||
class product_packaging(osv.osv):
|
||||
_name = "product.packaging"
|
||||
|
|
|
@ -155,6 +155,14 @@ HDD SH-1</field>
|
|||
<field name="attribute_id" ref="product_attribute_2"/>
|
||||
</record>
|
||||
|
||||
<record id="product_attribute_3" model="product.attribute">
|
||||
<field name="name">Wi-Fi</field>
|
||||
</record>
|
||||
<record id="product_attribute_value_5" model="product.attribute.value">
|
||||
<field name="name">2.4 GHz</field>
|
||||
<field name="attribute_id" ref="product_attribute_3"/>
|
||||
</record>
|
||||
|
||||
<record id="product_product_4" model="product.product">
|
||||
<field name="name">iPad Retina Display</field>
|
||||
<field name="categ_id" ref="ipad"/>
|
||||
|
@ -195,9 +203,14 @@ FaceTime HD Camera, 1.2 MP Photos</field>
|
|||
<field name="attribute_id" ref="product_attribute_2"/>
|
||||
<field name="value_ids" eval="[(6,0,[ref('product.product_attribute_value_3'), ref('product.product_attribute_value_4')])]"/>
|
||||
</record>
|
||||
<record id="product_attribute_line_3" model="product.attribute.line">
|
||||
<field name="product_tmpl_id" ref="product_product_4_product_template"/>
|
||||
<field name="attribute_id" ref="product_attribute_3"/>
|
||||
<field name="value_ids" eval="[(6,0,[ref('product.product_attribute_value_5')])]"/>
|
||||
</record>
|
||||
|
||||
<record id="product_product_4_product_template" model="product.template">
|
||||
<field name="variant_ids" eval="[(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2')])]"/>
|
||||
<field name="variant_ids" eval="[(6,0,[ref('product.product_attribute_line_1'), ref('product.product_attribute_line_2'), ref('product.product_attribute_line_3')])]"/>
|
||||
</record>
|
||||
|
||||
<record id="product_attribute_price_1" model="product.attribute.price">
|
||||
|
@ -296,14 +309,14 @@ FaceTime HD Camera, 1.2 MP Photos</field>
|
|||
<field name="variant_ids" eval="[(6,0,[ref('product.product_attribute_value_2')])]"/>
|
||||
</record>
|
||||
|
||||
<record id="product_attribute_line_3" model="product.attribute.line">
|
||||
<record id="product_attribute_line_4" model="product.attribute.line">
|
||||
<field name="product_tmpl_id" ref="product_product_11_product_template"/>
|
||||
<field name="attribute_id" ref="product_attribute_1"/>
|
||||
<field name="value_ids" eval="[(6,0,[ref('product.product_attribute_value_1'), ref('product.product_attribute_value_2')])]"/>
|
||||
</record>
|
||||
|
||||
<record id="product_product_11_product_template" model="product.template">
|
||||
<field name="variant_ids" eval="[(6,0,[ref('product.product_attribute_line_3')])]"/>
|
||||
<field name="variant_ids" eval="[(6,0,[ref('product.product_attribute_line_4')])]"/>
|
||||
</record>
|
||||
|
||||
<record id="product_attribute_price_2" model="product.attribute.price">
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
<field name="image" type="base64" file="website/static/description/website_edit.png"/>
|
||||
</record>
|
||||
|
||||
<record id="product.product_attribute_2" model="product.attribute">
|
||||
<field name="type">color</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_4" model="product.product">
|
||||
<field name="website_published" eval="True"/>
|
||||
<field name="website_size_x">2</field>
|
||||
|
|
Loading…
Reference in New Issue