From 913de79db845d3617f19d351a999774f3efb746b Mon Sep 17 00:00:00 2001 From: santiky Date: Mon, 23 Aug 2021 23:03:12 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1ade=20la=20funcionalidad=20de=20pos=5Fem?= =?UTF-8?q?pty=5Fdefault=5Fimage=20pra=20poder=20mostraar=20el=20formato?= =?UTF-8?q?=20en=20productos=20sin=20imagen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product_library/__manifest__.py | 22 +++++---- product_library/i18n/es.po | 49 +++++++++++++++++++ product_library/i18n/produc_library.pot | 42 ++++++++++++++++ product_library/models/__init__.py | 5 +- product_library/models/__init__.py~ | 23 --------- product_library/models/pos_config.py | 16 ++++++ product_library/models/product_product.py | 20 ++++++++ .../{res_product.py => product_template.py} | 0 product_library/static/src/css/pos.css | 20 ++++++++ .../src/js/{product_library.js => models.js} | 12 +++-- product_library/static/src/js/widgets.js | 42 ++++++++++++++++ product_library/static/src/xml/pos.xml | 40 +++++++++++++++ product_library/views/pos_config.xml | 29 +++++++++++ product_library/views/templates.xml | 5 +- 14 files changed, 284 insertions(+), 41 deletions(-) create mode 100644 product_library/i18n/es.po create mode 100644 product_library/i18n/produc_library.pot delete mode 100644 product_library/models/__init__.py~ create mode 100644 product_library/models/pos_config.py create mode 100644 product_library/models/product_product.py rename product_library/models/{res_product.py => product_template.py} (100%) rename product_library/static/src/js/{product_library.js => models.js} (77%) create mode 100644 product_library/static/src/js/widgets.js create mode 100644 product_library/views/pos_config.xml diff --git a/product_library/__manifest__.py b/product_library/__manifest__.py index 61cf170..e4f7ce9 100644 --- a/product_library/__manifest__.py +++ b/product_library/__manifest__.py @@ -1,31 +1,33 @@ -# -*- coding: utf-8 -*- - { 'name': 'Product Library', 'category': 'Product', 'summary': 'Add library related fields to product', - 'version': '12.0.1.0.1', + 'version': '12.0.1.0.2', 'description': """ Addon mejora de Odoo para librerías y tiendas de discos ================================================== -* Añade campos a product: Editorial, autor, género, formato,... -* Hace búsquedas en el TPV y backend en esos campos nuevos -* Búsqueda sin acentos en el PoS -* Muestra el campo formato en el PoS en los productos y en las líneas de la orden +* Añade campos a product: Editorial, autor, género, formato, fecha de edición, fecha de entrada, colección, subcolección. +* Hace búsquedas en el TPV y backend en esos campos nuevos. +* Búsqueda sin acentos en el PoS. +* Muestra el campo formato en el PoS en los productos y en las líneas de la orden. +* Funcionalidad de pos_empty_default_image para mostrar el formato, en el addon original sobrescribe el widget y no se puede mostraar. """, 'author': 'Criptomart', 'depends': [ - 'product', + 'product', 'point_of_sale', ], 'external_dependencies': {'python': [], 'bin': []}, 'data': [ 'views/product.xml', - 'views/templates.xml' + 'views/templates.xml', + 'views/pos_config.xml', + ], + 'qweb': [ + 'static/src/xml/pos.xml', ], - 'qweb': ['static/src/xml/pos.xml'], 'demo': [], 'installable': True, 'auto_install': False, diff --git a/product_library/i18n/es.po b/product_library/i18n/es.po new file mode 100644 index 0000000..7c60aed --- /dev/null +++ b/product_library/i18n/es.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_default_empty_image +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-10-26 11:08+0000\n" +"Last-Translator: Daniel Martinez Vila \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: pos_default_empty_image +#: model:ir.model.fields,field_description:pos_default_empty_image.field_pos_config__iface_fixed_font_size +#: model_terms:ir.ui.view,arch_db:pos_default_empty_image.pos_config_view_form +msgid "Fixed Font Size" +msgstr "Tamaño de fuente fijo" + +#. module: pos_default_empty_image +#: model:ir.model.fields,help:pos_default_empty_image.field_pos_config__iface_fixed_font_size +#: model_terms:ir.ui.view,arch_db:pos_default_empty_image.pos_config_view_form +msgid "" +"Font size of the product name, when it has no image. Set '0' will set " +"adaptative font-size, depending on the length of the name." +msgstr "" +"Tamaño de fuente del nombre del producto, cuando no tiene imagen. Establecer " +"'0' establecerá un tamaño de fuente adaptativo, dependiendo de la longitud " +"del nombre." + +#. module: pos_default_empty_image +#: model:ir.model.fields,field_description:pos_default_empty_image.field_product_product__has_image +msgid "Has Image" +msgstr "Tiene imagen" + +#. module: pos_default_empty_image +#: model:ir.model,name:pos_default_empty_image.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del punto de venta" + +#. module: pos_default_empty_image +#: model:ir.model,name:pos_default_empty_image.model_product_product +msgid "Product" +msgstr "Producto" diff --git a/product_library/i18n/produc_library.pot b/product_library/i18n/produc_library.pot new file mode 100644 index 0000000..f81e6c5 --- /dev/null +++ b/product_library/i18n/produc_library.pot @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_library +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_default_empty_image +#: model:ir.model.fields,field_description:pos_default_empty_image.field_pos_config__iface_fixed_font_size +#: model_terms:ir.ui.view,arch_db:pos_default_empty_image.pos_config_view_form +msgid "Fixed Font Size" +msgstr "" + +#. module: pos_default_empty_image +#: model:ir.model.fields,help:pos_default_empty_image.field_pos_config__iface_fixed_font_size +#: model_terms:ir.ui.view,arch_db:pos_default_empty_image.pos_config_view_form +msgid "Font size of the product name, when it has no image. Set '0' will set adaptative font-size, depending on the length of the name." +msgstr "" + +#. module: pos_default_empty_image +#: model:ir.model.fields,field_description:pos_default_empty_image.field_product_product__has_image +msgid "Has Image" +msgstr "" + +#. module: pos_default_empty_image +#: model:ir.model,name:pos_default_empty_image.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_default_empty_image +#: model:ir.model,name:pos_default_empty_image.model_product_product +msgid "Product" +msgstr "" + diff --git a/product_library/models/__init__.py b/product_library/models/__init__.py index 9c2a35c..29f251b 100644 --- a/product_library/models/__init__.py +++ b/product_library/models/__init__.py @@ -1,2 +1,5 @@ -from . import res_product +from . import pos_config +from . import product_template +from . import product_product + diff --git a/product_library/models/__init__.py~ b/product_library/models/__init__.py~ deleted file mode 100644 index ffd3b2e..0000000 --- a/product_library/models/__init__.py~ +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2013-Today OpenERP SA (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from . import res_product - diff --git a/product_library/models/pos_config.py b/product_library/models/pos_config.py new file mode 100644 index 0000000..1acbec4 --- /dev/null +++ b/product_library/models/pos_config.py @@ -0,0 +1,16 @@ +# Copyright (C) 2020 - Today: +# GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class PosConfig(models.Model): + _inherit = 'pos.config' + + iface_fixed_font_size = fields.Integer( + string="Fixed Font Size", + help="Font size of the product name, when it has no image." + " Set '0' will set adaptative font-size, depending on the" + " length of the name.") diff --git a/product_library/models/product_product.py b/product_library/models/product_product.py new file mode 100644 index 0000000..0cb6f82 --- /dev/null +++ b/product_library/models/product_product.py @@ -0,0 +1,20 @@ +# Copyright (C) 2017 - Today: +# GRAP (http://www.grap.coop) +# Akretion (http://www.akretion.com) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields, api + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + @api.multi + @api.depends('image') + def _compute_has_image(self): + for product in self: + product.has_image = product.image + + has_image = fields.Boolean( + compute='_compute_has_image', string='Has Image', store=True) diff --git a/product_library/models/res_product.py b/product_library/models/product_template.py similarity index 100% rename from product_library/models/res_product.py rename to product_library/models/product_template.py diff --git a/product_library/static/src/css/pos.css b/product_library/static/src/css/pos.css index 3c3a110..631cf67 100644 --- a/product_library/static/src/css/pos.css +++ b/product_library/static/src/css/pos.css @@ -17,3 +17,23 @@ font-style: normal; } +/* + Copyright (C) 2014 - Today: GRAP (http://www.grap.coop) + @author Julien WESTE + @author: Sylvain LE GAL (https://twitter.com/legalsylvain) + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +*/ + +.product-img-without-image{ + height:25px !important; +} + +.product-name-without-image{ + bottom:auto !important; + top:25px !important; + padding-top:3px !important; + height:80px !important; + line-height: 20px; + text-align: center; + word-wrap: break-word; +} diff --git a/product_library/static/src/js/product_library.js b/product_library/static/src/js/models.js similarity index 77% rename from product_library/static/src/js/product_library.js rename to product_library/static/src/js/models.js index f8cc6fa..d6f7d7b 100644 --- a/product_library/static/src/js/product_library.js +++ b/product_library/static/src/js/models.js @@ -2,10 +2,12 @@ odoo.define('product_library.product_library', function (require) { "use strict"; var models = require('point_of_sale.models'); - var screens = require('point_of_sale.screens'); - var core = require('web.core'); - var gui = require('point_of_sale.gui'); - var _t = core._t; + //var screens = require('point_of_sale.screens'); + //var core = require('web.core'); + //var gui = require('point_of_sale.gui'); + //var _t = core._t; + + models.load_fields("product.product", ['has_image']); /* ******************************************************** Overload models.PosModel @@ -15,7 +17,7 @@ Overload models.PosModel models.PosModel = models.PosModel.extend({ initialize: function (session, attributes) { - this.member_categories = []; + //this.member_categories = []; var product_model = _.find(this.models, function(model){ return model.model === 'product.product'; }); //product_model.fields.push('default_code'); diff --git a/product_library/static/src/js/widgets.js b/product_library/static/src/js/widgets.js new file mode 100644 index 0000000..79aa672 --- /dev/null +++ b/product_library/static/src/js/widgets.js @@ -0,0 +1,42 @@ +odoo.define('product_library.widgets', function (require) { + "use strict"; + + var screens = require('point_of_sale.screens'); + + var core = require('web.core'); + + var QWeb = core.qweb; + + //don't try to get an image if we know the product ain't one + var ProductListImageWidget = screens.ProductListWidget.include({ + get_product_image_url: function(product){ + if (product.has_image) + return this._super(product); + }, + + // Change product display if product has no image; + render_product: function(product){ + if (product.has_image){ + return this._super(product); + } + else { + var current_pricelist = this._get_active_pricelist(); + var cache_key = this.calculate_cache_key(product, current_pricelist); + var cached = this.product_cache.get_node(cache_key); + if(!cached){ + var product_html = QWeb.render('ProductNoImage',{ + widget: this, + product: product, + pricelist: current_pricelist, + }); + var product_node = document.createElement('div'); + product_node.innerHTML = product_html; + product_node = product_node.childNodes[1]; + this.product_cache.cache_node(cache_key,product_node); + return product_node; + } + return cached; + } + }, + }); +}); diff --git a/product_library/static/src/xml/pos.xml b/product_library/static/src/xml/pos.xml index 1bd5c31..1203191 100644 --- a/product_library/static/src/xml/pos.xml +++ b/product_library/static/src/xml/pos.xml @@ -26,4 +26,44 @@ + +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+
+ +
+
+
+ + + diff --git a/product_library/views/pos_config.xml b/product_library/views/pos_config.xml new file mode 100644 index 0000000..1b594ae --- /dev/null +++ b/product_library/views/pos_config.xml @@ -0,0 +1,29 @@ + + + + + + + pos.config + + + + +
+
+
+
+ +
+
+
+ +
diff --git a/product_library/views/templates.xml b/product_library/views/templates.xml index 4b698b9..3d44656 100644 --- a/product_library/views/templates.xml +++ b/product_library/views/templates.xml @@ -3,8 +3,9 @@