[10.0][FIX] account_move_fiscal_month/year: Wrong search result

In case of non existing fiscal year/month, the search method returns void domain which returns all records.
This commit is contained in:
Denis Roussel
2018-04-06 09:17:38 +02:00
parent b6e66427d7
commit 88ad4a7dfc
4 changed files with 19 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ class AccountMove(models.Model):
date_range_domain = [('name', operator, value)]
date_ranges = self.env['date.range'].search(date_range_domain)
if not date_ranges:
return [('id', '=', False)]
domain = []
for date_range in date_ranges:
domain = expression.OR([domain, [

View File

@@ -154,3 +154,10 @@ class TestAccountMoveFiscalMonth(TransactionCase):
move_march_2017 not in moves,
move_jan_2018 not in moves,
]))
# Search non existing month
moves = self.AccountMoveObj.search([
('date_range_fm_id', 'ilike', '2016'),
])
self.assertFalse(
moves
)

View File

@@ -40,6 +40,9 @@ class AccountMove(models.Model):
date_range_domain.append(('type_id', '=', fiscal_year_type.id))
date_ranges = self.env['date.range'].search(date_range_domain)
if not date_ranges:
return [('id', '=', False)]
domain = []
for date_range in date_ranges:
domain = expression.OR([domain, [

View File

@@ -131,3 +131,10 @@ class TestAccountMoveFiscalYear(TransactionCase):
move_2018 in moves,
move_2019 not in moves,
]))
# Search non existing year
moves = self.AccountMoveObj.search([
('date_range_fy_id', 'ilike', '2016'),
])
self.assertFalse(
moves
)