Skip to content
Snippets Groups Projects

Draft: Add find() method on fiscal years needed by other modules.

Open Etienne Ferriere requested to merge topic/16.0/MO16-00581 into branch/16.0
4 files
+ 64
2
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -86,3 +86,24 @@ class OCAAccountFiscalyear(models.Model):
for period in periods:
period.unlink()
return super().unlink()
def find(self, date=None):
"""
:param date: date (odoo format so string), if None, use today
:return: fiscal years that include the indicated date, using either
the company_id in the context or if not set, the user company_id
"""
if not date:
date = fields.Date.context_today(self)
company_id = self.env.context.get("company_id") or self.env.company.id
result = self.search(
[
("date_from", "<=", date),
("date_to", ">=", date),
("company_id", "=", company_id),
],
limit=1,
)
return result
Loading