From 89f73788258b8ba1ab1dd0fd846a114fec33fe05 Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Tue, 16 Jul 2019 08:37:18 +0200 Subject: [PATCH] [FIX] contract. Prevent wrong contract count. Contract count could be wrong if the current date for the user is not the UTC date. So a contract created in for instance the Amsterdam timezone just after midnight, would get maybe the 16th of july as date_start. but _compute_contract_count would look for contracts valid on the 15th of july. --- contract/models/res_partner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contract/models/res_partner.py b/contract/models/res_partner.py index ead5e4c7..acb26bfc 100644 --- a/contract/models/res_partner.py +++ b/contract/models/res_partner.py @@ -18,10 +18,12 @@ class ResPartner(models.Model): def _compute_contract_count(self): contract_model = self.env['account.analytic.account'] - today = fields.Date.today() + # localized date is also the default for date_start. + today = fields.Date.context_today(contract_model) fetch_data = contract_model.read_group([ ('recurring_invoices', '=', True), ('partner_id', 'child_of', self.ids), + ('date_start', '<=', today), # required for contracts '|', ('date_end', '=', False), ('date_end', '>=', today)],