+ }
+
+ def check_opening_journal(self, cr, uid, ids, context=None):
+ """
+ This constraint will check than the journal is not used twice in the system,
+ to avoid a concurrency opening of this journal.
+ """
+ for cash in self.browse(cr, uid, ids, context=None):
+ domain = [
+ ('id', '!=', cash.id),
+ ('journal_id', '=', cash.journal_id.id),
+ ('journal_id.type', '=', 'cash'),
+ ('state', 'in', ('open',)),
+ ]
+ count = self.search_count(cr, uid, domain, context=context)
+
+ if count:
+ return False
+ return True
+
+ _constraints = [
+ (check_opening_journal, "The selected journal has been opened !", ['journal_id']),
+ ]