Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Automation Oca
Entity: automation.configuration.step
Compute Method: _compute_graph_data
| Inputs | Method | Outputs |
|---|---|---|
|
- total = self.env["automation.record.step"].read_group( - [ - ("configuration_step_id", "in", self.ids), - ( - "processed_on", - ">=", - fields.Date.context_today(self) + relativedelta(days=-14), - ), - ("is_test", "=", False), - ], - ["configuration_step_id"], - ["configuration_step_id", "processed_on:day"], - lazy=False, - ) - done = self.env["automation.record.step"].read_group( - [ - ("configuration_step_id", "in", self.ids), - ( - "processed_on", - ">=", - fields.Date.context_today(self) + relativedelta(days=-14), - ), - ("state", "=", "done"), - ("is_test", "=", False), - ], - ["configuration_step_id"], - ["configuration_step_id", "processed_on:day"], - lazy=False, - ) - now = fields.Datetime.now() - date_map = { - babel.dates.format_datetime( - now + relativedelta(days=i - 14), - format="dd MMM yyy", - tzinfo=self._context.get("tz", None), - locale=get_lang(self.env).code, - ): 0 - for i in range(0, 15) - } - result = defaultdict( - lambda: {"done": date_map.copy(), "error": date_map.copy()} - ) - for line in total: - result[line["configuration_step_id"][0]]["error"][ - line["processed_on:day"] - ] += line["__count"] - for line in done: - result[line["configuration_step_id"][0]]["done"][ - line["processed_on:day"] - ] += line["__count"] - result[line["configuration_step_id"][0]]["error"][ - line["processed_on:day"] - ] -= line["__count"] - for record in self: - graph_info = dict(result[record.id]) - record.graph_data = { - "error": [ - {"x": key[:-5], "y": value, "name": key} - for (key, value) in graph_info["error"].items() - ], - "done": [ - {"x": key[:-5], "y": value, "name": key} - for (key, value) in graph_info["done"].items() - ], - } |
|
