[Imp] Improve code for pricelists.
bzr revid: amb@tinyerp.com-20130712073654-1fowt1xojgx0pjdc
This commit is contained in:
parent
5eddd3bea5
commit
b47a121f44
|
@ -376,20 +376,26 @@ class product_pricelist_item(osv.osv):
|
||||||
result.append((-2, _('Supplier Prices on the product form')))
|
result.append((-2, _('Supplier Prices on the product form')))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _default_get(self, cr, uid, fields, context=None):
|
# Added default function to fetch the Price type Based on Pricelist type.
|
||||||
result = self._price_field_get(cr,uid,context)
|
def _get_default_base(self, cr, uid, fields, context=None):
|
||||||
|
product_price_type_obj = self.pool.get('product.price.type')
|
||||||
if fields.get('type') == 'purchase':
|
if fields.get('type') == 'purchase':
|
||||||
base_value = [item for item in result if 'Cost Price' in item]
|
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field', '=', 'standard_price')], context=context)
|
||||||
return base_value[0]
|
elif fields.get('type') == 'sale':
|
||||||
|
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context=context)
|
||||||
else:
|
else:
|
||||||
base_value = [item for item in result if 'Public Price' in item]
|
return -1
|
||||||
return base_value[0]
|
if not product_price_type_ids:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0]
|
||||||
|
return pricetype.id
|
||||||
|
|
||||||
_name = "product.pricelist.item"
|
_name = "product.pricelist.item"
|
||||||
_description = "Pricelist item"
|
_description = "Pricelist item"
|
||||||
_order = "sequence, min_quantity desc"
|
_order = "sequence, min_quantity desc"
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'base': _default_get,
|
'base': _get_default_base,
|
||||||
'min_quantity': lambda *a: 0,
|
'min_quantity': lambda *a: 0,
|
||||||
'sequence': lambda *a: 5,
|
'sequence': lambda *a: 5,
|
||||||
'price_discount': lambda *a: 0,
|
'price_discount': lambda *a: 0,
|
||||||
|
|
Loading…
Reference in New Issue