diff --git a/addons/account/res_currency.py b/addons/account/res_currency.py index a7d3e5bc345..44f76b40cf4 100644 --- a/addons/account/res_currency.py +++ b/addons/account/res_currency.py @@ -43,5 +43,3 @@ class res_currency_account(osv.osv): rate = float(tot2)/float(tot1) return rate - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index 3183cb2c979..16ad4fee690 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -48,7 +48,6 @@ access_account_fiscalyear_partner_manager,account.fiscalyear.partnermanager,mode access_account_fiscalyear_employee,account.fiscalyear employee,model_account_fiscalyear,base.group_user,1,0,0,0 access_res_currency_account_manager,res.currency account manager,base.model_res_currency,group_account_manager,1,1,1,1 access_res_currency_rate_account_manager,res.currency.rate account manager,base.model_res_currency_rate,group_account_manager,1,1,1,1 -access_res_currency_rate_type_account_manager,res.currency.rate.type account manager,base.model_res_currency_rate_type,group_account_manager,1,1,1,1 access_account_invoice_user,account.invoice user,model_account_invoice,base.group_user,1,0,0,0 access_account_invoice_user,account.invoice.line user,model_account_invoice_line,base.group_user,1,0,0,0 access_account_payment_term_partner_manager,account.payment.term partner manager,model_account_payment_term,base.group_user,1,0,0,0 diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 85271dfb307..069c331c126 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -43,6 +43,10 @@ class price_type(osv.osv): res.append((field.name, field.field_description)) return res + def _get_field_currency(self, cr, uid, fname, ctx): + ids = self.search(cr, uid, [('field','=',fname)], context=ctx) + return self.browse(cr, uid, ids, context=ctx)[0].currency_id + def _get_currency(self, cr, uid, ctx): comp = self.pool.get('res.users').browse(cr,uid,uid).company_id if not comp: diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 656f581bc63..fc2a6e42650 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -163,7 +163,11 @@ class website_sale(http.Controller): keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_list) if not context.get('pricelist'): - context['pricelist'] = int(self.get_pricelist()) + pricelist = self.get_pricelist() + context['pricelist'] = int(pricelist) + else: + pricelist = pool.get('product.pricelist').browse(cr, uid, context['pricelist'], context) + product_obj = pool.get('product.template') product_count = product_obj.search_count(cr, uid, domain, context=context) @@ -181,8 +185,12 @@ class website_sale(http.Controller): categs = filter(lambda x: not x.parent_id, categories) attributes_obj = request.registry['product.attribute'] - attributes_ids = attributes_obj.search(cr, uid, [], context=request.context) - attributes = attributes_obj.browse(cr, uid, attributes_ids, context=request.context) + attributes_ids = attributes_obj.search(cr, uid, [], context=context) + attributes = attributes_obj.browse(cr, uid, attributes_ids, context=context) + + from_currency = pool.get('product.price.type')._get_field_currency(cr, uid, 'list_price', context) + to_currency = pricelist.currency_id + compute_currency = lambda price: pool['res.currency']._compute(cr, uid, from_currency, to_currency, price, context=context) values = { 'search': search, @@ -190,18 +198,18 @@ class website_sale(http.Controller): 'attrib_values': attrib_values, 'attrib_set': attrib_set, 'pager': pager, - 'pricelist': self.get_pricelist(), + 'pricelist': pricelist, 'products': products, 'bins': table_compute().process(products), 'rows': PPR, 'styles': styles, 'categories': categs, 'attributes': attributes, + 'compute_currency': compute_currency, 'keep': keep, 'style_in_product': lambda style, product: style.id in [s.id for s in product.website_style_ids], 'attrib_encode': lambda attribs: werkzeug.url_encode([('attrib',i) for i in attribs]), } - return request.website.render("website_sale.products", values) @http.route(['/shop/product/'], type='http', auth="public", website=True) @@ -266,8 +274,13 @@ class website_sale(http.Controller): cr, uid, context, pool = request.cr, request.uid, request.context, request.registry order = request.website.sale_get_order() + from_currency = pool.get('product.price.type')._get_field_currency(cr, uid, 'list_price', context) + to_currency = order.pricelist_id.currency_id + compute_currency = lambda price: pool['res.currency']._compute(cr, uid, from_currency, to_currency, price, context=context) + values = { 'order': order, + 'compute_currency': compute_currency, 'suggested_products': [], } if order: diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 7c0700a555a..a0ec9bfd3a9 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -120,9 +120,9 @@ class website(orm.Model): _columns = { 'pricelist_id': fields.related('user_id','partner_id','property_product_pricelist', - type='many2one', relation='product.pricelist', string='Default pricelist'), + type='many2one', relation='product.pricelist', string='Default Pricelist'), 'currency_id': fields.related('pricelist_id','currency_id', - type='many2one', relation='res.currency', string='Default pricelist'), + type='many2one', relation='res.currency', string='Default Currency'), } def sale_product_domain(self, cr, uid, ids, context=None): @@ -218,9 +218,4 @@ class website(orm.Model): 'sale_order_code_pricelist_id': False, }) - def compute_curency(self, cr, uid, ids, from_amount, from_currency_id=None, context=None): - from_currency_id = from_currency_id or self.browse(cr, SUPERUSER_ID, ids[0]).currency_id.id - to_currency_id = self.pool.get("res.users").browse(cr, uid, uid).partner_id.property_product_pricelist.currency_id.id - return self.pool['res.currency'].compute(cr, uid, from_currency_id, to_currency_id, from_amount, context=context) -# vim:et: diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index 2f7a248f8f6..07eb4a6fb27 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -80,7 +80,7 @@
- + - + - - - res.currency.rate.type.form - res.currency.rate.type - -
- - - -
-
-
- - - Currency Rate Type - res.currency.rate.type - form - tree,form - - - - res.currency.rate.type.search - res.currency.rate.type - - - - - - - - diff --git a/openerp/addons/base/security/ir.model.access.csv b/openerp/addons/base/security/ir.model.access.csv index bbf579486a4..41ac2b8ee40 100644 --- a/openerp/addons/base/security/ir.model.access.csv +++ b/openerp/addons/base/security/ir.model.access.csv @@ -51,7 +51,6 @@ "access_res_country_group_group_user","res_country_group group_user","model_res_country_group","group_partner_manager",1,1,1,1 "access_res_currency_group_all","res_currency group_all","model_res_currency",,1,0,0,0 "access_res_currency_rate_group_all","res_currency_rate group_all","model_res_currency_rate",,1,0,0,0 -"access_res_currency_rate_type_group_all","res_currency_rate_type group_all","model_res_currency_rate_type",,1,0,0,0 "access_res_currency_group_system","res_currency group_system","model_res_currency","group_system",1,1,1,1 "access_res_currency_rate_group_system","res_currency_rate group_system","model_res_currency_rate","group_system",1,1,1,1 "access_res_groups_group_erp_manager","res_groups group_erp_manager","model_res_groups","group_erp_manager",1,1,1,1