summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2015-09-03 08:59:27 +0200
committerNicolas Martinelli <nim@odoo.com>2015-09-03 13:15:16 +0200
commit3f48d2b6c4e84d8294a2af4e15bb3b7483114f37 (patch)
tree132408531d42c05e54c7349fd2b34d593f2dca1a
parente87144b2556975d87cbbc052f6d5380f31668b21 (diff)
[ADD] purchase: add the two-step validation process
Two-step validation process is set up at the level of the company.
-rw-r--r--addons/purchase/company.py16
-rw-r--r--addons/purchase/company_view.xml1
-rw-r--r--addons/purchase/purchase.py9
-rw-r--r--addons/purchase/purchase_view.xml9
4 files changed, 27 insertions, 8 deletions
diff --git a/addons/purchase/company.py b/addons/purchase/company.py
index c0f15294f03..eea108573b9 100644
--- a/addons/purchase/company.py
+++ b/addons/purchase/company.py
@@ -1,13 +1,19 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from openerp import api, fields, models, _
+from openerp import fields, models
class company(models.Model):
_inherit = 'res.company'
- po_lead = fields.Float(string='Purchase Lead Time', required=True,
- help="Margin of error for vendor lead times. When the system "\
- "generates Purchase Orders for procuring products, "\
- "they will be scheduled that many days earlier "\
+
+ po_lead = fields.Float(string='Purchase Lead Time', required=True,\
+ help="Margin of error for vendor lead times. When the system "
+ "generates Purchase Orders for procuring products, "
+ "they will be scheduled that many days earlier "
"to cope with unexpected vendor delays.", default=1.0)
+ po_double_validation = fields.Selection([
+ ('one_step', 'Confirm purchase orders in one step'),
+ ('two_step', 'Get 2 levels of approvals to confirm a purchase order')
+ ], string="Levels of Approvals", default='one_step',\
+ help="Provide a double validation mechanism for purchases")
diff --git a/addons/purchase/company_view.xml b/addons/purchase/company_view.xml
index e35bf1c24b5..5a8a112ba28 100644
--- a/addons/purchase/company_view.xml
+++ b/addons/purchase/company_view.xml
@@ -10,6 +10,7 @@
<field name="arch" type="xml">
<xpath expr="//group[@name='logistics_grp']" position="inside">
<field name="po_lead"/>
+ <field name="po_double_validation" widget="radio"/>
</xpath>
</field>
</record>
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 48be52f429b..be48ce543df 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -145,6 +145,7 @@ class PurchaseOrder(models.Model):
product_id = fields.Many2one('product.product', related='order_line.product_id', string='Product')
create_uid = fields.Many2one('res.users', 'Responsible')
company_id = fields.Many2one('res.company', 'Company', required=True, select=1, states=READONLY_STATES, default=lambda self: self.env.user.company_id.id)
+ po_double_validation = fields.Selection(related='company_id.po_double_validation', store=False, readonly=True)
picking_type_id = fields.Many2one('stock.picking.type', 'Deliver To', states=READONLY_STATES, required=True, default=_default_picking_type,\
help="This will determine picking type of incoming shipment")
@@ -242,7 +243,13 @@ class PurchaseOrder(models.Model):
@api.multi
def button_confirm(self):
- return self.button_approve()
+ # Deal with double validation process
+ if self.user_has_groups('purchase.group_purchase_manager'):
+ return self.button_approve()
+ elif self.po_double_validation == 'two_step':
+ self.write({'state': 'to approve'})
+ else:
+ return self.button_approve()
@api.multi
def button_cancel(self):
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index ec497ca41a6..cf72b1e2c60 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -143,14 +143,18 @@
<button name="print_quotation" string="Re-Print RFQ" type="object" states="sent" groups="base.group_user"/>
<button name="button_confirm" type="object" states="draft" string="Confirm Order" id="draft_confirm"/>
<button name="button_confirm" type="object" states="sent" string="Confirm Order" class="oe_highlight" id="bid_confirm"/>
- <button name="button_approve" type="object" states="to approve" string="Approve Order" class="oe_highlight" groups="purchase.group_purchase_manager"/>
+ <button name="button_approve" type="object" string="Approve Order" class="oe_highlight" groups="purchase.group_purchase_manager"
+ attrs="{'invisible': ['|', ('state', 'not in', ('to approve')), ('po_double_validation', '=', 'one_step')]}"/>
<button name="action_rfq_send" states="approved" string="Send PO by Email" type="object" context="{'send_rfq':False}"/>
<button name="%(purchase_open_picking)d" string="Receive Products" type="action" attrs="{'invisible': [('state','not in', ('purchase','done'))]}"/>
<button name="button_draft" states="cancel" string="Set to Draft" type="object" />
<button name="button_cancel" states="draft,to approve,sent,purchase" string="Cancel" type="object" />
<button name="button_done" type="object" string="Set to Done" states="purchase"
help="If a purchase order is done, you can not modify it manually anymore. But you will still be able to bill or receive."/>
- <field name="state" widget="statusbar" statusbar_visible="draft,sent,purchase,done" readonly="1"/>
+ <field name="state" widget="statusbar" statusbar_visible="draft,sent,purchase,done" readonly="1"
+ attrs="{'invisible': [('po_double_validation', '=', 'two_step')]}"/>
+ <field name="state" widget="statusbar" statusbar_visible="draft,sent,to approve,purchase,done" readonly="1"
+ attrs="{'invisible': [('po_double_validation', '=', 'one_step')]}"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
@@ -183,6 +187,7 @@
<field name="date_order"/>
<field name="origin" attrs="{'invisible': [('origin','=',False)]}"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
+ <field name="po_double_validation" invisible='1'/>
</group>
</group>
<notebook>