fix busqueda por autor y editorial.

This commit is contained in:
snt 2024-09-14 18:37:53 +02:00
parent 231656c52e
commit f4609c0f6a
5 changed files with 60 additions and 64 deletions

View file

@ -0,0 +1,21 @@
odoo.define("pos_supplierinfo_search.db", function (require) {
"use strict";
var PosDB = require("point_of_sale.DB");
PosDB.include({
_product_search_string: function (product) {
var res = this._super(product).replace("\n", "");
console.log("res", res);
if (product.autor) {
res += "|" + product.autor.replace(/:/g, "");
}
if (product.editorial) {
res += "|" + product.editorial.replace(/:/g, "");
}
res += "\n";
console.log("res", res);
return res;
}
});
});

View file

@ -1,33 +0,0 @@
odoo.define('product_library.screens', function (require) {
"use strict";
var ProductScreen = require('point_of_sale.ProductScreen');
var Registries = require('point_of_sale.Registries');
const LibraryProductScreen = (ProductScreen) =>
class extends ProductScreen {
_searchProduct(event) {
const query = event.target.value.trim().toLowerCase();
if (query) {
const products = this.env.pos.db.get_product_by_category(0).filter(product => {
return product.display_name.toLowerCase().includes(query) ||
product.autor.toLowerCase().includes(query) ||
product.editorial.toLowerCase().includes(query);
});
this.env.pos.db.add_products(products);
} else {
this.env.pos.db.add_products(this.env.pos.db.get_product_by_category(0));
}
this.render();
}
mounted() {
super.mounted();
this.el.querySelector('.searchbox input').addEventListener('input', this._searchProduct.bind(this));
}
};
Registries.Component.extend(ProductScreen, LibraryProductScreen);
return LibraryProductScreen;
});

View file

@ -9,7 +9,7 @@
<xpath expr="//div[hasclass('product-content')]" position="inside">
<div class="flex">
<br/>
<span><b> <t t-esc="props.product.formato"/></b></span>
<span><b><t t-esc="props.product.formato"/></b></span>
</div>
</xpath>
</t>
@ -31,17 +31,17 @@
<div class="section-product-info">
<br/>
<table class="mobile-table">
<tr>
<td>Formato:</td>
<td><t t-out="props.product.formato" /></td>
</tr>
<tr>
<td>Subtitulo:</td>
<td><t t-out="props.product.subtitle" /></td>
</tr>
<tr>
<td>Autor:</td>
<td><t t-out="props.product.author" /></td>
<td><t t-out="props.product.autor" /></td>
</tr>
<tr>
<td>Formato:</td>
<td><t t-out="props.product.formato" /></td>
</tr>
<tr>
<td>Editorial:</td>
@ -55,6 +55,11 @@
<td>Género:</td>
<td><t t-out="props.product.genero" /></td>
</tr>
<!-- Si se quita el campo description en la busqueda, no se muestra aquí
<tr>
<td>Descripcion:</td>
<td><t t-out="props.product.description" /></td>
</tr> -->
</div>
</xpath>
</t>