Skip to content

Commit

Permalink
Merge pull request NixOS#312060 from siriobalmelli/fix/odoo
Browse files Browse the repository at this point in the history
odoo: fix odoo16; add odoo17
  • Loading branch information
mkg20001 committed Jun 19, 2024
2 parents 2bfe205 + 6c10cfb commit 27e0947
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 31 deletions.
1 change: 1 addition & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -822,3 +822,4 @@ Module System:
### Internal {#sec-release-24.05-lib-internal}
- `lib` now has [Readme for contributing](https://github.com/NixOS/nixpkgs/tree/master/lib#readme).
- Some function's documentation is now written using the [accepted doc comment syntax](https://github.com/NixOS/rfcs/pull/145).
- `odoo` has been updated from `16.0.20231024` to `17.0.20240507`.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ in {
pyload = handleTest ./pyload.nix {};
oci-containers = handleTestOn ["aarch64-linux" "x86_64-linux"] ./oci-containers.nix {};
odoo = handleTest ./odoo.nix {};
odoo16 = handleTest ./odoo.nix { package = pkgs.odoo16; };
odoo15 = handleTest ./odoo.nix { package = pkgs.odoo15; };
# 9pnet_virtio used to mount /nix partition doesn't support
# hibernation. This test happens to work on x86_64-linux but
Expand Down
12 changes: 12 additions & 0 deletions nixos/tests/odoo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ import ./make-test-python.nix ({ pkgs, lib, package ? pkgs.odoo, ...} : {
package = package;
domain = "localhost";
};

# odoo does not automatically initialize its database,
# even if passing what _should_ be the equivalent of these options:
# settings = {
# options = {
# database = "odoo";
# init = "base";
# };
# };
systemd.services.odoo.preStart = ''
HOME=$STATE_DIRECTORY ${package}/bin/odoo -d odoo -i base --stop-after-init --without-demo all
'';
};
};

Expand Down
27 changes: 0 additions & 27 deletions pkgs/applications/finance/odoo/update.sh

This file was deleted.

111 changes: 111 additions & 0 deletions pkgs/by-name/od/odoo/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{ stdenv
, lib
, fetchgit
, fetchzip
, python310
, rtlcss
, wkhtmltopdf
, nixosTests
, odoo_version ? "17.0"
, odoo_release ? "20240610"
}:

let
python = python310.override {
packageOverrides = final: prev: {
# requirements.txt fixes docutils at 0.17; the default 0.21.1 tested throws exceptions
docutils-0_17 = prev.docutils.overridePythonAttrs (old: rec {
version = "0.17";
src = fetchgit {
url = "git:https://repo.or.cz/docutils.git";
rev = "docutils-${version}";
hash = "sha256-O/9q/Dg1DBIxKdNBOhDV16yy5ez0QANJYMjeovDoWX8=";
};
buildInputs = with prev; [setuptools];
});
};
};
in python.pkgs.buildPythonApplication rec {
pname = "odoo";
version = "${odoo_version}.${odoo_release}";

format = "setuptools";

src = fetchzip {
# find latest version on https://nightly.odoo.com/${odoo_version}/nightly/src
url = "https://nightly.odoo.com/${odoo_version}/nightly/src/odoo_${version}.zip";
name = "${pname}-${version}";
hash = "sha256-blibGJyaz+MxMazOXhPbGBAJWZoGubirwSnjVYyLBJs="; # odoo
};

# needs some investigation
doCheck = false;

makeWrapperArgs = [
"--prefix" "PATH" ":" "${lib.makeBinPath [ wkhtmltopdf rtlcss ]}"
];

propagatedBuildInputs = with python.pkgs; [
babel
chardet
cryptography
decorator
docutils-0_17 # sphinx has a docutils requirement >= 18
ebaysdk
freezegun
gevent
greenlet
idna
jinja2
libsass
lxml
markupsafe
num2words
ofxparse
passlib
pillow
polib
psutil
psycopg2
pydot
pyopenssl
pypdf2
pyserial
python-dateutil
python-ldap
python-stdnum
pytz
pyusb
qrcode
reportlab
requests
rjsmin
urllib3
vobject
werkzeug
xlrd
xlsxwriter
xlwt
zeep

setuptools
mock
];

# takes 5+ minutes and there are not files to strip
dontStrip = true;

passthru = {
updateScript = ./update.sh;
tests = {
inherit (nixosTests) odoo;
};
};

meta = with lib; {
description = "Open Source ERP and CRM";
homepage = "https://www.odoo.com/";
license = licenses.lgpl3Only;
maintainers = with maintainers; [ mkg20001 siriobalmelli ];
};
}
26 changes: 26 additions & 0 deletions pkgs/by-name/od/odoo/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused nix coreutils nix-prefetch

set -euo pipefail

VERSION="17.0" # must be incremented manually

RELEASE="$(
curl "https://nightly.odoo.com/$VERSION/nightly/src/" |
sed -nE 's/.*odoo_'"$VERSION"'.(20[0-9]{6}).tar.gz.*/\1/p' |
tail -n 1
)"

latestVersion="$VERSION.$RELEASE"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; odoo.version or (lib.getVersion odoo)" | tr -d '"')

if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "odoo is up-to-date: $currentVersion"
exit 0
fi

cd "$(dirname "${BASH_SOURCE[0]}")"

sed -ri "s| hash.+ # odoo| hash = \"$(nix-prefetch -q fetchzip --url "https://nightly.odoo.com/${VERSION}/nightly/src/odoo_${latestVersion}.zip")\"; # odoo|g" package.nix
sed -ri "s|, odoo_version \? .+|, odoo_version ? \"$VERSION\"|" package.nix
sed -ri "s|, odoo_release \? .+|, odoo_release ? \"$RELEASE\"|" package.nix
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ let
inherit version;
hash = "sha256-K4wORHtLnbzIXdl7butNy69si2w74L1lTiVVPgohV9g=";
};
disabledTests = old.disabledTests ++ [
"test_response_body"
];
});
};
};
Expand Down Expand Up @@ -99,7 +102,6 @@ in python.pkgs.buildPythonApplication rec {
dontStrip = true;

passthru = {
updateScript = ./update.sh;
tests = {
inherit (nixosTests) odoo;
};
Expand Down
3 changes: 0 additions & 3 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5968,9 +5968,6 @@ with pkgs;
inherit (darwin.apple_sdk.frameworks) AppKit Security;
};

odoo = callPackage ../applications/finance/odoo { };
odoo15 = callPackage ../applications/finance/odoo/odoo15.nix { };

odafileconverter = libsForQt5.callPackage ../applications/graphics/odafileconverter { };

oil-buku = callPackage ../applications/misc/oil-buku { };
Expand Down

0 comments on commit 27e0947

Please sign in to comment.