[IMP] purchase: add Purchases statbutton in procurement form view
In procurement form view display a Purchases stat button that redirects to the purchase order. It opens the PO form view. Note that Purchase Order field in Extra Information is left untouched. It is just a shortcut to ease usability.
This commit is contained in:
committed by
Thibault Delavallée
parent
e839a6e274
commit
dabbc2cb7e
@@ -34,6 +34,7 @@ Dashboard / Reports for Purchase Management will include:
|
||||
'data/purchase_data.yml',
|
||||
'report/purchase_reports.xml',
|
||||
'views/purchase_views.xml',
|
||||
'views/procurement_views.xml',
|
||||
'views/stock_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'report/purchase_report_views.xml',
|
||||
|
||||
@@ -1014,6 +1014,14 @@ class ProcurementOrder(models.Model):
|
||||
self.env['purchase.order.line'].create(vals)
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def open_purchase_order(self):
|
||||
action = self.env.ref('purchase.purchase_order_action_generic')
|
||||
action_dict = action.read()[0]
|
||||
action_dict['res_id'] = self.purchase_id.id
|
||||
action_dict['target'] = 'current'
|
||||
return action_dict
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_name = 'product.template'
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="procurement_order_view_form_inherit_purchase" model="ir.ui.view">
|
||||
<field name="name">procurement.order.form.inherit.button</field>
|
||||
<field name="model">procurement.order</field>
|
||||
<field name="inherit_id" ref="procurement.procurement_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='do_view_procurements']" position="before">
|
||||
<button name="open_purchase_order" string="Purchases" type="object"
|
||||
class="oe_stat_button" icon="fa-shopping-cart"
|
||||
context="{'active_id':purchase_id}"
|
||||
attrs="{'invisible':[('purchase_id', '=', False)]}">
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -390,6 +390,14 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="purchase_order_action_generic" model="ir.actions.act_window">
|
||||
<field name="name">Purchase Orders</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">purchase.order</field>
|
||||
<field name="domain">[]</field>
|
||||
<field name="view_id" ref="purchase_order_form"/>
|
||||
</record>
|
||||
|
||||
<record id="purchase_rfq" model="ir.actions.act_window">
|
||||
<field name="name">Requests for Quotation</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
|
||||
Reference in New Issue
Block a user