Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Barnada committed Oct 2, 2018
2 parents ccd0682 + f145534 commit 0629fbe
Show file tree
Hide file tree
Showing 27 changed files with 479 additions and 289 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ python:
install:
- pip install erppeek coveralls
- pip install -e .
- pip install pep8
script:
- coverage run ./tests/test.py
after_success:
- coveralls
- coverage report
- coverage report
- pep8 .
- pep8|wc -l
50 changes: 27 additions & 23 deletions Koo/Actions/Actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,16 @@
#
##############################################################################

import os
from PyQt5.QtWidgets import *
import time
import base64
import datetime
import copy

from Koo import Rpc

from . import Wizard
from Koo.Printer import *

from Koo.Common import Api
from Koo.Common import Common
from PyQt5.QtCore import *
from PyQt5.QtGui import *


class ExecuteReportThread(QThread):
Expand Down Expand Up @@ -71,7 +65,7 @@ def run(self):
str(e.type), e.message, e.data))
return

if ids == []:
if not ids:
self.warning.emit(_('Nothing to print.'))
return
self.datas['id'] = ids[0]
Expand All @@ -97,10 +91,17 @@ def run(self):
self.error.emit((_('Error: %s') %
str(e.type), e.message, e.data))

# @brief Executes the given report.


def executeReport(name, data, context=None):
"""
Executes the given report.
:param name:
:param data:
:param context:
:return:
"""

if context is None:
context = {}
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand All @@ -111,7 +112,7 @@ def executeReport(name, data, context=None):
if not ids:
ids = Rpc.session.execute(
'/object', 'execute', datas['model'], 'search', [])
if ids == []:
if not ids:
QApplication.restoreOverrideCursor()
QMessageBox.information(
None, _('Information'), _('Nothing to print!'))
Expand Down Expand Up @@ -156,7 +157,7 @@ def execute(act_id, datas, type=None, context=None):
context = {}
ctx = Rpc.session.context.copy()
ctx.update(context)
if type == None:
if type is None:
res = Rpc.session.execute(
'/object', 'execute', 'ir.actions.actions', 'read', [act_id], ['type'], ctx)
if not len(res):
Expand Down Expand Up @@ -216,11 +217,11 @@ def executeAction(action, datas, context=None):
target = action.get('target', 'current')
if not target:
target = 'current'
Api.instance.createWindow(view_ids, datas['res_model'], datas['res_id'], domain,
action['view_type'], datas.get(
'window', None), ctx,
datas['view_mode'], name=action.get('name', False), autoReload=datas['auto_refresh'],
target=target)
Api.instance.createWindow(
view_ids, datas['res_model'], datas['res_id'], domain,
action['view_type'], datas.get('window', None), ctx,
datas['view_mode'], name=action.get('name', False),
autoReload=datas['auto_refresh'], target=target)

# for key in tools.expr_eval(action.get('context', '{}')).keys():
# del Rpc.session.context[key]
Expand Down Expand Up @@ -265,7 +266,8 @@ def executeKeyword(keyword, data=None, context=None):
:param keyword:
:param data:
:param context:
:return:
:return: Name, action
:rtype: tuple
"""
if data is None:
data = {}
Expand All @@ -274,12 +276,14 @@ def executeKeyword(keyword, data=None, context=None):
actions = None
if 'id' in data:
try:
id = data.get('id', False)
actions = Rpc.session.execute('/object', 'execute',
'ir.values', 'get', 'action', keyword,
[(data['model'], id)], False, Rpc.session.context)
ident = data.get('id', False)
actions = Rpc.session.execute(
'/object', 'execute',
'ir.values', 'get', 'action', keyword,
[(data['model'], ident)], False, Rpc.session.context
)
actions = [x[2] for x in actions]
except Rpc.RpcException as e:
except Rpc.RpcException:
return None

if not actions:
Expand All @@ -294,4 +298,4 @@ def executeKeyword(keyword, data=None, context=None):
return None
(name, action) = res
Api.instance.executeAction(action, data, context=context)
return (name, action)
return name, action
13 changes: 8 additions & 5 deletions Koo/Actions/Wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from Koo.Common.Ui import *

from Koo import Rpc
from Koo.Common import Api
Expand Down Expand Up @@ -115,6 +113,7 @@ def save(self):
def cancel(self):
pass


class Wizard(QObject):
"""
The Wizard class shows a step by step wizard with the provided information.
Expand All @@ -123,7 +122,7 @@ def __init__(self, action, datas, state='init', parent=None, context=None):
QObject.__init__(self, parent)
if context is None:
context = {}
if not 'form' in datas:
if 'form' not in datas:
datas['form'] = {}
self.action = action
self.datas = datas
Expand All @@ -149,8 +148,10 @@ def finishedStep(self, res, exception):
self.progress.stop()
QApplication.restoreOverrideCursor()

# Check if 'res' is None as it can happen with 'Split in production lots'
# in inventory 'Movements', for example, if no production sequence is defined.
# Check if 'res' is None as it can happen with
# 'Split in production lots'
# in inventory 'Movements', for example, if no production sequence is
# defined.
# We'll also leave the wizard if an exception was thrown.
if exception or not res:
self.state = 'end'
Expand Down Expand Up @@ -194,13 +195,15 @@ def finishedStep(self, res, exception):
def execute(action, datas, state='init', parent=None, context=None):
"""
Executes the wizard with the provided information.
:param action:
:param datas:
:param state:
:param parent:
:param context:
:return:
"""

if context is None:
context = {}
w = Wizard(action, datas, state, parent, context)
Expand Down
33 changes: 23 additions & 10 deletions Koo/Common/ArrowsEventFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,33 @@

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *

# @brief The ArrowsEventFilter class provides an eventFilter that allows
# moving from one widget to another using Alt + Arrow (Left, Right, Up, Down)
# and also Alt + Minus and Alt + Plus.
#
# To install it in an application use 'app.installEventFilter( Koo.Common.ArrowsEventFilter( mainWindow ) )'


class ArrowsEventFilter(QObject):
# @brief Creates a new ArrowsEventFilter object.
"""
The ArrowsEventFilter class provides an eventFilter that allows
moving from one widget to another using Alt + Arrow (Left, Right, Up, Down)
and also Alt + Minus and Alt + Plus.
To install it in an application use
'app.installEventFilter( Koo.Common.ArrowsEventFilter( mainWindow ) )'
"""

def __init__(self, parent=None):
"""
Creates a new ArrowsEventFilter object.
:param parent:
"""
QObject.__init__(self, parent)

# Get all visible and focusable child widgets of the given widget
def allWidgets(self, object):
"""
Get all visible and focusable child widgets of the given widget
:param object:
:return:
"""

if not object.isWidgetType():
return []
result = []
Expand All @@ -57,8 +68,10 @@ def intersectHorizontally(self, rect1, rect2):
return False

def eventFilter(self, obj, event):
arrow_keys = (Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right)
plus_minus_keys = (Qt.Key_Plus, Qt.Key_Minus)
if event.type() in (QEvent.KeyPress, QEvent.KeyRelease) and event.modifiers() & Qt.AltModifier and \
event.key() in (Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right, Qt.Key_Plus, Qt.Key_Minus):
event.key() in (arrow_keys + plus_minus_keys):

if event.type() == QEvent.KeyRelease:
return True
Expand Down
15 changes: 6 additions & 9 deletions Koo/Common/Calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ def textToDate(text):
return QDate.currentDate()

