I want to change currency even if i had some journal items already created. Odoo does not allows it so thats why i had to override the write method but unable to do so . I am using the same code which is in res.company .py file but when i comment that error message from my custom module it still raises the error coming from the real module. Kindly help me with it.
@api.multi
def write(self, values):
#restrict the closing of FY if there are still unposted entries
self._validate_fiscalyear_lock(values)
# Reflect the change on accounts
for company in self:
#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)]):
raise UserError(_('You cannot change'))
return super(ResCompany, self).write(values)
Above is that error code