Trade Finance
This commit is contained in:
@@ -13,18 +13,42 @@ class ConstraintType(ModelSQL, ModelView):
|
|||||||
_rec_name = 'name'
|
_rec_name = 'name'
|
||||||
|
|
||||||
name = fields.Char('Type', required=True, size=50)
|
name = fields.Char('Type', required=True, size=50)
|
||||||
view_name = fields.Selection('get_views_selection', 'View')
|
view_name = fields.Selection([], 'View')
|
||||||
value_field = fields.Many2One('ir.model.field', 'Value Field',
|
value_field = fields.Selection(
|
||||||
ondelete='RESTRICT')
|
'get_column_selection', 'Value Field',
|
||||||
label_field = fields.Many2One('ir.model.field', 'Label Field',
|
selection_change_with=['view_name'])
|
||||||
ondelete='RESTRICT')
|
label_field = fields.Selection(
|
||||||
|
'get_column_selection', 'Label Field',
|
||||||
|
selection_change_with=['view_name'])
|
||||||
|
|
||||||
@classmethod
|
@fields.depends('view_name')
|
||||||
def get_views_selection(cls):
|
def get_column_selection(self):
|
||||||
|
if not self.view_name:
|
||||||
|
return [('', '')]
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"SELECT table_name FROM information_schema.views "
|
"SELECT column_name FROM information_schema.columns "
|
||||||
"WHERE table_schema = 'public' AND table_name LIKE 'vw_tf_const_%' "
|
"WHERE table_schema = 'public' AND table_name = %s "
|
||||||
"ORDER BY table_name"
|
"ORDER BY ordinal_position",
|
||||||
|
(self.view_name,)
|
||||||
)
|
)
|
||||||
return [('', '')] + [(r[0], r[0]) for r in cursor.fetchall()]
|
return [('', '')] + [(r[0], r[0]) for r in cursor.fetchall()]
|
||||||
|
|
||||||
|
@fields.depends('view_name')
|
||||||
|
def on_change_view_name(self):
|
||||||
|
self.value_field = None
|
||||||
|
self.label_field = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def fields_get(cls, fields_names=None, level=0):
|
||||||
|
res = super().fields_get(fields_names, level)
|
||||||
|
if 'view_name' in res:
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
cursor.execute(
|
||||||
|
"SELECT table_name FROM information_schema.views "
|
||||||
|
"WHERE table_schema = 'public' AND table_name LIKE 'vw_tf_const_%' "
|
||||||
|
"ORDER BY table_name"
|
||||||
|
)
|
||||||
|
res['view_name']['selection'] = (
|
||||||
|
[('', '')] + [(r[0], r[0]) for r in cursor.fetchall()])
|
||||||
|
return res
|
||||||
|
|||||||
@@ -115,6 +115,15 @@ class Facility(ModelSQL, ModelView):
|
|||||||
'facility', 'Facility Constraints',
|
'facility', 'Facility Constraints',
|
||||||
domain=[('limit', '=', None)])
|
domain=[('limit', '=', None)])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_status(cls):
|
||||||
|
pool = Pool()
|
||||||
|
FacilityStatus = pool.get('trade_finance.facility_status')
|
||||||
|
statuses = FacilityStatus.search([('code', '=', 'DRAFT')], limit=1)
|
||||||
|
if statuses:
|
||||||
|
return statuses[0].id
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_commitment_status():
|
def default_commitment_status():
|
||||||
return 'uncommitted'
|
return 'uncommitted'
|
||||||
@@ -140,6 +149,10 @@ class FacilityCurrency(ModelSQL, ModelView):
|
|||||||
'FX Haircut Formula', ondelete='RESTRICT')
|
'FX Haircut Formula', ondelete='RESTRICT')
|
||||||
fx_feeder = fields.Many2One('trade_finance.fx_feeder', 'FX Rate Feeder',
|
fx_feeder = fields.Many2One('trade_finance.fx_feeder', 'FX Rate Feeder',
|
||||||
ondelete='RESTRICT')
|
ondelete='RESTRICT')
|
||||||
|
valuation_method = fields.Many2One('trade_finance.valuation_method',
|
||||||
|
'Valuation Method', ondelete='RESTRICT')
|
||||||
|
date_from = fields.Date('Valid From')
|
||||||
|
date_to = fields.Date('Valid To')
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -476,3 +489,9 @@ class FacilityConstraint(ModelSQL, ModelView):
|
|||||||
'Constraint Type', required=True, ondelete='RESTRICT')
|
'Constraint Type', required=True, ondelete='RESTRICT')
|
||||||
is_exclusion = fields.Boolean('Exclusion',
|
is_exclusion = fields.Boolean('Exclusion',
|
||||||
help='Checked = Exclusion constraint, unchecked = Inclusion constraint')
|
help='Checked = Exclusion constraint, unchecked = Inclusion constraint')
|
||||||
|
date_from = fields.Date('Valid From')
|
||||||
|
date_to = fields.Date('Valid To')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_is_exclusion():
|
||||||
|
return False
|
||||||
|
|||||||
@@ -15,6 +15,16 @@
|
|||||||
<field name="group" ref="group_trade_finance_user"/>
|
<field name="group" ref="group_trade_finance_user"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- ================================================================ -->
|
||||||
|
<!-- FACILITY STATUS — Reference Data -->
|
||||||
|
<!-- ================================================================ -->
|
||||||
|
|
||||||
|
<record model="trade_finance.facility_status" id="facility_status_draft">
|
||||||
|
<field name="code">DRAFT</field>
|
||||||
|
<field name="name">Draft</field>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- ================================================================ -->
|
<!-- ================================================================ -->
|
||||||
<!-- FACILITY STATUS -->
|
<!-- FACILITY STATUS -->
|
||||||
<!-- ================================================================ -->
|
<!-- ================================================================ -->
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<tree>
|
<tree>
|
||||||
<field name="constraint_type"/>
|
<field name="constraint_type"/>
|
||||||
<field name="is_exclusion"/>
|
<field name="is_exclusion"/>
|
||||||
|
<field name="date_from"/>
|
||||||
|
<field name="date_to"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<tree>
|
<tree>
|
||||||
<field name="currency"/>
|
<field name="currency"/>
|
||||||
|
<field name="valuation_method"/>
|
||||||
<field name="fx_haircut_formula"/>
|
<field name="fx_haircut_formula"/>
|
||||||
<field name="fx_feeder"/>
|
<field name="fx_feeder"/>
|
||||||
|
<field name="date_from"/>
|
||||||
|
<field name="date_to"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<label name="name"/>
|
<label name="name"/>
|
||||||
<field name="name" colspan="3"/>
|
<field name="name" colspan="3"/>
|
||||||
<label name="status"/>
|
<label name="status"/>
|
||||||
<field name="status"/>
|
<field name="status" widget="selection"/>
|
||||||
<label name="tfe"/>
|
<label name="tfe"/>
|
||||||
<field name="tfe" colspan="3"/>
|
<field name="tfe" colspan="3"/>
|
||||||
<label name="commitment_status"/>
|
<label name="commitment_status"/>
|
||||||
@@ -30,20 +30,19 @@
|
|||||||
<field name="description" colspan="5"/>
|
<field name="description" colspan="5"/>
|
||||||
</group>
|
</group>
|
||||||
<notebook colspan="6">
|
<notebook colspan="6">
|
||||||
<page string="Accepted Currencies" id="currencies">
|
|
||||||
<field name="currencies" colspan="6"/>
|
|
||||||
</page>
|
|
||||||
<page string="Limits" id="limits">
|
<page string="Limits" id="limits">
|
||||||
<field name="limits" colspan="6"
|
<field name="limits" colspan="6"
|
||||||
domain="[('parent', '=', None)]"
|
domain="[('parent', '=', None)]"/>
|
||||||
mode="tree"/>
|
|
||||||
</page>
|
</page>
|
||||||
<page string="Caps" id="caps">
|
<page string="Currencies" id="currencies">
|
||||||
<field name="caps" colspan="6"/>
|
<field name="currencies" colspan="6"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Constraints" id="constraints">
|
<page string="Constraints" id="constraints">
|
||||||
<field name="constraints" colspan="6"/>
|
<field name="constraints" colspan="6"/>
|
||||||
</page>
|
</page>
|
||||||
|
<page string="Caps" id="caps">
|
||||||
|
<field name="caps" colspan="6"/>
|
||||||
|
</page>
|
||||||
<page string="Covenants" id="covenants">
|
<page string="Covenants" id="covenants">
|
||||||
<field name="covenants" colspan="6"/>
|
<field name="covenants" colspan="6"/>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<tree>
|
<tree expand="1">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="financing_type"/>
|
<field name="financing_type"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user