From 1941b9c244dc71ff7a76ce2abb71c24d81009a71 Mon Sep 17 00:00:00 2001 From: "Amit Bhavsar (Open ERP)" Date: Wed, 29 May 2013 19:27:34 +0530 Subject: [PATCH] [Product Pricelist] Default value for based on price bzr revid: amb@tinyerp.com-20130529135734-62rvtw3yocxvsmq1 --- addons/product/pricelist.py | 11 ++++++++++- addons/product/pricelist_view.xml | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 705844abae2..2396c56df34 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -376,11 +376,20 @@ 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) + if fields.get('type') == 'purchase': + base_value = [item for item in result if 'Cost Price' in item] + return base_value[0] + else: + base_value = [item for item in result if 'Public Price' in item] + return base_value[0] + _name = "product.pricelist.item" _description = "Pricelist item" _order = "sequence, min_quantity desc" _defaults = { - 'base': lambda *a: 1, + 'base': _default_get, 'min_quantity': lambda *a: 0, 'sequence': lambda *a: 5, 'price_discount': lambda *a: 0, diff --git a/addons/product/pricelist_view.xml b/addons/product/pricelist_view.xml index a1b996b891b..784a14228d5 100644 --- a/addons/product/pricelist_view.xml +++ b/addons/product/pricelist_view.xml @@ -152,7 +152,7 @@ - +
@@ -160,7 +160,7 @@ - +