Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2704 Vistas

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

Avatar
Descartar
Mejor respuesta

​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

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
ago 24
725
3
dic 24
2860
2
dic 23
1560
2
oct 22
3098
3
abr 25
8077