Skip to content

Commit

Permalink
[MERGE] forward port of branch saas-6 up to 8d95f6d
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Aug 15, 2015
2 parents 9979939 + 8d95f6d commit 73e6528
Show file tree
Hide file tree
Showing 75 changed files with 926 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<group col="4">
<field name="name"/>
<field name="code"/>
<field name="plan_id"/>
<field name="plan_id" required="1"/>
<field name="journal_id"/>
</group>
<field name="account_ids">
Expand Down
4 changes: 2 additions & 2 deletions addons/auth_oauth/auth_oauth_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<record id="provider_facebook" model="auth.oauth.provider">
<field name="name">Facebook Graph</field>
<field name="auth_endpoint">https://www.facebook.com/dialog/oauth</field>
<field name="scope"></field>
<field name="validation_endpoint">https://graph.facebook.com/me/permissions</field>
<field name="scope">public_profile,email</field>
<field name="validation_endpoint">https://graph.facebook.com/me</field>
<field name="data_endpoint"></field>
<field name="css_class">fa fa-facebook-square</field>
<field name="body">Log in with facebook</field>
Expand Down
7 changes: 6 additions & 1 deletion addons/auth_oauth/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ def auth_oauth(self, cr, uid, provider, params, context=None):
validation = self._auth_oauth_validate(cr, uid, provider, access_token)
# required check
if not validation.get('user_id'):
raise openerp.exceptions.AccessDenied()
# Workaround: facebook does not send 'user_id' in Open Graph Api
if validation.get('id'):
validation['user_id'] = validation['id']
else:
raise openerp.exceptions.AccessDenied()

# retrieve and sign in user
login = self._auth_oauth_signin(cr, uid, provider, validation, params, context=context)
if not login:
Expand Down
1 change: 0 additions & 1 deletion addons/hr_evaluation/hr_evaluation_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@
<filter string="New Mail" name="message_unread" domain="[('message_unread','=',True)]"/>
<group expand="0" string="Group By">
<filter string="Interviewer" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Survey" domain="[]" context="{'group_by':'survey_id'}"/>
<filter string="Status" name="group_state" domain="[]" context="{'group_by':'state'}"/>
</group>
</search>
Expand Down
13 changes: 12 additions & 1 deletion addons/hr_holidays/hr_holidays_view.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version='1.0' encoding='UTF-8' ?>
<openerp>
<data>

Expand All @@ -24,16 +25,26 @@
<filter domain="[('state','in',('confirm','validate1'))]" string="To Approve" name="approve"/>
<filter string="Approved Leaves" domain="[('state', '=', 'validate')]" name="validated"/>
<separator/>
<filter name="active_types" string="Active Types" domain="[('holiday_status_id.active', '=', True)]" help="Filters only on allocations and requests that belong to an holiday type that is 'active' (active field is True)"/>
<separator/>
<filter string="New Mail" name="message_unread" domain="[('message_unread','=',True)]"/>
<separator/>
<filter string="My Department Leaves" domain="[('department_id.manager_id.user_id', '=', uid)]" help="My Department Leaves"/>
<filter string="My Team Leaves" domain="[('employee_id.parent_id.user_id', '=', uid)]" groups="base.group_hr_manager" help="Leaves of Your Team Member"/>
<separator/>
<filter string="To Report in Payslip" name="gray" domain="[('payslip_status', '=', False)]" groups="base.group_hr_manager"/>
<separator/>
<filter name="year" string="Year" domain="[('holiday_status_id.active','=',True)]" help="Filters only on allocations and requests that belong to an holiday type that is 'active' (active field is True)"/>
<separator/>
<filter string="To Do" name="todo" domain="[('payslip_status', '=', False), ('holiday_status_id.active', '=', True)]"/>
<separator/>
<filter name="year" string="Year"
domain="['|','&amp;',('date_to', '&lt;=', time.strftime('%%Y-12-31')),
('date_to', '&gt;=', time.strftime('%%Y-01-01')),
'&amp;',('date_from', '&lt;=', time.strftime('%%Y-12-31')),
('date_from', '&gt;=', time.strftime('%%Y-01-01'))]"
help="Current Year Leaves"/>
<separator/>
<filter string="My Requests" name="my_leaves" domain="[('user_id', '=', uid)]" help="My Leave Requests"/>
<field name="employee_id"/>
<field name="department_id"/>
<field name="holiday_status_id"/>
Expand Down
5 changes: 4 additions & 1 deletion addons/hr_timesheet_invoice/hr_timesheet_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def _prepare_cost_invoice_line(self, cr, uid, invoice_id, product_id, uom, user_
def invoice_cost_create(self, cr, uid, ids, data=None, context=None):
invoice_obj = self.pool.get('account.invoice')
invoice_line_obj = self.pool.get('account.invoice.line')
analytic_line_obj = self.pool.get('account.analytic.line')
invoices = []
if context is None:
context = {}
Expand Down Expand Up @@ -279,13 +280,15 @@ def invoice_cost_create(self, cr, uid, ids, data=None, context=None):
analytic_line.to_invoice.id,
analytic_line.account_id,
analytic_line.journal_id.type)
# We want to retrieve the data in the partner language for the invoice creation
analytic_line = analytic_line_obj.browse(cr, uid , [line.id for line in analytic_line], context=invoice_context)
invoice_lines_grouping.setdefault(key, []).append(analytic_line)

# finally creates the invoice line
for (product_id, uom, user_id, factor_id, account, journal_type), lines_to_invoice in invoice_lines_grouping.items():
curr_invoice_line = self._prepare_cost_invoice_line(cr, uid, last_invoice,
product_id, uom, user_id, factor_id, account, lines_to_invoice,
journal_type, data, context=context)
journal_type, data, context=invoice_context)

invoice_line_obj.create(cr, uid, curr_invoice_line, context=context)
self.write(cr, uid, [l.id for l in analytic_line_ids], {'invoice_id': last_invoice}, context=context)
Expand Down
8 changes: 6 additions & 2 deletions addons/hw_escpos/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

_logger = logging.getLogger(__name__)

# workaround https://bugs.launchpad.net/openobject-server/+bug/947231
# related to http://bugs.python.org/issue7980
from datetime import datetime
datetime.strptime('2012-01-01', '%Y-%m-%d')

class EscposDriver(Thread):
def __init__(self):
Expand Down Expand Up @@ -146,7 +150,7 @@ def set_status(self, status, message = None):
_logger.warning('ESC/POS Device Disconnected: '+message)

def run(self):

printer = None
if not escpos:
_logger.error('ESC/POS cannot initialize, please verify system dependencies.')
return
Expand Down Expand Up @@ -192,7 +196,7 @@ def run(self):
errmsg = str(e) + '\n' + '-'*60+'\n' + traceback.format_exc() + '-'*60 + '\n'
_logger.error(errmsg);
finally:
if error:
if error:
self.queue.put((timestamp, task, data))
if printer:
printer.close()
Expand Down
8 changes: 4 additions & 4 deletions addons/hw_posbox_homepage/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
</p>
<p>
For more information on how to setup the Point of Sale with
the PosBox, please refer to <a href='/hw_proxy/static/doc/manual.pdf'>the manual</a>
the PosBox, please refer to <a href='/hw_proxy/static/doc/manual.pdf'>the manual</a>.
</p>
<p>
To see the status of the connected hardware, please refer
to the <a href='/hw_proxy/status'>hardware status page</a>
to the <a href='/hw_proxy/status'>hardware status page</a>.
</p>
<p>
The PosBox software installed on this posbox is <b>version 6</b>,
The PosBox software installed on this posbox is <b>version 13</b>,
the posbox version number is independent from Odoo. You can upgrade
the software on the <a href='/hw_proxy/upgrade/'>upgrade page</a>
the software on the <a href='/hw_proxy/upgrade/'>upgrade page</a>.
</p>
<p>For any other question, please contact the Odoo support at <a href='mailto:support@odoo.com'>support@odoo.com</a>
</p>
Expand Down
41 changes: 8 additions & 33 deletions addons/hw_posbox_upgrade/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,8 @@
$.ajax({
url:'/hw_proxy/perform_upgrade/'
}).then(function(status){
$('#upgrade').html('Upgrade Successful<br \\>Click to Restart the PosBox');
$('#upgrade').html('Upgrade successful, restarting the posbox...');
$('#upgrade').off('click');
$('#upgrade').click(function(){
$.ajax({ url:'/hw_proxy/perform_restart' })
$('#upgrade').text('Restarting');
$('#upgrade').off('click');
setTimeout(function(){
window.location = '/'
},30*1000);
});
},function(){
$('#upgrade').text('Upgrade Failed');
});
Expand Down Expand Up @@ -73,9 +64,11 @@
<body>
<h1>PosBox Software Upgrade</h1>
<p>
This tool will help you perform an upgrade of the PosBox's software.
This tool will help you perform an upgrade of the PosBox's software over the
internet.
<p></p>
However the preferred method to upgrade the posbox is to flash the sd-card with
the <a href='http://nightly.openerp.com/trunk/posbox/'>latest image</a>. The upgrade
the <a href='http://nightly.odoo.com/trunk/posbox/'>latest image</a>. The upgrade
procedure is explained into to the <a href='/hw_proxy/static/doc/manual.pdf'>PosBox manual</a>
</p>
<p>
Expand All @@ -93,7 +86,6 @@ class PosboxUpgrader(hw_proxy.Proxy):
def __init__(self):
super(PosboxUpgrader,self).__init__()
self.upgrading = threading.Lock()
self.last_upgrade = 0

@http.route('/hw_proxy/upgrade', type='http', auth='none', )
def upgrade(self):
Expand All @@ -102,25 +94,8 @@ def upgrade(self):
@http.route('/hw_proxy/perform_upgrade', type='http', auth='none')
def perform_upgrade(self):
self.upgrading.acquire()
if time.time() - self.last_upgrade < 30:
self.upgrading.release()
return 'UPTODATE'
else:
os.system('/bin/bash /home/pi/openerp/update.sh')
self.last_upgrade = time.time()
self.upgrading.release()
return 'SUCCESS'

