[IMP]Improvement in purchase_double_validation Module Taskid-1774
bzr revid: ron@tinyerp.com-20101214122213-3bcu7lhvvnwt3uoa
This commit is contained in:
@@ -155,7 +155,7 @@
|
||||
<field name="state" readonly="1"/>
|
||||
<button name="purchase_cancel" states="draft,confirmed,wait_auth" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
|
||||
<button name="action_cancel" states="approved,except_picking,except_invoice" string="Cancel Purchase Order" type="object" icon="gtk-cancel"/>
|
||||
<button name="action_cancel" states="approved,except_picking,except_invoice,wait" string="Cancel Purchase Order" type="object" icon="gtk-cancel"/>
|
||||
<button name="picking_ok" states="except_picking" string="Manually Corrected" icon="gtk-convert"/>
|
||||
<button name="invoice_ok" states="except_invoice" string="Manually Corrected" icon="gtk-convert"/>
|
||||
<button name="purchase_confirm" states="draft" string="Convert to Purchase Order" icon="gtk-go-forward"/>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import purchase_double_validation_installer
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
"name" : "purchase_double_validation",
|
||||
"version" : "1.1",
|
||||
"category": 'Generic Modules/Sales & Purchases',
|
||||
"depends" : ["base","purchase"],
|
||||
"author" : "Tiny",
|
||||
"description": """
|
||||
This module modifies purchase workflow in order to validate purchases that exceeds minimum amount set by wizard
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'purchase_double_validation_view.xml',
|
||||
'purchase_double_validation_workflow.xml',
|
||||
'purchase_double_validation_installer.xml', ],
|
||||
'demo_xml': [],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/python
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
from osv import fields, osv
|
||||
|
||||
class purchase_double_validation_installer(osv.osv_memory):
|
||||
_name = 'purchase.double.validation.installer'
|
||||
_inherit = 'res.config'
|
||||
|
||||
_columns = {
|
||||
'limit_amount': fields.integer('Limit Amount', required=True, help="Minimum amount after which validation of purchase is required"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'limit_amount': 1000,
|
||||
}
|
||||
|
||||
def execute(self, cr, uid, ids, context=None):
|
||||
data = self.read(cr, uid, ids, context=context)
|
||||
amt = data[0]['limit_amount']
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
transition_obj = self.pool.get('workflow.transition')
|
||||
waiting = data_pool._get_id(cr, uid, 'purchase_double_validation', 'trans_router1_waiting')
|
||||
waiting_id = data_pool.browse(cr, uid, waiting, context=context).res_id
|
||||
confirm = data_pool._get_id(cr, uid, 'purchase', 'trans_draft_confirmed')
|
||||
confirm_id = data_pool.browse(cr, uid, confirm, context=context).res_id
|
||||
transition_obj.write(cr, uid, waiting_id, {'condition': 'amount_total>%s' % (amt), 'signal': False})
|
||||
transition_obj.write(cr, uid, confirm_id, {'condition': 'amount_total<=%s' % (amt), 'signal': False})
|
||||
return {}
|
||||
|
||||
purchase_double_validation_installer()
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- configartion view -->
|
||||
|
||||
<record id="view_config_purchase_limit_amount" model="ir.ui.view">
|
||||
<field name="name">Configure Limit Amount for Purchase</field>
|
||||
<field name="model">purchase.double.validation.installer</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="base.res_config_view_base"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<form position="attributes">
|
||||
<attribute name="string">Purchase Application Configuration</attribute>
|
||||
</form>
|
||||
<separator string="title" position="attributes">
|
||||
<attribute name="string">Configure Limit Amount for Purchase</attribute>
|
||||
</separator>
|
||||
<xpath expr="//label[@string='description']" position="attributes">
|
||||
<attribute name="string">Define minimum amount after which puchase is needed to be validated.</attribute>
|
||||
</xpath>
|
||||
<xpath expr='//separator[@string="vsep"]' position='attributes'>
|
||||
<attribute name='rowspan'>15</attribute>
|
||||
<attribute name='string'></attribute>
|
||||
</xpath>
|
||||
<group string="res_config_contents" position="replace">
|
||||
<field name="limit_amount"/>
|
||||
<newline/>
|
||||
</group>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_config_purchase_limit_amount" model="ir.actions.act_window">
|
||||
<field name="name">Configure Limit Amount for Purchase</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">purchase.double.validation.installer</field>
|
||||
<field name="view_id" ref="view_config_purchase_limit_amount"/>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- register configuration wizard -->
|
||||
<record id="config_wizard_step_purchase_limit_amount" model="ir.actions.todo">
|
||||
<field name="action_id" ref="action_config_purchase_limit_amount"/>
|
||||
<field name="restart">onskip</field>
|
||||
<field name="groups_id" eval="[(6,0,[ref('base.group_extended')])]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_purchase_form_inherit" model="ir.ui.view">
|
||||
<field name="name">purchase.order.form.inherit</field>
|
||||
<field name="model">purchase.order</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@string='Convert to Purchase Order']" position="replace">
|
||||
<button name="draft_router1" states="draft" string="Confirm" icon="gtk-go-forward"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[@string='Approve Purchase']" position="replace">
|
||||
<button name="waiting_confirmed" states="wait" string="Convert to Purchase Order" icon="gtk-go-forward"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="act_waiting" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase.purchase_order"/>
|
||||
<field name="name">waiting</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">write({'state':'wait'})</field>
|
||||
</record>
|
||||
|
||||
<record id="act_router1" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase.purchase_order"/>
|
||||
<field name="name">router1</field>
|
||||
<field name="split_mode">OR</field>
|
||||
<field name="kind">dummy</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_draft_router1" model="workflow.transition">
|
||||
<field name="act_from" ref="purchase.act_draft"/>
|
||||
<field name="act_to" ref="act_router1"/>
|
||||
<field name="condition">True</field>
|
||||
<field name="signal">draft_router1</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_router1_waiting" model="workflow.transition">
|
||||
<field name="act_from" ref="act_router1"/>
|
||||
<field name="act_to" ref="act_waiting"/>
|
||||
<field name="condition">True</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="purchase.trans_draft_confirmed" model="workflow.transition">
|
||||
<field name="act_from" ref="act_router1"/>
|
||||
<field name="act_to" ref="purchase.act_confirmed"/>
|
||||
<field name="condition">True</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_waiting_confirmed" model="workflow.transition">
|
||||
<field name="act_from" ref="act_waiting"/>
|
||||
<field name="act_to" ref="purchase.act_confirmed"/>
|
||||
<field name="condition">True</field>
|
||||
<field name="signal">waiting_confirmed</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user