mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-24 20:42:07 +02:00
Initial commit: Accounting packages
This commit is contained in:
commit
4ef34c2317
2661 changed files with 1709616 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
from odoo import models, api, fields
|
||||
|
||||
from odoo.tools import date_utils
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
@api.model
|
||||
def get_fiscal_dates(self, payload):
|
||||
companies = self.env["res.company"].browse(
|
||||
data["company_id"] or self.env.company.id for data in payload
|
||||
)
|
||||
existing_companies = companies.exists()
|
||||
# prefetch both fields
|
||||
existing_companies.read(["fiscalyear_last_day", "fiscalyear_last_month"])
|
||||
results = []
|
||||
|
||||
for data, company in zip(payload, companies):
|
||||
if company not in existing_companies:
|
||||
results.append(False)
|
||||
continue
|
||||
start, end = date_utils.get_fiscal_year(
|
||||
fields.Date.to_date(data["date"]),
|
||||
day=company.fiscalyear_last_day,
|
||||
month=int(company.fiscalyear_last_month),
|
||||
)
|
||||
results.append({"start": start, "end": end})
|
||||
return results
|
||||
Loading…
Add table
Add a link
Reference in a new issue