From 22d71e80dcf4610a831f94af818fcdbb89134d05 Mon Sep 17 00:00:00 2001 From: santiky Date: Mon, 9 Aug 2021 19:43:59 +0200 Subject: [PATCH] =?UTF-8?q?b=C3=BAsqueda=20en=20el=20TPV=20por=20referenci?= =?UTF-8?q?a,=20autor,=20g=C3=A9nero=20y=20editorial.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit backup files atacks again... --- .gitignore | 1 + product_library/__manifest__.py | 15 ++- product_library/__manifest__.py~ | 9 +- .../data/product_code_sequence.xml | 113 ------------------ product_library/static/src/js/db.js | 28 +++++ .../static/src/js/product_library.js | 28 +++++ product_library/views/templates.xml | 24 ++-- 7 files changed, 82 insertions(+), 136 deletions(-) delete mode 100644 product_library/data/product_code_sequence.xml create mode 100644 product_library/static/src/js/db.js create mode 100644 product_library/static/src/js/product_library.js diff --git a/.gitignore b/.gitignore index 13d1490..e7c761b 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,4 @@ dmypy.json # Pyre type checker .pyre/ +*~ diff --git a/product_library/__manifest__.py b/product_library/__manifest__.py index db51d95..da1daff 100644 --- a/product_library/__manifest__.py +++ b/product_library/__manifest__.py @@ -4,20 +4,23 @@ 'name': 'Product Library', 'category': 'Product', 'summary': 'Add library related fields to product', - 'version': '0.1', + 'version': '12.0.1.0.0', 'description': """ -Add several fields to product for libraries +Addon mejora de Odoo para librerías y tiendas de discos ================================================== -Autor, coleccion, ISBN,.... +* Añade campos a product: Editorial, autor, género, formato,... +* Hace búsquedas en el TPV y backend en esos campos nuevos """, 'author': 'Criptomart', - 'depends': ['product'], + 'depends': [ + 'product', + 'point_of_sale', + ], 'data': [ 'views/product.xml', - #'views/templates.xml', - 'data/product_code_sequence.xml', + 'views/templates.xml' ], 'demo': [], 'installable': True, diff --git a/product_library/__manifest__.py~ b/product_library/__manifest__.py~ index 5318162..2169b32 100644 --- a/product_library/__manifest__.py~ +++ b/product_library/__manifest__.py~ @@ -13,12 +13,15 @@ Autor, coleccion, ISBN,.... """, 'author': 'Criptomart', - 'depends': ['product'], + 'depends': [ + 'product', + 'point_of_sale', + ], 'data': [ 'views/product.xml', - #'views/templates.xml', - 'data/product_code_sequence.xml', + 'views/templates.xml' ], + 'demo': [], 'installable': True, 'auto_install': False, 'application': True, diff --git a/product_library/data/product_code_sequence.xml b/product_library/data/product_code_sequence.xml deleted file mode 100644 index b373cca..0000000 --- a/product_library/data/product_code_sequence.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - Product Code LP - product.template.code.lp - DD-LP - 3057 - 4 - - - - Product Code Casete - product.template.code.k7 - DD-K7 - 3006 - 4 - - - - Product Code CD - product.template.code.cd - DD-CD - 3040 - 4 - - - - Product Code Single - product.template.code.sg - DD-SG - 3022 - 4 - - - - Product Code Libro - product.template.code.lb - DD-LB - 3055 - 4 - - - - Product Code Libelos - product.template.code.lx - DD-LX - 3015 - 4 - - - - Product Code Video - product.template.code.vi - DD-VI - 3002 - 4 - - - - Product Code Textil - product.template.code.tx - DD-TX - 3019 - 4 - - - - diff --git a/product_library/static/src/js/db.js b/product_library/static/src/js/db.js new file mode 100644 index 0000000..ce7863c --- /dev/null +++ b/product_library/static/src/js/db.js @@ -0,0 +1,28 @@ + odoo.define('product_library', function (require) { + + "use strict"; + var db = require("point_of_sale.DB"); + db.include({ + + _product_search_string: function(product){ + var str = product.name; + if(product.default_code){ + str += '|' + product.default_code; + } + if(product.autor){ + str += '|' + product.autor; + } + if(product.genero){ + str += '|' + product.genero; + } + if(product.editorial){ + str += '|' + product.editorial; + } + str = '' + product.id + ':' + str.replace(':','') + '\n'; + return str; + }, + }); + + return db; + + }); diff --git a/product_library/static/src/js/product_library.js b/product_library/static/src/js/product_library.js new file mode 100644 index 0000000..a932ef0 --- /dev/null +++ b/product_library/static/src/js/product_library.js @@ -0,0 +1,28 @@ +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; + +/* ******************************************************** +Overload models.PosModel +******************************************************** */ + + var _super_posmodel = models.PosModel.prototype; + models.PosModel = models.PosModel.extend({ + initialize: function (session, attributes) { + + this.member_categories = []; + + var product_model = _.find(this.models, function(model){ return model.model === 'product.product'; }); + product_model.fields.push('default_code'); + product_model.fields.push('autor'); + product_model.fields.push('editorial'); + product_model.fields.push('genero'); + return _super_posmodel.initialize.apply(this, arguments); + } + }); +}); diff --git a/product_library/views/templates.xml b/product_library/views/templates.xml index 201812c..aa04332 100644 --- a/product_library/views/templates.xml +++ b/product_library/views/templates.xml @@ -1,14 +1,10 @@ - - - - - + + +