From ce9fe1fcf680516e12d1e61a7305fdfb7ddbdc8f Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Sat, 14 Sep 2019 11:42:45 +0000 Subject: [PATCH] [IMP] * : remove company context key --- addons/account/models/chart_template.py | 2 +- addons/digest/models/digest.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 7bcc2f6ded1..5d11e7195a1 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -172,7 +172,7 @@ class AccountChartTemplate(models.Model): self.ensure_one() # do not use `request.env` here, it can cause deadlocks # Ensure everything is translated to the company's language, not the user's one. - self = self.with_context(lang=company.partner_id.lang, company=company) + self = self.with_context(lang=company.partner_id.lang).with_company(company) if not self.env.is_admin(): raise AccessError(_("Only administrators can load a chart of accounts")) diff --git a/addons/digest/models/digest.py b/addons/digest/models/digest.py index 950794d29b3..c8f49d8967f 100644 --- a/addons/digest/models/digest.py +++ b/addons/digest/models/digest.py @@ -56,7 +56,7 @@ class Digest(models.Model): digest.available_fields = ', '.join(kpis_values_fields) def _get_kpi_compute_parameters(self): - return fields.Date.to_string(self._context.get('start_date')), fields.Date.to_string(self._context.get('end_date')), self._context.get('company') + return fields.Date.to_string(self._context.get('start_date')), fields.Date.to_string(self._context.get('end_date')), self.env.company def _compute_kpi_res_users_connected_value(self): for record in self: @@ -105,8 +105,8 @@ class Digest(models.Model): self.ensure_one() res = {} for tf_name, tf in self._compute_timeframes(company).items(): - digest = self.with_context(start_date=tf[0][0], end_date=tf[0][1], company=company).with_user(user) - previous_digest = self.with_context(start_date=tf[1][0], end_date=tf[1][1], company=company).with_user(user) + digest = self.with_context(start_date=tf[0][0], end_date=tf[0][1]).with_user(user).with_company(company) + previous_digest = self.with_context(start_date=tf[1][0], end_date=tf[1][1]).with_user(user).with_company(company) kpis = {} for field_name, field in self._fields.items(): if field.type == 'boolean' and field_name.startswith(('kpi_', 'x_kpi_', 'x_studio_kpi_')) and self[field_name]: