account-analytic icon indicating copy to clipboard operation
account-analytic copied to clipboard

purchase_analytic conflict with project

Open azmykn opened this issue 2 years ago • 6 comments

Dear , If i installed Purchase Analytic with project , and try to open project updates i got this error ...

`Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/api.py", line 983, in get cache_value = field_cache[record._ids[0]] KeyError: 319

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1160, in get value = env.cache.get(record, self) File "/usr/lib/python3/dist-packages/odoo/api.py", line 990, in get raise CacheMiss(record, field) odoo.exceptions.CacheMiss: 'project.project(319,).purchase_orders_count'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/http.py", line 1583, in _serve_db return service_model.retrying(self._serve_ir_http, self.env) File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 134, in retrying result = func() File "/usr/lib/python3/dist-packages/odoo/http.py", line 1610, in _serve_ir_http response = self.dispatcher.dispatch(rule.endpoint, args) File "/usr/lib/python3/dist-packages/odoo/http.py", line 1807, in dispatch result = self.request.registry['ir.http']._dispatch(endpoint) File "/usr/lib/python3/dist-packages/odoo/addons/website/models/ir_http.py", line 235, in _dispatch response = super()._dispatch(endpoint) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 154, in _dispatch result = endpoint(**request.params) File "/usr/lib/python3/dist-packages/odoo/http.py", line 696, in route_wrapper result = endpoint(self, *args, **params_ok) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/dataset.py", line 42, in call_kw return self._call_kw(model, method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 461, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/usr/lib/python3/dist-packages/odoo/api.py", line 448, in _call_kw_multi result = method(recs, *args, **kwargs) File "/usr/lib/python3/dist-packages/odoo/addons/sale_timesheet/models/project.py", line 306, in get_panel_data panel_data = super(Project, self).get_panel_data() File "/usr/lib/python3/dist-packages/odoo/addons/sale_project/models/project.py", line 274, in get_panel_data panel_data = super().get_panel_data() File "/usr/lib/python3/dist-packages/odoo/addons/project_account_budget/models/project.py", line 53, in get_panel_data panel_data = super().get_panel_data() File "/usr/lib/python3/dist-packages/odoo/addons/project/models/project.py", line 851, in get_panel_data 'buttons': sorted(self._get_stat_buttons(), key=lambda k: k['sequence']), File "/usr/lib/python3/dist-packages/odoo/addons/project_timesheet_forecast_sale/models/project.py", line 44, in _get_stat_buttons buttons = super(Project, self)._get_stat_buttons() File "/usr/lib/python3/dist-packages/odoo/addons/sale_project/models/project.py", line 523, in _get_stat_buttons buttons = super(Project, self)._get_stat_buttons() File "/usr/lib/python3/dist-packages/odoo/addons/project_account_asset/models/project.py", line 53, in _get_stat_buttons buttons = super(Project, self)._get_stat_buttons() File "/usr/lib/python3/dist-packages/odoo/addons/project_hr_payroll_account/models/project.py", line 43, in _get_stat_buttons buttons = super(Project, self)._get_stat_buttons() File "/usr/lib/python3/dist-packages/odoo/addons/project_purchase/models/project.py", line 96, in _get_stat_buttons 'number': self.purchase_orders_count, File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1209, in get self.compute_value(recs) File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1368, in compute_value records._compute_field_value(self) File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 403, in _compute_field_value return super()._compute_field_value(field) File "/usr/lib/python3/dist-packages/odoo/models.py", line 4193, in _compute_field_value fields.determine(field.compute, self) File "/usr/lib/python3/dist-packages/odoo/fields.py", line 97, in determine return needle(*args) File "/usr/lib/python3/dist-packages/odoo/addons/project_purchase/models/project.py", line 31, in _compute_purchase_orders_count self._cr.execute(query_string, query_param) File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 313, in execute res = self._obj.execute(query, params) psycopg2.errors.AmbiguousColumn: column reference "analytic_distribution" is ambiguous LINE 1: SELECT jsonb_object_keys(analytic_distribution) as account_i... ^

The above server error caused the following client error: OwlError: The following error occurred in onWillStart: "Odoo Server Error" OwlError@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1133:1 wrapError@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1482:77 onWillStart@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1488:117 setup@https://test.centerpoint-eg.com/web/assets/35875-2b8c0a7/web.assets_backend.min.js:15419:1259 ComponentNode@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1443:202 createComponent/<@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1968:6 slot2@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js line 1933 > Function:21:21 callSlot@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1545:25 template@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js line 1933 > Function:46:10 _render@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1370:96 render@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1369:6 initiateRender@https://test.centerpoint-eg.com/web/assets/33916-f2947fd/web.assets_common.min.js:1448:47

Caused by: RPC_ERROR: Odoo Server Error RPCError@https://test.centerpoint-eg.com/web/assets/35875-2b8c0a7/web.assets_backend.min.js:973:274 makeErrorFromResponse@https://test.centerpoint-eg.com/web/assets/35875-2b8c0a7/web.assets_backend.min.js:977:163 jsonrpc/promise</<@https://test.centerpoint-eg.com/web/assets/35875-2b8c0a7/web.assets_backend.min.js:985:34`

azmykn avatar May 16 '23 20:05 azmykn

Looks like this report is about 16.0. purchase_analytic doesn't really change analytic_distribution of purchase.order.line, so I am not sure how it would affect the query where the error is thrown...

yostashiro avatar May 17 '23 01:05 yostashiro

I can reproduce this issue. Just inheriting analytic.mixin from purchase.order can cause this error and coming from query of project_purchase compute method https://github.com/odoo/odoo/blob/3855829a0daf4321ab54cce3a71a92eb68c216b3/addons/project_purchase/models/project.py#L21-L31

AungKoKoLin1997 avatar May 17 '23 03:05 AungKoKoLin1997

After I checked the query of _compute_purchase_orders_count, there is LEFT JOIN with purchase_order. So, when we inherit account.mixin in purchase.order and query use analytic_distribution without model indicator and get ambiguous error. We can fix using purchase_order_line.analytic_distribution.
And I proposed PR to the odoo/odoo https://github.com/odoo/odoo/pull/121611.

AungKoKoLin1997 avatar May 18 '23 06:05 AungKoKoLin1997

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.

github-actions[bot] avatar Nov 19 '23 12:11 github-actions[bot]

@azmykn

https://github.com/odoo/odoo/pull/121611

Fyi, this PR have already applied to the odoo source odoo, the issue is solved.

AungKoKoLin1997 avatar Nov 20 '23 03:11 AungKoKoLin1997

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.

github-actions[bot] avatar May 26 '24 12:05 github-actions[bot]