[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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -30,9 +30,12 @@
|
||||
<field name="inherit_id" ref="stock.view_warehouse_orderpoint_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<div name="button_box" position="inside">
|
||||
<button name="%(purchase.purchase_order_action_generic)d" type="action"
|
||||
string="Purchases" class="oe_stat_button" icon="fa-refresh"
|
||||
domain="[('orderpoint_id','=',active_id)]"/>
|
||||
<button type="object"
|
||||
name="action_view_purchase"
|
||||
class="oe_stat_button"
|
||||
string="Purchases"
|
||||
icon="fa-refresh">
|
||||
</button>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user