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..d4cc423ccda9db9691205c9da83307af97b2670f --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,187 @@ +env: + browser: true + es6: true + +# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 +parserOptions: + ecmaVersion: 2017 + +overrides: + - files: + - "**/*.esm.js" + parserOptions: + sourceType: module + +# Globals available in Odoo that shouldn't produce errorings +globals: + _: readonly + $: readonly + fuzzy: readonly + jQuery: readonly + moment: readonly + odoo: readonly + openerp: readonly + owl: 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..1c6434bfc2274c73d98dbf62b6de9baccdc353ce --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,127 @@ +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/|^.copier-answers.yml$|^.github/| + # Maybe reactivate this when all README files include prettier ignore tags? + ^README\.md$| + # 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 + - id: oca-fix-manifest-website + args: ["https://le-filament.com"] + - 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..dc6270e15be0c08da00e768a570f27c785d8630e --- /dev/null +++ b/.pylintrc @@ -0,0 +1,87 @@ +[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, + 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..43ea23947166ff8080219007cfae43ec54a28f8e --- /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=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 diff --git a/__init__.py b/__init__.py old mode 100755 new mode 100644 index f8a7089ea933a7ade21f775a637d381e6e53895c..a39f7c97a5af0eb47047e7bb0ff40b6127531aea --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,4 @@ # © 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import models -from . import wizard +from . import models, wizard diff --git a/__manifest__.py b/__manifest__.py old mode 100755 new mode 100644 index 3fdf794c3dc55993d93cf39f8b73ab57853cc6ee..d62ea0c485f7d83047f3d279e64a30a261118db3 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,7 +1,7 @@ { "name": "CG SCOP - Cotisations CG - Enonérations", "summary": "Gestion des exonérations CG Scop", - "version": "12.0.0.0", + "version": "14.0.1.0.0", "author": "Le Filament", "license": "AGPL-3", "application": False, @@ -24,6 +24,6 @@ "views/scop_cotisation_cg_exo_ur_notice.xml", "views/scop_instance.xml", # templates - "templates/report_scop_exo.xml" - ] + "templates/report_scop_exo.xml", + ], } diff --git a/datas/exo_ur_notice_data.xml b/datas/exo_ur_notice_data.xml index 140746fea4bc229f65052d1fad5da5165dab7c60..f58688c63b403663a8d98f1a50568bfe8b631f25 100644 --- a/datas/exo_ur_notice_data.xml +++ b/datas/exo_ur_notice_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data noupdate="1"> <record id="ur_notice_1" model="scop.cotisation.cg.exo.ur.notice"> diff --git a/datas/ir_sequence_data.xml b/datas/ir_sequence_data.xml index 3a5abd7740f8237f65bf5be81cc69b5d566684cd..206170ba899e4d21b6c3fa83766853b65599ddba 100644 --- a/datas/ir_sequence_data.xml +++ b/datas/ir_sequence_data.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2019 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> @@ -10,7 +10,7 @@ <field name="code">scop.cotisation.cg.exo</field> <field name="prefix">EXO-%(year)s-</field> <field name="padding">4</field> - <field name="company_id" ref="base.main_company"/> + <field name="company_id" ref="base.main_company" /> </record> </data> diff --git a/migration/14.0.1.0.0/post-migration.py b/migration/14.0.1.0.0/post-migration.py new file mode 100644 index 0000000000000000000000000000000000000000..75d155fd2fbc4557dc84d758c185d052cda9a54b --- /dev/null +++ b/migration/14.0.1.0.0/post-migration.py @@ -0,0 +1,67 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade # pylint: disable=W7936 + + +def scop_cotisation_cg_exo_map_values(env): + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("quarter_exo_start"), + "scop_cotisation_cg_exo", + [ + (1, "1"), + (2, "2"), + (3, "3"), + (4, "4"), + ], + table="scop_cotisation_cg_exo", + ) + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("quarter_exo_end"), + "scop_cotisation_cg_exo", + [ + (1, "1"), + (2, "2"), + (3, "3"), + (4, "4"), + ], + table="scop_cotisation_cg_exo", + ) + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("year_exo_start"), + "scop_cotisation_cg_exo", + [ + (2017, "2017"), + (2018, "2018"), + (2019, "2019"), + (2020, "2020"), + (2021, "2021"), + (2022, "2022"), + (2023, "2023"), + (2024, "2024"), + ], + table="scop_cotisation_cg_exo", + ) + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("year_exo_end"), + "scop_cotisation_cg_exo", + [ + (2017, "2017"), + (2018, "2018"), + (2019, "2019"), + (2020, "2020"), + (2021, "2021"), + (2022, "2022"), + (2023, "2023"), + (2024, "2024"), + ], + table="scop_cotisation_cg_exo", + ) + +@openupgrade.migrate() +def migrate(env, version): + scop_cotisation_cg_exo_map_values(env) diff --git a/migration/14.0.1.0.0/pre-migration.py b/migration/14.0.1.0.0/pre-migration.py new file mode 100644 index 0000000000000000000000000000000000000000..a0643181413888baf1386eb08740edcb4d88e99a --- /dev/null +++ b/migration/14.0.1.0.0/pre-migration.py @@ -0,0 +1,13 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + +column_renames = { + "scop_cotisation_cg_exo": [("quarter_exo_start", None), ("quarter_exo_end", None), ("year_exo_start", None), ("year_exo_end", None)], +} + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_columns(env.cr, column_renames) diff --git a/models/__init__.py b/models/__init__.py old mode 100755 new mode 100644 diff --git a/models/res_partner.py b/models/res_partner.py index 3d0a34619c1a8c82c5669f092742ec6b112905ff..6b61de63402d8643ecf39fee6615cbee3c328ffc 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -5,11 +5,11 @@ from odoo import fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" exo_ids = fields.One2many( - comodel_name='scop.cotisation.cg.exo', - inverse_name='partner_id', - domain=[('state', '=', 'done')], - string='Exonérations' + comodel_name="scop.cotisation.cg.exo", + inverse_name="partner_id", + domain=[("state", "=", "done")], + string="Exonérations", ) diff --git a/models/scop_bordereau.py b/models/scop_bordereau.py index 8048fb9cdebe2960b155837678a4d239bd79a59b..4905d68ffbf901e04ba197faec6c3ee1c1260d13 100644 --- a/models/scop_bordereau.py +++ b/models/scop_bordereau.py @@ -1,28 +1,26 @@ # © 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 ScopBordereau(models.Model): - _inherit = 'scop.bordereau' + _inherit = "scop.bordereau" exo_ids = fields.Many2many( - comodel_name='scop.cotisation.cg.exo', - relation='scop_bordereau_exo_rel', - column1='bordereau_id', - column2='exo_id', - string="Exonérations" + comodel_name="scop.cotisation.cg.exo", + relation="scop_bordereau_exo_rel", + column1="bordereau_id", + column2="exo_id", + string="Exonérations", ) exo_count = fields.Integer( - string='Nombre d\'exonérations', - compute='_compute_exo_count' + string="Nombre d'exonérations", compute="_compute_exo_count" ) # ------------------------------------------------------ # Compute fields # ------------------------------------------------------ - @api.multi def _compute_exo_count(self): for bdx in self: bdx.exo_count = len(bdx.exo_ids) @@ -35,12 +33,12 @@ class ScopBordereau(models.Model): Ouvre la vue sur les exonérations liées """ return { - 'type': 'ir.actions.act_window', - 'name': 'Exonérations', - 'view_mode': 'tree,form', - 'res_model': 'scop.cotisation.cg.exo', - 'target': 'current', - 'domain': [('id', 'in', self.exo_ids.ids)], + "type": "ir.actions.act_window", + "name": "Exonérations", + "view_mode": "tree,form", + "res_model": "scop.cotisation.cg.exo", + "target": "current", + "domain": [("id", "in", self.exo_ids.ids)], } # ------------------------------------------------------ diff --git a/models/scop_cotisation_cg.py b/models/scop_cotisation_cg.py index edff2592a54276e4d75590418081f467c9ffb76b..161e6c6aa3d62e15100154a1cf8adf56efc10021 100644 --- a/models/scop_cotisation_cg.py +++ b/models/scop_cotisation_cg.py @@ -10,8 +10,7 @@ class ScopCotisation(models.Model): # ------------------------------------------------------ # Override parent # ------------------------------------------------------ - def create_bordereau( - self, member, nb_quarter, liasse=None, date=False): + def create_bordereau(self, member, nb_quarter, liasse=None, date=False): """ Surcharge la fonction parente pour créer les avoirs si il y a des exonérations @@ -22,12 +21,14 @@ class ScopCotisation(models.Model): bdx_id = self.bordereau_ids.browse(bordereau) # Search if exo - exo_ids = self.env['scop.cotisation.cg.exo'].search([ - ('partner_id', '=', bdx_id.partner_id.id), - ('year_exo_start', '<=', bdx_id.year), - ('year_exo_end', '>=', bdx_id.year), - ('state', '=', 'done') - ]) + exo_ids = self.env["scop.cotisation.cg.exo"].search( + [ + ("partner_id", "=", bdx_id.partner_id.id), + ("year_exo_start", "<=", bdx_id.year), + ("year_exo_end", ">=", bdx_id.year), + ("state", "=", "done"), + ] + ) if exo_ids: for exo in exo_ids: exo.create_exo_refund(bdx_id) diff --git a/models/scop_cotisation_cg_exo.py b/models/scop_cotisation_cg_exo.py index 031f204d857effc99a0b2884c0a4a631cde40f4d..6fb3041ac6f15d283fc770a4360a16d102c046bd 100644 --- a/models/scop_cotisation_cg_exo.py +++ b/models/scop_cotisation_cg_exo.py @@ -1,234 +1,266 @@ # © 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from datetime import datetime, date +from datetime import date, datetime -from odoo import models, fields, api -from odoo.exceptions import ValidationError, UserError +from odoo import _, api, fields, models +from odoo.exceptions import UserError, ValidationError QUARTER_SELECTION = [ - (1, '1er trimestre'), - (2, '2ème trimestre'), - (3, '3ème trimestre'), - (4, '4ème trimestre') + ("1", "1er trimestre"), + ("2", "2ème trimestre"), + ("3", "3ème trimestre"), + ("4", "4ème trimestre"), ] class ScopCotisationExo(models.Model): _name = "scop.cotisation.cg.exo" _description = "Exonerations CG" - _inherit = ['mail.thread', 'mail.activity.mixin'] - _order = 'date_request desc' + _inherit = ["mail.thread", "mail.activity.mixin"] + _order = "date_request desc" @api.model def get_year_selection(self): return [ - (num, str(num)) for num in range((datetime.now().year + 3), (datetime.now().year - 10))] + (num, str(num)) + for num in range((datetime.now().year + 3), (datetime.now().year - 10)) + ] - name = fields.Char( - string='Nom', - compute='_compute_name', - search='_search_name') - number = fields.Char('Référence', readonly=1, index=True, default='New') + name = fields.Char(string="Nom", compute="_compute_name", search="_search_name") + number = fields.Char("Référence", readonly=1, index=True, default="New") partner_id = fields.Many2one( - comodel_name='res.partner', + comodel_name="res.partner", string="Coopérative", required=True, - domain=[('is_cooperative', '=', True), ('membership_status', '=', 'member')], - track_visibility='onchange') - date_request = fields.Date('Date de la demande', required=True, track_visibility='onchange') - motivation = fields.Text('Motivation de la SCOP') - source = fields.Selection([ - ('scop', 'SCOP'), - ('ur', 'UR')], + domain=[ + ("is_cooperative", "=", True), + ("membership_status", "=", "member"), + ], + tracking=1, + ) + date_request = fields.Date("Date de la demande", required=True, tracking=1) + motivation = fields.Text("Motivation de la SCOP") + source = fields.Selection( + [("scop", "SCOP"), ("ur", "UR")], string="Source", required=True, - track_visibility='onchange') - state = fields.Selection([ - ('todo', 'En cours de traitement'), - ('waiting', 'En attente présentation Instance'), - ('done', 'Traité'), - ('cancel', 'Annulé')], + tracking=1, + ) + state = fields.Selection( + [ + ("todo", "En cours de traitement"), + ("waiting", "En attente présentation Instance"), + ("done", "Traité"), + ("cancel", "Annulé"), + ], string="Statut", required=True, - default='todo', - track_visibility='onchange') - final_notice = fields.Selection([ - ('favorable', 'Favorable'), - ('unfavorable', 'Défavorable')], + default="todo", + tracking=1, + ) + final_notice = fields.Selection( + [("favorable", "Favorable"), ("unfavorable", "Défavorable")], string="Avis Final", - track_visibility='onchange') + tracking=1, + ) ur_notice = fields.Many2one( - comodel_name='scop.cotisation.cg.exo.ur.notice', + comodel_name="scop.cotisation.cg.exo.ur.notice", string="Avis UR", required=True, - track_visibility='onchange') + tracking=1, + ) quarter_exo_start = fields.Selection( - selection=QUARTER_SELECTION, - string='Trimestre initial' + selection=QUARTER_SELECTION, string="Trimestre initial" ) year_exo_start = fields.Selection( - selection=[(year, str(year)) for year in - range(2021, 2035)], - string='Année initiale' + selection=[(str(year), str(year)) for year in range(2021, 2035)], + string="Année initiale", ) quarter_exo_end = fields.Selection( - selection=QUARTER_SELECTION, - string='Trimestre final' + selection=QUARTER_SELECTION, string="Trimestre final" ) year_exo_end = fields.Selection( - selection=[(year, str(year)) for year in - range(2021, 2035)], - string='Année finale' + selection=[(str(year), str(year)) for year in range(2021, 2035)], + string="Année finale", ) date_exo_start = fields.Date( - string='Date Début Exo', - compute='_compute_exo_dates', - track_visibility='onchange', - store=True + string="Date Début Exo", + compute="_compute_exo_dates", + tracking=1, + store=True, ) date_exo_end = fields.Date( - string='Date Fin Exo', - compute='_compute_exo_dates', - track_visibility='onchange', - store=True + string="Date Fin Exo", + compute="_compute_exo_dates", + tracking=1, + store=True, ) nb_quarter = fields.Integer( - string='Nb trimestres exonérés', - compute='_compute_exo_dates', - store=True + string="Nb trimestres exonérés", + compute="_compute_exo_dates", + store=True, ) - type_exo = fields.Selection([ - ('amount', 'Montant'), - ('percent', 'Pourcentage')], + type_exo = fields.Selection( + [("amount", "Montant"), ("percent", "Pourcentage")], string="Type d'exonération", - track_visibility='onchange' - ) - amount_quarter = fields.Float('Montant souhaité pour les échéances') - percent_quarter = fields.Integer('Réduction appliquée aux échéances') - date_exo_ok = fields.Date('Date Acceptation Exo') - head_office_comment = fields.Text('Commentaire du bureau') - note = fields.Text('Notes internes') - instance_id = fields.Many2one( - comodel_name='scop.instance', - string="Instance" + tracking=1, ) + amount_quarter = fields.Float("Montant souhaité pour les échéances") + percent_quarter = fields.Integer("Réduction appliquée aux échéances") + date_exo_ok = fields.Date("Date Acceptation Exo") + head_office_comment = fields.Text("Commentaire du bureau") + note = fields.Text("Notes internes") + instance_id = fields.Many2one(comodel_name="scop.instance", string="Instance") bordereau_ids = fields.Many2many( - comodel_name='scop.bordereau', - relation='scop_bordereau_exo_rel', - column2='bordereau_id', - column1='exo_id', - string="Bordereaux" + comodel_name="scop.bordereau", + relation="scop_bordereau_exo_rel", + column2="bordereau_id", + column1="exo_id", + string="Bordereaux", ) company_id = fields.Many2one( - comodel_name='res.company', - string='Company', change_default=True, - required=True, readonly=True, - default=lambda self: self.env['res.company']._company_default_get('scop.cotisation.cg.followup')) + comodel_name="res.company", + string="Company", + change_default=True, + required=True, + readonly=True, + default=lambda self: self.env["res.company"]._company_default_get( + "scop.cotisation.cg.followup" + ), + ) exo_line_ids = fields.One2many( - comodel_name='scop.cotisation.cg.exo.line', - inverse_name='exo_id', - string='Ligne Exonération' + comodel_name="scop.cotisation.cg.exo.line", + inverse_name="exo_id", + string="Ligne Exonération", ) # ------------------------------------------------------ # Contraintes SQL # ------------------------------------------------------ - @api.constrains('date_exo_start', 'date_exo_end') + @api.constrains("date_exo_start", "date_exo_end") def _check_dates(self): for exo in self: if exo.date_exo_start and exo.date_exo_end: if exo.date_exo_start > exo.date_exo_end: raise ValidationError( - "La date de fin doit êre supérieure à la date de début d'exonération.") - intersect_exo_ids = self.search([ - ('partner_id', '=', exo.partner_id.id), - ('date_exo_end', '>=', exo.date_exo_start), - ('date_exo_start', '<=', exo.date_exo_end), - ('state', '=', 'done') - ]) + _( + "La date de fin doit êre supérieure à la " + "date de début d'exonération." + ) + ) + intersect_exo_ids = self.search( + [ + ("partner_id", "=", exo.partner_id.id), + ("date_exo_end", ">=", exo.date_exo_start), + ("date_exo_start", "<=", exo.date_exo_end), + ("state", "=", "done"), + ] + ) if intersect_exo_ids: raise ValidationError( - "Les périodes d'exonérations ne peuvent pas se chevaucher.") + _("Les périodes d'exonérations ne peuvent pas se chevaucher.") + ) - @api.constrains('percent_quarter') + @api.constrains("percent_quarter") def _check_description(self): for exo in self: if exo.percent_quarter < 0 or exo.percent_quarter > 100: raise ValidationError( - "La valeur de la réduction doit être comprise entre 1 et 100") + _("La valeur de la réduction doit être comprise entre 1 et 100") + ) # ------------------------------------------------------ # Onchange fields # ------------------------------------------------------ - @api.onchange('instance_id') + @api.onchange("instance_id") def _onchange_instance_id(self): - if self.state in ('todo', 'waiting'): + if self.state in ("todo", "waiting"): if self.instance_id: - self.state = 'waiting' + self.state = "waiting" if not self.number: prefix = 5 - len(str(self.id)) - self.number = 'EXO-' + str(datetime.now().year) + '-' + (prefix * '0') + str(self.id) + self.number = ( + "EXO-" + + str(datetime.now().year) + + "-" + + (prefix * "0") + + str(self.id) + ) else: - self.state = 'todo' + self.state = "todo" # ------------------------------------------------------ # Compute fields # ------------------------------------------------------ - @api.multi def _compute_name(self): for exo in self: - exo.name = datetime.strftime(exo.date_request, '%d/%m/%Y') + ' ' + exo.partner_id.name + exo.name = ( + datetime.strftime(exo.date_request, "%d/%m/%Y") + + " " + + exo.partner_id.name + ) @api.model def _search_name(self, operator, value): - partner_ids = self.partner_id.search([('name', operator, value)]) + partner_ids = self.partner_id.search([("name", operator, value)]) return [ - '|', - ('partner_id', 'in', partner_ids.ids), - ('date_request', operator, value), + "|", + ("partner_id", "in", partner_ids.ids), + ("date_request", operator, value), ] @api.depends( - 'quarter_exo_start', 'year_exo_start', - 'quarter_exo_end', 'year_exo_end', + "quarter_exo_start", + "year_exo_start", + "quarter_exo_end", + "year_exo_end", ) - @api.multi def _compute_exo_dates(self): for exo in self: if exo.year_exo_start and exo.quarter_exo_start: - exo.date_exo_start = date(int(exo.year_exo_start), exo.quarter_exo_start * 3 - 2, 1) + exo.date_exo_start = date( + int(exo.year_exo_start), int(exo.quarter_exo_start) * 3 - 2, 1 + ) if exo.year_exo_end and exo.quarter_exo_end: - end_day = 31 if exo.quarter_exo_end in (1, 4) else 30 - exo.date_exo_end = date(int(exo.year_exo_end), exo.quarter_exo_end * 3, end_day) + end_day = 31 if int(exo.quarter_exo_end) in (1, 4) else 30 + exo.date_exo_end = date( + int(exo.year_exo_end), int(exo.quarter_exo_end) * 3, end_day + ) if exo.date_exo_start and exo.date_exo_end: exo.nb_quarter = int( - ((exo.date_exo_end.year - exo.date_exo_start.year) * 12 + - exo.date_exo_end.month - exo.date_exo_start.month + 1) / 3) + ( + (exo.date_exo_end.year - exo.date_exo_start.year) * 12 + + exo.date_exo_end.month + - exo.date_exo_start.month + + 1 + ) + / 3 + ) # ------------------------------------------------------ # Button functions # ------------------------------------------------------ def action_view_bordereau(self): - years = list(range(self.year_exo_start, self.year_exo_end + 1)) + years = list(range(int(self.year_exo_start), int(self.year_exo_end) + 1)) return { - 'name': 'Bordereaux de cotisation - ' + self.partner_id.name, - 'type': 'ir.actions.act_window', - 'view_mode': 'tree,form', - 'res_model': 'scop.bordereau', - 'domain': [ - ('partner_id', '=', self.partner_id.id), - ('year', 'in', years), + "name": "Bordereaux de cotisation - " + self.partner_id.name, + "type": "ir.actions.act_window", + "view_mode": "tree,form", + "res_model": "scop.bordereau", + "domain": [ + ("partner_id", "=", self.partner_id.id), + ("year", "in", years), ], } def action_view_exo(self): return { - 'name': 'Bordereaux avec exonération - ' + self.partner_id.name, - 'type': 'ir.actions.act_window', - 'view_mode': 'tree,form', - 'res_model': 'scop.bordereau', - 'domain': [('id', 'in', self.bordereau_ids.ids)], + "name": "Bordereaux avec exonération - " + self.partner_id.name, + "type": "ir.actions.act_window", + "view_mode": "tree,form", + "res_model": "scop.bordereau", + "domain": [("id", "in", self.bordereau_ids.ids)], } def create_lines(self): @@ -236,99 +268,132 @@ class ScopCotisationExo(models.Model): contrib_type = self.partner_id.get_partner_contribution_type() # if exo is percent => affects percent to each line - if self.type_exo == 'percent': + if self.type_exo == "percent": for contrib in contrib_type: - self.exo_line_ids.create({ - 'exo_id': self.id, - 'contribution_id': contrib.id, - 'percent': self.percent_quarter - }) + self.exo_line_ids.create( + { + "exo_id": self.id, + "contribution_id": contrib.id, + "percent": self.percent_quarter, + } + ) # if exo is amount - if self.type_exo == 'amount': + if self.type_exo == "amount": # if various contribution type => affects prorate amount to each line if len(contrib_type) > 1: # Get last bdx for prorate calculation - last_bdx = self.env['scop.bordereau'].search([ - ('state', 'in', ['validated', 'paid']), - ('partner_id', '=', self.partner_id.id) - ], order='date_cotisation desc', limit=1) + last_bdx = self.env["scop.bordereau"].search( + [ + ("state", "in", ["validated", "paid"]), + ("partner_id", "=", self.partner_id.id), + ], + order="date_cotisation desc", + limit=1, + ) if last_bdx: last_amount = last_bdx.amount_total_cotiz amount_by_type = last_bdx.get_contribution_type() for contrib in contrib_type: for amount in amount_by_type: - if contrib.id == amount.get('type_contribution_id')[0]: - self.exo_line_ids.create({ - 'exo_id': self.id, - 'contribution_id': contrib.id, - 'amount': self.amount_quarter * amount.get('amount_total_signed') / last_amount - }) + if contrib.id == amount.get("type_contribution_id")[0]: + self.exo_line_ids.create( + { + "exo_id": self.id, + "contribution_id": contrib.id, + "amount": self.amount_quarter + * amount.get("amount_total_signed") + / last_amount, + } + ) else: for contrib in contrib_type: - self.exo_line_ids.create({ - 'exo_id': self.id, - 'contribution_id': contrib.id, - 'amount': round(self.amount_quarter / len(contrib_type), 2) - }) + self.exo_line_ids.create( + { + "exo_id": self.id, + "contribution_id": contrib.id, + "amount": round( + self.amount_quarter / len(contrib_type), 2 + ), + } + ) else: - self.exo_line_ids.create({ - 'exo_id': self.id, - 'contribution_id': contrib_type[0].id, - 'amount': self.amount_quarter - }) + self.exo_line_ids.create( + { + "exo_id": self.id, + "contribution_id": contrib_type[0].id, + "amount": self.amount_quarter, + } + ) def cancel_exo(self): - self.state = 'cancel' + self.state = "cancel" def validate_exo(self): if not self.date_exo_ok: - raise UserError("Il est nécessaire de renseigner une date d'acceptation pour valider") + raise UserError( + _("Il est nécessaire de renseigner une date d'acceptation pour valider") + ) else: # Unfavorable => nothing to do - if self.final_notice == 'unfavorable': - self.state = 'done' + if self.final_notice == "unfavorable": + self.state = "done" # Favorable - elif self.final_notice == 'favorable': - bordereau_ids = self.env['scop.bordereau'].search([ - ('partner_id', '=', self.partner_id.id), - ('year', 'in', list(range(self.year_exo_start, self.year_exo_end + 1))), - ('state', '!=', 'cancel') - ], order='year') + elif self.final_notice == "favorable": + bordereau_ids = self.env["scop.bordereau"].search( + [ + ("partner_id", "=", self.partner_id.id), + ( + "year", + "in", + list( + range( + int(self.year_exo_start), int(self.year_exo_end) + 1 + ) + ), + ), + ("state", "!=", "cancel"), + ], + order="year", + ) # If no bdx on period => nothing to do if not bordereau_ids: - self.state = 'done' + self.state = "done" else: for bdx in bordereau_ids: self.create_exo_refund(bdx) - self.state = 'done' + self.state = "done" else: - raise UserError("Il est nécessaire de renseigner un avis final pour valider") + raise UserError( + _("Il est nécessaire de renseigner un avis final pour valider") + ) def set_favorable(self): """ Button function to set exo favorable on instance tree view """ - self.final_notice = 'favorable' + self.final_notice = "favorable" def set_unfavorable(self): """ Button function to set exo unfavorable on instance tree view """ - self.final_notice = 'unfavorable' + self.final_notice = "unfavorable" # ------------------------------------------------------ # Override ORM # ------------------------------------------------------ @api.model def create(self, vals): - if vals.get('number', 'New' == 'New'): - vals['number'] = self.env['ir.sequence'].next_by_code('scop.cotisation.cg.exo') or 'New' + if vals.get("number", "New" == "New"): + vals["number"] = ( + self.env["ir.sequence"].next_by_code("scop.cotisation.cg.exo") or "New" + ) result = super(ScopCotisationExo, self).create(vals) return result @@ -342,15 +407,17 @@ class ScopCotisationExo(models.Model): """ quarters = {} if self.year_exo_start == self.year_exo_end: - quarters[str(self.year_exo_start)] = range(self.quarter_exo_start, self.quarter_exo_end + 1) + quarters[self.year_exo_start] = range( + int(self.quarter_exo_start), int(self.quarter_exo_end) + 1 + ) else: - for year in range(self.year_exo_start, self.year_exo_end + 1): - if year == self.year_exo_start: - quarters[str(year)] = list(range(self.quarter_exo_start, 5)) - elif year == self.year_exo_end: - quarters[str(year)] = list(range(1, self.quarter_exo_end + 1)) + for year in range(int(self.year_exo_start), int(self.year_exo_end) + 1): + if year == int(self.year_exo_start): + quarters[year] = list(range(int(self.quarter_exo_start), 5)) + elif year == int(self.year_exo_end): + quarters[year] = list(range(1, int(self.quarter_exo_end) + 1)) else: - quarters[str(year)] = list(range(1, 5)) + quarters[year] = list(range(1, 5)) return quarters def create_exo_refund(self, bordereau_id): @@ -361,17 +428,19 @@ class ScopCotisationExo(models.Model): bordereau_id.ensure_one() # Create version - if bordereau_id.state != 'new': - self.env['scop.bordereau.version'].create({ - 'bordereau_id': bordereau_id.id, - 'date': self.date_exo_ok, - 'comment': "Exonération", - 'version': bordereau_id.version, - 'liasse_fiscale_id_old': bordereau_id.liasse_fiscale_id.id, - 'type_assiette': bordereau_id.type_assiette, - 'montant_assiette': bordereau_id.montant_assiette, - 'amount_total_cotiz': bordereau_id.amount_total_cotiz, - }) + if bordereau_id.state != "new": + self.env["scop.bordereau.version"].create( + { + "bordereau_id": bordereau_id.id, + "date": self.date_exo_ok, + "comment": "Exonération", + "version": bordereau_id.version, + "liasse_fiscale_id_old": bordereau_id.liasse_fiscale_id.id, + "type_assiette": bordereau_id.type_assiette, + "montant_assiette": bordereau_id.montant_assiette, + "amount_total_cotiz": bordereau_id.amount_total_cotiz, + } + ) exo_quarters = self.get_quarters() # check exo period @@ -381,58 +450,73 @@ class ScopCotisationExo(models.Model): for quarter in exo_period: # Get all invoices on specific quarter amount_period = bordereau_id.invoice_ids.read_group( - [('bordereau_id', '=', bordereau_id.id), ('cotiz_quarter', '=', quarter)], - ['type_contribution_id', 'amount_total_signed'], - ['type_contribution_id']) - - # Get bdx schedule - base_cotiz = bordereau_id.base_cotisation_cg - bdx_quarters = [base_cotiz.trimester_1, base_cotiz.trimester_2, - base_cotiz.trimester_3, base_cotiz.trimester_4] + [ + ("bordereau_id", "=", bordereau_id.id), + ("cotiz_quarter", "=", quarter), + ], + ["type_contribution_id", "amount_total_signed"], + ["type_contribution_id"], + ) # Contribution type loop for amount_type in amount_period: - inv_type = amount_type.get('type_contribution_id')[0] - inv_amount = amount_type.get('amount_total_signed') + inv_type = amount_type.get("type_contribution_id")[0] + inv_amount = amount_type.get("amount_total_signed") # Get invoice on this type (for refund creation) - inv_id = bordereau_id.invoice_ids.filtered(lambda i: i.type_contribution_id.id == inv_type)[0] + inv_id = bordereau_id.invoice_ids.filtered( + lambda i: i.type_contribution_id.id == inv_type + )[0] - exo_line_id = self.exo_line_ids.filtered(lambda l: l.contribution_id.id == inv_type) + exo_line_id = self.exo_line_ids.filtered( + lambda l: l.contribution_id.id == inv_type + ) - if self.type_exo == 'percent': + if self.type_exo == "percent": exo_amount = round(inv_amount * (1 - exo_line_id.percent / 100), 2) - elif self.type_exo == 'amount': + elif self.type_exo == "amount": exo_amount = round(inv_amount - exo_line_id.amount, 2) else: - raise UserError("Erreur, le type d'exonération n'est pas configuré") + raise UserError( + _("Erreur, le type d'exonération n'est pas configuré") + ) if exo_amount != 0: - date_refund = bordereau_id.date_cotisation if bordereau_id.state == 'draft' else self.date_exo_ok + date_refund = ( + bordereau_id.date_cotisation + if bordereau_id.state == "draft" + else self.date_exo_ok + ) # Create refund - member_refund = bordereau_id.invoice_ids.create({ - 'partner_id': bordereau_id.partner_id.id, - 'liasse_fiscale_id': bordereau_id.liasse_fiscale_id.id, - 'type': 'out_refund', - 'year': bordereau_id.year, - 'is_contribution': True, - 'type_contribution_id': inv_type, - 'journal_id': inv_id.journal_id.id, - 'state': 'draft', - 'account_id': inv_id.account_id.id, - 'payment_mode_id': bordereau_id.payment_mode_id.id, - 'date_invoice': date_refund, - 'date_due': self.date_exo_ok, - 'bordereau_id': bordereau_id.id, - 'cotiz_quarter': quarter, - 'refund_invoice_id': inv_id.id, - 'name': 'Exonération ' + self.number - }) - member_refund.invoice_line_ids.create({ - 'invoice_id': member_refund.id, - 'product_id': inv_id.invoice_line_ids[0].product_id.id, - 'account_id': inv_id.invoice_line_ids[0].account_id.id, - 'name': inv_id.invoice_line_ids[0].product_id.name + " T" + str(quarter), - 'price_unit': exo_amount - }) + member_refund = bordereau_id.invoice_ids.create( + { + "partner_id": bordereau_id.partner_id.id, + "liasse_fiscale_id": bordereau_id.liasse_fiscale_id.id, + "type": "out_refund", + "year": bordereau_id.year, + "is_contribution": True, + "type_contribution_id": inv_type, + "journal_id": inv_id.journal_id.id, + "state": "draft", + "account_id": inv_id.account_id.id, + "payment_mode_id": bordereau_id.payment_mode_id.id, + "date_invoice": date_refund, + "date_due": self.date_exo_ok, + "bordereau_id": bordereau_id.id, + "cotiz_quarter": quarter, + "refund_invoice_id": inv_id.id, + "name": "Exonération " + self.number, + } + ) + member_refund.invoice_line_ids.create( + { + "invoice_id": member_refund.id, + "product_id": inv_id.invoice_line_ids[0].product_id.id, + "account_id": inv_id.invoice_line_ids[0].account_id.id, + "name": inv_id.invoice_line_ids[0].product_id.name + + " T" + + str(quarter), + "price_unit": exo_amount, + } + ) # Update link exo - bordereau - self.update({'bordereau_ids': [(4, bordereau_id.id)]}) + self.update({"bordereau_ids": [(4, bordereau_id.id)]}) diff --git a/models/scop_cotisation_cg_exo_line.py b/models/scop_cotisation_cg_exo_line.py index 4ba250cfd8f4b37b51ad8c5093235fca03810e76..bb1854db38c7a0c26e3348f22720b04ea0508086 100644 --- a/models/scop_cotisation_cg_exo_line.py +++ b/models/scop_cotisation_cg_exo_line.py @@ -1,10 +1,8 @@ # © 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from datetime import datetime, date -from odoo import models, fields, api -from odoo.exceptions import ValidationError, UserError +from odoo import fields, models class ScopCotisationExoLine(models.Model): @@ -13,20 +11,18 @@ class ScopCotisationExoLine(models.Model): _order = "create_date desc, contribution_id" exo_id = fields.Many2one( - comodel_name='scop.cotisation.cg.exo', + comodel_name="scop.cotisation.cg.exo", string="Exonération", - required=True) + required=True, + ) contribution_id = fields.Many2one( - comodel_name='scop.contribution.type', - required=True + comodel_name="scop.contribution.type", required=True ) - amount = fields.Float('Montant souhaité') - percent = fields.Integer('% réduction') - type_exo = fields.Selection([ - ('amount', 'Montant'), - ('percent', 'Pourcentage')], + amount = fields.Float("Montant souhaité") + percent = fields.Integer("% réduction") + type_exo = fields.Selection( string="Type d'exonération", - related='exo_id.type_exo' + related="exo_id.type_exo", ) # ------------------------------------------------------ diff --git a/models/scop_cotisation_cg_exo_ur_notice.py b/models/scop_cotisation_cg_exo_ur_notice.py index 704a0ae0ace46e57e3941c071a76dbb6236a3f48..3885a6034d87b5937af2b6e51c916dd2f36f45e3 100644 --- a/models/scop_cotisation_cg_exo_ur_notice.py +++ b/models/scop_cotisation_cg_exo_ur_notice.py @@ -1,12 +1,12 @@ # © 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import fields, models class ScopCotisationExoUrNotice(models.Model): _name = "scop.cotisation.cg.exo.ur.notice" _description = "Exonerations - Avis UR" - _order = 'name' + _order = "name" - name = fields.Char(string='Nom', required=True) + name = fields.Char(string="Nom", required=True) diff --git a/models/scop_instance.py b/models/scop_instance.py index 16ef1f34f702586282f13074bc2ced8ed2495f72..f414e0d7a282b43d71325818634e44917cf7043b 100644 --- a/models/scop_instance.py +++ b/models/scop_instance.py @@ -1,32 +1,30 @@ # © 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -import logging -from datetime import timedelta -from odoo import models, fields, api -from odoo.exceptions import UserError, ValidationError +from odoo import fields, models class ScopInstance(models.Model): _inherit = "scop.instance" - is_type_exo = fields.Boolean("Exonérations") + is_type_exo = fields.Boolean("Activer Exonérations") exo_ids = fields.One2many( comodel_name="scop.cotisation.cg.exo", inverse_name="instance_id", - string="Exonérations" + string="Exonérations", + ) + all_exo_validated = fields.Boolean( + compute="_compute_all_exo_validated", default=False ) - all_exo_validated = fields.Boolean(compute="_compute_all_exo_validated", default=False) # ------------------------------------------------------ # Computed fields / Search Fields # ------------------------------------------------------ - @api.multi def _compute_all_exo_validated(self): for instance in self: - exo_states = instance.exo_ids.mapped('state') - if not list(set(exo_states) - set(['done', 'cancel'])): + exo_states = instance.exo_ids.mapped("state") + if not list(set(exo_states) - {"done", "cancel"}): instance.all_exo_validated = True else: instance.all_exo_validated = False @@ -36,9 +34,9 @@ class ScopInstance(models.Model): # ------------------------------------------------------ def scop_valid_exo(self): for exo in self.exo_ids: - if exo.state not in ['done', 'cancel']: + if exo.state not in ["done", "cancel"]: if not exo.date_exo_ok: exo.date_exo_ok = fields.Date.to_date(self.date) if not exo.final_notice: - exo.final_notice = 'favorable' + exo.final_notice = "favorable" exo.validate_exo() diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv old mode 100755 new mode 100644 diff --git a/security/security_rules.xml b/security/security_rules.xml index bb9909943d87f3a338714fcf1c66b3c9c13afa5b..0dbebc36c1503a7adca20bc4ee96ea8b5ae69c12 100644 --- a/security/security_rules.xml +++ b/security/security_rules.xml @@ -1,12 +1,14 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data noupdate="1"> <record id="invoice_comp_rule" model="ir.rule"> <field name="name">CG Scop - Cotisation - Exonérations multi-company</field> - <field name="model_id" ref="model_scop_cotisation_cg_exo"/> - <field name="global" eval="True"/> - <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> + <field name="model_id" ref="model_scop_cotisation_cg_exo" /> + <field name="global" eval="True" /> + <field + name="domain_force" + >['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> </record> </data> </odoo> diff --git a/static/description/icon.png b/static/description/icon.png old mode 100755 new mode 100644 index 82ef47760a441cf229b5009f0a18ccf3842fbfa5..499652a2c9c0307f875bafc145b6fbafa133da72 Binary files a/static/description/icon.png and b/static/description/icon.png differ diff --git a/templates/report_scop_exo.xml b/templates/report_scop_exo.xml index d750ebad933c8008a9f0516752febbb92aebac3b..9178adfffdd12c9957d879952eb78bd95a71cc5b 100644 --- a/templates/report_scop_exo.xml +++ b/templates/report_scop_exo.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> @@ -9,12 +9,24 @@ <div class="row"> <div class="col-6 offset-6 mt64 mb64"> - <span t-field="o.partner_id.name" style="text-transform: uppercase; font-weight: 600;"/><br/> - <span t-field="o.partner_id.street" /><br/> - <t t-if="o.partner_id.street2"><span t-field="o.partner_id.street2"/><br/></t> - <t t-if="o.partner_id.street3"><span t-field="o.partner_id.street3"/><br/></t> - <span t-field="o.partner_id.zip" /> <span t-field="o.partner_id.city" style="text-transform: uppercase;"/> - <t t-if="o.partner_id.cedex"> <span t-field="o.partner_id.cedex"/></t> + <span + t-field="o.partner_id.name" + style="text-transform: uppercase; font-weight: 600;" + /><br /> + <span t-field="o.partner_id.street" /><br /> + <t t-if="o.partner_id.street2"><span + t-field="o.partner_id.street2" + /><br /></t> + <t t-if="o.partner_id.street3"><span + t-field="o.partner_id.street3" + /><br /></t> + <span t-field="o.partner_id.zip" /> <span + t-field="o.partner_id.city" + style="text-transform: uppercase;" + /> + <t t-if="o.partner_id.cedex"> <span + t-field="o.partner_id.cedex" + /></t> </div> </div> <div class="row"> @@ -27,11 +39,16 @@ <div class="row"> <div class="col-12 mb32"> <p> - Paris, le <span t-esc="o.date_exo_ok" t-options="{'widget': 'date', 'format': 'd MMMM YYYY'}"/> + Paris, le <span + t-esc="o.date_exo_ok" + t-options="{'widget': 'date', 'format': 'd MMMM YYYY'}" + /> </p> <p> - N° adhérent : <t t-esc="str(o.partner_id.member_number_int)"/><br/> - N° exonération : <span t-esc="o.number"/> + N° adhérent : <t + t-esc="str(o.partner_id.member_number_int)" + /><br /> + N° exonération : <span t-esc="o.number" /> </p> </div> </div> @@ -40,30 +57,46 @@ <p class="mb32">Cher Coopérateur,</p> <!-- Avis Favorable--> <t t-if="o.final_notice == 'favorable'"> - <p>Pour faire suite à votre dernier courrier, Le Bureau de la Direction Nationale qui s’est réuni le<span t-esc="o.instance_id.date" t-options="{'widget': 'date', 'format': 'd MMMM YYYY'}"/> a décidé de vous accorder une exonération exceptionnelle de vos cotisations confédérales.</p> + <p + >Pour faire suite à votre dernier courrier, Le Bureau de la Direction Nationale qui s’est réuni le<span + t-esc="o.instance_id.date" + t-options="{'widget': 'date', 'format': 'd MMMM YYYY'}" + /> a décidé de vous accorder une exonération exceptionnelle de vos cotisations confédérales.</p> <p> Le Bureau prend donc acte des modalités suivantes : </p> <p style="padding: 15px;"> <!-- Exonération totale--> - <t t-if="(o.type_exo == 'percent' and o.percent_quarter == 100) or (o.type_exo == 'amount' and o.amount_quarter == 0)"> + <t + t-if="(o.type_exo == 'percent' and o.percent_quarter == 100) or (o.type_exo == 'amount' and o.amount_quarter == 0)" + > Exonération totale des cotisations pour la période du </t> <t t-else=""> <!-- Réduction des échéances--> <t t-if="o.type_exo == 'percent'"> - Exonération de <span t-field="o.percent_quarter"/>% du montant des échéances trimestrielles sur la période du + Exonération de <span + t-field="o.percent_quarter" + />% du montant des échéances trimestrielles sur la période du </t> <!-- Montant fixe des échéances--> <t t-if="o.type_exo == 'amount'"> - Un montant des prochaines échéances fixé à <span t-field="o.amount_quarter"/>€ pour la période du + Un montant des prochaines échéances fixé à <span + t-field="o.amount_quarter" + />€ pour la période du </t> </t> <strong> - <t t-if="o.nb_quarter == 1"><span t-field="o.quarter_exo_start"/> <span t-field="o.year_exo_start"/>.</t> + <t t-if="o.nb_quarter == 1"><span + t-field="o.quarter_exo_start" + /> <span t-field="o.year_exo_start" />.</t> <t t-else=""> - <span t-field="o.quarter_exo_start"/> <span t-field="o.year_exo_start"/> au <span t-field="o.quarter_exo_end"/> <span t-field="o.year_exo_end"/>. + <span t-field="o.quarter_exo_start" /> <span + t-field="o.year_exo_start" + /> au <span + t-field="o.quarter_exo_end" + /> <span t-field="o.year_exo_end" />. </t> </strong> </p> @@ -71,16 +104,21 @@ <!-- Avis Défavorable--> <t t-if="o.final_notice == 'unfavorable'"> - <p>Pour faire suite à votre dernier courrier, Le Bureau de la Direction Nationale qui s’est réuni le<span t-esc="o.instance_id.date" t-options="{'widget': 'date', 'format': 'd MMMM YYYY'}"/> a décidé de ne pas accorder d'exonération exceptionnelle de vos cotisations confédérales pour la raison suivante : </p> + <p + >Pour faire suite à votre dernier courrier, Le Bureau de la Direction Nationale qui s’est réuni le<span + t-esc="o.instance_id.date" + t-options="{'widget': 'date', 'format': 'd MMMM YYYY'}" + /> a décidé de ne pas accorder d'exonération exceptionnelle de vos cotisations confédérales pour la raison suivante : </p> <p> - <t t-esc="o.head_office_comment"/> + <t t-esc="o.head_office_comment" /> </p> </t> - <p>Je vous prie de croire, cher Coopérateur, en l’assurance de toute ma considération coopérative.</p> + <p + >Je vous prie de croire, cher Coopérateur, en l’assurance de toute ma considération coopérative.</p> <p>Le Président</p> <p>Jacques LANDRIOT</p> - <p>Copie : <t t-esc="o.partner_id.ur_id.name"/></p> + <p>Copie : <t t-esc="o.partner_id.ur_id.name" /></p> </div> </div> </div> @@ -89,22 +127,24 @@ <template id="report_exo"> <t t-call="web.html_container"> - <t t-set="docs" t-value="docs.with_context(lang='fr')"/> + <t t-set="docs" t-value="docs.with_context(lang='fr')" /> <t t-foreach="docs" t-as="o"> - <t t-call="cgscop_cotisation_cg_exo.report_exo_coop_document" t-lang="fr"/> + <t + t-call="cgscop_cotisation_cg_exo.report_exo_coop_document" + t-lang="fr" + /> </t> </t> </template> <!-- QWeb Reports --> - <report - id="cgscop_exo_report" - model="scop.cotisation.cg.exo" - string="Courrier d'exonération" - report_type="qweb-pdf" - name="cgscop_cotisation_cg_exo.report_exo" - file="cgscop_cotisation_cg_exo.report_exo" - /> + <record id="cgscop_exo_report" model="ir.actions.report"> + <field name="name">Courrier d'exonération</field> + <field name="model">scop.cotisation.cg.exo</field> + <field name="report_type">qweb-pdf</field> + <field name="report_name">cgscop_cotisation_cg_exo.report_exo</field> + <field name="report_file">cgscop_cotisation_cg_exo.report_exo</field> + </record> </data> </odoo> diff --git a/views/res_partner.xml b/views/res_partner.xml index 1d3c1fffc8911bfe989e43e240f576b2036d8af2..eebc325a007a4193e392a69092cbfb1e5b9cb500 100644 --- a/views/res_partner.xml +++ b/views/res_partner.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,44 +7,59 @@ <record id="scop_contact_view_form_inherit" model="ir.ui.view"> <field name="name">scop.contact.view.form.inherit</field> <field name="model">res.partner</field> - <field name="inherit_id" ref="cgscop_partner.scop_contact_view_form"/> + <field name="inherit_id" ref="cgscop_partner.scop_contact_view_form" /> <field name="arch" type="xml"> <xpath expr="//page[@name='contribution']" position="after"> - <page name='scop_exo' string="Exonérations" attrs="{'invisible': ['|', ('is_cooperative', '!=', True), ('project_status', '!=', '6_suivi')]}"> + <page + name='scop_exo' + string="Exonérations" + attrs="{'invisible': ['|', ('is_cooperative', '!=', True), ('project_status', '!=', '6_suivi')]}" + > <field name="exo_ids" mode="tree,form" readonly="1"> - <tree create="false" edit="false" delete="false" default_order="date desc"> - <field name="date_request"/> - <field name="source"/> - <field name="date_exo_start"/> - <field name="date_exo_end"/> - <field name="ur_notice"/> - <field name="final_notice"/> - <field name="date_exo_ok"/> + <tree + create="false" + edit="false" + delete="false" + default_order="date desc" + > + <field name="date_request" /> + <field name="source" /> + <field name="date_exo_start" /> + <field name="date_exo_end" /> + <field name="ur_notice" /> + <field name="final_notice" /> + <field name="date_exo_ok" /> </tree> <form> <group string="Demande initiale"> <group name="request"> - <field name="date_request"/> - <field name="source"/> - <field name="ur_notice" options="{'no_create': True, 'no_open': True}"/> + <field name="date_request" /> + <field name="source" /> + <field + name="ur_notice" + options="{'no_create': True, 'no_open': True}" + /> </group> <group> - <field name="date_exo_start"/> - <field name="date_exo_end"/> + <field name="date_exo_start" /> + <field name="date_exo_end" /> </group> </group> - <strong><label for="motivation"/></strong> - <field name="motivation" placeholder=""/> + <strong><label for="motivation" /></strong> + <field name="motivation" placeholder="" /> <group string="Bureau"> <group> - <field name="date_exo_ok"/> + <field name="date_exo_ok" /> </group> <group> - <field name="final_notice"/> + <field name="final_notice" /> </group> </group> - <strong><label for="head_office_comment"/></strong> - <field name="head_office_comment" placeholder="Commentaire du bureau"/> + <strong><label for="head_office_comment" /></strong> + <field + name="head_office_comment" + placeholder="Commentaire du bureau" + /> </form> </field> </page> @@ -52,4 +67,4 @@ </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/scop_bordereau_cg.xml b/views/scop_bordereau_cg.xml index 8ffb2463b3805a7130d83157b7f9b3b4c58e0e27..1d087e9b86c35c04a8102d9f40a61ca6cb450169 100644 --- a/views/scop_bordereau_cg.xml +++ b/views/scop_bordereau_cg.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> @@ -8,15 +8,28 @@ <record id="scop_bordereau_exo_form_view" model="ir.ui.view"> <field name="name">scop.bordereau.exo.form</field> <field name="model">scop.bordereau</field> - <field name="inherit_id" ref="cgscop_cotisation_cg.scop_bordereau_form_view"/> + <field + name="inherit_id" + ref="cgscop_cotisation_cg.scop_bordereau_form_view" + /> <field name="arch" type="xml"> <xpath expr="//button[@name='action_show_cotiz']" position="after"> - <button name="action_show_exo" type="object" class="oe_stat_button" icon="fa-list" attrs="{'invisible':[('exo_count','=',0)]}"> - <field string="Exonération(s)" name="exo_count" widget="statinfo"/> + <button + name="action_show_exo" + type="object" + class="oe_stat_button" + icon="fa-list" + attrs="{'invisible':[('exo_count','=',0)]}" + > + <field + string="Exonération(s)" + name="exo_count" + widget="statinfo" + /> </button> </xpath> </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/scop_cotisation_cg_exo.xml b/views/scop_cotisation_cg_exo.xml index 6a6f9807e0177d4f1d36866ee651d09215fd20bf..b817db03e198999a356012f07842bec0269b425e 100644 --- a/views/scop_cotisation_cg_exo.xml +++ b/views/scop_cotisation_cg_exo.xml @@ -1,7 +1,6 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2019 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> @@ -11,19 +10,47 @@ <field name="model">scop.cotisation.cg.exo</field> <field name="arch" type="xml"> <search string="Exonerations"> - <field name="partner_id"/> - <field name="name"/> - <field name="date_request"/> - <separator/> - <filter name="on_going" domain="[('state', 'in', ('todo', 'waiting'))]" string="En cours de traitement"/> - <filter name="is_done" domain="[('state', '=', 'done')]" string="Traité"/> - <filter name="is_cancel" domain="[('state', '=', 'cancel')]" string="Annulé"/> - <separator/> - <filter name="is_favorable" domain="[('final_notice', '=', 'favorable')]" string="Favorable"/> - <filter name="is_unfavorable" domain="[('final_notice', '=', 'unfavorable')]" string="Défavorable"/> + <field name="partner_id" /> + <field name="name" /> + <field name="date_request" /> + <separator /> + <filter + name="on_going" + domain="[('state', 'in', ('todo', 'waiting'))]" + string="En cours de traitement" + /> + <filter + name="is_done" + domain="[('state', '=', 'done')]" + string="Traité" + /> + <filter + name="is_cancel" + domain="[('state', '=', 'cancel')]" + string="Annulé" + /> + <separator /> + <filter + name="is_favorable" + domain="[('final_notice', '=', 'favorable')]" + string="Favorable" + /> + <filter + name="is_unfavorable" + domain="[('final_notice', '=', 'unfavorable')]" + string="Défavorable" + /> <group expand="0" name="group_by" string="Group By"> - <filter name="group_state" string="Statut" context="{'group_by' : 'state'}"/> - <filter name="group_instance_id" string="Instance" context="{'group_by': 'instance_id'}"/> + <filter + name="group_state" + string="Statut" + context="{'group_by' : 'state'}" + /> + <filter + name="group_instance_id" + string="Instance" + context="{'group_by': 'instance_id'}" + /> </group> </search> </field> @@ -35,12 +62,12 @@ <field name="model">scop.cotisation.cg.exo</field> <field name="arch" type="xml"> <tree string="Exonerations"> - <field name="date_request"/> - <field name="partner_id"/> - <field name="state"/> - <field name="date_exo_start"/> - <field name="date_exo_end"/> - <field name="final_notice"/> + <field name="date_request" /> + <field name="partner_id" /> + <field name="state" /> + <field name="date_exo_start" /> + <field name="date_exo_end" /> + <field name="final_notice" /> </tree> </field> </record> @@ -53,75 +80,185 @@ <field name="arch" type="xml"> <form string="Exonerations"> <header> - <button name="validate_exo" type="object" string="Valider l'exonération" class="oe_highlight" confirm="Êtes-vous certain(e) de vouloir valider cette exonération ?" attrs="{'invisible': [('state', '!=', 'waiting')]}"/> - <button name="cancel_exo" type="object" string="Annuler" confirm="Êtes-vous certain(e) de vouloir annuler cette exonération ?" attrs="{'invisible': [('state', '=', 'cancel')]}"/> - <field name="state" widget="statusbar" readonly="1" force_save="1" /> + <button + name="validate_exo" + type="object" + string="Valider l'exonération" + class="oe_highlight" + confirm="Êtes-vous certain(e) de vouloir valider cette exonération ?" + attrs="{'invisible': [('state', '!=', 'waiting')]}" + /> + <button + name="cancel_exo" + type="object" + string="Annuler" + confirm="Êtes-vous certain(e) de vouloir annuler cette exonération ?" + attrs="{'invisible': [('state', '=', 'cancel')]}" + /> + <field + name="state" + widget="statusbar" + readonly="1" + force_save="1" + /> </header> <sheet> <div class="oe_button_box" name="button_box"> - <button name="action_view_bordereau" type="object" icon="fa-files-o" attrs="{'invisible': [('state', '=', 'done')]}" string="Borderaux en cours"/> - <button name="action_view_exo" type="object" class="oe_stat_button" icon="fa-list" attrs="{'invisible': [('state', '!=', 'done')]}" string="Bordereaux Exonérés"/> + <button + name="action_view_bordereau" + type="object" + icon="fa-files-o" + attrs="{'invisible': [('state', '=', 'done')]}" + string="Borderaux en cours" + /> + <button + name="action_view_exo" + type="object" + class="oe_stat_button" + icon="fa-list" + attrs="{'invisible': [('state', '!=', 'done')]}" + string="Bordereaux Exonérés" + /> </div> - <label for="partner_id" string="Coopérative"/> - <h1><field name="partner_id" options="{'no_create': True}"/></h1> - <label for="number" string="Référence de l'exonération"/> - <h3><field name="number"/></h3> + <label for="partner_id" string="Coopérative" /> + <h1><field + name="partner_id" + options="{'no_create': True}" + /></h1> + <label for="number" string="Référence de l'exonération" /> + <h3><field name="number" /></h3> <group string="Demande initiale"> <group name="request"> - <field name="date_request"/> - <field name="source"/> + <field name="date_request" /> + <field name="source" /> </group> <group> - <field name="ur_notice" options="{'no_create': True, 'no_open': True}"/> + <field + name="ur_notice" + options="{'no_create': True, 'no_open': True}" + /> </group> </group> - <strong><label for="motivation"/></strong> - <field name="motivation" placeholder=""/> + <strong><label for="motivation" /></strong> + <field name="motivation" placeholder="" /> <group string="Données de calcul"> <group> - <label for="quarter_exo_start" string="Début de l'exonération"/> + <label + for="quarter_exo_start" + string="Début de l'exonération" + /> <div> - <field name="quarter_exo_start" class="oe_inline" style="margin-right: 20px;" required="1"/> - <field name="year_exo_start" class="oe_inline" required="1"/> + <field + name="quarter_exo_start" + class="oe_inline" + style="margin-right: 20px;" + required="1" + /> + <field + name="year_exo_start" + class="oe_inline" + required="1" + /> </div> - <label for="quarter_exo_end" string="Fin de l'exonération"/> + <label + for="quarter_exo_end" + string="Fin de l'exonération" + /> <div> - <field name="quarter_exo_end" class="oe_inline" style="margin-right: 20px;" required="1"/> - <field name="year_exo_end" class="oe_inline" required="1"/> + <field + name="quarter_exo_end" + class="oe_inline" + style="margin-right: 20px;" + required="1" + /> + <field + name="year_exo_end" + class="oe_inline" + required="1" + /> </div> - <separator></separator> - <field name="date_exo_start"/> - <field name="date_exo_end"/> - <field name="nb_quarter"/> + <separator /> + <field name="date_exo_start" /> + <field name="date_exo_end" /> + <field name="nb_quarter" /> </group> <group> - <field name="type_exo"/> - <div class="alert alert-light oe_edit_only" role="alert" colspan="2" attrs="{'invisible': [('type_exo', '!=', 'amount')]}"> - Le montant saisi dans le champ ci-dessous correspond au <strong>montant de l'échéanche souhaité</strong> pour les échéances exonérées. + <field name="type_exo" /> + <div + class="alert alert-light oe_edit_only" + role="alert" + colspan="2" + attrs="{'invisible': [('type_exo', '!=', 'amount')]}" + > + Le montant saisi dans le champ ci-dessous correspond au <strong + >montant de l'échéanche souhaité</strong> pour les échéances exonérées. </div> - <field name="amount_quarter" attrs="{'invisible': [('type_exo', '!=', 'amount')]}"/> + <field + name="amount_quarter" + attrs="{'invisible': [('type_exo', '!=', 'amount')]}" + /> - <div class="alert alert-light oe_edit_only" role="alert" colspan="2" attrs="{'invisible': [('type_exo', '!=', 'percent')]}"> - Le nombre saisi dans le champ ci-dessous correspond au <strong>pourcentage de réduction</strong> appliqué aux échéances. + <div + class="alert alert-light oe_edit_only" + role="alert" + colspan="2" + attrs="{'invisible': [('type_exo', '!=', 'percent')]}" + > + Le nombre saisi dans le champ ci-dessous correspond au <strong + >pourcentage de réduction</strong> appliqué aux échéances. </div> - <field name="percent_quarter" attrs="{'invisible': [('type_exo', '!=', 'percent')]}"/> - <button name="create_lines" type="object" class="btn btn-info" string="Créer/Mettre à jour les lignes" - attrs="{'invisible': ['|', '|', ('state', 'in', ('done', 'cancel')), '&', ('amount_quarter', '<', 0), ('type_exo', '=', 'amount'), '&', ('percent_quarter', '=', 0), ('type_exo', '=', 'percent')]}"/> + <field + name="percent_quarter" + attrs="{'invisible': [('type_exo', '!=', 'percent')]}" + /> + <button + name="create_lines" + type="object" + class="btn btn-info" + string="Créer/Mettre à jour les lignes" + attrs="{'invisible': ['|', '|', ('state', 'in', ('done', 'cancel')), '&', ('amount_quarter', '<', 0), ('type_exo', '=', 'amount'), '&', ('percent_quarter', '=', 0), ('type_exo', '=', 'percent')]}" + /> <div colspan="2"> - <field name="exo_line_ids" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}"> + <field + name="exo_line_ids" + attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}" + > <tree create="0" delete="0" editable="top"> - <field name="type_exo" invisible="1"/> - <field name="contribution_id" readonly="1" string="Type de cotisation" options="{'no_open': True}"/> - <field name="amount" attrs="{'readonly': [('type_exo', '!=', 'amount')], 'invisible': [('type_exo', '!=', 'amount')]}" sum="Total"/> - <field name="percent" attrs="{'readonly': [('type_exo', '!=', 'percent')], 'invisible': [('type_exo', '!=', 'percent')]}"/> + <field name="type_exo" invisible="1" /> + <field + name="contribution_id" + readonly="1" + string="Type de cotisation" + options="{'no_open': True}" + /> + <field + name="amount" + attrs="{'readonly': [('type_exo', '!=', 'amount')], 'invisible': [('type_exo', '!=', 'amount')]}" + sum="Total" + /> + <field + name="percent" + attrs="{'readonly': [('type_exo', '!=', 'percent')], 'invisible': [('type_exo', '!=', 'percent')]}" + /> </tree> <form> <group> - <field name="type_exo" invisible="1"/> - <field name="contribution_id" readonly="1" string="Type de cotisation" options="{'no_open': True}"/> - <field name="amount" attrs="{'readonly': [('type_exo', '!=', 'amount')], 'invisible': [('type_exo', '!=', 'amount')]}"/> - <field name="percent" attrs="{'readonly': [('type_exo', '!=', 'percent')], 'invisible': [('type_exo', '!=', 'percent')]}"/> + <field name="type_exo" invisible="1" /> + <field + name="contribution_id" + readonly="1" + string="Type de cotisation" + options="{'no_open': True}" + /> + <field + name="amount" + attrs="{'readonly': [('type_exo', '!=', 'amount')], 'invisible': [('type_exo', '!=', 'amount')]}" + /> + <field + name="percent" + attrs="{'readonly': [('type_exo', '!=', 'percent')], 'invisible': [('type_exo', '!=', 'percent')]}" + /> </group> </form> </field> @@ -132,23 +269,30 @@ <group string="Bureau"> <group> - <field name="instance_id" options="{'no_create': True}" string="Instance de présentation"/> + <field + name="instance_id" + options="{'no_create': True}" + string="Instance de présentation" + /> </group> <group> - <field name="date_exo_ok"/> - <field name="final_notice"/> + <field name="date_exo_ok" /> + <field name="final_notice" /> </group> </group> - <strong><label for="head_office_comment"/></strong> - <field name="head_office_comment" placeholder="Commentaire du bureau"/> - <hr/> - <strong><label for="note"/></strong> - <field name="note" placeholder="Note interne CG Scop"/> + <strong><label for="head_office_comment" /></strong> + <field + name="head_office_comment" + placeholder="Commentaire du bureau" + /> + <hr /> + <strong><label for="note" /></strong> + <field name="note" placeholder="Note interne CG Scop" /> </sheet> <div class="oe_chatter" disable_attachment_box="0"> - <field name="message_follower_ids" widget="mail_followers"/> - <field name="activity_ids" widget="mail_activity"/> - <field name="message_ids" widget="mail_thread"/> + <field name="message_follower_ids" widget="mail_followers" /> + <field name="activity_ids" widget="mail_activity" /> + <field name="message_ids" widget="mail_thread" /> </div> </form> </field> @@ -164,9 +308,11 @@ <!-- MENUS --> - <menuitem id="menu_scop_cotisation_cg_exo" - parent="cgscop_cotisation_cg.menu_scop_cotisation_cg_main" - action="action_scop_cotisation_cg_exo" - sequence="60"/> + <menuitem + id="menu_scop_cotisation_cg_exo" + parent="cgscop_cotisation_cg.menu_scop_cotisation_cg_main" + action="action_scop_cotisation_cg_exo" + sequence="60" + /> </data> </odoo> diff --git a/views/scop_cotisation_cg_exo_ur_notice.xml b/views/scop_cotisation_cg_exo_ur_notice.xml index 8c9b52d8c1d72eeae112e6a1be9f88c990900445..587bda61d5e25da579811e6e406b93c73c5821c6 100644 --- a/views/scop_cotisation_cg_exo_ur_notice.xml +++ b/views/scop_cotisation_cg_exo_ur_notice.xml @@ -1,7 +1,6 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2019 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> @@ -11,13 +10,16 @@ <field name="model">scop.cotisation.cg.exo.ur.notice</field> <field name="arch" type="xml"> <tree string="Avis UR" editable="top"> - <field name="name"/> + <field name="name" /> </tree> </field> </record> <!-- Action --> - <record id="action_scop_cotisation_cg_exo_ur_notice" model="ir.actions.act_window"> + <record + id="action_scop_cotisation_cg_exo_ur_notice" + model="ir.actions.act_window" + > <field name="name">Exonérations - Avis UR</field> <field name="res_model">scop.cotisation.cg.exo.ur.notice</field> <field name="view_mode">tree</field> @@ -25,13 +27,17 @@ <!-- MENUS --> - <menuitem id="menu_scop_cotisation_cg_exo_ur_notice_config" - parent="account.menu_finance_configuration" - name="Exonérations CG Scop" - sequence="90"/> - <menuitem id="menu_scop_cotisation_cg_exo_ur_notice" - parent="menu_scop_cotisation_cg_exo_ur_notice_config" - action="action_scop_cotisation_cg_exo_ur_notice" - sequence="10"/> + <menuitem + id="menu_scop_cotisation_cg_exo_ur_notice_config" + parent="account.menu_finance_configuration" + name="Exonérations CG Scop" + sequence="90" + /> + <menuitem + id="menu_scop_cotisation_cg_exo_ur_notice" + parent="menu_scop_cotisation_cg_exo_ur_notice_config" + action="action_scop_cotisation_cg_exo_ur_notice" + sequence="10" + /> </data> </odoo> diff --git a/views/scop_instance.xml b/views/scop_instance.xml index b109827d4870b4a6f05dd3a1acc00ebc033e804d..16df386e57a97cd3ff8b7366b2b9d28f85666cd8 100644 --- a/views/scop_instance.xml +++ b/views/scop_instance.xml @@ -1,44 +1,66 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2021 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> <record id="scop_instance_exo_form_view" model="ir.ui.view"> <field name="name">scop.instance.exo.form</field> <field name="model">scop.instance</field> - <field name="inherit_id" ref="cgscop_instance.scop_instance_form_view"/> + <field name="inherit_id" ref="cgscop_instance.scop_instance_form_view" /> <field name="arch" type="xml"> <xpath expr="//group[@name='instance_type']" position="inside"> - <field name="is_type_exo" widget="boolean_toggle"/> + <field name="is_type_exo" widget="boolean_toggle" /> </xpath> - <xpath expr="//page[@name='membership']" position="after"> - <page name="exo" string="Exonérations" attrs="{'invisible':[('is_type_exo','!=',True)]}"> - <field name="all_exo_validated" invisible="1"/> - <button name="scop_valid_exo" - type="object" - string="Valider toutes les exonérations" - confirm="Confirmez-vous la validation des exonérations ?" - class="btn-outline-info" - attrs="{'invisible': [('all_exo_validated', '=', True)]}" + <xpath expr="//notebook" position="inside"> + <page + name="exo" + string="Exonérations" + attrs="{'invisible':[('is_type_exo','!=',True)]}" + > + <field name="all_exo_validated" invisible="1" /> + <button + name="scop_valid_exo" + type="object" + string="Valider toutes les exonérations" + confirm="Confirmez-vous la validation des exonérations ?" + class="btn-outline-info" + attrs="{'invisible': [('all_exo_validated', '=', True)]}" /> - <field name="exo_ids" widget="many2many" domain="[('instance_id', '=', False)]" options="{'no_create': 1}"> - <tree decoration-danger="final_notice == 'unfavorable'" decoration-success="final_notice == 'favorable'"> - <field name="date_request"/> - <field name="partner_id"/> - <field name="source"/> - <field name="ur_notice"/> - <field name="date_exo_start"/> - <field name="date_exo_end"/> - <field name="nb_quarter"/> - <field name="amount_quarter" widget="monetary"/> - <field name="final_notice"/> - <field name="state"/> - <button name="set_favorable" type="object" icon="fa-check-circle-o" class="btn-outline-success" - attrs="{'invisible': ['|', ('final_notice', '=', 'favorable'), ('state', 'in', ['done', 'cancel'])]}"/> - <button name="set_unfavorable" type="object" icon="fa-times-circle-o" class="btn-outline-danger" - attrs="{'invisible': ['|', ('final_notice', '=', 'unfavorable'), ('state', 'in', ['done', 'cancel'])]}"/> + <field + name="exo_ids" + widget="many2many" + domain="[('instance_id', '=', False)]" + options="{'no_create': 1}" + > + <tree + decoration-danger="final_notice == 'unfavorable'" + decoration-success="final_notice == 'favorable'" + > + <field name="date_request" /> + <field name="partner_id" /> + <field name="source" /> + <field name="ur_notice" /> + <field name="date_exo_start" /> + <field name="date_exo_end" /> + <field name="nb_quarter" /> + <field name="amount_quarter" widget="monetary" /> + <field name="final_notice" /> + <field name="state" /> + <button + name="set_favorable" + type="object" + icon="fa-check-circle-o" + class="btn-outline-success" + attrs="{'invisible': ['|', ('final_notice', '=', 'favorable'), ('state', 'in', ['done', 'cancel'])]}" + /> + <button + name="set_unfavorable" + type="object" + icon="fa-times-circle-o" + class="btn-outline-danger" + attrs="{'invisible': ['|', ('final_notice', '=', 'unfavorable'), ('state', 'in', ['done', 'cancel'])]}" + /> </tree> </field> </page> @@ -47,4 +69,4 @@ </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/wizard/__init__.py b/wizard/__init__.py old mode 100755 new mode 100644 diff --git a/wizard/scop_bordereau_update_liasse_wizard.py b/wizard/scop_bordereau_update_liasse_wizard.py index 792f58ec823681025a7ff651cad3d314e7b51785..2c076a45bc43b6f17a18f1a9c05e5f3549adc2d2 100644 --- a/wizard/scop_bordereau_update_liasse_wizard.py +++ b/wizard/scop_bordereau_update_liasse_wizard.py @@ -5,7 +5,7 @@ from odoo import models class ScopBordereauChangeLiasse(models.TransientModel): - _inherit = 'scop.bordereau.change.liasse.wizard' + _inherit = "scop.bordereau.change.liasse.wizard" # ------------------------------------------------------ # Override Parent