From ea0f1a55fac87cd5cb6f778efc107247aa20060c Mon Sep 17 00:00:00 2001 From: OCA Bot Date: Sun, 29 Sep 2019 23:43:58 +0200 Subject: [PATCH 01/10] [MIG] Add metafiles [skip ci] --- .travis.yml | 33 +++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 7 +++++++ LICENSE | 13 +++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.md diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..739a9307 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: python +sudo: false +cache: pip + +python: + - "3.5" + +addons: + # By default postgresql-9.1 is installed but there is issue related: + postgresql: "9.6" + apt: + packages: + - expect-dev # provides unbuffer utility + +env: + global: + - VERSION="13.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0" + + matrix: + - LINT_CHECK="1" + - TESTS="1" ODOO_REPO="OCA/OCB" + - TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1" + +install: + - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools + - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} + - travis_install_nightly + +script: + - travis_run_tests + +after_success: + - travis_after_tests_success diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..92d051bc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# OCA Guidelines + +Please follow the official guide from the [OCA Guidelines page](https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md). + +## Project Specific Guidelines + +This project does not have specific coding guidelines. diff --git a/LICENSE b/LICENSE index be3f7b28..2eabb66c 100644 --- a/LICENSE +++ b/LICENSE @@ -633,8 +633,13 @@ the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify +<<<<<<< HEAD it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or +======= + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or +>>>>>>> f5ffc96... [MIG] Add metafiles (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -643,7 +648,11 @@ the "copyright" line and a pointer to where the full notice is found. GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License +<<<<<<< HEAD along with this program. If not, see . +======= + along with this program. If not, see . +>>>>>>> f5ffc96... [MIG] Add metafiles Also add information on how to contact you by electronic and paper mail. @@ -658,4 +667,8 @@ specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see +<<<<<<< HEAD . +======= +. +>>>>>>> f5ffc96... [MIG] Add metafiles From d046e1889cd6b4fa4d15eaa8021ed913c3907d36 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Sat, 12 Oct 2019 12:26:44 +0200 Subject: [PATCH 02/10] pre-commit, black, isort [ci skip] --- .eslintrc | 291 ++++++++++++++++++++++++++++++++++++++++ .flake8 | 7 + .isort.cfg | 4 + .pre-commit-config.yaml | 73 ++++++++++ .pylintrc | 1 - .travis.yml | 33 +++-- LICENSE | 13 +- 7 files changed, 403 insertions(+), 19 deletions(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..28a0808b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,291 @@ +{ + "globals": { + "$": false, + "_": false, + "fuzzy": false, + "jQuery": false, + "moment": false, + "odoo": false, + "openerp": false, + "self": false + }, + "env": { + "browser": true + }, + "rules": { + "no-alert": "warn", + "no-array-constructor": "warn", + "no-bitwise": "off", + "no-caller": "warn", + "no-case-declarations": "warn", + "no-catch-shadow": "warn", + "no-class-assign": "warn", + "no-cond-assign": "warn", + "no-confusing-arrow": "warn", + "no-console": "off", + "no-const-assign": "warn", + "no-constant-condition": "warn", + "no-continue": "off", + "no-control-regex": "warn", + "no-debugger": "warn", + "no-delete-var": "warn", + "no-div-regex": "warn", + "no-dupe-args": "warn", + "no-dupe-class-members": "warn", + "no-dupe-keys": "warn", + "no-duplicate-case": "warn", + "no-duplicate-imports": "warn", + "no-else-return": "warn", + "no-empty": "warn", + "no-empty-character-class": "warn", + "no-empty-function": "warn", + "no-empty-pattern": "warn", + "no-eq-null": "warn", + "no-eval": "warn", + "no-ex-assign": "warn", + "no-extend-native": "warn", + "no-extra-bind": "warn", + "no-extra-boolean-cast": "warn", + "no-extra-label": "warn", + "no-extra-parens": "warn", + "no-extra-semi": "warn", + "no-fallthrough": "warn", + "no-floating-decimal": "warn", + "no-func-assign": "warn", + "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-invalid-this": "off", + "no-irregular-whitespace": "warn", + "no-iterator": "warn", + "no-label-var": "warn", + "no-labels": "warn", + "no-lone-blocks": "warn", + "no-lonely-if": "warn", + "no-loop-func": "off", + "no-magic-numbers": "off", + "no-mixed-operators": "warn", + "no-mixed-requires": "warn", + "no-mixed-spaces-and-tabs": "warn", + "no-multi-spaces": "warn", + "no-multi-str": "warn", + "no-multiple-empty-lines": "warn", + "no-native-reassign": "warn", + "no-negated-condition": "warn", + "no-negated-in-lhs": "warn", + "no-nested-ternary": "off", + "no-new": "warn", + "no-new-func": "warn", + "no-new-object": "warn", + "no-new-require": "warn", + "no-new-symbol": "warn", + "no-new-wrappers": "warn", + "no-obj-calls": "warn", + "no-octal": "warn", + "no-octal-escape": "warn", + "no-param-reassign": "warn", + "no-path-concat": "warn", + "no-plusplus": "off", + "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": "warn", + "no-script-url": "warn", + "no-self-assign": "warn", + "no-self-compare": "warn", + "no-sequences": "warn", + "no-shadow": "warn", + "no-shadow-restricted-names": "warn", + "no-whitespace-before-property": "warn", + "no-spaced-func": "warn", + "no-sparse-arrays": "warn", + "no-sync": "warn", + "no-tabs": "warn", + "no-ternary": "off", + "no-trailing-spaces": "warn", + "no-this-before-super": "warn", + "no-throw-literal": "warn", + "no-undef": "warn", + "no-undef-init": "warn", + "no-undefined": "off", + "no-unexpected-multiline": "warn", + "no-underscore-dangle": "off", + "no-unmodified-loop-condition": "warn", + "no-unneeded-ternary": "warn", + "no-unreachable": "warn", + "no-unsafe-finally": "warn", + "no-unused-expressions": "warn", + "no-unused-labels": "warn", + "no-unused-vars": "warn", + "no-use-before-define": "warn", + "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-var": "off", + "no-warning-comments": "off", + "no-with": "warn", + "array-bracket-spacing": "off", + "array-callback-return": "warn", + "arrow-body-style": "warn", + "arrow-parens": "warn", + "arrow-spacing": "off", + "accessor-pairs": "warn", + "block-scoped-var": "off", + "block-spacing": ["warn", "always"], + "brace-style": "warn", + "callback-return": "warn", + "camelcase": "off", + "capitalized-comments": ["warn", "always", { + "ignoreConsecutiveComments": true, + "ignoreInlineComments": true + }], + "comma-dangle": ["warn", "always-multiline"], + "comma-spacing": ["warn", { + "before": false, + "after": true + }], + "comma-style": "warn", + "complexity": [ + "warn", + 15 + ], + "computed-property-spacing": "off", + "consistent-return": "off", + "consistent-this": "off", + "constructor-super": "warn", + "curly": "warn", + "default-case": "off", + "dot-location": ["warn", "property"], + "dot-notation": "warn", + "eol-last": "warn", + "eqeqeq": "warn", + "func-names": "off", + "func-style": "off", + "generator-star-spacing": "off", + "global-require": "warn", + "guard-for-in": "off", + "handle-callback-err": "warn", + "id-blacklist": "warn", + "id-length": "off", + "id-match": "warn", + "indent": "warn", + "init-declarations": "warn", + "jsx-quotes": "warn", + "key-spacing": "off", + "keyword-spacing": "warn", + "linebreak-style": [ + "warn", + "unix" + ], + "lines-around-comment": "warn", + "max-depth": "warn", + "max-len": ["warn", { + "code": 88, + "ignorePattern": "odoo\\.define\\(", + "tabWidth": 4 + }], + "max-lines": "off", + "max-nested-callbacks": "warn", + "max-params": "off", + "max-statements": "off", + "max-statements-per-line": "warn", + "multiline-ternary": "off", + "new-cap": "off", + "new-parens": "warn", + "newline-after-var": "off", + "newline-before-return": "off", + "newline-per-chained-call": "off", + "object-curly-newline": ["warn", { "consistent": true }], + "object-curly-spacing": ["warn", "never"], + "object-property-newline": ["warn", { + "allowAllPropertiesOnSameLine": true + }], + "object-shorthand": "off", + "one-var": "off", + "one-var-declaration-per-line": "off", + "operator-assignment": "warn", + "operator-linebreak": "warn", + "padded-blocks": "off", + "prefer-arrow-callback": "off", + "prefer-const": "warn", + "prefer-reflect": "off", + "prefer-rest-params": "off", + "prefer-spread": "off", + "prefer-template": "off", + "quote-props": "off", + "quotes": "off", + "radix": "warn", + "require-yield": "warn", + "rest-spread-spacing": "off", + "semi": [ + "warn", + "always" + ], + "semi-spacing": "warn", + "sort-imports": "warn", + "sort-vars": "off", + "space-before-blocks": "warn", + "space-before-function-paren": "warn", + "space-in-parens": "off", + "space-infix-ops": "off", + "space-unary-ops": "off", + "spaced-comment": ["warn", "always"], + "strict": ["warn", "function"], + "template-curly-spacing": "off", + "unicode-bom": "warn", + "use-isnan": "warn", + "valid-jsdoc": ["warn", { + "prefer": { + "arg": "param", + "argument": "param", + "augments": "extends", + "constructor": "class", + "exception": "throws", + "func": "function", + "method": "function", + "prop": "property", + "return": "returns", + "virtual": "abstract", + "yield": "yields" + }, + "preferType": { + "array": "Array", + "bool": "Boolean", + "boolean": "Boolean", + "number": "Number", + "object": "Object", + "str": "String", + "string": "String" + }, + "requireParamDescription": false, + "requireReturn": false, + "requireReturnDescription": false, + "requireReturnType": false + }], + "valid-typeof": "warn", + "vars-on-top": "off", + "wrap-iife": "warn", + "wrap-regex": "warn", + "yield-star-spacing": "off", + "yoda": "warn" + }, + "parserOptions": { + "ecmaVersion": 2017 + } +} diff --git a/.flake8 b/.flake8 index e397e8ed..c68c00eb 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,9 @@ [flake8] +<<<<<<< HEAD max-line-length = 88 +======= +max-line-length = 80 +>>>>>>> 36d2e96... pre-commit, black, isort [ci skip] max-complexity = 16 # B = bugbear # B9 = bugbear opinionated (incl line length) @@ -8,5 +12,8 @@ select = C,E,F,W,B,B9 # E501: flake8 line length (covered by bugbear B950) # W503: line break before binary operator (black behaviour) ignore = E203,E501,W503 +<<<<<<< HEAD per-file-ignores= __init__.py:F401 +======= +>>>>>>> 36d2e96... pre-commit, black, isort [ci skip] diff --git a/.isort.cfg b/.isort.cfg index 0ec187ef..b8e4551d 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -9,5 +9,9 @@ line_length=88 known_odoo=odoo known_odoo_addons=odoo.addons sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER +<<<<<<< HEAD default_section=THIRDPARTY ensure_newline_before_comments = True +======= +known_third_party= +>>>>>>> 36d2e96... pre-commit, black, isort [ci skip] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b49c0eb..ce3fbe15 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +<<<<<<< HEAD exclude: | (?x) # NOT INSTALLABLE ADDONS @@ -136,3 +137,75 @@ repos: - id: pylint_odoo args: - --rcfile=.pylintrc-mandatory +<<<<<<< HEAD +======= + additional_dependencies: *pylint_deps +======= +exclude: "^setup/|/static/lib/|/static/src/lib/" +default_language_version: + python: python3 +repos: +- repo: https://github.com/psf/black + rev: 19.3b0 + hooks: + - id: black +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: trailing-whitespace + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ + - id: end-of-file-fixer + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ + - id: debug-statements + - id: flake8 + name: flake8 except __init__.py + exclude: /__init__\.py$ + additional_dependencies: ["flake8-bugbear==19.8.0"] + - id: flake8 + name: flake8 only __init__.py + args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py + files: /__init__\.py$ + additional_dependencies: ["flake8-bugbear==19.8.0"] + - id: fix-encoding-pragma + args: ["--remove"] + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-symlinks + - id: check-xml + - id: mixed-line-ending + args: ["--fix=lf"] +- repo: https://github.com/pre-commit/mirrors-pylint + rev: v2.3.1 + hooks: + - id: pylint + name: pylint with optional checks + args: ["--rcfile=.pylintrc", "--exit-zero"] + verbose: true + additional_dependencies: ["pylint-odoo==3.0.3"] + - id: pylint + name: pylint with mandatory checks + args: ["--rcfile=.pylintrc-mandatory"] + additional_dependencies: ["pylint-odoo==3.0.3"] +- repo: https://github.com/asottile/pyupgrade + rev: v1.24.0 + hooks: + - id: pyupgrade +- repo: https://github.com/asottile/seed-isort-config + rev: v1.9.3 + hooks: + - id: seed-isort-config +- repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort + name: isort except __init__.py + exclude: /__init__\.py$ +- repo: https://github.com/pre-commit/mirrors-eslint + rev: v6.5.1 + hooks: + - id: eslint + verbose: true diff --git a/.pylintrc b/.pylintrc index cad9c2f1..2c4eb3b7 100644 --- a/.pylintrc +++ b/.pylintrc @@ -116,7 +116,6 @@ enable=anomalous-backslash-in-string, too-complex, unnecessary-utf8-coding-comment - [REPORTS] msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} output-format=colorized diff --git a/.travis.yml b/.travis.yml index 739a9307..7048b77b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,41 @@ language: python -sudo: false -cache: pip +cache: + directories: + - $HOME/.cache/pip + - $HOME/.cache/pre-commit python: - - "3.5" + - "3.6" addons: - # By default postgresql-9.1 is installed but there is issue related: postgresql: "9.6" apt: packages: - expect-dev # provides unbuffer utility +stages: + - linting + - test + +jobs: + include: + - stage: linting + name: "pre-commit" + before_install: + install: pip install pre-commit + script: pre-commit run --all --show-diff-on-failure + after_success: + - stage: test + env: + - TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1" + - stage: test + env: + - TESTS="1" ODOO_REPO="OCA/OCB" + env: global: - VERSION="13.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0" - matrix: - - LINT_CHECK="1" - - TESTS="1" ODOO_REPO="OCA/OCB" - - TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1" - install: - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} diff --git a/LICENSE b/LICENSE index 2eabb66c..86dd5042 100644 --- a/LICENSE +++ b/LICENSE @@ -633,13 +633,8 @@ the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify -<<<<<<< HEAD it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or -======= - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or ->>>>>>> f5ffc96... [MIG] Add metafiles (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -648,11 +643,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License -<<<<<<< HEAD along with this program. If not, see . -======= - along with this program. If not, see . ->>>>>>> f5ffc96... [MIG] Add metafiles Also add information on how to contact you by electronic and paper mail. @@ -668,7 +659,11 @@ specific requirements. if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <<<<<<< HEAD +<<<<<<< HEAD . ======= . >>>>>>> f5ffc96... [MIG] Add metafiles +======= +. +>>>>>>> 36d2e96... pre-commit, black, isort [ci skip] From 47fdb676cdb652c82ddfc4b2dbeda6532b0a0a53 Mon Sep 17 00:00:00 2001 From: OCA Bot Date: Fri, 31 Jan 2020 18:51:02 +0100 Subject: [PATCH 03/10] [UPD] .travis.yml: Use verbose colored pre-commit [skip ci] --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7048b77b..8d16e8fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ jobs: name: "pre-commit" before_install: install: pip install pre-commit - script: pre-commit run --all --show-diff-on-failure + script: pre-commit run --all --show-diff-on-failure --verbose --color always after_success: - stage: test env: From b6ff608547f71ff9ecc6bb85f32e431c23486bc0 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Sat, 14 Mar 2020 12:16:54 +0100 Subject: [PATCH 04/10] pre-commit update [ci skip] --- .eslintrc | 291 ---------------------------------------- .isort.cfg | 4 + .pre-commit-config.yaml | 95 +++++++++++++ .prettierrc.yml | 4 + .travis.yml | 11 +- CONTRIBUTING.md | 3 +- 6 files changed, 111 insertions(+), 297 deletions(-) delete mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 28a0808b..00000000 --- a/.eslintrc +++ /dev/null @@ -1,291 +0,0 @@ -{ - "globals": { - "$": false, - "_": false, - "fuzzy": false, - "jQuery": false, - "moment": false, - "odoo": false, - "openerp": false, - "self": false - }, - "env": { - "browser": true - }, - "rules": { - "no-alert": "warn", - "no-array-constructor": "warn", - "no-bitwise": "off", - "no-caller": "warn", - "no-case-declarations": "warn", - "no-catch-shadow": "warn", - "no-class-assign": "warn", - "no-cond-assign": "warn", - "no-confusing-arrow": "warn", - "no-console": "off", - "no-const-assign": "warn", - "no-constant-condition": "warn", - "no-continue": "off", - "no-control-regex": "warn", - "no-debugger": "warn", - "no-delete-var": "warn", - "no-div-regex": "warn", - "no-dupe-args": "warn", - "no-dupe-class-members": "warn", - "no-dupe-keys": "warn", - "no-duplicate-case": "warn", - "no-duplicate-imports": "warn", - "no-else-return": "warn", - "no-empty": "warn", - "no-empty-character-class": "warn", - "no-empty-function": "warn", - "no-empty-pattern": "warn", - "no-eq-null": "warn", - "no-eval": "warn", - "no-ex-assign": "warn", - "no-extend-native": "warn", - "no-extra-bind": "warn", - "no-extra-boolean-cast": "warn", - "no-extra-label": "warn", - "no-extra-parens": "warn", - "no-extra-semi": "warn", - "no-fallthrough": "warn", - "no-floating-decimal": "warn", - "no-func-assign": "warn", - "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-invalid-this": "off", - "no-irregular-whitespace": "warn", - "no-iterator": "warn", - "no-label-var": "warn", - "no-labels": "warn", - "no-lone-blocks": "warn", - "no-lonely-if": "warn", - "no-loop-func": "off", - "no-magic-numbers": "off", - "no-mixed-operators": "warn", - "no-mixed-requires": "warn", - "no-mixed-spaces-and-tabs": "warn", - "no-multi-spaces": "warn", - "no-multi-str": "warn", - "no-multiple-empty-lines": "warn", - "no-native-reassign": "warn", - "no-negated-condition": "warn", - "no-negated-in-lhs": "warn", - "no-nested-ternary": "off", - "no-new": "warn", - "no-new-func": "warn", - "no-new-object": "warn", - "no-new-require": "warn", - "no-new-symbol": "warn", - "no-new-wrappers": "warn", - "no-obj-calls": "warn", - "no-octal": "warn", - "no-octal-escape": "warn", - "no-param-reassign": "warn", - "no-path-concat": "warn", - "no-plusplus": "off", - "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": "warn", - "no-script-url": "warn", - "no-self-assign": "warn", - "no-self-compare": "warn", - "no-sequences": "warn", - "no-shadow": "warn", - "no-shadow-restricted-names": "warn", - "no-whitespace-before-property": "warn", - "no-spaced-func": "warn", - "no-sparse-arrays": "warn", - "no-sync": "warn", - "no-tabs": "warn", - "no-ternary": "off", - "no-trailing-spaces": "warn", - "no-this-before-super": "warn", - "no-throw-literal": "warn", - "no-undef": "warn", - "no-undef-init": "warn", - "no-undefined": "off", - "no-unexpected-multiline": "warn", - "no-underscore-dangle": "off", - "no-unmodified-loop-condition": "warn", - "no-unneeded-ternary": "warn", - "no-unreachable": "warn", - "no-unsafe-finally": "warn", - "no-unused-expressions": "warn", - "no-unused-labels": "warn", - "no-unused-vars": "warn", - "no-use-before-define": "warn", - "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-var": "off", - "no-warning-comments": "off", - "no-with": "warn", - "array-bracket-spacing": "off", - "array-callback-return": "warn", - "arrow-body-style": "warn", - "arrow-parens": "warn", - "arrow-spacing": "off", - "accessor-pairs": "warn", - "block-scoped-var": "off", - "block-spacing": ["warn", "always"], - "brace-style": "warn", - "callback-return": "warn", - "camelcase": "off", - "capitalized-comments": ["warn", "always", { - "ignoreConsecutiveComments": true, - "ignoreInlineComments": true - }], - "comma-dangle": ["warn", "always-multiline"], - "comma-spacing": ["warn", { - "before": false, - "after": true - }], - "comma-style": "warn", - "complexity": [ - "warn", - 15 - ], - "computed-property-spacing": "off", - "consistent-return": "off", - "consistent-this": "off", - "constructor-super": "warn", - "curly": "warn", - "default-case": "off", - "dot-location": ["warn", "property"], - "dot-notation": "warn", - "eol-last": "warn", - "eqeqeq": "warn", - "func-names": "off", - "func-style": "off", - "generator-star-spacing": "off", - "global-require": "warn", - "guard-for-in": "off", - "handle-callback-err": "warn", - "id-blacklist": "warn", - "id-length": "off", - "id-match": "warn", - "indent": "warn", - "init-declarations": "warn", - "jsx-quotes": "warn", - "key-spacing": "off", - "keyword-spacing": "warn", - "linebreak-style": [ - "warn", - "unix" - ], - "lines-around-comment": "warn", - "max-depth": "warn", - "max-len": ["warn", { - "code": 88, - "ignorePattern": "odoo\\.define\\(", - "tabWidth": 4 - }], - "max-lines": "off", - "max-nested-callbacks": "warn", - "max-params": "off", - "max-statements": "off", - "max-statements-per-line": "warn", - "multiline-ternary": "off", - "new-cap": "off", - "new-parens": "warn", - "newline-after-var": "off", - "newline-before-return": "off", - "newline-per-chained-call": "off", - "object-curly-newline": ["warn", { "consistent": true }], - "object-curly-spacing": ["warn", "never"], - "object-property-newline": ["warn", { - "allowAllPropertiesOnSameLine": true - }], - "object-shorthand": "off", - "one-var": "off", - "one-var-declaration-per-line": "off", - "operator-assignment": "warn", - "operator-linebreak": "warn", - "padded-blocks": "off", - "prefer-arrow-callback": "off", - "prefer-const": "warn", - "prefer-reflect": "off", - "prefer-rest-params": "off", - "prefer-spread": "off", - "prefer-template": "off", - "quote-props": "off", - "quotes": "off", - "radix": "warn", - "require-yield": "warn", - "rest-spread-spacing": "off", - "semi": [ - "warn", - "always" - ], - "semi-spacing": "warn", - "sort-imports": "warn", - "sort-vars": "off", - "space-before-blocks": "warn", - "space-before-function-paren": "warn", - "space-in-parens": "off", - "space-infix-ops": "off", - "space-unary-ops": "off", - "spaced-comment": ["warn", "always"], - "strict": ["warn", "function"], - "template-curly-spacing": "off", - "unicode-bom": "warn", - "use-isnan": "warn", - "valid-jsdoc": ["warn", { - "prefer": { - "arg": "param", - "argument": "param", - "augments": "extends", - "constructor": "class", - "exception": "throws", - "func": "function", - "method": "function", - "prop": "property", - "return": "returns", - "virtual": "abstract", - "yield": "yields" - }, - "preferType": { - "array": "Array", - "bool": "Boolean", - "boolean": "Boolean", - "number": "Number", - "object": "Object", - "str": "String", - "string": "String" - }, - "requireParamDescription": false, - "requireReturn": false, - "requireReturnDescription": false, - "requireReturnType": false - }], - "valid-typeof": "warn", - "vars-on-top": "off", - "wrap-iife": "warn", - "wrap-regex": "warn", - "yield-star-spacing": "off", - "yoda": "warn" - }, - "parserOptions": { - "ecmaVersion": 2017 - } -} diff --git a/.isort.cfg b/.isort.cfg index b8e4551d..f79d4927 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -10,8 +10,12 @@ known_odoo=odoo known_odoo_addons=odoo.addons sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER <<<<<<< HEAD +<<<<<<< HEAD default_section=THIRDPARTY ensure_newline_before_comments = True ======= known_third_party= >>>>>>> 36d2e96... pre-commit, black, isort [ci skip] +======= +default_section=THIRDPARTY +>>>>>>> ea4e737... pre-commit update [ci skip] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ce3fbe15..1b57946b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,5 @@ <<<<<<< HEAD +<<<<<<< HEAD exclude: | (?x) # NOT INSTALLABLE ADDONS @@ -7,6 +8,12 @@ exclude: | ^setup/|/static/description/index\.html$| # We don't want to mess with tool-generated files .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| +======= +exclude: | + (?x) + # Files and folders generated by bots, to avoid loops + ^setup/|/static/description/index\.html$| +>>>>>>> ea4e737... pre-commit update [ci skip] # Maybe reactivate this when all README files include prettier ignore tags? ^README\.md$| # Library files can have extraneous formatting (even minimized) @@ -15,6 +22,7 @@ exclude: | ^docs/_templates/.*\.html$| # You don't usually want a bot to modify your legal texts (LICENSE.*|COPYING.*) +<<<<<<< HEAD default_language_version: python: python3 node: "16.17.0" @@ -209,3 +217,90 @@ repos: hooks: - id: eslint verbose: true +default_language_version: + python: python3 +repos: + - repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black + - repo: https://github.com/prettier/prettier + rev: "1.19.1" + hooks: + - id: prettier + # TODO Avoid awebdeveloper/pre-commit-prettier if possible + # HACK https://github.com/prettier/prettier/issues/7407 + - repo: https://github.com/awebdeveloper/pre-commit-prettier + rev: v0.0.1 + hooks: + - id: prettier + name: prettier xml plugin + additional_dependencies: + - "prettier@1.19.1" + - "@prettier/plugin-xml@0.7.2" + files: \.xml$ + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v6.8.0 + hooks: + - id: eslint + verbose: true + args: + - --color + - --fix + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: trailing-whitespace + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ + - id: end-of-file-fixer + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ + - id: debug-statements + - id: flake8 + name: flake8 except __init__.py + exclude: /__init__\.py$ + additional_dependencies: ["flake8-bugbear==19.8.0"] + - id: flake8 + name: flake8 only __init__.py + args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py + files: /__init__\.py$ + additional_dependencies: ["flake8-bugbear==19.8.0"] + - id: fix-encoding-pragma + args: ["--remove"] + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-merge-conflict + # exclude files where underlines are not distinguishable from merge conflicts + exclude: /README\.rst$|^docs/.*\.rst$ + - id: check-symlinks + - id: check-xml + - id: mixed-line-ending + args: ["--fix=lf"] + - repo: https://github.com/pre-commit/mirrors-pylint + rev: v2.3.1 + hooks: + - id: pylint + name: pylint with optional checks + args: ["--rcfile=.pylintrc", "--exit-zero"] + verbose: true + additional_dependencies: ["pylint-odoo==3.1.0"] + - id: pylint + name: pylint with mandatory checks + args: ["--rcfile=.pylintrc-mandatory"] + additional_dependencies: ["pylint-odoo==3.1.0"] + - repo: https://github.com/asottile/pyupgrade + rev: v1.26.2 + hooks: + - id: pyupgrade + - repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort + name: isort except __init__.py + exclude: /__init__\.py$ + - repo: https://github.com/acsone/setuptools-odoo + rev: 2.5.2 + hooks: + - id: setuptools-odoo-make-default diff --git a/.prettierrc.yml b/.prettierrc.yml index 5b6d4b36..2b149ffc 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -5,4 +5,8 @@ printWidth: 88 proseWrap: always semi: true trailingComma: "es5" +<<<<<<< HEAD xmlWhitespaceSensitivity: "strict" +======= +xmlWhitespaceSensitivity: "ignore" +>>>>>>> ea4e737... pre-commit update [ci skip] diff --git a/.travis.yml b/.travis.yml index 8d16e8fc..6716bfad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: python cache: directories: - - $HOME/.cache/pip - - $HOME/.cache/pre-commit + - $HOME/.cache/pip + - $HOME/.cache/pre-commit python: - "3.6" @@ -11,7 +11,7 @@ addons: postgresql: "9.6" apt: packages: - - expect-dev # provides unbuffer utility + - expect-dev # provides unbuffer utility stages: - linting @@ -34,10 +34,11 @@ jobs: env: global: - - VERSION="13.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0" + - VERSION="13.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0" install: - - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools + - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git + ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - travis_install_nightly diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 92d051bc..8f7056a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # OCA Guidelines -Please follow the official guide from the [OCA Guidelines page](https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md). +Please follow the official guide from the +[OCA Guidelines page](https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md). ## Project Specific Guidelines From 84518e987c2b8490239d25488d3a6427255dcf97 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 13 May 2020 14:05:59 +0200 Subject: [PATCH 05/10] [UPD] pin flake8 version [ci skip] --- .pre-commit-config.yaml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b57946b..e905911f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -257,15 +257,6 @@ repos: # exclude autogenerated files exclude: /README\.rst$|\.pot?$ - id: debug-statements - - id: flake8 - name: flake8 except __init__.py - exclude: /__init__\.py$ - additional_dependencies: ["flake8-bugbear==19.8.0"] - - id: flake8 - name: flake8 only __init__.py - args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py - files: /__init__\.py$ - additional_dependencies: ["flake8-bugbear==19.8.0"] - id: fix-encoding-pragma args: ["--remove"] - id: check-case-conflict @@ -278,6 +269,18 @@ repos: - id: check-xml - id: mixed-line-ending args: ["--fix=lf"] + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.9 + hooks: + - id: flake8 + name: flake8 except __init__.py + exclude: /__init__\.py$ + additional_dependencies: ["flake8-bugbear==19.8.0"] + - id: flake8 + name: flake8 only __init__.py + args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py + files: /__init__\.py$ + additional_dependencies: ["flake8-bugbear==19.8.0"] - repo: https://github.com/pre-commit/mirrors-pylint rev: v2.3.1 hooks: From 74080e72ba524e41963d72b19158aeb65bfb3599 Mon Sep 17 00:00:00 2001 From: Juan Jose Scarafia Date: Mon, 6 Jul 2020 08:02:39 -0300 Subject: [PATCH 06/10] [ADD] sale_product_pack_assisted --- sale_product_pack_assisted/README.rst | 117 ++++++++++++ sale_product_pack_assisted/__init__.py | 3 + sale_product_pack_assisted/__manifest__.py | 21 +++ sale_product_pack_assisted/i18n/es.po | 170 ++++++++++++++++++ sale_product_pack_assisted/models/__init__.py | 5 + .../models/product_template.py | 18 ++ .../models/sale_order_line.py | 72 ++++++++ .../models/sale_order_line_pack_line.py | 35 ++++ .../security/ir.model.access.csv | 3 + .../views/sale_order_line_pack_line_views.xml | 17 ++ .../views/sale_order_line_views.xml | 58 ++++++ .../views/sale_order_views.xml | 23 +++ 12 files changed, 542 insertions(+) create mode 100644 sale_product_pack_assisted/README.rst create mode 100644 sale_product_pack_assisted/__init__.py create mode 100644 sale_product_pack_assisted/__manifest__.py create mode 100644 sale_product_pack_assisted/i18n/es.po create mode 100644 sale_product_pack_assisted/models/__init__.py create mode 100644 sale_product_pack_assisted/models/product_template.py create mode 100644 sale_product_pack_assisted/models/sale_order_line.py create mode 100644 sale_product_pack_assisted/models/sale_order_line_pack_line.py create mode 100644 sale_product_pack_assisted/security/ir.model.access.csv create mode 100644 sale_product_pack_assisted/views/sale_order_line_pack_line_views.xml create mode 100644 sale_product_pack_assisted/views/sale_order_line_views.xml create mode 100644 sale_product_pack_assisted/views/sale_order_views.xml diff --git a/sale_product_pack_assisted/README.rst b/sale_product_pack_assisted/README.rst new file mode 100644 index 00000000..87a789f4 --- /dev/null +++ b/sale_product_pack_assisted/README.rst @@ -0,0 +1,117 @@ +================= +Sale product Pack +================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--pack-lightgray.png?logo=github + :target: https://github.com/OCA/product-pack/tree/12.0/sale_product_pack + :alt: OCA/product-pack +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-pack-12-0/product-pack-12-0-sale_product_pack + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/286/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds *Product Pack* functionality to sales orders. You can choose +a *Pack* in *sales order lines* and see different behaviors depending on +"Pack type" and "Pack component price" fields options selected on this *Pack*. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Go to *Sales > Products > Products*, create or select a product and check + *Is Pack?* +#. Set "Product type" and "Pack component price" fields in the *Pack* page. +#. Add the products to be included in it. +#. Go to *Sales > Orders > Quotations* and create a Quotation. +#. Add a product that has checked "Is Pack?" +#. Save data and you will see an specific behavior depending on "Pack type" and + "Pack component price" fields options selected on this *Pack*. For example, + for products that has *Detailed* option selected in "Pack type" field you + will see one *sale order line* per component that belong to this Pack. + (See *Product pack* module README.rst file) + +Known issues / Roadmap +====================== + +* If this module is installed and stock module is installed too, when you + create a Sale order for a *Non detailed* Pack and you confirm it, + a *Stock picking* is not created with the storable components of that Pack. + So, add a new module called *sale_stock_product_pack* that adds that feature. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* NaN·tic +* ADHOC SA +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Ernesto Tejeda + * Pedro M. Baeza + +* `Akretion `_: + + * Raphaël Reverdy + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-ernestotejeda| image:: https://github.com/ernestotejeda.png?size=40px + :target: https://github.com/ernestotejeda + :alt: ernestotejeda + +Current `maintainer `__: + +|maintainer-ernestotejeda| + +This module is part of the `OCA/product-pack `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_product_pack_assisted/__init__.py b/sale_product_pack_assisted/__init__.py new file mode 100644 index 00000000..83e553ac --- /dev/null +++ b/sale_product_pack_assisted/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/sale_product_pack_assisted/__manifest__.py b/sale_product_pack_assisted/__manifest__.py new file mode 100644 index 00000000..6018d202 --- /dev/null +++ b/sale_product_pack_assisted/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2019 NaN (http://www.nan-tic.com) - Àngel Àlvarez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Assisted Sale product Pack", + "version": "13.0.1.0.0", + "category": "Sales", + "website": "https://github.com/OCA/product-pack", + "author": "NaN·tic, ADHOC SA, Tecnativa, Odoo Community Association (OCA)", + "maintainers": ["jjscarafia"], + "license": "AGPL-3", + "depends": ["sale_product_pack"], + "data": [ + "views/sale_order_line_pack_line_views.xml", + "views/sale_order_line_views.xml", + "views/sale_order_views.xml", + "security/ir.model.access.csv", + ], + "installable": True, + "auto_install": False, + "application": False, +} diff --git a/sale_product_pack_assisted/i18n/es.po b/sale_product_pack_assisted/i18n/es.po new file mode 100644 index 00000000..e520f30d --- /dev/null +++ b/sale_product_pack_assisted/i18n/es.po @@ -0,0 +1,170 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_product_pack_assisted +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-07-06 10:57+0000\n" +"PO-Revision-Date: 2020-07-06 10: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: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line__ +msgid "Assisted Pack Lines" +msgstr "Líneas de Pack Asistido" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line__assisted_pack_total +msgid "Assisted Pack Total" +msgstr "Tota de Pack Asistido" + +#. module: sale_product_pack_assisted +#: model_terms:ir.ui.view,arch_db:sale_product_pack_assisted.view_order_line_form2 +msgid "Cancel" +msgstr "Cancelar" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__create_uid +msgid "Created by" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__create_date +msgid "Created on" +msgstr "" + +#. module: sale_product_pack_assisted +#: model_terms:ir.ui.view,arch_db:sale_product_pack_assisted.view_order_stock_form +msgid "Detail" +msgstr "Detalle" + +#. module: sale_product_pack_assisted +#: code:addons/sale_product_pack_assisted/models/sale_order_line.py:0 +#, python-format +msgid "Details" +msgstr "Detalles" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__discount +msgid "Discount (%)" +msgstr "Descuento (%s)" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__display_name +msgid "Display Name" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__id +msgid "ID" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__write_date +msgid "Last Updated on" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields.selection,name:sale_product_pack_assisted.selection__product_template__pack_type__non_detailed_assisted +msgid "Non Detailed - Assisted" +msgstr "No Detallado - Asistido" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,help:sale_product_pack_assisted.field_product_product__pack_type +#: model:ir.model.fields,help:sale_product_pack_assisted.field_product_template__pack_type +msgid "" +"On sale orders or purchase orders:\n" +"* Detailed: Display components individually in the sale order.\n" +"* Non Detailed: Do not display components individually in the sale order.\n" +"* Non Detailed - Assisted: Do not display components individually in the sale order but gives a template that user can edit to calculate pack amount" +msgstr "" +"En órdenes de venta u órdenes de compra:\n" +"* Detallado: Muestra los componentes individualmente en lineas de la Orden " +"de Venta/Orden de Compra\n" +"* No Detallado: No muestra los componentes individualmente en lineas de la " +"Orden de Venta/Orden de Compra\n" +"* No Detallado - Asistido: No muestra los componentes individualmente en lineas de la " +"Orden de Venta/Orden de Compra pero ofrece una plantilla que el usuario puede utilizar para calcular el importe del pack" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__order_line_id +msgid "Order Line" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_product_product__pack_type +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_product_template__pack_type +msgid "Pack Type" +msgstr "Tipo de Pack" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__product_id +msgid "Product" +msgstr "Producto" + +#. module: sale_product_pack_assisted +#: model:ir.model,name:sale_product_pack_assisted.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__product_uom_qty +msgid "Quantity" +msgstr "Cantidad" + +#. module: sale_product_pack_assisted +#: model:ir.model,name:sale_product_pack_assisted.model_sale_order_line_pack_line +msgid "Sale Order None Detailed Pack Lines" +msgstr "" + +#. module: sale_product_pack_assisted +#: model:ir.model,name:sale_product_pack_assisted.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de pedido de venta" + +#. module: sale_product_pack_assisted +#: model_terms:ir.ui.view,arch_db:sale_product_pack_assisted.view_sale_line_pack_line_tree +msgid "Sales Order Line Pack Lines" +msgstr "" + +#. module: sale_product_pack_assisted +#: model_terms:ir.ui.view,arch_db:sale_product_pack_assisted.view_order_line_form2 +msgid "Sales Order Lines" +msgstr "" + +#. module: sale_product_pack_assisted +#: model_terms:ir.ui.view,arch_db:sale_product_pack_assisted.view_order_line_form2 +msgid "Save" +msgstr "Guardar" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__price_subtotal +msgid "Subtotal" +msgstr "Subtotal" + +#. module: sale_product_pack_assisted +#: model:ir.model.fields,field_description:sale_product_pack_assisted.field_sale_order_line_pack_line__price_unit +msgid "Unit Price" +msgstr "Precio Unitario" + +#. module: sale_product_pack_assisted +#: model_terms:ir.ui.view,arch_db:sale_product_pack_assisted.view_order_line_form2 +msgid "or" +msgstr "o" diff --git a/sale_product_pack_assisted/models/__init__.py b/sale_product_pack_assisted/models/__init__.py new file mode 100644 index 00000000..6d080c0f --- /dev/null +++ b/sale_product_pack_assisted/models/__init__.py @@ -0,0 +1,5 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import sale_order_line_pack_line +from . import sale_order_line +from . import product_template diff --git a/sale_product_pack_assisted/models/product_template.py b/sale_product_pack_assisted/models/product_template.py new file mode 100644 index 00000000..8dff3709 --- /dev/null +++ b/sale_product_pack_assisted/models/product_template.py @@ -0,0 +1,18 @@ +# Copyright 2019 ADHOC SA - Juan José Scarafía +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + pack_type = fields.Selection( + selection_add=[("non_detailed_assisted", "Non Detailed - Assisted")], + help="On sale orders or purchase orders:\n" + "* Detailed: Display components individually in the sale order.\n" + "* Non Detailed: Do not display components individually in the" + " sale order.\n" + "* Non Detailed - Assisted: Do not display components individually in the" + " sale order but gives a template that user can edit to calculate pack amount", + ) diff --git a/sale_product_pack_assisted/models/sale_order_line.py b/sale_product_pack_assisted/models/sale_order_line.py new file mode 100644 index 00000000..050b396c --- /dev/null +++ b/sale_product_pack_assisted/models/sale_order_line.py @@ -0,0 +1,72 @@ +# Copyright 2019 ADHOC SA - Juan José Scarafía +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import _, api, fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + assisted_pack_line_ids = fields.One2many( + "sale.order.line.pack.line", "order_line_id", "Assisted Pack Lines" + ) + assisted_pack_total = fields.Float(compute="_compute_assisted_pack_total") + + @api.onchange("assisted_pack_total") + def _onchange_pack_line_ids(self): + for line in self: + line.price_unit = line.assisted_pack_total + + @api.depends( + "assisted_pack_line_ids", "assisted_pack_line_ids.price_subtotal", + ) + def _compute_assisted_pack_total(self): + for line in self: + line.assisted_pack_total = sum( + x.price_subtotal for x in line.assisted_pack_line_ids + ) + + def expand_pack_line(self, write=False): + self.ensure_one() + # if we are using update_pricelist or checking out on ecommerce we + # only want to update prices + do_not_expand = self._context.get("update_prices") or self._context.get( + "update_pricelist", False + ) + if not do_not_expand and self.product_id.pack_type == "non_detailed_assisted": + # remove previus existing lines + self.assisted_pack_line_ids.unlink() + + # create a sale pack line for each product pack line + for pack_line in self.product_id.pack_line_ids.with_context( + pricelist=self.order_id.pricelist_id.id + ): + price_unit = pack_line.product_id.price + quantity = pack_line.quantity + vals = { + "order_line_id": self.id, + "product_id": pack_line.product_id.id, + "product_uom_qty": quantity, + "price_unit": price_unit, + "discount": pack_line.sale_discount, + "price_subtotal": price_unit * quantity, + } + self.assisted_pack_line_ids.create(vals) + return super().expand_pack_line() + + def action_assisted_pack_detail(self): + view = self.env.ref("sale_product_pack_assisted.view_order_line_form2") + return { + "name": _("Details"), + "view_type": "form", + "view_mode": "form", + "res_model": "sale.order.line", + "view_id": view.id, + "type": "ir.actions.act_window", + "target": "new", + "readonly": True, + "res_id": self.id, + "context": dict(self.env.context, pricelist=self.order_id.pricelist_id.id), + } + + def button_save_data(self): + return True diff --git a/sale_product_pack_assisted/models/sale_order_line_pack_line.py b/sale_product_pack_assisted/models/sale_order_line_pack_line.py new file mode 100644 index 00000000..339a62dc --- /dev/null +++ b/sale_product_pack_assisted/models/sale_order_line_pack_line.py @@ -0,0 +1,35 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from odoo import api, fields, models + + +class SaleOrderLinePackLine(models.Model): + _name = "sale.order.line.pack.line" + _description = "Sale Order None Detailed Pack Lines" + + order_line_id = fields.Many2one( + "sale.order.line", "Order Line", ondelete="cascade", index=True, required=True + ) + product_id = fields.Many2one("product.product", "Product", required=True) + price_unit = fields.Float("Unit Price", required=True, digits="Product Price") + discount = fields.Float("Discount (%)", digits="Discount",) + price_subtotal = fields.Float( + compute="_compute_price_subtotal", string="Subtotal", digits="Account" + ) + product_uom_qty = fields.Float("Quantity", digits="Product UoS", required=True) + + @api.onchange("product_id") + def onchange_product_id(self): + for line in self: + line.price_unit = line.product_id.price + + @api.depends("price_unit", "product_uom_qty") + def _compute_price_subtotal(self): + for line in self: + line.price_subtotal = ( + line.product_uom_qty + * line.price_unit + * (1 - (line.discount or 0.0) / 100.0) + ) diff --git a/sale_product_pack_assisted/security/ir.model.access.csv b/sale_product_pack_assisted/security/ir.model.access.csv new file mode 100644 index 00000000..9d005f1c --- /dev/null +++ b/sale_product_pack_assisted/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sale_order_line_pack_line_user,sale_order_line_pack_line_user,model_sale_order_line_pack_line,base.group_user,1,1,1,1 +access_sale_order_line_pack_line_all,sale_order_line_pack_line_all,model_sale_order_line_pack_line,,1,0,0,0 diff --git a/sale_product_pack_assisted/views/sale_order_line_pack_line_views.xml b/sale_product_pack_assisted/views/sale_order_line_pack_line_views.xml new file mode 100644 index 00000000..9f1f1044 --- /dev/null +++ b/sale_product_pack_assisted/views/sale_order_line_pack_line_views.xml @@ -0,0 +1,17 @@ + + + + + sale.line.pack.line.tree + sale.order.line.pack.line + + + + + + + + + + + diff --git a/sale_product_pack_assisted/views/sale_order_line_views.xml b/sale_product_pack_assisted/views/sale_order_line_views.xml new file mode 100644 index 00000000..eada985d --- /dev/null +++ b/sale_product_pack_assisted/views/sale_order_line_views.xml @@ -0,0 +1,58 @@ + + + + view.order.line.button + sale.order.line + + +
+
+ +
+ + +
+
+
+ + + + +
+
+ +
+ + diff --git a/sale_product_pack_assisted/views/sale_order_views.xml b/sale_product_pack_assisted/views/sale_order_views.xml new file mode 100644 index 00000000..817c7abd --- /dev/null +++ b/sale_product_pack_assisted/views/sale_order_views.xml @@ -0,0 +1,23 @@ + + + + sale.order.form.inherit + sale.order + + + + + +