[FIX]purchase_requisition: add workflow to tender, change procurement workflow and rename purchase requisition into request for tender
bzr revid: csn@openerp.com-20130611130343-gjlhxm694a9z9b7u
This commit is contained in:
parent
159b59f8dd
commit
cddfd7f129
|
@ -1123,6 +1123,8 @@ class procurement_order(osv.osv):
|
|||
return False
|
||||
return True
|
||||
|
||||
def check_product_requisition(self, cr, uid, ids, context=None):
|
||||
return False
|
||||
|
||||
def action_po_assign(self, cr, uid, ids, context=None):
|
||||
""" This is action which call from workflow to assign purchase order to procurements
|
||||
|
|
|
@ -230,7 +230,7 @@
|
|||
<record id="trans_confirm_mto_purchase" model="workflow.transition">
|
||||
<field name="act_from" ref="procurement.act_confirm_mto"/>
|
||||
<field name="act_to" ref="act_buy"/>
|
||||
<field name="condition">check_buy() and check_supplier_info()</field>
|
||||
<field name="condition">check_buy() and check_supplier_info() and not check_product_requisition()</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_buy_make_done" model="workflow.transition">
|
||||
|
|
|
@ -43,6 +43,7 @@ keep track and order all your purchase orders.
|
|||
'purchase_requisition_data.xml',
|
||||
'purchase_requisition_view.xml',
|
||||
'purchase_requisition_report.xml',
|
||||
'purchase_requisition_workflow.xml',
|
||||
'security/ir.model.access.csv','purchase_requisition_sequence.xml'
|
||||
],
|
||||
'auto_install': False,
|
||||
|
|
|
@ -56,11 +56,12 @@ class purchase_requisition(osv.osv):
|
|||
'purchase_ids' : fields.one2many('purchase.order','requisition_id','Purchase Orders',states={'done': [('readonly', True)]}),
|
||||
'po_line_ids': fields.function(_get_po_line, method=True, type='one2many', relation='purchase.order.line', string='Products by supplier'),
|
||||
'line_ids' : fields.one2many('purchase.requisition.line','requisition_id','Products to Purchase',states={'done': [('readonly', True)]}),
|
||||
'move_dest_id': fields.many2one('stock.move', 'Reservation Destination', ondelete='set null'),
|
||||
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse'),
|
||||
'state': fields.selection([('draft','Draft Tender'),('in_progress','Sent to Suppliers'),('open','Choosing Lines'),('done','PO Created'),('cancel','Cancelled')],
|
||||
'Status', track_visibility='onchange', required=True),
|
||||
'multiple_rfq_per_supplier': fields.boolean('Multiple RFQ per supplier'),
|
||||
'account_analytic_id':fields.many2one('account.analytic.account', 'Analytic Account',),
|
||||
'account_analytic_id':fields.many2one('account.analytic.account', 'Analytic Account'),
|
||||
'schedule_date': fields.date('Scheduled Date', select=True),
|
||||
}
|
||||
_defaults = {
|
||||
|
@ -103,8 +104,13 @@ class purchase_requisition(osv.osv):
|
|||
return self.write(cr, uid, ids, {'state':'open'} ,context=context)
|
||||
|
||||
def tender_reset(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'draft'})
|
||||
|
||||
self.write(cr, uid, ids, {'state': 'draft'})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for p_id in ids:
|
||||
# Deleting the existing instance of workflow for PO
|
||||
wf_service.trg_delete(uid, 'purchase.requisition', p_id, cr)
|
||||
wf_service.trg_create(uid, 'purchase.requisition', p_id, cr)
|
||||
return True
|
||||
def tender_done(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state':'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
|
||||
|
||||
|
@ -207,6 +213,7 @@ class purchase_requisition(osv.osv):
|
|||
'product_uom': default_uom_po_id,
|
||||
'price_unit': seller_price,
|
||||
'date_planned': requisition_line.schedule_date or date_planned,
|
||||
'move_dest_id': requisition.move_dest_id.id,
|
||||
'taxes_id': [(6, 0, taxes)],
|
||||
'account_analytic_id':requisition_line.account_analytic_id.id,
|
||||
}
|
||||
|
@ -298,7 +305,9 @@ class purchase_requisition(osv.osv):
|
|||
self.cancel_quotation(cr, uid, tender, context=context)
|
||||
|
||||
#set tender to state done
|
||||
self.tender_done(cr, uid, id, context=context)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'purchase.requisition', tender.id, 'done', cr)
|
||||
#self.tender_done(cr, uid, id, context=context)
|
||||
return True
|
||||
|
||||
def trigger_validate_po(self, cr, uid, po_id, context=None):
|
||||
|
@ -327,11 +336,11 @@ class purchase_requisition_line(osv.osv):
|
|||
'product_uom_id': fields.many2one('product.uom', 'Product Unit of Measure'),
|
||||
'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')),
|
||||
'po_line_buy': fields.many2one('purchase.order.line', 'Purchase Order Line'),
|
||||
'requisition_id': fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade'),
|
||||
'requisition_id': fields.many2one('purchase.requisition','Request for Tender', ondelete='cascade'),
|
||||
'po_line_ids': fields.related('requisition_id', 'po_line_ids', string='PO lines', readonly=True, type="one2many"),
|
||||
'company_id': fields.related('requisition_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
|
||||
'account_analytic_id':fields.many2one('account.analytic.account', 'Analytic Account',),
|
||||
'schedule_date': fields.date('Scheduled Date', select=True),
|
||||
'schedule_date': fields.date('Scheduled Date'),
|
||||
}
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, product_uom_id, parent_analytic_account, analytic_account, parent_date, date, context=None):
|
||||
|
@ -359,7 +368,7 @@ class purchase_order(osv.osv):
|
|||
_inherit = "purchase.order"
|
||||
|
||||
_columns = {
|
||||
'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition'),
|
||||
'requisition_id' : fields.many2one('purchase.requisition','Request for Tender'),
|
||||
}
|
||||
|
||||
def wkf_confirm_order(self, cr, uid, ids, context=None):
|
||||
|
@ -414,7 +423,7 @@ class product_product(osv.osv):
|
|||
_inherit = 'product.product'
|
||||
|
||||
_columns = {
|
||||
'purchase_requisition': fields.boolean('Purchase Requisition', help="Check this box to generates purchase requisition instead of generating requests for quotation from procurement.")
|
||||
'purchase_requisition': fields.boolean('Request for Tender', help="Check this box to generates requests for tender instead of generating requests for quotation from procurement.")
|
||||
}
|
||||
_defaults = {
|
||||
'purchase_requisition': False
|
||||
|
@ -441,6 +450,7 @@ class procurement_order(osv.osv):
|
|||
'date_end': procurement.date_planned,
|
||||
'warehouse_id':warehouse_id and warehouse_id[0] or False,
|
||||
'company_id':procurement.company_id.id,
|
||||
'move_dest_id':procurement.move_id.id,
|
||||
'line_ids': [(0,0,{
|
||||
'product_id': procurement.product_id.id,
|
||||
'product_uom_id': procurement.product_uom.id,
|
||||
|
@ -453,6 +463,12 @@ class procurement_order(osv.osv):
|
|||
res = super(procurement_order, self).make_po(cr, uid, ids, context=context)
|
||||
return res
|
||||
|
||||
def check_product_requisition(self, cr, uid, ids, context=None):
|
||||
procurement = self.browse(cr, uid, ids, context=context)[0]
|
||||
if procurement.product_id.purchase_requisition:
|
||||
return True
|
||||
return False
|
||||
|
||||
procurement_order()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<report auto="False" id="report_purchase_requisition" model="purchase.requisition" name="purchase.requisition" rml="purchase_requisition/report/purchase_requisition.rml" string="Purchase Requisition"/>
|
||||
<report auto="False" id="report_purchase_requisition" model="purchase.requisition" name="purchase.requisition" rml="purchase_requisition/report/purchase_requisition.rml" string="Request for Tender"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
<field name="name">purchase.requisition.form</field>
|
||||
<field name="model">purchase.requisition</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Purchase Requisition" version="7.0">
|
||||
<header>
|
||||
<button name="tender_in_progress" states="draft" string="Send to Suppliers" type="object" class="oe_highlight"/>
|
||||
<button name="tender_open" states="in_progress" string="Choose supplier(s)" type="object" class="oe_highlight"/>
|
||||
<form string="Request for Tender" version="7.0">
|
||||
<header>
|
||||
<button name="sent_suppliers" states="draft" string="Send to Suppliers" class="oe_highlight"/>
|
||||
<button name="open_bid" states="in_progress" string="Choose supplier(s)" class="oe_highlight"/>
|
||||
<button name="tender_reset" states="cancel" string="Reset to Draft" type="object" />
|
||||
<button name="open_product_line" states="open" string="Choose product lines" type="object" class="oe_highlight" groups="purchase.group_advance_bidding"/>
|
||||
<button name="generate_po" states="open" string="Make Purchase" type="object" class="oe_highlight"/>
|
||||
<button name="tender_cancel" states="draft,in_progress" string="Cancel Requisition" type="object" />
|
||||
<button name="cancel_requisition" states="draft,in_progress" string="Cancel Requisition" type="object" />
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,in_progress,open,done" statusbar_colors='{"in_progress":"blue"}'/>
|
||||
</header>
|
||||
<sheet>
|
||||
|
@ -125,7 +125,7 @@
|
|||
<field name="name">purchase.requisition.tree</field>
|
||||
<field name="model">purchase.requisition</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree fonts="bold:message_unread==True" colors="grey:state == 'cancel';red:date_end and date_end<current_date;black:date_end>current_date;" string="Purchase Requisition">
|
||||
<tree fonts="bold:message_unread==True" colors="grey:state == 'cancel';red:date_end and date_end<current_date;black:date_end>current_date;" string="Request for Tender">
|
||||
<field name="message_unread" invisible="1"/>
|
||||
<field name="name"/>
|
||||
<field name="date_start"/>
|
||||
|
@ -142,12 +142,12 @@
|
|||
<field name="name">purchase.requisition.list.select</field>
|
||||
<field name="model">purchase.requisition</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Purchase Requisition">
|
||||
<field name="name" string="Purchase Requisition"/>
|
||||
<search string="Search Request for Tender">
|
||||
<field name="name" string="Request for Tender"/>
|
||||
<field name="exclusive" />
|
||||
<filter icon="terp-document-new" name="draft" string="New" domain="[('state','=','draft')]" help="New Purchase Requisition"/>
|
||||
<filter icon="terp-camera_test" string="Sent to Suppliers" domain="[('state','=','in_progress')]" help="Purchase Requisition in negociation"/>
|
||||
<filter icon="terp-dialog-close" string="Purchase Done" domain="[('state','=','done')]" help="Current Purchase Requisition"/>
|
||||
<filter icon="terp-document-new" name="draft" string="New" domain="[('state','=','draft')]" help="New Request for Tender"/>
|
||||
<filter icon="terp-camera_test" string="Sent to Suppliers" domain="[('state','=','in_progress')]" help="Request for Tender in negociation"/>
|
||||
<filter icon="terp-dialog-close" string="Purchase Done" domain="[('state','=','done')]" help="Current Request for Tender"/>
|
||||
<separator/>
|
||||
<filter icon="terp-personal-" string="Unassigned" domain="[('user_id','=', False)]" help="Unassigned Requisition"/>
|
||||
<field name="user_id" />
|
||||
|
@ -164,7 +164,7 @@
|
|||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_purchase_requisition">
|
||||
<field name="name">Purchase Requisitions</field>
|
||||
<field name="name">Request for Tender</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">purchase.requisition</field>
|
||||
<field name="view_type">form</field>
|
||||
|
@ -173,9 +173,9 @@
|
|||
<field name="search_view_id" ref="view_purchase_requisition_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to start a new purchase requisition process.
|
||||
Click to start a new request for tender process.
|
||||
</p><p>
|
||||
A purchase requisition is the step before a request for quotation.
|
||||
A request for tender is the step before a request for quotation.
|
||||
In a purchase requisition (or purchase tender), you can record the
|
||||
products you need to buy and trigger the creation of RfQs to
|
||||
suppliers. After the negotiation, once you have reviewed all the
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="purchase_requisition_workflow" model="workflow">
|
||||
<field name="name">Purchase Requisition Basic Workflow</field>
|
||||
<field name="osv">purchase.requisition</field>
|
||||
<field name="on_create">True</field>
|
||||
</record>
|
||||
|
||||
<record id="act_draft" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase_requisition_workflow"/>
|
||||
<field name="flow_start">True</field>
|
||||
<field name="name">draft</field>
|
||||
</record>
|
||||
<record id="act_sent" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase_requisition_workflow"/>
|
||||
<field name="name">sent</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">tender_in_progress()</field>
|
||||
</record>
|
||||
<record id="act_open" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase_requisition_workflow"/>
|
||||
<field name="name">open</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">tender_open()</field>
|
||||
</record>
|
||||
<record id="act_cancel" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase_requisition_workflow"/>
|
||||
<field name="name">cancel</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="action">tender_cancel()</field>
|
||||
</record>
|
||||
<record id="act_done" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase_requisition_workflow"/>
|
||||
<field name="name">done</field>
|
||||
<field name="action">tender_done()</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="flow_stop">True</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_draft_sent" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_sent"/>
|
||||
<field name="signal">sent_suppliers</field>
|
||||
</record>
|
||||
<record id="trans_sent_open" model="workflow.transition">
|
||||
<field name="act_from" ref="act_sent"/>
|
||||
<field name="act_to" ref="act_open"/>
|
||||
<field name="signal">open_bid</field>
|
||||
</record>
|
||||
<record id="trans_draft_cancel" model="workflow.transition">
|
||||
<field name="act_from" ref="act_draft"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel_requisition</field>
|
||||
</record>
|
||||
<record id="trans_open_done" model="workflow.transition">
|
||||
<field name="act_from" ref="act_open"/>
|
||||
<field name="act_to" ref="act_done"/>
|
||||
<field name="signal">done</field>
|
||||
</record>
|
||||
<record id="trans_sent_cancel" model="workflow.transition">
|
||||
<field name="act_from" ref="act_sent"/>
|
||||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">cancel_requisition</field>
|
||||
</record>
|
||||
|
||||
<!-- Procurement -->
|
||||
<record id="act_buy_req" model="workflow.activity">
|
||||
<field name="wkf_id" ref="procurement.wkf_procurement"/>
|
||||
<field name="name">buy_requisition</field>
|
||||
<field name="kind">subflow</field>
|
||||
<field name="subflow_id" search="[('osv','=','purchase.requisition')]"/>
|
||||
<field name="action">action_po_assign()</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_confirm_mto_purchase_req" model="workflow.transition">
|
||||
<field name="act_from" ref="procurement.act_confirm_mto"/>
|
||||
<field name="act_to" ref="act_buy_req"/>
|
||||
<field name="condition">check_buy() and check_supplier_info() and check_product_requisition()</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_buy_make_done_req" model="workflow.transition">
|
||||
<field name="act_from" ref="act_buy_req"/>
|
||||
<field name="act_to" ref="procurement.act_make_done"/>
|
||||
<field name="signal">subflow.done</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_buy_cancel_req" model="workflow.transition">
|
||||
<field name="act_from" ref="act_buy_req"/>
|
||||
<field name="act_to" ref="procurement.act_cancel"/>
|
||||
<field name="signal">subflow.cancel</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<document filename="Purchase Requisition.pdf">
|
||||
<template title="Purchase Requisition" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
|
||||
<document filename="Request for Tender.pdf">
|
||||
<template title="Request for Tender" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
|
||||
<pageTemplate id="first">
|
||||
<frame id="first" x1="34.0" y1="28.0" width="530" height="786"/>
|
||||
</pageTemplate>
|
||||
|
@ -132,7 +132,7 @@
|
|||
<para style="terp_default_8">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="terp_header">Purchase Requisition [[ requisition.name ]]</para>
|
||||
<para style="terp_header">Request for Tender [[ requisition.name ]]</para>
|
||||
<para style="terp_default_8">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<data>
|
||||
|
||||
<record id="view_purchase_requisition_partner" model="ir.ui.view">
|
||||
<field name="name">Purchase Requisition</field>
|
||||
<field name="name">Request for Tender</field>
|
||||
<field name="model">purchase.requisition.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Purchase Requisition" version="7.0">
|
||||
|
@ -19,7 +19,7 @@
|
|||
</record>
|
||||
|
||||
<record id="action_purchase_requisition_partner" model="ir.actions.act_window">
|
||||
<field name="name">Purchase Requisition</field>
|
||||
<field name="name">Request for Tender</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">purchase.requisition.partner</field>
|
||||
<field name="view_type">form</field>
|
||||
|
|
Loading…
Reference in New Issue