From 4dfe00adee073a3352d391bb07bf7aed77dc06fb Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 3 Nov 2010 13:47:13 +0530 Subject: [PATCH] [FIX] Account: account journals code and journal name should be unique lp bug: https://launchpad.net/bugs/669532 fixed bzr revid: mra@mra-laptop-20101103081713-p0hgynh02lr0v2wp --- addons/account/account.py | 13 +++++++++++++ addons/account/demo/account_minimal.xml | 14 +++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 507d1d392d9..90947a59ae4 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -614,9 +614,22 @@ class account_journal(osv.osv): 'user_id': lambda self,cr,uid,context: uid, 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } + _sql_constraints = [ + ('code_company_uniq', 'unique (code, company_id)', 'The code of the journal must be unique per company !'), + ('name_company_uniq', 'unique (name, company_id)', 'The name of the journal must be unique per company !'), + ] _order = 'code' + def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False): + journal = self.browse(cr, uid, id, context=context) + if not default: + default = {} + default = default.copy() + default['code'] = (journal['code'] or '') + '(copy)' + default['name'] = (journal['name'] or '') + '(copy)' + return super(account_journal, self).copy(cr, uid, id, default, context=context) + def write(self, cr, uid, ids, vals, context=None): if 'company_id' in vals: move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)]) diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index 87c8a37254d..d17fe1d760c 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -342,7 +342,7 @@ Sales Journal - (test) - SAJ + SAJ - (test) sale @@ -353,7 +353,7 @@ Sales Credit Note Journal - (test) - SCNJ + SCNJ- (test) sale_refund @@ -366,7 +366,7 @@ Expenses Journal - (test) - EXJ + EXJ- (test) purchase @@ -377,7 +377,7 @@ Expenses Credit Notes Journal - (test) - ECNJ + ECNJ- (test) purchase_refund @@ -390,7 +390,7 @@ Bank Journal - (test) - BNK + BNK- (test) bank @@ -401,7 +401,7 @@ Checks Journal - (test) - CHK + CHK- (test) bank @@ -412,7 +412,7 @@ Cash Journal - (test) - CSH + CSH- (test) cash