From 9527a10ba50520bade31e8be081aa200bf0dcced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?= Date: Fri, 26 Oct 2012 13:16:41 +0200 Subject: [PATCH] [IMP] Forbid to change the journal of a bank statement if you already have a line in it. This is done in the voucher, cause this is the case that break : when voucher is created and you change the journal, it'll result in having entries generated on various journal which is not consistent. bzr revid: joel.grandguillaume@camptocamp.com-20121026111641-a0lg5h1mcyh1tit7 --- addons/account_voucher/account_voucher.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index f25318727df..3e9fe15d3d1 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1532,7 +1532,17 @@ class account_bank_statement(osv.osv): }) return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context) - return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context) + + def write(self, cr, uid, ids, vals, context=None): + # We should not be able to change the journal if we already have + # bank statement line generated in case we use the voucher. This is because + # the import feature will write the current used journal. That lead to crap + # cause we should not be able to do that... A bank statement is by definition linked + # to one journal ! + for bk_st in self.browse(cr, uid, ids, context=context): + if vals.get('journal_id', False) and bk_st.line_ids: + raise osv.except_osv(_('Unable to change journal !'), _('You can not change the journal if you already generated lines !')) + return super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) account_bank_statement()