diff --git a/book.py b/book.py index 7ae0a6f..97b720c 100644 --- a/book.py +++ b/book.py @@ -546,7 +546,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView): 'defbook', 'book1', 'book2', 'book3', 'book4', 'book5']: cfg1 = ConfigUser.search([ - ('iduser.id', '=', book.owner.id), + ('iduser', '=', book.owner.id), ('%s.id' % x, '=', book.id)]) if len(cfg1) > 0: to_write_config.extend([cfg1, {x: None}]) diff --git a/line.py b/line.py index 589a377..5d34279 100644 --- a/line.py +++ b/line.py @@ -23,7 +23,7 @@ sel_payee = [ ('party.party', 'Party') ] -sel_linetype = [ +sel_linestate = [ ('edit', 'Edit'), ('check', 'Checked'), ('recon', 'Reconciled'), @@ -351,7 +351,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView): # allow cashbook-line at range-limits if Recon.search_count([ ('state', 'in', ['check', 'done']), - ('cashbook.id', '=', line.cashbook.id), + ('cashbook', '=', line.cashbook.id), ('date_from', '<', line.date), ('date_to', '>', line.date)]) > 0: raise UserError(gettext( @@ -362,7 +362,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView): # reconciliations exist if Recon.search_count([ ('state', 'in', ['check', 'done']), - ('cashbook.id', '=', line.cashbook.id), + ('cashbook', '=', line.cashbook.id), ['OR', ('date_from', '=', line.date), ('date_to', '=', line.date)]]) > 1: @@ -727,7 +727,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView): end_value = None recons = Reconciliation.search([ - ('cashbook.id', '=', line.cashbook.id), + ('cashbook', '=', line.cashbook.id), ('date_to', '<=', line2.date), ('state', '=', 'done'), ], order=[('date_from', 'DESC')], limit=1) @@ -737,14 +737,14 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView): ('date', '<=', line2.date), ['OR', ('reconciliation', '=', None), - ('reconciliation.id', '!=', recons[0])], + ('reconciliation', '!=', recons[0])], ]) end_value = getattr(recons[0], 'end_%s' % field_name) return (query2, end_value) if line.cashbook: query = [ - ('cashbook.id', '=', line.cashbook.id), + ('cashbook', '=', line.cashbook.id), ] balance = Decimal('0.0') @@ -754,7 +754,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView): if line.reconciliation: if line.reconciliation.state == 'done': query.append( - ('reconciliation.id', '=', line.reconciliation.id), + ('reconciliation', '=', line.reconciliation.id), ) balance = getattr( line.reconciliation, 'start_%s' % field_name) diff --git a/reconciliation.py b/reconciliation.py index 4ab997c..d700267 100644 --- a/reconciliation.py +++ b/reconciliation.py @@ -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) diff --git a/splitline.py b/splitline.py index 6efebbf..f074502 100644 --- a/splitline.py +++ b/splitline.py @@ -9,7 +9,7 @@ from trytond.pool import Pool from trytond.pyson import Eval, If from trytond.report import Report from trytond.i18n import gettext -from .line import sel_bookingtype, STATES, DEPENDS +from .line import sel_bookingtype, sel_linestate, STATES, DEPENDS from .book import sel_state_book from .mixin import SecondCurrencyMixin, MemCacheIndexMx @@ -90,7 +90,7 @@ class SplitLine(SecondCurrencyMixin, MemCacheIndexMx, ModelSQL, ModelView): selection=sel_bookingtype), 'on_change_with_bookingtype') state = fields.Function(fields.Selection( string='State', readonly=True, - selection=sel_linetype), 'on_change_with_state') + selection=sel_linestate), 'on_change_with_state') cashbook = fields.Function(fields.Many2One( string='Cashbook', readonly=True, states={'invisible': True}, model_name='cashbook.book'), diff --git a/wizard_booking.py b/wizard_booking.py index ef27f32..429deae 100644 --- a/wizard_booking.py +++ b/wizard_booking.py @@ -152,7 +152,7 @@ class EnterBookingWizard(Wizard): 'cashbooks': [x.id for x in Cashbook.search([ ('state', '=', 'open'), ('btype', '!=', None), - ('owner.id', '=', Transaction().user), + ('owner', '=', Transaction().user), ('id', 'in', book_ids), ])], 'bookingtype': getattr(self.start, 'bookingtype', 'out'), diff --git a/wizard_runreport.py b/wizard_runreport.py index 534f521..d2b4fc2 100644 --- a/wizard_runreport.py +++ b/wizard_runreport.py @@ -55,7 +55,7 @@ class RunCbReportStart(ModelView): if self.cashbook: recons = Recon2.search([ - ('cashbook.id', '=', self.cashbook.id), + ('cashbook', '=', self.cashbook.id), ], order=[('date_from', 'DESC')]) return [x.id for x in recons] @@ -103,7 +103,7 @@ class RunCbReport(Wizard): result['cashbook'] = result['cashbooks'][0] recons = Recon2.search([ - ('cashbook.id', '=', result['cashbook']), + ('cashbook', '=', result['cashbook']), ], order=[('date_from', 'DESC')]) if len(recons) > 0: result['reconciliations'] = [x.id for x in recons]