diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py
index ea396b61491..68360152399 100644
--- a/addons/procurement/procurement.py
+++ b/addons/procurement/procurement.py
@@ -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.
diff --git a/addons/procurement/procurement_workflow.xml b/addons/procurement/procurement_workflow.xml
index 1ac0453b0c5..12c20393310 100644
--- a/addons/procurement/procurement_workflow.xml
+++ b/addons/procurement/procurement_workflow.xml
@@ -34,6 +34,7 @@
write({'state':'exception'})
AND
+
confirm_temp
@@ -47,16 +48,6 @@
confirm_mto
-
-
- buy
- OR
-
-
-
- buy_end
- AND
-
make_to_stock
@@ -116,6 +107,7 @@
button_check
not test_cancel()
+
@@ -150,18 +142,6 @@
button_cancel
-
-
-
- check_buy()
-
-
-
-
-
-
-
-
@@ -182,7 +162,7 @@
- not check_produce()
+ not check_produce() and not check_buy()
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 5a12b17333a..47ae0eaa325 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -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
diff --git a/addons/purchase/purchase_workflow.xml b/addons/purchase/purchase_workflow.xml
index be2313a151a..11936db0bed 100644
--- a/addons/purchase/purchase_workflow.xml
+++ b/addons/purchase/purchase_workflow.xml
@@ -201,29 +201,30 @@
-
+
-
+
- buy_subflows
+ buy
subflow
action_po_assign()
-
-
-
-
+
+
+
+
+ check_buy() and check_supplier_info()
-
+
-
-
+
+
subflow.delivery_done
-
+
-
+
subflow.cancel