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

@ -1,30 +1,31 @@
{ {
'name': 'PoS Product Library', "name": "PoS Product Library",
'category': 'Product', "category": "Point of Sale",
'summary': 'Add product_library fields to point of sale', "summary": "Add product_library fields to point of sale",
'version': "16.0.1.0.0", "version": "16.0.1.0.0",
'description': """ "license": "AGPL-3",
"description": """
Añade los campos de product_library al TPV Añade campos de product_library al TPV
================================================== ==================================================
* Hace búsquedas en el TPV de los campos autor y género. * Hace búsquedas en el TPV de los campos autor y editorial.
* Muestra el campo formato en el PoS en los productos y en las líneas de la orden. * Muestra el campo formato en el PoS en los productos y en las líneas de la orden.
* Muestra los campos de product_library en el popup de info del producto. * Muestra los campos de product_library en el popup de info del producto.
* Impide la búsqueda en el TPV en las descripciones. * Quita la descriptición de los productos de la búsqueda en el TPV.
""", """,
'author': 'Criptomart', "author": "Criptomart",
'depends': [ "depends": [
'product_library', "product_library",
'point_of_sale', "point_of_sale",
], ],
"assets": { "assets": {
"point_of_sale.assets": [ "point_of_sale.assets": [
"pos_product_library/static/src/js/**/*.js", "pos_product_library/static/src/js/db.js",
"pos_product_library/static/src/xml/**/*.xml", "pos_product_library/static/src/xml/**/*.xml",
], ],
}, },
'demo': [], "data": [],
'installable': True, "demo": [],
'auto_install': False, "installable": True,
'application': True, "auto_install": False,
"application": True,
} }

View file

@ -6,10 +6,12 @@ class PosSession(models.Model):
def _loader_params_product_product(self): def _loader_params_product_product(self):
result = super()._loader_params_product_product() result = super()._loader_params_product_product()
result['search_params']['fields'].append('formato') result['search_params']['fields'].remove("description")
result['search_params']['fields'].append('autor'); result['search_params']['fields'].append("autor")
result['search_params']['fields'].append('editorial'); result['search_params']['fields'].append("editorial");
result['search_params']['fields'].append('genero'); result['search_params']['fields'].append("formato");
result['search_params']['fields'].append('subtitle'); result['search_params']['fields'].append("genero");
result['search_params']['fields'].append('fecha_entrada'); result['search_params']['fields'].append("subtitle");
result['search_params']['fields'].append("fecha_entrada");
return result return result

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"> <xpath expr="//div[hasclass('product-content')]" position="inside">
<div class="flex"> <div class="flex">
<br/> <br/>
<span><b> <t t-esc="props.product.formato"/></b></span> <span><b><t t-esc="props.product.formato"/></b></span>
</div> </div>
</xpath> </xpath>
</t> </t>
@ -31,17 +31,17 @@
<div class="section-product-info"> <div class="section-product-info">
<br/> <br/>
<table class="mobile-table"> <table class="mobile-table">
<tr>
<td>Formato:</td>
<td><t t-out="props.product.formato" /></td>
</tr>
<tr> <tr>
<td>Subtitulo:</td> <td>Subtitulo:</td>
<td><t t-out="props.product.subtitle" /></td> <td><t t-out="props.product.subtitle" /></td>
</tr> </tr>
<tr> <tr>
<td>Autor:</td> <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>
<tr> <tr>
<td>Editorial:</td> <td>Editorial:</td>
@ -55,6 +55,11 @@
<td>Género:</td> <td>Género:</td>
<td><t t-out="props.product.genero" /></td> <td><t t-out="props.product.genero" /></td>
</tr> </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> </div>
</xpath> </xpath>
</t> </t>