Commit Graph
35 Commits
Author SHA1 Message Date
Xavier Morel 9ebbfdac73 [FIX] *: incorrect translations markings
Fixes a large number of cases where strings are translated then
formatted, instead of letting `_()` do the formatting internally,
which allows it to recover from incorrect translations (missing,
broken, or extra placeholders).

Also

- removes translation markers entirely when there's nothing to
  translate e.g. `_("%s - %s")` is not useful
- fixes a few messes which lead to only partial translatability
  (DRY is generally a bad idea when translations are involved, even
  more so when you don't make the variable part translatable)
- fixes a few nearby issues noticed at the same time
- replaces a few `"%s"` by `%r`, which should automatically quote
  strings relatively appropriately
- fixes translated strings which use `\` to escape a newline (in order
  to fill-paragraph): `\` escapes only the newline, if the
  continuation string is indented this results in a bunch of spaces
  ending in the string to translate, which is pretty garbage for the
  translator, using implicit concatenation works much better

Note: some of the updates revert f-string parameters to %, because
babel (2.9) apparently has trouble with f-strings and blows up trying
to extract them.

Not in scope:

Helping translators fix translatable strings e.g. any translation
string with more than one placeholder probably should use keyword
placeholders

- Provides more context / data to the translator to make sense of the
  sentence.
- Allows reordering the translated terms, which can be necessary
  depending on the sentence and language.

closes odoo/odoo#139314

Related: odoo/enterprise#49311
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2023-10-23 16:45:09 +00:00
Martin Trigaux 22ab49e343 [IMP] *: use file_path and file_open
Replace all the calls to get_resource_path to the better file_path or
directly use file_open when not needed

Doing both a get_resource_path and file_open means checking twice that
the file exists.
Doing a simple path concatenation before a file_open is safe.
If given to another method (e.g. etree.parse), calling file_path is
the prefered method.

Note that get_resource_path used to return False when the file does
not exists while file_path/file_open raises a FileNotFoundException

closes odoo/odoo#135607

Related: odoo/upgrade#5187
Related: odoo/enterprise#47475
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-10-06 14:33:43 +00:00
lejeune quentin 54ea51a347 [FIX] point_of_sale: Fix errors of the new version of IoT 23.07
In the new version of the iot we import a new "crypt" library which is not available for windows

Addition of the class in the input of the password

closes odoo/odoo#128467

X-original-commit: f84bbfac2de786bf73e1fbe6d3b77452e17ac4bb
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2023-07-15 10:54:46 +02:00
lejeune quentin 5eeae30fd3 [FIX] point_of_sale: Update raspberry pi os for iot use
With this update the version of python goes to 3.9.2
In addition, a unique password system has been put in place

closes odoo/odoo#127975

X-original-commit: a0feb285ff2ff4a9b82f87ff5abefb307847f25a
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2023-07-10 18:16:33 +02:00
lejeune quentin 2badc30db9 [FIX] hw_drivers: Try catch the load of iot handlers
Currently, if a problem occurs during the loading of iot handlers
(drivers or interfaces), all loading of iot handlers is compromised.

With this FIX we display the Exception and the file concerned without
blocking the operation of the iot

closes odoo/odoo#118557

X-original-commit: 3b717b0d66ea2656e5058ab3df0b068fae8b08c8
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2023-04-14 10:45:09 +02:00
Loan (LSE) a6a7cd83f9 [FIX] hw_drivers: HTTPS certificate info on IoT homepage
HTTPS certificate IoT issues can be complicated to troubleshoot
as the information are not visible/given.
This PR aim to share this information on the IoT box homepage.
As there is a lot of possible causes for a given problem,
a code is used that will be explained/detailed in Odoo's
IoT documentation:
https://github.com/odoo/documentation/pull/3818

OPW-3227004

closes odoo/odoo#116650

X-original-commit: 8bc6b2d0033676507f95b74b3ae383ab17164203
Signed-off-by: Loan (LSE) <lse@odoo.com>
Signed-off-by: Sens Loan (lse) <lse@odoo.com>
2023-03-27 12:47:20 +02:00
lejeune quentin ab57a7fef4 [FIX] hw_drivers: Certificate checked before start nginx
Currently we verify the SSL certificate of the iot after starting the nginx web server.

So for the Windows iot if a new certificate is downloaded it will only be loaded by nginx
on the next restart of the iot because the process that runs nginx is a child of the one that runs the iot

With this commit we restart the windows iot if a new certificate is uploaded

closes odoo/odoo#112945

X-original-commit: 880afb3006ece93ee6575c977233bfb61081bf3a
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2023-02-17 12:07:48 +01:00
Yaroslav Soroko (yaso) fc9eb4691e [IMP] Added helpers to download and unzip files
This commit adds "download_from_url" and "unzip_file" functions to
helpers.py
These allow to downloaad files and unzip them from Python and let us
remove the bash scripts we were previously using for the same purpose.
More specifically this allows the same code to be used on Linux and
Windows IoT to download and unzip files

closes odoo/odoo#112942

X-original-commit: 01aad66d5bde13ced704dfc5226f271da185887a
Related: odoo/enterprise#37205
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2023-02-17 12:07:45 +01:00
lejeune quentin d3ccbe292f [FIX] hw_drivers: In IoT adapt path to filename
From the commit 2ab231bd7af609a751ed8168cc094dfeb1012eda
We introduce a error in the path to read Linux file

In this commit we correct the access to the file
which is in the "home" of the raspberry

closes odoo/odoo#107779

X-original-commit: e427d0a2147896aa4311488ebc13f45b84cb330c
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2022-12-13 12:47:51 +01:00
lejeune quentin b49e7e48f5 [IMP] hw_*: Add possibility to run IoT in Windows
Currently it is only possible to run the modules
for the IoT Box on Raspios.
The modifications brought by this commit brings the possibility
that the various hw_* modules can be executed whatever the OS
of the hardware (Linux or Windows).
If the modules should be versioned according to the OS,
the file will be renamed so that the end of
the file includes *_L (for linux) or *_W (for windows)

closes odoo/odoo#107350

X-original-commit: b7b8809ea8b7fe4ac8b24f43fe3f3a5e38a66696
Related: odoo/enterprise#34713
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2022-12-07 10:02:23 +01:00
lejeune quentin 08621a1b0c [FIX] hw_drivers: Allow the IoT to run without data base
From the last refactoring #78857 it was no longer possible to run the odoo server on an iot

With this commit we change the override of the db_list function
And and reload the driver controllers

closes odoo/odoo#86665

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2022-03-24 12:57:16 +01:00
Julien Castiaux 2e29a93503 [REF] core: remove http.addons_manifest
The http.addons_manifest is a map {module: manifest_dict} that is
populated upon the first http request. This map is basically a module
manifest cache with an extra `addons_path` key, the path of the module
on the file-system. This cache is eagerly populated upon the first http
request, the map is empty in non-http contextes (e.g. cron) which have
been a source of bugs (e.g. 50c8eb1).

A manifest cache is necessary because reading and parsing python files
from the file-system is not that cheap but there is no reason that cache
is located in `odoo.http`. A thin cache layer now wraps
`load_information_from_description_file()`/`load_manifest()` and is
lazily populated.

The `http.addons_manifest` have been removed. The extra `addons_path`
key is now present in the "normal" manifest. The `read_manifest()` was
hardly used so it has been deprecated. The only way to retrieve a
manifest is now `load_information_from_description_file()` which was
renamed `load_manifest()` (no cache) and `get_manifest()` (cache).

Side note about performances, the cache is necessary. Addons manifest
are read-only and reading + parsing python files from the file system is
not a cheap operation. Running the e-commerce tour
`@website_sale.test_04_admin_website_sale_tour` without cache on
`load_manifest()` requires 68,29 secs to complete on my laptop,
exceeding the default 1-minute time frame allowed in tests. Using a
cache the time is down to 36,53 secs. The performance impact is huge.

Part-of: odoo/odoo#79977
2021-12-14 12:39:54 +00:00
Raf Geens 60864de16b [FIX] hw_drivers: Block when getting network interface
get_ip and get_mac_address respectively try to get the IP and MAC from
the IoT box's active network interface. If the interface isn't fully up
yet (due to waiting on a slow DHCP server response for example), both
functions can end up raising a KeyError exception since neither
interface has a value.

This can be bad if it's uncaught and happens in something like the
Manager thread, potentially killing it as a result. This can then
disrupt the rest of the application. The network being gone for a bit or
slow is something that can happen during everyday use, so we should be
robust against it.

Since the box can't do any useful work without an active network
connection, this fix keeps retrying until one of the interfaces comes
back up.

opw-2357144

closes odoo/odoo#77052

X-original-commit: d0359858b17fb84c04c267bdf5cc1626569f5cce
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2021-09-23 14:24:58 +00:00
lejeune quentin b4920bfe55 [FIX] hw_drivers: Hide hostapd status in IoT
We call the status of the hostapd in each request of 'get_odoo_server_url()' and 'get_ssid()'
And this call display in the log the status '0' or 'inactive' in the log

With this commit we hide this useless information

closes odoo/odoo#72133

X-original-commit: e5e9f9f91cf9bf35f1e0b307008840a0de134e2f
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2021-06-14 13:13:32 +00:00
Antoine Prieels 2f7f9095d7 [FIX] hw_drivers: Don't crash if remount fails
We sometimes encountered IoT Boxes crashing because the remount failed.
As this isn't a big issue, we won't check the return value of the call
to `mount`.

closes odoo/odoo#59438

X-original-commit: 5f9874da0f5f5b27c546cd248d08299f0e65544b
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-10-07 15:44:11 +00:00
lejeune quentin c5f46533dd [FIX] point_of_sale: Fix path to nightly in IoT
The path to folder of images of IoT has change.

So we adapt the path for the upgrade of IoT

closes odoo/odoo#57978

X-original-commit: 9512a23f48176fe0e7970039c824281c4af18162
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-09-17 16:14:13 +00:00
Antoine Prieels 72681dc53f [IMP] hw_*,point_of_sale: Cleaning IoT Box
- Split driver.py to multiple files
- Remove hw_proxy module as most of its routes were not used and
  move remaingin routes to a controller in hw_drivers
- Add missing coding and license lines at the beginning of files
- Reorder imports and remove unused ones
- Rename device_id to device_identifier for clarity
- Rename screen to display for consistency
- Other minors improvements

Taskid: 1973956
X-original-commit: 841c016913a87133bf7257c62ae5f6bf7d99e06d
2020-08-25 11:24:56 +00:00
Antoine Prieels 6c97a9eb60 [FIX] hw_drivers, pos: Move IoTBox version file
We move the IoT Box version file from /home/pi to /var/odoo
so its not overriden after an auto-flash of the IoT Box.

closes odoo/odoo#54063

X-original-commit: ce0700ce401523267b5a8bd5665a368cfea24912
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-07-03 15:18:03 +00:00
lejeune quentin 9553871312 [FIX] hw_drivers: Restart Odoo after IoT has connected
When the route '/hw_drivers/box/connect' is called to connect an IoT Box to a DB,
the checkout on the branch of the DB is not performed and incompatibility can occur.

With this fix we relaunch Odoo via a parallel thread in order to be able to respond to the request...

closes odoo/odoo#52513

X-original-commit: 9aca7c464cef492c495a0c72d870b7075187dc63
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-06-05 14:00:06 +00:00
Antoine Prieels ec9759a6c0 [FIX] hw_drivers: Failed checkout and drivers loading
- The checkout to switch to the branch of the connected DB was not
processed correctly because the command used to clear the drivers
failed, raising an exception:

rm: cannot remove '/home/pi/odoo/addons/hw_drivers/drivers/__pycache__': Is a directory

- The location of the drivers has been changed in master. So, even if we
perform a checkout, the addons/hw_drivers/drivers directory doesn't
exist. The get_resource_path('hw_drivers', 'drivers') then returned
False instead of the correct path and the extraction of the zip file
failed.

closes odoo/odoo#52448

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-06-05 06:32:18 +00:00
Antoine Prieels e1c52c936d [IMP] hw_drivers: Easier detection of new devices
Until now, to detect new types of devices on the IoT Box, we had to
modify driver.py. If partners wanted to connect a new type of device,
they had to modify directly the files on the Box, meaning that after
each new build they had to re-apply all their modifications.

We remove the loops that detected the connected devices and replace
them by `Interfaces`. All interfaces will be loaded from the connected
Odoo instance with the corresponding drivers.

TaskID: 2082282
2020-05-13 13:26:05 +00:00
lejeune quentin 672323037a [FIX] hw_drivers: Clean drivers folder before change branch
When we change the version of branch we keep drivers.
But drivers are not compatible with all branch and Odoo
on the IoT Box can't start.

So we remove all drivers before checkout on another branch

closes odoo/odoo#50140

X-original-commit: 4e97aec6717697c742e5e0b09f00ab7dec09712f
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-04-24 11:10:12 +00:00
lejeune quentin 17c181ac74 [FIX] hw_drievrs: Replace SSID on the first boot
We replace the SSID of the IoTBox with a unique SSID

closes odoo/odoo#46255

X-original-commit: c847c1cb149e386331ff2e5b19a58862e1b66714
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-02-25 14:08:49 +00:00
lejeune quentin fff277a4a7 [FIX] hw_drivers: Do not send request if the IoT is in access point
If IoT Box is in access point mode and a server is configured
the box try to reach the server.
But in access point mode all requests are redirected to the box

So now before return True in function 'get_odoo_server_url'
we verify if the service 'hostapd' is inactive

closes odoo/odoo#46141

X-original-commit: 365f0e384630bad16e0872d2307702fca5a4e295
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-02-24 16:03:12 +00:00
lejeune quentin e8611b363a [IMP] point_of_sale: Add the possibility to the IoT Box to perform a self-flashing
To be able to flash the partition on which the IoT Box is executed,
we must create a third partition and install an OS there to be able
to boot on it and flash the partition of the IoT Box

- Creation of the third partition
- Raspbian download and checksum verification
- Installation of Raspbian on the third partition
- Download the IoT image on the Raspbian partition and check the checksum
- Reboot on the Raspbian partition
- Installation of the IoT image on the second partition
- Reboot on the IoT partition
- Cleaning and deleting the third partition

closes odoo/odoo#44430

Task: 2161955
X-original-commit: 407d9a88a3d23ed49ed5a2c5fa4d211cec43edfd
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-01-31 18:34:02 +00:00
Antoine Prieels 6e07e0b4b0 [FIX] hw_drivers: Use branch of connected DB
Preivously, the code of the IoT Box was retrieved from the branch that
was used during the build but the drivers were retrieved from the
connected Odoo DB. Both could be in different versions, which forced
used to make old drivers compatible with the new Box or new drivers
compatible with old versions of the Box.

All of this made it quite hard to modify the existing code, even for
new versions of the Box in master.

When connecting the IoT Box to an Odoo DB, we now retrieve the version
of Odoo that is used and checkout the Box to this branch. This means
that we can now modify the code of the Box in master without having to
worry about users using the latest build with older DBs.

Taskid: 2120749
X-original-commit: 6af5d669593a4f431d14fce08c6151932f97da82
2019-11-26 12:31:37 +00:00
lejeune quentin 5caa5d7d2e [IMP] hw_drivers: Change IoT Box version
Change the version of the IoT Box.
From 19_10 to 19_12

closes odoo/odoo#41109

X-original-commit: 2b8779dc657a5a2b877ad2a552dd0dfda0071357
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-11-29 10:23:15 +00:00
lejeune quentin 5d7e0b3735 [IMP] hw_drivers: Change version of IoT Box
We update the version of the build for IoT Box

closes odoo/odoo#38328

X-original-commit: be464a3759a4fe395334a1b26b90f7395e031d1a
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-10-10 06:31:41 +00:00
Antoine Prieels 9fff495927 [FIX] hw_drivers: Fix get_wifi_essid helper
The `get_wifi_essid` function was moved to the helpers file, but the
`self` argument was not removed from the function's signature.

closes odoo/odoo#36710

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-09-11 13:47:36 +00:00
lejeune quentin d4fa24c2bc [IMP] hw_drivers: Add possibility to choose a wifi network on IoT Box
Previously if you are wired connected we don't scan wifi network.

Now we scan the wifi network and add possibiliyt to select a network and use them.
2019-09-10 14:14:27 +00:00
lejeune quentin 9c10d7a28e [FIX] hw_drivers: Fix unmount of cups folder
To add or modify printer the /root_bypass_ramdisks/etc/cups/ need be writeable.
And /root_bypass_ramdisks/etc/cups/ = /etc/cups/
But when we make 'sudo mount -o remount,ro /' we put the /etc/cups/ and so
/root_bypass_ramdisks/etc/cups/ folder on read-only.

After all 'read-only' command we make another command to put cups folder writeable
2019-09-10 14:14:27 +00:00
Antoine Prieels 70006311d0 [IMP] hw_drivers, hw_posbox_homepage: get_ssid helper
Create a helper to get the ssid of the wifi to which the Box is
connected.
2019-09-04 13:10:03 +00:00
Antoine Prieels 2a7454ea6c [IMP] hw_{drivers, posbox_homepage}: Automatic load of drivers
Automatically load the IoT Drivers when Odoo starts on the IoT Box or
when the connection to the Odoo instance is done.

Allow to deactivate the automatic load to avoid overriding
modifications made on the Box.

TaskID: 2009683
2019-09-03 13:53:19 +00:00
lejeune quentin 2af13429cf [ADD] iot: Load a true certificate on IoT Box
With this commit we add the possibility to save the db_uuid and enterprise_code on the IoT Box.
We check the current SSL certificate and if it is not authenticated or not up to date
we send a request to 'https://www.odoo.com/odoo-enterprise/iot/x509'
with the db_uuid and enterprise_code to get the certificate, key, and domain associated with the client.
The IoT Box will be accessible in HTTPS according to the following domain:

https://<ip-with-dashes>.<sub-hash>.odoo-iot.com

<ip-with-dashes> being the ip address with dashes
<sub-hash> being a subdomain assigned by Odoo to a customer

Task: 1931770
2019-08-23 12:21:03 +02:00
lejeune quentin 84de7cbcb6 [ADD] iot: Improve usage of helpers in IoT Box
With this commit we move the helpers to a separate file for
easier access from the IoT Box
2019-08-23 12:21:02 +02:00