[IMP] purchase: double validation minimum amount
This commit is contained in:
@@ -17,3 +17,5 @@ class company(models.Model):
|
||||
('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")
|
||||
po_double_validation_amount = fields.Monetary(string='Double validation amount', default=5000,\
|
||||
help="Minimum amount for which a double validation is required")
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<xpath expr="//group[@name='logistics_grp']" position="inside">
|
||||
<field name="po_lead"/>
|
||||
<field name="po_double_validation" widget="radio"/>
|
||||
<field name="po_double_validation_amount" attrs="{'invisible': [('po_double_validation', '=', 'one_step')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -280,12 +280,14 @@ class PurchaseOrder(models.Model):
|
||||
line.product_id.write(vals)
|
||||
|
||||
# Deal with double validation process
|
||||
if self.user_has_groups('purchase.group_purchase_manager'):
|
||||
if self.po_double_validation == 'one_step'\
|
||||
or (self.po_double_validation == 'two_step'\
|
||||
and self.amount_total < self.env.user.company_id.currency_id.compute(self.company_id.po_double_validation_amount, self.currency_id))\
|
||||
or 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()
|
||||
self.write({'state': 'to approve'})
|
||||
return {}
|
||||
|
||||
@api.multi
|
||||
def button_cancel(self):
|
||||
|
||||
@@ -151,10 +151,7 @@
|
||||
<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"
|
||||
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')]}"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,sent,purchase,done" readonly="1" />
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
|
||||
Reference in New Issue
Block a user