OCA / fleet

Odoo fleet management modules
GNU Affero General Public License v3.0
28 stars 78 forks source link

[13.0] [fleet_vehicle_service_kanban] Can't acess Vehicles Services Logs from parent menu Vehicles #110

Closed rpsjr closed 4 months ago

rpsjr commented 1 year ago

Error: Odoo Server Error

Traceback (most recent call last): File "/opt/odoo/odoo/http.py", line 624, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/odoo/odoo/http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/opt/odoo/odoo/tools/pycompat.py", line 14, in reraise raise value File "/opt/odoo/odoo/http.py", line 669, in dispatch result = self._call_function(self.params) File "/opt/odoo/odoo/http.py", line 350, in _call_function return checked_call(self.db, *args, *kwargs) File "/opt/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, args, kwargs) File "/opt/odoo/odoo/http.py", line 339, in checked_call result = self.endpoint(*a, kw) File "/opt/odoo/odoo/http.py", line 915, in call return self.method(*args, *kw) File "/opt/odoo/odoo/http.py", line 515, in response_wrap response = f(args, kw) File "/opt/odoo/addons/web/controllers/main.py", line 1342, in call_kw return self._call_kw(model, method, args, kwargs) File "/opt/odoo/addons/web/controllers/main.py", line 1334, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/opt/odoo/odoo/api.py", line 386, in call_kw result = _call_kw_model(method, model, args, kwargs) File "/opt/odoo/odoo/api.py", line 359, in _call_kw_model result = method(recs, *args, kwargs) File "/opt/odoo/addons/web/models/models.py", line 154, in read_progress_bar for group in self._read_progress_bar(domain, group_by, progress_bar): File "/opt/odoo/addons/mail/models/mail_activity.py", line 794, in _read_progress_bar self.env.cr.execute(select_query, [tz] 3 + where_params) File "/opt/odoo/odoo/sql_db.py", line 173, in wrapper return f(self, args, kwargs) File "/opt/odoo/odoo/sql_db.py", line 250, in execute res = self._obj.execute(query, params) psycopg2.ProgrammingError: invalid reference to FROM-clause entry for table "fleet_vehicle_log_services" LINE 17: ) AS "_last_activity_state" ON ("fleet_vehicle_l... ^ HINT: There is an entry for table "fleet_vehicle_log_services", but it cannot be referenced from this part of the query.

Module

fleet_vehicle_service_kanban

Describe the bug

Can't acess Vehicles Services Logs from parent menu Vehicles

To Reproduce

Affected versions: [13.0]

Steps to reproduce the behavior:

  1. Open Fleet app
  2. Click on Vehicles main menu
  3. Click on Vehicles Services Logs btn

Expected behavior Vehicles Services Logs to be oppened

Additional context Add any other context about the problem here. (e.g. OS, Python version, ...)

mrvdb commented 1 year ago

I've had this problem as well. It's caused by a query building routing in mail_activity.py (in version 13.0).

The query uses implicit and explicit joins mixed, which causes the error. Rewriting the query to only use implicit joins in the same scope works around the error. I have not extensively tested if this works for all modules that use the activity progress mixin.

Appying the following patch does this:


diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py
index 1eb68e1486b..dfaa7041f1d 100644
--- a/addons/mail/models/mail_activity.py
+++ b/addons/mail/models/mail_activity.py
@@ -766,8 +766,8 @@ class MailActivityMixin(models.AbstractModel):
         tz = self._context.get('tz') or self.env.user.tz or 'UTC'
         select_query = """
             SELECT 1 AS id, count(*) AS "__count", {fields}
-            FROM {from_clause}
-            JOIN (
+            FROM {from_clause} ,
+               (
                 SELECT res_id,
                 CASE
                     WHEN min(date_deadline - (now() AT TIME ZONE COALESCE(res_partner.tz, %s))::date) > 0 THEN 'planned'
@@ -780,8 +780,8 @@ class MailActivityMixin(models.AbstractModel):
                 JOIN res_partner ON (res_partner.id = res_users.partner_id)
                 WHERE res_model = '{model}'
                 GROUP BY res_id
-            ) AS "_last_activity_state" ON ("{table}".id = "_last_activity_state".res_id)
-            WHERE {where_clause}
+            ) AS "_last_activity_state"
+            WHERE  ("{table}".id = "_last_activity_state".res_id) AND {where_clause}
             GROUP BY {group_by}
         """.format(
             fields=', '.join(select_terms),
marcelsavegnago commented 1 year ago

ping @rodrigonevest

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

marcelsavegnago commented 11 months ago

@rodrigonevest are you can check please ?

github-actions[bot] commented 5 months ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.