Merge pull request #79 from mdietrichc2c/add-error-message-history

Add history line + error message if reconciliation fails
This commit is contained in:
Leonardo Pistone
2015-01-08 13:02:56 +01:00
2 changed files with 24 additions and 0 deletions

View File

@@ -25,6 +25,9 @@ from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from openerp.tools.translate import _
from openerp import pooler
import logging
_logger = logging.getLogger(__name__)
class EasyReconcileOptions(orm.AbstractModel):
"""Options of a reconciliation profile
@@ -139,6 +142,7 @@ class AccountEasyReconcileMethod(orm.Model):
class AccountEasyReconcile(orm.Model):
_name = 'account.easy.reconcile'
_inherit = ['mail.thread']
_description = 'account easy reconcile'
def _get_total_unrec(self, cr, uid, ids, name, arg, context=None):
@@ -283,6 +287,22 @@ class AccountEasyReconcile(orm.Model):
'reconcile_ids': [(4, rid) for rid in reconcile_ids],
'reconcile_partial_ids': [(4, rid) for rid in partial_ids],
}, context=context)
except Exception as e:
# In case of error, we log it in the mail thread, log the
# stack trace and create an empty history line; otherwise,
# the cron will just loop on this reconcile task.
_logger.exception("The reconcile task %s had an exception: %s",
rec.name, e.value)
message = "There was an error during reconciliation : %s" \
% e.value
self.message_post(cr, uid, rec.id,
body=message, context=context)
self.pool.get('easy.reconcile.history').create(new_cr, uid, {
'easy_reconcile_id': rec.id,
'date': fields.datetime.now(),
'reconcile_ids': [],
'reconcile_partial_ids': [],
})
finally:
if ctx['commit_every']:
new_cr.commit()

View File

@@ -71,6 +71,10 @@ The lines should have the same amount (with the write-off) and the same referenc
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>