[FIX] account: prevent error when selecting company while journal is empty
Currently an error occurs when the user is creating a new invoice and selects the 'Customer' while the 'Journal' field is empty. Steps to Reproduce: - Install 'Accounting' module. - Go to Accounting > Customer > Invoices and then click on New. - Empty the 'Journal' field and then select any 'Customer'. - The error will be generated. Error: ValueError: Expected singleton: res.company() This error arises at [1] when the company is selected, but the 'journal_id' field is left empty, This commit fixes the above issue by ensuring that the company is selected based on the accessible branches of the associated journal, or falls back to the default company if no journal is specified. Link: [1]-https://github.com/odoo/odoo/blob/ad9cd949168e3be3db6e9a4983faa6b02626b0a2/addons/account/models/account_move.py#L1771 sentry-4835188267 closes odoo/odoo#149707 X-original-commit: aa645cfde60644eec05a120e434da4e94ff0da75 Signed-off-by: de Wouters de Bouchout Jean-Benoît (jbw) <jbw@odoo.com> Signed-off-by: Lavina Tekwani (late) <late@odoo.com>
This commit is contained in:
@@ -1735,7 +1735,7 @@ class AccountMove(models.Model):
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def _onchange_partner_id(self):
|
||||
self = self.with_company(self.journal_id.company_id._accessible_branches()[:1])
|
||||
self = self.with_company((self.journal_id.company_id or self.env.company)._accessible_branches()[:1])
|
||||
|
||||
warning = {}
|
||||
if self.partner_id:
|
||||
|
||||
Reference in New Issue
Block a user