mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
@@ -12,15 +12,23 @@ 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):
|
||||
for rec in self:
|
||||
date = rec.date
|
||||
company = rec.company_id
|
||||
rec.date_range_fm_id = company.find_daterange_fm(date)
|
||||
rec.date_range_fm_id =\
|
||||
company and company.find_daterange_fm(date) or False
|
||||
|
||||
@api.model
|
||||
def _search_date_range_fm(self, operator, value):
|
||||
@@ -29,9 +37,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, [
|
||||
|
||||
Reference in New Issue
Block a user