upgrade v16
separación de las funcionalidades del PoS en un módulo aparte
This commit is contained in:
parent
70679c57a3
commit
308b3c4353
19 changed files with 184 additions and 386 deletions
1
pos_product_library/__init__.py
Normal file
1
pos_product_library/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from . import models
|
30
pos_product_library/__manifest__.py
Normal file
30
pos_product_library/__manifest__.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
'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
|
||||
==================================================
|
||||
* Hace búsquedas en el TPV de los campos autor y género.
|
||||
* 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.
|
||||
""",
|
||||
'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/xml/**/*.xml",
|
||||
],
|
||||
},
|
||||
'demo': [],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'application': True,
|
||||
}
|
2
pos_product_library/models/__init__.py
Normal file
2
pos_product_library/models/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
from . import pos_session
|
||||
|
15
pos_product_library/models/pos_session.py
Normal file
15
pos_product_library/models/pos_session.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class PosSession(models.Model):
|
||||
_inherit = 'pos.session'
|
||||
|
||||
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');
|
||||
return result
|
33
pos_product_library/static/src/js/screens.js
Normal file
33
pos_product_library/static/src/js/screens.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
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;
|
||||
});
|
61
pos_product_library/static/src/xml/pos.xml
Normal file
61
pos_product_library/static/src/xml/pos.xml
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t
|
||||
t-name="ProductItem"
|
||||
t-inherit="point_of_sale.ProductItem"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//div[hasclass('product-content')]" position="inside">
|
||||
<div class="flex">
|
||||
<br/>
|
||||
<span><b> <t t-esc="props.product.formato"/></b></span>
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
<t t-inherit="point_of_sale.Orderline" t-inherit-mode="extension">
|
||||
<xpath expr="//span[hasclass('product-name')]" position="inside">
|
||||
<span>
|
||||
<br/>
|
||||
Formato: <t t-out="props.line.get_product().formato" />
|
||||
</span>
|
||||
</xpath>
|
||||
</t>
|
||||
<t
|
||||
t-name="ProductInfoPopup"
|
||||
t-inherit="point_of_sale.ProductInfoPopup"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//div[hasclass('section-product-info-title')]" position="after">
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Editorial:</td>
|
||||
<td><t t-out="props.product.editorial" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Entrada:</td>
|
||||
<td><t t-out="props.product.fecha_entrada" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Género:</td>
|
||||
<td><t t-out="props.product.genero" /></td>
|
||||
</tr>
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
Loading…
Add table
Add a link
Reference in a new issue