From 5af1c085bff377220047e80d8e4a64a5d8819d83 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Tue, 15 Mar 2016 14:28:12 +0100 Subject: [PATCH 01/14] [IMP] point_of_sale: migrate POSBox to Raspbian Jessie The main reason for doing this is supporting the new Raspberry Pi 3. No functional changes where made. For Raspbian Wheezy we used to download the full image and strip it as best we could to obtain a reasonable image size for people to download. Since Raspbian Jessie the Raspberry Pi Foundation has started releasing an official minimal image (Raspbian Jessie Lite) which we will use from now on to build our image. One downside of this is that the minimal image is a 1.3 GiB image which is too small for our purposes so it has to be resized. Because Raspbian Jessie migrated to systemd we cannot rely on /etc/init.d/rcS to set up the ramdisks anymore. Jessie provides a compatibility layer so old SysVinit scripts still work but rcS does not block like it does in a SysVinit system, it is run in parallel with other startup services. In our case this is a bad thing as setting up the ramdisks has to be done before any other services are started. To accomplish this the rcS hack has been migrated to a systemd service running before basic.target and with DefaultDependencies=no. This has a similar effect as the rcS hack because normal systemd services (with DefaultDependencies=yes) all require basic.target by default. --- .../posbox/configuration/setup_ramdisks.sh | 9 +++--- .../overwrite_after_init/etc/init.d/rcS | 10 ------- .../overwrite_after_init/etc/ld.so.preload | 1 + .../posbox/overwrite_before_init/etc/fstab | 5 ++++ .../etc/init_posbox_image.sh | 28 ++++--------------- .../overwrite_before_init/etc/ld.so.preload | 2 +- .../etc/systemd/system/ramdisks.service | 12 ++++++++ .../tools/posbox/posbox_create_image.sh | 23 ++++++++++++++- .../tools/posbox/posbox_download_images.sh | 4 +-- 9 files changed, 53 insertions(+), 41 deletions(-) delete mode 100755 addons/point_of_sale/tools/posbox/overwrite_after_init/etc/init.d/rcS create mode 100644 addons/point_of_sale/tools/posbox/overwrite_after_init/etc/ld.so.preload create mode 100644 addons/point_of_sale/tools/posbox/overwrite_before_init/etc/fstab create mode 100644 addons/point_of_sale/tools/posbox/overwrite_before_init/etc/systemd/system/ramdisks.service diff --git a/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh b/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh index 47e11d1bdd3..ce2f2e633e6 100755 --- a/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh +++ b/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh @@ -15,11 +15,10 @@ create_ramdisk () { mount --bind "${RAMDISK}" "${ORIGINAL}" } -# check /proc/cmdline - -# bind mount / so that we can get to the real /var and /etc -mount --bind / /root_bypass_ramdisks - echo "Creating ramdisks..." create_ramdisk "/var" "128M" create_ramdisk "/etc" "16M" +create_ramdisk "/tmp" "16M" + +# bind mount / so that we can get to the real /var and /etc +mount --bind / /root_bypass_ramdisks 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 deleted file mode 100755 index 4d32107fac8..00000000000 --- a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/init.d/rcS +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh -# -# rcS -# -# Call all S??* scripts in /etc/rcS.d/ in numerical/alphabetical order -# - -/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/ld.so.preload b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/ld.so.preload new file mode 100644 index 00000000000..37a96726c29 --- /dev/null +++ b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/ld.so.preload @@ -0,0 +1 @@ +/usr/lib/arm-linux-gnueabihf/libarmmem.so diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/fstab b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/fstab new file mode 100644 index 00000000000..d8e448c02d0 --- /dev/null +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/fstab @@ -0,0 +1,5 @@ +proc /proc proc defaults 0 0 +#/dev/mmcblk0p1 /boot vfat defaults 0 2 +#/dev/mmcblk0p2 / ext4 defaults,noatime 0 1 +# a swapfile is not a swap partition, no line here +# use dphys-swapfile swap[on|off] for that 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 c6d019cd945..86d2e7ffe3b 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 @@ -11,37 +11,16 @@ __base="$(basename ${__file} .sh)" # Recommends: antiword, graphviz, ghostscript, postgresql, python-gevent, poppler-utils 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 avahi-daemon" -INSTALLED_PKGS_TO_DELETE="" -set +o errexit -for CURRENT_PKG in $(echo $PKGS_TO_DELETE); do - $(dpkg --status $CURRENT_PKG &> /dev/null) - if [[ $? -eq 0 ]]; then - INSTALLED_PKGS_TO_DELETE="$INSTALLED_PKGS_TO_DELETE $CURRENT_PKG" - fi -done -set -o errexit - -apt-get -y remove --purge ${INSTALLED_PKGS_TO_DELETE} - -# Remove automatically installed dependency packages -apt-get -y autoremove - apt-get update apt-get -y dist-upgrade -PKGS_TO_INSTALL="adduser postgresql-client python python-dateutil python-decorator python-docutils python-feedparser python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-werkzeug python-xlwt python-yaml postgresql python-gevent python-serial python-pip python-dev localepurge vim mc mg screen iw hostapd isc-dhcp-server" +PKGS_TO_INSTALL="adduser postgresql-client python python-dateutil python-decorator python-docutils python-feedparser python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-werkzeug python-xlwt python-yaml postgresql python-gevent python-serial python-pip python-dev localepurge vim mc mg screen iw hostapd isc-dhcp-server git rsync console-data" apt-get -y install ${PKGS_TO_INSTALL} apt-get clean localepurge rm -rf /usr/share/doc -rm -rf /home/pi/python_games - -# remove raspi-config notice, it's not necessary and it's not installed anyway -rm -f /etc/profile.d/raspi-config.sh # python-usb in wheezy is too old # the latest pyusb from pip does not work either, usb.core.find() never returns @@ -70,6 +49,10 @@ echo "* * * * * rm /var/run/odoo/sessions/*" | crontab - update-rc.d -f hostapd remove update-rc.d -f isc-dhcp-server remove +systemctl daemon-reload +systemctl enable ramdisks.service +systemctl disable dphys-swapfile.service + # https://www.raspberrypi.org/forums/viewtopic.php?p=79249 # to not have "setting up console font and keymap" during boot take ages setupcon @@ -81,6 +64,7 @@ create_ramdisk_dir () { create_ramdisk_dir "/var" create_ramdisk_dir "/etc" +create_ramdisk_dir "/tmp" mkdir /root_bypass_ramdisks reboot diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/ld.so.preload b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/ld.so.preload index cfa850b8356..f1341ff1a3e 100644 --- a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/ld.so.preload +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/ld.so.preload @@ -1 +1 @@ -#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so +#/usr/lib/arm-linux-gnueabihf/libarmmem.so diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/systemd/system/ramdisks.service b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/systemd/system/ramdisks.service new file mode 100644 index 00000000000..48c75daabb8 --- /dev/null +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/systemd/system/ramdisks.service @@ -0,0 +1,12 @@ +[Unit] +Description=ramdisks +DefaultDependencies=no +After=sysinit.target local-fs.target +Before=basic.target + +[Service] +Type=oneshot +ExecStart=/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/setup_ramdisks.sh + +[Install] +WantedBy=basic.target 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 5e3d464ef2b..ba01ef09da5 100755 --- a/addons/point_of_sale/tools/posbox/posbox_create_image.sh +++ b/addons/point_of_sale/tools/posbox/posbox_create_image.sh @@ -50,8 +50,29 @@ rm ngrok.zip cd "${__dir}" mv /tmp/ngrok "${USR_BIN}" +# zero pad the image to be around 3.5 GiB, by default the image is only ~1.3 GiB +dd if=/dev/zero bs=1M count=2048 >> posbox.img + +# resize partition table +START_OF_ROOT_PARTITION=$(fdisk -l posbox.img | tail -n 1 | awk '{print $2}') +(echo 'p'; # print + echo 'd'; # delete + echo '2'; # second partition + echo 'n'; # create new partition + echo 'p'; # primary + echo '2'; # number 2 + echo "${START_OF_ROOT_PARTITION}"; # starting at previous offset + echo ''; # ending at default (fdisk should propose max) + echo 'p'; # print + echo 'w') | fdisk posbox.img # write and quit + LOOP_MAPPER_PATH=$(kpartx -av posbox.img | tail -n 1 | cut -d ' ' -f 3) LOOP_MAPPER_PATH="/dev/mapper/${LOOP_MAPPER_PATH}" + +# resize filesystem +e2fsck -f "${LOOP_MAPPER_PATH}" # resize2fs requires clean fs +resize2fs "${LOOP_MAPPER_PATH}" + mkdir "${MOUNT_POINT}" mount "${LOOP_MAPPER_PATH}" "${MOUNT_POINT}" @@ -70,7 +91,7 @@ umount "${MOUNT_POINT}" # from http://paulscott.co.za/blog/full-raspberry-pi-raspbian-emulation-with-qemu/ # ssh pi@localhost -p10022 -QEMU_OPTS=(-kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda posbox.img -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::18069-:8069 -net nic) +QEMU_OPTS=(-kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append 'root=/dev/sda2 rootfstype=ext4 rw' -hda posbox.img -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::18069-:8069 -net nic) if [ -z ${DISPLAY:-} ] ; then QEMU_OPTS+=(-nographic) fi diff --git a/addons/point_of_sale/tools/posbox/posbox_download_images.sh b/addons/point_of_sale/tools/posbox/posbox_download_images.sh index a138e44bfab..b500094058d 100755 --- a/addons/point_of_sale/tools/posbox/posbox_download_images.sh +++ b/addons/point_of_sale/tools/posbox/posbox_download_images.sh @@ -1,5 +1,5 @@ #!/bin/sh -wget 'http://downloads.raspberrypi.org/raspbian_latest' -O raspbian.img.zip +wget 'https://downloads.raspberrypi.org/raspbian_lite_latest' -O raspbian.img.zip unzip raspbian.img.zip -wget 'https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu' +wget 'https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.1.13-jessie' -O kernel-qemu From fd43faac167283d0fc267467263f25b3f63e60a8 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 13 Apr 2016 14:26:13 +0200 Subject: [PATCH 02/14] [IMP] point_of_sale: redirect POSBox image init script output to file Useful when updates to the initialization scripts don't go as planned. This leaves something to inspect. The initialization script already automatically stops (because of 'set -o errexit') but it was a bit tricky to actually see what went wrong because scrollback in QEMU isn't great. --- .../tools/posbox/overwrite_before_init/etc/rc.local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/rc.local b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/rc.local index c55290c3978..22b8b8a5c8a 100755 --- a/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/rc.local +++ b/addons/point_of_sale/tools/posbox/overwrite_before_init/etc/rc.local @@ -17,6 +17,6 @@ if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi -/etc/init_posbox_image.sh +/etc/init_posbox_image.sh 2>&1 | tee /home/pi/init_posbox_image.log exit 0 From f5a527fb0ac903eaf51c7d0ec67e875740011d80 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 13 Apr 2016 14:52:04 +0200 Subject: [PATCH 03/14] [IMP] point_of_sale: move POSBox AP to a less used subnet When the POSBox boots without a network cable attached it will automatically launch a wireless AP that people can connect to. This allows them to configure what wireless network the POSBox should connect to. This wireless AP was configured to use the 10.10.0.0/24 subnet. The AP itself was on 10.10.0.1. Although this is fine if used as intended it is a quick way to take down an existing network if you where to plug in an ethernet cable after the wireless AP has started. 10.10.0.1 is commonly used by routers all over the world and plugging in a booted POSBox into their networks will cause serious issues because the POSBox will share the same IP as the router. This moves the POSBox AP to the 10.11.12.0/24 subnet, with the AP on 10.11.12.1. This also makes the DHCP server listen only on wlan0 because otherwise you can end up with two DHCP servers on the same network which would still break stuff. --- .../tools/posbox/configuration/wireless_ap.sh | 2 +- .../etc/default/isc-dhcp-server | 21 +++++++++++++++++++ .../overwrite_after_init/etc/dhcp/dhcpd.conf | 6 +++--- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 addons/point_of_sale/tools/posbox/overwrite_after_init/etc/default/isc-dhcp-server diff --git a/addons/point_of_sale/tools/posbox/configuration/wireless_ap.sh b/addons/point_of_sale/tools/posbox/configuration/wireless_ap.sh index bf7a3427f69..97b011b296d 100755 --- a/addons/point_of_sale/tools/posbox/configuration/wireless_ap.sh +++ b/addons/point_of_sale/tools/posbox/configuration/wireless_ap.sh @@ -28,7 +28,7 @@ if [ -z "${WIRED_IP}" ] ; then service hostapd restart - ip addr add 10.10.0.1/24 dev wlan0 + ip addr add 10.11.12.1/24 dev wlan0 service isc-dhcp-server restart diff --git a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/default/isc-dhcp-server b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/default/isc-dhcp-server new file mode 100644 index 00000000000..ec7fb5a5b6a --- /dev/null +++ b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/default/isc-dhcp-server @@ -0,0 +1,21 @@ +# Defaults for isc-dhcp-server initscript +# sourced by /etc/init.d/isc-dhcp-server +# installed at /etc/default/isc-dhcp-server by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf). +#DHCPD_CONF=/etc/dhcp/dhcpd.conf + +# Path to dhcpd's PID file (default: /var/run/dhcpd.pid). +#DHCPD_PID=/var/run/dhcpd.pid + +# Additional options to start dhcpd with. +# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead +#OPTIONS="" + +# On what interfaces should the DHCP server (dhcpd) serve DHCP requests? +# Separate multiple interfaces with spaces, e.g. "eth0 eth1". +INTERFACES="wlan0" diff --git a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/dhcp/dhcpd.conf b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/dhcp/dhcpd.conf index 054b4b4477f..d13dbb9a639 100644 --- a/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/dhcp/dhcpd.conf +++ b/addons/point_of_sale/tools/posbox/overwrite_after_init/etc/dhcp/dhcpd.conf @@ -37,10 +37,10 @@ ddns-update-style none; # option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; #} -subnet 10.10.0.0 netmask 255.255.255.0 { - range 10.10.0.2 10.10.0.254; +subnet 10.11.12.0 netmask 255.255.255.0 { + range 10.11.12.2 10.11.12.254; option domain-name-servers 8.8.8.8, 208.67.222.222; - option routers 10.10.0.1; + option routers 10.11.12.1; } # This declaration allows BOOTP clients to get dynamic addresses, From 967629f8ac0a1864ab70adb18f4331fd952e4cb1 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Thu, 14 Apr 2016 10:24:40 +0200 Subject: [PATCH 04/14] [IMP] point_of_sale: release POSBox image v14 Marks official support for the Raspberry Pi 3. --- addons/hw_posbox_homepage/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hw_posbox_homepage/controllers/main.py b/addons/hw_posbox_homepage/controllers/main.py index 11d7a9d2f30..7c9f90dab2e 100644 --- a/addons/hw_posbox_homepage/controllers/main.py +++ b/addons/hw_posbox_homepage/controllers/main.py @@ -55,7 +55,7 @@ index_template = """ Wi-Fi can be configured by visiting the Wi-Fi configuration page.

