You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

  1. # Copyright 2020 Coop IT Easy SCRL fs
  2. # Robin Keunen <robin@coopiteasy.be>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from datetime import date
  5. from dateutil.relativedelta import relativedelta
  6. from odoo import api, fields, models
  7. class EMCHistoryImportSR(models.TransientModel):
  8. _name = "emc.history.import.sr"
  9. _description = "emc.history.import.sr"
  10. def first_day_of_month(self):
  11. return date.today() - relativedelta(day=1)
  12. def last_day_of_month(self):
  13. return date.today() + relativedelta(day=31)
  14. name = fields.Char("Name", default="Import History")
  15. date_from = fields.Date(
  16. string="Date From", required=True, default=first_day_of_month
  17. )
  18. date_to = fields.Date(
  19. string="Date To", required=True, default=last_day_of_month
  20. )
  21. @api.multi
  22. def import_subscription_button(self):
  23. self.env["subscription.request"].fetch_subscription_requests(
  24. date_from=self.date_from, date_to=self.date_to
  25. )
  26. action = self.env.ref("easy_my_coop.subscription_request_action")
  27. return action.read()[0]