@http.route('/hw_proxy/perform_restart', type='http', auth='none')
def perform_restart(self):
self.upgrading.acquire()
if time.time() - self.last_upgrade < 30:
self.upgrading.release()
return 'RESTARTED'
else:
os.system('/bin/bash /home/pi/openerp/restart.sh')
self.last_upgrade = time.time()
self.upgrading.release()
return 'SUCCESS'

os.system('/home/pi/posbox_update.sh')

self.upgrading.release()
return 'SUCCESS'
18 changes: 17 additions & 1 deletion addons/hw_proxy/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
from openerp import http
from openerp.http import request

# Those are the builtin raspberry pi USB modules, they should
# not appear in the list of connected devices.
BANNED_DEVICES = set([
"0424:9514", # Standard Microsystem Corp. Builtin Ethernet module
"1d6b:0002", # Linux Foundation 2.0 root hub
"0424:ec00", # Standard Microsystem Corp. Other Builtin Ethernet module
])


# drivers modules must add to drivers an object with a get_status() method
# so that 'status' can return the status of all active drivers
Expand Down Expand Up @@ -88,10 +96,18 @@ def status_http(self):
<p>The list of connected USB devices as seen by the posbox</p>
"""
devices = commands.getoutput("lsusb").split('\n')
count = 0
resp += "<div class='devices'>\n"
for device in devices:
device_name = device[device.find('ID')+2:]
resp+= "<div class='device' data-device='"+device+"'>"+device_name+"</div>\n"
device_id = device_name.split()[0]
if not (device_id in BANNED_DEVICES):
resp+= "<div class='device' data-device='"+device+"'>"+device_name+"</div>\n"
count += 1

if count == 0:
resp += "<div class='device'>No USB Device Found</div>"

resp += "</div>\n"
resp += """
<h2>Add New Printer</h2>
Expand Down
24 changes: 16 additions & 8 deletions addons/hw_scale/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,28 @@ def set_status(self, status, message = None):
if status == self.status['status']:
if message != None and message != self.status['messages'][-1]:
self.status['messages'].append(message)

if status == 'error' and message:
_logger.error('Scale Error: '+message)
elif status == 'disconnected' and message:
_logger.warning('Disconnected Scale: '+message)
else:
self.status['status'] = status
if message:
self.status['messages'] = [message]
else:
self.status['messages'] = []

if status == 'error' and message:
_logger.error('Scale Error: '+message)
elif status == 'disconnected' and message:
_logger.info('Disconnected Scale: %s', message)
if status == 'error' and message:
_logger.error('Scale Error: '+message)
elif status == 'disconnected' and message:
_logger.info('Disconnected Scale: %s', message)

def get_device(self):
try:
if not os.path.exists(self.input_dir):
self.set_status('disconnected','Scale Not Found')
return None
devices = [ device for device in listdir(self.input_dir)]
scales = [ device for device in devices if ('mettler' in device.lower()) or ('toledo' in device.lower()) ]
if len(scales) > 0:
Expand All @@ -69,8 +77,8 @@ def get_device(self):
stopbits = serial.STOPBITS_ONE,
parity = serial.PARITY_EVEN,
#xonxoff = serial.XON,
timeout = 0.01,
writeTimeout= 0.01)
timeout = 0.02,
writeTimeout= 0.02)
else:
self.set_status('disconnected','Scale Not Found')
return None
Expand All @@ -95,7 +103,7 @@ def read_weight(self):
if self.device:
try:
self.device.write('W')
time.sleep(0.1)
time.sleep(0.2)
answer = []

while True:
Expand Down Expand Up @@ -171,7 +179,7 @@ def run(self):
while True:
if self.device:
self.read_weight()
time.sleep(0.05)
time.sleep(0.15)
else:
with self.scalelock:
self.device = self.get_device()
Expand Down
6 changes: 6 additions & 0 deletions addons/hw_scanner/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def set_status(self, status, message = None):

def get_device(self):
try:
if not evdev:
return None
devices = [ device for device in listdir(self.input_dir)]
keyboards = [ device for device in devices if ('kbd' in device) and ('keyboard' not in device.lower())]
scanners = [ device for device in devices if ('barcode' in device.lower()) or ('scanner' in device.lower())]
Expand All @@ -133,6 +135,7 @@ def get_barcode(self):
been returned before. This is necessary to catch barcodes scanned while the POS is
busy reading another barcode
"""

self.lockedstart()

while True:
Expand Down Expand Up @@ -164,10 +167,13 @@ def run(self):
try:
device.ungrab()
except Exception as e:
device = None
self.set_status('error',str(e))
else:
time.sleep(5) # wait until a suitable device is plugged
device = self.get_device()
if not device:
continue

try:
device.grab()
Expand Down
Loading

0 comments on commit 73e6528

Please sign in to comment.