From 19e91633673261737494a4138af9d90edc0d329b Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 26 Aug 2015 13:39:46 +0200 Subject: [PATCH 01/22] [FIX] google_drive: code want uncompressed data This commit removes the request of having gzip or deflate data for two requests to google drive API. Previously the code worked since google api would send ungzipped data (maybe base on urllib2 user agent or other input parameters) but after a recent change on google part, it is not anymore the case. closes #8243 opw-648007 note: if we did not do this, we would either need to use requests or add custom uncompressing code for urllib2 response content. --- addons/google_drive/google_drive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/google_drive/google_drive.py b/addons/google_drive/google_drive.py index 8af18639299..3976d561c40 100644 --- a/addons/google_drive/google_drive.py +++ b/addons/google_drive/google_drive.py @@ -80,7 +80,7 @@ class config(osv.Model): client_secret=google_drive_client_secret, grant_type="refresh_token", scope=scope or 'https://www.googleapis.com/auth/drive')) - headers = {"Content-type": "application/x-www-form-urlencoded", "Accept-Encoding": "gzip, deflate"} + headers = {"Content-type": "application/x-www-form-urlencoded"} try: req = urllib2.Request('https://accounts.google.com/o/oauth2/token', data, headers) content = urllib2.urlopen(req, timeout=TIMEOUT).read() @@ -100,7 +100,7 @@ class config(osv.Model): access_token = self.get_access_token(cr, uid, context=context) # Copy template in to drive with help of new access token request_url = "https://www.googleapis.com/drive/v2/files/%s?fields=parents/id&access_token=%s" % (template_id, access_token) - headers = {"Content-type": "application/x-www-form-urlencoded", "Accept-Encoding": "gzip, deflate"} + headers = {"Content-type": "application/x-www-form-urlencoded"} try: req = urllib2.Request(request_url, None, headers) parents = urllib2.urlopen(req, timeout=TIMEOUT).read() From 4b6309f5ded42ccfa6f7f09c39b26473abc9334d Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 26 Aug 2015 10:18:40 +0200 Subject: [PATCH 02/22] [FIX] product: name_search result The function "name_search" defined on "product.template" made a search on "product.product" name to give the "product.template" which matched with the search. The number of results given by the name_search on "product.product" is generally limited to 8. The problem was when for example there were 8 variants ("product.product") with a name begining by "AA" for the same "product.template" T1 and another "product.product" with a name begining by "AB" linked to T2. In this situation, if a name_search was made on "product.template" with a name="A", the result got was just the the name of T1 linked to the 8 variants instead of the name of the two templates (T1 and T2) due to the limitation. opw:647066 --- addons/product/product.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 1e4d73c58e1..45074b0e299 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -821,18 +821,24 @@ class product_template(osv.osv): if not name or any(term[0] == 'id' for term in (args or [])): return super(product_template, self).name_search( cr, user, name=name, args=args, operator=operator, context=context, limit=limit) - + template_ids = set() product_product = self.pool['product.product'] - results = product_product.name_search( - cr, user, name, args, operator=operator, context=context, limit=limit) + results = product_product.name_search(cr, user, name, args, operator=operator, context=context, limit=limit) product_ids = [p[0] for p in results] - template_ids = [p.product_tmpl_id.id - for p in product_product.browse( - cr, user, product_ids, context=context)] + for p in product_product.browse(cr, user, product_ids, context=context): + template_ids.add(p.product_tmpl_id.id) + while (results and len(template_ids) < limit): + domain = [('product_tmpl_id', 'not in', list(template_ids))] + results = product_product.name_search( + cr, user, name, args+domain, operator=operator, context=context, limit=limit) + product_ids = [p[0] for p in results] + for p in product_product.browse(cr, user, product_ids, context=context): + template_ids.add(p.product_tmpl_id.id) + # re-apply product.template order + name_get return super(product_template, self).name_search( - cr, user, '', args=[('id', 'in', template_ids)], + cr, user, '', args=[('id', 'in', list(template_ids))], operator='ilike', context=context, limit=limit) class product_product(osv.osv): From e7c51228f363241960515d9bc5d1a1aa598b6950 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Tue, 25 Aug 2015 15:47:07 +0200 Subject: [PATCH 03/22] [IMP] hw_escpos: get rid of printer whitelist It makes more sense to just look for usb devices that identify as a printer and use whatever we get. This saves us time having to explain to users how to add their particular printer to the whitelist to test. --- addons/hw_escpos/controllers/main.py | 96 ++++++-------------- addons/hw_escpos/escpos/__init__.py | 2 +- addons/hw_escpos/escpos/supported_devices.py | 11 --- 3 files changed, 30 insertions(+), 79 deletions(-) delete mode 100644 addons/hw_escpos/escpos/supported_devices.py diff --git a/addons/hw_escpos/controllers/main.py b/addons/hw_escpos/controllers/main.py index 083e5cd5557..0b0f58027ab 100644 --- a/addons/hw_escpos/controllers/main.py +++ b/addons/hw_escpos/controllers/main.py @@ -52,60 +52,37 @@ class EscposDriver(Thread): self.lock = Lock() self.status = {'status':'connecting', 'messages':[]} - def supported_devices(self): - if not os.path.isfile('escpos_devices.pickle'): - return supported_devices.device_list - else: - try: - f = open('escpos_devices.pickle','r') - return pickle.load(f) - f.close() - except Exception as e: - self.set_status('error',str(e)) - return supported_devices.device_list - - def add_supported_device(self,device_string): - r = re.compile('[0-9A-Fa-f]{4}:[0-9A-Fa-f]{4}'); - match = r.search(device_string) - if match: - match = match.group().split(':') - vendor = int(match[0],16) - product = int(match[1],16) - name = device_string.split('ID') - if len(name) >= 2: - name = name[1] - else: - name = name[0] - _logger.info('ESC/POS: adding support for device: '+match[0]+':'+match[1]+' '+name) - - device_list = supported_devices.device_list[:] - if os.path.isfile('escpos_devices.pickle'): - try: - f = open('escpos_devices.pickle','r') - device_list = pickle.load(f) - f.close() - except Exception as e: - self.set_status('error',str(e)) - device_list.append({ - 'vendor': vendor, - 'product': product, - 'name': name, - }) - - try: - f = open('escpos_devices.pickle','w+') - f.seek(0) - pickle.dump(device_list,f) - f.close() - except Exception as e: - self.set_status('error',str(e)) - def connected_usb_devices(self): connected = [] - - for device in self.supported_devices(): - if usb.core.find(idVendor=device['vendor'], idProduct=device['product']) != None: - connected.append(device) + + # printers can either define bDeviceClass=7, or they can define one of + # their interfaces with bInterfaceClass=7. This class checks for both. + class FindUsbClass(object): + def __init__(self, usb_class): + self._class = usb_class + def __call__(self, device): + # first, let's check the device + if device.bDeviceClass == self._class: + return True + # transverse all devices and look through their interfaces to + # find a matching class + for cfg in device: + intf = usb.util.find_descriptor(cfg, bInterfaceClass=self._class) + + if intf is not None: + return True + + return False + + printers = usb.core.find(find_all=True, custom_match=FindUsbClass(7)) + + for printer in printers: + connected.append({ + 'vendor': printer.idVendor, + 'product': printer.idProduct, + 'name': usb.util.get_string(printer, 256, printer.iManufacturer) + " " + usb.util.get_string(printer, 256, printer.iProduct) + }) + return connected def lockedstart(self): @@ -377,18 +354,3 @@ class EscposProxy(hw_proxy.Proxy): _logger.info('ESC/POS: PRINT XML RECEIPT') driver.push_task('xml_receipt',receipt) - @http.route('/hw_proxy/escpos/add_supported_device', type='http', auth='none', cors='*') - def add_supported_device(self, device_string): - _logger.info('ESC/POS: ADDED NEW DEVICE:'+device_string) - driver.add_supported_device(device_string) - return "The device:\n"+device_string+"\n has been added to the list of supported devices.
Ok" - - @http.route('/hw_proxy/escpos/reset_supported_devices', type='http', auth='none', cors='*') - def reset_supported_devices(self): - try: - os.remove('escpos_devices.pickle') - except Exception as e: - pass - return 'The list of supported devices has been reset to factory defaults.
Ok' - - diff --git a/addons/hw_escpos/escpos/__init__.py b/addons/hw_escpos/escpos/__init__.py index 3fdeddee28b..22a5af61029 100644 --- a/addons/hw_escpos/escpos/__init__.py +++ b/addons/hw_escpos/escpos/__init__.py @@ -1 +1 @@ -__all__ = ["constants","escpos","exceptions","printer","supported_devices"] +__all__ = ["constants","escpos","exceptions","printer"] diff --git a/addons/hw_escpos/escpos/supported_devices.py b/addons/hw_escpos/escpos/supported_devices.py deleted file mode 100644 index bd08433de0e..00000000000 --- a/addons/hw_escpos/escpos/supported_devices.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/python - -# This is a list of esc/pos compatible usb printers. The vendor and product ids can be found by -# typing lsusb in a linux terminal, this will give you the ids in the form ID VENDOR:PRODUCT - -device_list = [ - { 'vendor' : 0x04b8, 'product' : 0x0e03, 'name' : 'Epson TM-T20' }, - { 'vendor' : 0x04b8, 'product' : 0x0202, 'name' : 'Epson TM-T70' }, - { 'vendor' : 0x04b8, 'product' : 0x0e15, 'name' : 'Epson TM-T20II' }, -] - From 2a96e18a79269f4d0605d790d212eef61f975fad Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Tue, 25 Aug 2015 16:07:27 +0200 Subject: [PATCH 04/22] [IMP] hw_posbox_upgrade: show latest commit of odoo repository on posbox Is useful when debugging, and figuring out whether or not an upgrade was successful. --- addons/hw_posbox_upgrade/controllers/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/hw_posbox_upgrade/controllers/main.py b/addons/hw_posbox_upgrade/controllers/main.py index 5ed958d020e..cec93510e83 100644 --- a/addons/hw_posbox_upgrade/controllers/main.py +++ b/addons/hw_posbox_upgrade/controllers/main.py @@ -6,6 +6,7 @@ import time import openerp import openerp.addons.hw_proxy.controllers.main as hw_proxy import threading +import subprocess from openerp import http from openerp.http import request from openerp.tools.translate import _ @@ -74,6 +75,14 @@ upgrade_template = """

