[MERGE] lp:~openerp-dev/openobject-addons/trunk-product-variant-imp-amb-dka

bzr revid: amb@tinyerp.com-20131112054305-h6mpdvl7mxbgj2fd
This commit is contained in:
Amit Bhavsar (Open ERP)
2013-11-12 11:13:05 +05:30
4 changed files with 35 additions and 7 deletions
+1 -1
View File
@@ -1534,7 +1534,7 @@ class account_invoice_line(osv.osv):
if type in ('in_invoice', 'in_refund'):
result.update( {'price_unit': price_unit or res.standard_price,'invoice_line_tax_id': tax_id} )
else:
result.update({'price_unit': res.list_price, 'invoice_line_tax_id': tax_id})
result.update({'price_unit': res.lst_price, 'invoice_line_tax_id': tax_id})
result['uos_id'] = uom_id or res.uom_id.id
+20 -4
View File
@@ -772,8 +772,8 @@ class product_product(osv.osv):
product_uom_obj = self.pool.get('product.uom')
for product in self.browse(cr, uid, ids, context=context):
res[product.id] = product[ptype] or 0.0
if ptype == 'list_price':
res[product.id] = (res[product.id] + ((res[product.id] * (product.price_margin)) / 100)) + \
if ptype == 'list_price' or ptype == 'lst_price':
res[product.id] = (product.list_price + ((product.list_price * (product.price_margin)) / 100)) + \
product.price_extra
if 'uom' in context:
uom = product.uom_id or product.uos_id
@@ -799,9 +799,13 @@ class product_product(osv.osv):
# will do the other languages).
context_wo_lang = context.copy()
context_wo_lang.pop('lang', None)
product = self.read(cr, uid, id, ['name', 'list_price', 'standard_price', 'categ_id'], context=context_wo_lang)
product = self.read(cr, uid, id, ['name', 'list_price', 'standard_price', 'categ_id', 'variants', 'product_tmpl_id'], context=context_wo_lang)
default = default.copy()
default.update(name=_("%s (copy)") % (product['name']), list_price=product['list_price'], standard_price=product['standard_price'], categ_id=product['categ_id'][0], product_tmpl_id=None)
if product['variants']:
default.update(variants=_("%s (copy)") % (product['variants']), product_tmpl_id=product['product_tmpl_id'][0])
else:
default.update(name=_("%s (copy)") % (product['name']), list_price=product['list_price'], standard_price=product['standard_price'], categ_id=product['categ_id'][0], product_tmpl_id=None)
if context.get('variant',False):
fields = ['product_tmpl_id', 'active', 'variants', 'default_code',
'price_margin', 'price_extra']
@@ -817,6 +821,18 @@ class product_product(osv.osv):
return super(product_product, self).copy(cr, uid, id, default=default,
context=context)
def copy_translations(self, cr, uid, old_id, new_id, context=None):
""" When we do not copy the template along the variant,
copy_translations sometimes receives 2 identical IDs.
That's because the ORM follows the o2m to copy the translations,
so in that case, it follows 'variant_ids' and for each variant,
it copy the translations. One of the variant is the 'new_id'.
Just skip the identical IDs.
"""
if old_id == new_id:
return
super(product_product, self).copy_translations(cr, uid, old_id, new_id, context=context)
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
context = {}
+1 -1
View File
@@ -116,7 +116,7 @@ parameter) will see those record just disappear.
-->
<record id="list_price" model="product.price.type">
<field name="name">Public Price</field>
<field name="field">list_price</field>
<field name="field">lst_price</field>
</record>
<record id="standard_price" model="product.price.type">
<field name="name">Cost Price</field>
+13 -1
View File
@@ -644,6 +644,18 @@
</record>
<!-- Variants -->
<record id="product_variant_search_form_view" model="ir.ui.view">
<field name="name">product.variant.search.form</field>
<field name="model">product.product</field>
<field name="arch" type="xml">
<search string="Product Variant">
<field name="name" string="Product" filter_domain="['|','|',('name','ilike',self),('default_code','ilike',self),('variants','ilike',self)]"/>
<group expand='0' string='Group by...'>
<filter string='Template' name="template_id" domain="[]" context="{'group_by' : 'product_tmpl_id'}"/>
</group>
</search>
</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>
@@ -688,7 +700,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form,kanban</field>
<field name="view_id" ref="product_variant_tree_view"/>
<field name="search_view_id" ref="product_search_form_view"/>
<field name="search_view_id" ref="product_variant_search_form_view"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to define a new variant of product.