mirror of
https://github.com/bringout/oca-report.git
synced 2026-04-19 19:41:59 +02:00
Initial commit: OCA Report packages (45 packages)
This commit is contained in:
commit
2f4db400df
2543 changed files with 469120 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright 2014 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import mis_builder_dashboard
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
# Copyright 2014 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# Copyright 2020 CorporateHub (https://corporatehub.eu)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AddMisReportInstanceDashboard(models.TransientModel):
|
||||
_name = "add.mis.report.instance.dashboard.wizard"
|
||||
_description = "MIS Report Add to Dashboard Wizard"
|
||||
|
||||
name = fields.Char(required=True)
|
||||
|
||||
dashboard_id = fields.Many2one(
|
||||
"ir.actions.act_window",
|
||||
string="Dashboard",
|
||||
required=True,
|
||||
domain="[('res_model', '=', " "'board.board')]",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = {}
|
||||
if self.env.context.get("active_id", False):
|
||||
res = super().default_get(fields_list)
|
||||
# get report instance name
|
||||
res["name"] = (
|
||||
self.env["mis.report.instance"]
|
||||
.browse(self.env.context["active_id"])
|
||||
.name
|
||||
)
|
||||
return res
|
||||
|
||||
def action_add_to_dashboard(self):
|
||||
active_model = self.env.context.get("active_model")
|
||||
assert active_model == "mis.report.instance"
|
||||
active_id = self.env.context.get("active_id")
|
||||
assert active_id
|
||||
# create the act_window corresponding to this report
|
||||
self.env.ref("mis_builder.mis_report_instance_result_view_form")
|
||||
view = self.env.ref("mis_builder.mis_report_instance_result_view_form")
|
||||
report_result = (
|
||||
self.env["ir.actions.act_window"]
|
||||
.sudo()
|
||||
.create(
|
||||
{
|
||||
"name": "mis.report.instance.result.view.action.%d"
|
||||
% self.env.context["active_id"],
|
||||
"res_model": active_model,
|
||||
"res_id": active_id,
|
||||
"target": "current",
|
||||
"view_mode": "form",
|
||||
"view_id": view.id,
|
||||
"context": self.env.context,
|
||||
}
|
||||
)
|
||||
)
|
||||
# add this result in the selected dashboard
|
||||
last_customization = self.env["ir.ui.view.custom"].search(
|
||||
[
|
||||
("user_id", "=", self.env.uid),
|
||||
("ref_id", "=", self.dashboard_id.view_id.id),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
arch = self.dashboard_id.view_id.arch
|
||||
if last_customization:
|
||||
arch = self.env["ir.ui.view.custom"].browse(last_customization[0].id).arch
|
||||
new_arch = etree.fromstring(arch)
|
||||
column = new_arch.xpath("//column")[0]
|
||||
# Due to native dashboard doesn't support form view
|
||||
# add "from_dashboard" to context to get correct views in "get_views"
|
||||
context = dict(self.env.context, from_dashboard=True)
|
||||
column.append(
|
||||
etree.Element(
|
||||
"action",
|
||||
{
|
||||
"context": str(context),
|
||||
"name": str(report_result.id),
|
||||
"string": self.name,
|
||||
"view_mode": "form",
|
||||
},
|
||||
)
|
||||
)
|
||||
self.env["ir.ui.view.custom"].create(
|
||||
{
|
||||
"user_id": self.env.uid,
|
||||
"ref_id": self.dashboard_id.view_id.id,
|
||||
"arch": etree.tostring(new_arch, pretty_print=True),
|
||||
}
|
||||
)
|
||||
|
||||
return {"type": "ir.actions.act_window_close"}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="mis_report_instance_add_to_dashboard_form_view">
|
||||
<field name="name">add.mis.report.instance.dashboard.wizard.view</field>
|
||||
<field name="model">add.mis.report.instance.dashboard.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add to dashboard">
|
||||
<group>
|
||||
<field name="name" />
|
||||
<field name="dashboard_id" />
|
||||
</group>
|
||||
<footer>
|
||||
<button
|
||||
name="action_add_to_dashboard"
|
||||
string="Add to dashboard"
|
||||
type="object"
|
||||
default_focus="1"
|
||||
class="oe_highlight"
|
||||
/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record
|
||||
model="ir.actions.act_window"
|
||||
id="mis_report_instance_add_to_dashboard_action"
|
||||
>
|
||||
<field name="name">Add to dashboard</field>
|
||||
<field name="res_model">add.mis.report.instance.dashboard.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="mis_report_instance_add_to_dashboard_form_view" />
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue