[FIX] purchase, procurement: workflow of procurement order fixed
bzr revid: qdp-launchpad@openerp.com-20121214163921-hevj7um2n7jf8e1p
This commit is contained in:
parent
3c7cd8f24d
commit
0c0c081676
|
@ -274,37 +274,9 @@ class procurement_order(osv.osv):
|
|||
return True
|
||||
|
||||
def check_buy(self, cr, uid, ids):
|
||||
""" Checks product type.
|
||||
@return: True or Product Id.
|
||||
"""ability of the workflow to manage the supply_method == 'buy'.
|
||||
"""
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid)
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
for procurement in self.browse(cr, uid, ids):
|
||||
if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
|
||||
return False
|
||||
if not procurement.product_id.seller_ids:
|
||||
message = _('No supplier defined for this product !')
|
||||
self.message_post(cr, uid, [procurement.id], body=message)
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
|
||||
return False
|
||||
partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement.
|
||||
|
||||
if not partner:
|
||||
message = _('No default supplier defined for this product')
|
||||
self.message_post(cr, uid, [procurement.id], body=message)
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
|
||||
return False
|
||||
if user.company_id and user.company_id.partner_id:
|
||||
if partner.id == user.company_id.partner_id.id:
|
||||
raise osv.except_osv(_('Configuration Error!'), _('The product "%s" has been defined with your company as reseller which seems to be a configuration error!' % procurement.product_id.name))
|
||||
|
||||
address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
|
||||
if not address_id:
|
||||
message = _('No address defined for the supplier')
|
||||
self.message_post(cr, uid, [procurement.id], body=message)
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
||||
def test_cancel(self, cr, uid, ids):
|
||||
""" Tests whether state of move is cancelled or not.
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<field name="action">write({'state':'exception'})</field>
|
||||
<field name="join_mode">AND</field>
|
||||
</record>
|
||||
<!-- to check... what's the use? mrp_jit, i guess -->
|
||||
<record id="act_confirm_temp" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_procurement"/>
|
||||
<field name="name">confirm_temp</field>
|
||||
|
@ -47,16 +48,6 @@
|
|||
<field name="wkf_id" ref="wkf_procurement"/>
|
||||
<field name="name">confirm_mto</field>
|
||||
</record>
|
||||
<record id="act_buy" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_procurement"/>
|
||||
<field name="name">buy</field>
|
||||
<field name="split_mode">OR</field>
|
||||
</record>
|
||||
<record id="act_buy_end" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_procurement"/>
|
||||
<field name="name">buy_end</field>
|
||||
<field name="join_mode">AND</field>
|
||||
</record>
|
||||
<record id="act_make_to_stock" model="workflow.activity">
|
||||
<field name="wkf_id" ref="wkf_procurement"/>
|
||||
<field name="name">make_to_stock</field>
|
||||
|
@ -116,6 +107,7 @@
|
|||
<field name="signal">button_check</field>
|
||||
<field name="condition">not test_cancel()</field>
|
||||
</record>
|
||||
<!-- to check... what's the use? mrp_jit, i guess -->
|
||||
<record id="trans_confirm_temp_confirm_wait" model="workflow.transition">
|
||||
<field name="act_from" ref="act_confirm_temp"/>
|
||||
<field name="act_to" ref="act_confirm_wait"/>
|
||||
|
@ -150,18 +142,6 @@
|
|||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">button_cancel</field>
|
||||
</record>
|
||||
<record id="trans_confirm_mto_purchase" model="workflow.transition">
|
||||
<field name="act_from" ref="act_confirm_mto"/>
|
||||
<field name="act_to" ref="act_buy"/>
|
||||
<field name="condition">check_buy()</field>
|
||||
</record>
|
||||
<record id="trans_buy_buy_end" model="workflow.transition">
|
||||
<field name="act_from" ref="act_buy"/>
|
||||
<field name="act_to" ref="act_buy_end"/>
|
||||
</record>
|
||||
<record id="trans_buy_done" model="workflow.transition">
|
||||
<field name="act_from" ref="act_buy_end"/>
|
||||
<field name="act_to" ref="act_make_done"/>
|
||||
</record>
|
||||
<record id="trans_confirm_mto_confirm" model="workflow.transition">
|
||||
<field name="act_from" ref="act_confirm_mto"/>
|
||||
|
@ -182,7 +162,7 @@
|
|||
<record id="trans_confirm_mto_make_done" model="workflow.transition">
|
||||
<field name="act_from" ref="act_confirm_mto"/>
|
||||
<field name="act_to" ref="act_make_done"/>
|
||||
<field name="condition">not check_produce()</field>
|
||||
<field name="condition">not check_produce() and not check_buy()</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_make_to_stock_make_done" model="workflow.transition">
|
||||
|
|
|
@ -1041,6 +1041,43 @@ class procurement_order(osv.osv):
|
|||
'purchase_id': fields.many2one('purchase.order', 'Purchase Order'),
|
||||
}
|
||||
|
||||
def check_buy(self, cr, uid, ids):
|
||||
''' return True if the supply method of the mto product is 'buy'
|
||||
'''
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid)
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
for procurement in self.browse(cr, uid, ids):
|
||||
if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_supplier_info(self, cr, uid, ids, context=None):
|
||||
for procurement in self.browse(cr, uid, ids, context=context):
|
||||
if not procurement.product_id.seller_ids:
|
||||
message = _('No supplier defined for this product !')
|
||||
self.message_post(cr, uid, [procurement.id], body=message)
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
|
||||
return False
|
||||
partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement.
|
||||
|
||||
if not partner:
|
||||
message = _('No default supplier defined for this product')
|
||||
self.message_post(cr, uid, [procurement.id], body=message)
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
|
||||
return False
|
||||
if user.company_id and user.company_id.partner_id:
|
||||
if partner.id == user.company_id.partner_id.id:
|
||||
raise osv.except_osv(_('Configuration Error!'), _('The product "%s" has been defined with your company as reseller which seems to be a configuration error!' % procurement.product_id.name))
|
||||
|
||||
address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
|
||||
if not address_id:
|
||||
message = _('No address defined for the supplier')
|
||||
self.message_post(cr, uid, [procurement.id], body=message)
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def action_po_assign(self, cr, uid, ids, context=None):
|
||||
""" This is action which call from workflow to assign purchase order to procurements
|
||||
@return: True
|
||||
|
|
|
@ -201,29 +201,30 @@
|
|||
<field name="act_from" ref="act_invoice_end"/>
|
||||
<field name="act_to" ref="act_done"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Procurement -->
|
||||
<record id="act_buy_sub" model="workflow.activity">
|
||||
<record id="act_buy" model="workflow.activity">
|
||||
<field name="wkf_id" ref="procurement.wkf_procurement"/>
|
||||
<field name="name">buy_subflows</field>
|
||||
<field name="name">buy</field>
|
||||
<field name="kind">subflow</field>
|
||||
<field name="subflow_id" search="[('osv','=','purchase.order')]"/>
|
||||
<field name="action">action_po_assign()</field>
|
||||
</record>
|
||||
|
||||
<record id="trans_buy_buy_sub" model="workflow.transition">
|
||||
<field name="act_from" ref="procurement.act_buy"/>
|
||||
<field name="act_to" ref="act_buy_sub"/>
|
||||
|
||||
<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>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="trans_buy_make_done" model="workflow.transition">
|
||||
<field name="act_from" ref="act_buy_sub"/>
|
||||
<field name="act_to" ref="procurement.act_buy_end"/>
|
||||
<field name="act_from" ref="act_buy"/>
|
||||
<field name="act_to" ref="procurement.act_make_done"/>
|
||||
<field name="signal">subflow.delivery_done</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="trans_buy_cancel" model="workflow.transition">
|
||||
<field name="act_from" ref="act_buy_sub"/>
|
||||
<field name="act_from" ref="act_buy"/>
|
||||
<field name="act_to" ref="procurement.act_cancel"/>
|
||||
<field name="signal">subflow.cancel</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue