diff --git a/__init__.py b/__init__.py index 5305644df1417bd42ff792a947cf27db51b60943..5ea0fdc7b5b17460f4470c015275932cebb49ec3 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,5 @@ # -*- coding: utf-8 -*- -from . import models \ No newline at end of file +from . import models +from . import controllers +from . import wizard \ No newline at end of file diff --git a/__manifest__.py b/__manifest__.py index 173862d2b9b3fe28208a2442efbe6e9aec4a5d5f..1f6e864d7d46bc8d466ec4b64d355091b9ba6b53 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -6,8 +6,11 @@ 'depends': ["cgscop_partner",], 'data': [ "security/ir.model.access.csv", + "security/security_rules.xml", 'views/partner_dashboard_ur.xml', 'views/partner_dashboard_dlg.xml', + "templates/header_dlg_template.xml", + "wizard/partner_dashboard_dlg_selection_wizard.xml", 'views/res_partner.xml', ], 'demo': [], diff --git a/controllers/__init__.py b/controllers/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..a7a226b9e317f3d5f70642297b533f0e1390e5f2 --- /dev/null +++ b/controllers/__init__.py @@ -0,0 +1 @@ +from . import banner_dash_dlg diff --git a/controllers/banner_dash_dlg.py b/controllers/banner_dash_dlg.py new file mode 100644 index 0000000000000000000000000000000000000000..90e89150717d080e2d7f093d4f1ee8f13412eed0 --- /dev/null +++ b/controllers/banner_dash_dlg.py @@ -0,0 +1,15 @@ +# © 2020 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import http +from odoo.http import request + + +class BannerDashDlgController(http.Controller): + + @http.route(['/cgscop_partner_dashboard/header_dlg'], type="json", auth="user") + def lm_header(self): + return { + 'html': request.env.ref( + 'cgscop_partner_dashboard.header_dlg_template').render({}) + } diff --git a/models/partner_dashboard_dlg.py b/models/partner_dashboard_dlg.py index 870cff1705ce7e5159679f85985a6e9b94cc3bb5..d238ad96e112d90e0b898de33be4d69830491bc9 100644 --- a/models/partner_dashboard_dlg.py +++ b/models/partner_dashboard_dlg.py @@ -45,6 +45,7 @@ class ScopPartnerDashboardDlg(models.Model): graph_values = fields.Text(compute="_compute_graph_values") + # ------------------------------------------------------ # Construction de la requete # ------------------------------------------------------ diff --git a/security/security_rules.xml b/security/security_rules.xml new file mode 100644 index 0000000000000000000000000000000000000000..82d5c9dba402e9df0c4fc9613fb3cb119e315153 --- /dev/null +++ b/security/security_rules.xml @@ -0,0 +1,8 @@ +<odoo> + <data noupdate="0"> + <record model="res.groups" id="partner_dashboard_dlg_selection_group" > + <field name="name">Dashboard coopératives, choix du délégué</field> + </record> + + </data> +</odoo> diff --git a/templates/header_dlg_template.xml b/templates/header_dlg_template.xml new file mode 100644 index 0000000000000000000000000000000000000000..14038e691e40c275d769a88feb88394900e18de4 --- /dev/null +++ b/templates/header_dlg_template.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <template id="header_dlg_template" name="cgscop_partner_dashboard.header_dlg_template"> + <div id="dash" style="background-color: #fff; padding: 16px "> + <div > + <div class="row"> + <div class="col-12"> + <a type="action" data-method="action_open_wizard_selection" data-model="scop.partner.dashboard.dlg.selection.wizard" + class="btn btn-secondary"> + Sélectionner un collaborateur + </a> + </div> + </div> + </div> + </div> + </template> +</odoo> \ No newline at end of file diff --git a/views/partner_dashboard_dlg.xml b/views/partner_dashboard_dlg.xml index c7e0148cdb887b6e4ded951c3620c4b2803a1ea6..eabdf5766ddc8838d5f89954f54a5b1336273f99 100644 --- a/views/partner_dashboard_dlg.xml +++ b/views/partner_dashboard_dlg.xml @@ -5,8 +5,8 @@ <record id="scop_partner_dashboard_dlg_kanban_view" model="ir.ui.view"> <field name="name">scop.partner.dashboard.dlg.kanban</field> <field name="model">scop.partner.dashboard.dlg</field> - <field name="arch" type="xml"> - <kanban create="false" class="oe_background_grey o_kanban_dashboard o_account_kanban" > + <field name="arch" type="xml"> + <kanban create="false" class="oe_background_grey o_kanban_dashboard o_account_kanban" banner_route="/cgscop_partner_dashboard/header_dlg" > <field name="name"/> <field name="dlg_id"/> <field name="dash_type"/> diff --git a/wizard/__init__.py b/wizard/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3fde40b983b3bbc616cf2c0e9c1482da2e891a0d --- /dev/null +++ b/wizard/__init__.py @@ -0,0 +1,4 @@ +# © 2019 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import partner_dashboard_dlg_selection_wizard diff --git a/wizard/partner_dashboard_dlg_selection_wizard.py b/wizard/partner_dashboard_dlg_selection_wizard.py new file mode 100644 index 0000000000000000000000000000000000000000..25cb0032df4ad694ca950bbfd7de43d53c60a5e9 --- /dev/null +++ b/wizard/partner_dashboard_dlg_selection_wizard.py @@ -0,0 +1,49 @@ +# © 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, api + + +class ScopPartnerDashboardDlgSelectiontWizard(models.TransientModel): + _name = 'scop.partner.dashboard.dlg.selection.wizard' + _description = "Wizard de sélection du délégué" + + @api.model + def _getUserDomain(self): + if self.env.user.has_group('cgscop_partner_dashboard.partner_dashboard_dlg_selection_group'): + return [('ur_id', '=', self.env.user.company_id.ur_id.id)] + else: + return [('id', '=', self.env.user.id)] + + # Fields common + dlg_id = fields.Many2one( + comodel_name='res.users', + domain=_getUserDomain, + string='Collaborateur') + + + #.................................................................................... + # Affichage du wizard + #.................................................................................... + @api.model + def action_open_wizard_selection(self): + action = self.env.ref( + 'cgscop_partner_dashboard.scop_partner_dashboard_dlg_selection_act').read()[ + 0] + return action + + #.................................................................................... + # Affichage de la demande + #.................................................................................... + def valid_wizard(self): + form_id = self.env.ref( + "cgscop_partner_dashboard.scop_partner_dashboard_dlg_kanban_view") + return { + 'name': 'Dashboard coopératives : '+self.dlg_id.name, + 'type': 'ir.actions.act_window', + 'res_model': 'scop.partner.dashboard.dlg', + 'view_mode': 'kanban', + 'views': [[form_id.id, 'kanban']], + 'target': 'main', + 'domain': [('dlg_id', '=', self.dlg_id.id)] + } \ No newline at end of file diff --git a/wizard/partner_dashboard_dlg_selection_wizard.xml b/wizard/partner_dashboard_dlg_selection_wizard.xml new file mode 100644 index 0000000000000000000000000000000000000000..5ef687251d26fdde021db49517abcb203f54dd17 --- /dev/null +++ b/wizard/partner_dashboard_dlg_selection_wizard.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <!-- WIZARD FORM --> + <record model="ir.ui.view" id="scop_partner_dashboard_dlg_selection_wizard" > + <field name="name">scop_partner_dashboard_dlg_selection_wizard</field> + <field name="model">scop.partner.dashboard.dlg.selection.wizard</field> + <field name="arch" type="xml"> + <form string="Sélection du collaborateur"> + <group string="Collaborateur" col="2"> + <field name="dlg_id" options="{'no_create_edit': True, 'no_open': True}" required="1"/> + </group> + <footer> + <button class="btn btn-sm btn-primary" name="valid_wizard" string="Validation" type="object"/> + <button class="btn btn-sm btn-default" special="cancel" string="Close"/> + </footer> + </form> + </field> + </record> + + <record model="ir.actions.act_window" id="scop_partner_dashboard_dlg_selection_act" > + <field name="name">Sélection du collaborateur</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">scop.partner.dashboard.dlg.selection.wizard</field> + <field name="view_mode">form</field> + <field name="view_id" ref="scop_partner_dashboard_dlg_selection_wizard"/> + <field name="target">new</field> + </record> + +</odoo>