optimize search-queries, line: fix state-selection
This commit is contained in:
parent
50ce7f5dbc
commit
0e30725d1f
6 changed files with 19 additions and 19 deletions
|
@ -165,7 +165,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
if Line.search_count([
|
||||
('date', '>', reconciliation.date_from),
|
||||
('date', '<', reconciliation.date_to),
|
||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
||||
('cashbook', '=', reconciliation.cashbook.id),
|
||||
('state', 'not in', ['check', 'recon']),
|
||||
]) > 0:
|
||||
raise UserError(gettext(
|
||||
|
@ -206,7 +206,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
lines = Line.search([
|
||||
('date', '>=', reconciliation.date_from),
|
||||
('date', '<=', reconciliation.date_to),
|
||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
||||
('cashbook', '=', reconciliation.cashbook.id),
|
||||
('reconciliation', '=', None),
|
||||
('state', 'in', ['check', 'recon']),
|
||||
])
|
||||
|
@ -297,7 +297,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
# deny if there are lines not linked to reconciliation
|
||||
if Line.search_count([
|
||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
||||
('cashbook', '=', reconciliation.cashbook.id),
|
||||
('reconciliation', '=', None),
|
||||
['OR',
|
||||
[ # lines inside of date-range
|
||||
|
@ -387,7 +387,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
if self.cashbook:
|
||||
if self.date_from is not None:
|
||||
reconciliations = Recon.search([
|
||||
('cashbook.id', '=', self.cashbook.id),
|
||||
('cashbook', '=', self.cashbook.id),
|
||||
('date_from', '<', self.date_from),
|
||||
], order=[('date_from', 'DESC')], limit=1)
|
||||
if len(reconciliations) > 0:
|
||||
|
@ -439,7 +439,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
# set date_from to date_to of predecessor
|
||||
recons = Recon.search([
|
||||
('cashbook.id', '=', id_cashbook),
|
||||
('cashbook', '=', id_cashbook),
|
||||
], order=[('date_to', 'DESC')], limit=1)
|
||||
if len(recons) > 0:
|
||||
values['date_from'] = recons[0].date_to
|
||||
|
@ -448,7 +448,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
# set date_to to day of last 'checked'-booking in selected cashbook
|
||||
lines = Line.search([
|
||||
('cashbook.id', '=', id_cashbook),
|
||||
('cashbook', '=', id_cashbook),
|
||||
('state', '=', 'check'),
|
||||
('reconciliation', '=', None),
|
||||
], order=[('date', 'DESC')], limit=1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue