Browse Source

Merge pull request #147 from ClearCorp/8.0-fix-#57

[FIX] BUG #57 that does not allow to create fields in the UI.
pull/145/head
Pedro M. Baeza 8 years ago
committed by GitHub
parent
commit
09b10fe637
  1. 10
      hw_customer_display/controllers/main.py
  2. 11
      hw_customer_display/test-scripts/customer-display-test.py
  3. 10
      hw_telium_payment_terminal/controllers/main.py
  4. 24
      pos_remove_pos_category/__openerp__.py
  5. 29
      pos_remove_pos_category/module.py
  6. 14
      pos_remove_pos_category/product.py

10
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

11
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

10
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

24
pos_remove_pos_category/__openerp__.py

@ -1,23 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2016 Akretion (<http://www.akretion.com>).
# 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",
}

29
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()

14
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

Loading…
Cancel
Save