From 1fba04d147ce79d1a03c0eafaec23e9a58a43d5c Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Thu, 5 Sep 2019 18:17:26 +0200 Subject: [PATCH] [ADD] Automatic block period account --- cash_daily_report/__manifest__.py | 1 + cash_daily_report/data/cron_jobs.xml | 23 +++++++++++++++++++ cash_daily_report/wizard/cash_daily_report.py | 17 +++++++++++--- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 cash_daily_report/data/cron_jobs.xml diff --git a/cash_daily_report/__manifest__.py b/cash_daily_report/__manifest__.py index 619134d0c..33c4fc38a 100644 --- a/cash_daily_report/__manifest__.py +++ b/cash_daily_report/__manifest__.py @@ -38,6 +38,7 @@ 'data': [ 'wizard/cash_daily_report.xml', 'data/menus.xml', + 'data/cron_jobs.xml', ], 'qweb': [], 'test': [ diff --git a/cash_daily_report/data/cron_jobs.xml b/cash_daily_report/data/cron_jobs.xml new file mode 100644 index 000000000..0d0142323 --- /dev/null +++ b/cash_daily_report/data/cron_jobs.xml @@ -0,0 +1,23 @@ + + + + + + + + Automatic Period Lock Date + 1 + + days + -1 + + code + + + model.automatic_period_lock_date() + + + + + + diff --git a/cash_daily_report/wizard/cash_daily_report.py b/cash_daily_report/wizard/cash_daily_report.py index dfde82544..7097ef742 100644 --- a/cash_daily_report/wizard/cash_daily_report.py +++ b/cash_daily_report/wizard/cash_daily_report.py @@ -32,6 +32,18 @@ class CashDailyReportWizard(models.TransientModel): FILENAME = 'cash_daily_report.xls' _name = 'cash.daily.report.wizard' + @api.model + def automatic_period_lock_date(self): + # The secong month day close the mont previous + days = 2 + closeday = datetime.today().replace(day=days) + if datetime.date.today() == closeday: + company = self.env['res.company'].search([]) + lastday = datetime.date.today() - datetime.timedelta(days) + company.write({ + 'period_lock_date': lastday + }) + @api.model @api.model def _get_default_date_start(self): @@ -145,7 +157,7 @@ class CashDailyReportWizard(models.TransientModel): else: total_dates[v_payment.payment_date][v_payment.journal_id.name] += amount - worksheet.write(k_payment+offset, 0, v_payment.name) + worksheet.write(k_payment+offset, 0, v_payment.create_uid.login) worksheet.write(k_payment+offset, 1, v_payment.communication) worksheet.write(k_payment+offset, 2, where) worksheet.write(k_payment+offset, 3, v_payment.payment_date, @@ -178,7 +190,7 @@ class CashDailyReportWizard(models.TransientModel): else: total_dates[v_payment.date][v_payment.journal_id.name] += -v_line.amount - worksheet.write(k_line+offset, 0, v_payment.name) + worksheet.write(k_line+offset, 0, v_payment.create_uid.login) worksheet.write(k_line+offset, 1, v_line.reference) worksheet.write(k_line+offset, 2, v_line.partner_id.name) worksheet.write(k_line+offset, 3, v_payment.date, @@ -194,7 +206,6 @@ class CashDailyReportWizard(models.TransientModel): if k_line: line = k_line + offset - result_journals = {} # NORMAL PAYMENTS if total_account_payment != 0: