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 index b0e1bbefecdd6e195f0bc3469b0fcd465ee61046..818770fb1bdc0a144e924c9a5940f0b035df8a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,75 @@ -.* -*.pyc -!.gitignore \ No newline at end of file +# 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..8a5999af4419f630dda23d9366b51967b8322ed3 --- /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 a453b4b3a3656a314b8ca36c4d0b0f54f491c85e..2696bfce6edd4385cb7e63fd3457dccef222714a --- a/__init__.py +++ b/__init__.py @@ -1,11 +1,10 @@ # © 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 report -from . import wizard +from odoo import SUPERUSER_ID, api + +from . import models, report, wizard -from odoo import api, SUPERUSER_ID def _configure_journals(cr, registry): """Setting journal and property field (if needed)""" @@ -13,19 +12,29 @@ def _configure_journals(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) # if we already have a coa installed, create journal and set property field - company_ids = env['res.company'].search([('chart_template_id', '!=', False)]) + company_ids = env["res.company"].search([("chart_template_id", "!=", False)]) for company_id in company_ids: - journal_id = env['account.journal'].search([ - ('name', '=', 'Cotisations'), - ('company_id', '=', company_id.id), - ('type', '=', 'sale')], limit=1).id + journal_id = ( + env["account.journal"] + .search( + [ + ("name", "=", "Cotisations"), + ("company_id", "=", company_id.id), + ("type", "=", "sale"), + ], + limit=1, + ) + .id + ) if not journal_id: - env['account.journal'].create({ - 'name': 'Cotisations', - 'type': 'sale', - 'code': 'COT', - 'company_id': company_id.id, - 'show_on_dashboard': False, - 'sequence': 6, - }) + env["account.journal"].create( + { + "name": "Cotisations", + "type": "sale", + "code": "COT", + "company_id": company_id.id, + "show_on_dashboard": False, + "sequence": 6, + } + ) diff --git a/__manifest__.py b/__manifest__.py old mode 100755 new mode 100644 index 4ac1922e05910c44f6b28fef5e56542699fd0faa..5e73bf3bc6eb3c7912aa6157bbde2d847d4ca11b --- a/__manifest__.py +++ b/__manifest__.py @@ -3,8 +3,7 @@ { "name": "CG SCOP - Cotisations", "summary": "CG SCOP - Cotisations", - "version": "12.0.1.1.0", - "development_status": "Production/Stable", + "version": "14.0.1.0.0", "author": "Le Filament", "license": "AGPL-3", "application": False, @@ -12,23 +11,23 @@ "depends": [ "account", "account_banking_sepa_direct_debit", - "cgscop_liste_ministere", + "account_payment_order", + "cgscop_account", + "cgscop_liasse_fiscale", "cgscop_partner", - "multi_company_menu", + "lefilament_sales", ], "data": [ "security/ir.model.access.csv", - "views/account_invoice.xml", "views/account_move.xml", "views/account_payment_order.xml", "views/account_payment_line.xml", "views/res_config_settings.xml", "views/res_partner.xml", - "views/scop_cotisation_task.xml", "report/scop_contribution_report.xml", ], "qweb": [ "static/src/xml/*.xml", ], - 'post_init_hook': '_configure_journals', + "post_init_hook": "_configure_journals", } 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..61f9c8cf460381028c5b7cab9c46424b349be86e --- /dev/null +++ b/migration/14.0.1.0.0/post-migration.py @@ -0,0 +1,23 @@ +# © 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_liasse_fiscale_map_values(env): + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("year"), + "scop_cotisation", + [ + (2020, "2020"), + (2021, "2021"), + (2022, "2022"), + ], + table="scop_cotisation", + ) + + +@openupgrade.migrate() +def migrate(env, version): + scop_liasse_fiscale_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..e029ec308d6f0cb93f6c07da7e3b0357430cd136 --- /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": [("year", 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 index 419d51378ff1cf86ca82d88e686bdf688a159866..5c324d7446baca0c0531001a4a2c5fa3ed029e42 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,12 +1,10 @@ # © 2019 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import account_invoice +from . import account_move from . import account_payment_order from . import chart_template from . import res_company from . import res_config_settings from . import res_partner -from . import scop_contribution from . import scop_cotisation -from . import scop_cotisation_task diff --git a/models/account_invoice.py b/models/account_invoice.py deleted file mode 100755 index 16c9033bad0656caeb6ce5001b49d05ac5defe78..0000000000000000000000000000000000000000 --- a/models/account_invoice.py +++ /dev/null @@ -1,109 +0,0 @@ -# © 2020 Le Filament (<http://www.le-filament.com>) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from datetime import datetime -import json - -from odoo import models, fields, api - - -class ScopAccountInvoice(models.Model): - _inherit = "account.invoice" - - @api.model - def default_get(self, fields): - """ - Attribue la valeur du journal des cotisations par défaut si la facture - est de type 'is_contribution' - Affecte le type 'is_contribution' par défaut si la facture est sur le - journal des cotisations - :param fields: - :return: - """ - res = super(ScopAccountInvoice, self).default_get(fields) - if res.get('is_contribution'): - res['journal_id'] =\ - self.env.user.company_id.contribution_journal_id.id - else: - if res.get('journal_id') == \ - self.env.user.company_id.contribution_journal_id.id: - res['is_contribution'] = True - return res - - liasse_fiscale_id = fields.Many2one( - comodel_name='scop.liasse.fiscale', - string='Liasse Fiscale') - year = fields.Integer('Année de cotisation') - is_contribution = fields.Boolean("Cotisation", default=False) - type_contribution_id = fields.Many2one( - comodel_name="scop.contribution.type", - string="Type de cotisation", - readonly=True) - partner_ur_id = fields.Many2one( - comodel_name='union.regionale', - string='UR Adhérent', - related='partner_id.ur_id', - store=True - ) - contribution_id = fields.Many2one( - comodel_name='scop.contribution', - string='Ligne de cotisation') - is_sdd = fields.Boolean( - 'Au prélèvement', - compute='compute_is_sdd', - search='_search_is_sdd') - - # ------------------------------------------------------ - # Computed field - # ------------------------------------------------------ - @api.multi - def compute_is_sdd(self): - sdd_id = self.env.ref( - 'account_banking_sepa_direct_debit.sepa_direct_debit').id - for invoice in self: - if invoice.payment_mode_id and invoice.payment_mode_id.payment_method_id.id == sdd_id: - invoice.is_sdd = True - else: - invoice.is_sdd = False - - @api.multi - def _search_is_sdd(self, operator, value): - recs = self.search([]).filtered(lambda x: x.is_sdd is True) - if recs: - return [('id', 'in', [x.id for x in recs])] - - # ------------------------------------------------------ - # Override Parent - # ------------------------------------------------------ - @api.one - def _get_outstanding_info_JSON(self): - super(ScopAccountInvoice, self)._get_outstanding_info_JSON() - info = json.loads(self.outstanding_credits_debits_widget) - if info: - values = info.get('content', False) - if self.state == 'open' and values: - domain = [('account_id', '=', self.account_id.id), - ('partner_id', '=', - self.env['res.partner']._find_accounting_partner( - self.partner_id).id), - ('reconciled', '=', False), - ('move_id.state', '=', 'posted'), - '|', - '&', ('amount_residual_currency', '!=', 0.0), - ('currency_id', '!=', None), - '&', ('amount_residual_currency', '=', 0.0), '&', - ('currency_id', '=', None), - ('amount_residual', '!=', 0.0)] - if self.type in ('out_invoice', 'in_refund'): - domain.extend([('credit', '>', 0), ('debit', '=', 0)]) - else: - domain.extend([('credit', '=', 0), ('debit', '>', 0)]) - lines = self.env['account.move.line'].search(domain) - for value in values: - for line in lines: - if value.get('id') == line.id: - value.update({ - 'date_maturity': datetime.strftime(line.date_maturity, "%d/%m/%Y"), - 'invoice': line.invoice_id.number - }) - self.outstanding_credits_debits_widget = json.dumps(info) diff --git a/models/account_move.py b/models/account_move.py new file mode 100644 index 0000000000000000000000000000000000000000..ffc5802a7ab687eb0ed2da6617922fddeef2541b --- /dev/null +++ b/models/account_move.py @@ -0,0 +1,125 @@ +# © 2020 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from odoo import api, fields, models + + +class ScopAccountMove(models.Model): + _inherit = "account.move" + + @api.model + def default_get(self, fields): + """ + Attribue la valeur du journal des cotisations par défaut si la facture + est de type 'is_contribution' + Affecte le type 'is_contribution' par défaut si la facture est sur le + journal des cotisations + :param fields: + :return: + """ + res = super(ScopAccountMove, self).default_get(fields) + if res.get("is_contribution"): + res["journal_id"] = self.env.user.company_id.contribution_journal_id.id + else: + if ( + res.get("journal_id") + == self.env.user.company_id.contribution_journal_id.id + ): + res["is_contribution"] = True + return res + + liasse_fiscale_id = fields.Many2one( + comodel_name="scop.liasse.fiscale", string="Liasse Fiscale" + ) + year = fields.Integer("Année de cotisation") + is_contribution = fields.Boolean("Cotisation", default=False) + type_contribution_id = fields.Many2one( + comodel_name="scop.contribution.type", + string="Type de cotisation", + readonly=True, + ) + partner_ur_id = fields.Many2one( + comodel_name="union.regionale", + string="UR Adhérent", + related="partner_id.ur_id", + store=True, + ) + partner_member_number = fields.Char( + string="N° Adhérent", + related="partner_id.member_number", + ) + contribution_id = fields.Many2one( + comodel_name="scop.contribution", string="Ligne de cotisation" + ) + is_sdd = fields.Boolean( + "Au prélèvement", compute="_compute_is_sdd", search="_search_is_sdd" + ) + + # ------------------------------------------------------ + # Computed field + # ------------------------------------------------------ + def _compute_is_sdd(self): + sdd_id = self.env.ref("account_banking_sepa_direct_debit.sepa_direct_debit").id + for invoice in self: + if ( + invoice.payment_mode_id + and invoice.payment_mode_id.payment_method_id.id == sdd_id + ): + invoice.is_sdd = True + else: + invoice.is_sdd = False + + def _search_is_sdd(self, operator, value): + recs = self.search([]).filtered(lambda x: x.is_sdd is True) + if recs: + return [("id", "in", [x.id for x in recs])] + + # ------------------------------------------------------ + # Override Parent + # ------------------------------------------------------ + # TODO: check if necessary + # def _get_outstanding_info_JSON(self): + # super(ScopAccountMove, self)._get_outstanding_info_JSON() + # info = json.loads(self.outstanding_credits_debits_widget) + # if info: + # values = info.get("content", False) + # if self.state == "open" and values: + # domain = [ + # ("account_id", "=", self.account_id.id), + # ( + # "partner_id", + # "=", + # self.env["res.partner"] + # ._find_accounting_partner(self.partner_id) + # .id, + # ), + # ("reconciled", "=", False), + # ("move_id.state", "=", "posted"), + # "|", + # "&", + # ("amount_residual_currency", "!=", 0.0), + # ("currency_id", "!=", None), + # "&", + # ("amount_residual_currency", "=", 0.0), + # "&", + # ("currency_id", "=", None), + # ("amount_residual", "!=", 0.0), + # ] + # if self.type in ("out_invoice", "in_refund"): + # domain.extend([("credit", ">", 0), ("debit", "=", 0)]) + # else: + # domain.extend([("credit", "=", 0), ("debit", ">", 0)]) + # lines = self.env["account.move.line"].search(domain) + # for value in values: + # for line in lines: + # if value.get("id") == line.id: + # value.update( + # { + # "date_maturity": datetime.strftime( + # line.date_maturity, "%d/%m/%Y" + # ), + # "invoice": line.invoice_id.number, + # } + # ) + # self.outstanding_credits_debits_widget = json.dumps(info) diff --git a/models/account_payment_order.py b/models/account_payment_order.py index c4685cd4f5398201a9c7fffe01be342be37e2f7f..846d3bc58367a46832720cb82638febf4c2a5a42 100644 --- a/models/account_payment_order.py +++ b/models/account_payment_order.py @@ -1,97 +1,92 @@ # Copyright 2020 Le Filament # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models, api +from odoo import fields, models from odoo.exceptions import ValidationError class AccountPaymentOrder(models.Model): - _inherit = 'account.payment.order' + _inherit = "account.payment.order" payment_line_amount = fields.Float( - string='Total Opérations', - compute='_compute_payment_line_amount' + string="Total Opérations", compute="_compute_payment_line_amount" ) bank_line_amount = fields.Float( - string='Total Lignes de paiement', - compute='_compute_bank_line_amount' + string="Total Lignes de paiement", compute="_compute_bank_line_amount" ) attachment_ids = fields.One2many( - comodel_name='ir.attachment', - compute='_compute_attachment_ids' + comodel_name="ir.attachment", compute="_compute_attachment_ids" ) # ------------------------------------------------------ # Compute fields # ------------------------------------------------------ - @api.multi def _compute_payment_line_amount(self): for po in self: - po.payment_line_amount = sum( - po.payment_line_ids.mapped('amount_currency') - ) + po.payment_line_amount = sum(po.payment_line_ids.mapped("amount_currency")) - @api.multi def _compute_bank_line_amount(self): for po in self: - po.bank_line_amount = sum( - po.bank_line_ids.mapped('amount_currency') - ) + po.bank_line_amount = sum(po.bank_line_ids.mapped("amount_currency")) - @api.multi def _compute_attachment_ids(self): - Attachment = self.env['ir.attachment'] + Attachment = self.env["ir.attachment"] for po in self: - po.attachment_ids = Attachment.search([ - ('res_model', '=', 'account.payment.order'), - ('res_id', '=', po.id) - ]) + po.attachment_ids = Attachment.search( + [ + ("res_model", "=", "account.payment.order"), + ("res_id", "=", po.id), + ] + ) # ------------------------------------------------------ # Button function # ------------------------------------------------------ def view_payment_line(self): - tree_id = self.env.ref( - 'cgscop_cotisation.scop_account_payment_line_tree').id + tree_id = self.env.ref("cgscop_cotisation.scop_account_payment_line_tree").id search_id = self.env.ref( - 'cgscop_cotisation.scop_account_payment_line_search').id + "cgscop_cotisation.scop_account_payment_line_search" + ).id return { - 'type': 'ir.actions.act_window', - 'name': "Lignes d'opérations", - 'res_model': 'account.payment.line', - 'views': [[tree_id, 'tree']], - 'search_view_id': [search_id, 'search'], - 'domain': [['order_id', '=', self.id]], + "type": "ir.actions.act_window", + "name": "Lignes d'opérations", + "res_model": "account.payment.line", + "views": [[tree_id, "tree"]], + "search_view_id": [search_id, "search"], + "domain": [["order_id", "=", self.id]], } def view_account_move(self): - tree_id = self.env.ref( - 'cgscop_cotisation.scop_account_move_tree').id - search_id = self.env.ref( - 'cgscop_cotisation.scop_account_move_search').id + tree_id = self.env.ref("cgscop_cotisation.scop_account_move_tree").id + search_id = self.env.ref("cgscop_cotisation.scop_account_move_search").id return { - 'type': 'ir.actions.act_window', - 'name': "Pièces comptables de l'ordre de prélèvement", - 'res_model': 'account.move', - 'views': [[tree_id, 'tree'], [False, 'form']], - 'search_view_id': [search_id, 'search'], - 'domain': [['payment_order_id', '=', self.id]], + "type": "ir.actions.act_window", + "name": "Pièces comptables de l'ordre de prélèvement", + "res_model": "account.move", + "views": [[tree_id, "tree"], [False, "form"]], + "search_view_id": [search_id, "search"], + "domain": [["payment_order_id", "=", self.id]], } # ------------------------------------------------------ # Common function # ------------------------------------------------------ - @api.multi def check_sepa_order(self): for order in self: if not order.sepa: - msg = "Les comptes bancaires des coopératives suivantes ne sont pas corrects : \n" - payment_line_ids = order.payment_line_ids.mapped('partner_bank_id') - account_ids = payment_line_ids.filtered(lambda a: a.acc_type != 'iban') + msg = ( + "Les comptes bancaires des coopératives " + "suivantes ne sont pas corrects : \n" + ) + payment_line_ids = order.payment_line_ids.mapped("partner_bank_id") + account_ids = payment_line_ids.filtered(lambda a: a.acc_type != "iban") for acc in account_ids: - msg += ' - ' + acc.partner_id.name + " - " + acc.acc_number + "\n" + msg += " - " + acc.partner_id.name + " - " + acc.acc_number + "\n" - msg += "\nVeuillez corriger ces comptes bancaires pour pouvoir valider l'ordre de prélèvement." + msg += ( + "\nVeuillez corriger ces comptes bancaires pour " + "pouvoir valider l'ordre de prélèvement." + ) raise ValidationError(msg) else: return True @@ -99,7 +94,6 @@ class AccountPaymentOrder(models.Model): # ------------------------------------------------------ # Override Parent # ------------------------------------------------------ - @api.multi def open2generated(self): self.check_sepa_order() - return super(AccountPaymentOrder, self).open2generated() \ No newline at end of file + return super(AccountPaymentOrder, self).open2generated() diff --git a/models/chart_template.py b/models/chart_template.py index 31732592171c3757d52047b5f9613012daabd2b6..c0a86c06aa146e03401584303256ecb7fa26d308 100644 --- a/models/chart_template.py +++ b/models/chart_template.py @@ -9,13 +9,17 @@ class CotisationChartTemplate(models.Model): @api.model def generate_journals(self, acc_template_ref, company, journals_dict=None): - journal_to_add = [{ - 'name': 'Cotisation', - 'type': 'sale', - 'code': 'COT', - 'favorite': False, - 'sequence': 6}] + journal_to_add = [ + { + "name": "Cotisation", + "type": "sale", + "code": "COT", + "favorite": False, + "sequence": 6, + } + ] return super(CotisationChartTemplate, self).generate_journals( acc_template_ref=acc_template_ref, company=company, - journals_dict=journal_to_add) + journals_dict=journal_to_add, + ) diff --git a/models/res_company.py b/models/res_company.py index 96f63c04070421d104eb92937429a0cc301f530b..344c4213b8af805180c0c9274b130215da789e46 100644 --- a/models/res_company.py +++ b/models/res_company.py @@ -5,17 +5,17 @@ from odoo import fields, models class ScopCotisationCompany(models.Model): - _inherit = 'res.company' + _inherit = "res.company" - is_contribution = fields.Boolean('Cotisations', default=False) + is_contribution = fields.Boolean("Cotisations", default=False) contribution_journal_id = fields.Many2one( - comodel_name='account.journal', - string='Journal des cotisations', - domain="[('type', '=', 'sale')]" + comodel_name="account.journal", + string="Journal des cotisations", + domain="[('type', '=', 'sale')]", ) tag_cotiz_id = fields.Many2one( - comodel_name='res.partner.category', - string='Etiquette de cotisation', - ondelete='restrict' + comodel_name="res.partner.category", + string="Etiquette de cotisation", + ondelete="restrict", ) diff --git a/models/res_config_settings.py b/models/res_config_settings.py index 61cb183a9fce0277fbeb904b72d40f3c27c40e23..5334e2aa1e66720dafdb48e6b26a3257d96f8aeb 100644 --- a/models/res_config_settings.py +++ b/models/res_config_settings.py @@ -5,64 +5,24 @@ from odoo import fields, models class CotisationsConfigSettings(models.TransientModel): - _inherit = 'res.config.settings' + _inherit = "res.config.settings" is_contribution = fields.Boolean( - string='Cotisations', + string="Cotisations", related="company_id.is_contribution", - readonly=False) + readonly=False, + ) contribution_journal_id = fields.Many2one( - comodel_name='account.journal', + comodel_name="account.journal", related="company_id.contribution_journal_id", readonly=False, - string='Journal des cotisations', - domain="[('type', '=', 'sale')]") + string="Journal des cotisations", + domain="[('type', '=', 'sale')]", + ) tag_cotiz_id = fields.Many2one( - comodel_name='res.partner.category', + comodel_name="res.partner.category", related="company_id.tag_cotiz_id", readonly=False, - string='Etiquette de cotisation') - - # ------------------------------------------------------ - # Actions - # ------------------------------------------------------ - def add_company_to_menu(self, menu, bool_condition): - """ - Add current company to the list of companies allowed to see menu - :param menu: target menu - :param bool_condition: condition to check to allow company or not - :return: add company to menu - """ - current_company_id = self.env.user.company_id - if bool_condition: - if current_company_id not in menu.company_ids: - menu.write({ - "company_ids": [(4, current_company_id.id)] - }) - else: - if current_company_id in menu.company_ids: - menu.write({ - "company_ids": [(3, current_company_id.id)] - }) - - # ------------------------------------------------------ - # Override Parent - # ------------------------------------------------------ - def execute(self): - """ - Rewrite execute() function to add current company to the list - of available company in ir_ui_menu - """ - res = super(CotisationsConfigSettings, self).execute() - - menu_cotiz = self.env.ref( - 'cgscop_cotisation.menu_scop_cotisation') - menu_cotiz_task_create = self.env.ref( - 'cgscop_cotisation.menu_scop_cotisation_list_task') - - bool_condition = self.is_contribution - - self.add_company_to_menu(menu_cotiz, bool_condition) - self.add_company_to_menu(menu_cotiz_task_create, bool_condition) - return res + string="Etiquette de cotisation", + ) diff --git a/models/res_partner.py b/models/res_partner.py index 67c5ab6ec7046cba252932d4083ecd6b1bdffd43..13d0939b5905257b3626041c19223ee3c2752c7e 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -5,10 +5,10 @@ from odoo import fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" contribution_report_ids = fields.One2many( - comodel_name='scop.contribution.report', - inverse_name='partner_id', - string='Cotisations', + comodel_name="scop.contribution.report", + inverse_name="partner_id", + string="Cotisations", ) diff --git a/models/scop_contribution.py b/models/scop_contribution.py deleted file mode 100644 index 03686978c46625e18cf969619a73bb858a5e6ac5..0000000000000000000000000000000000000000 --- a/models/scop_contribution.py +++ /dev/null @@ -1,71 +0,0 @@ -# © 2020 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 - - -class ScopContributions(models.Model): - _inherit = "scop.contribution" - - # TODO: remove after migration - invoice_id = fields.Many2one( - comodel_name='account.invoice', - string='Facture liée', - ondelete='cascade') - invoice_ids = fields.One2many( - comodel_name='account.invoice', - inverse_name='contribution_id', - string='Factures liées') - amount_paid = fields.Float( - compute='_compute_amount_paid', store=True) - amount_remaining = fields.Float( - compute='_compute_amount_remaining', store=True, readonly=False) - is_exempt = fields.Boolean( - string='Exonération', - compute='_compute_is_exempt', - default=False - ) - - @api.depends('amount_remaining') - @api.multi - def _compute_amount_paid(self): - for r in self: - r.amount_paid = r.amount_called - r.amount_remaining - - @api.depends('invoice_ids', 'invoice_ids.residual_signed') - @api.multi - def _compute_amount_remaining(self): - for r in self: - r.amount_remaining = sum( - r.invoice_ids.mapped('residual_signed')) - - @api.multi - def _compute_is_exempt(self): - for contrib in self: - if contrib.invoice_id: - is_refund = contrib.invoice_id.search([ - ('refund_invoice_id', '=', contrib.invoice_id.id), - ('state', 'in', ['open', 'paid'])]) - if is_refund: - contrib.is_exempt = True - else: - contrib.is_exempt = False - else: - contrib.is_exempt = False - - def view_refund(self): - tree_id = self.env.ref( - 'cgscop_cotisation.invoice_scop_contribution_refund_tree').id - refund_ids = self.invoice_id.search([ - ('refund_invoice_id', '=', self.invoice_id.id), - ('state', 'in', ['open', 'paid']) - ]) - return { - 'type': 'ir.actions.act_window', - 'name': 'Exonérations', - 'res_model': 'account.invoice', - 'views': [[tree_id, 'tree']], - 'target': 'new', - 'domain': [['id', 'in', refund_ids.ids]], - 'flags': {'action_buttons': False} - } diff --git a/models/scop_cotisation.py b/models/scop_cotisation.py index 37f9bb00da983f93fb9a2ce72b6f89ca573a26f5..731eebd7652ec8a9ce1ed13c8bb4f16bbeb9a993 100644 --- a/models/scop_cotisation.py +++ b/models/scop_cotisation.py @@ -1,95 +1,118 @@ # © 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, api - from datetime import date +from odoo import fields, models + class ScopCotisation(models.AbstractModel): _name = "scop.cotisation" _description = "Base des cotisations" year = fields.Selection( - [(year, str(year)) for year in range( - fields.Datetime.now().year - 1, fields.Datetime.now().year + 2)], - string='Année de cotisation', - required=True) + [ + (str(year), str(year)) + for year in range( + fields.Datetime.now().year - 1, fields.Datetime.now().year + 2 + ) + ], + string="Année de cotisation", + required=True, + ) company_id = fields.Many2one( - comodel_name='res.company', - string='Company', change_default=True, - required=True, readonly=True, - default=lambda self: self.env.user.company_id) + comodel_name="res.company", + string="Company", + change_default=True, + required=True, + readonly=True, + default=lambda self: self.env.user.company_id, + ) company_currency_id = fields.Many2one( - comodel_name='res.currency', related='company_id.currency_id', - string="Company Currency", readonly=True) + comodel_name="res.currency", + related="company_id.currency_id", + string="Company Currency", + readonly=True, + ) date_cotisation = fields.Date( string="Date calcul cotisation", - help="Date de calcul qui apparaitra sur le bordereau de cotisation" + help="Date de calcul qui apparaitra sur le bordereau de cotisation", ) member_count = fields.Integer( - "Adhérents renouvelés", - compute='_compute_member_count') + "Adhérents renouvelés", compute="_compute_member_count" + ) new_member_count = fields.Integer( - "Nouveaux adhérents", - compute='_compute_new_member_count') + "Nouveaux adhérents", compute="_compute_new_member_count" + ) invoiced_member_count = fields.Integer( - "Cotisations créées", - compute='_compute_invoiced_member_count') - trimester_1 = fields.Date('1er Trimestre') - trimester_2 = fields.Date('2ème Trimestre') - trimester_3 = fields.Date('3ème Trimestre') - trimester_4 = fields.Date('4ème Trimestre') + "Cotisations créées", compute="_compute_invoiced_member_count" + ) + trimester_1 = fields.Date("1er Trimestre") + trimester_2 = fields.Date("2ème Trimestre") + trimester_3 = fields.Date("3ème Trimestre") + trimester_4 = fields.Date("4ème Trimestre") # ------------------------------------------------------ # Compute fields # ------------------------------------------------------ - @api.multi def _compute_member_count(self): for cotiz in self: cotiz.member_count = len(cotiz.get_members()) - @api.multi def _compute_new_member_count(self): for cotiz in self: cotiz.new_member_count = len(cotiz.get_new_members()) - @api.multi def _compute_invoiced_member_count(self): for cotiz in self: - cotiz.invoiced_member_count = len( - cotiz.invoice_ids.mapped('partner_id')) + cotiz.invoiced_member_count = len(cotiz.invoice_ids.mapped("partner_id")) # ------------------------------------------------------ # Global functions # ------------------------------------------------------ - @api.multi def get_members(self): self.ensure_one() - members = self.env['scop.membership.period'].search([ - ('type_id', '=', self.env.ref( - 'cgscop_partner.membership_type_1').id), - ('start', '<', date(self.year, 1, 1)), - ('end', '=', None), - ]).mapped('partner_id') + members = ( + self.env["scop.membership.period"] + .search( + [ + ( + "type_id", + "=", + self.env.ref("cgscop_partner.membership_type_1").id, + ), + ("start", "<", date(self.year, 1, 1)), + ("end", "=", None), + ] + ) + .mapped("partner_id") + ) return members - @api.multi def get_new_members(self, limit_start_date=None): if not limit_start_date: limit_start_date = date(self.year, 12, 31) self.ensure_one() - members = self.env['scop.membership.period'].search([ - ('type_id', '=', self.env.ref( - 'cgscop_partner.membership_type_1').id), - ('start', '>=', date(self.year, 1, 1)), - ('start', '<=', limit_start_date), - '|', - ('end', '=', None), - ('end', '>', date(self.year, 1, 1)) - ]).mapped('partner_id') + members = ( + self.env["scop.membership.period"] + .search( + [ + ( + "type_id", + "=", + self.env.ref("cgscop_partner.membership_type_1").id, + ), + ("start", ">=", date(self.year, 1, 1)), + ("start", "<=", limit_start_date), + "|", + ("end", "=", None), + ("end", ">", date(self.year, 1, 1)), + ] + ) + .mapped("partner_id") + ) return members def round_to_closest_multiple(self, float_to_round, multiple): @@ -102,8 +125,7 @@ class ScopCotisation(models.AbstractModel): large_multiple = small_multiple + multiple # Return the closest of two - if abs(float_to_round - small_multiple) < \ - abs(float_to_round - large_multiple): + if abs(float_to_round - small_multiple) < abs(float_to_round - large_multiple): return small_multiple else: return large_multiple diff --git a/models/scop_cotisation_task.py b/models/scop_cotisation_task.py deleted file mode 100644 index c88a50327cdf98c5b2d8ee64b59aa0394a03da33..0000000000000000000000000000000000000000 --- a/models/scop_cotisation_task.py +++ /dev/null @@ -1,25 +0,0 @@ -# © 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 - - -class CotisationTask(models.Model): - _name = 'scop.cotisation.task' - _description = 'Gestion des créations des cotisations' - - year = fields.Integer('Année') - message = fields.Char("Message") - cotiz_created = fields.Integer("Appels de cotisation / Bordereaux créés") - cotiz_to_create = fields.Integer( - "Appels de cotisation / Bordereaux à créer") - is_error = fields.Boolean('En erreur', default=False) - status = fields.Selection([ - ('in_process', 'En cours'), - ('done', 'Terminé') - ], string='Statut') - company_id = fields.Many2one( - comodel_name='res.company', - string='Company', change_default=True, - required=True, readonly=True, - default=lambda self: self.env.user.company_id) diff --git a/report/__init__.py b/report/__init__.py old mode 100755 new mode 100644 index 530b04980c303e369063f0beec2f53cace402497..df1634d98ac4127ca081bd8dfd0133602849cba4 --- a/report/__init__.py +++ b/report/__init__.py @@ -1,4 +1,5 @@ # © 2020 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import account_invoice_all from . import scop_contribution_report diff --git a/report/account_invoice_all.py b/report/account_invoice_all.py new file mode 100644 index 0000000000000000000000000000000000000000..13c06b692e1c61265ae0c8b44db13f599ac9443e --- /dev/null +++ b/report/account_invoice_all.py @@ -0,0 +1,14 @@ +# © 2020 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from odoo import models + + +class AccountInvoiceReport(models.Model): + _inherit = "account.invoice.all" + + def _subquery(self): + query = super()._subquery() + query = query + " AND is_contribution is false" + return query diff --git a/report/scop_contribution_report.py b/report/scop_contribution_report.py index bb8cdbd4d9c2a1d399936465370e219e3b949f1a..ab23b67f815dc2a340c5b5e47cd10aa2dd7b8e32 100644 --- a/report/scop_contribution_report.py +++ b/report/scop_contribution_report.py @@ -1,39 +1,48 @@ # © 2022 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import tools -from odoo import models, fields, api +from psycopg2.extensions import AsIs + +from odoo import api, fields, models, tools class ScopContributionReport(models.Model): _name = "scop.contribution.report" _description = "Vue cotisations" _auto = False - _order = 'year desc, partner_id' + _order = "year desc, partner_id" - name = fields.Char(compute='_compute_name') - year = fields.Char('Année de cotisation') + name = fields.Char(compute="_compute_name") + year = fields.Char("Année de cotisation") source = fields.Selection( - string='Source', - selection=[('odoo', 'Odoo')], - required=True,) + string="Source", + selection=[("odoo", "Odoo")], + required=True, + ) type_contribution_id = fields.Many2one( comodel_name="scop.contribution.type", string="Type de cotisation", - readonly=True) - partner_id = fields.Many2one('res.partner', string='Partner', readonly=True) - amount_called = fields.Float('Montant Appelé') - amount_paid = fields.Float('Montant Payé') - amount_due = fields.Float('Montant Restant') - is_loss = fields.Boolean('Exonération/Perte', compute="_compute_is_loss") - payments = fields.Html('Paiements', compute="_compute_payments") + readonly=True, + ) + partner_id = fields.Many2one("res.partner", string="Partner", readonly=True) + amount_called = fields.Float("Montant Appelé") + amount_paid = fields.Float("Montant Payé") + amount_due = fields.Float("Montant Restant") + is_loss = fields.Boolean("Exonération/Perte", compute="_compute_is_loss") + payments = fields.Html("Paiements", compute="_compute_payments") _depends = { - 'account.invoice': [ - 'year', 'type_contribution_id', 'partner_id', - 'amount_total_signed', 'residual_company_signed', - 'state', 'type', 'is_contribution', 'refund_invoice_id' + "account.move": [ + "year", + "type_contribution_id", + "partner_id", + "amount_total_signed", + "amount_residual_signed", + "state", + "move_type", + "is_contribution", + "payment_state", ], } @@ -48,23 +57,24 @@ class ScopContributionReport(models.Model): i.type_contribution_id, i.partner_id, SUM(i.amount_total_signed) AS amount_called, - SUM(i.amount_total_signed - i.residual_company_signed) AS amount_paid, - SUM(i.residual_company_signed) AS amount_due + SUM(i.amount_total_signed - i.amount_residual_signed) AS amount_paid, + SUM(i.amount_residual_signed) AS amount_due """ return select_str def _from_invoice(self): from_str = """ FROM - account_invoice i + account_move i """ return from_str def _where_invoice(self): where_str = """ WHERE - i.state in ('open', 'paid', 'in_payment') AND - i.is_contribution = true + i.state = 'posted' + AND i.move_type in ('out_invoice', 'out_refund') + AND i.is_contribution = true """ return where_str @@ -79,8 +89,11 @@ class ScopContributionReport(models.Model): def _query_invoice(self): query = "(%s %s %s %s)" % ( - self._select_invoice(), self._from_invoice(), - self._where_invoice(), self._groupby_invoice()) + self._select_invoice(), + self._from_invoice(), + self._where_invoice(), + self._groupby_invoice(), + ) return query def _subquery(self): @@ -118,35 +131,39 @@ class ScopContributionReport(models.Model): def _query(self): query = ( - self._select() + self._subquery() + ') c ' + - self._query_groupby() + self._query_order() + self._select() + + self._subquery() + + ") c " + + self._query_groupby() + + self._query_order() ) return query - @api.model_cr + @api.model def init(self): tools.drop_view_if_exists(self.env.cr, self._table) - self.env.cr.execute("""CREATE or REPLACE VIEW %s as ( - %s - )""" % ( - self._table, self._query())) + self.env.cr.execute( + "CREATE or REPLACE VIEW %s as (%s)", + (AsIs(self._table), AsIs(self._query())), + ) # ------------------------------------------------------ # Computed fields # ------------------------------------------------------ - @api.multi def _compute_is_loss(self): for contribution in self: contribution.is_loss = contribution._get_is_loss() - @api.multi def _compute_name(self): for contribution in self: - contribution.name = (contribution.year + ' - ' + - contribution.type_contribution_id.name + - ' - ' + contribution.partner_id.name) + contribution.name = ( + contribution.year + + " - " + + contribution.type_contribution_id.name + + " - " + + contribution.partner_id.name + ) - @api.multi def _compute_payments(self): for contribution in self: contribution.payments = contribution._get_payment() @@ -155,12 +172,22 @@ class ScopContributionReport(models.Model): # Business functions # ------------------------------------------------------ def _get_is_loss(self): - invoice_ids = self.env['account.invoice'].sudo().search([ - ('year', '=', int(self.year)), - ('partner_id', '=', self.partner_id.id), - ('type_contribution_id', '=', self.type_contribution_id.id), - ]) - refund_ids = invoice_ids.filtered(lambda i: i.type == 'out_refund') + invoice_ids = ( + self.env["account.move"] + .sudo() + .search( + [ + ("year", "=", int(self.year)), + ("partner_id", "=", self.partner_id.id), + ( + "type_contribution_id", + "=", + self.type_contribution_id.id, + ), + ] + ) + ) + refund_ids = invoice_ids.filtered(lambda i: i.move_type == "out_refund") if refund_ids: return True else: @@ -169,38 +196,55 @@ class ScopContributionReport(models.Model): def _get_payment(self): self.ensure_one() payments_html = False - if self.source == 'odoo': + if self.source == "odoo": invoice_ids = self.get_invoice_contribution() - payment_ids = invoice_ids.mapped('payment_move_line_ids') + # TODO: trouver le nouveau champ payment_move_line_ids + payment_ids = invoice_ids.mapped("payment_move_line_ids") if payment_ids: - payments = payment_ids.mapped(lambda p: { - 'date': p.date, - 'name': p.name, - 'ref': p.ref, - 'credit': p.credit, - 'class': '' - } if not p.invoice_id else { - 'date': p.date, - 'name': p.name, - 'ref': '', - 'credit': p.credit, - 'class': 'text-danger' - }) + payments = payment_ids.mapped( + lambda p: { + "date": p.date, + "name": p.name, + "ref": p.ref, + "credit": p.credit, + "class": "", + } + if not p.invoice_id + else { + "date": p.date, + "name": p.name, + "ref": "", + "credit": p.credit, + "class": "text-danger", + } + ) payments_html = self._get_html_table(payments) if not payments_html: - payments_html = "<p>Il n'y a pas de paiements associés à cette cotisation</p>" + payments_html = ( + "<p>Il n'y a pas de paiements associés à cette cotisation</p>" + ) return payments_html def get_invoice_contribution(self): - invoice_ids = self.env['account.invoice'].sudo().search([ - ('year', '=', int(self.year)), - ('partner_id', '=', self.partner_id.id), - ('type_contribution_id', '=', self.type_contribution_id.id), - ('type', '=', 'out_invoice'), - '|', - ('bordereau_id.state', 'not in', ('cancel',)), - ('bordereau_id', '=', False) - ]) + invoice_ids = ( + self.env["account.move"] + .sudo() + .search( + [ + ("year", "=", int(self.year)), + ("partner_id", "=", self.partner_id.id), + ( + "type_contribution_id", + "=", + self.type_contribution_id.id, + ), + ("type", "=", "out_invoice"), + "|", + ("bordereau_id.state", "not in", ("cancel",)), + ("bordereau_id", "=", False), + ] + ) + ) return invoice_ids def _get_html_table(self, payments): @@ -227,10 +271,13 @@ class ScopContributionReport(models.Model): <td>%s</td> <td class='text-right'>%.2f €</td> </tr> - """ % (payment.get('class', ''), - payment.get('date', '').strftime('%d/%m/%Y'), - payment.get('name', ''), payment.get('ref', ''), - payment.get('credit', 0.0),) + """ % ( + payment.get("class", ""), + payment.get("date", "").strftime("%d/%m/%Y"), + payment.get("name", ""), + payment.get("ref", ""), + payment.get("credit", 0.0), + ) end_html = "</tbody></table>" return start_html + content_html + end_html diff --git a/report/scop_contribution_report.xml b/report/scop_contribution_report.xml index 6b7fbd72581220dcf5dd99fc7dbb5dce9d511d09..bb7b8e35fd725d0d3856af284161017b2b1df04f 100644 --- a/report/scop_contribution_report.xml +++ b/report/scop_contribution_report.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <!-- SEARCH VIEW --> @@ -7,18 +7,46 @@ <field name="model">scop.contribution.report</field> <field name="arch" type="xml"> <search string="Cotisations"> - <field name='partner_id'/> - <field name="year"/> - <field name="type_contribution_id"/> - <filter name="filter_paid" string="À régler" domain="[('amount_due', '!=', 0)]"/> - <filter name="filter_paid" string="Réglé" domain="[('amount_due', '=', 0)]"/> - <separator></separator> - <filter name="filter_cg" string="Cotisations CG" domain="[('type_contribution_id', '=', 1)]"/> - <filter name="filter_ur" string="Cotisations UR" domain="[('type_contribution_id', '=', 3)]"/> - <filter name="filter_fede" string="Cotisations Fédé" domain="[('type_contribution_id', '=', 2)]"/> + <field name='partner_id' /> + <field name="year" /> + <field name="type_contribution_id" /> + <filter + name="filter_paid" + string="À régler" + domain="[('amount_due', '!=', 0)]" + /> + <filter + name="filter_paid" + string="Réglé" + domain="[('amount_due', '=', 0)]" + /> + <separator /> + <filter + name="filter_cg" + string="Cotisations CG" + domain="[('type_contribution_id', '=', 1)]" + /> + <filter + name="filter_ur" + string="Cotisations UR" + domain="[('type_contribution_id', '=', 3)]" + /> + <filter + name="filter_fede" + string="Cotisations Fédé" + domain="[('type_contribution_id', '=', 2)]" + /> <group expand="0" string="Group By"> - <filter name="group_by_type_contribution_id" string="Type de cotisation" context="{'group_by':'type_contribution_id'}"/> - <filter name="group_by_year" string="Année" context="{'group_by':'year'}"/> + <filter + name="group_by_type_contribution_id" + string="Type de cotisation" + context="{'group_by':'type_contribution_id'}" + /> + <filter + name="group_by_year" + string="Année" + context="{'group_by':'year'}" + /> </group> </search> </field> @@ -30,12 +58,12 @@ <field name="model">scop.contribution.report</field> <field name="arch" type="xml"> <tree string="Cotisations"> - <field name="year"/> - <field name="type_contribution_id"/> - <field name='partner_id'/> - <field name='amount_called'/> - <field name='amount_paid'/> - <field name='amount_due'/> + <field name="year" /> + <field name="type_contribution_id" /> + <field name='partner_id' /> + <field name='amount_called' /> + <field name='amount_paid' /> + <field name='amount_due' /> </tree> </field> </record> @@ -47,8 +75,8 @@ <field name="arch" type="xml"> <form string="Cotisations"> <sheet> - <h2><field name="name"/></h2> - <separator></separator> + <h2><field name="name" /></h2> + <separator /> <table class="table table-striped table-hover"> <thead> <tr> @@ -59,15 +87,15 @@ </thead> <tbody> <tr> - <td><field name='amount_called'/> €</td> - <td><field name='amount_paid'/> €</td> - <td><field name='amount_due'/> €</td> + <td><field name='amount_called' /> €</td> + <td><field name='amount_paid' /> €</td> + <td><field name='amount_due' /> €</td> </tr> </tbody> </table> - <separator></separator> + <separator /> <h4>Détail des Paiements</h4> - <field name='payments' widget="html"/> + <field name='payments' widget="html" /> </sheet> </form> </field> @@ -79,11 +107,11 @@ <field name="model">scop.contribution.report</field> <field name="arch" type="xml"> <pivot string="Cotisations"> - <field name="year" type="row"/> - <field name="type_contribution_id" type="row"/> - <field name='amount_called' type="measure"/> - <field name='amount_paid' type="measure"/> - <field name='amount_due' type="measure"/> + <field name="year" type="row" /> + <field name="type_contribution_id" type="row" /> + <field name='amount_called' type="measure" /> + <field name='amount_paid' type="measure" /> + <field name='amount_due' type="measure" /> </pivot> </field> </record> @@ -94,10 +122,10 @@ <field name="model">scop.contribution.report</field> <field name="arch" type="xml"> <graph string="Cotisations"> - <field name="year"/> - <field name='amount_called' type="measure"/> - <field name='amount_paid' type="measure"/> - <field name='amount_due' type="measure"/> + <field name="year" /> + <field name='amount_called' type="measure" /> + <field name='amount_paid' type="measure" /> + <field name='amount_due' type="measure" /> </graph> </field> </record> @@ -112,11 +140,11 @@ <!-- Menu --> <menuitem - id="scop_contribution_report_menu" - name="Cotisations" - parent="account.account_reports_management_menu" - action="scop_contribution_report_action" - sequence="80" + id="scop_contribution_report_menu" + name="Cotisations" + parent="account.account_reports_management_menu" + action="scop_contribution_report_action" + sequence="80" /> </data> </odoo> diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv old mode 100755 new mode 100644 index 4f2ff5dd90bf3a1ebd7707b57e11307d1ff9ddf7..a6a75a0cff7931caca51cb84c17fe256ef518c6e --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,2 +1,2 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_scop_contribution_report_user,access_scop_contribution_report_user,model_scop_contribution_report,base.group_user,1,0,0,0 \ No newline at end of file +access_scop_contribution_report_user,access_scop_contribution_report_user,model_scop_contribution_report,base.group_user,1,0,0,0 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/static/src/xml/account_payment.xml b/static/src/xml/account_payment.xml index 5cc4c24ae4a60696f5f2057a5748ab1a69f39f8e..b2bfc276b5ea95bff5cb8af5aa67fdc81a7fe4a2 100644 --- a/static/src/xml/account_payment.xml +++ b/static/src/xml/account_payment.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <templates xml:space="preserve"> <!-- Copyright 2020 Le Filament @@ -6,12 +6,14 @@ <t t-extend="ShowPaymentInfo"> <t t-jquery='div.oe_form_field' t-operation='replace'> - <div class="oe_form_field" - style="margin-right: 10px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;" - t-att-title="line.date_maturity + ' - ' + line.title"> - <t t-esc="line.date_maturity"></t> - <t t-esc="line.invoice"></t> + <div + class="oe_form_field" + style="margin-right: 10px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;" + t-att-title="line.date_maturity + ' - ' + line.title" + > + <t t-esc="line.date_maturity" /> - <t t-esc="line.invoice" /> </div> </t> </t> -</templates> \ No newline at end of file +</templates> diff --git a/views/account_invoice.xml b/views/account_invoice.xml deleted file mode 100644 index a63f1185a143f58a80bb6ae883605716365142b6..0000000000000000000000000000000000000000 --- a/views/account_invoice.xml +++ /dev/null @@ -1,150 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<odoo> - <data> - - <!-- Form --> - <record id="invoice_form_scop_inherited" model="ir.ui.view"> - <field name="name">account.invoice.form.scop.inherited</field> - <field name="model">account.invoice</field> - <field name="mode">primary</field> - <field name="inherit_id" ref="account.invoice_form"/> - <field name="arch" type="xml"> - <field name="user_id" position="after"> - <field name="partner_ur_id" readonly="1" groups="base.group_no_one"/> - <field name="is_contribution" readonly="1" groups="base.group_no_one"/> - <field name="year" readonly="1"/> - </field> - - <xpath expr="//sheet/group[last()]" position="after"> - <group name="cotisations" string="Cotisations"> - <field name="liasse_fiscale_id" readonly="1"/> - </group> - </xpath> - - <xpath expr="//field[@name='partner_id']" position="attributes"> - <attribute name="string">Adhérent</attribute> - </xpath> - <xpath expr="//field[@name='date_invoice']" position="attributes"> - <attribute name="string">Date de cotisation</attribute> - </xpath> - <xpath expr="//field[@name='user_id']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - <xpath expr="//field[@name='team_id']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - - - <xpath expr="//field[@name='beneficiary_id']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - <xpath expr="//field[@name='lf_note_ref_facture']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - <xpath expr="//field[@name='team_id']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - - <xpath expr="//sheet/h1/div/label[1]" position="attributes"> - <attribute name="string">Cotisation en brouillon</attribute> - </xpath> - - </field> - </record> - - <!-- Tree --> - <record id="invoice_tree_scop_inherited" model="ir.ui.view"> - <field name="name">account.invoice.tree.scop.inherited</field> - <field name="model">account.invoice</field> - <field name="mode">primary</field> - <field name="inherit_id" ref="account.invoice_tree_with_onboarding"/> - <field name="arch" type="xml"> - - <xpath expr="//field[@name='partner_id']" position="attributes"> - <attribute name="string">Adhérent</attribute> - </xpath> - <xpath expr="//field[@name='partner_id']" position="after"> - <field name="type_contribution_id"/> - </xpath> - <xpath expr="//field[@name='date_invoice']" position="attributes"> - <attribute name="string">Date de cotisation</attribute> - </xpath> - <xpath expr="//field[@name='user_id']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - <xpath expr="//field[@name='company_id']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - <xpath expr="//field[@name='origin']" position="attributes"> - <attribute name="invisible">True</attribute> - </xpath> - <xpath expr="//field[@name='state']" position="after"> - <field name="is_sdd" invisible="1"/> - </xpath> - - </field> - </record> - - <record id="invoice_scop_contribution_refund_tree" model="ir.ui.view"> - <field name="name">account.invoice.tree.scop.contribution</field> - <field name="model">account.invoice</field> - <field name="arch" type="xml"> - <tree create="0" edit="0" delete="0"> - <field name="name"/> - <field name="date_invoice" string="Date d'émission"/> - <field name="number"/> - <field name="amount_total_signed" widget="monetary"/> - <field name="state" invisible="1"/> - </tree> - </field> - </record> - - <!-- Search --> - <record id="invoice_search_scop_inherited" model="ir.ui.view"> - <field name="name">account.invoice.search.scop.inherited</field> - <field name="model">account.invoice</field> - <field name="priority" eval="25"/> - <field name="arch" type="xml"> - <search string="Search Invoice"> - <filter name="draft" string="Brouillon" domain="[('state','=','draft')]"/> - <filter name="unpaid" string="Ouvert" domain="[('state', '=', 'open')]"/> - <!-- <filter name="in_payment" string="En Paiement" domain="[('state', '=', 'in_payment')]"/>--> - <filter name="paid" string="Payé" domain="[('state', '=', 'paid')]"/> - <filter name="late" string="Retard" domain="['&', ('date_due', '<', time.strftime('%%Y-%%m-%%d')), ('state', '=', 'open')]" help="Overdue invoices, maturity date passed"/> - <separator/> - <filter name="cotiz_equal_zero" domain="[('amount_total','=',0)]" string="Cotisation(s) égale(s) à 0"/> - <separator/> - <filter name="4_quarter" string="Sur 4 trimestres" domain="[('nb_quarter', '=', '4')]"/> - <filter name="3_quarter" string="Sur 3 trimestres" domain="[('nb_quarter', '=', '3')]"/> - <filter name="2_quarter" string="Sur 2 trimestres" domain="[('nb_quarter', '=', '2')]"/> - <filter name="1_quarter" string="Sur 1 trimestre" domain="[('nb_quarter', '=', '1')]"/> - <separator/> - <filter name="is_sdd" string="Cotisation au prélèvement" domain="[('is_sdd', '=', True)]"/> - <field name="partner_id" operator="child_of"/> - <field name="number" string="Invoice" context="{'active_test': False}" filter_domain="['|','|','|', ('number','ilike',self), ('origin','ilike',self), ('reference', 'ilike', self), ('partner_id', 'child_of', self)]"/> - <!-- <field name="user_id" string="Salesperson" domain="[('share','=', False)]"/>--> - <field name="date" string="Period"/> - <group expand="0" string="Group By"> - <filter name="group_by_partner_id" string="Adhérent" context="{'group_by':'commercial_partner_id'}"/> - <filter name="status" string="Statut" context="{'group_by':'state'}"/> - <separator/> - <filter string="Date de Facturation" name="invoicedate" context="{'group_by':'date_invoice'}"/> - <filter string="Date d'échéance" name="duedate" context="{'group_by':'date_due'}"/> - </group> - </search> - </field> - </record> - - <!-- Action --> - <record id="account.action_invoice_tree1" model="ir.actions.act_window"> - <field name="domain" eval="[('type','in', ['out_invoice']), ('is_contribution', '!=', True)]"/> - </record> - - <!-- MENUS --> - <menuitem id="menu_scop_cotisation" - name="Cotisations" - parent="account.menu_finance" - sequence="2"/> - - </data> -</odoo> \ No newline at end of file diff --git a/views/account_move.xml b/views/account_move.xml index ab6ab0cf86af3c106984891949f3736fa33a3a44..6fb83981b0cddc8b97a4333be8d515c118c15bbe 100644 --- a/views/account_move.xml +++ b/views/account_move.xml @@ -1,28 +1,236 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <!-- Copyright 2020 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <data> + <!-- ************************************** + Invoices changes for contribution + ************************************** --> + <!-- Form --> + <record id="account_ove_form_scop_inherited" model="ir.ui.view"> + <field name="name">account.move.form.scop.inherited</field> + <field name="model">account.move</field> + <field name="mode">primary</field> + <field name="inherit_id" ref="account.view_move_form" /> + <field name="arch" type="xml"> + <xpath expr="//div[@name='journal_div']" position="after"> + <field + name="partner_ur_id" + readonly="1" + groups="base.group_no_one" + /> + <field + name="is_contribution" + readonly="1" + groups="base.group_no_one" + /> + <field name="year" readonly="1" /> + </xpath> + + <xpath expr="//sheet/group[last()]" position="after"> + <group name="cotisations" string="Cotisations"> + <field name="liasse_fiscale_id" readonly="1" /> + </group> + </xpath> + + <xpath expr="//field[@name='partner_id']" position="attributes"> + <attribute name="string">Adhérent</attribute> + </xpath> + <xpath expr="//field[@name='partner_id']" position="after"> + <field name="partner_member_number" readonly="1" /> + </xpath> + <xpath expr="//field[@name='invoice_date']" position="attributes"> + <attribute name="string">Date de cotisation</attribute> + </xpath> + <xpath expr="//field[@name='user_id']" position="attributes"> + <attribute name="invisible">True</attribute> + </xpath> + <xpath expr="//field[@name='team_id']" position="attributes"> + <attribute name="invisible">True</attribute> + </xpath> + + <xpath expr="//field[@name='beneficiary_id']" position="attributes"> + <attribute name="invisible">True</attribute> + </xpath> + <xpath expr="//field[@name='team_id']" position="attributes"> + <attribute name="invisible">True</attribute> + </xpath> + </field> + </record> + + <!-- Tree --> + <record id="account_move_tree_scop_inherited" model="ir.ui.view"> + <field name="name">account.move.tree.scop.inherited</field> + <field name="model">account.move</field> + <field name="mode">primary</field> + <field name="inherit_id" ref="account.view_out_invoice_tree" /> + <field name="arch" type="xml"> + <xpath expr="//field[@name='partner_id']" position="before"> + <field name="partner_member_number" readonly="1" /> + </xpath> + <xpath expr="//field[@name='partner_id']" position="attributes"> + <attribute name="string">Adhérent</attribute> + </xpath> + <xpath expr="//field[@name='partner_id']" position="after"> + <field name="type_contribution_id" /> + </xpath> + <xpath expr="//field[@name='invoice_date']" position="attributes"> + <attribute name="string">Date de cotisation</attribute> + </xpath> + <xpath expr="//field[@name='company_id']" position="attributes"> + <attribute name="invisible">True</attribute> + </xpath> + <xpath expr="//field[@name='invoice_origin']" position="attributes"> + <attribute name="invisible">True</attribute> + </xpath> + <xpath expr="//field[@name='state']" position="after"> + <field name="is_sdd" invisible="1" /> + </xpath> + + </field> + </record> + + <record id="account_move_scop_contribution_refund_tree" model="ir.ui.view"> + <field name="name">account.invoice.tree.scop.contribution</field> + <field name="model">account.move</field> + <field name="arch" type="xml"> + <tree create="0" edit="0" delete="0"> + <field name="name" /> + <field name="invoice_date" string="Date d'émission" /> + <field name="ref" /> + <field name="amount_total_signed" widget="monetary" /> + <field name="state" invisible="1" /> + </tree> + </field> + </record> + + <!-- Search --> + <record id="account_move_search_scop_inherited" model="ir.ui.view"> + <field name="name">account.move.search.scop.inherited</field> + <field name="model">account.move</field> + <field name="priority" eval="25" /> + <field name="arch" type="xml"> + <search string="Search Invoice"> + <filter + name="draft" + string="Brouillon" + domain="['|', ('state','=','draft'), ('move_type','in', ['out_invoice', 'out_refund'])]" + /> + <filter + name="unpaid" + string="Non payées" + domain="[('payment_state', 'in', ['not_paid', 'in_payment', 'partial']), ('state', '=', 'posted')]" + /> + <filter + name="paid" + string="Payé" + domain="[('payment_state', '=', 'paid'), ('state', '=', 'posted')]" + /> + <filter + name="late" + string="Retard" + domain="['&', ('invoice_date_due', '<', time.strftime('%Y-%m-%d')), ('state', '=', 'posted'), ('payment_state', 'in', ('not_paid', 'partial'))]" + /> + <separator /> + <filter + name="cotiz_equal_zero" + domain="[('amount_total','=',0)]" + string="Cotisation(s) égale(s) à 0" + /> + <separator /> + <filter + name="is_sdd" + string="Cotisation au prélèvement" + domain="[('is_sdd', '=', True)]" + /> + <field name="partner_id" operator="child_of" /> + <field + name="name" + string="Invoice" + context="{'active_test': False}" + filter_domain="['|','|','|', ('name','ilike',self), ('invoice_origin','ilike',self), ('reference', 'ilike', self), ('partner_id', 'child_of', self)]" + /> + <field name="date" string="Period" /> + <group expand="0" string="Group By"> + <filter + name="group_by_partner_id" + string="Adhérent" + context="{'group_by':'commercial_partner_id'}" + /> + <filter + name="status" + string="Statut" + context="{'group_by':'state'}" + /> + <separator /> + <filter + string="Date de Facturation" + name="invoicedate" + context="{'group_by':'invoice_date'}" + /> + <filter + string="Date d'échéance" + name="duedate" + context="{'group_by':'invoice_date_due'}" + /> + </group> + </search> + </field> + </record> + + <!-- Action --> + <record id="account.action_move_out_invoice_type" model="ir.actions.act_window"> + <field + name="domain" + eval="[('move_type','=', 'out_invoice'), ('is_contribution', '!=', True)]" + /> + </record> + <record id="account.action_move_out_refund_type" model="ir.actions.act_window"> + <field + name="domain" + eval="[('move_type','=', 'out_refund'), ('is_contribution', '!=', True)]" + /> + </record> + + <!-- MENUS --> + <menuitem + id="menu_scop_cotisation" + name="Cotisations" + parent="account.menu_finance" + sequence="2" + /> + + <!-- ************************************** + Move changes for SDD rejected payments + ************************************** --> <!-- Tree View --> <record id="scop_account_move_tree" model="ir.ui.view"> <field name="name">scop.account.move.tree</field> <field name="model">account.move</field> <field name="arch" type="xml"> - <tree decoration-info="state == 'draft'" string="Pièces comptables" create="0" edit="0"> - <field name="date"/> - <field name="name"/> - <field name="partner_id"/> - <field name="ref"/> - <field name="journal_id"/> - <field name="amount" sum="Total Amount"/> - <field name="reverse_date"/> - <field name="reverse_entry_id"/> - <button name="%(account.action_view_account_move_reversal)d" type="action" - string="Rejeter (extourne)" class="btn-outline-danger btn-sm" - attrs="{'invisible': [('reverse_entry_id', '!=', False), ('state', '=', 'posted')]}"/> - <field name="state"/> - <field name="currency_id" invisible="1"/> + <tree + decoration-info="state == 'draft'" + string="Pièces comptables" + create="0" + edit="0" + > + <field name="date" /> + <field name="name" /> + <field name="partner_id" /> + <field name="ref" /> + <field name="journal_id" /> + <field name="amount_total" sum="Total Amount" /> + <field name="reversed_entry_id" /> + <button + name="%(account.action_view_account_move_reversal)d" + type="action" + string="Rejeter (extourne)" + class="btn-outline-danger btn-sm" + attrs="{'invisible': [('reversed_entry_id', '!=', False), ('state', '=', 'posted')]}" + /> + <field name="state" /> + <field name="currency_id" invisible="1" /> </tree> </field> </record> @@ -33,13 +241,21 @@ <field name="model">account.move</field> <field name="arch" type="xml"> <search string="Pièces comptables"> - <field name="partner_id" string="Adhérent"/> - <field name="ref" string="Référence"/> - <field name="name"/> - <filter name="rejected" domain="[('reverse_entry_id', '!=', False)]" string="Rejetés"/> - <filter name="not_rejected" domain="[('reverse_entry_id', '=', False)]" string="En cours"/> + <field name="partner_id" string="Adhérent" /> + <field name="ref" string="Référence" /> + <field name="name" /> + <filter + name="rejected" + domain="[('reversed_entry_id', '!=', False)]" + string="Rejetés" + /> + <filter + name="not_rejected" + domain="[('reversed_entry_id', '=', False)]" + string="En cours" + /> </search> </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/account_payment_line.xml b/views/account_payment_line.xml index e176b5b989ca535bbd68f976265d22dec5c3d325..1fa4a22ff96f42db456c6f431d6404d6cb5599b2 100644 --- a/views/account_payment_line.xml +++ b/views/account_payment_line.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <!-- Copyright 2020 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> @@ -9,17 +9,30 @@ <field name="model">account.payment.line</field> <field name="arch" type="xml"> <tree string="Payment Lines" editable="top" create="0"> - <field name="partner_id"/> - <field name="communication"/> - <field name="partner_bank_id" domain="[('partner_id', '=', partner_id)]" options="{'no_create': 1}"/> - <field name="mandate_id" domain="[('partner_id', '=', partner_id)]" options="{'no_create': 1}"/> - <field name="move_line_id" invisible="1"/> - <field name="ml_maturity_date"/> - <field name="date" readonly="1"/> - <field name="amount_currency" string="Montant"/> - <field name="name"/> - <field name="amount_company_currency" sum="Total in Company Currency" invisible="1"/> - <field name="payment_type" invisible="1"/> + <field name="company_id" invisible="1" /> + <field name="partner_id" /> + <field name="communication" /> + <field + name="partner_bank_id" + domain="[('partner_id', '=', partner_id)]" + options="{'no_create': 1}" + /> + <field + name="mandate_id" + domain="[('partner_id', '=', partner_id)]" + options="{'no_create': 1}" + /> + <field name="move_line_id" invisible="1" /> + <field name="ml_maturity_date" /> + <field name="date" readonly="1" /> + <field name="amount_currency" string="Montant" /> + <field name="name" /> + <field + name="amount_company_currency" + sum="Total in Company Currency" + invisible="1" + /> + <field name="payment_type" invisible="1" /> </tree> </field> </record> @@ -30,13 +43,13 @@ <field name="model">account.payment.line</field> <field name="arch" type="xml"> <search string="Lignes de paiement"> - <field name="partner_id" string="Adhérent"/> - <field name="communication" string="N° Facture"/> - <field name="mandate_id" string="Mandat de prélèvement"/> - <field name="partner_bank_id" string="Compte bancaire"/> + <field name="partner_id" string="Adhérent" /> + <field name="communication" string="N° Facture" /> + <field name="mandate_id" string="Mandat de prélèvement" /> + <field name="partner_bank_id" string="Compte bancaire" /> </search> </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/account_payment_order.xml b/views/account_payment_order.xml index 47a3907b38b74c952f4b754f522c640491df6dc7..51df21e2ad57386c556ab137c28d100817ae7065 100644 --- a/views/account_payment_order.xml +++ b/views/account_payment_order.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <!-- Copyright 2020 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> @@ -7,54 +7,90 @@ <record id="account_payment_order_form" model="ir.ui.view"> <field name="name">account.payment.order.form</field> <field name="model">account.payment.order</field> - <field name="inherit_id" ref="account_payment_order.account_payment_order_form"/> + <field + name="inherit_id" + ref="account_payment_order.account_payment_order_form" + /> + <field name="priority">100</field> <field name="arch" type="xml"> <xpath expr="//button[@name='action_cancel']" position="attributes"> - <attribute name="groups">base.group_system,cgscop_partner.group_cg_administrator</attribute> - <attribute name="confirm">Confirmer l'annulation de l'ordre de prélèvement ?</attribute> + <attribute + name="groups" + >base.group_system,cgscop_partner.group_cg_administrator</attribute> + <attribute + name="confirm" + >Confirmer l'annulation de l'ordre de prélèvement ?</attribute> </xpath> - <xpath expr="//button[@name='action_done_cancel']" position="attributes"> - <attribute name="groups">base.group_system,cgscop_partner.group_cg_administrator</attribute> - <attribute name="confirm">Confirmer l'annulation de l'ordre de prélèvement ?</attribute> + <xpath + expr="//button[@name='action_uploaded_cancel']" + position="attributes" + > + <attribute + name="groups" + >base.group_system,cgscop_partner.group_cg_administrator</attribute> + <attribute + name="confirm" + >Confirmer l'annulation de l'ordre de prélèvement ?</attribute> </xpath> <xpath expr="//field[@name='bank_line_count']" position="after"> - <field name="payment_line_amount"/> - <field name="bank_line_amount"/> - <button name="view_payment_line" - type="object" - string="Modifier les lignes de paiement" - attrs="{'invisible': [('state', '!=', 'draft')]}"/> + <field name="payment_line_amount" /> + <field name="bank_line_amount" /> + <button + name="view_payment_line" + type="object" + string="Modifier les lignes de paiement" + attrs="{'invisible': [('state', '!=', 'draft')]}" + /> </xpath> <xpath expr="//field[@name='description']" position="after"> - <button name="view_account_move" - type="object" - string="Gérer les rejets de prélèvement" - class="btn-info" - attrs="{'invisible': [('state', 'not in', ('uploaded', 'done'))]}"/> + <button + name="view_account_move" + type="object" + string="Gérer les rejets de prélèvement" + class="btn-info" + attrs="{'invisible': [('state', 'not in', ('uploaded', 'done'))]}" + /> </xpath> <xpath expr="//notebook" position="inside"> <page name="attachments" string="Fichiers de prélèvements"> <field name="attachment_ids"> <tree> - <field name="create_date"/> - <field name="name"/> - <field name="type"/> - <field name="datas" filename="datas_fname"/> - <field name="create_uid"/> + <field name="create_date" /> + <field name="name" /> + <field name="type" /> + <field name="datas" filename="datas_fname" /> + <field name="create_uid" /> </tree> <form> - <h1><field name="name"/></h1> + <h1><field name="name" /></h1> <group> <group> - <field name="datas" filename="datas_fname" attrs="{'invisible':[('type','=','url')]}" string="Télécharger le fichier"/> - <field name="datas_fname" invisible="1" attrs="{'invisible':[('type','=','url')]}" class="oe_inline oe_right"/> - <field name="url" widget="url" attrs="{'invisible':[('type','=','binary')]}"/> - <field name="mimetype" groups="base.group_no_one"/> - <field name="type"/> + <field + name="datas" + filename="name" + attrs="{'invisible':[('type','=','url')]}" + string="Télécharger le fichier" + /> + <field + name="name" + invisible="1" + attrs="{'invisible':[('type','=','url')]}" + class="oe_inline oe_right" + /> + <field + name="url" + widget="url" + attrs="{'invisible':[('type','=','binary')]}" + /> + <field + name="mimetype" + groups="base.group_no_one" + /> + <field name="type" /> </group> <group> - <field name="create_uid"/> - <field name="create_date"/> + <field name="create_uid" /> + <field name="create_date" /> </group> </group> </form> @@ -64,4 +100,4 @@ </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/res_config_settings.xml b/views/res_config_settings.xml index f97b36ad4962d78d1d9b9c34cb8c4f2cad56bcc7..14380d601be660109b172daedb5e6c2ccc969036 100644 --- a/views/res_config_settings.xml +++ b/views/res_config_settings.xml @@ -1,14 +1,17 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8" ?> <odoo> <data> <record id="res_config_settings_view_form_cotisations" model="ir.ui.view"> <field name="name">res.config.settings.view.form.inherit.cotisations</field> <field name="model">res.config.settings</field> - <field name="priority" eval="25"/> - <field name="inherit_id" ref="account.res_config_settings_view_form"/> + <field name="priority" eval="25" /> + <field name="inherit_id" ref="account.res_config_settings_view_form" /> <field name="arch" type="xml"> - <xpath expr="//div[@id='setup']" position="after"> + <xpath + expr="//div[@name='fiscal_localization_setting_container']" + position="after" + > <h2>Cotisations</h2> <div class="row mt16 o_settings_container" name="contribution"> <div class="col-xs-12 col-md-6 o_setting_box"> @@ -16,26 +19,32 @@ <field name="is_contribution" /> </div> <div class="o_setting_right_pane"> - <label for="is_contribution"/> + <label for="is_contribution" /> <div class="text-muted"> Activer la gestion des cotisations pour cette société </div> </div> - <div class="o_setting_left_pane"/> + <div class="o_setting_left_pane" /> <div class="o_setting_right_pane"> - <label for="contribution_journal_id"/> + <label for="contribution_journal_id" /> <div class="text-muted"> Définit le journal des cotisations </div> - <field name="contribution_journal_id" options="{'no_open': True, 'no_create': True}"/> + <field + name="contribution_journal_id" + options="{'no_open': True, 'no_create': True}" + /> </div> - <div class="o_setting_left_pane"/> + <div class="o_setting_left_pane" /> <div class="o_setting_right_pane"> - <label for="tag_cotiz_id"/> + <label for="tag_cotiz_id" /> <div class="text-muted"> Etiquette associée aux contacts cotisations </div> - <field name="tag_cotiz_id" options="{'no_open': True, 'no_create': True}"/> + <field + name="tag_cotiz_id" + options="{'no_open': True, 'no_create': True}" + /> </div> </div> </div> @@ -44,4 +53,4 @@ </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/res_partner.xml b/views/res_partner.xml index b0a5c4532275eb22b82859dcb5002806ca057788..43b0281a37b72c5add99913718081dab273929e3 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" ?> <odoo> <!-- Copyright 2020 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> @@ -7,21 +7,33 @@ <record id="scop_contact_view_form" model="ir.ui.view"> <field name="name">res.partner.scop.view.form</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='scop_membership']" position="after"> - <page name='scop_contribution' string="Cotisations" attrs="{'invisible': ['|', ('is_cooperative', '!=', True), ('project_status', '!=', '6_suivi')]}"> + <page + name='scop_contribution' + string="Cotisations" + attrs="{'invisible': ['|', ('is_cooperative', '!=', True), ('project_status', '!=', '6_suivi')]}" + > <notebook> <page name="contribution" string="Appels de Cotisations"> <field name="contribution_report_ids" mode="tree,form"> - <tree create="false" edit="false" delete="false" default_order="year desc"> - <field name="year"/> - <field name="type_contribution_id"/> - <field name='partner_id'/> - <field name='amount_called'/> - <field name='amount_paid'/> - <field name='amount_due'/> - <field name='is_loss' style="text-align: center;"/> + <tree + create="false" + edit="false" + delete="false" + default_order="year desc" + > + <field name="year" /> + <field name="type_contribution_id" /> + <field name='partner_id' /> + <field name='amount_called' /> + <field name='amount_paid' /> + <field name='amount_due' /> + <field + name='is_loss' + style="text-align: center;" + /> </tree> </field> </page> @@ -31,4 +43,4 @@ </field> </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/scop_cotisation_task.xml b/views/scop_cotisation_task.xml deleted file mode 100644 index 456ec4dbf5b01f85fbfbe8a12292a0d811d81254..0000000000000000000000000000000000000000 --- a/views/scop_cotisation_task.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2021 Le Filament - License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - -<odoo> - <data> - - <!-- TREE VIEW --> - <record model="ir.ui.view" id="view_scop_cotisation_task_tree"> - <field name="name">scop.cotisation.task.tree</field> - <field name="model">scop.cotisation.task</field> - <field name="arch" type="xml"> - <tree create="false" string="Taches création cotisations" default_order="create_date desc"> - <field name="create_date"/> - <field name="year"/> - <field name='status'/> - <field name='cotiz_created'/> - <field name='cotiz_to_create'/> - <field name='is_error'/> - <field name="message"/> - </tree> - </field> - </record> - - <!-- ACTIONS VIEWS--> - <record model="ir.actions.act_window" id="action_scop_cotisation_task"> - <field name="name">Taches cotisation</field> - <field name="res_model">scop.cotisation.task</field> - <field name="view_mode">tree,form</field> - </record> - - <!-- MENU --> - <menuitem id="menu_scop_cotisation_list_task" - parent="account.menu_finance_configuration" - name="Taches création cotisations" - sequence="50" - action="action_scop_cotisation_task"/> - - </data> -</odoo> \ No newline at end of file diff --git a/wizard/__init__.py b/wizard/__init__.py index 19819ada1414c6c1a760bcb3f85287c244b64e07..6e7a64ae019f927458367555b9c806f7f1cd7fe0 100644 --- a/wizard/__init__.py +++ b/wizard/__init__.py @@ -1,4 +1,4 @@ # © 2020 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import account_invoice_refund +from . import account_move_reversal diff --git a/wizard/account_invoice_refund.py b/wizard/account_invoice_refund.py deleted file mode 100644 index ecbcf3e795c9b25523a21adfadc207a8d0cb5f5c..0000000000000000000000000000000000000000 --- a/wizard/account_invoice_refund.py +++ /dev/null @@ -1,26 +0,0 @@ -# © 2020 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 - - -class ContributionAccountInvoiceRefund(models.TransientModel): - _inherit = 'account.invoice.refund' - - def _get_refund(self, inv, mode): - """ - Surcharge la la fonction initiale pour ajouter l'année - et le type cotisation - :param inv: facture - :param mode: wizard mode - :return: avoir - """ - refund = super( - ContributionAccountInvoiceRefund, self)._get_refund(inv, mode) - refund.update({ - 'year': inv.year, - 'is_contribution': inv.is_contribution, - 'type_contribution_id': inv.type_contribution_id.id, - 'payment_term_id': inv.payment_term_id.id, - }) - return refund diff --git a/wizard/account_move_reversal.py b/wizard/account_move_reversal.py new file mode 100644 index 0000000000000000000000000000000000000000..bc8cbebe304c71003dfa09737d301a5660e2a824 --- /dev/null +++ b/wizard/account_move_reversal.py @@ -0,0 +1,28 @@ +# © 2020 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class ContributionAccountMoveReversal(models.TransientModel): + _inherit = "account.move.reversal" + + def _prepare_default_reversal(self, move): + """ + Surcharge la la fonction initiale pour ajouter l'année + et le type cotisation + :param move: facture + :return: avoir + """ + refund = super(ContributionAccountMoveReversal, self)._prepare_default_reversal( + move + ) + refund.update( + { + "year": move.year, + "is_contribution": move.is_contribution, + "type_contribution_id": move.type_contribution_id.id, + "payment_term_id": move.payment_term_id.id, + } + ) + return refund