diff options
| author | tdi-odoo <tdi@odoo.com> | 2016-09-20 16:12:36 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2016-09-27 15:12:53 +0200 |
| commit | dabbc2cb7ed7420131bef0ef5b33103d1d3d6a00 (patch) | |
| tree | 8b1d472e6940b87ca9f4187297c721fca45b9147 | |
| parent | e839a6e274daf40914abc342e6c9c107d88d9b1f (diff) | |
[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.
| -rw-r--r-- | addons/purchase/__manifest__.py | 1 | ||||
| -rw-r--r-- | addons/purchase/models/purchase.py | 8 | ||||
| -rw-r--r-- | addons/purchase/views/procurement_views.xml | 19 | ||||
| -rw-r--r-- | addons/purchase/views/purchase_views.xml | 8 |
4 files changed, 36 insertions, 0 deletions
diff --git a/addons/purchase/__manifest__.py b/addons/purchase/__manifest__.py index 3c3470196e3..60e242c9244 100644 --- a/addons/purchase/__manifest__.py +++ b/addons/purchase/__manifest__.py @@ -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', diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index dadf196e8fd..60e8322d17e 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -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' diff --git a/addons/purchase/views/procurement_views.xml b/addons/purchase/views/procurement_views.xml new file mode 100644 index 00000000000..d7ad173ac92 --- /dev/null +++ b/addons/purchase/views/procurement_views.xml @@ -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>
\ No newline at end of file diff --git a/addons/purchase/views/purchase_views.xml b/addons/purchase/views/purchase_views.xml index 654c629a7e6..79bdbbda826 100644 --- a/addons/purchase/views/purchase_views.xml +++ b/addons/purchase/views/purchase_views.xml @@ -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> |
