diff --git a/README.md b/README.md index 45e0ef9631c3111bf7df6ba65b941ffd1ff78228..6b30e4c0a556ecfe38df4857037f6e1d8727015f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ -# Financial - Deal Flow +# Financial - Guarantee Contract ## Description -Ce module ajoute la gestion du deal flow des outils financiers - +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: diff --git a/__manifest__.py b/__manifest__.py index 008001abf09bb5dda71a54ed8520602fbbf30425..e91974ab101e9216796585f42f598fb0a1a164a6 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,6 +1,6 @@ { - "name": "Financial - Contract", - "summary": "Gestion des contrats des outils financiers", + "name": "Financial - Guarantee Contract", + "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", @@ -14,6 +14,9 @@ # datas # views "views/financial_contract_guarantee.xml", + "views/financial_contract_guarantee_line.xml", + "views/financial_product_template_guarantee.xml", + "views/res_partner.xml", # views menu "views/menus.xml", # wizard diff --git a/models/__init__.py b/models/__init__.py index 4bc2b148c2d887deef82e80d09f5069ee0d29747..1de888b9b2d7a742922073923889da5c61cbbcb5 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,3 +1,7 @@ -from . import financial_contract from . import financial_contract_guarantee -# from . import financial_product_template_guarantee +from . import financial_contract_guarantee_line +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_partner diff --git a/models/financial_contract.py b/models/financial_contract.py deleted file mode 100644 index f717a7e21b33a91a2375fd16d9bec2f41b1c92d8..0000000000000000000000000000000000000000 --- a/models/financial_contract.py +++ /dev/null @@ -1,23 +0,0 @@ -# © 2019 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 FinancialContract(models.Model): - _inherit = "financial.contract" - - tool = fields.Selection( - selection_add=[ - ("financial.contract.guarantee", "Prêt"), - ], - ondelete={"financial.contract.guarantee": "cascade"}, - ) - - # ------------------------------------------------------ - # Computed fields / Search Fields - # ------------------------------------------------------ - - # ------------------------------------------------------ - # CRUD (Override ORM) - # ------------------------------------------------------ diff --git a/models/financial_contract_guarantee.py b/models/financial_contract_guarantee.py index 2e0dd0e297298b34dc73cb3619ed48dcab5ece43..0353ebdeb338bfa66ced525f1ab6f3f8402f6bc8 100644 --- a/models/financial_contract_guarantee.py +++ b/models/financial_contract_guarantee.py @@ -1,16 +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 +from odoo import Command, api, fields, models class FinancialContractGuarantee(models.Model): _name = "financial.contract.guarantee" _inherit = [ + "financial.contract", "mail.thread", "mail.activity.mixin", ] - _inherits = {"financial.contract": "contract_id"} _description = "Financial contract guarantee" _check_company_auto = True _rec_names_search = [ @@ -21,21 +21,88 @@ class FinancialContractGuarantee(models.Model): ] _order = "create_date desc" + product_id = fields.Many2one( + comodel_name="financial.product.template.guarantee", + string="Gamme", + required=True, + ) + suspensive_condition_ids = fields.One2many( + comodel_name="financial.contract.guarantee.suspensive.condition", + inverse_name="contract_id", + compute="_compute_suspensive_condition_ids", + store=True, + readonly=False, + ) + # TODO: voir pour la gestion de ce champ avec le module contract external external_loan_id = fields.Many2one( - comodel_name="financial.contract", + comodel_name="financial.contract.external", string="Prêt lié", - domain="[('partner_id', '=', partner_id), ('type', '=', 'loan'), " - "('deal_type', '=', 'external')]", - financial_tool_type="guarantee", + domain="[('partner_id', '=', partner_id), ('tool', '=', 'loan')]", + ) + loan_contract_number = fields.Char( + string="Numéro de contrat de prêt", + related="external_loan_id.number", + store=True, ) - guarantee_rate = fields.Float("Quotité garantie", tracking=1) + is_counter_guarantee = fields.Boolean("Contre Garantie", default=False) - bdf_scoring = fields.Char("Cotations BDF") - loan_balance = fields.Monetary("Solde créance") - guarantee_balance = fields.Monetary("Solde Garantie") fmg_amount = fields.Monetary("Montant FMG") social_share_amount = fields.Monetary("Montant parts sociales") - final_risk_guarantee = fields.Monetary("Garantie risque final", tracking=1) + final_risk_guarantee = fields.Monetary( + string="Garantie risque final", + compute="_compute_final_risk_guarantee", + store=True, + tracking=1, + ) + + line_ids = fields.One2many( + comodel_name="financial.contract.guarantee.line", + inverse_name="guarantee_id", + string="Lignes de solde", + ) + + # loan_balance = fields.Monetary( + # string="Solde créance", + # compute="_compute_balance", + # store=True, + # tracking=2, + # ) + # guarantee_balance = fields.Monetary( + # string="Solde Garantie", + # compute="_compute_balance", + # store=True, + # tracking=2, + # ) + + # Loan Data + payment_date = fields.Date("Date de versement") + amount_initial = fields.Monetary("Montant initial") + amount_received = fields.Monetary("Montant reçu") + end_date = fields.Date("Date de fin de prêt") + remaining_capital = fields.Monetary("Capital restant dû") + loan_duration = fields.Integer("Durée du crédit") + guarantee_rate = fields.Float("Quotité garantie") + guarantee_amount = fields.Monetary("En cours garanti") + # Company Data + segment_code = fields.Char("Code Segment") + bdf_scoring = fields.Char( + string="Cotation BDF", + compute="_compute_guarantee_data", + store=True, + readonly=False, + tracking=2, + ) + bdf_date = fields.Char("Date Cotation BDF") + mcdo_scoring = fields.Char("Cotation MacDonough") + mcdo_date = fields.Date("Date Cotation MacDonough") + branch_code = fields.Char("Code branche") + + # Invoice Data + commission_amount = fields.Monetary( + string="Montant de commission", + compute="_compute_commission_amount", + store=True, + ) # ------------------------------------------------------ # Constrains functions @@ -44,6 +111,60 @@ class FinancialContractGuarantee(models.Model): # ------------------------------------------------------ # Computed fields / Search Fields # ------------------------------------------------------ + @api.depends( + "line_ids", + "line_ids.bdf_scoring", + ) + def _compute_guarantee_data(self): + for guarantee in self: + last_line = guarantee.line_ids.sorted("line_date desc") + guarantee.update({"bdf_scoring": last_line.bdf_scoring}) + + @api.depends( + "line_ids", + "line_ids.commission_amount", + ) + def _compute_guarantee_data(self): + for guarantee in self: + guarantee.commission_amount = sum( + guarantee.line_ids.mapped("commission_amount") + ) + + # @api.depends() + # def _compute_balance(self): + # for guarantee in self: + # guarantee.loan_balance = 0 + # guarantee.guarantee_balance = 0 + + @api.depends() + def _compute_final_risk_guarantee(self): + for guarantee in self: + guarantee.final_risk_guarantee = 0 + + @api.depends("product_id") + def _compute_suspensive_condition_ids(self): + for contract in self: + condition_to_create = [] + if contract.product_id: + for condition in self.product_id.suspensive_condition_ids: + condition_to_create.append( + Command.create( + { + "condition_id": condition.id, + "condition_comment": condition.condition_comment, + }, + ) + ) + if condition_to_create: + contract.suspensive_condition_ids.unlink() + contract.suspensive_condition_ids = condition_to_create + + # ------------------------------------------------------ + # Onchange + # ------------------------------------------------------ + @api.onchange("product_id") + def _onchange_product_id(self): + self._set_product_values() # ------------------------------------------------------ # Actions @@ -52,3 +173,10 @@ class FinancialContractGuarantee(models.Model): # ------------------------------------------------------ # CRUD (Override ORM) # ------------------------------------------------------ + + # ------------------------------------------------------ + # Business functions + # ------------------------------------------------------ + def _set_product_values(self): + if self.product_id: + self.guarantee_rate = self.product_id.guarantee_rate diff --git a/models/financial_contract_guarantee_line.py b/models/financial_contract_guarantee_line.py new file mode 100644 index 0000000000000000000000000000000000000000..5ec0d82dbca53bdf102875618834cfed584d3fa7 --- /dev/null +++ b/models/financial_contract_guarantee_line.py @@ -0,0 +1,77 @@ +# © 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 FinancialContractGuaranteeLine(models.Model): + _name = "financial.contract.guarantee.line" + _description = "Financial contract guarantee line" + _check_company_auto = True + _rec_names_search = [ + "partner_id.name", + "partner_id.member_number", + ] + _order = "line_date desc" + + guarantee_id = fields.Many2one( + comodel_name="financial.contract.guarantee", + string="Contrat de garantie", + required=True, + index=True, + ) + partner_id = fields.Many2one( + comodel_name="res.partner", + related="guarantee_id.partner_id", + string="Contact", + store=True, + index=True, + ) + company_id = fields.Many2one( + comodel_name="res.company", + related="guarantee_id.company_id", + string="Société", + store=True, + index=True, + ) + currency_id = fields.Many2one( + comodel_name="res.currency", + related="guarantee_id.currency_id", + ) + # Loan Data + line_date = fields.Date("Date en cours") + payment_date = fields.Date("Date de versement") + amount_initial = fields.Monetary("Montant initial") + amount_received = fields.Monetary("Montant reçu") + end_date = fields.Date("Date de fin de prêt") + remaining_capital = fields.Monetary("Capital restant dû") + loan_duration = fields.Integer("Durée du crédit") + guarantee_rate = fields.Float("Quotité garantie") + guarantee_amount = fields.Monetary("En cours garanti") + # Company Data + segment_code = fields.Char("Code Segment") + bdf_scoring = fields.Char("Cotation BDF") + bdf_date = fields.Char("Date Cotation BDF") + mcdo_scoring = fields.Char("Cotation MacDonough") + mcdo_date = fields.Date("Date Cotation MacDonough") + branch_code = fields.Char("Code branche") + # Invoice Data + commission_rate = fields.Float("Taux de commission") + commission_amount = fields.Monetary("Montant de commission") + commission_date_due = fields.Date("Echeance de commission") + + # ------------------------------------------------------ + # Constrains functions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD (Override ORM) + # ------------------------------------------------------ diff --git a/models/financial_contract_guarantee_suspensive_condition.py b/models/financial_contract_guarantee_suspensive_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..36a28f8ad65da5752910cb155d8339274577b232 --- /dev/null +++ b/models/financial_contract_guarantee_suspensive_condition.py @@ -0,0 +1,33 @@ +# © 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 FinancialContractGuaranteeSuspensiveCondition(models.Model): + _name = "financial.contract.guarantee.suspensive.condition" + _inherit = ["financial.contract.suspensive.condition"] + _description = "Financial contract suspensive condition" + + contract_id = fields.Many2one( + comodel_name="financial.contract.guarantee", + string="Contrat", + required=True, + ondelete="cascade", + ) + + # ------------------------------------------------------ + # Constrains functions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD (Override ORM) + # ------------------------------------------------------ diff --git a/models/financial_product_guarantee_suspensive_condition.py b/models/financial_product_guarantee_suspensive_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..51c67d7a010e95a93314fd090a56e51df5931b63 --- /dev/null +++ b/models/financial_product_guarantee_suspensive_condition.py @@ -0,0 +1,33 @@ +# © 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 FinancialProductGuaranteeSuspensiveCondition(models.Model): + _name = "financial.product.guarantee.suspensive.condition" + _inherit = ["financial.product.suspensive.condition"] + _description = "Financial product guarantee suspensive condition" + + product_id = fields.Many2one( + comodel_name="financial.product.template.guarantee", + string="Produit", + required=True, + ondelete="cascade", + ) + + # ------------------------------------------------------ + # Constrains functions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD (Override ORM) + # ------------------------------------------------------ diff --git a/models/financial_product_template_guarantee.py b/models/financial_product_template_guarantee.py index 06494dbf5e55448ed96f71957c24f06347f72c1b..92c61e34a1e8dba6459b822ace98ffebe2fc7304 100644 --- a/models/financial_product_template_guarantee.py +++ b/models/financial_product_template_guarantee.py @@ -7,25 +7,19 @@ from odoo import fields, models class FinancialProductTemplateGuarantee(models.Model): _name = "financial.product.template.guarantee" _inherit = [ + "financial.product.template", "mail.thread", "mail.activity.mixin", ] - _inherits = {"financial.product.template": "product_id"} _description = "Financial product template guarantee" - tool = fields.Selection( - selection_add=[ - ("financial.contract.guarantee", "Garantie"), - ], - ondelete={"financial.contract.guarantee": "cascade"}, - ) - product_id = fields.Many2one( - comodel_name="financial.product.template", - string="Produit", - required=True, - index=True, - ondelete="cascade", + guarantee_rate = fields.Float("Quotité garantie") + suspensive_condition_ids = fields.One2many( + comodel_name="financial.product.guarantee.suspensive.condition", + inverse_name="product_id", + string="Conditions suspensives", ) + # ------------------------------------------------------ # Constrains functions # ------------------------------------------------------ diff --git a/models/res_company.py b/models/res_company.py new file mode 100644 index 0000000000000000000000000000000000000000..55698fecda271da7f8c8cef545ceaeed5b373c7a --- /dev/null +++ b/models/res_company.py @@ -0,0 +1,63 @@ +# Copyright 2023- Le Filament (https://le-filament.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import api, fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + contract_guarantee_sequence_id = fields.Many2one("ir.sequence") + + # ------------------------------------------------------ + # Fields declaration + # ------------------------------------------------------ + + # ------------------------------------------------------ + # SQL Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Default methods + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Onchange / Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD methods (ORM overrides) + # ------------------------------------------------------ + @api.model_create_multi + def create(self, values): + """ + Crée une séquence dédiée à la société + """ + res = super().create(values) + for company in res: + company.contract_guarantee_sequence_id = self.env["ir.sequence"].create( + { + "name": f"Contrats Financiers : Garantie - {res.name}", + "company_id": res.id, + "number_next": 1, + "number_increment": 1, + "use_date_range": True, + "prefix": "G%(year)s%(month)s", + "padding": 4, + "implementation": "no_gap", + "code": f"financial.contract.guarantee.company_{res.id}", + } + ) + return res + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Business methods + # ------------------------------------------------------ diff --git a/models/res_partner.py b/models/res_partner.py new file mode 100644 index 0000000000000000000000000000000000000000..a53ea3a1426f278199846d4da8cd89e564abd71a --- /dev/null +++ b/models/res_partner.py @@ -0,0 +1,63 @@ +# Copyright 2023- Le Filament (https://le-filament.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + # ------------------------------------------------------ + # Fields declaration + # ------------------------------------------------------ + financial_contract_guarantee_ids = fields.One2many( + comodel_name="financial.contract.guarantee", + inverse_name="partner_id", + string="Contrats de garanties", + ) + financial_contract_guarantee_count = fields.Integer( + compute="_compute_financial_contract_guarantee_count" + ) + + # ------------------------------------------------------ + # SQL Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Default methods + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + def _compute_financial_contract_guarantee_count(self): + for partner in self: + partner.financial_contract_guarantee_count = ( + partner.financial_contract_guarantee_ids.__len__() + ) + + # ------------------------------------------------------ + # Onchange / Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD methods (ORM overrides) + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + def action_view_contract_guarantee(self): + self.ensure_one() + return { + "type": "ir.actions.act_window", + "name": "Contrats de garantie", + "res_model": "financial.contract.guarantee", + "view_mode": "tree,form", + "domain": [("partner_id", "=", self.id)], + "flags": {"mode": "readonly"}, + } + + # ------------------------------------------------------ + # Business methods + # ------------------------------------------------------ diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index ac9637ca65764862b4a599211bc5b953aa05601b..dd9292b556f93ab9bf6845a9e06a76180b12b7fc 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,2 +1,8 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_financial_contract_guarantee,access_financial_contract_guarantee,model_financial_contract_guarantee,financial_contract.group_financial_user,1,1,1,1 +access_financial_contract_guarantee_line,access_financial_contract_guarantee_line,model_financial_contract_guarantee_line,financial_contract.group_financial_user,1,1,1,1 +access_financial_product_template_guarantee,access_financial_product_template_guarantee,model_financial_product_template_guarantee,financial_contract.group_financial_user,1,0,0,0 +access_financial_product_template_guarantee_admin,access_financial_product_template_guarantee,model_financial_product_template_guarantee,financial_contract.group_financial_admin,1,1,1,1 +access_financial_contract_guarantee_suspensive_condition,access_financial_contract_guarantee_suspensive_condition,model_financial_contract_guarantee_suspensive_condition,financial_contract.group_financial_user,1,1,1,1 +access_financial_product_guarantee_suspensive_condition,access_financial_product_guarantee_suspensive_condition,model_financial_product_guarantee_suspensive_condition,financial_contract.group_financial_user,1,0,0,0 +access_financial_product_guarantee_suspensive_condition_admin,access_financial_product_guarantee_suspensive_condition_admin,model_financial_product_guarantee_suspensive_condition,financial_contract.group_financial_admin,1,1,1,1 diff --git a/static/description/icon.png b/static/description/icon.png old mode 100755 new mode 100644 index 82ef47760a441cf229b5009f0a18ccf3842fbfa5..2b426e06b3a8f298795f598a50bcb1ae195d1c30 Binary files a/static/description/icon.png and b/static/description/icon.png differ diff --git a/views/financial_contract_guarantee.xml b/views/financial_contract_guarantee.xml index 78d8e22607fddba3eac0e19f87c77c798a9ff67b..b37e019e834c6a1656c49d0c45cb38d577985cdc 100644 --- a/views/financial_contract_guarantee.xml +++ b/views/financial_contract_guarantee.xml @@ -5,23 +5,19 @@ <!-- Tree Guarantee --> <record id="financial_contract_guarantee_tree_view" model="ir.ui.view"> <field name="name">financial.contract.guarantee.tree</field> - <field name="model">financial.contract</field> + <field name="model">financial.contract.guarantee</field> <field name="arch" type="xml"> <tree> <field name="currency_id" invisible="1" /> - <field name="tool" invisible="1" /> <field name="partner_id" /> - <field name="product_id" /> <field name="state" /> <field name="expiration_date" /> <field name="amount" string="Montant" /> <field name="external_loan_id" /> <field name="fmg_amount" /> <field name="social_share_amount" /> - <field name="guarantee_rate" /> + <field name="guarantee_rate" widget="percentage" /> <field name="is_counter_guarantee" /> - <field name="loan_balance" /> - <field name="guarantee_balance" /> <field name="final_risk_guarantee" /> <field name="payment_date" /> <field name="company_id" /> @@ -39,19 +35,55 @@ /> <field name="mode">primary</field> <field name="arch" type="xml"> - <xpath expr="//group" position="inside"> - <group> - <field name="external_loan_id" /> - <field name="fmg_amount" /> - <field name="social_share_amount" /> - <field name="guarantee_rate" /> - <field name="is_counter_guarantee" /> - <field name="loan_balance" /> - <field name="guarantee_balance" /> - <field name="final_risk_guarantee" /> + <xpath expr="//field[@name='amount']" position="attributes"> + <attribute name="invisible">1</attribute> + </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="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="company_id" /> + <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}" + > + <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> </xpath> </field> </record> @@ -64,9 +96,6 @@ <field name="name">Garanties</field> <field name="res_model">financial.contract.guarantee</field> <field name="view_mode">tree,form</field> - <field - name="domain" - >[('state', 'in', ['proposal', 'contract', 'done', 'cancel'])]</field> </record> </odoo> diff --git a/views/financial_contract_guarantee_line.xml b/views/financial_contract_guarantee_line.xml new file mode 100644 index 0000000000000000000000000000000000000000..d9be051e2348228bfc5cf5846086642d78fbf75b --- /dev/null +++ b/views/financial_contract_guarantee_line.xml @@ -0,0 +1,127 @@ +<?xml version="1.0" ?> +<!-- Copyright 2024 Le Filament + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> +<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="model">financial.contract.guarantee.line</field> + <field name="arch" type="xml"> + <tree> + <field name="currency_id" invisible="1" /> + <field name="line_date" /> + <field name="partner_id" /> + <field name="guarantee_id" /> + <field name="payment_date" /> + <field name="amount_initial" optional="show" /> + <field name="amount_received" optional="show" /> + <field name="end_date" /> + <field name="remaining_capital" /> + <field name="loan_duration" /> + <field name="guarantee_rate" widget="percentage" /> + <field name="guarantee_amount" /> + <field name="segment_code" optional="show" /> + <field name="bdf_scoring" optional="show" /> + <field name="bdf_date" optional="show" /> + <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_amount" optional="show" /> + <field name="commission_date_due" optional="show" /> + </tree> + </field> + </record> + + <record + id="financial_contract_guarantee_line_light_tree_view" + model="ir.ui.view" + > + <field name="name">financial.contract.guarantee.line.tree</field> + <field name="model">financial.contract.guarantee.line</field> + <field name="arch" type="xml"> + <tree> + <field name="currency_id" invisible="1" /> + <field name="line_date" /> + <field name="partner_id" invisible="1" /> + <field name="guarantee_id" invisible="1" /> + <field name="payment_date" optional="hide" /> + <field name="amount_initial" optional="show" /> + <field name="amount_received" optional="show" /> + <field name="end_date" /> + <field name="remaining_capital" /> + <field name="loan_duration" /> + <field name="guarantee_rate" widget="percentage" /> + <field name="guarantee_amount" /> + <field name="segment_code" optional="hide" /> + <field name="bdf_scoring" optional="hide" /> + <field name="bdf_date" optional="hide" /> + <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_amount" optional="show" /> + <field name="commission_date_due" optional="show" /> + </tree> + </field> + </record> + + <!-- Form --> + <record model="ir.ui.view" id="financial_contract_guarantee_line_form_view"> + <field name="name">financial.contract.guarantee.line.form</field> + <field name="model">financial.contract.guarantee.line</field> + <field name="mode">primary</field> + <field name="arch" type="xml"> + <form string="Guarantee Line"> + <sheet> + <group> + <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}" + /> + </group> + <group name="loan_data" string="Données du prêt"> + <field name="payment_date" /> + <field name="amount_initial" /> + <field name="amount_received" /> + <field name="end_date" /> + <field name="remaining_capital" /> + <field name="loan_duration" /> + <field name="guarantee_rate" widget="percentage" /> + <field name="guarantee_amount" /> + </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_rate" widget="percentage" /> + <field name="commission_amount" /> + <field name="commission_date_due" /> + </group> + </group> + </sheet> + </form> + </field> + </record> + +</odoo> diff --git a/views/financial_product_template_guarantee.xml b/views/financial_product_template_guarantee.xml new file mode 100644 index 0000000000000000000000000000000000000000..684974845b4b389458f46d8b0a48871d0d7c0be5 --- /dev/null +++ b/views/financial_product_template_guarantee.xml @@ -0,0 +1,97 @@ +<?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> + <field name="model">financial.product.template.guarantee</field> + <field + name="inherit_id" + ref="financial_contract.financial_product_template_tree_view" + /> + <field name="mode">primary</field> + <field name="arch" type="xml"> + <xpath expr="//tree" position="attributes"> + <attribute name="create">1</attribute> + <attribute name="edit">1</attribute> + <attribute name="delete">1</attribute> + </xpath> + <xpath expr="//field[@name='category_id']" position="after"> + <field name="guarantee_rate" widget="percentage" /> + </xpath> + </field> + </record> + + <!-- Form --> + <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 + name="inherit_id" + ref="financial_contract.financial_product_template_form_view" + /> + <field name="mode">primary</field> + <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> + </group> + </xpath> + <!-- Suspensive conditions --> + <xpath expr="//page[@name='description']" position="before"> + <page + string="Conditions suspensives" + name="suspensive_condition" + > + <field + name="suspensive_condition_ids" + context="{'default_product_id': active_id}" + > + <tree editable="top"> + <field name="product_id" invisible="1" /> + <field + name="condition_id" + options="{'no_create': 1, 'no_edit': 1}" + /> + <field name="condition_comment" /> + </tree> + </field> + </page> + </xpath> + <!-- Chatter --> + <xpath expr="//sheet" position="after"> + <div class="oe_chatter"> + <field name="message_follower_ids" /> + <field name="message_ids" /> + </div> + </xpath> + </field> + </record> + + <!-- Action --> + <record + model="ir.actions.act_window" + id="financial_product_template_guarantee_action" + > + <field name="name">Garanties</field> + <field name="res_model">financial.product.template.guarantee</field> + <field name="view_mode">tree,form</field> + </record> + +</odoo> diff --git a/views/menus.xml b/views/menus.xml index 65baccc0e950f78e5396fdb2280a27c2bc1c1789..2e507a973312832a9ccf1c1d6b62ded26cd42d8d 100644 --- a/views/menus.xml +++ b/views/menus.xml @@ -4,9 +4,17 @@ <menuitem id="menu_financial_contract_guarantee" name="Garanties" - parent="financial_contact.financial_contract_menu_root" + parent="financial_contract.financial_contract_menu_root" action="financial_contract_guarantee_action" sequence="40" /> + <menuitem + id="menu_financial_product_template_guarantee" + name="Garanties" + parent="financial_contract.menu_financial_product_template" + action="financial_product_template_guarantee_action" + sequence="40" + /> + </odoo> diff --git a/views/res_partner.xml b/views/res_partner.xml new file mode 100644 index 0000000000000000000000000000000000000000..c176314a6b39a0f075787f9c623d0bd81ada2ca4 --- /dev/null +++ b/views/res_partner.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- Copyright 2023- Le Filament (https://le-filament.com) + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> +<odoo> + <!-- Form View --> + <record id="res_partner_financial_contract_loan_form" model="ir.ui.view"> + <field name="name">res.partner.financial.contract.loan.form</field> + <field name="model">res.partner</field> + <field name="inherit_id" ref="base.view_partner_form" /> + <field name="arch" type="xml"> + <xpath expr="//div[@name='button_box']" position="inside"> + <button + name="action_view_contract_guarantee" + class="oe_stat_button" + icon="fa-file-text-o" + attrs="{'invisible': [('financial_contract_guarantee_count', '=', 0)]}" + type="object" + > + <field + name="financial_contract_guarantee_count" + widget="statinfo" + string="Contrat(s) de garantie" + /> + </button> + </xpath> + <xpath expr="//notebook" position="inside"> + <page name="guarantee_contracts" string="Contrats de garantie"> + <field + name="financial_contract_guarantee_ids" + readonly="1" + /> + </page> + </xpath> + </field> + </record> + +</odoo>