Skip to content
Snippets Groups Projects
Commit d25ce7f9 authored by Thibaud - Le Filament's avatar Thibaud - Le Filament
Browse files

[IMP] Added button link to the dedicated financial tool in the deal flow contract section

parent fdd57cac
No related branches found
No related tags found
1 merge request!1Draft: Link deal_flow_tool_type with corresponding tool
......@@ -4,7 +4,7 @@ from datetime import datetime
from ocb.odoo import api
from odoo import fields, models
from odoo import _, fields, models
MAP_DICT = {"loan": "loan.manager.loan", "invest": "", "warranty": ""}
......@@ -56,15 +56,17 @@ class FinancialContract(models.Model):
@api.model
def create(self, values):
# FIXME: ORM overload + design does not imply inheritance,
# therefore hardcoded creation of each model ? (Warranty, title and loan)
contract = super().create(values)
# Create financial tool associated
financial_tool_record = self.env[contract.deal_tool_model_id.model].create(
{
"description": contract.name,
"first_term_date": datetime.now,
"payment_date": datetime.now,
"first_term_date": datetime.now(),
"payment_date": datetime.now(),
"amount": contract.deal_tool_id.amount,
"partner_id": contract.deal_id.partner_id,
"partner_id": contract.deal_id.partner_id.id,
}
)
self.deal_tool_model_id_referenced_id = financial_tool_record.id
......@@ -73,6 +75,14 @@ class FinancialContract(models.Model):
# ------------------------------------------------------
# Actions
# ------------------------------------------------------
def btn_open_tool_form(self):
return {
"name": _("Financial tool"),
"type": "ir.actions.act_window",
"res_model": self.deal_tool_model_id.model,
"res_id": self.deal_tool_model_id_referenced_id,
"view_mode": "form",
}
# ------------------------------------------------------
# Business methods
......
......@@ -17,4 +17,23 @@
</xpath>
</field>
</record>
<record id="financial_deal_contract_view_tree" model="ir.ui.view">
<field name="name">financial.contract.tree</field>
<field name="model">financial.contract</field>
<field
name="inherit_id"
ref="financial_contract.financial_contract_view"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='state']" position="after">
<button
name="btn_open_tool_form"
type="object"
icon="fa-calculator"
/>
</xpath>
</field>
</record>
</odoo>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment