From 88e1081b80109a81c47cf428e06388764d5bde8e Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 21 Aug 2017 12:09:44 +0200 Subject: [PATCH] [REM] remove pos_remove_pos_category Fix : #200 --- pos_remove_pos_category/README.rst | 63 ------------- pos_remove_pos_category/__init__.py | 5 - pos_remove_pos_category/__openerp__.py | 20 ---- pos_remove_pos_category/i18n/ca.po | 73 --------------- pos_remove_pos_category/i18n/fr.po | 73 --------------- pos_remove_pos_category/i18n/it.po | 73 --------------- .../i18n/pos_remove_pos_category.pot | 47 ---------- pos_remove_pos_category/models/__init__.py | 2 - pos_remove_pos_category/models/module.py | 53 ----------- pos_remove_pos_category/models/product.py | 91 ------------------- .../static/src/js/pos_remove_pos_category.js | 38 -------- pos_remove_pos_category/views/assets.xml | 9 -- .../views/pos_category_view.xml | 30 ------ pos_remove_pos_category/views/pos_view.xml | 17 ---- 14 files changed, 594 deletions(-) delete mode 100644 pos_remove_pos_category/README.rst delete mode 100644 pos_remove_pos_category/__init__.py delete mode 100644 pos_remove_pos_category/__openerp__.py delete mode 100644 pos_remove_pos_category/i18n/ca.po delete mode 100644 pos_remove_pos_category/i18n/fr.po delete mode 100644 pos_remove_pos_category/i18n/it.po delete mode 100644 pos_remove_pos_category/i18n/pos_remove_pos_category.pot delete mode 100644 pos_remove_pos_category/models/__init__.py delete mode 100644 pos_remove_pos_category/models/module.py delete mode 100644 pos_remove_pos_category/models/product.py delete mode 100644 pos_remove_pos_category/static/src/js/pos_remove_pos_category.js delete mode 100644 pos_remove_pos_category/views/assets.xml delete mode 100644 pos_remove_pos_category/views/pos_category_view.xml delete mode 100644 pos_remove_pos_category/views/pos_view.xml diff --git a/pos_remove_pos_category/README.rst b/pos_remove_pos_category/README.rst deleted file mode 100644 index bcdee09d63..0000000000 --- a/pos_remove_pos_category/README.rst +++ /dev/null @@ -1,63 +0,0 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License - -POS Remove POS Category -======================= - -This module was written to replace POS categories by product categories -in the point of sale. - -Important notes ---------------- -- When the module is installed the link beetween products and POS categories - is **overwritten** by a link beetween products and product categories - (the link is the field pos_categ_id in the table product_template) -- When the module is uninstalled the link beetween products and POS categories - is restored in an **empty** state (NULL values) - -Installation -============ - -This module depends on the `point_of_sale` Odoo official module. - -Configuration -============= - -No configuration is needed just use product categories as standard -pos categories. -You may uncheck 'Available in the Point of Sale' field -in regular product categories if you want that a category becomes invisible -in POS. -Children categories will becomes invisible too, whatever their checkbox state. - - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. - - -Credits -======= - -Contributors ------------- - -* Sylvain Calador -* Simone Orsi - -Maintainer ----------- - -.. image:: http://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org - -This module is maintained by the OCA. - -OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. - -To contribute to this module, please visit http://odoo-community.org. diff --git a/pos_remove_pos_category/__init__.py b/pos_remove_pos_category/__init__.py deleted file mode 100644 index d5e4731ac4..0000000000 --- a/pos_remove_pos_category/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2015-TODAY Akretion (). -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from . import models diff --git a/pos_remove_pos_category/__openerp__.py b/pos_remove_pos_category/__openerp__.py deleted file mode 100644 index 87eec41b14..0000000000 --- a/pos_remove_pos_category/__openerp__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2015-TODAY Akretion (). -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -{ - 'name': 'POS Remove POS Category', - 'version': '9.0.0.1.0', - 'author': 'Akretion, Camptocamp SA, Odoo Community Association (OCA)', - 'category': 'Sales Management', - 'depends': [ - 'point_of_sale', - ], - 'demo': [], - 'website': 'https://www.akretion.com', - 'data': [ - 'views/assets.xml', - 'views/pos_view.xml', - 'views/pos_category_view.xml', - ], - 'installable': True, -} diff --git a/pos_remove_pos_category/i18n/ca.po b/pos_remove_pos_category/i18n/ca.po deleted file mode 100644 index 7d905a2fcb..0000000000 --- a/pos_remove_pos_category/i18n/ca.po +++ /dev/null @@ -1,73 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_remove_pos_category -# -# Translators: -# Marc Tormo i Bochaca , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-28 05:50+0000\n" -"PO-Revision-Date: 2017-03-28 05:50+0000\n" -"Last-Translator: Marc Tormo i Bochaca , 2017\n" -"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: ca\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: pos_remove_pos_category -#: model:ir.ui.view,arch_db:pos_remove_pos_category.product_category_list_view -msgid "Available in POS" -msgstr "Disponible al TPV" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_available_in_pos -msgid "Available in the Point of Sale" -msgstr "Disponible al Punt de Venda " - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_available_in_pos -msgid "" -"Check if you want this category to appear in Point Of Sale.\n" -"If you uncheck, children categories will becomes invisible too, whatever their checkbox state." -msgstr "" -"Marqueu si voleu que aquesta categoria aparegui al Punt de Venda.\n" -"Si el desmarqueu, les categories filles també es tornaran invisibles, encara que estiguin marcades. " - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_image -msgid "Image" -msgstr "Imatge" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_image_medium -msgid "Image medium" -msgstr "Imatge mitjana " - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_ir_module_module -msgid "Module" -msgstr "Mòdul " - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_category -msgid "Product Category" -msgstr "Categoria de Producte " - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_template -msgid "Product Template" -msgstr "Plantilla de Producte " - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_image -msgid "Show Image Category in Form View" -msgstr "Mostra la imatge de la categoria a la vista del formulari " - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_image_medium -msgid "Show image category button in POS" -msgstr "Mostra la imatge de la categoria al TPV " diff --git a/pos_remove_pos_category/i18n/fr.po b/pos_remove_pos_category/i18n/fr.po deleted file mode 100644 index 738cb1b2e7..0000000000 --- a/pos_remove_pos_category/i18n/fr.po +++ /dev/null @@ -1,73 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_remove_pos_category -# -# Translators: -# OCA Transbot , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-01 04:05+0000\n" -"PO-Revision-Date: 2017-03-01 04:05+0000\n" -"Last-Translator: OCA Transbot , 2017\n" -"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: fr\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" - -#. module: pos_remove_pos_category -#: model:ir.ui.view,arch_db:pos_remove_pos_category.product_category_list_view -msgid "Available in POS" -msgstr "Disponible dans le PDV" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_available_in_pos -msgid "Available in the Point of Sale" -msgstr "Disponible dans le Point de Vente" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_available_in_pos -msgid "" -"Check if you want this category to appear in Point Of Sale.\n" -"If you uncheck, children categories will becomes invisible too, whatever their checkbox state." -msgstr "" -"Cochez si vous voulez que cette catégorie apparaisse dans le Point de Vente.\n" -"Si vous décochez, les catégories enfants deviendront invisible également, quel que soit l'état de leur case à cocher." - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_image -msgid "Image" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_image_medium -msgid "Image medium" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_ir_module_module -msgid "Module" -msgstr "Module" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_category -msgid "Product Category" -msgstr "Catégorie de Produit" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_template -msgid "Product Template" -msgstr "Modèle d'article" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_image -msgid "Show Image Category in Form View" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_image_medium -msgid "Show image category button in POS" -msgstr "" diff --git a/pos_remove_pos_category/i18n/it.po b/pos_remove_pos_category/i18n/it.po deleted file mode 100644 index 6219fde985..0000000000 --- a/pos_remove_pos_category/i18n/it.po +++ /dev/null @@ -1,73 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_remove_pos_category -# -# Translators: -# OCA Transbot , 2017 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-01 04:05+0000\n" -"PO-Revision-Date: 2017-03-01 04:05+0000\n" -"Last-Translator: OCA Transbot , 2017\n" -"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: it\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: pos_remove_pos_category -#: model:ir.ui.view,arch_db:pos_remove_pos_category.product_category_list_view -msgid "Available in POS" -msgstr "Disponibile nel POS" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_available_in_pos -msgid "Available in the Point of Sale" -msgstr "Disponibile nel POS" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_available_in_pos -msgid "" -"Check if you want this category to appear in Point Of Sale.\n" -"If you uncheck, children categories will becomes invisible too, whatever their checkbox state." -msgstr "" -"Attiva per far apparire questa categoria nel POS.\n" -"Se disattivato, anche le sotto-categorie saranno nascoste, anche se attivate singolarmente." - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_image -msgid "Image" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,field_description:pos_remove_pos_category.field_product_category_image_medium -msgid "Image medium" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_ir_module_module -msgid "Module" -msgstr "Module" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_category -msgid "Product Category" -msgstr "Categoria Prodotto" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_template -msgid "Product Template" -msgstr "Template Prodotto" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_image -msgid "Show Image Category in Form View" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model.fields,help:pos_remove_pos_category.field_product_category_image_medium -msgid "Show image category button in POS" -msgstr "" diff --git a/pos_remove_pos_category/i18n/pos_remove_pos_category.pot b/pos_remove_pos_category/i18n/pos_remove_pos_category.pot deleted file mode 100644 index 752acaeb88..0000000000 --- a/pos_remove_pos_category/i18n/pos_remove_pos_category.pot +++ /dev/null @@ -1,47 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_remove_pos_category -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 9.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 07:13+0000\n" -"PO-Revision-Date: 2015-07-24 07:13+0000\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_remove_pos_category -#: view:product.category:pos_remove_pos_category.product_category_list_view -msgid "Available in POS" -msgstr "" - -#. module: pos_remove_pos_category -#: field:product.category,available_in_pos:0 -msgid "Available in the Point of Sale" -msgstr "" - -#. module: pos_remove_pos_category -#: help:product.category,available_in_pos:0 -msgid "Check if you want this category to appear in Point Of Sale.\n" -"If you uncheck, children categories will becomes invisible too, whatever their checkbox state." -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_ir_module_module -msgid "Module" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_category -msgid "Product Category" -msgstr "" - -#. module: pos_remove_pos_category -#: model:ir.model,name:pos_remove_pos_category.model_product_template -msgid "Product Template" -msgstr "" diff --git a/pos_remove_pos_category/models/__init__.py b/pos_remove_pos_category/models/__init__.py deleted file mode 100644 index af4a9dcf13..0000000000 --- a/pos_remove_pos_category/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import module -from . import product diff --git a/pos_remove_pos_category/models/module.py b/pos_remove_pos_category/models/module.py deleted file mode 100644 index 3b12e6f088..0000000000 --- a/pos_remove_pos_category/models/module.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2015-TODAY Akretion (). -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openerp import models - - -class Module(models.Model): - - _inherit = 'ir.module.module' - - def module_uninstall(self, cr, uid, ids, context=None): - - context = context or {} - - for module in self.browse(cr, uid, ids, context=context): - if module.name == 'pos_remove_pos_category': - - # As we have loose previous POS categs restore them - # in a sane empty state - - cr.execute('UPDATE product_template SET pos_categ_id=NULL') - - # And restore original constraint - cr.execute(''' - ALTER TABLE product_template - DROP CONSTRAINT IF EXISTS - product_template_pos_categ_id_fkey - ''') - - cr.execute(''' - ALTER TABLE product_template ADD CONSTRAINT - "product_template_pos_categ_id_fkey" - FOREIGN KEY (pos_categ_id) - REFERENCES pos_category(id) ON DELETE SET NULL; - ''') - - # Restore POS category menu action - # in SQL because pool/env is not available here - cr.execute(''' - UPDATE ir_act_window iaw SET res_model='pos.category' - FROM ir_model_data imd - WHERE - iaw.id = imd.res_id AND - imd.model = 'ir.actions.act_window' AND - imd.name = 'product_pos_category_action' - ''') - - break - - return super(Module, self).module_uninstall( - cr, uid, ids, context=context - ) diff --git a/pos_remove_pos_category/models/product.py b/pos_remove_pos_category/models/product.py deleted file mode 100644 index 52fc0e8e1c..0000000000 --- a/pos_remove_pos_category/models/product.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2015-TODAY Akretion (). -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -import sys -from openerp import models, fields, api, tools - - -class ProductTemplate(models.Model): - _inherit = 'product.template' - - pos_categ_id = fields.Many2one('product.category', - store=True, related='categ_id') - - @api.model - def create(self, vals): - if 'categ_id' in vals: - vals['pos_categ_id'] = vals['categ_id'] - return super(ProductTemplate, self).create(vals) - - @api.multi - def write(self, vals): - if 'pos_categ_id' in vals and not vals['pos_categ_id']: - del vals['pos_categ_id'] - return super(ProductTemplate, self).write(vals) - - -class ProductCategory(models.Model): - _inherit = 'product.category' - - image = fields.Binary(help='Show Image Category in Form View') - image_medium = fields.Binary(help='Show image category button in POS', - compute="_get_image", - inverse="_set_image", - store=True) - available_in_pos = fields.Boolean( - string="Available in the Point of Sale", - default=True, - help="Check if you want this category to appear in Point Of Sale.\n" - "If you uncheck, children categories will becomes invisible too, " - "whatever their checkbox state.") - - @api.multi - def _get_image(self): - return dict( - (rec.id, tools.image_get_resized_images(rec.image)) for rec in - self) - - @api.one - def _set_image(self): - return self.write( - {'image': tools.image_resize_image_big(self.image_medium)}) - - -_auto_end_original = models.BaseModel._auto_end - - -def _auto_end(self, cr, context=None): - """ Create the foreign keys recorded by _auto_init. - (pos_remove_pos_category monkey patching) - """ - context = context or {} - module = context['module'] - foreign_keys = [] - patched = 'openerp.addons.pos_remove_pos_category' in sys.modules - - for t, k, r, d in self._foreign_keys: - if patched and (t, k) == ('product_template', 'pos_categ_id'): - if module == 'pos_remove_pos_category': - cr.execute(''' - ALTER TABLE product_template - DROP CONSTRAINT IF EXISTS - product_template_pos_categ_id_fkey - ''') - cr.execute(''' - UPDATE product_template - SET pos_categ_id = categ_id; - ''') - cr.execute(''' - ALTER TABLE product_template ADD CONSTRAINT - "product_template_pos_categ_id_fkey" - FOREIGN KEY (pos_categ_id) - REFERENCES product_category(id) ON DELETE SET NULL; - ''') - continue - foreign_keys.append((t, k, r, d)) - self._foreign_keys = foreign_keys - return _auto_end_original(self, cr, context=context) - - -models.BaseModel._auto_end = _auto_end diff --git a/pos_remove_pos_category/static/src/js/pos_remove_pos_category.js b/pos_remove_pos_category/static/src/js/pos_remove_pos_category.js deleted file mode 100644 index fc1b2ad322..0000000000 --- a/pos_remove_pos_category/static/src/js/pos_remove_pos_category.js +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015-2016 Akretion (). - * Copyright (C) 2017-TODAY Camptocamp SA (). - * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - ******************************************************************************/ - -odoo.define('pos_remove_pos_category.remove_pos_category', function (require) { - "use strict"; - - var core = require('web.core'); - var pos_models = require('point_of_sale.models'); - var pos_screens = require('point_of_sale.screens'); - var Model = require('web.DataModel'); - var _t = core._t; - - var _pos_super = pos_models.PosModel.prototype; - pos_models.PosModel = pos_models.PosModel.extend({ - initialize: function(session, attributes) { - for (var i = 0 ; i < this.models.length; i++){ - if (this.models[i].model == 'pos.category') { - this.models[i].model = 'product.category'; - this.models[i].domain = [['available_in_pos', '=', true]]; - } - } - return _pos_super.initialize.apply(this, arguments); - } - }); - - // override method js POS (widgets.js) - // change pos.category by product.category - pos_screens.ProductCategoriesWidget.include({ - get_image_url: function(category){ - var image_url = '/web/binary/image?model=product.category&field=image_medium&id='; - return window.location.origin + image_url + category.id; - } - }); - -}); diff --git a/pos_remove_pos_category/views/assets.xml b/pos_remove_pos_category/views/assets.xml deleted file mode 100644 index 5cb4e69a2a..0000000000 --- a/pos_remove_pos_category/views/assets.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/pos_remove_pos_category/views/pos_category_view.xml b/pos_remove_pos_category/views/pos_category_view.xml deleted file mode 100644 index f33d061374..0000000000 --- a/pos_remove_pos_category/views/pos_category_view.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - product.category - - - 20 - - - - - - - - - - - - product.category - - - - - - - - diff --git a/pos_remove_pos_category/views/pos_view.xml b/pos_remove_pos_category/views/pos_view.xml deleted file mode 100644 index c8e3cc549a..0000000000 --- a/pos_remove_pos_category/views/pos_view.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - product.template.form.inherit - product.template - - - - - 1 - - - - - product.category - -