Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4470 Lượt xem

I would like to extend the `l10n_in` localization in my custom module `test_module` by adding additional accounts to the Chart of Accounts `l10n_in.indian_chart_template_standard`.


Defined `account.account.template` XML data containing entries like:

        <record model="account.account.template" id="p10100">
<field name="name">Test Account Receivable</field>
<field name="code">10100</field>
<field name="user_type_id" ref="account.data_account_type_current_assets"/>
<field name="reconcile" eval="False"/>
<field name="chart_template_id" ref="l10n_in.indian_chart_template_standard"/>
</record>

I have also defined an XML to load the templates for companies:

    <data noupdate="0">
<function model="account.chart.template" name="try_loading_for_current_company">
<value eval="[ref('l10n_in.indian_chart_template_standard')]"/>
</function>
</data>


But installing `test_module` on a new database results in following error (because the journals are already created by `l10n_in` module and it tries to load again?)

odoo.tools.convert.ParseError: "duplicate key value violates unique constraint "account_journal_code_company_uniq"
DETAIL:  Key (code, name, company_id)=(INV, Tax Invoices, 1) already exists.
" while parsing /opt/odoo/addons/test_module/data/account_chart_template_data.xml:4, near
<function model="account.chart.template" name="try_loading_fpos_for_current_company">
            <value eval="[ref('l10n_in.indian_chart_template_standard')]"/>
        </function>


What is the best practice to handle such cases properly in code?



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Your account number may be repeated twice in your account chart. The best way is to comment on this section and after installing the module in the accounting settings section, select the desired localization. 


—>


This is probably an error. Now check the Odo server log to find the error. After fixing the error, you can return the commented part to its original state.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 24
2343
2
thg 11 23
2610
4
thg 8 25
2205
1
thg 9 24
919
0
thg 12 23
1519