如何更换 看板模板上的标签? Odoo 10企业

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

我尝试使用xpath替换标签。但它没有用,我不知道出了什么问题?我只想删除条件t-if =“record.planned_revenue.raw_value”。我尝试过这篇文章:https://odedrabhavesh.blogspot.com/2015/01/how-to-replace-kanban-image-in-odoo.htmlenter code herehttps://www.odoo.com/forum/help-1/question/how-to-inherit-from-a-kanban-view-in-odoo9-102568但他们并没有像我期望的那样工作。

这是原始模板:

<record id="crm_case_kanban_view_leads" model="ir.ui.view">
        <field name="name">crm.lead.kanban.lead</field>
        <field name="model">crm.lead</field>
        <field name="arch" type="xml">
            <kanban default_group_by="stage_id" class="o_kanban_small_column o_opportunity_kanban"
                    on_create="crm.create_opportunity_simplified">
                <field name="stage_id"
                       options='{"group_by_tooltip": {"requirements": "Description", "legend_priority": "Use of stars"}}'/>
                <field name="color"/>
                <field name="priority"/>
                <field name="planned_revenue"/>
                <field name="kanban_state"/>
                <field name="date_action"/>
                <field name="user_email"/>
                <field name="user_id"/>
                <field name="partner_address_email"/>
                <field name="message_needaction_counter"/>
                <field name="tag_ids"/>
                <field name="partner_id"/>
                <field name="title_action"/>
                <field name="active"/>
                <field name="company_currency"/>
                <templates>
                    <field name="date_deadline"/>
                    <t t-name="kanban-box">
                        <div t-attf-class="#{kanban_color(record.color.raw_value)} oe_kanban_global_click">
                            <div class="o_dropdown_kanban dropdown">

                                <a class="dropdown-toggle btn" data-toggle="dropdown" href="#">
                                    <span class="fa fa-bars fa-lg"/>
                                </a>
                                <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                                    <t t-if="widget.editable">
                                        <li>
                                            <a type="edit">Edit</a>
                                        </li>
                                    </t>
                                    <t t-if="widget.deletable">
                                        <li>
                                            <a type="delete">Delete</a>
                                        </li>
                                    </t>
                                    <li t-if="! record.active.value">
                                        <a name="action_set_active" type="object">Unarchive</a>
                                    </li>
                                    <li t-if="record.active.value">
                                        <a name="action_set_unactive" type="object">Archive</a>
                                    </li>
                                    <li>
                                        <ul class="oe_kanban_colorpicker" data-field="color"/>
                                    </li>
                                </ul>
                            </div>
                            <div class="oe_kanban_content">
                                <div>
                                    <field name="tag_ids"/>
                                </div>
                                <div>
                                    <strong>
                                        <field name="name"/>
                                    </strong>
                                </div>
                                <div class="text-muted">
                                    <t t-if="record.planned_revenue.raw_value">
                                        <field name="planned_revenue" widget="monetary"
                                               options="{'currency_field': 'company_currency'}"/>
                                        <span t-if="record.partner_id.value">,</span>
                                    </t>
                                    <span t-if="record.partner_id.value">
                                        <t t-esc="record.partner_id.value"/>
                                    </span>
                                </div>

                                <div class="o_kanban_footer">
                                    <field name="priority" widget="priority" groups="base.group_user"/>
                                    <t t-if="record.message_needaction_counter.raw_value">
                                        <span class='oe_kanban_mail_new' title='Unread Messages'>
                                            <i class='fa fa-comments'/>
                                            <t t-raw="record.message_needaction_counter.raw_value"/>
                                        </span>
                                    </t>
                                    <div>
                                        <a name="%(crm.crm_activity_log_action)d" type="action"
                                           t-if="record.kanban_state.raw_value!='grey'">
                                            <span
                                                    t-att-title="record.date_action.value + ': '+ record.title_action.value"
                                                    t-attf-class="oe_kanban_status oe_kanban_status_#{record.kanban_state.raw_value}"/>
                                        </a>
                                        <a name="%(crm.crm_activity_schedule_action)d" type="action"
                                           t-if="record.kanban_state.raw_value=='grey'">
                                            <span
                                                    class="oe_kanban_status oe_kanban_status_grey"/>
                                        </a>
                                        <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)"
                                             t-att-title="record.user_id.value" width="24" height="24"
                                             class="oe_kanban_avatar pull-right"/>
                                    </div>
                                </div>
                            </div>
                            <div class="oe_clear"></div>
                        </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>

我想替换这个:

<t t-if="record.planned_revenue.raw_value">

通过:

<t>

这是我的习惯:

<record id="crm_case_kanban_view_leads_custom" model="ir.ui.view">
        <field name="name">crm.lead.kanban.lead.extends</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.crm_case_kanban_view_leads"/>
        <field name="arch" type="xml">
            <xpath expr='//kanban/templates/t/div/div/div/t[0]' position="replace">
                <t>
                    <field name="planned_revenue" widget="monetary"
                           options="{'currency_field': 'company_currency'}"/>
                    <span t-if="record.partner_id.value">,</span>
                </t>
            </xpath>
        </field>
    </record>

它没用,有什么不对?

customization odoo odoo-10 kanban
2个回答
0
投票

我用xpath解决了这个问题:

<xpath expr="//t/div/div[@class='oe_kanban_content']/div[@class='text-muted']/t" position="replace">

0
投票

您的代码将不起作用,因为您基本上替换了整个<t>内容而不仅仅是属性。除非您打算将replace与原始内容的副本一起使用,这是不好的做法。

您需要单独输出要更改的属性:

<t t-if="record.planned_revenue.raw_value" position="attributes">
    <attribute name="t-if">True</attribute>
</t>

或者在经典的xpath语法中:

<xpath expr="//t[@t-if='record.planned_revenue.raw_value']" position="attributes">
    <attribute name="t-if">True</attribute>
</xpath>
© www.soinside.com 2019 - 2024. All rights reserved.