From ea0e87596145420c73e99dc93509f7f9bdcad475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20V=C3=A1squez?= Date: Thu, 19 Jan 2017 18:48:45 -0600 Subject: [PATCH] [FIX] Pylint on hw_customer_display and hw_telium_payment_terminal and flake8 on pos_remove_pos_category --- .../test-scripts/customer-display-test.py | 11 +++++++++-- hw_telium_payment_terminal/controllers/main.py | 9 ++++++--- pos_remove_pos_category/module.py | 10 +++++----- 3 files changed, 20 insertions(+), 10 deletions(-) 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..b2f4d124 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): diff --git a/pos_remove_pos_category/module.py b/pos_remove_pos_category/module.py index a5e71d0c..1de1099e 100644 --- a/pos_remove_pos_category/module.py +++ b/pos_remove_pos_category/module.py @@ -19,7 +19,7 @@ # ############################################################################## -from openerp import models +from openerp import models, api class Module(models.Model): @@ -34,16 +34,16 @@ class Module(models.Model): # 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 ''') - cr.execute(''' + self.env.cr.execute(''' ALTER TABLE product_template ADD CONSTRAINT "product_template_pos_categ_id_fkey" FOREIGN KEY (pos_categ_id) @@ -52,7 +52,7 @@ 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