Odoo - 无法更改默认货币公司

问题描述 投票:0回答:3

我想通过打开设置->公司->货币来更改公司货币。但是当我已经更改货币并点击“保存”按钮时,我收到此警告对话框

您无法更改公司的货币,因为某些日记帐项目已经存在

如何解决这个问题?

odoo currency odoo-14
3个回答
3
投票

您无法更改公司的货币,因为某些日记帐项目已经存在

  • 一些数据已经使用相同货币创建,如果您不需要该条目,则只需删除它,然后更改货币。
参考代码 -

源代码

#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 the currency of the company since some journal items already exist'))
    

0
投票
发生错误是因为存在日记帐分录。如果您必须更改公司货币,您至少有 2 个选择:

    删除所有日记条目。
  1. 直接通过 PostgreSQL 使用新货币 ID 更新所有日记帐分录中的所有货币 ID。
完成选项 1 或 2 后,请再次尝试更改公司货币。


0
投票
一个肮脏的解决方案可能是使用 psql 临时更改某些寄存器的 company_id。

update account_journal set company_id = temp_company_id; update account_move set company_id = temp_company_id; update account_move_line set company_id = temp_company_id;
之后您可以更改公司的货币。
最后您可以返回到修改后的寄存器的“company_id”的先前值。

© www.soinside.com 2019 - 2024. All rights reserved.