From 0b18a5afec291a7248593704b0456d667349fca4 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 27 Jan 2015 10:33:48 +0100 Subject: [PATCH] [FIX] purchase: purchases button on product variants This rev. is related to 8381d47543e998e792b9514d9e6b19635832052b The action action_purchase_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 it will 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 be done in master. --- addons/purchase/purchase.py | 7 +++++++ addons/purchase/purchase_view.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 3519ef3e6a2..47528a44f22 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1444,6 +1444,13 @@ class product_product(osv.Model): for product_id in ids } + def action_view_purchases(self, cr, uid, ids, context=None): + if isinstance(ids, (int, long)): + ids = [ids] + result = self.pool['product.template']._get_act_window_dict(cr, uid, 'purchase.action_purchase_line_product_tree', context=context) + result['domain'] = "[('product_id','in',[" + ','.join(map(str, ids)) + "])]" + return result + _columns = { 'purchase_count': fields.function(_purchase_count, string='# Purchases', type='integer'), } diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 8fdc99811d2..dead323d2d2 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -648,7 +648,7 @@ -