From 100a6eed915bf72339a86e8f0373ca863b7eb4aa Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Thu, 27 Aug 2020 17:26:23 +0200 Subject: [PATCH] [IMP] emcc: default date to import wizard --- .isort.cfg | 2 +- .../wizards/emc_history_import_sr.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index 22988e0..d0c6c75 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -9,4 +9,4 @@ line_length=79 known_odoo=odoo known_odoo_addons=odoo.addons sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER -known_third_party=addons,cStringIO,lxml,openerp,psycopg2,requests,setuptools,werkzeug,xlsxwriter +known_third_party=addons,cStringIO,dateutil,lxml,openerp,psycopg2,requests,setuptools,werkzeug,xlsxwriter diff --git a/easy_my_coop_connector/wizards/emc_history_import_sr.py b/easy_my_coop_connector/wizards/emc_history_import_sr.py index 70018f7..cb7626f 100644 --- a/easy_my_coop_connector/wizards/emc_history_import_sr.py +++ b/easy_my_coop_connector/wizards/emc_history_import_sr.py @@ -2,6 +2,10 @@ # Robin Keunen # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from datetime import date + +from dateutil.relativedelta import relativedelta + from odoo import api, fields, models @@ -9,9 +13,19 @@ class EMCHistoryImportSR(models.TransientModel): _name = "emc.history.import.sr" _description = "emc.history.import.sr" + def first_day_of_month(self): + return date.today() - relativedelta(day=1) + + def last_day_of_month(self): + return date.today() + relativedelta(day=31) + name = fields.Char("Name", default="Import History") - date_from = fields.Date(string="Date From", required=True) - date_to = fields.Date(string="Date To", required=True) + date_from = fields.Date( + string="Date From", required=True, default=first_day_of_month + ) + date_to = fields.Date( + string="Date To", required=True, default=last_day_of_month + ) @api.multi def import_subscription_button(self):