[FIX]purchase_requisition: add button and a new state in purchase order workflow and changes in tender process

bzr revid: csn@openerp.com-20130529095150-4f0g1vmfj9h54juu
This commit is contained in:
Cedric Snauwaert 2013-05-29 11:51:50 +02:00
parent 37111666cf
commit d39a918143
12 changed files with 331 additions and 25 deletions

View File

@ -18,7 +18,7 @@
<data noupdate="1">
<!--Email template -->
<record id="email_template_edi_purchase" model="email.template">
<field name="name">Purchase Order - Send by mail</field>
<field name="name">RFQ - Send by mail</field>
<field name="email_from">${object.validator.email or ''}</field>
<field name="subject">${object.company_id.name} Order (Ref ${object.name or 'n/a' })</field>
<field name="email_recipients">${object.partner_id.id}</field>
@ -34,6 +34,80 @@
<p>Here is a ${object.state in ('draft', 'sent') and 'request for quotation' or 'purchase order confirmation'} from ${object.company_id.name}: </p>
<p style="border-left: 1px solid #8e0000; margin-left: 30px;">
&nbsp;&nbsp;<strong>REFERENCES</strong><br />
&nbsp;&nbsp;Order number: <strong>${object.name}</strong><br />
&nbsp;&nbsp;Order date: ${object.date_order}<br />
% if object.origin:
&nbsp;&nbsp;Order reference: ${object.origin}<br />
% endif
% if object.partner_ref:
&nbsp;&nbsp;Your reference: ${object.partner_ref}<br />
% endif
% if object.validator:
&nbsp;&nbsp;Your contact: <a href="mailto:${object.validator.email or ''}?subject=Order%20${object.name}">${object.validator.name}</a>
% endif
</p>
<br/>
<p>If you have any question, do not hesitate to contact us.</p>
<p>Thank you!</p>
<br/>
<br/>
<div style="width: 375px; margin: 0px; padding: 0px; background-color: #8E0000; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; background-repeat: repeat no-repeat;">
<h3 style="margin: 0px; padding: 2px 14px; font-size: 12px; color: #DDD;">
<strong style="text-transform:uppercase;">${object.company_id.name}</strong></h3>
</div>
<div style="width: 347px; margin: 0px; padding: 5px 14px; line-height: 16px; background-color: #F2F2F2;">
<span style="color: #222; margin-bottom: 5px; display: block; ">
% if object.company_id.street:
${object.company_id.street}<br/>
% endif
% if object.company_id.street2:
${object.company_id.street2}<br/>
% endif
% if object.company_id.city or object.company_id.zip:
${object.company_id.zip} ${object.company_id.city}<br/>
% endif
% if object.company_id.country_id:
${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}<br/>
% endif
</span>
% if object.company_id.phone:
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
Phone:&nbsp; ${object.company_id.phone}
</div>
% endif
% if object.company_id.website:
<div>
Web :&nbsp;<a href="${object.company_id.website}">${object.company_id.website}</a>
</div>
%endif
<p></p>
</div>
</div>
]]></field>
</record>
<!--Email template -->
<record id="email_template_edi_purchase_done" model="email.template">
<field name="name">Purchase Order - Send by mail</field>
<field name="email_from">${object.validator.email or ''}</field>
<field name="subject">${object.company_id.name} Order (Ref ${object.name or 'n/a' })</field>
<field name="email_recipients">${object.partner_id.id}</field>
<field name="model_id" ref="purchase.model_purchase_order"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="report_purchase_order"/>
<field name="report_name">PO_${(object.name or '').replace('/','_')}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
<p>Hello ${object.partner_id.name},</p>
<p>Here is a ${object.state in ('draft', 'sent') and 'request for quotation' or 'purchase order confirmation'} from ${object.company_id.name}: </p>
<p style="border-left: 1px solid #8e0000; margin-left: 30px;">
&nbsp;&nbsp;<strong>REFERENCES</strong><br />
&nbsp;&nbsp;Order number: <strong>${object.name}</strong><br />

View File

@ -154,8 +154,9 @@ class purchase_order(osv.osv):
STATE_SELECTION = [
('draft', 'Draft PO'),
('sent', 'RFQ Sent'),
('bid', 'Bid Received'),
('confirmed', 'Waiting Approval'),
('approved', 'Purchase Order'),
('approved', 'Purchase Confirmed'),
('except_picking', 'Shipping Exception'),
('except_invoice', 'Invoice Exception'),
('done', 'Done'),
@ -226,6 +227,8 @@ class purchase_order(osv.osv):
'create_uid': fields.many2one('res.users', 'Responsible'),
'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}),
'journal_id': fields.many2one('account.journal', 'Journal'),
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
}
_defaults = {
'date_order': fields.date.context_today,
@ -395,6 +398,9 @@ class purchase_order(osv.osv):
self.write(cr, uid, ids, {'state': 'approved', 'date_approve': fields.date.context_today(self,cr,uid,context=context)})
return True
def wkf_bid_received(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state':'bid', 'bid_date': fields.date.context_today(self,cr,uid,context=context)})
def print_confirm(self,cr,uid,ids,context=None):
print "Confirmed"
@ -408,9 +414,14 @@ class purchase_order(osv.osv):
'''
This function opens a window to compose an email, with the edi purchase template message loaded by default
'''
if not context:
context= {}
ir_model_data = self.pool.get('ir.model.data')
try:
template_id = ir_model_data.get_object_reference(cr, uid, 'purchase', 'email_template_edi_purchase')[1]
if context.get('send_rfq', False):
template_id = ir_model_data.get_object_reference(cr, uid, 'purchase', 'email_template_edi_purchase')[1]
else:
template_id = ir_model_data.get_object_reference(cr, uid, 'purchase', 'email_template_edi_purchase_done')[1]
except ValueError:
template_id = False
try:
@ -864,7 +875,8 @@ class purchase_order_line(osv.osv):
'invoice_lines': fields.many2many('account.invoice.line', 'purchase_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
'invoiced': fields.boolean('Invoiced', readonly=True),
'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner", store=True),
'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date")
'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date"),
'lead_time': fields.float('Delivery Lead Time', help="Average delay in days to deliver this product."),
}
_defaults = {
@ -1195,8 +1207,10 @@ class mail_mail(osv.Model):
def _postprocess_sent_message(self, cr, uid, mail, context=None):
if mail.model == 'purchase.order':
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'purchase.order', mail.res_id, 'send_rfq', cr)
obj = self.pool.get('purchase.order').browse(cr, uid, mail.res_id, context=context)
if obj.state == 'draft':
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'purchase.order', mail.res_id, 'send_rfq', cr)
return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context)

View File

@ -161,28 +161,31 @@
<field name="arch" type="xml">
<form string="Purchase Order" version="7.0">
<header>
<button name="wkf_send_rfq" states="draft" string="Send by Email" type="object" context="{'send_rfq':True}" class="oe_highlight"/>
<button name="wkf_send_rfq" states="sent" string="Send by Email" type="object" context="{'send_rfq':True}"/>
<button name="bid_received" states="sent" string="Bid Received" class="oe_highlight"/>
<button name="wkf_send_rfq" states="draft" string="Send RFQ by Email" type="object" context="{'send_rfq':True}" class="oe_highlight"/>
<button name="wkf_send_rfq" states="sent" string="Send RFQ by Email" type="object" context="{'send_rfq':True}"/>
<button name="print_quotation" string="Print" type="object" states="draft" class="oe_highlight" groups="base.group_user"/>
<button name="print_quotation" string="Print" type="object" states="sent" groups="base.group_user"/>
<button name="purchase_confirm" states="draft" string="Confirm Order"/>
<button name="purchase_confirm" states="sent" string="Confirm Order" class="oe_highlight"/>
<button name="wkf_send_rfq" states="confirmed" string="Resend Purchase Order" type="object" class="oe_highlight"/>
<button name="purchase_confirm" states="bid" string="Confirm Order" class="oe_highlight"/>
<button name="wkf_send_rfq" states="confirmed" string="Resend RFQ" type="object" class="oe_highlight"/>
<button name="action_cancel" states="approved,except_picking,except_invoice" string="Cancel Order" type="object" />
<button name="picking_ok" states="except_picking" string="Manually Corrected"/>
<button name="invoice_ok" states="except_invoice" string="Manually Corrected"/>
<button name="purchase_approve" states="confirmed" string="Approve Order" class="oe_highlight" groups="purchase.group_purchase_manager"/>
<button name="view_picking" string="Receive Products" type="object" attrs="{'invisible': ['|', ('shipped','=',True), ('state','!=', 'approved')]}" class="oe_highlight"/>
<button name="view_invoice" string="Receive Invoice" type="object" attrs="{'invisible': ['|', ('invoice_method','=','picking'), '|', ('state','!=', 'approved'), ('invoiced','=',True) ]}" class="oe_highlight"/>
<button name="wkf_send_rfq" states="approved" string="Send PO by Email" type="object" context="{'send_rfq':False}"/>
<button name="print_quotation" string="Print" type="object" states="approved" groups="base.group_user"/>
<button name="action_cancel_draft" states="cancel,sent,confirmed" string="Set to Draft" type="object" />
<button name="purchase_cancel" states="draft,confirmed,sent" string="Cancel Order"/>
<field name="state" widget="statusbar" statusbar_visible="draft,sent,approved,done" statusbar_colors='{"except_picking":"red","except_invoice":"red","confirmed":"blue"}' readonly="1"/>
<button name="purchase_cancel" states="draft,confirmed,sent,bid" string="Cancel Order"/>
<field name="state" widget="statusbar" statusbar_visible="draft,sent,bid,approved,done" statusbar_colors='{"except_picking":"red","except_invoice":"red","confirmed":"blue"}' readonly="1"/>
</header>
<sheet>
<div class="oe_title">
<h1>
<label string="Request for Quotation " attrs="{'invisible': [('state','not in',('draft','sent'))]}"/>
<label string="Purchase Order " attrs="{'invisible': [('state','in',('draft','sent'))]}"/>
<label string="Request for Quotation " attrs="{'invisible': [('state','not in',('draft','sent','bid'))]}"/>
<label string="Purchase Order " attrs="{'invisible': [('state','in',('draft','sent','bid'))]}"/>
<field name="name" class="oe_inline" readonly="1"/>
</h1>
</div>
@ -208,6 +211,7 @@
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
<field name="name"/>
<field name="date_planned"/>
<field name="lead_time"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="account_analytic_id" groups="purchase.group_analytic_accounting" domain="[('type','not in',('view','template'))]"/>
<field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
@ -249,6 +253,12 @@
</group>
</group>
</page>
<page string="Bid information">
<group>
<field name="bid_date"/>
<field name="bid_validity"/>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
@ -431,6 +441,7 @@
</tree>
</field>
</record>
<record id="purchase_order_line_form2" model="ir.ui.view">
<field name="name">purchase.order.line.form2</field>
<field name="model">purchase.order.line</field>
@ -483,8 +494,8 @@
<field name="product_id"/>
<field name="partner_id" string="Supplier" filter_domain="[('partner_id', 'child_of', self)]"/>
<group expand="0" string="Group By...">
<filter string="Supplier" icon="terp-partner" domain="[]" context="{'group_by' : 'partner_id'}" />
<filter string="Product" icon="terp-accessories-archiver" domain="[]" context="{'group_by' : 'product_id'}" />
<filter name="groupby_supplier" string="Supplier" icon="terp-partner" domain="[]" context="{'group_by' : 'partner_id'}" />
<filter name="groupby_product" string="Product" icon="terp-accessories-archiver" domain="[]" context="{'group_by' : 'product_id'}" />
<filter icon="terp-gtk-jump-to-rtl" string="Order Reference" domain="[]" context="{'group_by' :'order_id'}"/>
<filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by' : 'state'}" />
</group>
@ -518,6 +529,7 @@
</p>
</field>
</record>
<record id="purchase_line_form_action_tree2" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>

View File

@ -19,6 +19,12 @@
<field name="kind">function</field>
<field name="action">write({'state':'sent'})</field>
</record>
<record id="act_bid" model="workflow.activity">
<field name="wkf_id" ref="purchase_order"/>
<field name="name">bid</field>
<field name="kind">function</field>
<field name="action">wkf_bid_received()</field>
</record>
<record id="act_confirmed" model="workflow.activity">
<field name="wkf_id" ref="purchase_order"/>
<field name="name">confirmed</field>
@ -103,16 +109,26 @@
<field name="act_to" ref="act_sent"/>
<field name="signal">send_rfq</field>
</record>
<record id="trans_sent_confirmed" model="workflow.transition">
<field name="act_from" ref="act_sent"/>
<record id="trans_bid_confirmed" model="workflow.transition">
<field name="act_from" ref="act_bid"/>
<field name="act_to" ref="act_confirmed"/>
<field name="signal">purchase_confirm</field>
</record>
<record id="trans_sent_bid" model="workflow.transition">
<field name="act_from" ref="act_sent"/>
<field name="act_to" ref="act_bid"/>
<field name="signal">bid_received</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">purchase_cancel</field>
</record>
<record id="trans_bid_cancel" model="workflow.transition">
<field name="act_from" ref="act_bid"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">purchase_cancel</field>
</record>
<record id="trans_confirmed_cancel" model="workflow.transition">
<field name="act_from" ref="act_confirmed"/>

View File

@ -36,6 +36,7 @@ keep track and order all your purchase orders.
'demo': ['purchase_requisition_demo.xml'],
'data': ['security/purchase_tender.xml',
'wizard/purchase_requisition_partner_view.xml',
'wizard/bid_line_qty_view.xml',
'purchase_requisition_data.xml',
'purchase_requisition_view.xml',
'purchase_requisition_report.xml',

View File

@ -32,6 +32,18 @@ class purchase_requisition(osv.osv):
_name = "purchase.requisition"
_description="Purchase Requisition"
_inherit = ['mail.thread', 'ir.needaction_mixin']
def _get_po_line(self, cr, uid, ids, field_names, arg=None, context=None):
result = {}
if not ids: return result
for id in ids:
result.setdefault(id, [])
for element in self.browse(cr, uid, ids, context=context):
for po in element.purchase_ids:
for po_line in po.order_line:
result[po_line.order_id.requisition_id.id].append(po_line.id)
return result
_columns = {
'name': fields.char('Requisition Reference', size=32,required=True),
'origin': fields.char('Source Document', size=32),
@ -42,9 +54,10 @@ class purchase_requisition(osv.osv):
'description': fields.text('Description'),
'company_id': fields.many2one('res.company', 'Company', required=True),
'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)]}),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse'),
'state': fields.selection([('draft','New'),('in_progress','Sent to Suppliers'),('cancel','Cancelled'),('done','Purchase Done')],
'state': fields.selection([('draft','New'),('in_progress','Sent to Suppliers'),('open','Choose Lines'),('cancel','Cancelled'),('done','Purchase Done')],
'Status', track_visibility='onchange', required=True)
}
_defaults = {
@ -77,10 +90,14 @@ class purchase_requisition(osv.osv):
def tender_in_progress(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state':'in_progress'} ,context=context)
def tender_open(self, cr, uid, ids, context=None):
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'})
def tender_done(self, cr, uid, ids, context=None):
self.generate_po(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state':'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
def _planned_date(self, requisition, delay=0.0):
@ -115,6 +132,25 @@ class purchase_requisition(osv.osv):
date_planned = self._planned_date(requisition_line.requisition_id, seller_delay)
return seller_price, qty, default_uom_po_id, date_planned
def open_product_line(self, cr, uid, ids, context=None):
""" This opens product line view to view all lines from the different quotations, groupby default by product and partner to show comparaison
between supplier price
@return: the product line tree view
"""
if context is None:
context = {}
res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid ,'purchase_requisition','purchase_line_tree', context=context)
res['context'] = context
po_ids_browse = self.browse(cr, uid, ids, context=context)[0].po_line_ids
po_ids=[]
for po in po_ids_browse:
po_ids.append(po.id)
res['context'].update({
'search_default_groupby_product' : True,
})
res['domain'] = [('id','in', po_ids)]
return res
def make_purchase_order(self, cr, uid, ids, partner_id, context=None):
"""
Create New RFQ for Supplier
@ -163,6 +199,20 @@ class purchase_requisition(osv.osv):
return res
def generate_po(self, cr, uid, id, context=None):
"""
Generate all purchase order based on selected lines, should only be called on one tender at a time
"""
id_per_supplier = {}
for po_line in self.browse(cr, uid, id, context=context)[0].po_line_ids:
if po_line.state == 'confirmed':
partner = po_line.partner_id.id
if id_per_supplier.get(partner):
id_per_supplier[partner].append(po_line.id)
else:
id_per_supplier[partner] = [po_line.id]
#TODO generate po based on supplier and check if a draft po is complete before creating a new one
class purchase_requisition_line(osv.osv):
@ -174,7 +224,9 @@ class purchase_requisition_line(osv.osv):
'product_id': fields.many2one('product.product', 'Product' ),
'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')),
'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade'),
'po_line_buy': fields.many2one('purchase.order.line', 'Purchase Order Line'),
'requisition_id': fields.many2one('purchase.requisition','Purchase Requisition', 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),
}
@ -218,6 +270,24 @@ class purchase_order(osv.osv):
purchase_order()
class purchase_order_line(osv.osv):
_inherit = 'purchase.order.line'
#TODO add field function to get same value as product_qty wherever quantity_bid is zero, with an inverse fct to write on quantity_bid
_columns= {
'quantity_bid': fields.float('Quantity Bid', digits_compute=dp.get_precision('Product Unit of Measure')),
}
def action_draft(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'draft'}, context=context)
def action_confirm(self, cr, uid, ids, context=None):
super(purchase_order_line, self).action_confirm(cr, uid, ids, context=context)
for element in self.browse(cr, uid, ids, context=context):
if not element.quantity_bid:
self.write(cr, uid, ids, {'quantity_bid': element.product_qty}, context=context)
return True
class product_product(osv.osv):
_inherit = 'product.product'

View File

@ -31,12 +31,17 @@
<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_reset" states="done,cancel" string="Reset to Draft" type="object" />
<button name="tender_done" states="in_progress" string="Purchase Done" type="object" class="oe_highlight"/>
<button name="tender_open" states="in_progress" string="Choosing Supplier(s)" type="object" class="oe_highlight"/>
<button name="tender_reset" states="cancel" string="Reset to Draft" type="object" />
<button name="tender_done" states="open" string="Make Purchase" type="object" class="oe_highlight"/>
<button name="tender_cancel" states="draft,in_progress" string="Cancel Requisition" type="object" />
<field name="state" widget="statusbar" statusbar_visible="draft,in_progress,done" statusbar_colors='{"in_progress":"blue"}'/>
<field name="state" widget="statusbar" statusbar_visible="draft,in_progress,open,done" statusbar_colors='{"in_progress":"blue"}'/>
</header>
<sheet>
<div class="oe_right oe_button_box" style="margin-top: 10px">
<button name="open_product_line" type="object" string="View Products Lines"
attrs="{'invisible': [('state', 'not in', ('open','done'))]}"/>
</div>
<div class="oe_edit_only">
<label for="name" class="oe_inline"/>
<label for="origin" class="oe_inline"/>
@ -78,7 +83,7 @@
<div class="oe_right oe_button_box" style="margin-top: 10px">
<button name="%(action_purchase_requisition_partner)d" type="action"
string="Request a Quotation" icon="gtk-execute"
attrs="{'invisible': [('line_ids','=',False),('state', 'not in', ('in_progress'))]}"/>
attrs="{'invisible': ['|', ('line_ids','=',[]),('state', 'in', ('open','done'))]}"/>
</div>
<separator string="Quotations"/>
<field name="purchase_ids" readonly="1">
@ -206,5 +211,46 @@
res_model="purchase.order"
src_model="purchase.requisition"/>
<record id="purchase_order_line_tree_tender" model="ir.ui.view">
<field name="name">purchase.order.line.tree.tender</field>
<field name="model">purchase.order.line</field>
<field name="arch" type="xml">
<tree string="Purchase Order Lines" create="false" colors="blue:state == 'confirmed';gray:state == 'cancel'">
<field name="name"/>
<field name="partner_id" string="Supplier" />
<field name="product_id"/>
<field name="price_unit"/>
<field name="product_qty"/>
<field name="quantity_bid"/>
<field name="product_uom" groups="product.group_uom"/>
<field name="price_subtotal"/>
<field name="lead_time" />
<field name="state" invisible="1"/>
<field name="invoiced" invisible="1"/>
<button name="action_draft" states="confirmed" type="object" string="Cancel Bid" icon="gtk-cancel"/>
<button name="%(action_bid_line_qty)d" type="action" states="draft" string="Change Quantity" icon="gtk-ok"/>
<button name="action_confirm" states="draft" type="object" string="Confirm Order" icon="gtk-apply"/>
</tree>
</field>
</record>
<record id="purchase_line_tree" model="ir.actions.act_window">
<field name="name">Bid Lines</field>
<field name="res_model">purchase.order.line</field>
<field name="context">{"search_default_groupby_product" : True,}</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="search_view_id" ref="purchase.purchase_order_line_search"/>
</record>
<record id="purchase_line_tree_action" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="purchase_order_line_tree_tender"/>
<field name="act_window_id" ref="purchase_line_tree"/>
</record>
</data>
</openerp>

View File

@ -20,6 +20,7 @@
##############################################################################
import purchase_requisition_partner
import bid_line_qty
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from openerp.osv import fields, osv
from openerp.osv.orm import browse_record, browse_null
from openerp.tools.translate import _
import openerp.addons.decimal_precision as dp
class bid_line_qty(osv.osv_memory):
_name = "bid.line.qty"
_description = "Change Bid line quantity"
_columns = {
'qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
}
def change_qty(self, cr, uid, ids, context=None):
active_ids = context and context.get('active_ids', [])
data = self.browse(cr, uid, ids, context=context)[0]
self.pool.get('purchase.order.line').write(cr, uid, active_ids, {'quantity_bid':data.qty})#.make_purchase_order(cr, uid, active_ids, data.partner_id.id, context=context)
return {'type': 'ir.actions.act_window_close'}
bid_line_qty()

View File

@ -0,0 +1,31 @@
<openerp>
<data>
<record id="view_bid_line_qty" model="ir.ui.view">
<field name="name">Quantity to Purchase</field>
<field name="model">bid.line.qty</field>
<field name="arch" type="xml">
<form string="Quantity" version="7.0">
<group>
<field name="qty" context="{'default_qty': 0}"/>
</group>
<footer>
<button name="change_qty" string="Change Quantity" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_bid_line_qty" model="ir.actions.act_window">
<field name="name">Bid Line Qty</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bid.line.qty</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -49,5 +49,4 @@ class purchase_requisition_partner(osv.osv_memory):
purchase_requisition_partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -27,5 +27,6 @@
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
</data>
</openerp>