欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > odoo 继承原生domain进行修改

odoo 继承原生domain进行修改

2024/10/24 4:36:39 来源:https://blog.csdn.net/weixin_42464956/article/details/140350706  浏览:    关键词:odoo 继承原生domain进行修改

有需求是
编辑条件,进行对条件的路由拼接,进行展示对应报表
在原生的 domain widget 效果不是很理想,并想展示只是编辑条件以及展示条件,并不能满足。所以继承开发并另命名widget
代码如下:

js 修改

在原有代码基础上复制进行修改

export class XCDomainField extends Component {static template = "iframe_manage.XCDomainField";xxxx...}
export const xcdomainField = {component: XCDomainField,xxxx...}
registry.category("fields").add("xcdomain", xcdomainField);
xml 修改

在原有代码基础上复制进行修改

<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve"><t t-name="iframe_manage.XCDomainField"><div t-att-class="{ o_inline_mode: !props.editInDialog }"><t t-set="resModel" t-value="getResModel()"/><t t-if="resModel"><t t-if="props.isFoldable and state.folded and state.isValid"><button class="btn btn-primary o_field_domain_dialog_button"t-on-click.prevent="onEditDialogBtnClick">编辑条件</button><t t-foreach="state.facets" t-as="facet" t-key="facet_index"><small class="o_facet_value" t-esc="facet" style="margin-right:5px;"/></t></t><t t-else=""><div class="d-flex"><DomainSelectorresModel="resModel"domain="getDomain()"readonly="props.readonly or props.editInDialog"update.bind="update"isDebugMode="!!env.debug"className="props.readonly ? 'o_read_mode' : 'o_edit_mode'"/></div><div class="o_field_domain_panel d-flex align-items-center gap-2 mt-1"><t t-if="state.isValid === null and state.recordCount === null"><i class="fa fa-circle-o-notch fa-spin ms-2" role="img" aria-label="Loading"title="Loading"/></t><t t-else=""><t t-if="state.isValid"></t><t t-else=""><span class="text-warning" role="alert"><i class="fa fa-exclamation-triangle" role="img" aria-label="Warning"title="Warning"/>Invalid domain</span></t><t t-if="!!env.debug and !props.readonly"><buttonclass="btn btn-sm btn-icon fa fa-refresh o_refresh_count"role="img"aria-label="Refresh"title="Refresh"t-on-click="() => this.checkProps()"/></t></t><t t-if="props.editInDialog and !props.readonly"><button class="btn btn-sm btn-primary o_field_domain_dialog_button"t-on-click.prevent="onEditDialogBtnClick">Edit Domain</button></t></div></t></t><t t-else=""><div>Select a model to add a filter.</div></t></div></t></templates>

效果如下

在这里插入图片描述

另附资料

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com