콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
17576 화면

In product.product_category_form_view


<?xml version="1.0"?>
<form class="oe_form_configuration">
    <sheet>
        <div class="oe_button_box" name="button_box">
            <button class="oe_stat_button" name="164" icon="fa-th-list" type="action" context="{'search_default_categ_id': active_id}">
                <div class="o_form_field o_stat_info">
                    <span class="o_stat_value"><field name="product_count"/></span>
                    <span class="o_stat_text"> Products</span>
                </div>
            </button>
        </div>
        <div class="oe_title">
            <label for="name" string="Category name" class="oe_edit_only"/>
            <h1><field name="name" placeholder="e.g. Lamps"/></h1>
        </div>
        <group name="first" col="4" string="Category Type">
            <field name="parent_id"/>
            <field name="type"/>
        </group>
    </sheet>
</form>



I would like to add another section:

"Category Test", a new section/title with same font and style as "Category Type", "Inventory Valuation", "Account Properties", etc. titles.

Under that section there will be a dummy checkbox (test checkbox) just to understand how to properly place new fields/sections.

I have created and installed the new module, now I have to understand which would be the right way to add this new section with the checkbox field.

Under views folder of the module I create the new .xml file:


<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <data>
        <!-- Add test field to existing view -->
        <record model="ir.ui.view" id="category_test_form_view">
            <field name="name">category.test</field>
            <field name="model">product.category</field>
            <field name="inherit_id" ref="product.product_category_form_view"/>
            <field name="arch" type="xml">
                <WHAT SHOULD I PUT HERE?>
            </field>
        </record>
    </data>
</odoo>


How would you specify to add both title and Test checkbox AFTER the Category Type section?

Odoo 10.

아바타
취소

What are the name(s) of the new fields you have created to go on the Category Test section?

ditto

작성자

It was just test field. I was in doubt about the whole xpath and group syntax. Thanks for hte comments anyway.

작성자 베스트 답변

I finally find it with some time. I was also having issues because I did not include "product" as module dependency in __manifest__.py.


The right xml is:

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <data>
        <!-- Add test field to existing view -->
        <record model="ir.ui.view" id="category_test_form_view">
            <field name="name">Category Test</field>
            <field name="model">product.category</field>
            <field name="inherit_id" ref="product.product_category_form_view"/>
            <field name="arch" type="xml">
                <xpath expr="//group[@name='first']" position="after">
                        <group name="first" string="Category Test">
                                <field name="test"/>
                                <field name="image_medium" widget="image" class="oe_avatar" modifiers="{}"/>
                        </group>
                </xpath>
            </field>
        </record>
    </data>
</odoo>
아바타
취소
관련 게시물 답글 화면 활동
1
2월 23
1994
1
5월 20
3012
1
3월 18
9800
0
5월 24
6936
3
4월 24
4459