diff --git a/pingen/ir_attachment.py b/pingen/ir_attachment.py index 6b9b256..cbb950d 100644 --- a/pingen/ir_attachment.py +++ b/pingen/ir_attachment.py @@ -85,7 +85,6 @@ class ir_attachment(orm.Model): else: if document: if document.state == 'pushed': - # TODO: cancel on pingen.com raise osv.except_osv( _('Error'), _('The attachment %s is already pushed to pingen.com.') % \ diff --git a/pingen/pingen.py b/pingen/pingen.py index da1378a..b460618 100644 --- a/pingen/pingen.py +++ b/pingen/pingen.py @@ -37,6 +37,7 @@ POST_SENDING_STATUS = { 400: 'Sending cancelled', } + class PingenException(RuntimeError): """There was an ambiguous exception that occurred while handling your request.""" @@ -51,8 +52,7 @@ class APIError(PingenException): class Pingen(object): - """ Interface to pingen.com API - """ + """ Interface to the pingen.com API """ def __init__(self, token, staging=True): self._token = token diff --git a/pingen/pingen_document.py b/pingen/pingen_document.py index 074f6c5..522b2c2 100644 --- a/pingen/pingen_document.py +++ b/pingen/pingen_document.py @@ -91,7 +91,7 @@ class pingen_document(orm.Model): ] def _get_pingen_session(self, cr, uid, context=None): - """ Returns a pingen session for a user""" + """ Returns a pingen session for a user """ company = self.pool.get('res.users').browse( cr, uid, uid, context=context).company_id return self.pool.get('res.company')._pingen(cr, uid, company, context=context) @@ -99,7 +99,7 @@ class pingen_document(orm.Model): def _push_to_pingen(self, cr, uid, document, pingen=None, context=None): """ Push a document to pingen.com - :param Pingen pingen: optional pingen object to, reuse session + :param Pingen pingen: optional pingen object to reuse session """ attachment_obj = self.pool.get('ir.attachment') @@ -224,12 +224,13 @@ class pingen_document(orm.Model): loc_cr.rollback() raise - loc_cr.commit() + else: + loc_cr.commit() return True def _resolve_error(self, cr, uid, document, context=None): - """ A document as resolved, put in the correct state""" + """ A document as resolved, put in the correct state """ if document.post_id: state = 'sendcenter' elif document.pingen_id: @@ -239,7 +240,7 @@ class pingen_document(orm.Model): document.write({'state': state}, context=context) def resolve_error(self, cr, uid, ids, context=None): - """ A document as resolved, put in the correct state""" + """ A document as resolved, put in the correct state """ for document in self.browse(cr, uid, ids, context=context): self._resolve_error(cr, uid, document, context=context) return True @@ -380,8 +381,8 @@ class pingen_document(orm.Model): _logger.error('Unexcepted error in pingen cron') loc_cr.rollback() raise - - loc_cr.commit() + else: + loc_cr.commit() return True def update_post_infos(self, cr, uid, ids, context=None):