diff --git a/__manifest__.py b/__manifest__.py index 7f3286bc8a02553906ba63cba52c2d1182c3f1c7..b3978130d9cc9712329077be5ea54b247cf0d339 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -26,6 +26,7 @@ "wizard/scop_deces_wizard.xml", "wizard/scop_membership_out_wizard.xml", "wizard/scop_membership_period_wizard.xml", + "wizard/scop_status_wizard.xml", "views/res_company.xml", "views/res_users.xml", "views/res_partner.xml", diff --git a/views/res_partner.xml b/views/res_partner.xml index a239dd9c9ea9cdb4ba779e21aee71d58bf042360..b21b0bd37f760b0dd43fb526230e12c58167cef2 100644 --- a/views/res_partner.xml +++ b/views/res_partner.xml @@ -249,7 +249,8 @@ <button string="Envoyer Dossier CG" type="object" name="scop_send_to_cg" class="btn-primary" attrs="{'invisible': ['|', ('write_date', '=', False), ('project_status', '!=', '4_adhesion')]}"/> <button string="Dossier créé CG" type="object" name="scop_valid_cg" class="btn-primary" attrs="{'invisible': ['|', ('write_date', '=', False), ('project_status', '!=', '5_cg')]}" groups="cgscop_partner.group_add_period"/> <button string="Prospect Abandonne" type="object" name="scop_abandonne" attrs="{'invisible':[('project_status','in',('5_cg', '6_suivi', '7_abandonne'))]}"/> - <button string="Projet d'adhésion" class="oe_read_only" type="object" name="scop_prj_adhesion" attrs="{'invisible':['|',('project_status','not in',('6_suivi')),('membership_status','in',('member'))]}" confirm="Êtes-vous sûr de vouloir basculer cette coopérative dans les projets ?"/>/> + <button string="Projet d'adhésion" class="oe_read_only" type="object" name="scop_prj_adhesion" attrs="{'invisible':['|',('project_status','not in',('6_suivi')),('membership_status','in',('member'))]}" confirm="Êtes-vous sûr de vouloir basculer cette coopérative dans les projets ?"/> + <button string="Modification statut projet" type="action" name="%(cgscop_partner.scop_status_wizard_action)d" groups="cgscop_partner.group_cg_administrator"/> <field name="project_status" widget="statusbar" clickable="True" statusbar_visible="1_information,2_pre-diagnostic,3_accompagnement,4_adhesion" attrs="{'invisible':[('project_status','in',('6_suivi'))]}"/> </header> </xpath> diff --git a/wizard/__init__.py b/wizard/__init__.py index 14ef5e48de39ecbfd07497e8222d950179aaf0f9..0142c729b11252427835735f55280928f7125f8a 100644 --- a/wizard/__init__.py +++ b/wizard/__init__.py @@ -6,3 +6,4 @@ from . import scop_period_wizard from . import scop_deces_wizard from . import scop_membership_period_wizard from . import scop_membership_out_wizard +from . import scop_status_wizard diff --git a/wizard/scop_status_wizard.py b/wizard/scop_status_wizard.py new file mode 100644 index 0000000000000000000000000000000000000000..4b21de59d50b30c106d32595e9a1838740ff0f21 --- /dev/null +++ b/wizard/scop_status_wizard.py @@ -0,0 +1,48 @@ +# © 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 + + +PROJECT_STATUS = [ + ('1_information', "Phase d'information"), + ('2_pre-diagnostic', 'Phase de pré-diagnostic'), + ('3_accompagnement', "Phase d'accompagnement projet"), + ('4_adhesion', "Phase d'adhésion"), + ('5_cg', 'Soumis CGScop'), + ('6_suivi', 'Phase de suivi'), + ('7_abandonne', 'Projet abandonné')] + + +class ScopStatusWizard(models.TransientModel): + _name = 'scop.status.wizard' + _description = "Wizard changement de statut projet" + + # Default functions + @api.model + def _default_partner_id(self): + return self.env.context.get('active_id') + + @api.model + def _default_project_status(self): + return self.env['res.partner'].browse( + self.env.context.get('active_id')).project_status + + # Fields common + partner_id = fields.Many2one( + comodel_name='res.partner', + string='Partner', + default=_default_partner_id) + + # Informations Bandeau + project_status = fields.Selection( + selection=PROJECT_STATUS, + string='Statut projet actuel', + default=_default_project_status) + project_status_new = fields.Selection( + selection=PROJECT_STATUS, + string='Statut projet nouveau',) + + def change_project_status(self): + self.partner_id.write( + {'project_status': self.project_status_new}) diff --git a/wizard/scop_status_wizard.xml b/wizard/scop_status_wizard.xml new file mode 100644 index 0000000000000000000000000000000000000000..f11e2371bf4eb6548dc17dc1976246afc4acb57a --- /dev/null +++ b/wizard/scop_status_wizard.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <!-- WIZARD FORM --> + <record id="scop_status_wizard_view_form" model="ir.ui.view"> + <field name="name">scop.status.wizard.form</field> + <field name="model">scop.status.wizard</field> + <field name="arch" type="xml"> + <form string="Changement statut projet"> + <group name="period" string="Période" col="2"> + <field name="partner_id" readonly="1"/> + <field name="project_status" readonly="1"/> + <field name="project_status_new" required="1"/> + </group> + <footer> + <button class="btn btn-sm btn-primary" name="change_project_status" string="Modifier statut projet" type="object"/> + <button class="btn btn-sm btn-default" special="cancel" string="Close"/> + </footer> + </form> + </field> + </record> + + <record id="scop_status_wizard_action" model="ir.actions.act_window"> + <field name="name">Modification statut projet</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">scop.status.wizard</field> + <field name="view_mode">form</field> + <field name="view_id" ref="scop_status_wizard_view_form"/> + <field name="target">new</field> + </record> + +</odoo>