[FIX] account: use more efficient method

Check accounting entries in a more effective way.

closes odoo/odoo#124755

X-original-commit: 316c1d9745af33d85bd94747b3d913d9c9db2342
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Alvaro Fuentes Suarez (afu) <afu@odoo.com>
This commit is contained in:
Alvaro Fuentes
2023-06-13 10:13:58 +02:00
parent 8bcca1a267
commit 30fd0071a2
+1 -1
View File
@@ -401,7 +401,7 @@ class ResCompany(models.Model):
#forbid the change of currency_id if there are already some accounting entries existing
if 'currency_id' in values and values['currency_id'] != company.currency_id.id:
if self.env['account.move.line'].search([('company_id', '=', company.id)]):
if company._existing_accounting():
raise UserError(_('You cannot change the currency of the company since some journal items already exist'))
return super(ResCompany, self).write(values)