openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #02723
lp:~camptocamp/openerp-humanitarian-ngo/add-bid_selected_state_on_po-nbi into lp:openerp-humanitarian-ngo/purchase-wkfl
Nicolas Bessi - Camptocamp has proposed merging lp:~camptocamp/openerp-humanitarian-ngo/add-bid_selected_state_on_po-nbi into lp:openerp-humanitarian-ngo/purchase-wkfl.
Requested reviews:
OpenERP for Humanitarian Core Editors (humanitarian-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/openerp-humanitarian-ngo/add-bid_selected_state_on_po-nbi/+merge/200799
--
https://code.launchpad.net/~camptocamp/openerp-humanitarian-ngo/add-bid_selected_state_on_po-nbi/+merge/200799
Your team OpenERP for Humanitarian Core Editors is requested to review the proposed merge of lp:~camptocamp/openerp-humanitarian-ngo/add-bid_selected_state_on_po-nbi into lp:openerp-humanitarian-ngo/purchase-wkfl.
=== modified file 'purchase_extended/model/purchase_order.py'
--- purchase_extended/model/purchase_order.py 2013-11-01 11:44:19 +0000
+++ purchase_extended/model/purchase_order.py 2014-01-08 10:32:14 +0000
@@ -14,6 +14,7 @@
('sent', 'RFQ Sent'),
('draftbid', 'Draft Bid'), # added
('bid', 'Bid Encoded'), # Bid Received renamed into Bid Encoded
+ ('bid_selected', 'Bid selected'), # added
('draftpo', 'Draft PO'), # added
('confirmed', 'Waiting Approval'),
('approved', 'Purchase Confirmed'),
@@ -236,17 +237,22 @@
value['value']['dest_address_id'] = dest_id
return value
+ def po_tender_requisition_selected(self, cr, uid, ids, context=None):
+ """Workflow function that write state 'bid selected'"""
+ return self.write(cr, uid, ids, {'state': 'bid_selected'},
+ context=context)
+
class purchase_order_line(orm.Model):
_inherit = 'purchase.order.line'
def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
- name=False, price_unit=False, state='draft', context=None):
+ name=False, price_unit=False, context=None, state='draft', type='rfq', **kwargs):
res = super(purchase_order_line, self).onchange_product_id(cr, uid, ids,
pricelist_id, product_id, qty, uom_id, partner_id, date_order,
- fiscal_position_id, date_planned, name, price_unit, state, context)
- if state == 'draft':
+ fiscal_position_id, date_planned, name, price_unit, context)
+ if state == 'draft' and type == 'bid':
res['value'].update({'price_unit': 0})
elif state in ('sent', 'draftbid', 'bid'):
if 'price_unit' in res['value']:
=== modified file 'purchase_extended/view/purchase_order.xml'
--- purchase_extended/view/purchase_order.xml 2013-08-13 13:20:04 +0000
+++ purchase_extended/view/purchase_order.xml 2014-01-08 10:32:14 +0000
@@ -56,6 +56,12 @@
<button name="draft_po" states="draft" string="Convert to PO"/>
<button name="draft_po" states="bid" string="Convert to PO" class="oe_highlight"/>
</xpath>
+ <field name="product_id" position="replace">
+ <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,parent.state,parent.type)"/>
+ </field>
+ <field name="product_qty" position="replace">
+ <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,parent.state,parent.type)"/>
+ </field>
</field>
</record>
<record id="purchase.purchase_rfq" model="ir.actions.act_window">
@@ -76,5 +82,19 @@
</xpath>
</field>
</record>
+
+ <record id="on_change_on_po_line_form" model="ir.ui.view">
+ <field name="name">on change on po line form</field>
+ <field name="model">purchase.order.line</field>
+ <field name="inherit_id" ref="purchase.purchase_order_line_form" />
+ <field name="arch" type="xml">
+ <field name="product_id" position="replace">
+ <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,parent.state,parent.type)"/>
+ </field>
+ <field name="product_qty" position="replace">
+ <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,parent.state,parent.type)"/>
+ </field>
+ </field>
+ </record>
</data>
</openerp>
=== modified file 'purchase_extended/workflow/purchase_order.xml'
--- purchase_extended/workflow/purchase_order.xml 2013-08-07 12:39:30 +0000
+++ purchase_extended/workflow/purchase_order.xml 2014-01-08 10:32:14 +0000
@@ -55,6 +55,20 @@
<field name="signal">purchase_cancel</field>
</record>
+ <record id="act_po_requisition_selected" model="workflow.activity">
+ <field name="wkf_id" ref="purchase.purchase_order"/>
+ <field name="name">Bid selected</field>
+ <field name="kind">function</field>
+ <field name="action">po_tender_requisition_selected()</field>
+ <field name="flow_stop">True</field>
+ </record>
+ <record id="trans_po_requisition_selected" model="workflow.transition">
+ <field name="act_from" ref="purchase.act_bid"/>
+ <field name="act_to" ref="act_po_requisition_selected"/>
+ <field name="signal">select_requisition</field>
+ </record>
+
+
<!-- Rename some activities to make the workflow clear -->
<record id="purchase.act_draft" model="workflow.activity">
<field name="name">draft RFQ</field>
=== modified file 'purchase_requisition_extended/model/purchase_requisition.py'
--- purchase_requisition_extended/model/purchase_requisition.py 2013-11-01 11:44:19 +0000
+++ purchase_requisition_extended/model/purchase_requisition.py 2014-01-08 10:32:14 +0000
@@ -142,18 +142,34 @@
context=context)
return super(PurchaseRequisition, self).generate_po(cr, uid, [ids], context=context)
+ def quotation_selected(self, cr, uid, quotation, context=None):
+ """Predicate that checks if a quotation has at least one line chosen
+ :param quotation: record of 'purchase.order'
+
+ :returns: True if one line has been chosen
+
+ """
+ # This topic is subject to changes
+ return quotation.bid_partial
+
def cancel_quotation(self, cr, uid, tender, context=None):
"""
Called from generate_po. Cancel only draft and sent rfq
"""
po = self.pool.get('purchase.order')
wf_service = netsvc.LocalService("workflow")
+ tender.refresh()
for quotation in tender.purchase_ids:
- if quotation.state in ['draft', 'sent']:
- wf_service.trg_validate(uid, 'purchase.order', quotation.id, 'purchase_cancel', cr)
- po.message_post(cr, uid, [quotation.id],
- body=_('Canceled by the call for bids associated to this request for quotation.'),
- context=context)
+ if quotation.state in ['draft', 'sent', 'bid']:
+ if self.quotation_selected(cr, uid, quotation, context=context):
+ wf_service.trg_validate(uid, 'purchase.order', quotation.id,
+ 'select_requisition', cr)
+ else:
+ wf_service.trg_validate(uid, 'purchase.order', quotation.id, 'purchase_cancel', cr)
+ po.message_post(cr, uid, [quotation.id],
+ body=_('Canceled by the call for bids associated'
+ ' to this request for quotation.'),
+ context=context)
return True
@@ -226,19 +242,6 @@
res['domain'] = expression.AND([eval(res.get('domain', [])), [('requisition_id', 'in', ids)]])
return res
- def open_product_line(self, cr, uid, ids, context=None):
- """ Filter to show only lines from bids received. Group by requisition line instead of product for unicity
- """
- res = super(PurchaseRequisition, self).open_product_line(cr, uid, ids, context=context)
- ctx = res.setdefault('context', {})
- if 'search_default_groupby_product' in ctx:
- del ctx['search_default_groupby_product']
- if 'search_default_hide_cancelled' in ctx:
- del ctx['search_default_hide_cancelled']
- ctx['search_default_groupby_requisitionline'] = True
- ctx['search_default_showbids'] = True
- return res
-
def close_callforbids(self, cr, uid, ids, context=None):
"""
Check all quantities have been sourced
@@ -289,6 +292,19 @@
'context': ctx,
}
+ def open_product_line(self, cr, uid, ids, context=None):
+ """ Filter to show only lines from bids received. Group by requisition line instead of product for unicity
+ """
+ res = super(PurchaseRequisition, self).open_product_line(cr, uid, ids, context=context)
+ ctx = res.setdefault('context', {})
+ if 'search_default_groupby_product' in ctx:
+ del ctx['search_default_groupby_product']
+ if 'search_default_hide_cancelled' in ctx:
+ del ctx['search_default_hide_cancelled']
+ ctx['search_default_groupby_requisitionline'] = True
+ ctx['search_default_showbids'] = True
+ return res
+
def close_callforbids_ok(self, cr, uid, ids, context=None):
wf_service = netsvc.LocalService("workflow")
for id in ids:
References