[IMP] stock: Log if a method doesn't exist when running scheduler

Purpose
=======

If a method doesn't exist when running scheduler, log an error instead of raising an AttributeError

The goal of a cron method is to go ad far as possible.
This commit is contained in:
Yannick Tivisse
2017-11-16 14:49:05 +01:00
parent 31e3a97577
commit 16a2f91832
+4 -1
View File
@@ -184,7 +184,10 @@ class ProcurementGroup(models.Model):
if not rule:
raise UserError(_('No procurement rule found. Please verify the configuration of your routes'))
getattr(rule, '_run_%s' % rule.action)(product_id, product_qty, product_uom, location_id, name, origin, values)
if hasattr(rule, '_run_%s' % rule.action):
getattr(rule, '_run_%s' % rule.action)(product_id, product_qty, product_uom, location_id, name, origin, values)
else:
_logger.error("The method _run_%s doesn't exist on the procument rules" % rule.action)
return True
@api.model