Skip to content
Snippets Groups Projects
  • alsh-odoo's avatar
    883c03a0
    [FIX] hr_expense: raise exception if multiple company records selected · 883c03a0
    alsh-odoo authored
    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>
    883c03a0
    History
    [FIX] hr_expense: raise exception if multiple company records selected
    alsh-odoo authored
    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>