optimize search-queries, line: fix state-selection
This commit is contained in:
parent
6550baa468
commit
7a4fd94981
6 changed files with 20 additions and 20 deletions
|
@ -183,7 +183,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(
|
||||
|
@ -224,7 +224,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']),
|
||||
])
|
||||
|
@ -315,7 +315,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
|
||||
|
@ -405,7 +405,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:
|
||||
|
@ -457,7 +457,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
|
||||
|
@ -466,7 +466,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