[FIX] account: bank statement lines indeterminist order

The order of a bank statement lines is entirely done on the sequence:
`_order = "statement_id desc, sequence"`

The `create` method of `accounT.bank.statement` is overriden
to handle the sequences of each line.

The `write` method as well, except that the set of the sequences
lines is done after the call to `super`. So, if you add
several new lines to a bank statement, the order of the line
you just added can be different before and after save,
as the sequence of these new lines are not set before
actually writting them on the bank statement.

The widget `handle` serves this sequencing purpose. The
fact it isn't used here is most-likely because
it did not exist at the time this was designed.

Besides, this gives the possibility to the user
to add a new line and re-order it where he wants.
For instance, when manually entering a bank statement,
a user could skip unintentionally a line. If he would
like to add it at the right place, before this revision,
he would have to delete all the lines coming
after the line he skipped. Now, he can add
it at the end, and re-order it where he wants.

What is done in the overriden `create` and `write`
is now useless, but we left it for retro-compatibility
purposes, for databases updating their sources without
updating their views.

opw-667541
This commit is contained in:
Denis Ledoux 2016-02-01 12:45:26 +01:00
parent 19a1c18f57
commit 2083c16606
2 changed files with 2 additions and 1 deletions

View File

@ -947,6 +947,7 @@ class account_bank_statement_line(osv.osv):
_defaults = {
'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line', context=context),
'date': lambda self,cr,uid,context={}: context.get('date', fields.date.context_today(self,cr,uid,context=context)),
'sequence': 1,
}
class account_statement_operation_template(osv.osv):

View File

@ -602,7 +602,7 @@
<page string="Transactions" name="statement_line_ids">
<field name="line_ids" context="{'date':date}">
<tree editable="bottom" string="Statement lines" colors="grey:journal_entry_id!=False">
<field name="sequence" readonly="1" invisible="1"/>
<field name="sequence" widget="handle"/>
<field name="journal_entry_id" invisible="1"/>
<field name="date" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="name" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>