From d35be1e671edbf6636654a169d079bc2dca24ce2 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sun, 4 Jan 2015 13:59:29 +0100 Subject: [PATCH 1/4] [FIX] Module account_banking: Solve issue https://github.com/OCA/bank-payment/issues/88 Conflict between account_banking and Cash Management. Not all views for account.bank.statement.line have the state field. This conflicts with fields added to the model that have readonly conditioned on state. Solved by moving readonly attribute from model to banking views. --- account_banking/account_banking.py | 29 +--------- account_banking/account_banking_view.xml | 69 +++++++++++++++++++++--- 2 files changed, 62 insertions(+), 36 deletions(-) diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index 67113d4b6..c2187ecba 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -504,7 +504,6 @@ class account_bank_statement_line(orm.Model): 1. Extra links to account.period and res.partner.bank for tracing and matching. 2. Extra 'trans' field to carry the transaction id of the bank. - 3. Readonly states for most fields except when in draft. ''' _inherit = 'account.bank.statement.line' _description = 'Bank Transaction' @@ -548,57 +547,31 @@ class account_bank_statement_line(orm.Model): _columns = { # Redefines. Todo: refactor away to view attrs - 'amount': fields.float( - 'Amount', - readonly=True, - digits_compute=dp.get_precision('Account'), - states={'draft': [('readonly', False)]}, - ), - 'ref': fields.char( - 'Ref.', - size=32, - readonly=True, - states={'draft': [('readonly', False)]}, - ), + # Only name left because of required False. Is this needed? 'name': fields.char( 'Name', size=64, required=False, - readonly=True, - states={'draft': [('readonly', False)]}, - ), - 'date': fields.date( - 'Date', - required=True, - readonly=True, - states={'draft': [('readonly', False)]}, ), # New columns 'trans': fields.char( 'Bank Transaction ID', size=15, required=False, - readonly=True, - states={'draft': [('readonly', False)]}, ), 'partner_bank_id': fields.many2one( 'res.partner.bank', 'Bank Account', required=False, - readonly=True, - states={'draft': [('readonly', False)]}, ), 'period_id': fields.many2one( 'account.period', 'Period', - required=True, - states={'confirmed': [('readonly', True)]}, ), 'currency': fields.many2one( 'res.currency', 'Currency', required=True, - states={'confirmed': [('readonly', True)]}, ), 'reconcile_id': fields.many2one( 'account.move.reconcile', diff --git a/account_banking/account_banking_view.xml b/account_banking/account_banking_view.xml index e56f2e62e..338af42a6 100644 --- a/account_banking/account_banking_view.xml +++ b/account_banking/account_banking_view.xml @@ -278,6 +278,37 @@ + + + {'readonly': [('state','!=','draft'),]} + + + {'readonly': [('state','!=','draft'),]} + + + {'readonly': [('state','!=','draft'),]} + + + {'readonly': [('state','!=','draft'),]} + + + {'readonly': [('state','!=','draft'),]} + @@ -295,9 +326,18 @@ - - - + + +