2017-07-06 09:40:15 +02:00
|
|
|
# Copyright 2017 ACSONE SA/NV
|
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
|
2020-11-17 00:09:33 +01:00
|
|
|
from odoo import models
|
2017-07-06 09:40:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ResCompany(models.Model):
|
|
|
|
|
2020-11-17 00:00:36 +01:00
|
|
|
_inherit = "res.company"
|
2017-07-06 09:40:15 +02:00
|
|
|
|
|
|
|
def find_daterange_fm(self, date_str):
|
|
|
|
self.ensure_one()
|
2020-11-17 00:00:36 +01:00
|
|
|
fm_id = self.env.ref("account_fiscal_month.date_range_fiscal_month")
|
|
|
|
return self.env["date.range"].search(
|
|
|
|
[
|
|
|
|
("type_id", "=", fm_id.id),
|
|
|
|
("date_start", "<=", date_str),
|
|
|
|
("date_end", ">=", date_str),
|
|
|
|
"|",
|
|
|
|
("company_id", "=", self.id),
|
|
|
|
("company_id", "=", False),
|
|
|
|
],
|
|
|
|
limit=1,
|
|
|
|
order="company_id asc",
|
|
|
|
)
|