Compare commits
1 Commits
18.0
...
18.0-fix-o
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3fa6b8d6e |
@@ -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 }}"
|
||||
13
.gitignore
vendored
13
.gitignore
vendored
@@ -25,19 +25,6 @@ var/
|
||||
*.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
|
||||
|
||||
@@ -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
|
||||
2
partner_gogocarto_export_api/.gitignore
vendored
2
partner_gogocarto_export_api/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
*.*~
|
||||
*pyc
|
||||
@@ -1,66 +0,0 @@
|
||||
============================
|
||||
partner_gogocarto_export_api
|
||||
============================
|
||||
|
||||
Gogocarto Export module, to export the partner data needed for a Gogocarto map.
|
||||
|
||||
This module allow the users to decide:
|
||||
|
||||
* the partners to be exported
|
||||
* the fields exported for each partner (*name*, *partner_longitude* and *partner_latitude* automatically exported)
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``partner_gogocarto_export_api``, all dependencies will be installed by default.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To export partners data:
|
||||
|
||||
#. Set the fields you want to export in Settings / Gogocarto.
|
||||
#. Check the field *"Export to Gogocarto"* in the partner form view.
|
||||
|
||||
And use the link *https://yourodoo.com/web/<company_id>/get_http_gogocarto_elements* in Gogocarto server import configuration (*https://video.colibris-outilslibres.org/videos/watch/c74fc469-c822-4ab8-82a7-a2555e49e576*)
|
||||
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/partner-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 SAINLEGER <https://github.com/stephansainleger>
|
||||
* Chloé Migayrou <https://github.com/MigayrouChloe>
|
||||
* Nicolas Jeudy <https://github.com/njeudy>
|
||||
* Lokavaluto Teams <https://lokavaluto.fr>
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
* Lokavaluto (https://lokavaluto.fr)
|
||||
* Mycéliandre (https://myceliandre.fr)
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore and Lokavaluto.
|
||||
@@ -1,2 +0,0 @@
|
||||
from . import controllers
|
||||
from . import models
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"name": "partner_gogocarto_export_api",
|
||||
"summary": """HTTP JSON api to send partner data for Gogocarto import""",
|
||||
"license": "AGPL-3",
|
||||
"author": "Lokavaluto, Elabore",
|
||||
"website": "https://git.elabore.coop/elabore/partner-tools",
|
||||
"category": "Localization",
|
||||
"version": "18.0.1.0.0",
|
||||
"depends": [
|
||||
"base",
|
||||
"base_setup",
|
||||
"contacts",
|
||||
"base_geolocalize",
|
||||
"partner_geolocalize_usability",
|
||||
"jsonifier",
|
||||
"server_action_mass_edit",
|
||||
],
|
||||
"data": [
|
||||
"views/gogocarto_partner.xml",
|
||||
"views/gogocarto_config_settings_view.xml",
|
||||
"views/res_company_view.xml",
|
||||
],
|
||||
"demo": [],
|
||||
"installable": True,
|
||||
"auto_install": False,
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
from . import main
|
||||
@@ -1,29 +0,0 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from odoo import http
|
||||
from odoo.http import Response, request
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PartnerGogocartojs(http.Controller):
|
||||
|
||||
@http.route(
|
||||
'/web/<company_id>/get_http_gogocarto_elements',
|
||||
methods=['GET'],
|
||||
type='http',
|
||||
csrf=False,
|
||||
auth="public",
|
||||
website=True)
|
||||
def get_gogocarto_elements_http(self, company_id):
|
||||
data = self._jsonify_get_partner(company_id)
|
||||
return Response(json.dumps(data))
|
||||
|
||||
def _jsonify_get_partner(self, company_id):
|
||||
PartnerSudo = request.env['res.partner'].sudo()
|
||||
parser = PartnerSudo._get_gogocarto_parser(company_id)
|
||||
partners = PartnerSudo.with_company(company_id).search(
|
||||
PartnerSudo._get_gogocarto_domain(company_id)
|
||||
)
|
||||
return partners.jsonify(parser)
|
||||
@@ -1,82 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * partner_gogocarto_export_api
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 18.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-10-18 21:57+0000\n"
|
||||
"PO-Revision-Date: 2026-10-18 21:57+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: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "Check the export on /web/{COMPANY_ID}/get_http_gogocarto_elements."
|
||||
msgstr "Vérifiez l'export sur /web/{COMPANY_ID}/get_http_gogocarto_elements.\""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model,name:partner_gogocarto_export_api.model_res_company
|
||||
msgid "Companies"
|
||||
msgstr "Sociétés"
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model,name:partner_gogocarto_export_api.model_res_config_settings
|
||||
msgid "Config Settings"
|
||||
msgstr "Paramètres de configuration"
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model,name:partner_gogocarto_export_api.model_res_partner
|
||||
msgid "Contact"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_company__export_gogocarto_fields
|
||||
msgid "Export Gogocarto Fields"
|
||||
msgstr "Champs exportés dans Gogocarto"
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_partner__in_gogocarto
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_users__in_gogocarto
|
||||
msgid "Export to Gogocarto"
|
||||
msgstr "Exporter dans Gogocarto"
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "GogoCarto"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_config_settings__export_gogocarto_fields
|
||||
msgid "GogoCarto Exported fields"
|
||||
msgstr "Champs exportés dans Gogocarto"
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_company_gogocarto_form_view
|
||||
msgid "GogoCarto Setup"
|
||||
msgstr "Gogocarto"
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "GogoCarto export configuration"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.actions.server,name:partner_gogocarto_export_api.mass_editing_partner
|
||||
msgid "Mass Edit In Gogocarto Field"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "Open export URL"
|
||||
msgstr "Ouvrir l'URL d'export"
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "Partner fields to export for Gogocarto map."
|
||||
msgstr "Champs de contact à exporter vers Gogocarto."
|
||||
@@ -1,82 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * partner_gogocarto_export_api
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 18.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-10-18 21:57+0000\n"
|
||||
"PO-Revision-Date: 2026-10-18 21:57+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: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "Check the export on /web/{COMPANY_ID}/get_http_gogocarto_elements."
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model,name:partner_gogocarto_export_api.model_res_company
|
||||
msgid "Companies"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model,name:partner_gogocarto_export_api.model_res_config_settings
|
||||
msgid "Config Settings"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model,name:partner_gogocarto_export_api.model_res_partner
|
||||
msgid "Contact"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_company__export_gogocarto_fields
|
||||
msgid "Export Gogocarto Fields"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_partner__in_gogocarto
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_users__in_gogocarto
|
||||
msgid "Export to Gogocarto"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "GogoCarto"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_config_settings__export_gogocarto_fields
|
||||
msgid "GogoCarto Exported fields"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_company_gogocarto_form_view
|
||||
msgid "GogoCarto Setup"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "GogoCarto export configuration"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model:ir.actions.server,name:partner_gogocarto_export_api.mass_editing_partner
|
||||
msgid "Mass Edit In Gogocarto Field"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "Open export URL"
|
||||
msgstr ""
|
||||
|
||||
#. module: partner_gogocarto_export_api
|
||||
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
|
||||
msgid "Partner fields to export for Gogocarto map."
|
||||
msgstr ""
|
||||
@@ -1,3 +0,0 @@
|
||||
from . import res_partner
|
||||
from . import res_config_settings
|
||||
from . import company
|
||||
@@ -1,13 +0,0 @@
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class Company(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
export_gogocarto_fields = fields.Many2many(
|
||||
'ir.model.fields',
|
||||
domain=[
|
||||
('model_id', '=', 'res.partner'),
|
||||
('name', 'not in', ['id', 'name', 'partner_longitude', 'partner_latitude'])
|
||||
]
|
||||
)
|
||||
@@ -1,35 +0,0 @@
|
||||
import logging
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
export_gogocarto_fields = fields.Many2many(
|
||||
related="company_id.export_gogocarto_fields",
|
||||
relation="ir.model.fields",
|
||||
string="GogoCarto Exported fields",
|
||||
readonly=False,
|
||||
domain=[
|
||||
("model_id", "=", "res.partner"),
|
||||
("name", "not in", ["name", "partner_longitude", "partner_latitude", "id"]),
|
||||
],
|
||||
)
|
||||
|
||||
def action_open_gogocarto_export(self):
|
||||
"""
|
||||
Open the company's Gogocarto export endpoint in a new tab.
|
||||
|
||||
:return: URL action targeting the export endpoint of the company selected in the
|
||||
settings
|
||||
:rtype: dict
|
||||
"""
|
||||
self.ensure_one()
|
||||
return {
|
||||
"type": "ir.actions.act_url",
|
||||
"target": "new",
|
||||
"url": f"/web/{self.company_id.id}/get_http_gogocarto_elements",
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
""" Inherits partner, adds Gogocarto fields in the partner form, and functions"""
|
||||
_inherit = 'res.partner'
|
||||
|
||||
in_gogocarto = fields.Boolean('Export to Gogocarto')
|
||||
|
||||
def _get_gogocarto_domain(self, company_id):
|
||||
# To OVERRIDE in sub_modules to customize the partner selection
|
||||
return [('in_gogocarto', '=', True)]
|
||||
|
||||
def _get_generic_parser(self, fields):
|
||||
parser = []
|
||||
for field in fields:
|
||||
if field.ttype in [
|
||||
"boolean",
|
||||
"char",
|
||||
"integer",
|
||||
"monetary",
|
||||
"text",
|
||||
"selection",
|
||||
"float",
|
||||
"date_time",
|
||||
"date",
|
||||
"html"]:
|
||||
parser.append(field.name)
|
||||
elif field.ttype in ["many2one", "one2many", "many2many"]:
|
||||
parser.append((field.name, ['id', 'name']))
|
||||
elif field.ttype == "binary":
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
return parser
|
||||
|
||||
def _get_gogocarto_parser(self, company_id):
|
||||
fields = self._get_export_fields(company_id)
|
||||
parser = self._get_generic_parser(fields)
|
||||
return parser
|
||||
|
||||
def _get_export_fields(self, company_id):
|
||||
CompanySudo = self.env['res.company'].sudo().search([('id', '=', company_id)])
|
||||
default_fields = self.env['ir.model.fields'].sudo().search([
|
||||
('model_id', '=', 'res.partner'),
|
||||
('name', 'in', ['id', 'name', 'partner_longitude', 'partner_latitude'])])
|
||||
company_fields = CompanySudo.export_gogocarto_fields
|
||||
export_fields = default_fields | company_fields
|
||||
return export_fields
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 52 KiB |
@@ -1,3 +0,0 @@
|
||||
from . import test_controller
|
||||
from . import test_res_partner
|
||||
from . import test_settings_view
|
||||
@@ -1,84 +0,0 @@
|
||||
from odoo.tests.common import HttpCase
|
||||
|
||||
_ROUTE = "/web/{company_id}/get_http_gogocarto_elements"
|
||||
|
||||
|
||||
class TestGogocartoExportHttp(HttpCase):
|
||||
"""
|
||||
End-to-end tests of the public JSON endpoint.
|
||||
|
||||
Requests are made anonymously on purpose: the route is declared
|
||||
``auth="public"`` and Gogocarto servers fetch it without credentials.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.partner = cls.env["res.partner"].create(
|
||||
{
|
||||
"name": "Gogo Test Partner",
|
||||
"street": "1 rue du Test",
|
||||
"city": "Paris",
|
||||
"in_gogocarto": True,
|
||||
"partner_latitude": 48.8566,
|
||||
"partner_longitude": 2.3522,
|
||||
}
|
||||
)
|
||||
cls.env["res.partner"].create({"name": "Hidden Partner", "in_gogocarto": False})
|
||||
company = cls.env["res.company"].browse(1)
|
||||
company.export_gogocarto_fields = (
|
||||
cls.env["ir.model.fields"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("model_id", "=", "res.partner"),
|
||||
("name", "in", ["street", "city"]),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
def _get_elements(self, company_id="1"):
|
||||
"""
|
||||
Call the export endpoint anonymously and return the response.
|
||||
|
||||
:param company_id: company id to embed in the route
|
||||
:return: the HTTP response for the endpoint
|
||||
"""
|
||||
# ``authenticate(None, None)`` opens an anonymous session bound to
|
||||
# the test database; a bare cookie-less request would not resolve
|
||||
# the database when the instance hosts several of them.
|
||||
self.authenticate(None, None)
|
||||
return self.url_open(_ROUTE.format(company_id=company_id))
|
||||
|
||||
def test_returns_flagged_partners_as_json(self):
|
||||
"""
|
||||
The endpoint returns the flagged partner with its exported data.
|
||||
"""
|
||||
response = self._get_elements()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
entries = [e for e in response.json() if e["id"] == self.partner.id]
|
||||
self.assertEqual(len(entries), 1)
|
||||
entry = entries[0]
|
||||
self.assertEqual(entry["name"], "Gogo Test Partner")
|
||||
self.assertEqual(entry["street"], "1 rue du Test")
|
||||
self.assertEqual(entry["city"], "Paris")
|
||||
self.assertEqual(entry["partner_latitude"], 48.8566)
|
||||
self.assertEqual(entry["partner_longitude"], 2.3522)
|
||||
|
||||
def test_excludes_unflagged_partners(self):
|
||||
"""
|
||||
Partners without the ``in_gogocarto`` flag are never exported.
|
||||
"""
|
||||
data = self._get_elements().json()
|
||||
self.assertFalse(any(e["name"] == "Hidden Partner" for e in data))
|
||||
|
||||
def test_unknown_company_returns_default_fields(self):
|
||||
"""
|
||||
An unknown company id degrades gracefully to the default fields.
|
||||
"""
|
||||
response = self._get_elements(company_id="99999999")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
entry = [e for e in response.json() if e["id"] == self.partner.id][0]
|
||||
self.assertNotIn("street", entry) # no company fields selected
|
||||
self.assertIn("name", entry)
|
||||
self.assertIn("partner_latitude", entry)
|
||||
@@ -1,104 +0,0 @@
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestGogocartoParser(TransactionCase):
|
||||
"""
|
||||
Unit tests of the parser and domain helpers.
|
||||
|
||||
These pin the data contract sent to the Gogocarto importer: a silent
|
||||
regression here corrupts the map feed while the HTTP endpoint keeps
|
||||
answering 200.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.Partner = cls.env["res.partner"]
|
||||
cls.ModelFields = cls.env["ir.model.fields"].sudo()
|
||||
cls.Company = cls.env["res.company"].sudo()
|
||||
|
||||
def test_get_gogocarto_domain_default(self):
|
||||
"""
|
||||
The default selection only exports explicitly flagged partners.
|
||||
"""
|
||||
self.assertEqual(
|
||||
self.Partner._get_gogocarto_domain(1),
|
||||
[("in_gogocarto", "=", True)],
|
||||
)
|
||||
|
||||
def test_get_export_fields_without_company(self):
|
||||
"""
|
||||
An unknown company id falls back to the default field set.
|
||||
"""
|
||||
fields = self.Partner._get_export_fields(99999999)
|
||||
self.assertEqual(
|
||||
set(fields.mapped("name")),
|
||||
{"id", "name", "partner_longitude", "partner_latitude"},
|
||||
)
|
||||
|
||||
def test_get_export_fields_includes_company_fields(self):
|
||||
"""
|
||||
Fields selected on the company extend the default field set.
|
||||
"""
|
||||
company = self.Company.create({"name": "Gogo Test Co"})
|
||||
street = self.ModelFields.search(
|
||||
[("model_id", "=", "res.partner"), ("name", "=", "street")], limit=1
|
||||
)
|
||||
company.export_gogocarto_fields = street
|
||||
|
||||
fields = self.Partner._get_export_fields(company.id)
|
||||
|
||||
self.assertEqual(
|
||||
set(fields.mapped("name")),
|
||||
{
|
||||
"id",
|
||||
"name",
|
||||
"partner_longitude",
|
||||
"partner_latitude",
|
||||
"street",
|
||||
},
|
||||
)
|
||||
|
||||
def test_get_generic_parser_maps_supported_ttypes(self):
|
||||
"""
|
||||
Scalar fields map by name, relational ones to [id, name], and binary fields are
|
||||
excluded from the parser.
|
||||
"""
|
||||
fields = self.ModelFields.search(
|
||||
[
|
||||
("model_id", "=", "res.partner"),
|
||||
("name", "in", ["phone", "comment", "category_id", "image_1920"]),
|
||||
]
|
||||
)
|
||||
parser = self.Partner._get_generic_parser(fields)
|
||||
self.assertIn("phone", parser) # char
|
||||
self.assertIn("comment", parser) # html
|
||||
self.assertIn(("category_id", ["id", "name"]), parser) # many2many
|
||||
self.assertNotIn("image_1920", parser) # binary
|
||||
|
||||
def test_get_generic_parser_skips_unsupported_ttypes(self):
|
||||
"""
|
||||
A ttype outside the supported sets is silently skipped.
|
||||
"""
|
||||
field = MagicMock()
|
||||
field.ttype = "many2one_reference"
|
||||
field.name = "x_unsupported"
|
||||
self.assertEqual(self.Partner._get_generic_parser(field), [])
|
||||
|
||||
def test_get_gogocarto_parser_composition(self):
|
||||
"""
|
||||
The Gogocarto parser combines default and company fields.
|
||||
"""
|
||||
company = self.Company.create({"name": "Gogo Test Co 2"})
|
||||
street = self.ModelFields.search(
|
||||
[("model_id", "=", "res.partner"), ("name", "=", "street")], limit=1
|
||||
)
|
||||
company.export_gogocarto_fields = street
|
||||
|
||||
parser = self.Partner._get_gogocarto_parser(company.id)
|
||||
|
||||
self.assertIn("street", parser)
|
||||
self.assertIn("name", parser)
|
||||
self.assertIn("partner_latitude", parser)
|
||||
@@ -1,35 +0,0 @@
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestGogocartoSettingsView(TransactionCase):
|
||||
"""
|
||||
Regression tests of the settings view structure.
|
||||
"""
|
||||
|
||||
def test_settings_menu_entry_exists(self):
|
||||
"""A dedicated ``<app>`` must exist so GogoCarto gets its own entry
|
||||
in the settings side menu: in 18.0 the menu is built exclusively
|
||||
from ``<app>`` elements, blocks buried in another app's tab are
|
||||
not listed."""
|
||||
arch = self.env["res.config.settings"].get_view(
|
||||
view_id=self.env.ref(
|
||||
"partner_gogocarto_export_api.res_config_settings_view_form_gogocarto"
|
||||
).id,
|
||||
view_type="form",
|
||||
)["arch"]
|
||||
self.assertIn('name="partner_gogocarto_export_api"', arch)
|
||||
self.assertIn("export_gogocarto_fields", arch)
|
||||
|
||||
def test_action_opens_export_url_in_new_tab(self):
|
||||
"""
|
||||
The settings button returns a URL action to the current company's export
|
||||
endpoint, opened in a new tab.
|
||||
"""
|
||||
settings = self.env["res.config.settings"].create({})
|
||||
action = settings.action_open_gogocarto_export()
|
||||
self.assertEqual(action["type"], "ir.actions.act_url")
|
||||
self.assertEqual(action["target"], "new")
|
||||
self.assertEqual(
|
||||
action["url"],
|
||||
f"/web/{settings.company_id.id}/get_http_gogocarto_elements",
|
||||
)
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form_gogocarto" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.gogocarto</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="priority" eval="99" />
|
||||
<field name="inherit_id" ref="base.res_config_settings_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form" position="inside">
|
||||
<app
|
||||
data-string="GogoCarto"
|
||||
string="GogoCarto"
|
||||
name="partner_gogocarto_export_api"
|
||||
logo="/partner_gogocarto_export_api/static/description/icon.png"
|
||||
>
|
||||
<block
|
||||
title="GogoCarto export configuration"
|
||||
name="gogocarto_settings"
|
||||
id="gogocarto_selection_settings"
|
||||
>
|
||||
<setting
|
||||
id="gogocarto_fields"
|
||||
help="Partner fields to export for Gogocarto map."
|
||||
>
|
||||
<div class="text-muted">
|
||||
Check the export on /web/{COMPANY_ID}/get_http_gogocarto_elements.
|
||||
</div>
|
||||
<div class="mt16">
|
||||
<field
|
||||
name="export_gogocarto_fields"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="object"
|
||||
name="action_open_gogocarto_export"
|
||||
string="Open export URL"
|
||||
icon="oi-arrow-right"
|
||||
class="btn-link"
|
||||
/>
|
||||
</setting>
|
||||
</block>
|
||||
</app>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="partner_gogocarto_form_view">
|
||||
<field name="name">partner.gogocarto.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="partner_geolocalize_usability.partner_geolocalize_form_view" />
|
||||
<field name='priority'>99</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='geolocalize']/group" position="inside">
|
||||
<field name="in_gogocarto" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- Mass Edit Partner field in_gogocarto -->
|
||||
<record id="mass_editing_partner" model="ir.actions.server">
|
||||
<field name="state">mass_edit</field>
|
||||
<field name="name">Mass Edit In Gogocarto Field</field>
|
||||
<field name="model_id" ref="base.model_res_partner" />
|
||||
</record>
|
||||
<record id="mass_editing_partner_in_gogocarto" model="ir.actions.server.mass.edit.line" >
|
||||
<field name="server_action_id" ref="mass_editing_partner" />
|
||||
<field name="field_id" ref="partner_gogocarto_export_api.field_res_partner__in_gogocarto" />
|
||||
</record>
|
||||
<!-- Add context actions -->
|
||||
<function model="ir.actions.server" name="create_action">
|
||||
<value eval="[ref('mass_editing_partner')]" />
|
||||
</function>
|
||||
</odoo>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="res_company_gogocarto_form_view">
|
||||
<field name="name">res_company.gogocarto.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="inherit_id" ref="base.view_company_form"/>
|
||||
<field name='priority'>99</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//notebook" position="inside">
|
||||
<page string="GogoCarto Setup" name="gogocarto">
|
||||
<group>
|
||||
<field name="export_gogocarto_fields"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user