[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')))
|
||||
return result
|
||||
|
||||
def _default_get(self, cr, uid, fields, context=None):
|
||||
result = self._price_field_get(cr,uid,context)
|
||||
# Added default function to fetch the Price type Based on Pricelist type.
|
||||
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':
|
||||
base_value = [item for item in result if 'Cost Price' in item]
|
||||
return base_value[0]
|
||||
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field', '=', 'standard_price')], context=context)
|
||||
elif fields.get('type') == 'sale':
|
||||
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context=context)
|
||||
else:
|
||||
base_value = [item for item in result if 'Public Price' in item]
|
||||
return base_value[0]
|
||||
return -1
|
||||
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"
|
||||
_description = "Pricelist item"
|
||||
_order = "sequence, min_quantity desc"
|
||||
_defaults = {
|
||||
'base': _default_get,
|
||||
'base': _get_default_base,
|
||||
'min_quantity': lambda *a: 0,
|
||||
'sequence': lambda *a: 5,
|
||||
'price_discount': lambda *a: 0,
|
||||
|
|
Loading…
Reference in New Issue