diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..bfd7ac53df9f103f6dc8853738c63fd364445fde --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Configuration for known file extensions +[*.{css,js,json,less,md,py,rst,sass,scss,xml,yaml,yml}] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{json,yml,yaml,rst,md}] +indent_size = 2 + +# Do not configure editor for libs and autogenerated content +[{*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst}] +charset = unset +end_of_line = unset +indent_size = unset +indent_style = unset +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000000000000000000000000000000000000..88f2881b4c128fc4762338a8f420272c44cc29ef --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,180 @@ +env: + browser: true + +# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 +parserOptions: + ecmaVersion: 2017 + +# Globals available in Odoo that shouldn't produce errorings +globals: + _: readonly + $: readonly + fuzzy: readonly + jQuery: readonly + moment: readonly + odoo: readonly + openerp: readonly + Promise: readonly + +# Styling is handled by Prettier, so we only need to enable AST rules; +# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890 +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 + 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 + yoda: warn diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000000000000000000000000000000000..e397e8ed4e3e7f7fe7785dd391bb80aa6d85575e --- /dev/null +++ b/.flake8 @@ -0,0 +1,12 @@ +[flake8] +max-line-length = 88 +max-complexity = 16 +# B = bugbear +# B9 = bugbear opinionated (incl line length) +select = C,E,F,W,B,B9 +# E203: whitespace before ':' (black behaviour) +# E501: flake8 line length (covered by bugbear B950) +# W503: line break before binary operator (black behaviour) +ignore = E203,E501,W503 +per-file-ignores= + __init__.py:F401 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..818770fb1bdc0a144e924c9a5940f0b035df8a0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,75 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +/.venv +/.pytest_cache + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +*.eggs + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Pycharm +.idea + +# Eclipse +.settings + +# Visual Studio cache/options directory +.vs/ +.vscode + +# OSX Files +.DS_Store + +# Django stuff: +*.log + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Sphinx documentation +docs/_build/ + +# Backup files +*~ +*.swp + +# OCA rules +!static/lib/ diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0ec187efd1bf802844749f508cda0c8f138970f9 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,13 @@ +[settings] +; see https://github.com/psf/black +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True +use_parentheses=True +line_length=88 +known_odoo=odoo +known_odoo_addons=odoo.addons +sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER +default_section=THIRDPARTY +ensure_newline_before_comments = True diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cb8b5ef27a4408c9767c962d0f4e70fb99715061 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,123 @@ +exclude: | + (?x) + # NOT INSTALLABLE ADDONS + # END NOT INSTALLABLE ADDONS + # Files and folders generated by bots, to avoid loops + ^setup/|/static/description/index\.html$| + # We don't want to mess with tool-generated files + .svg$|/tests/([^/]+/)?cassettes/| + # Library files can have extraneous formatting (even minimized) + /static/(src/)?lib/| + # Repos using Sphinx to generate docs don't need prettying + ^docs/_templates/.*\.html$| + # You don't usually want a bot to modify your legal texts + (LICENSE.*|COPYING.*) +default_language_version: + python: python3 + node: "14.13.0" +repos: + - repo: local + hooks: + # These files are most likely copier diff rejection junks; if found, + # review them manually, fix the problem (if needed) and remove them + - id: forbidden-files + name: forbidden files + entry: found forbidden files; remove them + language: fail + files: "\\.rej$" + - repo: https://github.com/oca/maintainer-tools + rev: ab1d7f6 + hooks: + # update the NOT INSTALLABLE ADDONS section above + - id: oca-update-pre-commit-excluded-addons + - repo: https://github.com/myint/autoflake + rev: v1.4 + hooks: + - id: autoflake + args: + - --expand-star-imports + - --ignore-init-module-imports + - --in-place + - --remove-all-unused-imports + - --remove-duplicate-keys + - --remove-unused-variables + - repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.1.2 + hooks: + - id: prettier + name: prettier (with plugin-xml) + additional_dependencies: + - "prettier@2.1.2" + - "@prettier/plugin-xml@0.12.0" + args: + - --plugin=@prettier/plugin-xml + files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v7.8.1 + hooks: + - id: eslint + verbose: true + args: + - --color + - --fix + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.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: 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/asottile/pyupgrade + rev: v2.7.2 + hooks: + - id: pyupgrade + args: ["--keep-percent-format"] + - repo: https://github.com/PyCQA/isort + rev: 5.5.1 + hooks: + - id: isort + name: isort except __init__.py + args: + - --settings=. + exclude: /__init__\.py$ + - repo: https://gitlab.com/PyCQA/flake8 + rev: 3.8.3 + hooks: + - id: flake8 + name: flake8 + additional_dependencies: ["flake8-bugbear==20.1.4"] + - repo: https://github.com/PyCQA/pylint + rev: pylint-2.5.3 + hooks: + - id: pylint + name: pylint with optional checks + args: + - --rcfile=.pylintrc + - --exit-zero + verbose: true + additional_dependencies: &pylint_deps + - pylint-odoo==3.5.0 + - id: pylint + name: pylint with mandatory checks + args: + - --rcfile=.pylintrc-mandatory + additional_dependencies: *pylint_deps diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000000000000000000000000000000000000..5b6d4b361ace92f3877993bf2848fac190d8fab6 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,8 @@ +# Defaults for all prettier-supported languages. +# Prettier will complete this with settings from .editorconfig file. +bracketSpacing: false +printWidth: 88 +proseWrap: always +semi: true +trailingComma: "es5" +xmlWhitespaceSensitivity: "strict" diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000000000000000000000000000000000000..c3d0a5c839baeee21312961c56158de4936fdc91 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,88 @@ +[MASTER] +load-plugins=pylint_odoo +score=n + +[ODOOLINT] +readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" +manifest_required_authors=Le Filament +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=14.0 + +[MESSAGES CONTROL] +disable=all + +# This .pylintrc contains optional AND mandatory checks and is meant to be +# loaded in an IDE to have it check everything, in the hope this will make +# optional checks more visible to contributors who otherwise never look at a +# green travis to see optional checks that failed. +# .pylintrc-mandatory containing only mandatory checks is used the pre-commit +# config as a blocking check. + +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, + eval-used, + incoherent-interpreter-exec-perm, + license-allowed, + manifest-author-string, + manifest-deprecated-key, + manifest-required-author, + manifest-required-key, + manifest-version-format, + method-compute, + 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, + # 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, + too-complex, + unnecessary-utf8-coding-comment + + +[REPORTS] +msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} +output-format=colorized +reports=no diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory new file mode 100644 index 0000000000000000000000000000000000000000..974196ea332738ed397c86db63cd09be0d3fd609 --- /dev/null +++ b/.pylintrc-mandatory @@ -0,0 +1,64 @@ +[MASTER] +load-plugins=pylint_odoo +score=n + +[ODOOLINT] +readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" +manifest_required_authors=Le Filament +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=12.0,14.0 + +[MESSAGES CONTROL] +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, + eval-used, + incoherent-interpreter-exec-perm, + license-allowed, + manifest-author-string, + manifest-deprecated-key, + manifest-required-author, + manifest-required-key, + manifest-version-format, + method-compute, + 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 + +[REPORTS] +msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} +output-format=colorized +reports=no diff --git a/README.rst b/README.rst old mode 100755 new mode 100644 index 7d870cbe0c9ef54a93794e0a64d0eaa763aba4a4..0a5bc2ca5aa1ec01e41ad961fd7d2a6df0673615 --- a/README.rst +++ b/README.rst @@ -34,4 +34,3 @@ Maintainer :target: https://le-filament.com This module is maintained by Le Filament - diff --git a/__init__.py b/__init__.py index e352eeb90b1ca31078563924292ce9240f8b436c..957992f377d7ce8942a87238397684babc5eb305 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,4 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import models \ No newline at end of file +from . import models diff --git a/__manifest__.py b/__manifest__.py old mode 100755 new mode 100644 index ad1490d8f337bbbe883b17dea77a7410fc483393..8cded89f023e7985f204ac5bcfe57d0ee816e345 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,32 +1,30 @@ { - 'name': "FUMAISON OCC - Contacts", - 'summary': "Contacts", - 'author': "Le Filament", - 'website': "https://www.le-filament.com", - 'version': '14.0.1.0.1', - 'license': "AGPL-3", - 'depends': [ - 'base', 'contacts', 'account' - ], - 'data': [ + "name": "FUMAISON OCC - Contacts", + "summary": "Contacts", + "author": "Le Filament", + "website": "https://www.le-filament.com", + "version": "14.0.1.0.1", + "license": "AGPL-3", + "depends": ["base", "contacts", "account"], + "data": [ "security/ir.model.access.csv", # datas - 'data/res_partner_billing_type_data.xml', - 'data/res_partner_call_frequency_data.xml', - 'data/res_partner_packaging_data.xml', - 'data/res_partner_regional_center_data.xml', - 'data/res_partner_status_data.xml', - 'data/res_partner_day_data.xml', + "data/res_partner_billing_type_data.xml", + "data/res_partner_call_frequency_data.xml", + "data/res_partner_packaging_data.xml", + "data/res_partner_regional_center_data.xml", + "data/res_partner_status_data.xml", + "data/res_partner_day_data.xml", # views - 'views/res_partner_views.xml', + "views/res_partner_views.xml", # views menu - 'views/menu_views.xml', - 'views/fumoc_category_views.xml', + "views/menu_views.xml", + "views/fumoc_category_views.xml", # wizard ], - 'qweb': [ + "qweb": [ # "static/src/xml/*.xml", ], - 'installable': True, - 'auto_install': False, + "installable": True, + "auto_install": False, } diff --git a/data/res_partner_billing_type_data.xml b/data/res_partner_billing_type_data.xml index a9e8534cc1195cbe490a756b13fe1957acee8bf3..820400e03ac23c01e0341e45b5349ce3497bed4e 100644 --- a/data/res_partner_billing_type_data.xml +++ b/data/res_partner_billing_type_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="billing_livraison" model="res.partner.billing.type"> @@ -11,4 +11,4 @@ <field name="name">au mois</field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/data/res_partner_call_frequency_data.xml b/data/res_partner_call_frequency_data.xml index bb6ec85ca26ecc7c05db2b127c53e6d4d0c10b9d..74ce542d20e6c450afe7b362f173a182d19066b8 100644 --- a/data/res_partner_call_frequency_data.xml +++ b/data/res_partner_call_frequency_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="call_hebdo" model="res.partner.call.frequency"> @@ -20,4 +20,4 @@ <field name="name">Appel du client</field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/data/res_partner_day_data.xml b/data/res_partner_day_data.xml index 87e75404d5881c98904f76394ccc5d2e4fd23691..c164ccd32a259a6ffb6f70d101d73ed35bd1783c 100644 --- a/data/res_partner_day_data.xml +++ b/data/res_partner_day_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="lundi" model="res.partner.day"> @@ -20,4 +20,4 @@ <field name="name">Samedi</field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/data/res_partner_packaging_data.xml b/data/res_partner_packaging_data.xml index 0ef558f65839ea421df7ff8068a6f772ab647019..48fee0af8a274f67ef832a7fb4b7d0eca7624373 100644 --- a/data/res_partner_packaging_data.xml +++ b/data/res_partner_packaging_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="packaging_seule" model="res.partner.packaging"> @@ -14,4 +14,4 @@ <field name="name">Exception</field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/data/res_partner_regional_center_data.xml b/data/res_partner_regional_center_data.xml index 78197de3ac3ba8e37edacd4a069718e168fa8903..674b7a2c710a76ec01449e0bacfc3bed37e5dd97 100644 --- a/data/res_partner_regional_center_data.xml +++ b/data/res_partner_regional_center_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="regional_center_biocoop" model="res.partner.regional.center"> diff --git a/data/res_partner_status_data.xml b/data/res_partner_status_data.xml index 5387b2649bd51087e896ac76cd02ecc12d7bc8ec..c113864b9a10d900bae218adb2e3bbeb78409012 100644 --- a/data/res_partner_status_data.xml +++ b/data/res_partner_status_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="status_proscpect" model="res.partner.status"> @@ -20,4 +20,4 @@ <field name="name">Autre</field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/models/__init__.py b/models/__init__.py index 22f351505506652591379bca305dad3813d011a3..abb4a9fa96a244f22f9f9b28b59429755a1f9522 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -2,4 +2,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import res_partner -from . import fumoc_category \ No newline at end of file +from . import fumoc_category diff --git a/models/fumoc_category.py b/models/fumoc_category.py index 3bab3fce44af156f06fb28b70d7b2cb44ec08f47..88787aa1a5231544997b9ed40781286c86f6b9ae 100644 --- a/models/fumoc_category.py +++ b/models/fumoc_category.py @@ -1,42 +1,41 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError class FumocCategory(models.Model): - _name = 'fumoc.category' + _name = "fumoc.category" _description = "Catégorie" _parent_name = "parent_id" _parent_store = True - _rec_name = 'complete_name' - _order = 'complete_name' + _rec_name = "complete_name" + _order = "complete_name" # ------------------------------------------------------ # Fields declaration # ------------------------------------------------------ - name = fields.Char( - 'Nom de la catégorie', - index=True, - required=True) + name = fields.Char("Nom de la catégorie", index=True, required=True) complete_name = fields.Char( - 'Nom complet', - compute='_compute_complete_name', - store=True) + "Nom complet", compute="_compute_complete_name", store=True + ) parent_id = fields.Many2one( - 'fumoc.category', - 'Catégorie mère', index=True, ondelete='cascade') + "fumoc.category", "Catégorie mère", index=True, ondelete="cascade" + ) parent_path = fields.Char(index=True) - child_id = fields.One2many('fumoc.category', 'parent_id', 'Enfants cat') + child_id = fields.One2many("fumoc.category", "parent_id", "Enfants cat") # ------------------------------------------------------ # SQL Constraints # ------------------------------------------------------ - @api.constrains('parent_id') + @api.constrains("parent_id") def _check_type_recursion(self): if not self._check_recursion(): - raise ValidationError(_('Vous ne pouvez pas créer de cateogries récursives.')) + raise ValidationError( + _("Vous ne pouvez pas créer de cateogries récursives.") + ) return True # ------------------------------------------------------ @@ -44,16 +43,19 @@ class FumocCategory(models.Model): # ------------------------------------------------------ @api.model def name_create(self, name): - return self.create({'name': name}).name_get()[0] + return self.create({"name": name}).name_get()[0] # ------------------------------------------------------ # Computed fields / Search Fields # ------------------------------------------------------ - @api.depends('name', 'parent_id.complete_name') + @api.depends("name", "parent_id.complete_name") def _compute_complete_name(self): for type in self: if type.parent_id: - type.complete_name = '%s / %s' % (type.parent_id.complete_name, type.name) + type.complete_name = "%s / %s" % ( + type.parent_id.complete_name, + type.name, + ) else: type.complete_name = type.name diff --git a/models/res_partner.py b/models/res_partner.py index e70d363fb137afa6c927b25865c1d441a49f9883..194e9583f5826e57c334d5742e5a0d5ae03e7d9c 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -1,11 +1,11 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models, api +from odoo import fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" # ------------------------------------------------------ # Fields declaration @@ -16,49 +16,47 @@ class ResPartner(models.Model): # Fields for customer regional_center_id = fields.Many2one( - 'res.partner.regional.center', - string="Centrale régionale") - packaging_id = fields.Many2one( - 'res.partner.packaging', - string="Emballage") - departure_day_ids = fields.Many2many(comodel_name='res.partner.day', string="Jour de départ") + "res.partner.regional.center", string="Centrale régionale" + ) + packaging_id = fields.Many2one("res.partner.packaging", string="Emballage") + departure_day_ids = fields.Many2many( + comodel_name="res.partner.day", string="Jour de départ" + ) billing_type_id = fields.Many2one( - 'res.partner.billing.type', - string="Type de facturation") + "res.partner.billing.type", string="Type de facturation" + ) delivery_note = fields.Text("Commentaire pour BL") billing_note = fields.Text("Commentaire pour Facture") call_frequency_id = fields.Many2one( - 'res.partner.call.frequency', - string="Fréquence d'appel du client") + "res.partner.call.frequency", string="Fréquence d'appel du client" + ) call_day = fields.Selection( - [('lundi', 'Lundi'), - ('mardi', 'Mardi'), - ('mercredi', 'Mercredi'), - ('jeudi', 'Jeudi'), - ('vendredi', 'Vendredi'), - ('samedi', 'Samedi'), - ], string="Jour d'appel du client") + [ + ("lundi", "Lundi"), + ("mardi", "Mardi"), + ("mercredi", "Mercredi"), + ("jeudi", "Jeudi"), + ("vendredi", "Vendredi"), + ("samedi", "Samedi"), + ], + string="Jour d'appel du client", + ) customer_status_id = fields.Many2one( - 'res.partner.status', - string="Statut du client") + "res.partner.status", string="Statut du client" + ) # category_id = fields.Many2one( # 'res.partner.category', string='Catégorie') res_transporter_id = fields.Many2one( - 'res.partner.transporter', - string="Nom du transporteur" + "res.partner.transporter", string="Nom du transporteur" ) payment_method_id = fields.Many2one( - 'res.partner.payment.method', - string="Méthode de paiement" + "res.partner.payment.method", string="Méthode de paiement" ) function_ids = fields.Many2many( - comodel_name='res.partner.function', - string="Postes" + comodel_name="res.partner.function", string="Postes" ) - user2_id = fields.Many2one('res.users', string="Commercial suivi") - fumoc_category_id = fields.Many2one( - 'fumoc.category', - "Catégorie") + user2_id = fields.Many2one("res.users", string="Commercial suivi") + fumoc_category_id = fields.Many2one("fumoc.category", "Catégorie") # ------------------------------------------------------ # SQL Constraints # ------------------------------------------------------ @@ -87,64 +85,65 @@ class ResPartner(models.Model): # Business methods # ------------------------------------------------------ + class ResPartnerRegionalCenter(models.Model): - _name = 'res.partner.regional.center' - _description = 'Centrale régionale' + _name = "res.partner.regional.center" + _description = "Centrale régionale" name = fields.Char("Centrale régionale", required=True) class ResPartnerPackaging(models.Model): - _name = 'res.partner.packaging' - _description = 'Emballage' + _name = "res.partner.packaging" + _description = "Emballage" name = fields.Char("Emballage", required=True) class ResPartnerBillingType(models.Model): - _name = 'res.partner.billing.type' - _description = 'Type de facturation' + _name = "res.partner.billing.type" + _description = "Type de facturation" name = fields.Char("Type de facturation", required=True) class ResPartnerCallFrequency(models.Model): - _name = 'res.partner.call.frequency' + _name = "res.partner.call.frequency" _description = "Fréquence d'appel du client" name = fields.Char("Fréquence d'appel", required=True) class ResPartnerStatus(models.Model): - _name = 'res.partner.status' + _name = "res.partner.status" _description = "Statut du client" name = fields.Char("Statut du client", required=True) class ResPartnerPaymentMethod(models.Model): - _name = 'res.partner.payment.method' + _name = "res.partner.payment.method" _description = "Mode de paiement" name = fields.Char("Mode de paiement", required=True) class ResPartnerTransporter(models.Model): - _name = 'res.partner.transporter' + _name = "res.partner.transporter" _description = "Transporteur" name = fields.Char("Nom du transporteur", required=True) class ResPartnerDay(models.Model): - _name = 'res.partner.day' + _name = "res.partner.day" _description = "Jours de la semaine" name = fields.Char("Jour", required=True) class ResPartnerFunction(models.Model): - _name = 'res.partner.function' + _name = "res.partner.function" _description = "Poste occupé" name = fields.Char("Poste occupé", required=True) diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv old mode 100755 new mode 100644 diff --git a/views/fumoc_category_views.xml b/views/fumoc_category_views.xml index ef93c7f7ab56bb4c223cf7690016fd022e48a4a9..24f9e8d81af3daa22be871b0052a83496f98e48f 100644 --- a/views/fumoc_category_views.xml +++ b/views/fumoc_category_views.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2021 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> @@ -9,8 +9,8 @@ <field name="model">fumoc.category</field> <field name="arch" type="xml"> <search string="Catégories"> - <field name="name" string="Type"/> - <field name="parent_id"/> + <field name="name" string="Type" /> + <field name="parent_id" /> </search> </field> </record> @@ -21,11 +21,11 @@ <form class="oe_form_configuration"> <sheet> <div class="oe_title"> - <label for="name" string="Nom" class="oe_edit_only"/> + <label for="name" string="Nom" class="oe_edit_only" /> <h1><field name="name" /></h1> </div> <group name="first" col="2"> - <field name="parent_id" class="oe_inline"/> + <field name="parent_id" class="oe_inline" /> </group> </sheet> </form> @@ -37,7 +37,7 @@ <field name="priority">1</field> <field name="arch" type="xml"> <tree string="Types"> - <field name="display_name" string="Type"/> + <field name="display_name" string="Type" /> </tree> </field> </record> @@ -46,8 +46,8 @@ <field name="name">fumoc_category_action</field> <field name="type">ir.actions.act_window</field> <field name="res_model">fumoc.category</field> - <field name="search_view_id" ref="fumoc_category_search_view"/> - <field name="view_id" ref="fumoc_category_list_view"/> + <field name="search_view_id" ref="fumoc_category_search_view" /> + <field name="view_id" ref="fumoc_category_list_view" /> </record> <menuitem @@ -55,7 +55,8 @@ id="menu_fumoc_category" name="Catégories" parent="fumoc_partner.menu_fumaison_conf" - sequence="2"/> + sequence="2" + /> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/menu_views.xml b/views/menu_views.xml index 6a829486d4c465c82522c80a627ca469f3763a86..4cbd0e767b78eab8d15a2013fd957cb2c3a943b8 100644 --- a/views/menu_views.xml +++ b/views/menu_views.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2021 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> @@ -46,41 +46,68 @@ <field name="res_model">res.partner.function</field> </record> - <menuitem id="contacts.res_partner_menu_config" + <menuitem + id="contacts.res_partner_menu_config" name="Configuration" parent="contacts.menu_contacts" groups="base.group_erp_manager" - sequence="2"/> - - <menuitem id="menu_fumaison_conf" name="Conf Client" - parent="contacts.res_partner_menu_config" sequence="6"/> - - <menuitem id="menu_billing_partner" - action="action_billing_type" parent="menu_fumaison_conf" - sequence="1"/> - - <menuitem id="menu_call_frequency_partner" - action="action_call_frequency" parent="menu_fumaison_conf" - sequence="2"/> - - <menuitem id="menu_packaging_partner" - action="action_packaging" parent="menu_fumaison_conf" - sequence="3"/> - - <menuitem id="menu_regional_center_partner" - action="action_regional_center" parent="menu_fumaison_conf" - sequence="4"/> - - <menuitem id="menu_status_partner" - action="action_status" parent="menu_fumaison_conf" - sequence="5"/> - - <menuitem id="menu_transporter" - action="action_transporter" parent="menu_fumaison_conf" - sequence="6"/> - - <menuitem id="menu_function" - action="action_function" parent="menu_fumaison_conf" - sequence="7"/> + sequence="2" + /> + + <menuitem + id="menu_fumaison_conf" + name="Conf Client" + parent="contacts.res_partner_menu_config" + sequence="6" + /> + + <menuitem + id="menu_billing_partner" + action="action_billing_type" + parent="menu_fumaison_conf" + sequence="1" + /> + + <menuitem + id="menu_call_frequency_partner" + action="action_call_frequency" + parent="menu_fumaison_conf" + sequence="2" + /> + + <menuitem + id="menu_packaging_partner" + action="action_packaging" + parent="menu_fumaison_conf" + sequence="3" + /> + + <menuitem + id="menu_regional_center_partner" + action="action_regional_center" + parent="menu_fumaison_conf" + sequence="4" + /> + + <menuitem + id="menu_status_partner" + action="action_status" + parent="menu_fumaison_conf" + sequence="5" + /> + + <menuitem + id="menu_transporter" + action="action_transporter" + parent="menu_fumaison_conf" + sequence="6" + /> + + <menuitem + id="menu_function" + action="action_function" + parent="menu_fumaison_conf" + sequence="7" + /> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/res_partner_views.xml b/views/res_partner_views.xml index c8070c2c1a7ac8f524829c6c48bd4f58f9c0ef49..1b35aab99cc5d149dedca547f9daf0271e04720b 100644 --- a/views/res_partner_views.xml +++ b/views/res_partner_views.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2021 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> @@ -7,54 +7,98 @@ <record id="view_partner_form" model="ir.ui.view"> <field name="name">res.partner.form</field> <field name="model">res.partner</field> - <field name="inherit_id" ref="base.view_partner_form"/> + <field name="inherit_id" ref="base.view_partner_form" /> <field name="arch" type="xml"> <field name="type" position="before"> - <field name="is_customer"/> - <field name="is_supplier"/> - <field name="is_transporter"/> + <field name="is_customer" /> + <field name="is_supplier" /> + <field name="is_transporter" /> </field> - <xpath expr="//notebook//page[@name='sales_purchases']//group//group//field[@name='user_id']" position="after"> - <field name="user2_id"/> + <xpath + expr="//notebook//page[@name='sales_purchases']//group//group//field[@name='user_id']" + position="after" + > + <field name="user2_id" /> </xpath> - <xpath expr="//notebook//page[@name='sales_purchases']//group//group//field[@name='property_product_pricelist']" position="after"> - <field name="payment_method_id" options="{'no_create_edit': True}"/> - <field name="billing_type_id" options="{'no_create_edit': True}"/> + <xpath + expr="//notebook//page[@name='sales_purchases']//group//group//field[@name='property_product_pricelist']" + position="after" + > + <field + name="payment_method_id" + options="{'no_create_edit': True}" + /> + <field name="billing_type_id" options="{'no_create_edit': True}" /> </xpath> <field name="function" position="replace"> - <field name="function_ids" widget="many2many_tags"/> + <field name="function_ids" widget="many2many_tags" /> </field> - <xpath expr="//notebook//page[@name='contact_addresses']//field//kanban//field[@name='function']" position="replace"> - <field name="function_ids"/> + <xpath + expr="//notebook//page[@name='contact_addresses']//field//kanban//field[@name='function']" + position="replace" + > + <field name="function_ids" /> </xpath> - <xpath expr="//notebook//page[@name='contact_addresses']//field//form//sheet//group//group//field[@name='function']" position="replace"> - <field name="function_ids" attrs="{'invisible': [('type','!=', 'contact')]}" widget="many2many_tags"/> + <xpath + expr="//notebook//page[@name='contact_addresses']//field//form//sheet//group//group//field[@name='function']" + position="replace" + > + <field + name="function_ids" + attrs="{'invisible': [('type','!=', 'contact')]}" + widget="many2many_tags" + /> </xpath> <field name="team_id" position="replace"> <field name="team_id" /> </field> <xpath expr="//notebook" position="inside"> - <page string="Infos Clients" name="customer" attrs="{'invisible': [('is_customer', '!=', True)]}"> + <page + string="Infos Clients" + name="customer" + attrs="{'invisible': [('is_customer', '!=', True)]}" + > <group> <group> - <field name="regional_center_id" options="{'no_create_edit': True}"/> - <field name="packaging_id" options="{'no_create_edit': True}"/> - <field name="departure_day_ids" widget="many2many_checkboxes"/> - <field name="res_transporter_id" options="{'no_create_edit': True}"/> + <field + name="regional_center_id" + options="{'no_create_edit': True}" + /> + <field + name="packaging_id" + options="{'no_create_edit': True}" + /> + <field + name="departure_day_ids" + widget="many2many_checkboxes" + /> + <field + name="res_transporter_id" + options="{'no_create_edit': True}" + /> </group> <group> - <field name="customer_status_id" options="{'no_create_edit': True}"/> - <field name="fumoc_category_id" options="{'no_create_edit': True}"/> - <field name="call_frequency_id" options="{'no_create_edit': True}"/> - <field name="call_day"/> + <field + name="customer_status_id" + options="{'no_create_edit': True}" + /> + <field + name="fumoc_category_id" + options="{'no_create_edit': True}" + /> + <field + name="call_frequency_id" + options="{'no_create_edit': True}" + /> + <field name="call_day" /> </group> </group> <group> <group> - <field name="delivery_note"/> + <field name="delivery_note" /> </group> <group> - <field name="billing_note"/> + <field name="billing_note" /> </group> </group> </page> @@ -65,10 +109,14 @@ <record id="view_partner_simple_form" model="ir.ui.view"> <field name="name">res.partner.simplified.form.fumoc</field> <field name="model">res.partner</field> - <field name="inherit_id" ref="base.view_partner_simple_form"/> + <field name="inherit_id" ref="base.view_partner_simple_form" /> <field name="arch" type="xml"> <field name="function" position="replace"> - <field name="function_ids" widget="many2many_tags" attrs="{'invisible': [('is_company','=', True)]}"/> + <field + name="function_ids" + widget="many2many_tags" + attrs="{'invisible': [('is_company','=', True)]}" + /> </field> </field> </record> @@ -76,16 +124,21 @@ <record id="view_partner_tree" model="ir.ui.view"> <field name="name">res.partner.tree.fumoc</field> <field name="model">res.partner</field> - <field name="inherit_id" ref="base.view_partner_tree"/> + <field name="inherit_id" ref="base.view_partner_tree" /> <field name="arch" type="xml"> <field name="user_id" position="after"> - <field name="user2_id" optional="show" widget="many2one_avatar_user" domain="[('share', '=', False)]"/> + <field + name="user2_id" + optional="show" + widget="many2one_avatar_user" + domain="[('share', '=', False)]" + /> </field> <field name="state_id" position="replace"> - <field name="state_id" invisible="1"/> + <field name="state_id" invisible="1" /> </field> <field name="country_id" position="replace"> - <field name="country_id" invisible="1"/> + <field name="country_id" invisible="1" /> </field> </field> </record>