- The PosBox software installed on this posbox is version 13, + The PosBox software installed on this posbox is version 14, the posbox version number is independent from Odoo. You can upgrade the software on the upgrade page.

From 00ead29c7c1877de94be8c28bd587fa7acedcc69 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Thu, 14 Apr 2016 14:00:42 +0200 Subject: [PATCH 05/14] [FIX] web: fix layout issue in Chrome 50 The height was not distributed anymore to the children of a `table-row` element if they are not themselves `table-cell` elements. Fixes #11629 --- addons/web/static/src/css/base.css | 2 ++ addons/web/static/src/css/base.sass | 2 ++ 2 files changed, 4 insertions(+) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 62373f1f7d3..f52fd597c5a 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -902,6 +902,7 @@ height: 100%; } .openerp .oe_leftbar > div > div > div { + display: table-cell; position: relative; height: 100%; } @@ -1062,6 +1063,7 @@ height: 100%; } .openerp .oe_application > div > .oe_view_manager > .oe_view_manager_wrapper > div { + display: table-cell; position: relative; height: 100%; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 40ace6829eb..bd0a322e8c0 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -785,6 +785,7 @@ $sheet-padding: 16px display: table-row height: 100% > div + display: table-cell position: relative height: 100% > div.oe_secondary_menus_container @@ -917,6 +918,7 @@ $sheet-padding: 16px display: table-row height: 100% > div + display: table-cell position: relative height: 100% > .oe_view_manager_body From dc3f1e22117aafbc1342a2ea1a8902072edaeb4e Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 14 Apr 2016 13:58:30 +0200 Subject: [PATCH 06/14] [FIX] account_analytic_analysis: comment field in account.invoice When creating an invoice from a contract with button "create invoices", the description linked to the contract has to written in the comment field of the invoice. opw:671660 --- addons/account_analytic_analysis/account_analytic_analysis.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 8b7591df00d..fcd716c1c96 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -705,6 +705,7 @@ class account_analytic_account(osv.osv): 'payment_term': partner_payment_term, 'company_id': contract.company_id.id or False, 'user_id': contract.manager_id.id or uid, + 'comment': contract.description, } return invoice From 1d25fe1e05d61c9b6be5d3bd25a65e5b8c4696b7 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 14 Apr 2016 10:55:37 +0200 Subject: [PATCH 07/14] [FIX] qweb: escape alt-field properly in image widget This is very unlikely to be exploitable because the alt-field usually comes from master data (e.g. product names) that can't be injected. Courtesy of Naglis Jonaitis --- addons/website/models/ir_qweb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/models/ir_qweb.py b/addons/website/models/ir_qweb.py index 85fe6a3a2f8..27806bbe437 100644 --- a/addons/website/models/ir_qweb.py +++ b/addons/website/models/ir_qweb.py @@ -300,7 +300,7 @@ class Image(orm.AbstractModel): src = self.pool['website'].image_url(cr, uid, record, field_name, max_size) alt = None if options.get('alt-field') and getattr(record, options['alt-field'], None): - alt = record[options['alt-field']] + alt = escape(record[options['alt-field']]) elif options.get('alt'): alt = options['alt'] img = '' % (classes, src, options.get('style', ''), ' alt="%s"' % alt if alt else '') From 605b94e64c202d7dbb335ce37280fae87a3a6d87 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 15 Apr 2016 10:03:53 +0200 Subject: [PATCH 08/14] [FIX] point_of_sale: do not hide transactional errors Catching and hiding database transactional errors can sometimes cause a POS order to be entirely lost. When it occurs, the transaction won't be committed into the database, and if there is only one order in the batch, the server won't return any error to the frontend POS which will consider the order saved. --- addons/point_of_sale/point_of_sale.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index fbe0e3c1241..05a3dcb4339 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -24,6 +24,7 @@ from dateutil.relativedelta import relativedelta from decimal import Decimal import logging import pdb +import psycopg2 import time import openerp @@ -537,6 +538,9 @@ class pos_order(osv.osv): wf_service = netsvc.LocalService("workflow") try: wf_service.trg_validate(uid, 'pos.order', order_id, 'paid', cr) + except psycopg2.OperationalError: + # do not hide transactional errors, the order(s) won't be saved! + raise except Exception: _logger.error('ERROR: Could not fully process the POS Order', exc_info=True) return order_ids From e1a99192bda1019a50be879cb0baaa72d447956a Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 15 Apr 2016 12:12:26 +0200 Subject: [PATCH 09/14] Revert "[FIX] web: fix layout issue in Chrome 50" or how to break every internet explorer releases while attempting to fix chrome 50 --- addons/web/static/src/css/base.css | 2 -- addons/web/static/src/css/base.sass | 2 -- 2 files changed, 4 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index f52fd597c5a..62373f1f7d3 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -902,7 +902,6 @@ height: 100%; } .openerp .oe_leftbar > div > div > div { - display: table-cell; position: relative; height: 100%; } @@ -1063,7 +1062,6 @@ height: 100%; } .openerp .oe_application > div > .oe_view_manager > .oe_view_manager_wrapper > div { - display: table-cell; position: relative; height: 100%; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index bd0a322e8c0..40ace6829eb 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -785,7 +785,6 @@ $sheet-padding: 16px display: table-row height: 100% > div - display: table-cell position: relative height: 100% > div.oe_secondary_menus_container @@ -918,7 +917,6 @@ $sheet-padding: 16px display: table-row height: 100% > div - display: table-cell position: relative height: 100% > .oe_view_manager_body From f992c8ee192c075b38bf14dd5dcfb10fba7dd2ef Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Mon, 18 Apr 2016 12:23:39 +0200 Subject: [PATCH 10/14] [FIX] web: fix layout issue in Chrome 50 A 100% height is not distributed anymore to the children of a table-row if they are not themselves table-cell in Chrome 50. This breaks the indenpendent scrolling of the menu and the view manager. However, setting the `table-cell` display breaks the layout in Internet Explorer. When the webclient is loaded by Chrome 50, we load a stylesheet forcing a `table-cell` for display. Seems to be related to https://bugs.chromium.org/p/chromium/issues/detail?id=353580 and https://chromium.googlesource.com/chromium/src.git/+/8876584335b48c99cf8df552ef4d8efebb131041 Related to e1a99192bda1019a50be879cb0baaa72d447956a Fixes #11629 --- addons/web/static/src/css/chrome50.css | 8 ++++++++ addons/web/static/src/js/chrome.js | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 addons/web/static/src/css/chrome50.css diff --git a/addons/web/static/src/css/chrome50.css b/addons/web/static/src/css/chrome50.css new file mode 100644 index 00000000000..cfcf6d84033 --- /dev/null +++ b/addons/web/static/src/css/chrome50.css @@ -0,0 +1,8 @@ +/* Do not forward port! */ +.oe_leftbar > div > div > div { + display: table-cell; +} + +.oe_view_manager > .oe_view_manager_wrapper > div { + display: table-cell; +} diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 83c2ea63dae..34a9f15cb00 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1292,6 +1292,14 @@ instance.web.WebClient = instance.web.Client.extend({ self.action_manager.do_action(self.client_options.action_post_login); delete(self.client_options.action_post_login); } + + /* Do not forward port! */ + if ($.browser.chrome) { + var chrome_version = $.browser.version.split('.')[0]; + if (parseInt(chrome_version, 10) >= 50) { + openerp.loadCSS('/web/static/src/css/chrome50.css'); + } + } }, update_logo: function() { var company = this.session.company_id; From 6057e645d6724692dbfc287fd650480f007d2028 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 14 Apr 2016 09:50:10 +0200 Subject: [PATCH 11/14] =?UTF-8?q?[FIX]=C2=A0purchase:=20Shipping=20=20exce?= =?UTF-8?q?ption=20when=20cancelling=20a=20PO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When canceling and clicking on "reset to draft" button a PO with invoicing method = Based on generated draft invoice, the purchase workflow led to a shipping exception. To be in state done the PO must have: All its PO lines invoiced with _set_po_lines_invoiced All its incoming shipments done with test_moves_done opw:673561 --- addons/purchase/purchase.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 63131ec104d..cbeb2325124 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -653,6 +653,14 @@ class purchase_order(osv.osv): return False self.write(cr, uid, ids, {'state':'draft','shipped':0}) self.set_order_line_status(cr, uid, ids, 'draft', context=context) + for po in self.browse(cr, SUPERUSER_ID, ids, context=context): + for picking in po.picking_ids: + picking.move_lines.write({'purchase_line_id': False}) + for invoice in po.invoice_ids: + po.write({'invoice_ids': [(3, invoice.id, _)]}) + for po_line in po.order_line: + for invoice_line in po_line.invoice_lines: + po_line.write({'invoice_lines': [(3, invoice_line.id, _)]}) for p_id in ids: # Deleting the existing instance of workflow for PO self.delete_workflow(cr, uid, [p_id]) # TODO is it necessary to interleave the calls? From 9fa53b7ee7fc8faca2ee8bc1d5205dca62f3e565 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Mon, 18 Apr 2016 11:51:56 +0200 Subject: [PATCH 12/14] [FIX] point_of_sale: adapt to Chrome 50's new handling of cell heights Chrome 50 treats percent-height divs inside of auto-height cells as auto [1]. So from now on it's important that an explicit 'height: 100%' CSS property is set on parent tds, otherwise you'll end up with elements with a height of 0. An extra difficulty is that this new height property on subwindow-container will result in the element being as high as his parent table. So the collapsed trick doesn't work anymore in the customer list. This has to be done conditionally. The proposed workaround of adding 100% height to parents of affected elements causes issues in IE/Edge because the effect of adding a height in percent to a table-{cell,row} element is not defined by CSS [2]. DO NOT FORWARD-PORT! [1] https://chromium.googlesource.com/chromium/src/+/8876584335b48c99cf8df552ef4d8efebb131041 [2] http://stackoverflow.com/a/27384730 --- addons/point_of_sale/static/src/css/chrome50.css | 6 ++++++ addons/point_of_sale/static/src/css/pos.css | 3 +++ addons/point_of_sale/static/src/js/widgets.js | 7 +++++++ addons/point_of_sale/static/src/xml/pos.xml | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 addons/point_of_sale/static/src/css/chrome50.css diff --git a/addons/point_of_sale/static/src/css/chrome50.css b/addons/point_of_sale/static/src/css/chrome50.css new file mode 100644 index 00000000000..67ecddccfde --- /dev/null +++ b/addons/point_of_sale/static/src/css/chrome50.css @@ -0,0 +1,6 @@ +.pos .screen .content-cell{ + height: 100%; +} +.pos .subwindow .subwindow-container{ + height: 100%; +} \ No newline at end of file diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 02b19831776..60337c78c15 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -166,6 +166,9 @@ td { .pos .window .subwindow.collapsed{ height: 0px; } +.pos .window .subwindow-container .collapsed{ + height: 0px; +} .pos .subwindow .subwindow-container{ display: table-cell; position: relative; diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 59decb450ac..81cd422a737 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -965,6 +965,13 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa start: function() { var self = this; return self.pos.ready.done(function() { + if ($.browser.chrome) { + var chrome_version = $.browser.version.split('.')[0]; + if (parseInt(chrome_version, 10) >= 50) { + openerp.loadCSS('/point_of_sale/static/src/css/chrome50.css'); + } + } + // remove default webclient handlers that induce click delay $(document).off(); $(window).off(); diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 34d81e9475b..196495dd624 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -435,7 +435,7 @@