diff --git a/account.py b/account.py index 29cff1ae2c..3104babe88 100644 --- a/account.py +++ b/account.py @@ -363,11 +363,12 @@ class PrintGeneralLegderInit(WizardOSV): _name = 'account.account.open_general_ledger.init' fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year', required=True) - #TODO add domain for start_period <= end_period start_period = fields.Many2One('account.period', 'Start Period', - domain="[('fiscalyear', '=', fiscalyear)]") + domain="[('fiscalyear', '=', fiscalyear), " \ + "('end_date', '<', (end_period, 'start_date'))]") end_period = fields.Many2One('account.period', 'End Period', - domain="[('fiscalyear', '=', fiscalyear)]") + domain="[('fiscalyear', '=', fiscalyear), " \ + "('start_date', '>', (start_period, 'end_date'))]") company = fields.Many2One('company.company', 'Company', required=True) posted = fields.Boolean('Posted Move', help='Only posted move') diff --git a/period.py b/period.py index 35d0098465..63eb2e8855 100644 --- a/period.py +++ b/period.py @@ -58,6 +58,24 @@ class Period(OSV): 'a period with moves!') return + def search(self, cursor, user, args, offset=0, limit=None, order=None, + context=None, count=False, query_string=False): + args = args[:] + i = 0 + while i < len(args): + if args[i][0] in ('start_date', 'end_date'): + if isinstance(args[i][2], (list, tuple)): + if not args[i][2][0]: + args[i] = ('id', '!=', '0') + else: + period = self.browse(cursor, user, args[i][2][0], + context=context) + args[i] = (args[i][0], args[i][1], period[args[i][2][1]]) + i += 1 + return super(Period, self).search(cursor, user, args, offset=offset, + limit=limit, order=order, context=context, count=count, + query_string=query_string) + def create(self, cursor, user, vals, context=None): fiscalyear_obj = self.pool.get('account.fiscalyear') if vals.get('fiscalyear'):