Skip to content
Snippets Groups Projects
Commit 883c03a0 authored by alsh-odoo's avatar alsh-odoo
Browse files

[FIX] hr_expense: raise exception if multiple company records selected

This traceback arises when the user selects multi
company records and click on the 'create report' button.

To reproduce this issue:

1) Install 'hr_expense'
2) Create a new company for example 'test'
3) Enable the 'test' company on the right corner
4) Now open 'employees' and change the company of the current user(Mitchel Admin)
   to the 'test'.
5) Open 'Expenses', create a new record, and change the company to 'test'.
6) Fill the required field values and save the record.
7) Now click 'My Expenses/My Expenses to report' and select all the records (Make sure
   'My Expenses' filter is applied)
8) Click on the 'Create Record' button

Error:- "ValueError: Expected singleton: res.company(2, 1)"

On the '_create_sheet_from_expenses' method, the value of 'company_id' is getting
through 'self.company_id.id'.
See:-
https://github.com/odoo/odoo/blob/f910987cb4af84c1e7afabf67f05d4eebc31e765/addons/hr_expense/models/hr_expense.py#L324-L335



But when user selects multi company recordsets
'self.company_id' has multi recordsets.

When 'company_id' is getting value through 'self.company_id.id', because of
'self.company_id' has multiple records, which leads
to the above traceback.

By applying this commit will resolve the issue by raising an exception,
when user selected multi company records to create report.

sentry-4465422743

closes odoo/odoo#135035

Signed-off-by: default avatarde Wouters de Bouchout Jean-Benoît (jbw) <jbw@odoo.com>
parent 10c4091f
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment