From bcf5b7584b45f47f58ac961dbb79cd43f29f56df Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Tue, 28 Feb 2017 18:28:44 +0100 Subject: [PATCH] pos_remove_pos_category (#148) * migrate to v9 and add italian translation * short headers * migrate JS * [fix] be defensive: do not assume we have a product category --- pos_remove_pos_category/README.rst | 1 + pos_remove_pos_category/__init__.py | 24 ++------- pos_remove_pos_category/__manifest__.py | 33 +++--------- pos_remove_pos_category/i18n/fr.po | 2 +- pos_remove_pos_category/i18n/it.po | 54 +++++++++++++++++++ .../i18n/pos_remove_pos_category.pot | 3 +- pos_remove_pos_category/models/__init__.py | 2 + .../{ => models}/module.py | 21 +------- .../{ => models}/product.py | 24 ++------- .../point_of_sale_view.xml | 19 ------- .../static/src/js/pos_remove_pos_category.js | 48 ++++++++--------- pos_remove_pos_category/views/assets.xml | 9 ++++ .../views/pos_category.xml | 41 -------------- .../views/pos_category_view.xml | 30 +++++++++++ pos_remove_pos_category/views/pos_view.xml | 17 ++++++ 15 files changed, 153 insertions(+), 175 deletions(-) create mode 100644 pos_remove_pos_category/i18n/it.po create mode 100644 pos_remove_pos_category/models/__init__.py rename pos_remove_pos_category/{ => models}/module.py (63%) rename pos_remove_pos_category/{ => models}/product.py (74%) delete mode 100644 pos_remove_pos_category/point_of_sale_view.xml create mode 100644 pos_remove_pos_category/views/assets.xml delete mode 100644 pos_remove_pos_category/views/pos_category.xml create mode 100644 pos_remove_pos_category/views/pos_category_view.xml create 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 index 93c6eb74..bcdee09d 100644 --- a/pos_remove_pos_category/README.rst +++ b/pos_remove_pos_category/README.rst @@ -47,6 +47,7 @@ Contributors ------------ * Sylvain Calador +* Simone Orsi Maintainer ---------- diff --git a/pos_remove_pos_category/__init__.py b/pos_remove_pos_category/__init__.py index 5f45a17f..d5e4731a 100644 --- a/pos_remove_pos_category/__init__.py +++ b/pos_remove_pos_category/__init__.py @@ -1,23 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2015-TODAY Akretion (). -# -# 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 . -# -############################################################################## +# Copyright (C) 2015-TODAY Akretion (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import product -from . import module +from . import models diff --git a/pos_remove_pos_category/__manifest__.py b/pos_remove_pos_category/__manifest__.py index 16a5a129..87eec41b 100644 --- a/pos_remove_pos_category/__manifest__.py +++ b/pos_remove_pos_category/__manifest__.py @@ -1,28 +1,10 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2015-TODAY Akretion (). -# -# 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 . -# -############################################################################## - +# Copyright (C) 2015-TODAY Akretion (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'POS Remove POS Category', - 'version': '8.0.0.1.0', - 'author': 'Akretion, Odoo Community Association (OCA)', + 'version': '9.0.0.1.0', + 'author': 'Akretion, Camptocamp SA, Odoo Community Association (OCA)', 'category': 'Sales Management', 'depends': [ 'point_of_sale', @@ -30,8 +12,9 @@ 'demo': [], 'website': 'https://www.akretion.com', 'data': [ - 'point_of_sale_view.xml', - 'views/pos_category.xml', + 'views/assets.xml', + 'views/pos_view.xml', + 'views/pos_category_view.xml', ], - 'installable': False, + 'installable': True, } diff --git a/pos_remove_pos_category/i18n/fr.po b/pos_remove_pos_category/i18n/fr.po index 3eb0223c..f5012eb8 100644 --- a/pos_remove_pos_category/i18n/fr.po +++ b/pos_remove_pos_category/i18n/fr.po @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"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 09:20+0100\n" diff --git a/pos_remove_pos_category/i18n/it.po b/pos_remove_pos_category/i18n/it.po new file mode 100644 index 00000000..32452d51 --- /dev/null +++ b/pos_remove_pos_category/i18n/it.po @@ -0,0 +1,54 @@ +# 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: 2017-01-23 13:13+0100\n" +"Last-Translator: Simone Orsi \n" +"Language-Team: \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.8.9\n" + +#. module: pos_remove_pos_category +#: view:product.category:pos_remove_pos_category.product_category_list_view +msgid "Available in POS" +msgstr "Disponibile nel POS" + +#. module: pos_remove_pos_category +#: field:product.category,available_in_pos:0 +msgid "Available in the Point of Sale" +msgstr "Disponibile nel POS" + +#. 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 "" +"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,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" diff --git a/pos_remove_pos_category/i18n/pos_remove_pos_category.pot b/pos_remove_pos_category/i18n/pos_remove_pos_category.pot index be5c8f97..752acaeb 100644 --- a/pos_remove_pos_category/i18n/pos_remove_pos_category.pot +++ b/pos_remove_pos_category/i18n/pos_remove_pos_category.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"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" @@ -45,4 +45,3 @@ msgstr "" #: 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 new file mode 100644 index 00000000..af4a9dcf --- /dev/null +++ b/pos_remove_pos_category/models/__init__.py @@ -0,0 +1,2 @@ +from . import module +from . import product diff --git a/pos_remove_pos_category/module.py b/pos_remove_pos_category/models/module.py similarity index 63% rename from pos_remove_pos_category/module.py rename to pos_remove_pos_category/models/module.py index b94d925b..3b12e6f0 100644 --- a/pos_remove_pos_category/module.py +++ b/pos_remove_pos_category/models/module.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2015-TODAY Akretion (). -# -# 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 . -# -############################################################################## +# Copyright (C) 2015-TODAY Akretion (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models diff --git a/pos_remove_pos_category/product.py b/pos_remove_pos_category/models/product.py similarity index 74% rename from pos_remove_pos_category/product.py rename to pos_remove_pos_category/models/product.py index 7cee84f1..52fc0e8e 100644 --- a/pos_remove_pos_category/product.py +++ b/pos_remove_pos_category/models/product.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2015-TODAY Akretion (). -# -# 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 . -# -############################################################################## +# 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 @@ -31,7 +14,8 @@ class ProductTemplate(models.Model): @api.model def create(self, vals): - vals['pos_categ_id'] = vals['categ_id'] + if 'categ_id' in vals: + vals['pos_categ_id'] = vals['categ_id'] return super(ProductTemplate, self).create(vals) @api.multi diff --git a/pos_remove_pos_category/point_of_sale_view.xml b/pos_remove_pos_category/point_of_sale_view.xml deleted file mode 100644 index 29cb8281..00000000 --- a/pos_remove_pos_category/point_of_sale_view.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - product.template.form.inherit - product.template - - - - - 1 - - - - - product.category - - - 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 index ed409ca5..fc1b2ad3 100644 --- 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 @@ -1,44 +1,38 @@ /****************************************************************************** - * Point Of Sale - Pricelist for POS Odoo - * Copyright (C) 2015-TODAY Akretion (http://www.akretion.com) - * @author Sylvain Calador - * - * 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 . - * + * Copyright (C) 2015-2016 Akretion (). + * Copyright (C) 2017-TODAY Camptocamp SA (). + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). ******************************************************************************/ -openerp.pos_remove_pos_category = function(instance, local) { - module = instance.point_of_sale; +odoo.define('pos_remove_pos_category.remove_pos_category', function (require) { + "use strict"; - var initialize_original = module.PosModel.prototype.initialize; - module.PosModel = module.PosModel.extend({ + 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 initialize_original.call(this, session, attributes); + return _pos_super.initialize.apply(this, arguments); } - }); + }); - //override method js POS (widgets.js) - //change pos.category by product.category - module.ProductCategoriesWidget = module.ProductCategoriesWidget.extend({ + // override method js POS (widgets.js) + // change pos.category by product.category + pos_screens.ProductCategoriesWidget.include({ get_image_url: function(category){ - return window.location.origin + '/web/binary/image?model=product.category&field=image_medium&id='+category.id; + 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 new file mode 100644 index 00000000..5cb4e69a --- /dev/null +++ b/pos_remove_pos_category/views/assets.xml @@ -0,0 +1,9 @@ + + + + diff --git a/pos_remove_pos_category/views/pos_category.xml b/pos_remove_pos_category/views/pos_category.xml deleted file mode 100644 index f904ea8a..00000000 --- a/pos_remove_pos_category/views/pos_category.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - product.category - - - 20 - - - - - -
- -
-
-
-
- - - product.category - - - - - - - -
-
diff --git a/pos_remove_pos_category/views/pos_category_view.xml b/pos_remove_pos_category/views/pos_category_view.xml new file mode 100644 index 00000000..f33d0613 --- /dev/null +++ b/pos_remove_pos_category/views/pos_category_view.xml @@ -0,0 +1,30 @@ + + + + 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 new file mode 100644 index 00000000..c8e3cc54 --- /dev/null +++ b/pos_remove_pos_category/views/pos_view.xml @@ -0,0 +1,17 @@ + + + + product.template.form.inherit + product.template + + + + + 1 + + + + + product.category + +