Compare commits
1 Commits
18.0
...
16.0-sale_
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d8293f73e |
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Run the Python tests of the given Odoo modules.
|
||||
#
|
||||
# This script is meant to be executed *inside* an Elabore doodba image
|
||||
# (docker.0k.io/mirror/odoo:rc_<version>-ELABORE-LIGHT), with a
|
||||
# PostgreSQL service reachable at $PGHOST. The modules under test are
|
||||
# read from the current working directory (the checked-out repository),
|
||||
# which is prepended to the addons path so that the PR's code takes
|
||||
# precedence over the modules already baked in the image.
|
||||
#
|
||||
# Usage: odoo-tests.sh <module1,module2,...>
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
modules="${1:?usage: odoo-tests.sh <module1,module2,...>}"
|
||||
|
||||
export PGHOST=postgres
|
||||
export PGUSER=odoo
|
||||
export PGPASSWORD=odoopassword
|
||||
export PGDATABASE="test_$(basename "$PWD" | tr '.-' '__')"
|
||||
export WITHOUT_DEMO=all
|
||||
export DB_FILTER='.*'
|
||||
|
||||
# Generate /opt/odoo/auto/odoo.conf from the environment and wait for
|
||||
# the database to accept connections.
|
||||
/opt/odoo/common/entrypoint
|
||||
|
||||
# Odoo test-tags format: "/module1,/module2" (one leading slash).
|
||||
tags="/$(echo "$modules" | tr ',' ',/')"
|
||||
|
||||
exec odoo \
|
||||
--config=/opt/odoo/auto/odoo.conf \
|
||||
--max-cron-threads=0 \
|
||||
--limit-time-real=10000 \
|
||||
--workers=0 \
|
||||
--test-enable \
|
||||
--stop-after-init \
|
||||
--addons-path="$PWD,/opt/odoo/auto/addons" \
|
||||
-d "$PGDATABASE" \
|
||||
-i "$modules" \
|
||||
--test-tags "$tags"
|
||||
@@ -2,6 +2,8 @@ name: pre-commit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "16.0*"
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
@@ -13,10 +15,10 @@ jobs:
|
||||
python-version: "3.11"
|
||||
- name: Get python version
|
||||
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
|
||||
- uses: https://gitea.com/actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
# - uses: actions/cache@v4
|
||||
# with:
|
||||
# path: ~/.cache/pre-commit
|
||||
# key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
- name: Install pre-commit
|
||||
run: pip install pre-commit
|
||||
- name: Run pre-commit
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
name: tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "18.0*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: odoo-ci
|
||||
container:
|
||||
image: docker.0k.io/mirror/odoo:rc_18.0-ELABORE-LIGHT
|
||||
services:
|
||||
postgres:
|
||||
image: docker.0k.io/postgres:17.2.0-myc
|
||||
env:
|
||||
POSTGRES_USER: odoo
|
||||
POSTGRES_PASSWORD: odoopassword
|
||||
POSTGRES_DB: postgres
|
||||
steps:
|
||||
# The doodba image ships no Node.js, so actions/checkout@v4 cannot
|
||||
# run here. The repository is private, so the job token is required.
|
||||
- name: Checkout
|
||||
env:
|
||||
SECRET_GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
token="${GITEA_TOKEN:-${GITHUB_TOKEN:-${SECRET_GITEA_TOKEN:-${SECRET_GITHUB_TOKEN:-}}}}"
|
||||
if [ -z "$token" ]; then
|
||||
echo "::error::No job token available to clone the repository"
|
||||
exit 1
|
||||
fi
|
||||
server="${GITHUB_SERVER_URL:-https://git.elabore.coop}"
|
||||
repo="${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is not set}"
|
||||
ref="${GITHUB_REF:-${GITHUB_SHA:?neither GITHUB_REF nor GITHUB_SHA is set}}"
|
||||
auth_url="$(printf '%s' "${server%/}/${repo}.git" |
|
||||
sed -E "s#^https://#https://${token}@#")"
|
||||
git init -q .
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git remote add origin "$auth_url"
|
||||
git fetch -q --depth=1 origin "$ref"
|
||||
git checkout -q FETCH_HEAD
|
||||
|
||||
- name: Detect changed modules
|
||||
id: changed
|
||||
run: |
|
||||
set -eu
|
||||
if [ -n "${GITHUB_BASE_REF:-}" ]; then
|
||||
git fetch -q --depth=1 origin "refs/heads/$GITHUB_BASE_REF"
|
||||
base_rev="FETCH_HEAD"
|
||||
scope="diff against $GITHUB_BASE_REF"
|
||||
else
|
||||
base_rev=""
|
||||
scope="all installable modules (manual run)"
|
||||
fi
|
||||
if [ -n "$base_rev" ]; then
|
||||
modules="$(
|
||||
git diff --name-only "$base_rev" HEAD |
|
||||
awk -F/ '{print $1}' | sort -u |
|
||||
while read -r dir; do
|
||||
[ -f "$dir/__manifest__.py" ] && echo "$dir"
|
||||
done | paste -sd, -
|
||||
)"
|
||||
else
|
||||
modules="$(
|
||||
for dir in */; do
|
||||
dir="${dir%/}"
|
||||
[ -f "$dir/__manifest__.py" ] && echo "$dir"
|
||||
done | paste -sd, -
|
||||
)"
|
||||
fi
|
||||
echo "modules=$modules" >> "$GITHUB_OUTPUT"
|
||||
echo "Modules to test ($scope): ${modules:-<none>}"
|
||||
|
||||
- name: Run Odoo tests
|
||||
if: steps.changed.outputs.modules != ''
|
||||
run: bash .gitea/scripts/odoo-tests.sh "${{ steps.changed.outputs.modules }}"
|
||||
90
.gitignore
vendored
90
.gitignore
vendored
@@ -1,88 +1,2 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
/.venv
|
||||
/.pytest_cache
|
||||
/.ruff_cache
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
eggs/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
*.eggs
|
||||
|
||||
# Windows installers
|
||||
*.msi
|
||||
|
||||
# Debian packages
|
||||
*.deb
|
||||
|
||||
# Redhat packages
|
||||
*.rpm
|
||||
|
||||
# MacOS packages
|
||||
*.dmg
|
||||
*.pkg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Pycharm
|
||||
.idea
|
||||
|
||||
# Eclipse
|
||||
.settings
|
||||
|
||||
# Visual Studio cache/options directory
|
||||
.vs/
|
||||
.vscode
|
||||
|
||||
# OSX Files
|
||||
.DS_Store
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Rope
|
||||
.ropeproject
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# Backup files
|
||||
*~
|
||||
*.swp
|
||||
|
||||
# OCA rules
|
||||
!static/lib/
|
||||
*.*~
|
||||
*.pyc
|
||||
|
||||
@@ -22,7 +22,7 @@ exclude: |
|
||||
(LICENSE.*|COPYING.*)
|
||||
default_language_version:
|
||||
python: python3
|
||||
node: "22.9.0"
|
||||
node: "16.17.0"
|
||||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
@@ -38,12 +38,8 @@ repos:
|
||||
entry: found a en.po file
|
||||
language: fail
|
||||
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
|
||||
- repo: https://github.com/sbidoul/whool
|
||||
rev: v1.3
|
||||
hooks:
|
||||
- id: whool-init
|
||||
- repo: https://github.com/oca/maintainer-tools
|
||||
rev: b89f767503be6ab2b11e4f50a7557cb20066e667
|
||||
rev: f9b919b9868143135a9c9cb03021089cabba8223
|
||||
hooks:
|
||||
# update the NOT INSTALLABLE ADDONS section above
|
||||
- id: oca-update-pre-commit-excluded-addons
|
||||
@@ -53,13 +49,16 @@ repos:
|
||||
$(git rev-parse --show-toplevel))"'
|
||||
- id: oca-gen-addon-readme
|
||||
entry:
|
||||
bash -c 'oca-gen-addon-readme --addons-dir=. --branch=$(git symbolic-ref
|
||||
bash -c 'oca-gen-addon-readme
|
||||
--addons-dir=.
|
||||
--branch=$(git symbolic-ref
|
||||
refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")
|
||||
--repo-name=$(basename $(git rev-parse --show-toplevel)) --org-name="Elabore"
|
||||
--if-source-changed --keep-source-digest --convert-fragments-to-markdown'
|
||||
- id: oca-gen-external-dependencies
|
||||
--repo-name=$(basename $(git rev-parse --show-toplevel))
|
||||
--org-name="Elabore"
|
||||
--if-source-changed --keep-source-digest'
|
||||
|
||||
- repo: https://github.com/OCA/odoo-pre-commit-hooks
|
||||
rev: v0.0.33
|
||||
rev: v0.1.4
|
||||
hooks:
|
||||
- id: oca-checks-odoo-module
|
||||
- id: oca-checks-po
|
||||
@@ -78,8 +77,8 @@ repos:
|
||||
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
|
||||
language: node
|
||||
additional_dependencies:
|
||||
- "prettier@3.3.3"
|
||||
- "@prettier/plugin-xml@3.4.1"
|
||||
- "prettier@2.7.1"
|
||||
- "@prettier/plugin-xml@2.2.0"
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: eslint
|
||||
@@ -92,11 +91,10 @@ repos:
|
||||
types: [javascript]
|
||||
language: node
|
||||
additional_dependencies:
|
||||
- "eslint@9.12.0"
|
||||
- "eslint-plugin-jsdoc@50.3.1"
|
||||
- "globals@16.0.0"
|
||||
- "eslint@8.24.0"
|
||||
- "eslint-plugin-jsdoc@"
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.6.0
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
# exclude autogenerated files
|
||||
@@ -117,8 +115,23 @@ repos:
|
||||
- id: check-xml
|
||||
- id: mixed-line-ending
|
||||
args: ["--fix=lf"]
|
||||
- repo: https://github.com/PyCQA/docformatter
|
||||
rev: v1.7.7
|
||||
hooks:
|
||||
- id: docformatter
|
||||
args: [
|
||||
"--in-place", # modify the files
|
||||
"--recursive", # run on all the files
|
||||
"--wrap-summaries",
|
||||
"88", # max length of 1st line
|
||||
"--wrap-descriptions",
|
||||
"88", # max length of other lines
|
||||
"--pre-summary-newline", # new line before a long summary
|
||||
"--make-summary-multi-line", # force summary on multilines
|
||||
]
|
||||
additional_dependencies: ["tomli"] # if Python <3.11
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.6.8
|
||||
rev: v0.12.0
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
||||
73
.pylintrc
73
.pylintrc
@@ -10,7 +10,7 @@ manifest-required-authors=Elabore
|
||||
manifest-required-keys=license
|
||||
manifest-deprecated-keys=description,active
|
||||
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
|
||||
valid-odoo-versions=18.0
|
||||
valid-odoo-versions=16.0
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
disable=all
|
||||
@@ -25,25 +25,19 @@ disable=all
|
||||
enable=anomalous-backslash-in-string,
|
||||
api-one-deprecated,
|
||||
api-one-multi-together,
|
||||
assignment-from-none,
|
||||
attribute-deprecated,
|
||||
class-camelcase,
|
||||
dangerous-default-value,
|
||||
dangerous-view-replace-wo-priority,
|
||||
development-status-allowed,
|
||||
duplicate-id-csv,
|
||||
duplicate-key,
|
||||
duplicate-xml-fields,
|
||||
duplicate-xml-record-id,
|
||||
eval-referenced,
|
||||
incoherent-interpreter-exec-perm,
|
||||
openerp-exception-warning,
|
||||
redundant-modulename-xml,
|
||||
relative-import,
|
||||
rst-syntax-error,
|
||||
wrong-tabs-instead-of-spaces,
|
||||
xml-syntax-error,
|
||||
assignment-from-none,
|
||||
attribute-deprecated,
|
||||
dangerous-default-value,
|
||||
development-status-allowed,
|
||||
duplicate-key,
|
||||
eval-used,
|
||||
incoherent-interpreter-exec-perm,
|
||||
license-allowed,
|
||||
manifest-author-string,
|
||||
manifest-deprecated-key,
|
||||
@@ -54,68 +48,73 @@ enable=anomalous-backslash-in-string,
|
||||
method-inverse,
|
||||
method-required-super,
|
||||
method-search,
|
||||
openerp-exception-warning,
|
||||
pointless-statement,
|
||||
pointless-string-statement,
|
||||
print-used,
|
||||
redundant-keyword-arg,
|
||||
redundant-modulename-xml,
|
||||
reimported,
|
||||
relative-import,
|
||||
return-in-init,
|
||||
rst-syntax-error,
|
||||
sql-injection,
|
||||
too-few-format-args,
|
||||
translation-field,
|
||||
translation-required,
|
||||
unreachable,
|
||||
use-vim-comment,
|
||||
wrong-tabs-instead-of-spaces,
|
||||
xml-syntax-error,
|
||||
attribute-string-redundant,
|
||||
character-not-valid-in-resource-link,
|
||||
consider-merging-classes-inherited,
|
||||
context-overridden,
|
||||
create-user-wo-reset-password,
|
||||
dangerous-filter-wo-user,
|
||||
dangerous-qweb-replace-wo-priority,
|
||||
deprecated-data-xml-node,
|
||||
deprecated-openerp-xml-node,
|
||||
duplicate-po-message-definition,
|
||||
file-not-used,
|
||||
missing-newline-extrafiles,
|
||||
old-api7-method-defined,
|
||||
po-msgstr-variables,
|
||||
po-syntax-error,
|
||||
str-format-used,
|
||||
unnecessary-utf8-coding-comment,
|
||||
xml-attribute-translatable,
|
||||
xml-deprecated-qweb-directive,
|
||||
xml-deprecated-tree-attribute,
|
||||
attribute-string-redundant,
|
||||
consider-merging-classes-inherited,
|
||||
context-overridden,
|
||||
except-pass,
|
||||
file-not-used,
|
||||
invalid-commit,
|
||||
manifest-maintainers-list,
|
||||
missing-newline-extrafiles,
|
||||
missing-readme,
|
||||
missing-return,
|
||||
odoo-addons-relative-import,
|
||||
old-api7-method-defined,
|
||||
po-msgstr-variables,
|
||||
po-syntax-error,
|
||||
renamed-field-parameter,
|
||||
resource-not-exist,
|
||||
str-format-used,
|
||||
test-folder-imported,
|
||||
translation-contains-variable,
|
||||
translation-positional-used,
|
||||
website-manifest-key-not-valid-uri,
|
||||
external-request-timeout,
|
||||
missing-manifest-dependency,
|
||||
too-complex,,
|
||||
create-user-wo-reset-password,
|
||||
dangerous-filter-wo-user,
|
||||
file-not-used,
|
||||
missing-newline-extrafiles,
|
||||
no-utf8-coding-comment,
|
||||
old-api7-method-defined,
|
||||
unnecessary-utf8-coding-comment,
|
||||
website-manifest-key-not-valid-uri,
|
||||
xml-attribute-translatable,
|
||||
xml-deprecated-qweb-directive,
|
||||
xml-deprecated-tree-attribute,
|
||||
external-request-timeout,
|
||||
# messages that do not cause the lint step to fail
|
||||
consider-merging-classes-inherited,
|
||||
create-user-wo-reset-password,
|
||||
dangerous-filter-wo-user,
|
||||
deprecated-module,
|
||||
file-not-used,
|
||||
invalid-commit,
|
||||
missing-manifest-dependency,
|
||||
missing-newline-extrafiles,
|
||||
missing-readme,
|
||||
no-utf8-coding-comment,
|
||||
odoo-addons-relative-import,
|
||||
old-api7-method-defined,
|
||||
redefined-builtin,
|
||||
manifest-external-assets
|
||||
too-complex,
|
||||
unnecessary-utf8-coding-comment
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
@@ -9,7 +9,7 @@ manifest-required-authors=Elabore
|
||||
manifest-required-keys=license
|
||||
manifest-deprecated-keys=description,active
|
||||
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
|
||||
valid-odoo-versions=18.0
|
||||
valid-odoo-versions=16.0
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
disable=all
|
||||
@@ -17,25 +17,19 @@ disable=all
|
||||
enable=anomalous-backslash-in-string,
|
||||
api-one-deprecated,
|
||||
api-one-multi-together,
|
||||
assignment-from-none,
|
||||
attribute-deprecated,
|
||||
class-camelcase,
|
||||
dangerous-default-value,
|
||||
dangerous-view-replace-wo-priority,
|
||||
development-status-allowed,
|
||||
duplicate-id-csv,
|
||||
duplicate-key,
|
||||
duplicate-xml-fields,
|
||||
duplicate-xml-record-id,
|
||||
eval-referenced,
|
||||
incoherent-interpreter-exec-perm,
|
||||
openerp-exception-warning,
|
||||
redundant-modulename-xml,
|
||||
relative-import,
|
||||
rst-syntax-error,
|
||||
wrong-tabs-instead-of-spaces,
|
||||
xml-syntax-error,
|
||||
assignment-from-none,
|
||||
attribute-deprecated,
|
||||
dangerous-default-value,
|
||||
development-status-allowed,
|
||||
duplicate-key,
|
||||
eval-used,
|
||||
incoherent-interpreter-exec-perm,
|
||||
license-allowed,
|
||||
manifest-author-string,
|
||||
manifest-deprecated-key,
|
||||
@@ -46,50 +40,56 @@ enable=anomalous-backslash-in-string,
|
||||
method-inverse,
|
||||
method-required-super,
|
||||
method-search,
|
||||
openerp-exception-warning,
|
||||
pointless-statement,
|
||||
pointless-string-statement,
|
||||
print-used,
|
||||
redundant-keyword-arg,
|
||||
redundant-modulename-xml,
|
||||
reimported,
|
||||
relative-import,
|
||||
return-in-init,
|
||||
rst-syntax-error,
|
||||
sql-injection,
|
||||
too-few-format-args,
|
||||
translation-field,
|
||||
translation-required,
|
||||
unreachable,
|
||||
use-vim-comment,
|
||||
wrong-tabs-instead-of-spaces,
|
||||
xml-syntax-error,
|
||||
attribute-string-redundant,
|
||||
character-not-valid-in-resource-link,
|
||||
consider-merging-classes-inherited,
|
||||
context-overridden,
|
||||
create-user-wo-reset-password,
|
||||
dangerous-filter-wo-user,
|
||||
dangerous-qweb-replace-wo-priority,
|
||||
deprecated-data-xml-node,
|
||||
deprecated-openerp-xml-node,
|
||||
duplicate-po-message-definition,
|
||||
file-not-used,
|
||||
missing-newline-extrafiles,
|
||||
old-api7-method-defined,
|
||||
po-msgstr-variables,
|
||||
po-syntax-error,
|
||||
str-format-used,
|
||||
unnecessary-utf8-coding-comment,
|
||||
xml-attribute-translatable,
|
||||
xml-deprecated-qweb-directive,
|
||||
xml-deprecated-tree-attribute,
|
||||
attribute-string-redundant,
|
||||
consider-merging-classes-inherited,
|
||||
context-overridden,
|
||||
except-pass,
|
||||
file-not-used,
|
||||
invalid-commit,
|
||||
manifest-maintainers-list,
|
||||
missing-newline-extrafiles,
|
||||
missing-readme,
|
||||
missing-return,
|
||||
odoo-addons-relative-import,
|
||||
old-api7-method-defined,
|
||||
po-msgstr-variables,
|
||||
po-syntax-error,
|
||||
renamed-field-parameter,
|
||||
resource-not-exist,
|
||||
str-format-used,
|
||||
test-folder-imported,
|
||||
translation-contains-variable,
|
||||
translation-positional-used,
|
||||
unnecessary-utf8-coding-comment,
|
||||
website-manifest-key-not-valid-uri,
|
||||
xml-attribute-translatable,
|
||||
xml-deprecated-qweb-directive,
|
||||
xml-deprecated-tree-attribute,
|
||||
external-request-timeout
|
||||
|
||||
[REPORTS]
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
var globals = require('globals');
|
||||
jsdoc = require("eslint-plugin-jsdoc");
|
||||
|
||||
const config = [{
|
||||
plugins: {
|
||||
jsdoc,
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
globals: {
|
||||
_: "readonly",
|
||||
$: "readonly",
|
||||
fuzzy: "readonly",
|
||||
jQuery: "readonly",
|
||||
moment: "readonly",
|
||||
odoo: "readonly",
|
||||
openerp: "readonly",
|
||||
owl: "readonly",
|
||||
luxon: "readonly",
|
||||
QUnit: "readonly",
|
||||
...globals.browser,
|
||||
},
|
||||
|
||||
ecmaVersion: 2024,
|
||||
sourceType: "script",
|
||||
},
|
||||
|
||||
rules: {
|
||||
"accessor-pairs": "warn",
|
||||
"array-callback-return": "warn",
|
||||
"callback-return": "warn",
|
||||
"capitalized-comments": ["warn", "always", {
|
||||
ignoreConsecutiveComments: true,
|
||||
ignoreInlineComments: true,
|
||||
}],
|
||||
complexity: ["warn", 15],
|
||||
"constructor-super": "warn",
|
||||
"dot-notation": "warn",
|
||||
eqeqeq: "warn",
|
||||
"global-require": "warn",
|
||||
"handle-callback-err": "warn",
|
||||
"id-blacklist": "warn",
|
||||
"id-match": "warn",
|
||||
"init-declarations": "error",
|
||||
"max-depth": "warn",
|
||||
"max-nested-callbacks": "warn",
|
||||
"max-statements-per-line": "warn",
|
||||
"no-alert": "warn",
|
||||
"no-array-constructor": "warn",
|
||||
"no-caller": "warn",
|
||||
"no-case-declarations": "warn",
|
||||
"no-class-assign": "warn",
|
||||
"no-cond-assign": "error",
|
||||
"no-const-assign": "error",
|
||||
"no-constant-condition": "warn",
|
||||
"no-control-regex": "warn",
|
||||
"no-debugger": "error",
|
||||
"no-delete-var": "warn",
|
||||
"no-div-regex": "warn",
|
||||
"no-dupe-args": "error",
|
||||
"no-dupe-class-members": "error",
|
||||
"no-dupe-keys": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-else-return": "warn",
|
||||
"no-empty-character-class": "warn",
|
||||
"no-empty-function": "error",
|
||||
"no-empty-pattern": "error",
|
||||
"no-empty": "warn",
|
||||
"no-eq-null": "error",
|
||||
"no-eval": "error",
|
||||
"no-ex-assign": "error",
|
||||
"no-extend-native": "warn",
|
||||
"no-extra-bind": "warn",
|
||||
"no-extra-boolean-cast": "warn",
|
||||
"no-extra-label": "warn",
|
||||
"no-fallthrough": "warn",
|
||||
"no-func-assign": "error",
|
||||
"no-global-assign": "error",
|
||||
"no-implicit-coercion": ["warn", {
|
||||
allow: ["~"],
|
||||
}],
|
||||
"no-implicit-globals": "warn",
|
||||
"no-implied-eval": "warn",
|
||||
"no-inline-comments": "warn",
|
||||
"no-inner-declarations": "warn",
|
||||
"no-invalid-regexp": "warn",
|
||||
"no-irregular-whitespace": "warn",
|
||||
"no-iterator": "warn",
|
||||
"no-label-var": "warn",
|
||||
"no-labels": "warn",
|
||||
"no-lone-blocks": "warn",
|
||||
"no-lonely-if": "error",
|
||||
"no-mixed-requires": "error",
|
||||
"no-multi-str": "warn",
|
||||
"no-native-reassign": "error",
|
||||
"no-negated-condition": "warn",
|
||||
"no-negated-in-lhs": "error",
|
||||
"no-new-func": "warn",
|
||||
"no-new-object": "warn",
|
||||
"no-new-require": "warn",
|
||||
"no-new-symbol": "warn",
|
||||
"no-new-wrappers": "warn",
|
||||
"no-new": "warn",
|
||||
"no-obj-calls": "warn",
|
||||
"no-octal-escape": "warn",
|
||||
"no-octal": "warn",
|
||||
"no-param-reassign": "warn",
|
||||
"no-path-concat": "warn",
|
||||
"no-process-env": "warn",
|
||||
"no-process-exit": "warn",
|
||||
"no-proto": "warn",
|
||||
"no-prototype-builtins": "warn",
|
||||
"no-redeclare": "warn",
|
||||
"no-regex-spaces": "warn",
|
||||
"no-restricted-globals": "warn",
|
||||
"no-restricted-imports": "warn",
|
||||
"no-restricted-modules": "warn",
|
||||
"no-restricted-syntax": "warn",
|
||||
"no-return-assign": "error",
|
||||
"no-script-url": "warn",
|
||||
"no-self-assign": "warn",
|
||||
"no-self-compare": "warn",
|
||||
"no-sequences": "warn",
|
||||
"no-shadow-restricted-names": "warn",
|
||||
"no-shadow": "warn",
|
||||
"no-sparse-arrays": "warn",
|
||||
"no-sync": "warn",
|
||||
"no-this-before-super": "warn",
|
||||
"no-throw-literal": "warn",
|
||||
"no-undef-init": "warn",
|
||||
"no-undef": "error",
|
||||
"no-unmodified-loop-condition": "warn",
|
||||
"no-unneeded-ternary": "error",
|
||||
"no-unreachable": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-unused-vars": "error",
|
||||
"no-use-before-define": "error",
|
||||
"no-useless-call": "warn",
|
||||
"no-useless-computed-key": "warn",
|
||||
"no-useless-concat": "warn",
|
||||
"no-useless-constructor": "warn",
|
||||
"no-useless-escape": "warn",
|
||||
"no-useless-rename": "warn",
|
||||
"no-void": "warn",
|
||||
"no-with": "warn",
|
||||
"operator-assignment": ["error", "always"],
|
||||
"prefer-const": "warn",
|
||||
radix: "warn",
|
||||
"require-yield": "warn",
|
||||
"sort-imports": "warn",
|
||||
"spaced-comment": ["error", "always"],
|
||||
strict: ["error", "function"],
|
||||
"use-isnan": "error",
|
||||
|
||||
"jsdoc/check-tag-names": "warn",
|
||||
"jsdoc/check-types": "warn",
|
||||
"jsdoc/require-param-description": "off",
|
||||
"jsdoc/require-return": "off",
|
||||
"jsdoc/require-return-description": "off",
|
||||
"jsdoc/require-return-type": "off",
|
||||
|
||||
"valid-typeof": "warn",
|
||||
yoda: "warn",
|
||||
},
|
||||
|
||||
settings: {
|
||||
jsdoc: {
|
||||
tagNamePreference: {
|
||||
arg: "param",
|
||||
argument: "param",
|
||||
augments: "extends",
|
||||
constructor: "class",
|
||||
exception: "throws",
|
||||
func: "function",
|
||||
method: "function",
|
||||
prop: "property",
|
||||
return: "returns",
|
||||
virtual: "abstract",
|
||||
yield: "yields",
|
||||
},
|
||||
preferredTypes: {
|
||||
array: "Array",
|
||||
bool: "Boolean",
|
||||
boolean: "Boolean",
|
||||
number: "Number",
|
||||
object: "Object",
|
||||
str: "String",
|
||||
string: "String",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
}, {
|
||||
files: ["**/*.esm.js", "**/*test.js"],
|
||||
|
||||
languageOptions: {
|
||||
ecmaVersion: 2024,
|
||||
sourceType: "module",
|
||||
},
|
||||
}];
|
||||
|
||||
module.exports = config
|
||||
@@ -1,14 +0,0 @@
|
||||
/** @type {import('prettier').Config} */
|
||||
|
||||
const config = {
|
||||
// https://github.com/prettier/prettier/issues/15388#issuecomment-1717746872
|
||||
plugins: [require.resolve("@prettier/plugin-xml")],
|
||||
bracketSpacing: false,
|
||||
printWidth: 88,
|
||||
proseWrap: "always",
|
||||
semi: true,
|
||||
trailingComma: "es5",
|
||||
xmlWhitespaceSensitivity: "preserve",
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
@@ -1,42 +0,0 @@
|
||||
# Sale - Disable Product Creation in Sale
|
||||
|
||||
Prevents users from creating new products directly from sale order lines.
|
||||
|
||||
## Description
|
||||
|
||||
By default, Odoo allows users to create new products on-the-fly when filling
|
||||
in sale order lines via the *Product* field. This can lead to duplicate or
|
||||
poorly configured products when the catalog should be managed centrally.
|
||||
|
||||
This module adds the `no_create` option to the `product_template_id` field in
|
||||
the sale order line tree view, so users can only select existing products from
|
||||
the catalog.
|
||||
|
||||
## Usage
|
||||
|
||||
Once installed, the *Create and edit…* and *Create* options are removed from
|
||||
the product dropdown in sale order lines. Users must pick a product that
|
||||
already exists in the product catalog.
|
||||
|
||||
No configuration is required.
|
||||
|
||||
## Installation
|
||||
|
||||
Install via the standard Odoo module installation procedure.
|
||||
|
||||
**Dependencies:** `base`, `sale`
|
||||
|
||||
## Credits
|
||||
|
||||
### Authors
|
||||
|
||||
- [Elabore](https://elabore.coop)
|
||||
|
||||
### Maintainer
|
||||
|
||||
This module is maintained by [Elabore](https://elabore.coop).
|
||||
|
||||
## License
|
||||
|
||||
This module is licensed under **AGPL-3**. See the [LICENSE](LICENSE) file for
|
||||
full details.
|
||||
50
sale_disable_product_creation_in_sale/README.rst
Normal file
50
sale_disable_product_creation_in_sale/README.rst
Normal file
@@ -0,0 +1,50 @@
|
||||
===============
|
||||
sale_usability_misc
|
||||
===============
|
||||
|
||||
Various improves for Sales app
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``sale_usability_misc``.
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
- Allow group sales administores to see date_order field event if not in developper mode
|
||||
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/sale_usability_misc/issues>`_. In case of
|
||||
trouble, please check there if your issue has already been
|
||||
reported. If you spotted it first, help us smashing it by providing a
|
||||
detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* `Elabore <mailto:laetitia.dacosta@elabore.coop>`
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "sale_disable_product_creation_in_sale",
|
||||
"version": "18.0.1.0.0",
|
||||
"version": "16.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://elabore.coop",
|
||||
"maintainer": "Elabore",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='order_line']/list//field[@name='product_template_id']" position="attributes">
|
||||
<xpath expr="//field[@name='order_line']/tree//field[@name='product_template_id']" position="attributes">
|
||||
<attribute name="options">{'no_create': True}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
2
sale_order_invoice_untaxed_amount/.gitignore
vendored
2
sale_order_invoice_untaxed_amount/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
*.*~
|
||||
*pyc
|
||||
@@ -1,65 +0,0 @@
|
||||
# sale_order_invoice_untaxed_amount
|
||||
|
||||
Display the invoiced and uninvoiced untaxed total in the sale order.
|
||||
|
||||
This module adds two stored computed fields on the sale order:
|
||||
|
||||
- **Invoiced Untaxed Amount**: the sum of the untaxed amounts of all
|
||||
non-cancelled invoices linked to the sale order.
|
||||
- **Uninvoiced Untaxed Amount**: the remaining untaxed amount still to be
|
||||
invoiced (`amount_untaxed - invoiced_untaxed_amount`, never negative).
|
||||
|
||||
Both fields are displayed:
|
||||
|
||||
- In the **sale order form**, below the tax totals block.
|
||||
- In the **sale order list view**, as optional columns (hidden by default)
|
||||
with column totals.
|
||||
|
||||
## Installation
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
`sale_order_invoice_untaxed_amount`.
|
||||
|
||||
## Configuration
|
||||
|
||||
This module does not require any configuration.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Open or create a sale order.
|
||||
2. Confirm the order and create one or more invoices from it.
|
||||
3. The **Invoiced Untaxed Amount** and **Uninvoiced Untaxed Amount** are
|
||||
displayed below the totals block of the sale order form.
|
||||
4. In the sale orders list view, enable the optional columns **Invoiced
|
||||
Untaxed Amount** and **Uninvoiced Untaxed Amount** to compare invoiced and
|
||||
remaining untaxed amounts across orders.
|
||||
|
||||
The amounts are recomputed automatically whenever the order state, its
|
||||
invoices, or the invoices state change.
|
||||
|
||||
## Known issues / Roadmap
|
||||
|
||||
None yet.
|
||||
|
||||
## Bug Tracker
|
||||
|
||||
Bugs are tracked on [our issues website](https://github.com/elabore-coop/sale-tools/issues).
|
||||
In case of trouble, please check there if your issue has already been
|
||||
reported. If you spotted it first, help us smashing it by providing a
|
||||
detailed and welcomed feedback.
|
||||
|
||||
## Credits
|
||||
|
||||
### Contributors
|
||||
|
||||
- Stéphan Sainléger
|
||||
|
||||
### Funders
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
- Elabore (https://elabore.coop)
|
||||
|
||||
### Maintainer
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
from . import models
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Copyright 2022 Stéphan Sainléger (Elabore)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "sale_order_invoice_untaxed_amount",
|
||||
"version": "18.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://elabore.coop",
|
||||
"maintainer": "Stéphan Sainléger",
|
||||
"license": "AGPL-3",
|
||||
"category": "Tools",
|
||||
"summary": "Display the invoiced and uninvoiced untaxed total in the sale order",
|
||||
# any module necessary for this one to work correctly
|
||||
"depends": [
|
||||
"account",
|
||||
"sale",
|
||||
],
|
||||
"qweb": [
|
||||
# "static/src/xml/*.xml",
|
||||
],
|
||||
"external_dependencies": {
|
||||
"python": [],
|
||||
},
|
||||
# always loaded
|
||||
"data": [
|
||||
"views/sale_order_view.xml",
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
"demo": [],
|
||||
"js": [],
|
||||
"css": [],
|
||||
"installable": True,
|
||||
# Install this module automatically if all dependency have been previously
|
||||
# and independently installed. Used for synergetic or glue modules.
|
||||
"auto_install": False,
|
||||
"application": False,
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
This directory should contain the *.po for Odoo translation.
|
||||
@@ -1,56 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * sale_order_invoice_untaxed_amount
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-12-02 08:32+0000\n"
|
||||
"PO-Revision-Date: 2022-12-02 08:32+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__display_name
|
||||
msgid "Display Name"
|
||||
msgstr "Nom affiché"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__invoiced_untaxed_amount
|
||||
msgid "Invoiced Untaxed Amount"
|
||||
msgstr "Facturé HT"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model_terms:ir.ui.view,arch_db:sale_order_invoice_untaxed_amount.view_order_tree_invoiced_untaxed_amount
|
||||
msgid "Invoiced Untaxed Total"
|
||||
msgstr "Facturé HT Total"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr "Dernière modification le"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model,name:sale_order_invoice_untaxed_amount.model_sale_order
|
||||
msgid "Sales Order"
|
||||
msgstr "Bon de commande"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__uninvoiced_untaxed_amount
|
||||
msgid "Uninvoiced Untaxed Amount"
|
||||
msgstr "Non-facturé HT"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model_terms:ir.ui.view,arch_db:sale_order_invoice_untaxed_amount.view_order_tree_invoiced_untaxed_amount
|
||||
msgid "Uninvoiced Untaxed Total"
|
||||
msgstr "Non-facturé HT Total"
|
||||
@@ -1,56 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * sale_order_invoice_untaxed_amount
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-12-02 08:33+0000\n"
|
||||
"PO-Revision-Date: 2022-12-02 08:33+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__invoiced_untaxed_amount
|
||||
msgid "Invoiced Untaxed Amount"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model_terms:ir.ui.view,arch_db:sale_order_invoice_untaxed_amount.view_order_tree_invoiced_untaxed_amount
|
||||
msgid "Invoiced Untaxed Total"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model,name:sale_order_invoice_untaxed_amount.model_sale_order
|
||||
msgid "Sales Order"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model:ir.model.fields,field_description:sale_order_invoice_untaxed_amount.field_sale_order__uninvoiced_untaxed_amount
|
||||
msgid "Uninvoiced Untaxed Amount"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_order_invoice_untaxed_amount
|
||||
#: model_terms:ir.ui.view,arch_db:sale_order_invoice_untaxed_amount.view_order_tree_invoiced_untaxed_amount
|
||||
msgid "Uninvoiced Untaxed Total"
|
||||
msgstr ""
|
||||
@@ -1 +0,0 @@
|
||||
from . import sale_order
|
||||
@@ -1,43 +0,0 @@
|
||||
# Copyright (C) 2021 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
|
||||
_inherit = "sale.order"
|
||||
|
||||
invoiced_untaxed_amount = fields.Monetary(
|
||||
string="Invoiced Untaxed Amount",
|
||||
compute="_compute_invoice_untaxed_amount",
|
||||
store=True,
|
||||
)
|
||||
|
||||
uninvoiced_untaxed_amount = fields.Monetary(
|
||||
string="Uninvoiced Untaxed Amount",
|
||||
compute="_compute_invoice_untaxed_amount",
|
||||
store=True,
|
||||
)
|
||||
|
||||
@api.depends(
|
||||
"state",
|
||||
"invoice_ids",
|
||||
"invoice_ids.amount_untaxed_signed",
|
||||
"amount_total",
|
||||
"invoice_ids.state",
|
||||
)
|
||||
def _compute_invoice_untaxed_amount(self):
|
||||
for rec in self:
|
||||
if rec.state != "cancel" and rec.invoice_ids:
|
||||
rec.invoiced_untaxed_amount = 0.0
|
||||
for invoice in rec.invoice_ids:
|
||||
if invoice.state != "cancel":
|
||||
rec.invoiced_untaxed_amount += invoice.amount_untaxed_signed
|
||||
rec.uninvoiced_untaxed_amount = max(0, rec.amount_untaxed - rec.invoiced_untaxed_amount)
|
||||
else:
|
||||
rec.invoiced_untaxed_amount = 0.0
|
||||
if rec.state in ["draft", "sent", "cancel"]:
|
||||
rec.uninvoiced_untaxed_amount = 0.0
|
||||
else:
|
||||
rec.uninvoiced_untaxed_amount = rec.amount_untaxed
|
||||
@@ -1 +0,0 @@
|
||||
from . import test_sale_order_invoice_untaxed_amount
|
||||
@@ -1,134 +0,0 @@
|
||||
# Copyright (C) 2021 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestSaleOrderInvoiceUntaxedAmount(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
# Partners
|
||||
cls.res_partner_1 = cls.env["res.partner"].create({"name": "Wood Corner"})
|
||||
|
||||
# Products
|
||||
cls.product_1 = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Desk Combination",
|
||||
"type": "consu",
|
||||
"invoice_policy": "order",
|
||||
}
|
||||
)
|
||||
cls.product_2 = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Conference Chair",
|
||||
"type": "consu",
|
||||
"invoice_policy": "order",
|
||||
}
|
||||
)
|
||||
cls.product_3 = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Repair Services",
|
||||
"type": "service",
|
||||
"invoice_policy": "order",
|
||||
}
|
||||
)
|
||||
|
||||
# Sale Order
|
||||
cls.tax = cls.env["account.tax"].create(
|
||||
{"name": "Tax 21", "type_tax_use": "sale", "amount": 21}
|
||||
)
|
||||
cls.sale_order_1 = cls.env["sale.order"].create(
|
||||
{"partner_id": cls.res_partner_1.id}
|
||||
)
|
||||
cls.order_line_1 = cls.env["sale.order.line"].create(
|
||||
{
|
||||
"order_id": cls.sale_order_1.id,
|
||||
"product_id": cls.product_1.id,
|
||||
"product_uom": cls.product_1.uom_id.id,
|
||||
"product_uom_qty": 10.0,
|
||||
"price_unit": 10.0,
|
||||
"tax_id": [(6, 0, cls.tax.ids)],
|
||||
}
|
||||
)
|
||||
cls.order_line_2 = cls.env["sale.order.line"].create(
|
||||
{
|
||||
"order_id": cls.sale_order_1.id,
|
||||
"product_id": cls.product_2.id,
|
||||
"product_uom": cls.product_2.uom_id.id,
|
||||
"product_uom_qty": 25.0,
|
||||
"price_unit": 4.0,
|
||||
"tax_id": [(6, 0, cls.tax.ids)],
|
||||
}
|
||||
)
|
||||
cls.order_line_3 = cls.env["sale.order.line"].create(
|
||||
{
|
||||
"order_id": cls.sale_order_1.id,
|
||||
"product_id": cls.product_3.id,
|
||||
"product_uom": cls.product_3.uom_id.id,
|
||||
"product_uom_qty": 20.0,
|
||||
"price_unit": 5.0,
|
||||
"tax_id": [(6, 0, cls.tax.ids)],
|
||||
}
|
||||
)
|
||||
# Total untaxed amount: 10*10 + 25*4 + 20*5 = 100 + 100 + 100 = 300
|
||||
|
||||
def test_untaxed_amount_without_invoice(self):
|
||||
"""No invoice yet: nothing invoiced, everything uninvoiced."""
|
||||
self.assertEqual(self.sale_order_1.amount_untaxed, 300.0)
|
||||
self.assertEqual(
|
||||
self.sale_order_1.invoiced_untaxed_amount,
|
||||
0.0,
|
||||
"Invoiced Untaxed Amount should be 0.0 without invoice",
|
||||
)
|
||||
# Order still in draft: uninvoiced amount is forced to 0.0
|
||||
self.assertEqual(
|
||||
self.sale_order_1.uninvoiced_untaxed_amount,
|
||||
0.0,
|
||||
"Uninvoiced Untaxed Amount should be 0.0 while in draft",
|
||||
)
|
||||
|
||||
def test_untaxed_amount_with_down_payment(self):
|
||||
"""A fixed down payment of 100 is invoiced."""
|
||||
context_payment = {
|
||||
"active_ids": [self.sale_order_1.id],
|
||||
"active_id": self.sale_order_1.id,
|
||||
}
|
||||
payment = (
|
||||
self.env["sale.advance.payment.inv"]
|
||||
.with_context(context_payment)
|
||||
.create({"advance_payment_method": "fixed", "fixed_amount": 100})
|
||||
)
|
||||
payment.create_invoices()
|
||||
|
||||
# The fixed down payment (100) is a tax-included amount.
|
||||
# With a 21% tax, the invoiced untaxed amount is 100 / 1.21 = 82.64.
|
||||
self.assertAlmostEqual(
|
||||
self.sale_order_1.invoiced_untaxed_amount,
|
||||
82.64,
|
||||
places=2,
|
||||
msg="Invoiced Untaxed Amount should be 82.64 (100 tax included / 1.21)",
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
self.sale_order_1.uninvoiced_untaxed_amount,
|
||||
217.36,
|
||||
places=2,
|
||||
msg="Uninvoiced Untaxed Amount should be 217.36 (300 - 82.64)",
|
||||
)
|
||||
|
||||
def test_untaxed_amount_fully_invoiced(self):
|
||||
"""The whole order is invoiced: nothing remains uninvoiced."""
|
||||
self.sale_order_1.action_confirm()
|
||||
self.sale_order_1._create_invoices(final=True)
|
||||
|
||||
self.assertEqual(
|
||||
self.sale_order_1.invoiced_untaxed_amount,
|
||||
300.0,
|
||||
"Invoiced Untaxed Amount should equal the full untaxed total",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.sale_order_1.uninvoiced_untaxed_amount,
|
||||
0.0,
|
||||
"Uninvoiced Untaxed Amount should be 0 once fully invoiced",
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="view_order_form_invoiced_untaxed_amount" model="ir.ui.view">
|
||||
<field name="name">sale.order.form.invoiced.untaxed.amount</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<group name="sale_total" position="after">
|
||||
<group name="invoiced_untaxed" class="oe_subtotal_footer order-2 order-lg-2" colspan="2">
|
||||
<field name="invoiced_untaxed_amount" />
|
||||
<field name="uninvoiced_untaxed_amount" />
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_order_tree_invoiced_untaxed_amount" model="ir.ui.view">
|
||||
<field name="name">sale.order.list.invoiced.untaxed.amount</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='amount_tax']" position="after">
|
||||
<field name="invoiced_untaxed_amount" sum="Invoiced Untaxed Total" optional="hide" />
|
||||
<field
|
||||
name="uninvoiced_untaxed_amount"
|
||||
sum="Uninvoiced Untaxed Total"
|
||||
optional="hide"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
2
sale_outstanding/.gitignore
vendored
2
sale_outstanding/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
*.*~
|
||||
*pyc
|
||||
@@ -1,110 +0,0 @@
|
||||
# Sale Outstanding
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
This module computes and displays two financial indicators on sale orders:
|
||||
|
||||
- **Outstanding (Untaxed)**: total amount of order lines that have been delivered but not yet invoiced.
|
||||
- **To Do (Untaxed)**: total amount of order lines that have not yet been fully delivered
|
||||
(excluding services billed on order with the `ordered_timesheet` policy).
|
||||
|
||||
Both values are visible directly on the sale order form and in the list view
|
||||
(columns hidden by default, toggleable via the column selector).
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Description](#description)
|
||||
- [Installation](#installation)
|
||||
- [Configuration](#configuration)
|
||||
- [Usage](#usage)
|
||||
- [Known Issues / Roadmap](#known-issues--roadmap)
|
||||
- [Bug Tracker](#bug-tracker)
|
||||
- [Credits](#credits)
|
||||
|
||||
## Description
|
||||
|
||||
This module extends the `sale.order` model with two computed, stored monetary fields.
|
||||
|
||||
### `sum_outstanding` — Outstanding (Untaxed)
|
||||
|
||||
Computed as the sum across all order lines of:
|
||||
|
||||
```
|
||||
qty_to_invoice × price_unit
|
||||
```
|
||||
|
||||
This amount represents what has been delivered to the customer but not yet invoiced.
|
||||
|
||||
### `sum_pending_work` — To Do (Untaxed)
|
||||
|
||||
Computed as the sum across all order lines of:
|
||||
|
||||
```
|
||||
(ordered_qty − delivered_qty) × price_unit
|
||||
```
|
||||
|
||||
Services whose invoicing policy is `ordered_timesheet` are excluded from this calculation,
|
||||
as they are invoiced upon order confirmation rather than upon delivery.
|
||||
|
||||
This amount represents work that still needs to be delivered and has not yet been invoiced.
|
||||
|
||||
### Display
|
||||
|
||||
- **Form view**: both fields appear in an `oe_subtotal_footer` group placed after the order
|
||||
totals block.
|
||||
- **List view**: both columns are added after `amount_tax`, hidden by default, with column
|
||||
footer totals.
|
||||
|
||||
## Installation
|
||||
|
||||
This module depends on:
|
||||
|
||||
- `base` (Odoo core)
|
||||
- `sale` (Odoo core)
|
||||
|
||||
Use the standard Odoo module installation procedure to install `sale_outstanding`.
|
||||
|
||||
## Configuration
|
||||
|
||||
No specific configuration is required. The fields are computed automatically.
|
||||
|
||||
To display the columns in the sale order list view, click the column selector icon
|
||||
(top-right corner of the list) and enable **Outstanding (Untaxed)** and/or **To Do (Untaxed)**.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Open a confirmed sale order for which deliveries have been (partially or fully) completed.
|
||||
2. The **Outstanding (Untaxed)** field shows the amount delivered but not yet invoiced.
|
||||
3. The **To Do (Untaxed)** field shows the amount of work not yet delivered.
|
||||
4. In the sale order list view, enable the optional columns for a global overview of outstanding amounts.
|
||||
|
||||
## Known Issues / Roadmap
|
||||
|
||||
- Amounts are computed excluding taxes. A possible improvement would be to add tax-included variants.
|
||||
- The filter on `service_policy == 'ordered_timesheet'` is hard-coded; a configurable setting
|
||||
would allow more flexibility.
|
||||
|
||||
## Bug Tracker
|
||||
|
||||
Bugs are tracked on [our issue tracker](https://github.com/elabore-coop/sale-tools/issues).
|
||||
If you encounter a problem, please check whether your issue has already been reported.
|
||||
If you are the first to spot it, help us by providing detailed and actionable feedback.
|
||||
|
||||
## Credits
|
||||
|
||||
### Contributors
|
||||
|
||||
- Stéphan Sainléger \<stephan@sainleger.fr\>
|
||||
|
||||
### Funders
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
- [Elabore](https://elabore.coop)
|
||||
- [Datactivist](https://datactivist.coop)
|
||||
|
||||
### Maintainer
|
||||
|
||||
This module is maintained by [Elabore](https://elabore.coop).
|
||||
@@ -1 +0,0 @@
|
||||
from . import models
|
||||
@@ -1,62 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * sale_outstanding
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-11-24 18:04+0000\n"
|
||||
"PO-Revision-Date: 2022-11-24 18:04+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__display_name
|
||||
msgid "Display Name"
|
||||
msgstr "Nom affiché"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr "Dernière modification le"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding
|
||||
msgid "Outstanding Total"
|
||||
msgstr "Total en cours HT"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: code:addons/sale_outstanding/models/sale.py:0
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_outstanding
|
||||
#, python-format
|
||||
msgid "Outstanding Untaxed"
|
||||
msgstr "En cours HT"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding
|
||||
msgid "Pending work Total"
|
||||
msgstr "Total Reste à produire HT"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model,name:sale_outstanding.model_sale_order
|
||||
msgid "Sales Order"
|
||||
msgstr "Bon de commande"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: code:addons/sale_outstanding/models/sale.py:0
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_pending_work
|
||||
#, python-format
|
||||
msgid "To Do Untaxed"
|
||||
msgstr "Reste à produire HT"
|
||||
@@ -1,62 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * sale_outstanding
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-11-24 18:02+0000\n"
|
||||
"PO-Revision-Date: 2022-11-24 18:02+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__display_name
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding
|
||||
msgid "Outstanding Total"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: code:addons/sale_outstanding/models/sale.py:0
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_outstanding
|
||||
#, python-format
|
||||
msgid "Outstanding Untaxed"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding
|
||||
#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding
|
||||
msgid "Pending work Total"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: model:ir.model,name:sale_outstanding.model_sale_order
|
||||
msgid "Sales Order"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale_outstanding
|
||||
#: code:addons/sale_outstanding/models/sale.py:0
|
||||
#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_pending_work
|
||||
#, python-format
|
||||
msgid "To Do Untaxed"
|
||||
msgstr ""
|
||||
@@ -1 +0,0 @@
|
||||
from . import sale
|
||||
@@ -1,29 +0,0 @@
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
@api.depends("order_line.qty_delivered", "order_line.qty_invoiced", "order_line.qty_to_invoice", "order_line.price_unit")
|
||||
def _compute_sum_outstanding(self):
|
||||
for order in self:
|
||||
lines_outstanding = order.order_line.mapped(lambda r:(r.qty_to_invoice * r.price_unit))
|
||||
order["sum_outstanding"] = sum(lines_outstanding)
|
||||
|
||||
@api.depends("order_line.qty_delivered", "order_line.product_uom_qty", "order_line.price_unit")
|
||||
def _compute_sum_pending_work(self):
|
||||
for order in self:
|
||||
lines_pending_work = order.order_line.mapped(
|
||||
lambda r: (
|
||||
(r.product_uom_qty - r.qty_delivered) * r.price_unit
|
||||
if not r.product_id
|
||||
or "service_policy" not in r.product_id.product_tmpl_id._fields
|
||||
or r.product_id.product_tmpl_id.service_policy != "ordered_prepaid"
|
||||
else 0
|
||||
)
|
||||
)
|
||||
order["sum_pending_work"] = sum(lines_pending_work)
|
||||
|
||||
|
||||
sum_outstanding = fields.Monetary(_("Outstanding Untaxed"), readonly=True, store=True, compute="_compute_sum_outstanding")
|
||||
sum_pending_work = fields.Monetary(_("To Do Untaxed"), readonly=True, store=True, compute="_compute_sum_pending_work")
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# Copyright 2025 Stéphan Sainléger (Elabore)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_sale_outstanding
|
||||
@@ -1,248 +0,0 @@
|
||||
# Copyright 2025 Stéphan Sainléger (Elabore)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.fields import Command
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
@tagged("post_install", "-at_install")
|
||||
class TestSaleOutstanding(TransactionCase):
|
||||
"""Tests for sum_outstanding and sum_pending_work computed fields."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||
|
||||
cls.partner = cls.env["res.partner"].create({"name": "Test Customer"})
|
||||
|
||||
# Storable product — delivered on shipping (delivery policy)
|
||||
cls.product_storable = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Storable Product",
|
||||
"type": "consu",
|
||||
"list_price": 100.0,
|
||||
"invoice_policy": "delivery",
|
||||
"taxes_id": [],
|
||||
}
|
||||
)
|
||||
|
||||
# Service product — invoiced on delivery (timesheet / manual delivery)
|
||||
cls.product_service = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Service Product",
|
||||
"type": "service",
|
||||
"list_price": 50.0,
|
||||
"invoice_policy": "delivery",
|
||||
"service_policy": "delivered_timesheet",
|
||||
"taxes_id": [],
|
||||
}
|
||||
)
|
||||
|
||||
# Service product with ordered_prepaid policy — must be excluded from pending work.
|
||||
# service_policy is a computed field on product.template derived from
|
||||
# invoice_policy + service_type. 'ordered_prepaid' = invoice_policy='order' +
|
||||
# service_type='timesheet' (requires sale_project/sale_timesheet).
|
||||
# We set the policy directly on the template when the field exists.
|
||||
cls.product_service_ordered = cls.env["product.product"].create(
|
||||
{
|
||||
"name": "Service Ordered Prepaid",
|
||||
"type": "service",
|
||||
"list_price": 80.0,
|
||||
"invoice_policy": "order",
|
||||
"service_type": "timesheet",
|
||||
"taxes_id": [],
|
||||
}
|
||||
)
|
||||
# Force service_policy to 'ordered_prepaid' if the field is available
|
||||
# (provided by sale_project / sale_timesheet).
|
||||
if "service_policy" in cls.env["product.template"]._fields:
|
||||
cls.product_service_ordered.product_tmpl_id.service_policy = "ordered_prepaid"
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def _make_order(self, lines):
|
||||
"""Create and confirm a sale order with the given line specs.
|
||||
|
||||
Each entry in *lines* is a dict with keys: product, qty, price_unit.
|
||||
Returns the confirmed sale.order record.
|
||||
"""
|
||||
order = self.env["sale.order"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"order_line": [
|
||||
Command.create(
|
||||
{
|
||||
"product_id": spec["product"].id,
|
||||
"product_uom_qty": spec["qty"],
|
||||
"price_unit": spec["price_unit"],
|
||||
}
|
||||
)
|
||||
for spec in lines
|
||||
],
|
||||
}
|
||||
)
|
||||
order.action_confirm()
|
||||
return order
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# sum_outstanding
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def test_outstanding_zero_before_delivery(self):
|
||||
"""sum_outstanding is 0 when nothing has been delivered yet."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 5.0, "price_unit": 100.0}]
|
||||
)
|
||||
self.assertEqual(
|
||||
order.sum_outstanding,
|
||||
0.0,
|
||||
"No delivery done yet — outstanding should be 0.",
|
||||
)
|
||||
|
||||
def test_outstanding_after_partial_delivery(self):
|
||||
"""sum_outstanding equals delivered-but-not-invoiced amount after partial delivery."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 10.0, "price_unit": 100.0}]
|
||||
)
|
||||
line = order.order_line
|
||||
# Simulate partial delivery: 4 units delivered
|
||||
line.qty_delivered = 4.0
|
||||
# qty_to_invoice == qty_delivered - qty_invoiced == 4 - 0 == 4
|
||||
self.assertAlmostEqual(order.sum_outstanding, 4.0 * 100.0)
|
||||
|
||||
def test_outstanding_after_full_delivery(self):
|
||||
"""sum_outstanding equals full order amount when all is delivered but not invoiced."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 5.0, "price_unit": 200.0}]
|
||||
)
|
||||
order.order_line.qty_delivered = 5.0
|
||||
self.assertAlmostEqual(order.sum_outstanding, 5.0 * 200.0)
|
||||
|
||||
def test_outstanding_zero_after_invoice(self):
|
||||
"""sum_outstanding drops to 0 once the delivered qty has been fully invoiced."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 3.0, "price_unit": 100.0}]
|
||||
)
|
||||
line = order.order_line
|
||||
line.qty_delivered = 3.0
|
||||
# Simulate invoicing by setting qty_invoiced directly (bypass actual invoice flow)
|
||||
line.qty_invoiced = 3.0
|
||||
# qty_to_invoice = max(0, qty_delivered - qty_invoiced) = 0
|
||||
self.assertAlmostEqual(order.sum_outstanding, 0.0)
|
||||
|
||||
def test_outstanding_multi_line(self):
|
||||
"""sum_outstanding sums across all lines correctly."""
|
||||
order = self._make_order(
|
||||
[
|
||||
{"product": self.product_storable, "qty": 2.0, "price_unit": 100.0},
|
||||
{"product": self.product_service, "qty": 3.0, "price_unit": 50.0},
|
||||
]
|
||||
)
|
||||
lines = order.order_line
|
||||
lines[0].qty_delivered = 2.0 # outstanding: 2 × 100 = 200
|
||||
lines[1].qty_delivered = 1.0 # outstanding: 1 × 50 = 50
|
||||
self.assertAlmostEqual(order.sum_outstanding, 200.0 + 50.0)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# sum_pending_work
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def test_pending_work_equals_full_qty_before_delivery(self):
|
||||
"""sum_pending_work equals full order amount when nothing has been delivered."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 5.0, "price_unit": 100.0}]
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
order.sum_pending_work,
|
||||
5.0 * 100.0,
|
||||
msg="No delivery done — pending work should equal full order amount.",
|
||||
)
|
||||
|
||||
def test_pending_work_decreases_with_delivery(self):
|
||||
"""sum_pending_work decreases as deliveries are recorded."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 10.0, "price_unit": 100.0}]
|
||||
)
|
||||
order.order_line.qty_delivered = 7.0
|
||||
# Remaining: (10 - 7) × 100 = 300
|
||||
self.assertAlmostEqual(order.sum_pending_work, 3.0 * 100.0)
|
||||
|
||||
def test_pending_work_zero_after_full_delivery(self):
|
||||
"""sum_pending_work is 0 once everything has been delivered."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 5.0, "price_unit": 100.0}]
|
||||
)
|
||||
order.order_line.qty_delivered = 5.0
|
||||
self.assertAlmostEqual(order.sum_pending_work, 0.0)
|
||||
|
||||
def test_pending_work_excludes_ordered_prepaid_service(self):
|
||||
"""Products with service_policy='ordered_prepaid' are excluded from pending work."""
|
||||
if "service_policy" not in self.env["product.template"]._fields:
|
||||
self.skipTest("service_policy field not available (sale_project not installed)")
|
||||
order = self._make_order(
|
||||
[
|
||||
{"product": self.product_storable, "qty": 2.0, "price_unit": 100.0},
|
||||
# This line must be ignored in the pending work computation
|
||||
{
|
||||
"product": self.product_service_ordered,
|
||||
"qty": 5.0,
|
||||
"price_unit": 80.0,
|
||||
},
|
||||
]
|
||||
)
|
||||
# Only the storable product counts: 2 × 100 = 200
|
||||
self.assertAlmostEqual(
|
||||
order.sum_pending_work,
|
||||
2.0 * 100.0,
|
||||
msg=(
|
||||
"ordered_prepaid service should be excluded; "
|
||||
"only storable product pending work should be counted."
|
||||
),
|
||||
)
|
||||
|
||||
def test_pending_work_includes_non_ordered_prepaid_service(self):
|
||||
"""Services with a delivery-based policy ARE included in pending work."""
|
||||
order = self._make_order(
|
||||
[
|
||||
{"product": self.product_storable, "qty": 2.0, "price_unit": 100.0},
|
||||
{"product": self.product_service, "qty": 4.0, "price_unit": 50.0},
|
||||
]
|
||||
)
|
||||
# Both lines count: 2×100 + 4×50 = 400
|
||||
self.assertAlmostEqual(order.sum_pending_work, 200.0 + 200.0)
|
||||
|
||||
def test_pending_work_multi_line_partial_delivery(self):
|
||||
"""sum_pending_work aggregates remaining work across multiple partially delivered lines."""
|
||||
order = self._make_order(
|
||||
[
|
||||
{"product": self.product_storable, "qty": 10.0, "price_unit": 100.0},
|
||||
{"product": self.product_service, "qty": 8.0, "price_unit": 50.0},
|
||||
]
|
||||
)
|
||||
lines = order.order_line
|
||||
lines[0].qty_delivered = 6.0 # remaining: (10-6) × 100 = 400
|
||||
lines[1].qty_delivered = 2.0 # remaining: (8-2) × 50 = 300
|
||||
self.assertAlmostEqual(order.sum_pending_work, 400.0 + 300.0)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Edge cases
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def test_empty_order_both_fields_zero(self):
|
||||
"""Both fields are 0 on an order with no lines."""
|
||||
order = self.env["sale.order"].create({"partner_id": self.partner.id})
|
||||
self.assertEqual(order.sum_outstanding, 0.0)
|
||||
self.assertEqual(order.sum_pending_work, 0.0)
|
||||
|
||||
def test_recompute_on_qty_change(self):
|
||||
"""Fields recompute correctly when ordered quantity is updated."""
|
||||
order = self._make_order(
|
||||
[{"product": self.product_storable, "qty": 5.0, "price_unit": 100.0}]
|
||||
)
|
||||
self.assertAlmostEqual(order.sum_pending_work, 5.0 * 100.0)
|
||||
order.order_line.product_uom_qty = 8.0
|
||||
self.assertAlmostEqual(order.sum_pending_work, 8.0 * 100.0)
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="view_order_form_inherit_outstanding" model="ir.ui.view">
|
||||
<field name="name">sale.order.view.form.inherit</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<group name="sale_total" position="after">
|
||||
<group name="outstanding" class="oe_subtotal_footer">
|
||||
<field name="sum_outstanding" />
|
||||
<field name="sum_pending_work" />
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_order_tree_inherit_outstanding" model="ir.ui.view">
|
||||
<field name="name">sale.order.list.outstanding</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.sale_order_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='amount_tax']" position="after">
|
||||
<field name="sum_outstanding" sum="Outstanding Total" optional="hide" />
|
||||
<field name="sum_pending_work" sum="Pending work Total" optional="hide" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
1
sale_restricted_qty_website_sale/__init__.py
Normal file
1
sale_restricted_qty_website_sale/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
@@ -1,33 +1,35 @@
|
||||
# Copyright 2022 Stéphan Sainléger (Elabore)
|
||||
# Copyright 2026 Elabore ()
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "sale_outstanding",
|
||||
"version": "18.0.1.0.0",
|
||||
"name": "sale_restricted_qty_website_sale",
|
||||
"version": "16.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://elabore.coop",
|
||||
"maintainer": "Stéphan Sainléger",
|
||||
"maintainer": "Elabore",
|
||||
"license": "AGPL-3",
|
||||
"category": "Tools",
|
||||
"summary": "Calculates and displays the sale order outstanding and pending work.",
|
||||
"category": "Sales",
|
||||
"summary": "Improve UX handling on e-commerce product page",
|
||||
# any module necessary for this one to work correctly
|
||||
"depends": [
|
||||
"base",
|
||||
"sale",
|
||||
"sale_restricted_qty","website_sale",
|
||||
],
|
||||
"qweb": [],
|
||||
"external_dependencies": {
|
||||
"python": [],
|
||||
},
|
||||
# always loaded
|
||||
"data": [
|
||||
"views/sale_views.xml",
|
||||
"views/restricted_qty_website_sale_view.xml"
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
"demo": [],
|
||||
"test": ["tests/test_sale_outstanding.py"],
|
||||
"assets": {
|
||||
"web.assets_frontend": [
|
||||
"sale_restricted_qty_website_sale/static/src/js/add_to_cart.js",
|
||||
],
|
||||
},
|
||||
"installable": True,
|
||||
# Install this module automatically if all dependency have been previously
|
||||
# and independently installed. Used for synergetic or glue modules.
|
||||
"auto_install": False,
|
||||
"auto_install": True,
|
||||
"application": False,
|
||||
}
|
||||
80
sale_restricted_qty_website_sale/i18n/fr.po
Normal file
80
sale_restricted_qty_website_sale/i18n/fr.po
Normal file
@@ -0,0 +1,80 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * elabore_website_sale_restricted_qty
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2026-08-18 00:00+0000\n"
|
||||
"Last-Translator: Élabore <https://elabore.coop>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#. odoo-python
|
||||
#: code:addons/elabore_website_sale_restricted_qty/models/sale_order_line.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The selected quantity is not available for sale:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"
|
||||
"Please adjust the quantity."
|
||||
msgstr ""
|
||||
"La quantité choisie n'est pas disponible à la vente :\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"
|
||||
"Merci d'ajuster la quantité."
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#. odoo-python
|
||||
#: code:addons/elabore_website_sale_restricted_qty/models/sale_order_line.py:0
|
||||
#, python-format
|
||||
msgid "%(product)s: minimum order quantity is %(qty)s."
|
||||
msgstr "%(product)s : quantité minimum de commande %(qty)s."
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#. odoo-python
|
||||
#: code:addons/elabore_website_sale_restricted_qty/models/sale_order_line.py:0
|
||||
#, python-format
|
||||
msgid "%(product)s: maximum order quantity is %(qty)s."
|
||||
msgstr "%(product)s : quantité maximum de commande %(qty)s."
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#. odoo-python
|
||||
#: code:addons/elabore_website_sale_restricted_qty/models/sale_order_line.py:0
|
||||
#, python-format
|
||||
msgid "%(product)s: must be ordered in multiples of %(qty)s."
|
||||
msgstr "%(product)s : à commander par multiples de %(qty)s."
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#. odoo-python
|
||||
#: code:addons/elabore_website_sale_restricted_qty/models/product_restricted_qty_mixin.py:0
|
||||
#, python-format
|
||||
msgid "minimum order: %(qty)s %(uom)s"
|
||||
msgstr "commande minimum : %(qty)s %(uom)s"
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#. odoo-python
|
||||
#: code:addons/elabore_website_sale_restricted_qty/models/product_restricted_qty_mixin.py:0
|
||||
#, python-format
|
||||
msgid "in multiples of %(qty)s %(uom)s"
|
||||
msgstr "par multiples de %(qty)s %(uom)s"
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#. odoo-python
|
||||
#: code:addons/elabore_website_sale_restricted_qty/models/product_restricted_qty_mixin.py:0
|
||||
#, python-format
|
||||
msgid "maximum: %(qty)s %(uom)s"
|
||||
msgstr "maximum : %(qty)s %(uom)s"
|
||||
|
||||
#. module: elabore_website_sale_restricted_qty
|
||||
#: model:ir.ui.view,name:elabore_website_sale_restricted_qty.product_restricted_qty_info
|
||||
msgid "Restricted Quantity Information"
|
||||
msgstr "Information sur les quantités restreintes"
|
||||
2
sale_restricted_qty_website_sale/models/__init__.py
Normal file
2
sale_restricted_qty_website_sale/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import product_restricted_qty_mixin
|
||||
from . import sale_order_line
|
||||
@@ -0,0 +1,59 @@
|
||||
# Copyright 2026 Élabore (https://elabore.coop)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, models
|
||||
from odoo.tools import float_is_zero
|
||||
from odoo.tools.misc import formatLang
|
||||
|
||||
|
||||
class ProductRestrictedQtyMixin(models.AbstractModel):
|
||||
"""Extending the OCA abstract mixin makes these helpers available at once
|
||||
on product.product, product.template and product.category."""
|
||||
|
||||
_inherit = "product.restricted.qty.mixin"
|
||||
|
||||
def _format_restricted_qty(self, qty):
|
||||
"""Short form: 6 rather than 6.0, and a locale-aware separator
|
||||
for decimals."""
|
||||
if float_is_zero(qty - int(qty), precision_digits=3):
|
||||
return str(int(qty))
|
||||
return formatLang(self.env, qty)
|
||||
|
||||
def _get_restricted_qty_hint(self):
|
||||
"""Sentence shown to the customer. Empty when nothing restricts him.
|
||||
|
||||
OCA semantics: `force_sale_min_qty` / `force_sale_max_qty` set to Yes
|
||||
make the bound purely indicative -- the constraint does not block, so
|
||||
we announce nothing rather than promising a rule that does not exist.
|
||||
"""
|
||||
self.ensure_one()
|
||||
uom = self.uom_id.name if "uom_id" in self._fields else ""
|
||||
parts = []
|
||||
if self.sale_min_qty and not self.force_sale_min_qty:
|
||||
parts.append(
|
||||
_(
|
||||
"minimum order: %(qty)s %(uom)s",
|
||||
qty=self._format_restricted_qty(self.sale_min_qty),
|
||||
uom=uom,
|
||||
)
|
||||
)
|
||||
if self.sale_multiple_qty:
|
||||
parts.append(
|
||||
_(
|
||||
"in multiples of %(qty)s %(uom)s",
|
||||
qty=self._format_restricted_qty(self.sale_multiple_qty),
|
||||
uom=uom,
|
||||
)
|
||||
)
|
||||
if self.sale_max_qty and not self.force_sale_max_qty:
|
||||
parts.append(
|
||||
_(
|
||||
"maximum: %(qty)s %(uom)s",
|
||||
qty=self._format_restricted_qty(self.sale_max_qty),
|
||||
uom=uom,
|
||||
)
|
||||
)
|
||||
if not parts:
|
||||
return ""
|
||||
hint = " · ".join(parts)
|
||||
return hint[0].upper() + hint[1:]
|
||||
62
sale_restricted_qty_website_sale/models/sale_order_line.py
Normal file
62
sale_restricted_qty_website_sale/models/sale_order_line.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from odoo import _, api, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
@api.constrains(
|
||||
"product_uom_qty", "sale_min_qty", "sale_max_qty", "sale_multiple_qty"
|
||||
)
|
||||
def check_constraint_restricted_qty(self):
|
||||
"""Rewrite the error message raised by `sale_restricted_qty`.
|
||||
|
||||
The upstream message is written for a salesperson: it dumps the
|
||||
offending products and explains how to tick "force min quantity" on
|
||||
the product form. Unreadable for an eCommerce customer.
|
||||
|
||||
Detection is left to the OCA module -- the `is_qty_*` fields stay the
|
||||
single source of truth. Only the wording is replaced, so an upstream
|
||||
change to the rules is followed without breaking anything.
|
||||
"""
|
||||
try:
|
||||
return super().check_constraint_restricted_qty()
|
||||
except ValidationError:
|
||||
raise ValidationError(self._get_restricted_qty_error_message()) from None
|
||||
|
||||
def _get_restricted_qty_error_message(self):
|
||||
"""Customer-facing message, one line per unmet restriction."""
|
||||
details = []
|
||||
for line in self:
|
||||
product = line.product_id
|
||||
if not product.force_sale_min_qty and line.is_qty_less_min_qty:
|
||||
details.append(
|
||||
_(
|
||||
"%(product)s: minimum order quantity is %(qty)s.",
|
||||
product=product.display_name,
|
||||
qty=product._format_restricted_qty(line.sale_min_qty),
|
||||
)
|
||||
)
|
||||
if not product.force_sale_max_qty and line.is_qty_bigger_max_qty:
|
||||
details.append(
|
||||
_(
|
||||
"%(product)s: maximum order quantity is %(qty)s.",
|
||||
product=product.display_name,
|
||||
qty=product._format_restricted_qty(line.sale_max_qty),
|
||||
)
|
||||
)
|
||||
if line.is_qty_not_multiple_qty:
|
||||
details.append(
|
||||
_(
|
||||
"%(product)s: must be ordered in multiples of %(qty)s.",
|
||||
product=product.display_name,
|
||||
qty=product._format_restricted_qty(line.sale_multiple_qty),
|
||||
)
|
||||
)
|
||||
|
||||
return _(
|
||||
"The selected quantity is not available for sale:\n\n"
|
||||
"%s\n\n"
|
||||
"Please adjust the quantity.",
|
||||
"\n".join(details),
|
||||
)
|
||||
@@ -0,0 +1,45 @@
|
||||
odoo.define("sale_restricted_qty_website_sale.add_to_cart", function (require) {
|
||||
"use strict";
|
||||
|
||||
const publicWidget = require("web.public.widget");
|
||||
const wSaleUtils = require("website_sale.utils");
|
||||
const WebsiteSale = require("website_sale.website_sale").WebsiteSale;
|
||||
|
||||
WebsiteSale.include({
|
||||
/**
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
_addToCartInPage: function () {
|
||||
return this._super.apply(this, arguments).catch((error) => {
|
||||
const message = this._getRestrictedQtyMessage(error);
|
||||
if (!message) {
|
||||
// Not a quantity restriction: let the real error surface.
|
||||
return Promise.reject(error);
|
||||
}
|
||||
if (error && error.event && error.event.preventDefault) {
|
||||
// Legacy convention: tells the crash manager the error is
|
||||
// handled, so it does not open its own dialog on top.
|
||||
error.event.preventDefault();
|
||||
}
|
||||
wSaleUtils.showWarning(message);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Object} error rejection from the legacy RPC
|
||||
* @returns {string|false} the message, or false to re-throw
|
||||
*/
|
||||
_getRestrictedQtyMessage: function (error) {
|
||||
const data =
|
||||
(error && error.message && error.message.data) ||
|
||||
(error && error.data);
|
||||
if (!data || data.name !== "odoo.exceptions.ValidationError") {
|
||||
return false;
|
||||
}
|
||||
return data.message;
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
1
sale_restricted_qty_website_sale/tests/__init__.py
Normal file
1
sale_restricted_qty_website_sale/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_restricted_qty_website_sale
|
||||
@@ -0,0 +1,89 @@
|
||||
from lxml import html
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import HttpCase, tagged
|
||||
|
||||
from odoo.addons.http_routing.models.ir_http import slug
|
||||
|
||||
|
||||
@tagged("post_install", "-at_install")
|
||||
class TestRestrictedQtyInfo(HttpCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.partner = cls.env["res.partner"].create({"name": "eCommerce customer"})
|
||||
cls.product_min = cls._create_product(
|
||||
"Product min 6", manual_sale_min_qty=6.0
|
||||
)
|
||||
cls.product_free = cls._create_product("Unrestricted product")
|
||||
# force = Yes -> purely indicative bound, nothing to tell the customer
|
||||
cls.product_indicative = cls._create_product(
|
||||
"Product min 6 indicative",
|
||||
manual_sale_min_qty=6.0,
|
||||
manual_force_sale_min_qty="force",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _create_product(cls, name, **restrictions):
|
||||
values = {
|
||||
"name": name,
|
||||
"type": "consu",
|
||||
"list_price": 10.0,
|
||||
"sale_ok": True,
|
||||
"is_published": True,
|
||||
}
|
||||
values.update(restrictions)
|
||||
return cls.env["product.template"].create(values).product_variant_id
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Error message
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def _create_line(self, product, qty):
|
||||
order = self.env["sale.order"].create({"partner_id": self.partner.id})
|
||||
self.env["sale.order.line"].create(
|
||||
{
|
||||
"order_id": order.id,
|
||||
"product_id": product.id,
|
||||
"product_uom_qty": qty,
|
||||
}
|
||||
)
|
||||
# @api.constrains are evaluated on flush, not on create().
|
||||
self.env.flush_all()
|
||||
return order
|
||||
|
||||
def test_error_message_is_customer_facing(self):
|
||||
with self.assertRaises(ValidationError) as error:
|
||||
self._create_line(self.product_min, 1)
|
||||
|
||||
message = str(error.exception)
|
||||
self.assertIn("Product min 6", message)
|
||||
self.assertIn("6", message)
|
||||
self.assertNotIn("force min", message, "Upstream jargon still present")
|
||||
|
||||
def test_valid_quantity_raises_nothing(self):
|
||||
self._create_line(self.product_min, 6)
|
||||
|
||||
def test_indicative_minimum_still_does_not_block(self):
|
||||
self._create_line(self.product_indicative, 1)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Product page display
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def _hint_on_page(self, product):
|
||||
response = self.url_open("/shop/%s" % slug(product.product_tmpl_id))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
tree = html.fromstring(response.content)
|
||||
return tree.xpath("//div[contains(@class, 'o_wsale_qty_restriction')]")
|
||||
|
||||
def test_hint_is_displayed(self):
|
||||
hint = self._hint_on_page(self.product_min)
|
||||
self.assertEqual(len(hint), 1)
|
||||
self.assertIn("6", hint[0].text_content())
|
||||
|
||||
def test_no_hint_without_restriction(self):
|
||||
self.assertFalse(self._hint_on_page(self.product_free))
|
||||
|
||||
def test_no_hint_for_an_indicative_minimum(self):
|
||||
self.assertFalse(self._hint_on_page(self.product_indicative))
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Product page: tell the customer about the orderable quantities,
|
||||
right below the quantity selector and the add-to-cart button. -->
|
||||
<template id="product_restricted_qty_info"
|
||||
inherit_id="website_sale.product_quantity"
|
||||
name="Restricted Quantity Information">
|
||||
<xpath expr="//div[@id='add_to_cart_wrap']" position="after">
|
||||
<t t-set="qty_hint" t-value="product._get_restricted_qty_hint()"/>
|
||||
<div t-if="qty_hint"
|
||||
class="o_wsale_qty_restriction alert alert-info d-flex align-items-center w-100 mt-2 mb-0 py-2 px-3">
|
||||
<i class="fa fa-info-circle me-2" role="img" aria-label="Information"/>
|
||||
<span t-out="qty_hint"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
@@ -1,45 +0,0 @@
|
||||
# Sale - Usability Misc
|
||||
|
||||
Miscellaneous usability improvements for the Odoo Sales app.
|
||||
|
||||
## Description
|
||||
|
||||
This module adjusts field visibility on the sale order form so that key
|
||||
information is accessible to **Sales Managers** without requiring developer
|
||||
mode.
|
||||
|
||||
### Changes
|
||||
|
||||
| Field | Default visibility | New visibility |
|
||||
|---|---|---|
|
||||
| **Order Date** (`date_order`) | Developer mode only (`base.group_no_one`) | Sales Managers (`sales_team.group_sale_manager`) |
|
||||
| **Opportunity** (`opportunity_id`) | Developer mode only (`base.group_no_one`) | Sales Managers (`sales_team.group_sale_manager`) |
|
||||
|
||||
## Usage
|
||||
|
||||
Once installed, users with the *Sales / Manager* role can see and edit the
|
||||
**Order Date** and **Opportunity** fields directly on the sale order form,
|
||||
without activating developer mode.
|
||||
|
||||
No configuration is required.
|
||||
|
||||
## Installation
|
||||
|
||||
Install via the standard Odoo module installation procedure.
|
||||
|
||||
**Dependencies:** `base`, `sale`, `sales_team`, `sale_crm`
|
||||
|
||||
## Credits
|
||||
|
||||
### Authors
|
||||
|
||||
- [Elabore](https://elabore.coop)
|
||||
|
||||
### Maintainer
|
||||
|
||||
This module is maintained by [Elabore](https://elabore.coop).
|
||||
|
||||
## License
|
||||
|
||||
This module is licensed under **AGPL-3**. See the [LICENSE](LICENSE) file for
|
||||
full details.
|
||||
50
sale_usability_misc/README.rst
Normal file
50
sale_usability_misc/README.rst
Normal file
@@ -0,0 +1,50 @@
|
||||
===============
|
||||
sale_usability_misc
|
||||
===============
|
||||
|
||||
Various improves for Sales app
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``sale_usability_misc``.
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
- Allow group sales administores to see date_order field event if not in developper mode
|
||||
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/sale_usability_misc/issues>`_. In case of
|
||||
trouble, please check there if your issue has already been
|
||||
reported. If you spotted it first, help us smashing it by providing a
|
||||
detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* `Elabore <mailto:laetitia.dacosta@elabore.coop>`
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "sale_usability_misc",
|
||||
"version": "18.0.1.0.0",
|
||||
"version": "16.0.1.0.1",
|
||||
"author": "Elabore",
|
||||
"website": "https://elabore.coop",
|
||||
"maintainer": "Elabore",
|
||||
|
||||
Reference in New Issue
Block a user