fix busqueda por autor y editorial.
This commit is contained in:
parent
446814d0c8
commit
78d5fca7de
5 changed files with 60 additions and 64 deletions
|
@ -1,30 +1,31 @@
|
|||
{
|
||||
'name': 'PoS Product Library',
|
||||
'category': 'Product',
|
||||
'summary': 'Add product_library fields to point of sale',
|
||||
'version': "16.0.1.0.0",
|
||||
'description': """
|
||||
|
||||
Añade los campos de product_library al TPV
|
||||
"name": "PoS Product Library",
|
||||
"category": "Point of Sale",
|
||||
"summary": "Add product_library fields to point of sale",
|
||||
"version": "16.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"description": """
|
||||
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 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',
|
||||
'depends': [
|
||||
'product_library',
|
||||
'point_of_sale',
|
||||
"author": "Criptomart",
|
||||
"depends": [
|
||||
"product_library",
|
||||
"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",
|
||||
],
|
||||
],
|
||||
},
|
||||
'demo': [],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'application': True,
|
||||
"data": [],
|
||||
"demo": [],
|
||||
"installable": True,
|
||||
"auto_install": False,
|
||||
"application": True,
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ class PosSession(models.Model):
|
|||
|
||||
def _loader_params_product_product(self):
|
||||
result = super()._loader_params_product_product()
|
||||
result['search_params']['fields'].append('formato')
|
||||
result['search_params']['fields'].append('autor');
|
||||
result['search_params']['fields'].append('editorial');
|
||||
result['search_params']['fields'].append('genero');
|
||||
result['search_params']['fields'].append('subtitle');
|
||||
result['search_params']['fields'].append('fecha_entrada');
|
||||
result['search_params']['fields'].remove("description")
|
||||
result['search_params']['fields'].append("autor")
|
||||
result['search_params']['fields'].append("editorial");
|
||||
result['search_params']['fields'].append("formato");
|
||||
result['search_params']['fields'].append("genero");
|
||||
result['search_params']['fields'].append("subtitle");
|
||||
result['search_params']['fields'].append("fecha_entrada");
|
||||
|
||||
return result
|
||||
|
|
21
pos_product_library/static/src/js/db.js
Normal file
21
pos_product_library/static/src/js/db.js
Normal 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;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -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;
|
||||
});
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue