From 127d8cb219002c27e47363f17721c2eb18a777b4 Mon Sep 17 00:00:00 2001 From: jordan <jordan@le-filament.com> Date: Thu, 24 Mar 2022 18:01:45 +0100 Subject: [PATCH] [add] new module cgscop_adhesion_instance on migration to 14.0 --- .editorconfig | 20 ++ .eslintrc.yml | 187 ++++++++++++++ .flake8 | 12 + .gitignore | 75 ++++++ .isort.cfg | 13 + .pre-commit-config.yaml | 127 +++++++++ .prettierrc.yml | 8 + .pylintrc | 87 +++++++ .pylintrc-mandatory | 64 +++++ README.rst | 1 - __init__.py | 3 +- __manifest__.py | 7 +- models/__init__.py | 0 models/res_partner.py | 10 +- models/scop_instance.py | 95 +++---- models/scop_instance_partner.py | 56 ++-- models/union_regionale.py | 2 +- report/report_scop_instance_adhesion.xml | 241 ++++++++++++------ security/ir.model.access.csv | 3 + static/src/css/style.css | 17 ++ views/assets.xml | 54 ++-- views/res_partner.xml | 46 ++-- views/scop_instance.xml | 181 +++++++++---- wizard/__init__.py | 0 .../scop_instance_mail_membership_wizard.py | 4 +- .../scop_instance_mail_membership_wizard.xml | 25 +- wizard/scop_instance_report_per_ur_wizard.py | 6 +- wizard/scop_instance_report_per_ur_wizard.xml | 11 +- wizard/scop_instance_wizard.py | 10 +- wizard/scop_instance_wizard.xml | 24 +- 30 files changed, 1100 insertions(+), 289 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc.yml create mode 100644 .flake8 create mode 100644 .gitignore create mode 100644 .isort.cfg create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierrc.yml create mode 100644 .pylintrc create mode 100644 .pylintrc-mandatory mode change 100755 => 100644 README.rst mode change 100755 => 100644 __init__.py mode change 100755 => 100644 __manifest__.py mode change 100755 => 100644 models/__init__.py mode change 100755 => 100644 models/union_regionale.py create mode 100644 static/src/css/style.css mode change 100755 => 100644 views/assets.xml mode change 100755 => 100644 wizard/__init__.py diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..bfd7ac5 --- /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 0000000..d4cc423 --- /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 0000000..e397e8e --- /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 0000000..818770f --- /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 0000000..0ec187e --- /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 0000000..1c6434b --- /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 0000000..5b6d4b3 --- /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 0000000..dc6270e --- /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 0000000..43ea239 --- /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 index efc838d..9b16248 --- a/README.rst +++ b/README.rst @@ -31,4 +31,3 @@ Maintainer :target: https://le-filament.com This module is maintained by Le Filament - diff --git a/__init__.py b/__init__.py old mode 100755 new mode 100644 index 8b92814..cef2435 --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,4 @@ # Copyright 2022 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 5acc18f..2f2808d --- a/__manifest__.py +++ b/__manifest__.py @@ -1,23 +1,24 @@ { "name": "CG SCOP - Adhésion Instance", "summary": "Gestion des instances Adhésions", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "author": "Le Filament", "license": "AGPL-3", "application": False, "installable": True, "depends": [ - "cgscop_adhesion_alfodoo", "cgscop_instance", + "cgscop_adhesion", ], "data": [ # datas + "security/ir.model.access.csv", # views "views/assets.xml", "views/res_partner.xml", "views/scop_instance.xml", # report - "report/report_invoice_adhesion.xml", + "report/report_scop_instance_adhesion.xml", # wizard "wizard/scop_instance_mail_membership_wizard.xml", "wizard/scop_instance_report_per_ur_wizard.xml", 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 0a8f327..94534ae 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -1,7 +1,7 @@ # © 2022 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, api, fields +from odoo import fields, models class ScopPartner(models.Model): @@ -26,9 +26,7 @@ class ScopPartner(models.Model): "is_type_membership" ).sorted("date_start") if instance_adhesion_ids: - r.date_bureau_validation = instance_adhesion_ids[ - -1 - ].date_start.date() + r.date_bureau_validation = instance_adhesion_ids[-1].date_start.date() # ------------------------------------------------------ # Business method @@ -61,7 +59,5 @@ class ScopPartner(models.Model): ): amount_adhesion = adhesion_from_instance.amount_adhesion else: - amount_adhesion = super(ScopPartner, self).get_amount_adhesion( - effectif - ) + amount_adhesion = super(ScopPartner, self).get_amount_adhesion(effectif) return amount_adhesion diff --git a/models/scop_instance.py b/models/scop_instance.py index 81f71f7..8a0e3f5 100644 --- a/models/scop_instance.py +++ b/models/scop_instance.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import logging -from odoo import models, fields, api +from odoo import _, api, fields, models from odoo.exceptions import UserError, ValidationError _logger = logging.getLogger(__name__) @@ -10,7 +10,7 @@ _logger = logging.getLogger(__name__) class ScopInstance(models.Model): - _inherit = ["scop.instance", "cgscop.alfresco"] + _inherit = "scop.instance" # ------------------------------------------------------ # Fields declaration @@ -29,11 +29,7 @@ class ScopInstance(models.Model): string="Nombre de lignes de commandes", compute="_compute_partners_count", ) - comments = fields.Text("Commentaires") - - email_count = fields.Integer( - string="Nombre de mails", compute="_compute_emails" - ) + email_count = fields.Integer(string="Nombre de mails", compute="_compute_emails") # ------------------------------------------------------ # Computed fields / Search Fields @@ -56,8 +52,7 @@ class ScopInstance(models.Model): "subtype_id", "=", self.env.ref( - "cgscop_adhesion_alfodoo." - "mail_message_subtype_adhesion" + "cgscop_adhesion.mail_message_subtype_adhesion" ).id, ), ], @@ -117,9 +112,9 @@ class ScopInstance(models.Model): Generic function to create report adhésion CG :return: """ - return self.env.ref( - "cgscop_adhesion.cgscop_adhesion_report" - ).report_action(partners) + return self.env.ref("cgscop_adhesion.cgscop_adhesion_report").report_action( + partners + ) # ------------------------------------------------------ # Actions @@ -130,9 +125,7 @@ class ScopInstance(models.Model): :return: """ self.ensure_one() - wizard = self.env["scop.instance.wizard"].create( - {"instance_id": self.id} - ) + wizard = self.env["scop.instance.wizard"].create({"instance_id": self.id}) return { "name": "Ajouter des coops", "type": "ir.actions.act_window", @@ -148,7 +141,7 @@ class ScopInstance(models.Model): :return: """ return self.env.ref( - "cgscop_instance.cgscop_instance_adhesion_report" + "cgscop_adhesion_instance.cgscop_instance_adhesion_report" ).report_action(self) def create_report_adhesion_all(self): @@ -160,7 +153,7 @@ class ScopInstance(models.Model): lambda p: p.project_status == "6_suivi" ) if len(partners) < 1: - raise UserError('Aucune coopérative n\'est en statut "suivi"') + raise UserError(_('Aucune coopérative n\'est en statut "suivi"')) return self.create_report_adhesion(partners) def create_report_adhesion_per_ur(self): @@ -172,7 +165,7 @@ class ScopInstance(models.Model): lambda i: i.project_status == "6_suivi" ) if len(partners) < 1: - raise UserError('Aucune coopérative n\'est en statut "suivi"') + raise UserError(_('Aucune coopérative n\'est en statut "suivi"')) urs = partners.mapped("ur_id") wizard = self.env["scop.instance.report.wizard"].create( { @@ -199,7 +192,7 @@ class ScopInstance(models.Model): lambda i: i.project_status == "6_suivi" ) if len(partners) < 1: - raise UserError('Aucune coopérative n\'est en statut "suivi"') + raise UserError(_('Aucune coopérative n\'est en statut "suivi"')) wizard = self.env["scop.instance.mail.wizard"].create({}) return { @@ -220,7 +213,7 @@ class ScopInstance(models.Model): self.ensure_one() partner_ids = self._get_partners().ids tree_view = self.env.ref( - "cgscop_instance.res_partner_instance_coops_tree" + "cgscop_adhesion_instance.res_partner_instance_coops_tree" ).id return { "type": "ir.actions.act_window", @@ -248,10 +241,7 @@ class ScopInstance(models.Model): ( "subtype_id", "=", - self.env.ref( - "cgscop_adhesion_alfodoo." - "mail_message_subtype_adhesion" - ).id, + self.env.ref("cgscop_adhesion.mail_message_subtype_adhesion").id, ), ], } @@ -268,52 +258,48 @@ class ScopInstance(models.Model): - log success or error - open wizard to send mail to all validated coops """ + # Check if function is called with context or not partners_to_validate = self.env.context.get( - "partners_to_validate", False - ) - if not partners_to_validate: - partners_to_validate = self.instance_partner_ids.filtered( + "partners_to_validate", + self.instance_partner_ids.filtered( lambda p: p.state == "positive" and p.project_status == "5_cg" - ) + ), + ) validated_partners = list() for r in partners_to_validate: partner = r.partner_id try: - # scop_valid_cg - partner.with_context( - origin_instance_id=self.id - ).scop_valid_cg() - # set membership stat period - membership_period = self.env["scop.membership.period"].search( - [ - ("partner_id", "=", partner.id), - ("start", "=", self.date), - ("end", "=", False), - ], - limit=1, - ) - if membership_period.start_stat != r.statistic_membership_date: - membership_period.update( - {"start_stat": r.statistic_membership_date} + with self.env.cr.savepoint(): + # scop_valid_cg + partner.with_context(origin_instance_id=self.id).scop_valid_cg() + # set membership stat period + membership_period = self.env["scop.membership.period"].search( + [ + ("partner_id", "=", partner.id), + ("start", "=", self.date), + ("end", "=", False), + ], + limit=1, ) - # log success - validated_partners.append(partner.id) - r.is_success = True - self.env.cr.commit() + if membership_period.start_stat != r.statistic_membership_date: + membership_period.update( + {"start_stat": r.statistic_membership_date} + ) + # log success + validated_partners.append(partner.id) + r.is_success = True except Exception as e: logger = "Erreur lors la validation du dossier %s : " "%s" % ( partner.name, e.args[0], ) _logger.warning(logger) - self.env.cr.rollback() r.is_success = False r.message_error = ( fields.datetime.now().strftime("%d/%m/%Y - %-H:%M") + " - Erreur : " + e.args[0] ) - self.env.cr.commit() if len(partners_to_validate) == 1: raise ValidationError(logger) @@ -327,9 +313,7 @@ class ScopInstance(models.Model): Open wizard to send mail adhésion to partners of instance """ self.ensure_one() - template_id = self.env.ref( - "cgscop_adhesion_alfodoo.email_template_adhesion" - ) + template_id = self.env.ref("cgscop_adhesion.email_template_adhesion") ir_model_data = self.env["ir.model.data"] try: compose_form_id = ir_model_data.get_object_reference( @@ -343,7 +327,7 @@ class ScopInstance(models.Model): "default_use_template": True, "default_template_id": template_id.id, "default_subtype_id": self.env.ref( - "cgscop_adhesion_alfodoo.mail_message_subtype_adhesion" + "cgscop_adhesion.mail_message_subtype_adhesion" ).id, "default_composition_mode": "mass_mail" if len(partners.ids) > 1 @@ -352,7 +336,6 @@ class ScopInstance(models.Model): } return { "type": "ir.actions.act_window", - "view_type": "form", "view_mode": "form", "res_model": "mail.compose.message", "views": [(compose_form_id, "form")], diff --git a/models/scop_instance_partner.py b/models/scop_instance_partner.py index e977daa..3305fde 100644 --- a/models/scop_instance_partner.py +++ b/models/scop_instance_partner.py @@ -1,7 +1,7 @@ # © 2022 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, api +from odoo import _, api, fields, models class ScopInstancePartner(models.Model): @@ -30,9 +30,7 @@ class ScopInstancePartner(models.Model): partner_id = fields.Many2one( comodel_name="res.partner", string="Coopératives", required=True ) - display_name = fields.Char( - string="Coopérative", related="partner_id.display_name" - ) + display_name = fields.Char(string="Coopérative", related="partner_id.display_name") city = fields.Char(string="Ville", related="partner_id.city") ur_id = fields.Many2one( comodel_name="union.regionale", string="UR", related="partner_id.ur_id" @@ -48,15 +46,13 @@ class ScopInstancePartner(models.Model): selection=[("positive", "Favorable"), ("negative", "Défavorable")], default="positive", required=True, - track_visibility="onchange", ) amount_adhesion = fields.Float( string="Montant Adhésion", compute="_compute_amount_adhesion", store=True, - track_visibility="onchange", ) - comments = fields.Text("Commentaires", track_visibility="onchange") + comments = fields.Text("Commentaires") statistic_membership_date = fields.Date( string="Date d'adhésion statistique", default=lambda self: self._get_default_date_stat(), @@ -92,9 +88,7 @@ class ScopInstancePartner(models.Model): else r.partner_id.get_lm_adhesion(r.instance_id.date.year) ) effectif = lm.eff_tt - r.amount_adhesion = r.partner_id.get_theorical_amount_adhesion( - effectif - ) + r.amount_adhesion = r.partner_id.get_theorical_amount_adhesion(effectif) else: r.amount_adhesion = 0 @@ -119,6 +113,11 @@ class ScopInstancePartner(models.Model): # On supprime l'objet "statut coop par instance" associé self.unlink() + def scop_valid_cg_again(self): + return self.instance_id.with_context( + partners_to_validate=self + ).scop_valid_cg_mass() + def try_push_again(self): message = ( "<p>" @@ -127,24 +126,25 @@ class ScopInstancePartner(models.Model): + "<p><strong>Voulez-vous tenter de valider à " "nouveau cette coop ?</strong></p>" ) - action = ( - "instance_id.with_context(partners_to_validate=" - "self.env['scop.instance.partner']." - "browse(" + str(self.id) + ")).scop_valid_cg_mass()" - ) - message_id = self.env["message.wizard"].create( - { - "message": message, - "cancel_button": True, - "action": action, - } - ) return { - "name": "Erreur de validation pour " + self.partner_id.name, - "type": "ir.actions.act_window", - "view_mode": "form", - "res_model": "message.wizard", - "res_id": message_id.id, - "target": "new", + "type": "ir.actions.act_window.message", + "title": _("Erreur de validation pour " + self.partner_id.name), + "is_html_message": True, + "message": _(message), + "close_button_title": False, + "buttons": [ + { + "type": "method", + "name": "Ok", + "model": self._name, + "method": "scop_valid_cg_again", + "args": [self.ids], + "classes": "btn-primary", + }, + { + "type": "ir.actions.act_window_close", + "name": "Annuler", + }, + ], } diff --git a/models/union_regionale.py b/models/union_regionale.py old mode 100755 new mode 100644 index b12c6ae..02c8846 --- a/models/union_regionale.py +++ b/models/union_regionale.py @@ -1,7 +1,7 @@ # © 2022 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, models +from odoo import models class UnionRegionale(models.Model): diff --git a/report/report_scop_instance_adhesion.xml b/report/report_scop_instance_adhesion.xml index 408ae4d..baf9ae4 100644 --- a/report/report_scop_instance_adhesion.xml +++ b/report/report_scop_instance_adhesion.xml @@ -1,16 +1,15 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2022 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> <template id="report_instance_adhesion_document"> <t t-call="web.external_layout"> - <t t-set="o" t-value="o.with_context(lang='fr')"/> - <t t-set="datas" t-value="o.get_report_datas()"/> - <t t-set="partners" t-value="datas.get('partners')"/> - <t t-set="ur_ids" t-value="partners.mapped('ur_id').sorted('id')"/> + <t t-set="o" t-value="o.with_context(lang='fr')" /> + <t t-set="datas" t-value="o.get_report_datas()" /> + <t t-set="partners" t-value="datas.get('partners')" /> + <t t-set="ur_ids" t-value="partners.mapped('ur_id').sorted('id')" /> <div class="page"> <div class="instance-layout"> @@ -18,52 +17,89 @@ <div class="row"> <div class="col-12 text-center mb64"> <h2> - Bureau de la Direction Nationale - <span t-field="o.date" t-options="{'widget': 'date', 'format': 'dd/MM/YYYY'}"/> + Bureau de la Direction Nationale - <span + t-field="o.date" + t-options="{'widget': 'date', 'format': 'dd/MM/YYYY'}" + /> </h2> <h3> Proposition d'adhésions définitives </h3> - <hr/> + <hr /> </div> </div> <!-- Global --> - <div class="row" > + <div class="row"> <div class="col-12"> <h3 class="mb32"> Global par Union Régionale </h3> - <div class="row" style="font-weight: 700; font-size: 16px;"> + <div + class="row" + style="font-weight: 700; font-size: 16px;" + > <div class="col-4">Union Régionale</div> <div class="col-3 text-center">Coopératives</div> <div class="col-3 text-center">Salariés</div> <div class="col-2 text-center">Associés</div> </div> - <hr/> + <hr /> <t t-foreach="ur_ids" t-as="ur"> <div style="page-break-inside: avoid;"> - <div class="row bgg" style="font-weight: 700; font-size: 16px;"> - <div class="col-4"><t t-esc="ur.name"/></div> - <div class="col-3 text-center"><t t-esc="len(partners.filtered(lambda p: p.ur_id.id == ur.id))"/></div> - <div class="col-3 text-center"><t t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id).mapped('eff_tt'))"/></div> - <div class="col-2 text-center"><t t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id).mapped('eff_sal_assoc'))"/></div> + <div + class="row bgg" + style="font-weight: 700; font-size: 16px;" + > + <div class="col-4"><t + t-esc="ur.name" + /></div> + <div class="col-3 text-center"><t + t-esc="len(partners.filtered(lambda p: p.ur_id.id == ur.id))" + /></div> + <div class="col-3 text-center"><t + t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id).mapped('eff_tt'))" + /></div> + <div class="col-2 text-center"><t + t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id).mapped('eff_sal_assoc'))" + /></div> </div> - <t t-set="type_coop" t-value="partners.filtered(lambda p: p.ur_id.id == ur.id).mapped('coop_form_id')"/> + <t + t-set="type_coop" + t-value="partners.filtered(lambda p: p.ur_id.id == ur.id).mapped('coop_form_id')" + /> <t t-foreach="type_coop" t-as="type_id"> <div class="row" style="font-size: 14px;"> - <div class="col-4 text-right"><t t-esc="type_id.name"/></div> - <div class="col-3 text-center"><t t-esc="len(partners.filtered(lambda p: p.ur_id.id == ur.id and p.coop_form_id.id == type_id.id))"/></div> - <div class="col-3 text-center"><t t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id and p.coop_form_id.id == type_id.id).mapped('eff_tt'))"/></div> - <div class="col-2 text-center"><t t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id and p.coop_form_id.id == type_id.id).mapped('eff_sal_assoc'))"/></div> + <div class="col-4 text-right"><t + t-esc="type_id.name" + /></div> + <div class="col-3 text-center"><t + t-esc="len(partners.filtered(lambda p: p.ur_id.id == ur.id and p.coop_form_id.id == type_id.id))" + /></div> + <div class="col-3 text-center"><t + t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id and p.coop_form_id.id == type_id.id).mapped('eff_tt'))" + /></div> + <div class="col-2 text-center"><t + t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id and p.coop_form_id.id == type_id.id).mapped('eff_sal_assoc'))" + /></div> </div> </t> - <hr/> + <hr /> </div> </t> - <div class="row" style="font-weight: 700; font-size: 16px;"> + <div + class="row" + style="font-weight: 700; font-size: 16px;" + > <div class="col-4">TOTAL GÉNÉRAL</div> - <div class="col-3 text-center"><t t-esc="len(partners)"/></div> - <div class="col-3 text-center"><t t-esc="sum(partners.mapped('eff_tt'))"/></div> - <div class="col-2 text-center"><t t-esc="sum(partners.mapped('eff_sal_assoc'))"/></div> + <div class="col-3 text-center"><t + t-esc="len(partners)" + /></div> + <div class="col-3 text-center"><t + t-esc="sum(partners.mapped('eff_tt'))" + /></div> + <div class="col-2 text-center"><t + t-esc="sum(partners.mapped('eff_sal_assoc'))" + /></div> </div> </div> </div> @@ -71,16 +107,19 @@ <!-- Detail by UR --> <div> <t t-foreach="ur_ids" t-as="ur"> - <t t-set="partner_ids" t-value="partners.filtered(lambda p: p.ur_id.id == ur.id).sorted('cooperative_form_id')"/> + <t + t-set="partner_ids" + t-value="partners.filtered(lambda p: p.ur_id.id == ur.id).sorted('cooperative_form_id')" + /> <div class="row"> <div class="col-12 mb32"> <h3> - UR : <span t-esc="ur.name"/> + UR : <span t-esc="ur.name" /> </h3> - <hr/> + <hr /> </div> - <hr/> + <hr /> </div> <div class="row"> <div class="col-12"> @@ -88,50 +127,104 @@ <thead> <tr> <th scope="col">Type</th> - <th scope="col">Raison sociale</th> + <th + scope="col" + >Raison sociale</th> <th scope="col">CP</th> <th scope="col">Ville</th> - <th scope="col">Effectif total</th> - <th scope="col">Salariés associés</th> + <th + scope="col" + >Effectif total</th> + <th + scope="col" + >Salariés associés</th> <th scope="col">Capital</th> <th scope="col">CA</th> <th scope="col">VA</th> - <th scope="col">Origine de création</th> + <th + scope="col" + >Origine de création</th> <th scope="col">NAF</th> - <th scope="col">Objet social</th> - <th scope="col">Adhésion Fédération</th> - <th scope="col">Forme juridique</th> + <th + scope="col" + >Objet social</th> + <th + scope="col" + >Adhésion Fédération</th> + <th + scope="col" + >Forme juridique</th> </tr> </thead> <tbody> - <t t-foreach="partner_ids" t-as="partner"> + <t + t-foreach="partner_ids" + t-as="partner" + > <tr> - <td><t t-esc="partner.coop_form_id.name"/></td> - <td><t t-esc="partner.partner_id.name"/></td> - <td><t t-esc="partner.zip"/></td> - <td><t t-esc="partner.city"/></td> - <td><t t-esc="partner.eff_tt"/></td> - <td><t t-esc="partner.eff_sal_assoc"/></td> - <td><t t-esc="partner.cap_tt" t-options="{'widget': 'float', 'precision': 0}"/> €</td> - <td><t t-esc="partner.scop_liasse_fiscale_id.revenue_cg" t-options="{'widget': 'float', 'precision': 0}"/> €</td> - <td><t t-esc="partner.scop_liasse_fiscale_id.av_cg" t-options="{'widget': 'float', 'precision': 0}"/> €</td> - <td><t t-esc="partner.creation_origin_id"/></td> - <td><t t-esc="partner.code_naf"/></td> - <td><t t-esc="partner.social_object"/></td> - <td><t t-esc="partner.project_federation.name"/></td> - <td><t t-esc="partner.partner_company_type_id"/></td> + <td><t + t-esc="partner.coop_form_id.name" + /></td> + <td><t + t-esc="partner.partner_id.name" + /></td> + <td><t + t-esc="partner.zip" + /></td> + <td><t + t-esc="partner.city" + /></td> + <td><t + t-esc="partner.eff_tt" + /></td> + <td><t + t-esc="partner.eff_sal_assoc" + /></td> + <td><t + t-esc="partner.cap_tt" + t-options="{'widget': 'float', 'precision': 0}" + /> €</td> + <td><t + t-esc="partner.scop_liasse_fiscale_id.revenue_cg" + t-options="{'widget': 'float', 'precision': 0}" + /> €</td> + <td><t + t-esc="partner.scop_liasse_fiscale_id.av_cg" + t-options="{'widget': 'float', 'precision': 0}" + /> €</td> + <td><t + t-esc="partner.creation_origin_id" + /></td> + <td><t + t-esc="partner.code_naf" + /></td> + <td><t + t-esc="partner.social_object" + /></td> + <td><t + t-esc="partner.project_federation.name" + /></td> + <td><t + t-esc="partner.partner_company_type_id" + /></td> </tr> </t> </tbody> <tfoot> <tr> <td>TOTAL</td> - <td></td> + <td /> <td colspan="2"> - <t t-esc="len(partner_ids)"/> coop(s)</td> - <td><t t-esc="sum(list(partner_ids.mapped('eff_tt')))"/></td> - <td><t t-esc="sum(list(partner_ids.mapped('eff_sal_assoc')))"/></td> - <td colspan="8"/> + <t + t-esc="len(partner_ids)" + /> coop(s)</td> + <td><t + t-esc="sum(list(partner_ids.mapped('eff_tt')))" + /></td> + <td><t + t-esc="sum(list(partner_ids.mapped('eff_sal_assoc')))" + /></td> + <td colspan="8" /> </tr> </tfoot> </table> @@ -148,10 +241,13 @@ <template id="report_instance_adhesion"> <t t-call="web.html_container"> - <t t-set="docs" t-value="docs.with_context(lang='fr')"/> - <t t-set="company" t-value="docs.env.user.company_id"/> + <t t-set="docs" t-value="docs.with_context(lang='fr')" /> + <t t-set="company" t-value="docs.env.user.company_id" /> <t t-foreach="docs" t-as="o"> - <t t-call="cgscop_instance.report_instance_adhesion_document" t-lang="fr"/> + <t + t-call="cgscop_adhesion_instance.report_instance_adhesion_document" + t-lang="fr" + /> </t> </t> </template> @@ -159,28 +255,31 @@ <!-- Paper format --> <record id="paperformat_a4_landscape" model="report.paperformat"> <field name="name">A4 Paysage Scop Instance</field> - <field name="default" eval="True"/> + <field name="default" eval="True" /> <field name="format">A4</field> <field name="orientation">Landscape</field> <field name="margin_top">35</field> <field name="margin_bottom">20</field> <field name="margin_left">10</field> <field name="margin_right">10</field> - <field name="header_line" eval="False"/> + <field name="header_line" eval="False" /> <field name="header_spacing">30</field> <field name="dpi">90</field> </record> <!-- QWeb Reports --> - <report - id="cgscop_instance_adhesion_report" - model="scop.instance" - string="CG Scop - États préparatoires" - report_type="qweb-pdf" - name="cgscop_instance.report_instance_adhesion" - paperformat="paperformat_a4_landscape" - menu="False" - /> + <record id="cgscop_instance_adhesion_report" model="ir.actions.report"> + <field name="name">CG Scop - États préparatoires</field> + <field name="model">scop.instance</field> + <field name="report_type">qweb-pdf</field> + <field + name="report_name" + >cgscop_adhesion_instance.report_instance_adhesion</field> + <field + name="report_file" + >cgscop_adhesion_instance.report_instance_adhesion</field> + <field name="paperformat_id" ref="paperformat_a4_landscape" /> + </record> </data> </odoo> diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index 6b7a392..0368279 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,3 +1,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink admin_scop_instance_partner,admin_scop_instance_partner,model_scop_instance_partner,cgscop_partner.group_cg_administrative,1,1,1,1 user_scop_instance_partner,user_scop_instance_partner,model_scop_instance_partner,base.group_user,1,0,0,0 +cg_scop_instance_wizard,cg_scop_instance_wizard,model_scop_instance_wizard,cgscop_partner.group_cg_administrative,1,1,1,1 +cg_scop_instance_mail_wizard,cg_scop_instance_mail_wizard,model_scop_instance_mail_wizard,cgscop_partner.group_cg_administrative,1,1,1,1 +cg_scop_instance_report_wizard,cg_scop_instance_report_wizard,model_scop_instance_report_wizard,cgscop_partner.group_cg_administrative,1,1,1,1 diff --git a/static/src/css/style.css b/static/src/css/style.css new file mode 100644 index 0000000..549afce --- /dev/null +++ b/static/src/css/style.css @@ -0,0 +1,17 @@ +.instance-layout table { + border-color: #aaa !important; +} +.instance-layout table td { + border-color: #aaa !important; +} +.instance-layout table thead tr th { + text-transform: none; + border-color: #aaa !important; +} +.instance-layout table tbody tr td, +.instance-layout > .row > table tbody tr:last-child td { + font-size: 14px; + border-right: 1px solid #aaa !important; + background-color: #fff !important; + color: #000 !important; +} diff --git a/views/assets.xml b/views/assets.xml old mode 100755 new mode 100644 index a4924d8..4fa5a0d --- a/views/assets.xml +++ b/views/assets.xml @@ -1,24 +1,40 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2022 Le Filament - License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - +License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> - <template id="cgscop_instance_report_assets_editor" inherit_id="web.report_assets_editor"> - <xpath expr="." position="inside"> - <link rel="stylesheet" href="/cgscop_instance/static/src/css/style.css"/> - </xpath> - </template> +<!-- <template--> +<!-- id="cgscop_instance_report_assets_editor"--> +<!-- inherit_id="web.report_assets_editor"--> +<!-- >--> +<!-- <xpath expr="." position="inside">--> +<!-- <link rel="stylesheet" href="/cgscop_instance/static/src/css/style.css" />--> +<!-- </xpath>--> +<!-- </template>--> - <template id="cgscop_instance_assets_pdf" name="cgscop_instance_assets" inherit_id="web.report_assets_pdf"> - <xpath expr="." position="inside"> - <link rel="stylesheet" href="/cgscop_instance/static/src/css/style.css"/> - </xpath> - </template> + <template + id="cgscop_instance_assets_pdf" + name="cgscop_instance_assets" + inherit_id="web.report_assets_pdf" + > + <xpath expr="." position="inside"> + <link + rel="stylesheet" + href="/cgscop_adhesion_instance/static/src/css/style.css" + /> + </xpath> + </template> - <template id="cgscop_instance_report_assets_common" name="cgscop_instance_report_assets" inherit_id="web.report_assets_common"> - <xpath expr="." position="inside"> - <link rel="stylesheet" href="/cgscop_instance/static/src/css/style.css"/> - </xpath> - </template> + <template + id="cgscop_instance_report_assets_common" + name="cgscop_instance_report_assets" + inherit_id="web.report_assets_common" + > + <xpath expr="." position="inside"> + <link + rel="stylesheet" + href="/cgscop_adhesion_instance/static/src/css/style.css" + /> + </xpath> + </template> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/res_partner.xml b/views/res_partner.xml index 8b0dc1c..9d7b22f 100644 --- a/views/res_partner.xml +++ b/views/res_partner.xml @@ -1,7 +1,6 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2022 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> @@ -12,12 +11,12 @@ <field name="priority">50</field> <field name="arch" type="xml"> <tree string="Coopératives" create="false"> - <field name="display_name" string="Coopérative"/> - <field name="city"/> - <field name="ur_id"/> - <field name="phone"/> - <field name="email"/> - <field name="project_status"/> + <field name="display_name" string="Coopérative" /> + <field name="city" /> + <field name="ur_id" /> + <field name="phone" /> + <field name="email" /> + <field name="project_status" /> </tree> </field> </record> @@ -26,10 +25,16 @@ <record id="view_res_partner_form_instance_inherit" model="ir.ui.view"> <field name="name">res.partner.form.instance.inherit</field> <field name="model">res.partner</field> - <field name="inherit_id" ref="cgscop_adhesion.view_partner_cooperative_adhesion_form"/> + <field + name="inherit_id" + ref="cgscop_adhesion.view_partner_cooperative_adhesion_form" + /> <field name="arch" type="xml"> - <xpath expr="//header/button[@name='scop_valid_cg_button']" position="attributes"> - <attribute name="invisible" eval="True"/> + <xpath + expr="//header/button[@name='scop_valid_cg_button']" + position="attributes" + > + <attribute name="invisible" eval="True" /> </xpath> </field> </record> @@ -37,14 +42,23 @@ <record id="view_res_partner_form_instance_inherit2" model="ir.ui.view"> <field name="name">res.partner.form.instance.inherit2</field> <field name="model">res.partner</field> - <field name="inherit_id" ref="cgscop_adhesion.view_partner_cooperative_adhesion_form"/> - <field name="groups_id" eval="[(4, ref('cgscop_partner.group_cg_administrator'))]"/> + <field + name="inherit_id" + ref="cgscop_adhesion.view_partner_cooperative_adhesion_form" + /> + <field + name="groups_id" + eval="[(4, ref('cgscop_partner.group_cg_administrator'))]" + /> <field name="arch" type="xml"> - <xpath expr="//header/button[@name='scop_valid_cg_button']" position="attributes"> - <attribute name="invisible" eval="False"/> + <xpath + expr="//header/button[@name='scop_valid_cg_button']" + position="attributes" + > + <attribute name="invisible" eval="False" /> </xpath> </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/scop_instance.xml b/views/scop_instance.xml index ee9eb4f..45117bf 100644 --- a/views/scop_instance.xml +++ b/views/scop_instance.xml @@ -1,74 +1,149 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2022 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> <record id="scop_instance_form_view" model="ir.ui.view"> <field name="name">scop.instance.form.inherit</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_membership" widget="boolean_toggle" /> + </xpath> + <xpath expr="//notebook" position="inside"> - <page name="membership" string="Adhésion" attrs="{'invisible':[('is_type_membership','=',False)]}"> + <page + name="membership" + string="Adhésion" + attrs="{'invisible':[('is_type_membership','=',False)]}" + > <header> - <button name="action_add_coop" type="object" - string="Associer des coopératives" - class="btn-primary"/> - <button name="create_report_instance_adhesion" type="object" - string="États préparatoires" - class="btn-info"/> - <button name="scop_valid_cg_mass" type="object" - string="Valider les coops" - class="btn-info"/> - <button name="create_report_adhesion_all" type="object" - string="Générer tous les courriers" class="btn-info"/> - <button name="create_report_adhesion_per_ur" type="object" - string="Générer les courriers par UR" class="btn-info"/> - <button name="action_send_mail_adhesion" type="object" - string="Envoyer les mails d'adhésion" class="btn-info"/> + <button + name="action_add_coop" + type="object" + string="Associer des coopératives" + class="btn-primary" + /> + <button + name="create_report_instance_adhesion" + type="object" + string="États préparatoires" + class="btn-info" + /> + <button + name="scop_valid_cg_mass" + type="object" + string="Valider les coops" + class="btn-info" + /> + <button + name="create_report_adhesion_all" + type="object" + string="Générer tous les courriers" + class="btn-info" + /> + <button + name="create_report_adhesion_per_ur" + type="object" + string="Générer les courriers par UR" + class="btn-info" + /> + <button + name="action_send_mail_adhesion" + type="object" + string="Envoyer les mails d'adhésion" + class="btn-info" + /> </header> - <div class="oe_button_box" name="button_box"> - <button name="action_show_coop" type="object" - class="oe_stat_button" icon="fa-address-card-o"> - <field string="Coopératives" name="partners_count" widget="statinfo"/> + <div class="oe_button_box mt-3" name="button_box"> + <button + name="action_show_coop" + type="object" + class="oe_stat_button" + icon="fa-address-card-o" + > + <field + string="Coopératives" + name="partners_count" + widget="statinfo" + /> </button> - <button name="action_show_emails" type="object" class="oe_stat_button" icon="fa-envelope-o"> - <field name="email_count" widget="statinfo" string="Mails"/> + <button + name="action_show_emails" + type="object" + class="oe_stat_button" + icon="fa-envelope-o" + > + <field + name="email_count" + widget="statinfo" + string="Mails" + /> </button> </div> <group> - <field name="date_membership" required="1"/> - <button name="update_membership_date" type="object" - string="Mettre à jour la date d'adhésion statistique" class="btn-outline-dark btn-sm"/> + <field name="date_membership" required="1" /> + <button + name="update_membership_date" + type="object" + string="Mettre à jour la date d'adhésion statistique" + class="btn-outline-dark btn-sm" + /> </group> <field name="instance_partner_ids"> - <tree string="Coopératives" create="false" - decoration-warning="state == 'negative'" - decoration-danger="is_success == False and state != 'negative'" - editable="top"> - <field name="display_name" string="Coopérative" readonly="True"/> - <field name="city" readonly="True"/> - <field name="ur_id" readonly="True" options="{'no_open': True}"/> - <field name="phone" readonly="True"/> - <field name="email" readonly="True"/> - <field name="project_status" readonly="True"/> - <field name="state" readonly="True"/> - <field name="comments" readonly="False"/> - <field name="amount_adhesion" readonly="False"/> - <field name="statistic_membership_date" readonly="False" - string="Date adhésion stat."/> - <button name="switch_state" type="object" - string="Changer avis" icon="fa-retweet" - attrs="{'invisible':[('project_status','=','6_suivi')]}"/> - <field name="is_success" invisible="True"/> - <button name="try_push_again" type="object" - string="Forcer la validation" icon="fa-exclamation-circle" - attrs="{'invisible':[('is_success','=',True)]}"/> - <button name="action_free_coop_from_instance" type="object" - string="Détacher la coop" icon="fa-times"/> + <tree + string="Coopératives" + create="false" + decoration-warning="state == 'negative'" + decoration-danger="is_success == False and state != 'negative'" + editable="top" + > + <field + name="display_name" + string="Coopérative" + readonly="True" + /> + <field name="city" readonly="True" /> + <field + name="ur_id" + readonly="True" + options="{'no_open': True}" + /> + <field name="phone" readonly="True" /> + <field name="email" readonly="True" /> + <field name="project_status" readonly="True" /> + <field name="state" readonly="True" /> + <field name="comments" readonly="False" /> + <field name="amount_adhesion" readonly="False" /> + <field + name="statistic_membership_date" + readonly="False" + string="Date adhésion stat." + /> + <button + name="switch_state" + type="object" + string="Changer avis" + icon="fa-retweet" + attrs="{'invisible':[('project_status','=','6_suivi')]}" + /> + <field name="is_success" invisible="True" /> + <button + name="try_push_again" + type="object" + string="Forcer la validation" + icon="fa-exclamation-circle" + attrs="{'invisible':[('is_success','=',True)]}" + /> + <button + name="action_free_coop_from_instance" + type="object" + string="Détacher la coop" + icon="fa-times" + /> </tree> </field> </page> @@ -78,4 +153,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_instance_mail_membership_wizard.py b/wizard/scop_instance_mail_membership_wizard.py index 960eaaf..c2d9af2 100644 --- a/wizard/scop_instance_mail_membership_wizard.py +++ b/wizard/scop_instance_mail_membership_wizard.py @@ -1,7 +1,7 @@ # © 2022 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 UserError @@ -43,4 +43,4 @@ class ScopInstanceMailWizard(models.TransientModel): .send_mass_mail_adhesion(self.partner_ids) ) else: - raise UserError("Impossible d'envoyer le mail") + raise UserError(_("Impossible d'envoyer le mail")) diff --git a/wizard/scop_instance_mail_membership_wizard.xml b/wizard/scop_instance_mail_membership_wizard.xml index a4488d2..a73e03f 100644 --- a/wizard/scop_instance_mail_membership_wizard.xml +++ b/wizard/scop_instance_mail_membership_wizard.xml @@ -1,7 +1,6 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2022 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> @@ -10,14 +9,28 @@ <field name="model">scop.instance.mail.wizard</field> <field name="arch" type="xml"> <form create="false" edit="false"> - <field name="partner_ids" options="{'no_create': True, 'no_open': True}"> + <field + name="partner_ids" + options="{'no_create': True, 'no_open': True}" + > <tree> - <field name="name" string="Coopératives"/> + <field name="name" string="Coopératives" /> </tree> </field> <footer> - <button name="send_mail" string="Envoyer à ces coops" type="object" default_focus="1" class="oe_highlight"/> - <button name="cancel" string="Fermer" special="cancel" class="oe_highlight"/> + <button + name="send_mail" + string="Envoyer à ces coops" + type="object" + default_focus="1" + class="oe_highlight" + /> + <button + name="cancel" + string="Fermer" + special="cancel" + class="oe_highlight" + /> </footer> </form> </field> diff --git a/wizard/scop_instance_report_per_ur_wizard.py b/wizard/scop_instance_report_per_ur_wizard.py index 0b9ddf3..fd4ea82 100644 --- a/wizard/scop_instance_report_per_ur_wizard.py +++ b/wizard/scop_instance_report_per_ur_wizard.py @@ -1,7 +1,7 @@ # © 2022 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 ScopInstanceReportWizard(models.TransientModel): @@ -9,6 +9,4 @@ class ScopInstanceReportWizard(models.TransientModel): _description = "Wizard: Imprimer les courriers par UR" ur_ids = fields.Many2many(comodel_name="union.regionale", string="UR") - partner_ids = fields.Many2many( - comodel_name="res.partner", string="Coopératives" - ) + partner_ids = fields.Many2many(comodel_name="res.partner", string="Coopératives") diff --git a/wizard/scop_instance_report_per_ur_wizard.xml b/wizard/scop_instance_report_per_ur_wizard.xml index e992805..821ecda 100644 --- a/wizard/scop_instance_report_per_ur_wizard.xml +++ b/wizard/scop_instance_report_per_ur_wizard.xml @@ -1,7 +1,6 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2022 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> @@ -12,8 +11,12 @@ <form create="false" edit="false"> <field name="ur_ids"> <tree> - <field name="name" string="UR"/> - <button name="create_report_adhesion_per_ur" type="object" icon="fa-print"/> + <field name="name" string="UR" /> + <button + name="create_report_adhesion_per_ur" + type="object" + icon="fa-print" + /> </tree> </field> </form> diff --git a/wizard/scop_instance_wizard.py b/wizard/scop_instance_wizard.py index 9c562f0..3988713 100644 --- a/wizard/scop_instance_wizard.py +++ b/wizard/scop_instance_wizard.py @@ -1,7 +1,7 @@ # © 2022 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 class ScopInstanceWizard(models.TransientModel): @@ -47,9 +47,7 @@ class ScopInstanceWizard(models.TransientModel): ) return { "domain": { - "partner_ids": [ - ("id", "in", available_soumis_cg.mapped("id")) - ] + "partner_ids": [("id", "in", available_soumis_cg.mapped("id"))] } } else: @@ -60,9 +58,7 @@ class ScopInstanceWizard(models.TransientModel): ] ) return { - "domain": { - "partner_ids": [("id", "in", available_coops.mapped("id"))] - } + "domain": {"partner_ids": [("id", "in", available_coops.mapped("id"))]} } # ------------------------------------------------------ diff --git a/wizard/scop_instance_wizard.xml b/wizard/scop_instance_wizard.xml index 7032ee0..98d2f03 100644 --- a/wizard/scop_instance_wizard.xml +++ b/wizard/scop_instance_wizard.xml @@ -1,7 +1,6 @@ -<?xml version="1.0"?> +<?xml version="1.0" ?> <!-- Copyright 2022 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - <odoo> <data> @@ -11,15 +10,22 @@ <field name="arch" type="xml"> <form string="Ajouter des coopératives"> <group> - <field name="type" widget="radio"/> - <field name="partner_ids" widget="many2many_tags" - options="{'no_create': True, 'no_open': True}" - attrs="{'invisible': [('type', '=', 'all')]}"/> + <field name="type" widget="radio" /> + <field + name="partner_ids" + widget="many2many_tags" + options="{'no_create': True, 'no_open': True}" + attrs="{'invisible': [('type', '=', 'all')]}" + /> </group> <footer> - <button name="add_partners" type="object" - string="Ajouter" class="oe_highlight"/> - <button special="cancel" string="Cancel"/> + <button + name="add_partners" + type="object" + string="Ajouter" + class="oe_highlight" + /> + <button special="cancel" string="Cancel" /> </footer> </form> </field> -- GitLab