[FIX] Search method should only search on fiscal month date range

This commit is contained in:
Benjamin Willig
2017-10-12 13:53:31 +02:00
committed by Cédric Pigeon
parent 12f5b6324c
commit 71512e6a10

View File

@@ -12,8 +12,15 @@ class AccountMove(models.Model):
date_range_fm_id = fields.Many2one(
comodel_name='date.range', string="Fiscal month",
domain=lambda self: self._get_date_range_fm_domain(),
compute='_compute_date_range_fm', search='_search_date_range_fm')
@api.model
def _get_date_range_fm_domain(self):
fiscal_month_type = self.env.ref(
'account_fiscal_month.date_range_fiscal_month')
return "[('type_id', '=', %d)]" % fiscal_month_type.id
@api.multi
@api.depends('date', 'company_id')
def _compute_date_range_fm(self):
@@ -29,9 +36,14 @@ class AccountMove(models.Model):
else:
date_range_domain = [('name', operator, value)]
fiscal_month_type = self.env.ref(
'account_fiscal_month.date_range_fiscal_month')
date_range_domain.append(('type_id', '=', fiscal_month_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, [