diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index fed88d70d23ecb3297ea28854b320c4d62ee3c26..0000000000000000000000000000000000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,188 +0,0 @@ -env: - browser: true - es6: true - -# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 -parserOptions: - ecmaVersion: 2019 - -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 - luxon: 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/.gitignore b/.gitignore index d99361a24aa02c2d19d8165c3a057b84bc575166..109270f27c2a80740fab3c0fbc084b9d938f964e 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,19 @@ var/ *.eggs .copier-answers.yml +# Windows installers +*.msi + +# Debian packages +*.deb + +# Redhat packages +*.rpm + +# MacOS packages +*.dmg +*.pkg + # Installer logs pip-log.txt pip-delete-this-directory.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3efb4d9157dc36d84e372eec5fc21e7f4a417a58..207e4c9037d15863a1efcc9bd98b6199792df472 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ exclude: | # 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/| + .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs| # Maybe reactivate this when all README files include prettier ignore tags? ^README\.md$| # Library files can have extraneous formatting (even minimized) @@ -16,11 +16,13 @@ exclude: | readme/.*\.(rst|md)$| # Ignore build and dist directories in addons /build/|/dist/| + # Ignore test files in addons + /tests/samples/.*| # You don't usually want a bot to modify your legal texts (LICENSE.*|COPYING.*) default_language_version: python: python3 - node: "16.17.0" + node: "22.9.0" repos: - repo: local hooks: @@ -37,46 +39,50 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools - rev: f71041f22b8cd68cf7c77b73a14ca8d8cd190a60 + rev: bf9ecb9938b6a5deca0ff3d870fbd3f33341fded 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"] - - id: oca-gen-addon-readme - args: - - --addons-dir=. - - --branch=16.0 - - --org-name=lefilament - - --repo-name=template_module - - --if-source-changed - - --keep-source-digest - repo: https://github.com/OCA/odoo-pre-commit-hooks - rev: v0.0.25 + rev: v0.0.33 hooks: - id: oca-checks-odoo-module - id: oca-checks-po - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.7.1 + args: + - --disable=po-pretty-format + - repo: local hooks: - id: prettier name: prettier (with plugin-xml) - additional_dependencies: - - "prettier@2.7.1" - - "@prettier/plugin-xml@2.2.0" + entry: prettier args: - - --plugin=@prettier/plugin-xml + - --write + - --list-different + - --ignore-unknown + types: [text] files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ - - repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.24.0 + language: node + additional_dependencies: + - "prettier@3.3.3" + - "@prettier/plugin-xml@3.4.1" + - repo: local hooks: - id: eslint - verbose: true + name: eslint + entry: eslint args: - --color - --fix + verbose: true + types: [javascript] + language: node + additional_dependencies: + - "eslint@9.12.0" + - "eslint-plugin-jsdoc@50.3.1" - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.6.0 hooks: - id: trailing-whitespace # exclude autogenerated files @@ -98,13 +104,13 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.3 + rev: v0.6.8 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - repo: https://github.com/OCA/pylint-odoo - rev: v8.0.19 + rev: v9.1.3 hooks: - id: pylint_odoo name: pylint with optional checks diff --git a/.pylintrc b/.pylintrc index 71c476d4f10ac08a7333729b93705c9573d240d5..b855a9270efdb66248c84038041d1a589961ee44 100644 --- a/.pylintrc +++ b/.pylintrc @@ -5,12 +5,12 @@ 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=16.0 +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=18.0 [MESSAGES CONTROL] disable=all diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 99064933ef82c469ba5fda5b2904447c05c99dbe..f9450512a1b688db0b671c400b492ac9e4e2e425 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -9,7 +9,7 @@ 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=16.0 +valid-odoo-versions=18.0 [MESSAGES CONTROL] disable=all diff --git a/.ruff.toml b/.ruff.toml index 0240c75f6a4ae4550f3473ad0a5faaef022bf6c7..0f1e35f24803bf777951495f745cb2f1630cb4cb 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -15,16 +15,16 @@ exclude = ["setup/*"] [format] exclude = ["setup/*"] -[per-file-ignores] +[lint.per-file-ignores] "__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py "__manifest__.py" = ["B018"] # useless expression -[isort] +[lint.isort] section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"] -[isort.sections] +[lint.isort.sections] "odoo" = ["odoo"] "odoo-addons" = ["odoo.addons"] -[mccabe] +[lint.mccabe] max-complexity = 16 diff --git a/__manifest__.py b/__manifest__.py index e91974ab101e9216796585f42f598fb0a1a164a6..0a7bfd27f2c7d3bcc991a68469b04380f224ebdc 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -3,19 +3,22 @@ "summary": "Gestion des contrats de garantie des outils financiers", "author": "Le Filament, Odoo Community Association (OCA)", "website": "https://le-filament.com", - "version": "16.0.1.0.0", + "version": "18.0.1.0.0", "license": "AGPL-3", "depends": [ "financial_contract", + "financial_contract_external", ], "data": [ # security + "security/security_rules.xml", "security/ir.model.access.csv", # datas # views "views/financial_contract_guarantee.xml", "views/financial_contract_guarantee_line.xml", "views/financial_product_template_guarantee.xml", + "views/res_config_settings.xml", "views/res_partner.xml", # views menu "views/menus.xml", diff --git a/eslint.config.cjs b/eslint.config.cjs new file mode 100644 index 0000000000000000000000000000000000000000..0d5731f89a8bc2073894c17dfe41e410db0e4cfe --- /dev/null +++ b/eslint.config.cjs @@ -0,0 +1,202 @@ +jsdoc = require("eslint-plugin-jsdoc"); + +const config = [{ + plugins: { + jsdoc, + }, + + languageOptions: { + globals: { + _: "readonly", + $: "readonly", + fuzzy: "readonly", + jQuery: "readonly", + moment: "readonly", + odoo: "readonly", + openerp: "readonly", + owl: "readonly", + luxon: "readonly", + }, + + ecmaVersion: 2024, + sourceType: "script", + }, + + 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", + + "jsdoc/check-tag-names": "warn", + "jsdoc/check-types": "warn", + "jsdoc/require-param-description": "off", + "jsdoc/require-return": "off", + "jsdoc/require-return-description": "off", + "jsdoc/require-return-type": "off", + + "valid-typeof": "warn", + yoda: "warn", + }, + + settings: { + jsdoc: { + tagNamePreference: { + arg: "param", + argument: "param", + augments: "extends", + constructor: "class", + exception: "throws", + func: "function", + method: "function", + prop: "property", + return: "returns", + virtual: "abstract", + yield: "yields", + }, + preferredTypes: { + array: "Array", + bool: "Boolean", + boolean: "Boolean", + number: "Number", + object: "Object", + str: "String", + string: "String", + }, + }, + }, + +}, { + files: ["**/*.esm.js"], + + languageOptions: { + ecmaVersion: 2024, + sourceType: "module", + }, +}]; + +module.exports = config diff --git a/models/__init__.py b/models/__init__.py index 1de888b9b2d7a742922073923889da5c61cbbcb5..2708798798c3f7cf1b3069c3d0d9c0a8afb15d75 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -4,4 +4,5 @@ from . import financial_contract_guarantee_suspensive_condition from . import financial_product_guarantee_suspensive_condition from . import financial_product_template_guarantee from . import res_company +from . import res_config_settings from . import res_partner diff --git a/models/financial_contract_guarantee.py b/models/financial_contract_guarantee.py index 0353ebdeb338bfa66ced525f1ab6f3f8402f6bc8..ec8f10ebd7c4cb7afaf65c74cdf7d0e84cd00092 100644 --- a/models/financial_contract_guarantee.py +++ b/models/financial_contract_guarantee.py @@ -24,6 +24,7 @@ class FinancialContractGuarantee(models.Model): product_id = fields.Many2one( comodel_name="financial.product.template.guarantee", string="Gamme", + check_company=True, required=True, ) suspensive_condition_ids = fields.One2many( diff --git a/models/financial_contract_guarantee_line.py b/models/financial_contract_guarantee_line.py index 5ec0d82dbca53bdf102875618834cfed584d3fa7..b787418c50481957651525b3f35c7e9bcc92e247 100644 --- a/models/financial_contract_guarantee_line.py +++ b/models/financial_contract_guarantee_line.py @@ -12,7 +12,7 @@ class FinancialContractGuaranteeLine(models.Model): "partner_id.name", "partner_id.member_number", ] - _order = "line_date desc" + _order = "line_date desc, id desc" guarantee_id = fields.Many2one( comodel_name="financial.contract.guarantee", diff --git a/models/res_company.py b/models/res_company.py index 55698fecda271da7f8c8cef545ceaeed5b373c7a..016004a5f4d4f2836559ad7d7e125098f5bee81a 100644 --- a/models/res_company.py +++ b/models/res_company.py @@ -7,7 +7,13 @@ from odoo import api, fields, models class ResCompany(models.Model): _inherit = "res.company" - contract_guarantee_sequence_id = fields.Many2one("ir.sequence") + contract_guarantee_sequence_id = fields.Many2one( + comodel_name="ir.sequence", + string="Séquence des contrats de garantie", + check_company=True, + domain="[('company_id', '=', company_id), ('code', '=', 'financial.contract.guarantee')]", + ) + amount_guarantee_limit = fields.Monetary("Plafond de garantie") # ------------------------------------------------------ # Fields declaration @@ -49,7 +55,7 @@ class ResCompany(models.Model): "prefix": "G%(year)s%(month)s", "padding": 4, "implementation": "no_gap", - "code": f"financial.contract.guarantee.company_{res.id}", + "code": "financial.contract.guarantee", } ) return res diff --git a/models/res_config_settings.py b/models/res_config_settings.py new file mode 100644 index 0000000000000000000000000000000000000000..9071add1ebc71fa63aacda83f3efa74407608d48 --- /dev/null +++ b/models/res_config_settings.py @@ -0,0 +1,16 @@ +# © 2024 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 ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + contract_guarantee_sequence_id = fields.Many2one( + related="company_id.contract_guarantee_sequence_id", readonly=False + ) + amount_guarantee_limit = fields.Monetary( + related="company_id.amount_guarantee_limit", readonly=False + ) + currency_id = fields.Many2one(related="company_id.currency_id") diff --git a/models/res_partner.py b/models/res_partner.py index a53ea3a1426f278199846d4da8cd89e564abd71a..6ad8bd80ae866b4d95048bb18c1abbb4846fc538 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -18,6 +18,15 @@ class ResPartner(models.Model): financial_contract_guarantee_count = fields.Integer( compute="_compute_financial_contract_guarantee_count" ) + guarantee_amount_ongoing = fields.Float( + string="En cours de garantie", compute="_compute_ongoing_guarantee" + ) + guarantee_amount_left = fields.Float( + string="Montant de garantie disponible", compute="_compute_ongoing_guarantee" + ) + is_amount_guarantee_limit = fields.Boolean( + string="Plafond de garantie dépassé", compute="_compute_ongoing_guarantee" + ) # ------------------------------------------------------ # SQL Constraints @@ -36,6 +45,23 @@ class ResPartner(models.Model): partner.financial_contract_guarantee_ids.__len__() ) + def _compute_ongoing_guarantee(self): + for partner in self: + guarantee_ids = partner.financial_contract_guarantee_ids.filtered( + lambda guarantee: guarantee.company_id == self.env.company + and guarantee.state == "contract" + ) + ongoing_guarantee_amount = sum(guarantee_ids.mapped("remaining_capital")) + partner.guarantee_amount_ongoing = ongoing_guarantee_amount + partner.guarantee_amount_left = ( + self.env.company.amount_guarantee_limit - ongoing_guarantee_amount + ) + partner.is_amount_guarantee_limit = ( + True + if ongoing_guarantee_amount > self.env.company.amount_guarantee_limit + else False + ) + # ------------------------------------------------------ # Onchange / Constraints # ------------------------------------------------------ @@ -53,7 +79,7 @@ class ResPartner(models.Model): "type": "ir.actions.act_window", "name": "Contrats de garantie", "res_model": "financial.contract.guarantee", - "view_mode": "tree,form", + "view_mode": "list,form", "domain": [("partner_id", "=", self.id)], "flags": {"mode": "readonly"}, } diff --git a/prettier.config.cjs b/prettier.config.cjs new file mode 100644 index 0000000000000000000000000000000000000000..e66cd82cc1e4dfeded9749598144f820c8491fab --- /dev/null +++ b/prettier.config.cjs @@ -0,0 +1,14 @@ +/** @type {import('prettier').Config} */ + +const config = { + // https://github.com/prettier/prettier/issues/15388#issuecomment-1717746872 + plugins: [require.resolve("@prettier/plugin-xml")], + bracketSpacing: false, + printWidth: 88, + proseWrap: "always", + semi: true, + trailingComma: "es5", + xmlWhitespaceSensitivity: "preserve", +}; + +module.exports = config; diff --git a/security/security_rules.xml b/security/security_rules.xml new file mode 100644 index 0000000000000000000000000000000000000000..b0199453007441e13f01e7f44248d175e27c093d --- /dev/null +++ b/security/security_rules.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" ?> +<odoo> + <!-- + Group rules + --> + <record id="financial_product_template_multi_company_rule" model="ir.rule"> + <field name="name">Financial Product Template Guarantee Multi Company</field> + <field name="model_id" ref="model_financial_product_template_guarantee" /> + <field + name="domain_force" + >[('company_id', 'in', company_ids + [False])]</field> + <field + name="groups" + eval="[(6, 0, [ref('financial_contract.group_financial_user')])]" + /> + <field name="perm_read" eval="False" /> + <field name="perm_write" eval="True" /> + <field name="perm_create" eval="True" /> + <field name="perm_unlink" eval="True" /> + </record> + <record id="financial_contract_guarantee_multi_company_rule" model="ir.rule"> + <field name="name">Financial Contract Guarantee Multi Company</field> + <field name="model_id" ref="model_financial_contract_guarantee" /> + <field + name="domain_force" + >[('company_id', 'in', company_ids + [False])]</field> + <field + name="groups" + eval="[(6, 0, [ref('financial_contract.group_financial_user')])]" + /> + <field name="perm_read" eval="False" /> + <field name="perm_write" eval="True" /> + <field name="perm_create" eval="True" /> + <field name="perm_unlink" eval="True" /> + </record> + <record id="financial_contract_guarantee_line_multi_company_rule" model="ir.rule"> + <field name="name">Financial Contract Guarantee Line Multi Company</field> + <field name="model_id" ref="model_financial_contract_guarantee_line" /> + <field + name="domain_force" + >[('company_id', 'in', company_ids + [False])]</field> + <field + name="groups" + eval="[(6, 0, [ref('financial_contract.group_financial_user')])]" + /> + <field name="perm_read" eval="False" /> + <field name="perm_write" eval="True" /> + <field name="perm_create" eval="True" /> + <field name="perm_unlink" eval="True" /> + </record> + +</odoo> diff --git a/views/financial_contract_guarantee.xml b/views/financial_contract_guarantee.xml index b37e019e834c6a1656c49d0c45cb38d577985cdc..185539be9f4fe528842ac7b62b07f3e3243f82b7 100644 --- a/views/financial_contract_guarantee.xml +++ b/views/financial_contract_guarantee.xml @@ -2,12 +2,12 @@ <!-- Copyright 2024 Le Filament License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> - <!-- Tree Guarantee --> + <!-- List Guarantee --> <record id="financial_contract_guarantee_tree_view" model="ir.ui.view"> - <field name="name">financial.contract.guarantee.tree</field> + <field name="name">financial.contract.guarantee.list</field> <field name="model">financial.contract.guarantee</field> <field name="arch" type="xml"> - <tree> + <list> <field name="currency_id" invisible="1" /> <field name="partner_id" /> <field name="state" /> @@ -21,7 +21,7 @@ <field name="final_risk_guarantee" /> <field name="payment_date" /> <field name="company_id" /> - </tree> + </list> </field> </record> @@ -38,6 +38,9 @@ <xpath expr="//field[@name='amount']" position="attributes"> <attribute name="invisible">1</attribute> </xpath> + <xpath expr="//field[@name='company_id']" position="after"> + <field name="product_id" /> + </xpath> <xpath expr="//group[@name='contract_data']" position="inside"> <field name="external_loan_id" options="{'no_create': 1}" /> @@ -47,55 +50,91 @@ <field name="is_counter_guarantee" /> </xpath> <xpath expr="//group[@name='contract_data']" position="after"> -<!-- <group name="guarantee" string="Données de la garantie">--> -<!-- <field name="currency_id" invisible="1" />--> -<!-- --> -<!-- </group>--> - <group name="loan_data" string="Données du prêt lié"> <field name="payment_date" /> <field name="amount_initial" /> <field name="amount_received" /> <field name="remaining_capital" /> </group> - <group name="company_data" string="Notation"> - <field name="segment_code" /> - <field name="branch_code" /> - <field name="bdf_scoring" /> - <field name="bdf_date" /> - <field name="mcdo_scoring" /> - <field name="mcdo_date" /> - </group> <group name="invoice_data" string="Commissions"> <field name="commission_amount" /> </group> </xpath> - <xpath expr="//field[@name='comment']" position="after"> - <separator string="Conditions suspensives" /> - <field - name="suspensive_condition_ids" - context="{'default_contract_id': active_id}" + <xpath expr="//page[@name='comment']" position="before"> + <page + name="lines" + string="État du crédit" + invisible="state not in ['contract', 'done', 'cancel']" > - <tree editable="top"> - <field name="contract_id" invisible="1" /> - <field name="condition_id" /> - <field name="condition_comment" /> - <field name="comment" /> - <field name="date_done" /> - </tree> - </field> + <field + name="line_ids" + readonly="1" + context="{'list_view_ref': 'financial_contract_guarantee.financial_contract_guarantee_line_light_tree_view'}" + /> + </page> + <page name="suspensive_condition" string="Conditions suspensives"> + <field + name="suspensive_condition_ids" + context="{'default_contract_id': id}" + readonly="state in ['contract', 'done', 'cancel']" + > + <list editable="top"> + <field name="contract_id" invisible="1" /> + <field name="condition_id" /> + <field name="condition_comment" /> + <field name="comment" /> + <field name="date_done" /> + </list> + </field> + </page> + <page name="company_data" string="Notation"> + <group> + <group> + <field name="segment_code" /> + <field name="branch_code" /> + </group> + <group> + <field name="bdf_scoring" /> + <field name="bdf_date" /> + <field name="mcdo_scoring" /> + <field name="mcdo_date" /> + </group> + </group> + </page> + </xpath> + <xpath expr="//sheet" position="after"> + <chatter /> + </xpath> + </field> + </record> + + <!-- Search --> + <record id="financial_contract_guarantee_search_view" model="ir.ui.view"> + <field name="name">financial.contract.guarantee.search</field> + <field name="model">financial.contract.guarantee</field> + <field + name="inherit_id" + ref="financial_contract.financial_contract_search_view" + /> + <field name="mode">primary</field> + <field name="arch" type="xml"> + <xpath expr="//filter[@name='group_state']" position="after"> + <filter + name="group_product" + string="Produit" + context="{'group_by': 'product_id'}" + /> </xpath> </field> </record> <!-- Action --> - <record - model="ir.actions.act_window" - id="financial_contract_guarantee_action" - > + <record model="ir.actions.act_window" id="financial_contract_guarantee_action"> <field name="name">Garanties</field> <field name="res_model">financial.contract.guarantee</field> - <field name="view_mode">tree,form</field> + <field name="view_mode">list,form,pivot,graph</field> + <field + name="context" + >{'search_default_contract': 1, 'search_default_proposal': 1, }</field> </record> - </odoo> diff --git a/views/financial_contract_guarantee_line.xml b/views/financial_contract_guarantee_line.xml index d9be051e2348228bfc5cf5846086642d78fbf75b..5a98d15ebd4e2b5896eadfa020c75cd3d06e2300 100644 --- a/views/financial_contract_guarantee_line.xml +++ b/views/financial_contract_guarantee_line.xml @@ -4,11 +4,17 @@ <odoo> <!-- Tree --> <record id="financial_contract_guarantee_line_tree_view" model="ir.ui.view"> - <field name="name">financial.contract.guarantee.line.tree</field> + <field name="name">financial.contract.guarantee.line.list</field> <field name="model">financial.contract.guarantee.line</field> <field name="arch" type="xml"> - <tree> + <list> <field name="currency_id" invisible="1" /> + <field name="company_id" invisible="1" /> + <field + name="company_id" + optional="hide" + groups="base.group_multi_company" + /> <field name="line_date" /> <field name="partner_id" /> <field name="guarantee_id" /> @@ -26,26 +32,25 @@ <field name="mcdo_scoring" optional="show" /> <field name="mcdo_date" optional="show" /> <field name="branch_code" optional="show" /> - <field - name="commission_rate" - widget="percentage" - optional="show" - /> + <field name="commission_rate" widget="percentage" optional="show" /> <field name="commission_amount" optional="show" /> <field name="commission_date_due" optional="show" /> - </tree> + </list> </field> </record> - <record - id="financial_contract_guarantee_line_light_tree_view" - model="ir.ui.view" - > - <field name="name">financial.contract.guarantee.line.tree</field> + <record id="financial_contract_guarantee_line_light_tree_view" model="ir.ui.view"> + <field name="name">financial.contract.guarantee.line.list</field> <field name="model">financial.contract.guarantee.line</field> <field name="arch" type="xml"> - <tree> + <list> <field name="currency_id" invisible="1" /> + <field name="company_id" invisible="1" /> + <field + name="company_id" + optional="hide" + groups="base.group_multi_company" + /> <field name="line_date" /> <field name="partner_id" invisible="1" /> <field name="guarantee_id" invisible="1" /> @@ -63,14 +68,10 @@ <field name="mcdo_scoring" optional="hide" /> <field name="mcdo_date" optional="hide" /> <field name="branch_code" optional="hide" /> - <field - name="commission_rate" - widget="percentage" - optional="show" - /> + <field name="commission_rate" widget="percentage" optional="show" /> <field name="commission_amount" optional="show" /> <field name="commission_date_due" optional="show" /> - </tree> + </list> </field> </record> @@ -86,14 +87,13 @@ <group name="guarantee" string="Contrat"> <field name="currency_id" invisible="1" /> <field name="line_date" /> + <field name="partner_id" options="{'no_create': 1}" /> + <field name="guarantee_id" options="{'no_create': 1}" /> <field - name="partner_id" - options="{'no_create': 1}" - /> - <field - name="guarantee_id" - options="{'no_create': 1}" + name="company_id" + groups="base.group_multi_company,base.group_no_one" /> + <field name="company_id" invisible="1" /> </group> <group name="loan_data" string="Données du prêt"> <field name="payment_date" /> @@ -123,5 +123,4 @@ </form> </field> </record> - </odoo> diff --git a/views/financial_product_template_guarantee.xml b/views/financial_product_template_guarantee.xml index 684974845b4b389458f46d8b0a48871d0d7c0be5..98ae5dd9704d8e2b7c88136a3cd8f9c761e0e114 100644 --- a/views/financial_product_template_guarantee.xml +++ b/views/financial_product_template_guarantee.xml @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="utf-8" ?> <odoo> <!-- Tree --> - <record - id="financial_product_template_guarantee_tree_view" - model="ir.ui.view" - > - <field name="name">financial.product.template.guarantee.tree</field> + <record id="financial_product_template_guarantee_tree_view" model="ir.ui.view"> + <field name="name">financial.product.template.guarantee.list</field> <field name="model">financial.product.template.guarantee</field> <field name="inherit_id" @@ -13,7 +10,7 @@ /> <field name="mode">primary</field> <field name="arch" type="xml"> - <xpath expr="//tree" position="attributes"> + <xpath expr="//list" position="attributes"> <attribute name="create">1</attribute> <attribute name="edit">1</attribute> <attribute name="delete">1</attribute> @@ -25,10 +22,7 @@ </record> <!-- Form --> - <record - id="financial_product_template_guarantee_form_view" - model="ir.ui.view" - > + <record id="financial_product_template_guarantee_form_view" model="ir.ui.view"> <field name="name">financial.product.template.guarantee.form</field> <field name="model">financial.product.template.guarantee</field> <field @@ -39,47 +33,34 @@ <field name="arch" type="xml"> <!-- Loan Fields --> <xpath expr="//notebook" position="before"> - <!-- Loan values --> - <group name="guarantee_data"> - <group - string="Données du de la garantie" - name="guarantee_values" - > - <field - name="guarantee_rate" - widget="percentage" - required="1" - /> - </group> + <!-- Loan values --> + <group name="guarantee_data"> + <group string="Données du de la garantie" name="guarantee_values"> + <field name="guarantee_rate" widget="percentage" required="1" /> </group> - </xpath> + </group> + </xpath> <!-- Suspensive conditions --> <xpath expr="//page[@name='description']" position="before"> - <page - string="Conditions suspensives" - name="suspensive_condition" - > + <page string="Conditions suspensives" name="suspensive_condition"> <field name="suspensive_condition_ids" - context="{'default_product_id': active_id}" + context="{'default_product_id': id}" > - <tree editable="top"> + <list editable="top"> <field name="product_id" invisible="1" /> <field name="condition_id" options="{'no_create': 1, 'no_edit': 1}" /> <field name="condition_comment" /> - </tree> + </list> </field> </page> </xpath> <!-- Chatter --> <xpath expr="//sheet" position="after"> - <div class="oe_chatter"> - <field name="message_follower_ids" /> - <field name="message_ids" /> - </div> + <chatter /> </xpath> </field> </record> @@ -91,7 +72,6 @@ > <field name="name">Garanties</field> <field name="res_model">financial.product.template.guarantee</field> - <field name="view_mode">tree,form</field> + <field name="view_mode">list,form</field> </record> - </odoo> diff --git a/views/menus.xml b/views/menus.xml index 2e507a973312832a9ccf1c1d6b62ded26cd42d8d..d3d2dfc4f4d73c862b7914859033d41844ff8594 100644 --- a/views/menus.xml +++ b/views/menus.xml @@ -1,13 +1,18 @@ <?xml version="1.0" encoding="utf-8" ?> <odoo> - <menuitem id="menu_financial_contract_guarantee" name="Garanties" parent="financial_contract.financial_contract_menu_root" - action="financial_contract_guarantee_action" sequence="40" /> + <menuitem + id="menu_financial_contract_guarantee_list" + name="Contrats de Garantie" + parent="menu_financial_contract_guarantee" + action="financial_contract_guarantee_action" + sequence="1" + /> <menuitem id="menu_financial_product_template_guarantee" @@ -16,5 +21,4 @@ action="financial_product_template_guarantee_action" sequence="40" /> - </odoo> diff --git a/views/res_config_settings.xml b/views/res_config_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5031161cc67e700da17665839549de0d2015687 --- /dev/null +++ b/views/res_config_settings.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record + id="res_config_settings_financial_contract_guarantee_view_form" + model="ir.ui.view" + > + <field + name="name" + >res.config.settings.view.financial.contract.guarantee.form.inherit</field> + <field name="model">res.config.settings</field> + <field name="priority" eval="40" /> + <field + name="inherit_id" + ref="financial_contract.res_config_settings_financial_contract_view_form" + /> + <field name="arch" type="xml"> + <xpath expr="//app[@name='financial_contract']" position="inside"> + <block title="Configuration des garanties" name="guarantee"> + <setting title="Sélection des numéros de contrat pour la garantie"> + <field + name="contract_guarantee_sequence_id" + options="{'no_create': 1}" + /> + </setting> + <setting + title="Montant du plafond de garantie pour cette société. Laisser à 0 si pas de plafond" + > + <field name="amount_guarantee_limit" /> + </setting> + </block> + </xpath> + </field> + </record> +</odoo> diff --git a/views/res_partner.xml b/views/res_partner.xml index c176314a6b39a0f075787f9c623d0bd81ada2ca4..dbc6eefe7b833e21ec6557b718b1297c115efcc9 100644 --- a/views/res_partner.xml +++ b/views/res_partner.xml @@ -13,7 +13,7 @@ name="action_view_contract_guarantee" class="oe_stat_button" icon="fa-file-text-o" - attrs="{'invisible': [('financial_contract_guarantee_count', '=', 0)]}" + invisible="financial_contract_guarantee_count == 0" type="object" > <field @@ -25,13 +25,15 @@ </xpath> <xpath expr="//notebook" position="inside"> <page name="guarantee_contracts" string="Contrats de garantie"> - <field - name="financial_contract_guarantee_ids" - readonly="1" - /> + <group> + <group> + <field name="guarantee_amount_ongoing" /> + <field name="guarantee_amount_left" /> + </group> + </group> + <field name="financial_contract_guarantee_ids" readonly="1" /> </page> </xpath> </field> </record> - </odoo>