From 44b803aa8aeff6696538c45e7463da4cbd667a13 Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Thu, 13 Mar 2025 19:02:20 +0100 Subject: [PATCH] [UPD] Data for import --- README.md | 3 + models/financial_contract_guarantee.py | 16 +- models/mutual_guarantee_fund_line.py | 26 ++- views/financial_contract_guarantee.xml | 254 +++++++++++++------------ 4 files changed, 173 insertions(+), 126 deletions(-) diff --git a/README.md b/README.md index 6b30e4c..38b9450 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,14 @@ ## Description Ajoute la gestion des garanties de prêt pour les contrats. + ## Credits Le développement de ce module a été financé par / The development of this module has been financially supported by: + - CGSCop (https://www.les-scop.coop/) - SOCODEN + ## Contributors * Benjamin <benjamin@le-filament.com> diff --git a/models/financial_contract_guarantee.py b/models/financial_contract_guarantee.py index 0ed2c61..7c7de91 100644 --- a/models/financial_contract_guarantee.py +++ b/models/financial_contract_guarantee.py @@ -98,18 +98,26 @@ class FinancialContractGuarantee(models.Model): social_share_ids = fields.One2many( comodel_name="company.share.line", inverse_name="guarantee_id", - string="FMG", + string="Parts sociales", ) social_share_paid = fields.Monetary( string="Montant parts sociales payé", compute="_compute_social_share_paid", store=True ) + is_old_associate = fields.Boolean( + string="Nouveau sociétaire", + compute="_compute_is_new_associate", + store=True, + default=False, + ) line_ids = fields.One2many( comodel_name="financial.contract.guarantee.line", inverse_name="guarantee_id", string="Lignes de solde", ) + date_folder_received = fields.Date("Date de réception dossier") + date_approval_president = fields.Date("Date Validation Président") # Loan Data payment_date = fields.Date("Date de versement") @@ -262,6 +270,12 @@ class FinancialContractGuarantee(models.Model): contract.suspensive_condition_ids.unlink() contract.suspensive_condition_ids = condition_to_create + @api.depends("partner_id", "partner_id.company_share_line_ids") + def _compute_is_new_associate(self): + for guarantee in self: + if guarantee.partner_id and guarantee.partner_id.company_share_line_ids: + guarantee.is_old_associate = True + # ------------------------------------------------------ # Onchange # ------------------------------------------------------ diff --git a/models/mutual_guarantee_fund_line.py b/models/mutual_guarantee_fund_line.py index 02c3f3b..6db1207 100644 --- a/models/mutual_guarantee_fund_line.py +++ b/models/mutual_guarantee_fund_line.py @@ -1,8 +1,8 @@ # © 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 - +from odoo import api, fields, models +from odoo.exceptions import ValidationError class MutualGuaranteeFundLine(models.Model): _name = "mutual.guarantee.fund.line" @@ -13,7 +13,7 @@ class MutualGuaranteeFundLine(models.Model): guarantee_id = fields.Many2one( comodel_name="financial.contract.guarantee", string="Contrat de garantie", - required=True, + required=False, index=True, ) partner_id = fields.Many2one( @@ -34,12 +34,30 @@ class MutualGuaranteeFundLine(models.Model): comodel_name="res.currency", related="guarantee_id.currency_id", ) - amount = fields.Monetary("Montant") + amount = fields.Monetary("Montant", required=True) date = fields.Date(required=True) + type = fields.Selection( + selection=[ + ("subscribe", "Souscription"), + ("refund", "Remboursement"), + ("guarantee_call", "Appel en garantie"), + ("storing", "Mise en réserve"), + ], + string="Type de mouvement", + required=True + ) + comment = fields.Text("Commentaire") # ------------------------------------------------------ # Constrains functions # ------------------------------------------------------ + @api.constrains("type", "amount") + def _check_amount_type(self): + for fmg in self: + if fmg.type == "subscribe" and fmg.amount <= 0: + raise ValidationError("Le montant d'une souscription doit être positif") + elif fmg.type in ["refund", "guarantee_call", "storing"] and fmg.amount >= 0: + raise ValidationError("Le montant d'une souscription doit être négatif") # ------------------------------------------------------ # Computed fields / Search Fields diff --git a/views/financial_contract_guarantee.xml b/views/financial_contract_guarantee.xml index 7ab7799..0a592ed 100644 --- a/views/financial_contract_guarantee.xml +++ b/views/financial_contract_guarantee.xml @@ -7,7 +7,7 @@ <field name="name">financial.contract.guarantee.list</field> <field name="model">financial.contract.guarantee</field> <field name="arch" type="xml"> - <list> + <list multi_edit="1"> <field name="currency_id" column_invisible="1" /> <field name="partner_id" /> <field name="state" /> @@ -29,133 +29,145 @@ </record> <!-- Form --> - <record model="ir.ui.view" id="financial_contract_guarantee_form_view"> + <record model="ir.ui.view" id="financial_contract_guarantee_form"> <field name="name">financial.contract.guarantee.form</field> <field name="model">financial.contract.guarantee</field> - <field - name="inherit_id" - ref="financial_contract.financial_contract_form_view" - /> - <field name="mode">primary</field> <field name="arch" type="xml"> - <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}" /> - <field name="guarantee_rate" widget="percentage" /> - <field name="fmg_amount" /> - <field name="social_share_amount" /> - <field name="social_share_number" /> - <field name="is_counter_guarantee" /> - <field - name="counter_guarantee_rate" - widget="percentage" - invisible="not is_counter_guarantee" - required="is_counter_guarantee" - /> - <field - name="counter_guarantee_partner_id" - widget="percent" - invisible="not is_counter_guarantee" - options="{'no_create': 1}" - required="is_counter_guarantee" - /> - </xpath> - <xpath expr="//group[@name='contract_data']" position="after"> - <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="invoice_data" string="Commissions"> - <field name="commission_amount" /> - </group> - </xpath> - <xpath expr="//page[@name='comment']" position="before"> - <!-- lignes de crédit --> - <page - name="lines" - string="État du crédit" - invisible="state in ['init', 'offer', 'cancel']" - > - <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"> + <form> + <header> + <field name="state" widget="statusbar" options="{'clickable': '1'}" /> + </header> + <sheet> <group> - <group> - <field name="segment_code" /> - <field name="branch_code" /> + <group name="customer" string="Coopérative"> + <field name="partner_id" /> + <field name="ur_id" /> + <field name="siren" /> + <field name="member_number" /> + <field name="is_old_associate" /> </group> - <group> - <field name="bdf_scoring" /> - <field name="bdf_date" /> - <field name="mcdo_scoring" /> - <field name="mcdo_date" /> + <group name="contract" string="contrat"> + <field name="number"/> + <field name="product_id" /> + <field name="amount_initial" /> + <field name="guarantee_rate" widget="percentage" /> + <field name="fmg_amount" /> + <field name="social_share_amount" /> + <field name="social_share_number" /> + <field name="is_counter_guarantee" /> + <field + name="counter_guarantee_rate" + widget="percentage" + invisible="not is_counter_guarantee" + required="is_counter_guarantee" + /> + <field + name="counter_guarantee_partner_id" + widget="percent" + invisible="not is_counter_guarantee" + options="{'no_create': 1}" + required="is_counter_guarantee" + /> </group> - </group> - </page> - <page - name="Commissions" - string="Commissions" - invisible="state in ['init', 'offer', 'cancel']" - > - </page> - <page - name="fmg" - string="FMG" - invisible="state in ['init', 'offer', 'cancel']" - > - <field name="fmg_ids"> - <list create="0" edit="0" delete="0"> - <field name="date" /> - <field name="amount" /> - </list> - </field> - </page> - <page - name="social_share" - string="Parts Sociales" - invisible="state in ['init', 'offer', 'cancel']" - > - <field name="social_share_ids"> - <list create="0" edit="0" delete="0"> + <group name="loan" string="Prêt"> + <field name="external_loan_id" options="{'no_create': 1}" /> <field name="payment_date" /> - <field name="share_number" /> - <field name="share_unit_price" /> - <field name="share_action" /> - <field name="share_total_amount" /> - </list> - </field> - </page> - </xpath> - <xpath expr="//sheet" position="after"> + <field name="amount_initial" /> + <field name="amount_received" /> + <field name="remaining_capital" /> + </group> + <group name="invoice_data" string="Commissions"> + <field name="commission_amount" /> + </group> + </group> + <notebook> + <!-- lignes de crédit --> + <page + name="lines" + string="État du crédit" + invisible="state in ['init', 'offer', 'cancel']" + > + <field + name="line_ids" + readonly="1" + context="{'list_view_ref': 'financial_contract_guarantee.financial_contract_guarantee_line_light_tree_view'}" + /> + </page> + <!-- conditions suspensives --> + <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" column_invisible="1" /> + <field name="condition_id" /> + <field name="condition_comment" /> + <field name="comment" /> + <field name="date_done" /> + </list> + </field> + </page> + <!-- notation --> + <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> + <!-- commissions --> + <page + name="Commissions" + string="Commissions" + invisible="state in ['init', 'offer', 'cancel']" + > + </page> + <!-- fmg --> + <page + name="fmg" + string="FMG" + invisible="state in ['init', 'offer', 'cancel']" + > + <field name="fmg_ids"> + <list create="0" edit="0" delete="0"> + <field name="date" /> + <field name="amount" /> + </list> + </field> + </page> + <!-- parts sociales --> + <page + name="social_share" + string="Parts Sociales" + invisible="state in ['init', 'offer', 'cancel']" + > + <field name="social_share_ids"> + <list create="0" edit="0" delete="0"> + <field name="payment_date" /> + <field name="share_number" /> + <field name="share_unit_price" /> + <field name="share_action" /> + <field name="share_total_amount" /> + </list> + </field> + </page> + <!-- description --> + <page name="comment" string="Description"> + <field name="comment"/> + </page> + </notebook> + </sheet> <chatter /> - </xpath> + </form> </field> </record> @@ -187,6 +199,6 @@ <field name="view_mode">list,form,pivot,graph</field> <field name="context" - >{'search_default_contract': 1, 'search_default_proposal': 1, }</field> + >{'search_default_notified': 1, 'search_default_signed': 1, 'search_default_paid': 1, 'search_default_litigation': 1, }</field> </record> </odoo> -- GitLab