mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[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.
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -278,6 +278,37 @@
|
||||
<field name="invoice_id"/>
|
||||
<field name="reconcile_id"/>
|
||||
</xpath>
|
||||
<!-- Many fields readonly when state != draft -->
|
||||
<xpath
|
||||
expr="//field[@name='line_ids']/tree/field[@name='amount']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute name="attrs">{'readonly': [('state','!=','draft'),]}</attribute>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='line_ids']/tree/field[@name='ref']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute name="attrs">{'readonly': [('state','!=','draft'),]}</attribute>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='line_ids']/tree/field[@name='name']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute name="attrs">{'readonly': [('state','!=','draft'),]}</attribute>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='line_ids']/tree/field[@name='date']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute name="attrs">{'readonly': [('state','!=','draft'),]}</attribute>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='line_ids']/tree/field[@name='partner_bank_id']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute name="attrs">{'readonly': [('state','!=','draft'),]}</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='line_ids']/form//field[@name='amount']"
|
||||
position="after">
|
||||
@@ -295,9 +326,18 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Statement lines" colors="black:state == 'confirmed';darkmagenta:match_multi == True;crimson:duplicate == True;grey:state=='draft';">
|
||||
<field name="sequence" readonly="1" invisible="1"/>
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field
|
||||
name="date"
|
||||
attrs="{'readonly': [('state','!=','draft'),]}"
|
||||
/>
|
||||
<field
|
||||
name="name"
|
||||
attrs="{'readonly': [('state','!=','draft'),]}"
|
||||
/>
|
||||
<field
|
||||
name="ref"
|
||||
attrs="{'readonly': [('state','!=','draft'),]}"
|
||||
/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
|
||||
<field name="link_partner_ok" invisible="1" />
|
||||
<button name="link_partner"
|
||||
@@ -307,13 +347,26 @@
|
||||
attrs="{'invisible': [('link_partner_ok', '=', False)]}"
|
||||
/>
|
||||
<!-- TODO set partner_id when partner_bank_id changes -->
|
||||
<field name="partner_bank_id"/>
|
||||
<field
|
||||
name="partner_bank_id"
|
||||
attrs="{'readonly': [('state','!=','draft'),]}"
|
||||
/>
|
||||
<field name="type" on_change="onchange_type(partner_id, type)"/>
|
||||
<!-- TODO note the references to parent from the statement form view -->
|
||||
<field domain="[('journal_id','=',parent.journal_id)]"
|
||||
attrs="{'readonly': ['|', ('state', '!=', 'draft'), ('match_type', '!=', '')]}" name="account_id"/>
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '<>', 'view')]"/>
|
||||
<field name="amount"/>
|
||||
<field
|
||||
domain="[('journal_id','=',parent.journal_id)]"
|
||||
attrs="{'readonly': ['|', ('state', '!=', 'draft'), ('match_type', '!=', '')]}"
|
||||
name="account_id"
|
||||
/>
|
||||
<field
|
||||
name="analytic_account_id"
|
||||
groups="analytic.group_analytic_accounting"
|
||||
domain="[('company_id', '=', parent.company_id), ('type', '<>', 'view')]"
|
||||
/>
|
||||
<field
|
||||
name="amount"
|
||||
attrs="{'readonly': [('state','!=','draft'),]}"
|
||||
/>
|
||||
<field name="match_type"/>
|
||||
<field name="residual"/>
|
||||
<field name="parent_id" invisible="1" />
|
||||
|
||||
Reference in New Issue
Block a user