inputFormats = [
'dd/MM/yyyy', 'dd-MM-yyyy', ('dd-MM-yy',
'century'), ('dd/MM/yy', 'century'),
('dd-M-yy', 'century'), ('d-M-yy',
'add'), ('d-MM-yy', 'century'), 'dd.MM.yyyy',
('dd.MM.yy', 'century'), 'ddMMyyyy', ('ddMMyy', 'century'), ('dd/MM', 'year'),
('dd.MM', 'year'), ('ddMM', 'year'), ('dd', 'month')
'dd/MM/yyyy', 'dd-MM-yyyy', ('dd-MM-yy', 'century'),
('dd/MM/yy', 'century'), ('dd-M-yy', 'century'),
('d-M-yy', 'add'), ('d-MM-yy', 'century'), 'dd.MM.yyyy',
('dd.MM.yy', 'century'), 'ddMMyyyy', ('ddMMyy', 'century'),
('dd/MM', 'year'), ('dd.MM', 'year'), ('ddMM', 'year'),
('dd', 'month')
]
for x in inputFormats:
if isinstance(x, tuple):
Expand Down Expand Up @@ -288,9 +288,6 @@ def storageToDateTime(text):

(PopupCalendarUi, PopupCalendarBase) = loadUiType(Common.uiPath('datetime.ui'))

# @brief
#


class PopupCalendarWidget(QWidget, PopupCalendarUi):
"""
Expand Down
25 changes: 10 additions & 15 deletions Koo/Common/CommandLine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@
#
##############################################################################

import gettext
import os
import sys
import optparse

from . import Debug
from .Settings import *
from Koo import Rpc

from PyQt5.QtCore import QDir, QUrl

Expand Down Expand Up @@ -71,29 +66,29 @@ def parseArguments(args):
Settings.loadFromFile()
Settings.loadFromRegistry()

# Allow URL to be specified in an environment variable so user password is not
# visible when listing running processes.
# Allow URL to be specified in an environment variable so user password
# is not visible when listing running processes.
if os.environ.get('KOO_URL'):
Settings.setValue('login.url', os.environ.get('KOO_URL'))

if options.url:
Settings.setValue('login.url', options.url)
if Settings.value('login.url'):
url = QUrl(Settings.value('login.url'))
if not options.stylesheet is None:
if options.stylesheet is not None:
Settings.setValue('koo.stylesheet', options.stylesheet)
if not options.pos_mode is None:
if options.pos_mode is not None:
Settings.setValue('koo.pos_mode', options.pos_mode)
if not options.enter_as_tab is None:
if options.enter_as_tab is not None:
Settings.setValue('koo.enter_as_tab', options.enter_as_tab)
if not options.debug is None:
if options.debug is not None:
Settings.setValue('client.debug', options.debug)
if not options.disable_kde is None:
if options.disable_kde is not None:
Settings.setValue('kde.enabled', False)
if not options.database is None:
if options.database is not None:
Settings.setValue('login.db', options.database)
if not options.open_model is None:
if options.open_model is not None:
Settings.setValue('open.model', options.open_model)
if not options.open_id is None:
if options.open_id is not None:
Settings.setValue('open.id', options.open_id)
return arguments
8 changes: 1 addition & 7 deletions Koo/Common/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def nodeAttributes(node):


def sendEMail(to, subject, body):
# Import smtplib for the actual sending function
# Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
Expand All @@ -119,7 +119,6 @@ def sendEMail(to, subject, body):
(SelectionDialogUi, SelectionDialogBase) = loadUiType(uiPath('win_selection.ui'))



class SelectionDialog(QDialog, SelectionDialogUi):
"""
The SelectionDialog class shows a dialog prompting the user to choose
Expand Down Expand Up @@ -148,8 +147,6 @@ def selected(self):
self.result = (str(item.text()), item.value)
self.accept()

# @brief


def selection(title, values, alwaysask=False):
"""
Expand Down Expand Up @@ -307,8 +304,6 @@ def error(title, message, details=''):
(LostConnectionDialogUi, LostConnectionDialogBase) = loadUiType(
uiPath('lostconnection.ui'))

# @brief


class LostConnectionDialog(QDialog, LostConnectionDialogUi):
"""
Expand Down Expand Up @@ -370,7 +365,6 @@ def lostConnectionError(count):
(ProgressDialogUi, ProgressDialogBase) = loadUiType(uiPath('progress.ui'))



class ProgressDialog(QDialog, ProgressDialogUi):
"""
The ProgressDialog class shows a progress bar moving left and right until
Expand Down
Loading

0 comments on commit 0629fbe

Please sign in to comment.