To upgrade the posbox, click on the upgrade button. The upgrade will take a few minutes. Do not reboot the PosBox during the upgrade.

+

+ Latest patch: +

+
+"""
+upgrade_template += subprocess.check_output("git --work-tree=/home/pi/odoo/ --git-dir=/home/pi/odoo/.git log -1", shell=True).replace("\n", "
") +upgrade_template += """ +
From f0551d2d8d45662379c80921d331bdf4e719a98c Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Tue, 18 Aug 2015 13:12:58 +0200 Subject: [PATCH 05/22] [IMP] point_of_sale: get rid of avahi-daemon on posbox --- .../tools/posbox/overwrite_before_init/etc/init_posbox_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh index 781b599d51f..367108ef167 100755 --- a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh @@ -12,7 +12,7 @@ __base="$(basename ${__file} .sh)" export DEBIAN_FRONTEND=noninteractive # GUI-related packages -PKGS_TO_DELETE="xserver-xorg-video-fbdev xserver-xorg xinit gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-libav epiphany-browser lxde lxtask menu-xdg gksu xserver-xorg-video-fbturbo xpdf gtk2-engines alsa-utils netsurf-gtk zenity desktop-base lxpolkit weston omxplayer raspberrypi-artwork lightdm gnome-themes-standard-data gnome-icon-theme qt50-snapshot qt50-quick-particle-examples idle python-pygame python-tk idle3 python-serial python-picamera debian-reference-en dillo x2x scratch nuscratch raspberrypi-ui-mods timidity smartsim penguinspuzzle pistore sonic-pi python-pifacecommon python-pifacedigitalio oracle-java8-jdk minecraft-pi python-minecraftpi wolfram-engine raspi-config libgl1-mesa-dri libicu48 pypy-upstream lxde-icon-theme python3" +PKGS_TO_DELETE="xserver-xorg-video-fbdev xserver-xorg xinit gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-libav epiphany-browser lxde lxtask menu-xdg gksu xserver-xorg-video-fbturbo xpdf gtk2-engines alsa-utils netsurf-gtk zenity desktop-base lxpolkit weston omxplayer raspberrypi-artwork lightdm gnome-themes-standard-data gnome-icon-theme qt50-snapshot qt50-quick-particle-examples idle python-pygame python-tk idle3 python-serial python-picamera debian-reference-en dillo x2x scratch nuscratch raspberrypi-ui-mods timidity smartsim penguinspuzzle pistore sonic-pi python-pifacecommon python-pifacedigitalio oracle-java8-jdk minecraft-pi python-minecraftpi wolfram-engine raspi-config libgl1-mesa-dri libicu48 pypy-upstream lxde-icon-theme python3 avahi-daemon" INSTALLED_PKGS_TO_DELETE="" set +o errexit for CURRENT_PKG in $(echo $PKGS_TO_DELETE); do From 02f0cbe3539ede171958645ba9d524d4edc7f2e8 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 26 Aug 2015 11:05:29 +0200 Subject: [PATCH 06/22] [IMP] point_of_sale: keep as many scripts as possible in the odoo repo This way we don't require a new image when we want to change eg. the odoo configuration file. --- addons/hw_posbox_upgrade/controllers/main.py | 2 +- .../home/pi => configuration}/led_status.sh | 0 .../{overwrite_before_init/home/pi => configuration}/odoo.conf | 0 .../home/pi => configuration}/posbox_update.sh | 0 .../etc => configuration}/setup_ramdisks.sh | 0 .../tools/posbox/overwrite_after_init/etc/init.d/rcS | 2 +- .../tools/posbox/overwrite_after_init/etc/rc.local | 2 +- .../tools/posbox/overwrite_before_init/etc/init.d/odoo | 2 +- addons/point_of_sale/tools/posbox/posbox_create_image.sh | 1 + 9 files changed, 5 insertions(+), 4 deletions(-) rename addons/point_of_sale/tools/posbox/{overwrite_before_init/home/pi => configuration}/led_status.sh (100%) rename addons/point_of_sale/tools/posbox/{overwrite_before_init/home/pi => configuration}/odoo.conf (100%) rename addons/point_of_sale/tools/posbox/{overwrite_before_init/home/pi => configuration}/posbox_update.sh (100%) rename addons/point_of_sale/tools/posbox/{overwrite_after_init/etc => configuration}/setup_ramdisks.sh (100%) diff --git a/addons/hw_posbox_upgrade/controllers/main.py b/addons/hw_posbox_upgrade/controllers/main.py index cec93510e83..42811820e74 100644 --- a/addons/hw_posbox_upgrade/controllers/main.py +++ b/addons/hw_posbox_upgrade/controllers/main.py @@ -104,7 +104,7 @@ class PosboxUpgrader(hw_proxy.Proxy): def perform_upgrade(self): self.upgrading.acquire() - os.system('/home/pi/posbox_update.sh') + os.system('/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/posbox_update.sh') self.upgrading.release() return 'SUCCESS' diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/led_status.sh b/addons/point_of_sale/tools/posbox/configuration/led_status.sh similarity index 100% rename from addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/led_status.sh rename to addons/point_of_sale/tools/posbox/configuration/led_status.sh diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/odoo.conf b/addons/point_of_sale/tools/posbox/configuration/odoo.conf similarity index 100% rename from addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/odoo.conf rename to addons/point_of_sale/tools/posbox/configuration/odoo.conf diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/posbox_update.sh b/addons/point_of_sale/tools/posbox/configuration/posbox_update.sh similarity index 100% rename from addons/point_of_sale/tools/posbox/overwrite_before_init/home/pi/posbox_update.sh rename to addons/point_of_sale/tools/posbox/configuration/posbox_update.sh diff --git a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/setup_ramdisks.sh b/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh similarity index 100% rename from addons/point_of_sale/tools/posbox/overwrite_after_init/etc/setup_ramdisks.sh rename to addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh diff --git a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/init.d/rcS b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/init.d/rcS index 6380e949834..4d32107fac8 100755 --- a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/init.d/rcS +++ b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/init.d/rcS @@ -5,6 +5,6 @@ # Call all S??* scripts in /etc/rcS.d/ in numerical/alphabetical order # -/etc/setup_ramdisks.sh +/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh exec /etc/init.d/rc S diff --git a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local index 065b6a05f77..dab16e3b415 100755 --- a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local +++ b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/rc.local @@ -20,6 +20,6 @@ fi mkdir -p /var/run/odoo chown pi:pi /var/run/odoo -/home/pi/led_status.sh & +/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/led_status.sh & exit 0 diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init.d/odoo b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init.d/odoo index 9bdaa86c584..f9bc0400abc 100755 --- a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init.d/odoo +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init.d/odoo @@ -17,7 +17,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin DAEMON=/home/pi/odoo/odoo.py NAME=odoo DESC=odoo -CONFIG=/home/pi/odoo.conf +CONFIG=/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/odoo.conf LOGFILE=/var/log/odoo/odoo-server.log PIDFILE=/var/run/${NAME}.pid USER=pi diff --git a/addons/point_of_sale/tools/posbox/posbox_create_image.sh b/addons/point_of_sale/tools/posbox/posbox_create_image.sh index 9e65410f8fe..5b860c65043 100755 --- a/addons/point_of_sale/tools/posbox/posbox_create_image.sh +++ b/addons/point_of_sale/tools/posbox/posbox_create_image.sh @@ -35,6 +35,7 @@ git config core.sparsecheckout true echo "addons/web addons/web_kanban addons/hw_* +addons/point_of_sale/tools/posbox/configuration openerp/ odoo.py" | tee --append .git/info/sparse-checkout > /dev/null git read-tree -mu HEAD From 1db1027cd5f434a3b8b94209202d47242e54a46f Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 26 Aug 2015 11:33:06 +0200 Subject: [PATCH 07/22] [IMP] point_of_sale: do more aggresive logrotate on rsyslog logs /var/log/syslog gets filled up quicker than usual because of all the crontab logs: Aug 26 09:29:01 raspberrypi /USR/SBIN/CRON[21223]: (root) CMD (rm /var/run/odoo/sessions/*) --- .../etc/init_posbox_image.sh | 6 +++ .../etc/logrotate.d/rsyslog | 37 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 addons/point_of_sale/tools/posbox/overwrite_before_init/etc/logrotate.d/rsyslog diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh index 367108ef167..6838f7fa78c 100755 --- a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/init_posbox_image.sh @@ -56,6 +56,12 @@ sudo -u postgres createuser -s pi mkdir /var/log/odoo chown pi:pi /var/log/odoo +# logrotate is very picky when it comes to file permissions +chown -R root:root /etc/logrotate.d/ +chmod -R 644 /etc/logrotate.d/ +chown root:root /etc/logrotate.conf +chmod 644 /etc/logrotate.conf + echo "* * * * * rm /var/run/odoo/sessions/*" | crontab - update-rc.d odoo defaults diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/logrotate.d/rsyslog b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/logrotate.d/rsyslog new file mode 100644 index 00000000000..3c4ad13016d --- /dev/null +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/logrotate.d/rsyslog @@ -0,0 +1,37 @@ +/var/log/syslog +{ + rotate 3 + daily + missingok + notifempty + delaycompress + compress + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} + +/var/log/mail.info +/var/log/mail.warn +/var/log/mail.err +/var/log/mail.log +/var/log/daemon.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/lpr.log +/var/log/cron.log +/var/log/debug +/var/log/messages +{ + rotate 3 + daily + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + invoke-rc.d rsyslog rotate > /dev/null + endscript +} From 6b988199489a89a0c48d1942c71547e0dfe54a06 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 10 Aug 2015 11:11:20 +0200 Subject: [PATCH 08/22] [FIX] membership: Don't overwrite invoice lines for membership invoice The invoice line is already linked to the invoice as it has the invoice_id field filled in the invoice line create method just above. Closes #7971 --- addons/membership/membership.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/membership/membership.py b/addons/membership/membership.py index 14b16992044..b955205aa46 100644 --- a/addons/membership/membership.py +++ b/addons/membership/membership.py @@ -428,8 +428,7 @@ class Partner(osv.osv): 'fiscal_position': fpos_id or False }, context=context) line_value['invoice_id'] = invoice_id - invoice_line_id = invoice_line_obj.create(cr, uid, line_value, context=context) - invoice_obj.write(cr, uid, invoice_id, {'invoice_line': [(6, 0, [invoice_line_id])]}, context=context) + invoice_line_obj.create(cr, uid, line_value, context=context) invoice_list.append(invoice_id) if line_value['invoice_line_tax_id']: tax_value = invoice_tax_obj.compute(cr, uid, invoice_id).values() From 675d09c005386cbe2b2e4fe4d625d8faf9054b3f Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Aug 2015 14:18:37 +0200 Subject: [PATCH 09/22] [FIX] fields_view_get super arguments The context argument needs to be passed as positional argument to avoid issues when surcharging fields_view_get Closes #7933 --- addons/account/report/account_report.py | 2 +- addons/account_analytic_plans/account_analytic_plans.py | 4 ++-- addons/anonymization/anonymization.py | 2 +- addons/crm/crm_lead.py | 2 +- addons/membership/membership.py | 2 +- addons/project/project.py | 2 +- addons/project/wizard/project_task_delegate.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/account/report/account_report.py b/addons/account/report/account_report.py index 8b650719151..c224138bf26 100644 --- a/addons/account/report/account_report.py +++ b/addons/account/report/account_report.py @@ -94,7 +94,7 @@ class report_aged_receivable(osv.osv): self._init(cr, user) self.called = True # To make sure that init doesn't get called multiple times - res = super(report_aged_receivable, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + res = super(report_aged_receivable, self).fields_view_get(cr, user, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) return res def _calc_bal(self, cr, uid, ids, name, args, context=None): diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index 83f92e4ac5c..9fc1fb93cf4 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -168,7 +168,7 @@ class account_analytic_plan_instance(osv.osv): if context is None: context = {} wiz_id = self.pool.get('ir.actions.act_window').search(cr, uid, [("name","=","analytic.plan.create.model.action")], context=context) - res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) journal_obj = self.pool.get('account.journal') analytic_plan_obj = self.pool.get('account.analytic.plan') if (res['type']=='form'): @@ -360,7 +360,7 @@ class account_move_line(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): if context is None: context = {} - result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) return result diff --git a/addons/anonymization/anonymization.py b/addons/anonymization/anonymization.py index 6d1fed48c97..f5ba65b4c13 100644 --- a/addons/anonymization/anonymization.py +++ b/addons/anonymization/anonymization.py @@ -310,7 +310,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory): step = context.get('step', 'new_window') - res = super(ir_model_fields_anonymize_wizard, self).fields_view_get(cr, uid, view_id, view_type, context, *args, **kwargs) + res = super(ir_model_fields_anonymize_wizard, self).fields_view_get(cr, uid, view_id, view_type, context=context, *args, **kwargs) eview = etree.fromstring(res['arch']) placeholder = eview.xpath("group[@name='placeholder1']") diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 8a1148b8984..ede6d03fe05 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -164,7 +164,7 @@ class crm_lead(format_address, osv.osv): action = self.get_formview_action(cr, user, context['opportunity_id'], context=context) if action.get('views') and any(view_id for view_id in action['views'] if view_id[1] == view_type): view_id = next(view_id[0] for view_id in action['views'] if view_id[1] == view_type) - res = super(crm_lead, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + res = super(crm_lead, self).fields_view_get(cr, user, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) if view_type == 'form': res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context) return res diff --git a/addons/membership/membership.py b/addons/membership/membership.py index b955205aa46..de9bcf9fc5f 100644 --- a/addons/membership/membership.py +++ b/addons/membership/membership.py @@ -456,7 +456,7 @@ class Product(osv.osv): view_id = dict_model['membership_products_form'] else: view_id = dict_model['membership_products_tree'] - return super(Product,self).fields_view_get(cr, user, view_id, view_type, context, toolbar, submenu) + return super(Product,self).fields_view_get(cr, user, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) '''Product''' _inherit = 'product.template' diff --git a/addons/project/project.py b/addons/project/project.py index 05e68afbdd3..c674034b367 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -844,7 +844,7 @@ class task(osv.osv): users_obj = self.pool.get('res.users') if context is None: context = {} - res = super(task, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu) + res = super(task, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) # read uom as admin to avoid access rights issues, e.g. for portal/share users, # this should be safe (no context passed to avoid side-effects) diff --git a/addons/project/wizard/project_task_delegate.py b/addons/project/wizard/project_task_delegate.py index e3c935d4f5d..2aae392bbb5 100644 --- a/addons/project/wizard/project_task_delegate.py +++ b/addons/project/wizard/project_task_delegate.py @@ -91,7 +91,7 @@ class project_task_delegate(osv.osv_memory): } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - res = super(project_task_delegate, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu) + res = super(project_task_delegate, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) users_pool = self.pool.get('res.users') obj_tm = users_pool.browse(cr, uid, uid, context=context).company_id.project_time_mode_id tm = obj_tm and obj_tm.name or 'Hours' From 0f036999567117ff42b2174f4b9703e33ba8628e Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 27 Aug 2015 12:20:28 +0200 Subject: [PATCH 10/22] [FIX] auth_signup: login & name readonly if signup with token In the case of a signup with token, the user login already exists, and changing of login (email) is therefore not allowed. It's the same behavior than in the reset password view (`auth_signup.reset_password`) opw-648125 --- addons/auth_signup/views/auth_signup_login.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/auth_signup/views/auth_signup_login.xml b/addons/auth_signup/views/auth_signup_login.xml index 27d80dfb5bf..33fbf119d7a 100644 --- a/addons/auth_signup/views/auth_signup_login.xml +++ b/addons/auth_signup/views/auth_signup_login.xml @@ -42,7 +42,9 @@