From 68b8286d5fe384af2ce05b58807e532ffa27a796 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 2 Feb 2015 10:34:27 +0100 Subject: [PATCH] [FIX] sale: sales button on product variants This rev. is comparable to 0b18a5afec291a7248593704b0456d667349fca4 The action action_order_line_product_tree is used in both product templates and product variants forms. Therefore, the default_product_id: active_id in the context cannot be used, As sometimes the active_id will be a product template, sometimes it will be a product variant. I believe two different window actions should be used, instead of sharing a common one and making hacks. Nevertheless, as we avoid taking risks in stable releases This should probably be performed in master. --- addons/sale/sale.py | 6 ++++++ addons/sale/sale_view.xml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 4919e502aa5..8ccd684f160 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1270,6 +1270,12 @@ class product_product(osv.Model): r[group['product_id'][0]] = group['product_uom_qty'] return r + def action_view_sales(self, cr, uid, ids, context=None): + result = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'sale.action_order_line_product_tree', raise_if_not_found=True) + result = self.pool['ir.actions.act_window'].read(cr, uid, [result], context=context)[0] + result['domain'] = "[('product_id','in',[" + ','.join(map(str, ids)) + "])]" + return result + _columns = { 'sales_count': fields.function(_sales_count, string='# Sales', type='integer'), } diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index c4b6af73163..cdcdf275e1e 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -490,7 +490,7 @@ - {'search_default_product_id': active_id, 'default_product_id': active_id} + {} Sales Order Lines sale.order.line @@ -502,7 +502,7 @@ -