diff --git a/models/crm.py b/models/crm.py index a721b3edd3be5fef4ac5eeebfbcc250dce198c0b..3ec3300999b4bbc575d060d9a2f941b33af2ee4b 100644 --- a/models/crm.py +++ b/models/crm.py @@ -26,6 +26,9 @@ class Lead(models.Model): status_opp = fields.Selection( [("won", "Gagné"), ("lost", "Perdu")], string="Statut" ) + exclusivity = fields.Selection( + [("full", "Totale"), ("partial", "Partielle")], string="Exclusivité" + ) def action_expected_revenue_calc(self): for lead in self: @@ -55,6 +58,12 @@ class Lead(models.Model): + lead.mission5.pct ) * lead.initial_amount + def toggle_active(self): + """Overloads function defined in crm with simple toggle of active""" + to_deactivate = self.filtered("active") + to_deactivate["active"] = False + (self - to_deactivate)["active"] = True + def action_set_won(self): res = super(Lead, self).action_set_won() for lead in self: @@ -62,10 +71,10 @@ class Lead(models.Model): return res def action_set_lost(self, **additional_values): - res = super(Lead, self).action_set_lost(**additional_values) - for lead in self: - lead.status_opp = "lost" - return res + if additional_values: + self.write(dict(additional_values)) + self.write({"status_opp": "lost"}) + return True class CrmActionType(models.Model): diff --git a/views/crm_view.xml b/views/crm_view.xml index 6e067057b308c6e0770f74876746bbe90b45ff6a..cca0fd5af1dc1556c9362ede698df60b0d8f56a0 100644 --- a/views/crm_view.xml +++ b/views/crm_view.xml @@ -32,31 +32,36 @@ <field name="inherit_id" ref="crm.crm_lead_view_form" /> <field name="priority">101</field> <field name="arch" type="xml"> + <button name="action_set_won_rainbowman" position="attributes"> + <attribute + name="attrs" + >{'invisible': [('status_opp', '=', 'won')]}</attribute> + </button> <button name="%(crm.crm_lead_lost_action)d" position="attributes"> <attribute name="attrs" - >{'invisible': [('active', '=', False),('probability', '<', 100)]}</attribute> + >{'invisible': [('status_opp', '=', 'lost')]}</attribute> </button> + <button name="toggle_active" position="replace" /> <button name="action_set_lost" position="replace" /> - <xpath - expr="//group[@name='opportunity_partner']//field[@name='partner_id']" - position="before" - > - <field name="status_opp" invisible="1" /> - </xpath> - <xpath expr="//widget[2]" position="replace"> - <widget - name="web_ribbon" - title="Perdu" - bg_color="bg-danger" - attrs="{'invisible': [('status_opp', '!=', 'lost')]}" - /> - <widget - name="web_ribbon" - title="Gagné" - attrs="{'invisible': [('status_opp', '!=', 'won')]}" - /> - </xpath> + <sheet position="before"> + <div + class="alert" + role="alert" + style="margin-bottom:0px;color:white;background-color:#000080;border-color:#000066;" + attrs="{'invisible': [('exclusivity', '!=', 'full')]}" + > + Exclusivité totale + </div> + <div + class="alert" + role="alert" + style="margin-bottom:0px;color:black;background-color:#fd3f92;border-color:#c80259;" + attrs="{'invisible': [('exclusivity', '!=', 'partial')]}" + > + Exclusivité partielle + </div> + </sheet> <header position="inside"> <button name="action_expected_revenue_calc" @@ -66,11 +71,36 @@ attrs="{'invisible': [('type', '=', 'lead')]}" /> </header> + <xpath expr="//widget[1]" position="attributes"> + <attribute + name="attrs" + >{'invisible': [('status_opp', '!=', 'lost')]}</attribute> + </xpath> + <xpath expr="//widget[2]" position="attributes"> + <attribute + name="attrs" + >{'invisible': [('status_opp', '!=', 'won')]}</attribute> + </xpath> + <xpath + expr="//group[@name='opportunity_partner']//field[@name='partner_id']" + position="before" + > + <field name="status_opp" groups="base.group_no_one" /> + <field + name="lost_reason" + attrs="{'invisible': [('status_opp', '!=', 'lost')]}" + /> + </xpath> + <xpath + expr="//group[@name='opportunity_info']//field[@name='lost_reason']" + position="replace" + /> <xpath expr="//notebook/page[@name='lead']" position="after"> <page string="Détail" name="details"> <group string="Projet"> <group> <field name="categorie_type" required="1" /> + <field name="exclusivity" /> <field name="provisional_delivery_date" attrs="{'invisible': [('type', '=', 'lead')]}" @@ -152,27 +182,37 @@ </group> <group string="Acteurs" - attrs="{'invisible': [('type', '=', 'lead')]}" + attrs="{'invisible': [('categorie_type', '==', 'interne')]}" > <group> - <field name="customer_type" /> + <field + name="customer_type" + attrs="{'invisible': ['|', ('type', '=', 'lead'), ('categorie_type', 'not in', ('formation', 'r_d', 'action_commercial'))]}" + /> <field name="customer_subtype" options="{'no_open': True, 'no_create': True}" + attrs="{'invisible': ['|', ('type', '=', 'lead'), ('categorie_type', 'not in', ('formation', 'r_d', 'action_commercial'))]}" + /> + <field + name="moa" + attrs="{'invisible': [('type', '=', 'lead')]}" /> - <field name="moa" /> <field name="archi_mandataire" /> <field name="archi_cotraitant" /> <field name="first_time_with_archi" /> </group> - <group> + <group attrs="{'invisible': [('type', '=', 'lead')]}"> <field name="landscaper" /> <field name="be_structure" /> <field name="other_moe_members" /> </group> </group> - <group string="Mission"> + <group + string="Missions" + attrs="{'invisible': [('categorie_type', '!=', 'bureau_etude')]}" + > <group> <field name="mission_type" /> <field name="mission_nature" />