Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2712 Widoki

Hello, I activated the customer portal and it works fine on version 15.I have a need to improve the search part and I need a code or an application to integrate a search bar on the seen list part to facilitate the search

Awatar
Odrzuć
Najlepsza odpowiedź

​To add a search bar on the seen list part of the customer portal in Odoo v15, you can follow these steps:

Create a new module in Odoo.
Add a new template file to the module to modify the customer portal view.
In the template file, add the HTML code for the search bar.
Add a new JavaScript file to the module to handle the search functionality.
In the JavaScript file, use the Odoo framework to search for records based on the search query entered by the user.
Modify the customer portal controller to load the new template file and JavaScript file.

Here is some example code to get you started:

Create a new module in Odoo:

Add a new JavaScript file to the module to handle the search functionality:

javascript
// static/src/js/portal_search.js

odoo.define('portal_search', function (require) {
​'use strict';

​var core = require('web.core');
​var PortalChatter = require('portal.chatter');

​PortalChatter.include({
​events: _.extend({}, PortalChatter.prototype.events, {
​'submit .o_portal_search form': '_onSearch',
​}),

​_onSearch: function (ev) {
​ev.preventDefault();
​var $form = $(ev.currentTarget);
​var query = $form.find('input[name="search"]').val();
​if (query) {
​this._search(query);
​​}
​},

​_search: function (query) {
​var self = this;
​var domain = [['name', 'ilike', query]];
​var context = {};
​this._rpc({
​model: 'helpdesk.ticket',
​method: 'search_read',
​domain: domain,
​fields: ['name', 'description'],
​context: context,
​​}).then(function (result) {
​​self.$('.o_portal_chatter_messages').html('');
​​_.each(result, function (record) {
​self._addMessage(record);
​​});
​​​});
​​},
​});
​});

In the JavaScript file, use the Odoo framework to search for records based on the search query entered by the user.

Modify the customer portal controller to load the new template file and JavaScript file:

python
#controllers/main.py

from odoo.addons.portal.controllers.portal import CustomerPortal

class HelpdeskCustomerPortal(CustomerPortal):

​def _prepare_portal_layout_values(self):
​values = super(HelpdeskCustomerPortal, self)._prepare_portal_layout_values()
​values['search_js'] = '/customer_portal_search/static/src/js/portal_search.js'
​return values

By following these steps, you should be able to add a search bar to the seen list part of

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 24
731
3
gru 24
2901
2
gru 23
1576
2
paź 22
3121
3
kwi 25
8106