Fix problem when try to remove a reconcilaition created from bank
statement, and not remove from there. Update raise message.
This commit is contained in:
parent
757af61826
commit
3bad172191
12
locale/ca.po
12
locale/ca.po
|
@ -44,13 +44,13 @@ msgstr ""
|
|||
|
||||
msgctxt "model:ir.message,text:reconciliation_cannot_delete"
|
||||
msgid ""
|
||||
"Cannot break reconciliation \"%(reconciliation)s\" because line \"%(line)s\""
|
||||
" has assigned to Bank Statement Line Please go to \"%(statement_line)s\" "
|
||||
"bank statement line to unreconcile"
|
||||
"Cannot break reconciliation because there is a line assigned to Bank "
|
||||
"Statement Line. Please go to \"%(bank_line)s\" bank statement line to "
|
||||
"unreconcile."
|
||||
msgstr ""
|
||||
"No es pot trencar la conciliació \"%(reconciliation)s\" perquè la línia "
|
||||
"\"%(line)s\" s'ha assignat a la línia de l'extracte bancari. Aneu a la línia"
|
||||
" de l'extracte bancari \"%(statement_line)s\" per no conciliar."
|
||||
"No es pot trencar la conciliació perquè hi ha una línia assignada a una línia"
|
||||
" d'extracte bancari. Aneu a la línia \"%(bank_line)s\" de l'extracte bancari "
|
||||
"per trencar la conciliació."
|
||||
|
||||
msgctxt "model:ir.message,text:same_account"
|
||||
msgid ""
|
||||
|
|
12
locale/es.po
12
locale/es.po
|
@ -44,13 +44,13 @@ msgstr ""
|
|||
|
||||
msgctxt "model:ir.message,text:reconciliation_cannot_delete"
|
||||
msgid ""
|
||||
"Cannot break reconciliation \"%(reconciliation)s\" because line \"%(line)s\""
|
||||
" has assigned to Bank Statement Line Please go to \"%(statement_line)s\" "
|
||||
"bank statement line to unreconcile"
|
||||
"Cannot break reconciliation because there is a line assigned to Bank "
|
||||
"Statement Line. Please go to \"%(bank_line)s\" bank statement line to "
|
||||
"unreconcile."
|
||||
msgstr ""
|
||||
"No se puede romper la conciliación \"%(reconciliation)s\" porque la línea "
|
||||
"\"%(line)s\" se ha asignado a la línea del extracto bancario. Vaya a la "
|
||||
"línea del extracto bancario \"%(statement_line)s\" para no conciliar"
|
||||
"No se puede romper la conciliación porque hay una línea asignada a una línea"
|
||||
" de extracto bancario. Id a la línea \"%(bank_line)s\" del extracto bancario "
|
||||
"para romper la conciliación."
|
||||
|
||||
msgctxt "model:ir.message,text:same_account"
|
||||
msgid ""
|
||||
|
|
|
@ -16,7 +16,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="text">Not found a counterpart account. Check accounts from journal and move lines are not the same.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="reconciliation_cannot_delete">
|
||||
<field name="text">Cannot break reconciliation "%(reconciliation)s" because line "%(line)s" has assigned to Bank Statement Line Please go to "%(statement_line)s" bank statement line to unreconcile</field>
|
||||
<field name="text">Cannot break reconciliation because there is a line assigned to Bank Statement Line. Please go to "%(bank_line)s" bank statement line to unreconcile.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
39
statement.py
39
statement.py
|
@ -343,44 +343,21 @@ class Reconciliation(metaclass=PoolMeta):
|
|||
def delete(cls, reconciliations):
|
||||
from_statement = Transaction().context.get(
|
||||
'from_account_bank_statement_line', False)
|
||||
if from_statement:
|
||||
return super(Reconciliation, cls).delete(reconciliations)
|
||||
|
||||
cls.check_bank_statement_lines(reconciliations)
|
||||
if not from_statement:
|
||||
cls.check_bank_statement_lines(reconciliations)
|
||||
return super(Reconciliation, cls).delete(reconciliations)
|
||||
|
||||
@classmethod
|
||||
def check_bank_statement_lines(cls, reconciliations):
|
||||
BankLines = Pool().get('account.bank.reconciliation')
|
||||
BankLine = Pool().get('account.bank.statement.line')
|
||||
|
||||
moves = set(
|
||||
line.move
|
||||
for reconciliation in reconciliations
|
||||
lines = [line for reconciliation in reconciliations
|
||||
for line in reconciliation.lines
|
||||
)
|
||||
if isinstance(line.origin, BankLine)]
|
||||
|
||||
lines_with_statement = BankLines.search(
|
||||
[
|
||||
('move_line', 'in', (line for reconciliation in reconciliations
|
||||
for line in reconciliation.lines)),
|
||||
('bank_statement_line', '!=', None),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
|
||||
if lines_with_statement:
|
||||
bank_line = lines_with_statement[0]
|
||||
|
||||
error_reconciliation = next(
|
||||
reconciliation
|
||||
for reconciliation in reconciliations
|
||||
for line in reconciliation.lines
|
||||
if bank_line.move_line.move == line.move
|
||||
)
|
||||
if lines:
|
||||
line = lines[0]
|
||||
raise UserError(gettext(
|
||||
'account_bank_statement_counterpart.reconciliation_cannot_delete',
|
||||
reconciliation=error_reconciliation.rec_name,
|
||||
line=bank_line.rec_name,
|
||||
statement_line=(
|
||||
bank_line.bank_statement_line.rec_name)
|
||||
bank_line=line.origin.rec_name
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue