From 2c5022b4f33b1406736d0f9a0bee76942ba0bf7f Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Wed, 21 Feb 2018 11:53:04 +0100 Subject: [PATCH] [FIX] purchase: orderpoint should redirect to linked PO Since procurement order removal. We lost the behavior to access PO directly from the orderpoint. In 10.0 the puchase button redirect to the procurement order and the purchases were accessible from the procurement order. We do not have the procurement order anymore thus the button return to a list view with all RFQ and PO. Fixes #23096 --- addons/purchase/models/stock.py | 16 ++++++++++++++++ addons/purchase/views/stock_views.xml | 9 ++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/addons/purchase/models/stock.py b/addons/purchase/models/stock.py index ca97053c775..2fbd8bec354 100644 --- a/addons/purchase/models/stock.py +++ b/addons/purchase/models/stock.py @@ -179,3 +179,19 @@ class Orderpoint(models.Model): for poline in self.env['purchase.order.line'].search([('state','in',('draft','sent','to approve')),('orderpoint_id','in',self.ids)]): res[poline.orderpoint_id.id] += poline.product_uom._compute_quantity(poline.product_qty, poline.orderpoint_id.product_uom, round=False) return res + + def action_view_purchase(self): + """ This function returns an action that display existing + purchase orders of given orderpoint. + """ + action = self.env.ref('purchase.purchase_rfq') + result = action.read()[0] + + # Remvove the context since the action basically display RFQ and not PO. + result['context'] = {} + order_line_ids = self.env['purchase.order.line'].search([('orderpoint_id', '=', self.id)]) + purchase_ids = order_line_ids.mapped('order_id') + + result['domain'] = "[('id','in',%s)]" % (purchase_ids.ids) + + return result diff --git a/addons/purchase/views/stock_views.xml b/addons/purchase/views/stock_views.xml index 80c9382ca1d..bc24cf74be0 100644 --- a/addons/purchase/views/stock_views.xml +++ b/addons/purchase/views/stock_views.xml @@ -30,9 +30,12 @@
-