diff --git a/hw_customer_display/controllers/main.py b/hw_customer_display/controllers/main.py index e2184f7b..f6e4358b 100644 --- a/hw_customer_display/controllers/main.py +++ b/hw_customer_display/controllers/main.py @@ -26,15 +26,18 @@ import simplejson import time from threading import Thread, Lock from Queue import Queue -from unidecode import unidecode -from serial import Serial import openerp.addons.hw_proxy.controllers.main as hw_proxy from openerp import http from openerp.tools.config import config - logger = logging.getLogger(__name__) +try: + from serial import Serial + from unidecode import unidecode +except (ImportError, IOError) as err: + logger.debug(err) + class CustomerDisplayDriver(Thread): def __init__(self): @@ -164,6 +167,7 @@ class CustomerDisplayDriver(Thread): except Exception as e: self.set_status('error', str(e)) + driver = CustomerDisplayDriver() hw_proxy.drivers['customer_display'] = driver diff --git a/hw_customer_display/test-scripts/customer-display-test.py b/hw_customer_display/test-scripts/customer-display-test.py index ad3a50d4..3c7748df 100755 --- a/hw_customer_display/test-scripts/customer-display-test.py +++ b/hw_customer_display/test-scripts/customer-display-test.py @@ -6,9 +6,16 @@ # with the customer display independantly from the Odoo server # It has been tested with a Bixolon BCD-1100 -from serial import Serial -from unidecode import unidecode import sys +import logging + +_logger = logging.getLogger(__name__) + +try: + from serial import Serial + from unidecode import unidecode +except (ImportError, IOError) as err: + _logger.debug(err) DEVICE = '/dev/ttyUSB0' DEVICE_RATE = 9600 diff --git a/hw_telium_payment_terminal/controllers/main.py b/hw_telium_payment_terminal/controllers/main.py index 563d2cc9..8bd11ede 100644 --- a/hw_telium_payment_terminal/controllers/main.py +++ b/hw_telium_payment_terminal/controllers/main.py @@ -27,15 +27,18 @@ import time import curses.ascii from threading import Thread, Lock from Queue import Queue -from serial import Serial -import pycountry import openerp.addons.hw_proxy.controllers.main as hw_proxy from openerp import http from openerp.tools.config import config - logger = logging.getLogger(__name__) +try: + import pycountry + from serial import Serial +except (ImportError, IOError) as err: + logger.debug(err) + class TeliumPaymentTerminalDriver(Thread): def __init__(self): @@ -268,6 +271,7 @@ class TeliumPaymentTerminalDriver(Thread): except Exception as e: self.set_status('error', str(e)) + driver = TeliumPaymentTerminalDriver() hw_proxy.drivers['telium_payment_terminal'] = driver diff --git a/pos_remove_pos_category/__openerp__.py b/pos_remove_pos_category/__openerp__.py index 3c1592e6..0f1566f8 100644 --- a/pos_remove_pos_category/__openerp__.py +++ b/pos_remove_pos_category/__openerp__.py @@ -1,23 +1,7 @@ # -*- 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 . -# -############################################################################## +# © 2016 Akretion (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# -*- encoding: utf-8 -*- { 'name': 'POS Remove POS Category', @@ -34,4 +18,6 @@ 'views/pos_category.xml', ], 'installable': True, + "license": "AGPL-3", + } diff --git a/pos_remove_pos_category/module.py b/pos_remove_pos_category/module.py index b94d925b..d642fcdf 100644 --- a/pos_remove_pos_category/module.py +++ b/pos_remove_pos_category/module.py @@ -19,33 +19,32 @@ # ############################################################################## -from openerp import models +from openerp import models, api 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): + @api.multi + def module_uninstall(self): + for module in self: 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') + self.env.cr.execute(''' + UPDATE product_template SET pos_categ_id=NULL; + ''') # And restore original constraint - cr.execute(''' + self.env.cr.execute(''' ALTER TABLE product_template DROP CONSTRAINT IF EXISTS - product_template_pos_categ_id_fkey + product_template_pos_categ_id_fkey; ''') - cr.execute(''' + self.env.cr.execute(''' ALTER TABLE product_template ADD CONSTRAINT "product_template_pos_categ_id_fkey" FOREIGN KEY (pos_categ_id) @@ -54,17 +53,15 @@ class Module(models.Model): # Restore POS category menu action # in SQL because pool/env is not available here - cr.execute(''' + self.env.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' + imd.name = 'product_pos_category_action'; ''') break - return super(Module, self).module_uninstall( - cr, uid, ids, context=context - ) + return super(Module, self).module_uninstall() diff --git a/pos_remove_pos_category/product.py b/pos_remove_pos_category/product.py index 7cee84f1..1396912a 100644 --- a/pos_remove_pos_category/product.py +++ b/pos_remove_pos_category/product.py @@ -46,8 +46,8 @@ class ProductCategory(models.Model): 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", + compute="_compute_get_image", + inverse="_inverse_set_image", store=True) available_in_pos = fields.Boolean( string="Available in the Point of Sale", @@ -57,13 +57,14 @@ class ProductCategory(models.Model): "whatever their checkbox state.") @api.multi - def _get_image(self): + def _compute_get_image(self): return dict( (rec.id, tools.image_get_resized_images(rec.image)) for rec in self) - @api.one - def _set_image(self): + @api.multi + def _inverse_set_image(self): + self.ensure_one() return self.write( {'image': tools.image_resize_image_big(self.image_medium)}) @@ -76,7 +77,8 @@ def _auto_end(self, cr, context=None): (pos_remove_pos_category monkey patching) """ context = context or {} - module = context['module'] + # If the field is created by the user, there is no module. + module = context.get('module', False) foreign_keys = [] patched = 'openerp.addons.pos_remove_pos_category' in sys.modules