[FIX] purchase: reduce the number of mail messages sent to when procurement in exception
lp bug: https://launchpad.net/bugs/1233730 fixed bzr revid: mat@openerp.com-20131004140602-8gic5ojgadso5801
This commit is contained in:
parent
c536c5a432
commit
dbac14474f
|
@ -1035,28 +1035,27 @@ class procurement_order(osv.osv):
|
|||
partner_obj = self.pool.get('res.partner')
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
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
|
||||
message = ''
|
||||
partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement.
|
||||
|
||||
if not partner:
|
||||
if not procurement.product_id.seller_ids:
|
||||
message = _('No supplier defined for this product !')
|
||||
elif not partner:
|
||||
message = _('No default supplier defined for this product')
|
||||
elif not partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']:
|
||||
message = _('No address defined for the supplier')
|
||||
|
||||
if message:
|
||||
if procurement.message != message:
|
||||
# avoid sending too many messages
|
||||
self.message_post(cr, uid, [procurement.id], body=message)
|
||||
cr.execute('update procurement_order set message=%s where id=%s', (message, procurement.id))
|
||||
self.write(cr, uid, [procurement.id], {'message':message}, context=context)
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue