简体   繁体   English

如何在 Odoo v15 的 website_sale 中搜索自定义字段?

[英]How to make custom field searchable in website_sale in Odoo v15?

So I have created a number of custom fields on Inventory -> Products by adding the fields and then modifying the View from Developer mode.因此,我通过添加字段然后修改开发人员模式的视图,在 Inventory -> Products 上创建了许多自定义字段。

Furthermore, I made those fields searchable inside the Oddo backend (in both Inventory -> Products and Website -> Products pages).此外,我使这些字段在 Oddo 后端内可搜索(在库存 -> 产品和网站 -> 产品页面中)。

But, I cannot figure out how to make those custom fields searchable in the Website itself.但是,我无法弄清楚如何使这些自定义字段在网站本身中可搜索。 So, on the website I have a Shop page that searches by title, description, etc and allows me to Filter on price, etc. But I need it to search on my custom fields.因此,在网站上我有一个商店页面,可以按标题、描述等进行搜索,并允许我按价格等进行过滤。但我需要它来搜索我的自定义字段。

For example, I have a custom field named "Anno" with id of "x_anno", which is added to forms like例如,我有一个名为“Anno”的自定义字段,id 为“x_anno”,它被添加到 forms 中,例如

<field name="x_anno" />

Anno = year so I want products made in 2011 if someone types "2011" in Search on the Website -> Shop Anno = year 所以我想要 2011 年生产的产品,如果有人在网站搜索中输入“2011” -> 商店

How do I pull that off?我该怎么做呢? Any pointers?任何指针?

Thanks in advance提前致谢

I am writing this answer for future reference:我正在写这个答案以供将来参考:

Writing ODOO Apps and modules is the right way to go for this.为此,编写 ODOO 应用程序和模块是 go 的正确方法。 I made a mistake of modifying the Views from Developer mode, which is the wrong approach.我错误地从开发人员模式修改视图,这是错误的做法。 Right approach is creating the Odoo module, and there are plenty of resources for that online, ie https://webkul.com/blog/how-to-create-a-module-in-odoo/正确的方法是创建 Odoo 模块,网上有很多相关资源,即https://webkul.com/blog/how-to-create-a-module-in-odoo/

Once you write your module and install it into Odoo, it offers a whole new access to changes and modifications, which surely would not be available via simple View editing.一旦您编写了模块并将其安装到 Odoo 中,它就提供了一种全新的更改和修改访问权限,这肯定无法通过简单的视图编辑来实现。

Since I wrote this question, struggling with the basic task, I've managed to:自从我写了这个问题,努力完成基本任务后,我成功地做到了:

  • Create new module创建新模块
  • Add it to main menu with custom icon使用自定义图标将其添加到主菜单
  • Add suboptions添加子选项
  • Each suboption is a separate model with CRUD operations每个子选项都是一个单独的 model,带有 CRUD 操作
  • Added new tab to product sheet containing all my modeles from the App in many2many mode在产品表中添加了新标签,其中包含我在多对多模式下应用程序中的所有模型
  • Added a list of entries to the website在网站上添加了条目列表
  • Made products on website searchable / filterable by data in my new module使网站上的产品可通过我的新模块中的数据进行搜索/过滤
  • Allowed some models to have public pages允许一些模型有公共页面

And finally I got a good grasp of how Odoo internally works最后我很好地掌握了 Odoo 的内部工作原理

TLDR; TLDR; Go for Odoo modules instead of simple View editing from developer mode Go 用于 Odoo 模块,而不是从开发人员模式进行简单的视图编辑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM