03.03.26
This commit is contained in:
@@ -15,6 +15,7 @@ class GRConfiguration(ModelSingleton, ModelSQL, ModelView):
|
|||||||
dashboard = fields.Char("Dashboard connexion")
|
dashboard = fields.Char("Dashboard connexion")
|
||||||
dark = fields.Boolean("Dark mode")
|
dark = fields.Boolean("Dark mode")
|
||||||
pnl_id = fields.Integer("Pnl ID")
|
pnl_id = fields.Integer("Pnl ID")
|
||||||
|
position_id = fields.Integer("Position ID")
|
||||||
forex_id = fields.Integer("Forex ID")
|
forex_id = fields.Integer("Forex ID")
|
||||||
payload = fields.Char("Metabase payload")
|
payload = fields.Char("Metabase payload")
|
||||||
automation = fields.Boolean("Automation")
|
automation = fields.Boolean("Automation")
|
||||||
@@ -1052,3 +1052,38 @@ class PnlBI(ModelSingleton,ModelSQL, ModelView):
|
|||||||
else:
|
else:
|
||||||
url = f"metabase:{config.bi}/embed/dashboard/{token}#bordered=true&titled=true"
|
url = f"metabase:{config.bi}/embed/dashboard/{token}#bordered=true&titled=true"
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
class PositionReport(Wizard):
|
||||||
|
'Position report'
|
||||||
|
__name__ = 'position.report'
|
||||||
|
|
||||||
|
start = StateAction('purchase_trade.act_position_bi')
|
||||||
|
|
||||||
|
def do_start(self, action):
|
||||||
|
pool = Pool()
|
||||||
|
# action['views'].reverse()
|
||||||
|
return action, {'res_id': [1]}
|
||||||
|
|
||||||
|
class PositionBI(ModelSingleton,ModelSQL, ModelView):
|
||||||
|
'Position BI'
|
||||||
|
__name__ = 'position.bi'
|
||||||
|
|
||||||
|
input = fields.Text("BI")
|
||||||
|
metabase = fields.Function(fields.Text(""),'get_bi')
|
||||||
|
|
||||||
|
def get_bi(self,name=None):
|
||||||
|
Configuration = Pool().get('gr.configuration')
|
||||||
|
config = Configuration.search(['id','>',0])[0]
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"resource": {"dashboard": config.position_id},
|
||||||
|
"params": {},
|
||||||
|
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=30),
|
||||||
|
}
|
||||||
|
token = jwt.encode(payload, config.payload, algorithm="HS256")
|
||||||
|
logger.info("TOKEN:%s",token)
|
||||||
|
if config.dark:
|
||||||
|
url = f"metabase:{config.bi}/embed/dashboard/{token}#theme=night&bordered=true&titled=true"
|
||||||
|
else:
|
||||||
|
url = f"metabase:{config.bi}/embed/dashboard/{token}#bordered=true&titled=true"
|
||||||
|
return url
|
||||||
|
|||||||
@@ -126,6 +126,25 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="wiz_name">pnl.report</field>
|
<field name="wiz_name">pnl.report</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="position_bi_view_graph">
|
||||||
|
<field name="model">position.bi</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">position_bi_graph</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window" id="act_position_bi">
|
||||||
|
<field name="name">Position BI</field>
|
||||||
|
<field name="res_model">position.bi</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_position_bi_view">
|
||||||
|
<field name="sequence" eval="30"/>
|
||||||
|
<field name="view" ref="pnl_bi_view_graph"/>
|
||||||
|
<field name="act_window" ref="act_position_bi"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.wizard" id="act_position_report">
|
||||||
|
<field name="name">Position report</field>
|
||||||
|
<field name="wiz_name">position.report</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="mtm_view_form">
|
<record model="ir.ui.view" id="mtm_view_form">
|
||||||
<field name="model">mtm.component</field>
|
<field name="model">mtm.component</field>
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
<field name="pnl_id"/>
|
<field name="pnl_id"/>
|
||||||
<label name="forex_id"/>
|
<label name="forex_id"/>
|
||||||
<field name="forex_id"/>
|
<field name="forex_id"/>
|
||||||
|
<label name="position_id"/>
|
||||||
|
<field name="position_id"/>
|
||||||
<label name="payload"/>
|
<label name="payload"/>
|
||||||
<field name="payload"/>
|
<field name="payload"/>
|
||||||
<label name="automation"/>
|
<label name="automation"/>
|
||||||
|
|||||||
4
modules/purchase_trade/view/position_bi_graph.xml
Normal file
4
modules/purchase_trade/view/position_bi_graph.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<form>
|
||||||
|
<field name="metabase" widget="html_viewer" height="2800"/>
|
||||||
|
</form>
|
||||||
Reference in New Issue
Block a user