From 079f118a46b49606e622e775b6552d5f95dabf11 Mon Sep 17 00:00:00 2001 From: Benjamin <benjamin@le-filament.com> Date: Tue, 21 Apr 2020 17:11:20 +0200 Subject: [PATCH] =?UTF-8?q?[fix]=20modification=20vue=20et=20mod=C3=A8le?= =?UTF-8?q?=20pour=20la=20gestion=20des=20enfants=20d'une=20coop=20(pbl=20?= =?UTF-8?q?droits=20enfants)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/res_partner.py | 62 ++++++++++ views/res_partner.xml | 282 +++++++++++++++++++++++------------------- 2 files changed, 215 insertions(+), 129 deletions(-) diff --git a/models/res_partner.py b/models/res_partner.py index 42d4e43..7e9800d 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -374,6 +374,8 @@ class ScopPartner(models.Model): domain=[('child_ids', '=', False)], on_delete='restrict', track_visibility='onchange') + # Hack pour la création de contacts depuis la fiche organisme + parent_id_onchange = fields.Many2one('res.partner') # ------------------------------------------------------ # Constrains @@ -431,6 +433,12 @@ class ScopPartner(models.Model): # ------------------------------------------------------ # Onchange # ------------------------------------------------------ + + # Hack pour la création de contacts depuis la fiche organisme + @api.onchange('parent_id_onchange') + def _onchange_parent_id_onchange(self): + self.parent_id = self.parent_id_onchange + @api.onchange('creation_origin_id') def onchange_creation_origin_id(self): for coop in self: @@ -538,6 +546,7 @@ class ScopPartner(models.Model): vals['firstname'] = vals.get('firstname').title() if vals.get('city'): vals['city'] = vals.get('city').upper() + result = super(ScopPartner, self).write(vals) for partner in self: if (not partner.is_company @@ -770,6 +779,59 @@ class ScopPartner(models.Model): }) return True + def add_director(self): + return { + 'type': 'ir.actions.act_window', + 'views': [[self.env.ref('cgscop_partner.scop_partner_director_form_view').id, "form"]], + 'view_mode': 'form', + 'res_model': 'res.partner', + 'target': 'new', + 'context': { + 'default_parent_id_onchange': self.id, + 'default_street': self.street, + 'default_street2': self.street2, + 'default_street3': self.street3, + 'default_city': self.city, + 'default_city_id': self.city_id.id, + 'default_cedex': self.cedex, + 'default_state_id': self.state_id.id, + 'default_zip': self.zip, + 'default_country_id': self.country_id.id, + 'default_supplier': self.supplier, + 'default_customer': self.customer, + 'default_lang': self.lang, + 'default_user_id': self.user_id.id, + 'default_ur_id': self.ur_id.id, + 'default_type': 'contact', + }, + } + + def add_contact(self): + return { + 'type': 'ir.actions.act_window', + 'views': [[self.env.ref('cgscop_partner.scop_partner_contact_form_view').id, "form"]], + 'view_mode': 'form', + 'res_model': 'res.partner', + 'target': 'new', + 'context': { + 'default_parent_id_onchange': self.id, + 'default_street': self.street, + 'default_street2': self.street2, + 'default_street3': self.street3, + 'default_city': self.city, + 'default_city_id': self.city_id.id, + 'default_cedex': self.cedex, + 'default_state_id': self.state_id.id, + 'default_zip': self.zip, + 'default_country_id': self.country_id.id, + 'default_supplier': self.supplier, + 'default_customer': self.customer, + 'default_lang': self.lang, + 'default_user_id': self.user_id.id, + 'default_ur_id': self.ur_id.id + }, + } + class ResPartneCertification(models.Model): _name = "res.partner.certification" diff --git a/views/res_partner.xml b/views/res_partner.xml index a4bde09..98bf053 100644 --- a/views/res_partner.xml +++ b/views/res_partner.xml @@ -83,6 +83,7 @@ <!-- Affiche les champs de la vue partenaire --> <field name="parent_id" position="before"> + <field name="parent_id_onchange" invisible="1"/> <label for="parent_id" string="Société" attrs="{'invisible': ['|', '&', ('is_company','=', True),('parent_id', '=', False),('company_name', '!=', False),('company_name', '!=', '')]}"/> </field> <field name="parent_id" position="attributes"> @@ -364,7 +365,7 @@ <field name="creation_origin_id" attrs="{'required': [('is_cooperative', '=', True)]}" options="{'no_open': True, 'no_create': True}"/> <field name="creation_suborigin_id" domain="[('parent_id', '=', creation_origin_id), ('child_ids', '=', False)]" options="{'no_open': True, 'no_create': True}"/> <field name="is_ag_constitution" attrs="{'invisible': [('project_status', '!=', '3_accompagnement')]}"/> - <field name="date_1st_sign" attrs="{'invisible': [('project_status', 'in', ('1_information', '2_pre-diagnostic', '3_accompagnement')), ('is_ag_constitution', '!=', True)], 'required': ['|', ('project_status', 'in', ('4_adhesion', '5_cg', '6_suivi')), ('is_ag_constitution', '=', True)]}"/> + <field name="date_1st_sign" attrs="{'invisible': [('project_status', 'in', ('1_information', '2_pre-diagnostic', '3_accompagnement')), ('is_ag_constitution', '!=', True)], 'required': ['|', ('project_status', 'in', ('4_adhesion', '5_cg', '6_suivi')), ('is_ag_constitution', '=', True), ('is_cooperative', '=', True)]}"/> <field name="registration_date" attrs="{'invisible': [('project_status', 'in', ('1_information', '2_pre-diagnostic', '3_accompagnement'))]}"/> <field name="social_object" attrs="{'required': [('is_cooperative', '=', True), ('project_status','in',('2_pre-diagnostic', '3_accompagnement','4_adhesion', '5_cg', '6_suivi'))]}"/> <field name="naf_id" attrs="{'readonly': [('write_date', '!=', False), ('project_status', '=', '6_suivi')], 'required':['|', ('project_status','in',('4_adhesion', '5_cg'), '&', ('write_date', '=', False), ('project_status', '=', '6_suivi'))], 'invisible': [('project_status', 'in', ('1_information', '2_pre-diagnostic', '3_accompagnement'))]}" options="{'no_open': True, 'no_create': True}"/> @@ -392,8 +393,10 @@ <notebook colspan="4"> <page name="scop_contacts" string="Contacts & Addresses"> <label for="director_ids" string="Dirigeants"/> - <field name="director_ids" - context="{'default_parent_id': active_id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_cedex': cedex, 'default_state_id': state_id, 'default_zip': zip, 'default_zip_id': zip_id, 'default_city_id': city_id, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer, 'default_lang': lang, 'default_user_id': user_id, 'default_ur_id': ur_id, 'default_type': 'contact', }"> + <p> + <button name="add_director" type="object" class="btn-info" string="Ajouter un dirigeant"></button> + </p> + <field name="director_ids" readonly="1"> <kanban> <field name="id"/> <field name="color"/> @@ -449,63 +452,12 @@ </t> </templates> </kanban> - <form string="Contact Dirigeant"> - <sheet> - <field name="parent_id" invisible="1"/> - <group col="2"> - <group invisible="1"> - <field name="street"/> - <field name="street2"/> - <field name="street3"/> - <field name="zip_id"/> - <field name="zip"/> - <field name="city"/> - <field name="cedex"/> - <field name="state_id"/> - <field name="country_id"/> - <field name="type"/> - <field name="category_id"/> - </group> - <group> - <field name="title" placeholder="Madame" options='{"no_open": True, "no_create": True}'/> - <field name="firstname" string="Prénom" required="1"/> - <field name="lastname" string="Nom de famille" required="1"/> - <field name="mandate_id" options="{'no_open': True, 'no_create': True}" required="1"/> - <field name="function" placeholder="Responsable des ventes"/> - <field name="email"/> - <field name="phone" widget="phone"/> - <field name="mobile" widget="phone"/> - <field name="category_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" /> - <field name="comment" placeholder="Commentaires..."/> - </group> - <group> - <field name="birthyear"/> - <field name="contact_origin_id" options="{'no_open': True, 'no_create': True}"/> - <field name="contact_legality" readonly="1"/> - <field name="segment_1_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - <field name="segment_2_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - <field name="segment_3_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - <field name="segment_4_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - </group> - </group> - <field name="subscription_ids"> - <tree string="Subscriptions" editable="bottom"> - <field name="newsletter_id"/> - <field name="consent"/> - </tree> - </field> - <field name="supplier" invisible="True"/> - <field name="customer" invisible="True"/> - <field name="lang" invisible="True"/> - <field name="image" invisible="True"/> - <field name="user_id" invisible="True"/> - <field name="ur_id" invisible="True"/> - </sheet> - </form> </field> <label for="other_child_ids" string="Autres Contacts / Adresses"/> - <field name="other_child_ids" mode="kanban" - context="{'default_parent_id': active_id, 'default_street': street, 'default_street2': street2, 'default_street3': street3, 'default_city': city, 'default_city_id': city_id, 'default_cedex': cedex, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer, 'default_lang': lang, 'default_user_id': user_id, 'default_ur_id': ur_id}"> + <p> + <button name="add_contact" type="object" class="btn-info" string="Ajouter un contact"></button> + </p> + <field name="other_child_ids" mode="kanban" readonly="1"> <kanban> <field name="id"/> <field name="color"/> @@ -574,77 +526,6 @@ </t> </templates> </kanban> - <form string="Contact / Address"> - <sheet> - <!-- parent_id and type fields needed in attrs in base_address_city module which overwrites - _fields_view_get() of partner. It would be better to put those fields there but the web client - dosen't support when a field is displayed several times in the same view.--> - <field name="type" required="1" widget="radio" options="{'horizontal': true}"/> - <field name="parent_id" invisible="1"/> - <hr/> - <group> - <group attrs="{'invisible': [('type', '=', 'contact')]}"> - <label for="street" string="Address"/> - <div> - <div name="div_address" class="o_address_format"> - <field name="street" placeholder="Rue..." class="o_address_street"/> - <field name="street2" placeholder="Rue 2..." class="o_address_street"/> - <field name="street3" placeholder="Rue 3..." class="o_address_street"/> - <field name="zip_id" - options="{'create_name_field': 'city', 'no_open': True, 'no_create': True}" - placeholder="CP/Ville autocomplétion" - class="oe_edit_only"/> - <field name="zip" placeholder="ZIP" class="o_address_city"/> - <field name="city" placeholder="Ville" class="o_address_city" - attrs="{'readonly': [('type', '=', 'contact'), ('parent_id', '!=', False)]}" modifiers="{'readonly':[['type','=','contact'],['parent_id','!=',false]]}"/> - <field name="city_id" invisible="1"/> - <field name="cedex" placeholder="Cedex" class="o_address_city" - attrs="{'readonly': [('type', '=', 'contact'), ('parent_id', '!=', False)]}" modifiers="{'readonly':[['type','=','contact'],['parent_id','!=',false]]}"/> - <field name="state_id" class="o_address_zip" placeholder="Région" - options='{"no_open": True, "no_create": True}' context="{'country_id': country_id, 'zip': zip}"/> - <field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/> - </div> - </div> - </group> - <group> - <field name="title" placeholder="Madame" - attrs="{'invisible': [('type','!=', 'contact')]}" options='{"no_open": True, "no_create": True}'/> - <field name="name" string="Nom" attrs="{'required' : [('type', '!=', 'contact')], 'invisible' : [('type', '=', 'contact')]}"/> - <field name="firstname" string="Prénom" attrs="{'required' : [('type', '=', 'contact')], 'invisible' : [('type', '!=', 'contact')]}"/> - <field name="lastname" string="Nom de famille" attrs="{'required' : [('type', '=', 'contact')], 'invisible' : [('type', '!=', 'contact')]}"/> - <field name="mandate_id" options="{'no_open': True, 'no_create': True}" attrs="{'invisible': [('type','!=', 'contact')]}"/> - <field name="function" placeholder="e.g. Directeur des Ventes" - attrs="{'invisible': [('type','!=', 'contact')]}"/> - <field name="email"/> - <field name="phone" widget="phone"/> - <field name="mobile" widget="phone"/> - <field name="category_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" /> - <field name="comment" placeholder="internal note..."/> - </group> - <group attrs="{'invisible': [('type', '!=', 'contact')]}"> - <field name="birthyear"/> - <field name="contact_origin_id" options="{'no_open': True, 'no_create': True}"/> - <field name="contact_legality" readonly="1"/> - <field name="segment_1_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - <field name="segment_2_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - <field name="segment_3_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - <field name="segment_4_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> - </group> - </group> - <field name="subscription_ids" attrs="{'invisible': [('type', '!=', 'contact')]}"> - <tree string="Subscriptions" editable="bottom"> - <field name="newsletter_id" domain="[]"/> - <field name="consent"/> - </tree> - </field> - <field name="supplier" invisible="True"/> - <field name="customer" invisible="True"/> - <field name="lang" invisible="True"/> - <field name="image" invisible="True"/> - <field name="user_id" invisible="True"/> - <field name="ur_id" invisible="True" options='{"no_open": True, "no_create": True}'/> - </sheet> - </form> </field> </page> <page name='scop_revision' string="Révisions" attrs="{'invisible': [('project_status', '!=', '6_suivi')]}"> @@ -860,6 +741,149 @@ </field> </record> + <!-- + CG Scop Partner Director View + --> + <record id="scop_partner_director_form_view" model="ir.ui.view"> + <field name="name">scop.partner.director.form.view</field> + <field name="model">res.partner</field> + <field name="arch" type="xml"> + <form string="Contact Dirigeant"> + <sheet> + <field name="parent_id_onchange" invisible="1"/> + <field name="parent_id" invisible="1"/> + <group col="2"> + <group invisible="1"> + <field name="street"/> + <field name="street2"/> + <field name="street3"/> + <field name="zip_id"/> + <field name="zip"/> + <field name="city"/> + <field name="cedex"/> + <field name="state_id"/> + <field name="country_id"/> + <field name="type"/> + <field name="category_id"/> + </group> + <group> + <field name="title" placeholder="Madame" options='{"no_open": True, "no_create": True}'/> + <field name="firstname" string="Prénom" required="1"/> + <field name="lastname" string="Nom de famille" required="1"/> + <field name="mandate_id" options="{'no_open': True, 'no_create': True}" required="1"/> + <field name="function" placeholder="Responsable des ventes"/> + <field name="email"/> + <field name="phone" widget="phone"/> + <field name="mobile" widget="phone"/> + <field name="category_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" /> + <field name="comment" placeholder="Commentaires..."/> + </group> + <group> + <field name="birthyear"/> + <field name="contact_origin_id" options="{'no_open': True, 'no_create': True}"/> + <field name="contact_legality" readonly="1"/> + <field name="segment_1_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + <field name="segment_2_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + <field name="segment_3_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + <field name="segment_4_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + </group> + </group> + <field name="subscription_ids"> + <tree string="Subscriptions" editable="bottom"> + <field name="newsletter_id"/> + <field name="consent"/> + </tree> + </field> + <field name="supplier" invisible="True"/> + <field name="customer" invisible="True"/> + <field name="lang" invisible="True"/> + <field name="image" invisible="True"/> + <field name="user_id" invisible="True"/> + <field name="ur_id" invisible="True"/> + </sheet> + </form> + </field> + </record> + + <!-- + CG Scop Partner Contact View + --> + <record id="scop_partner_contact_form_view" model="ir.ui.view"> + <field name="name">scop.partner.contact.form.view</field> + <field name="model">res.partner</field> + <field name="arch" type="xml"> + <form string="Contact / Address"> + <sheet> + <field name="type" required="1" widget="radio" options="{'horizontal': true}"/> + <field name="parent_id_onchange" invisible="1"/> + <field name="parent_id" invisible="1"/> + <hr/> + <group> + <group attrs="{'invisible': [('type', '=', 'contact')]}"> + <label for="street" string="Address"/> + <div> + <div name="div_address" class="o_address_format"> + <field name="street" placeholder="Rue..." class="o_address_street"/> + <field name="street2" placeholder="Rue 2..." class="o_address_street"/> + <field name="street3" placeholder="Rue 3..." class="o_address_street"/> + <field name="zip_id" + options="{'create_name_field': 'city', 'no_open': True, 'no_create': True}" + placeholder="CP/Ville autocomplétion" + class="oe_edit_only"/> + <field name="zip" placeholder="ZIP" class="o_address_city"/> + <field name="city" placeholder="Ville" class="o_address_city" + attrs="{'readonly': [('type', '=', 'contact'), ('parent_id', '!=', False)]}" modifiers="{'readonly':[['type','=','contact'],['parent_id','!=',false]]}"/> + <field name="city_id" invisible="1"/> + <field name="cedex" placeholder="Cedex" class="o_address_city" + attrs="{'readonly': [('type', '=', 'contact'), ('parent_id', '!=', False)]}" modifiers="{'readonly':[['type','=','contact'],['parent_id','!=',false]]}"/> + <field name="state_id" class="o_address_zip" placeholder="Région" + options='{"no_open": True, "no_create": True}' context="{'country_id': country_id, 'zip': zip}"/> + <field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/> + </div> + </div> + </group> + <group> + <field name="title" placeholder="Madame" + attrs="{'invisible': [('type','!=', 'contact')]}" options='{"no_open": True, "no_create": True}'/> + <field name="name" string="Nom" attrs="{'required' : [('type', '!=', 'contact')], 'invisible' : [('type', '=', 'contact')]}"/> + <field name="firstname" string="Prénom" attrs="{'required' : [('type', '=', 'contact')], 'invisible' : [('type', '!=', 'contact')]}"/> + <field name="lastname" string="Nom de famille" attrs="{'required' : [('type', '=', 'contact')], 'invisible' : [('type', '!=', 'contact')]}"/> + <field name="mandate_id" options="{'no_open': True, 'no_create': True}" attrs="{'invisible': [('type','!=', 'contact')]}"/> + <field name="function" placeholder="e.g. Directeur des Ventes" + attrs="{'invisible': [('type','!=', 'contact')]}"/> + <field name="email"/> + <field name="phone" widget="phone"/> + <field name="mobile" widget="phone"/> + <field name="category_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" /> + <field name="comment" placeholder="internal note..."/> + </group> + <group attrs="{'invisible': [('type', '!=', 'contact')]}"> + <field name="birthyear"/> + <field name="contact_origin_id" options="{'no_open': True, 'no_create': True}"/> + <field name="contact_legality" readonly="1"/> + <field name="segment_1_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + <field name="segment_2_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + <field name="segment_3_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + <field name="segment_4_id" widget="many2many_tags" options="{'color_field': 'color', 'no_create': True}" domain="[('ur_id', '=', ur_id)]"/> + </group> + </group> + <field name="subscription_ids" attrs="{'invisible': [('type', '!=', 'contact')]}"> + <tree string="Subscriptions" editable="bottom"> + <field name="newsletter_id" domain="[]"/> + <field name="consent"/> + </tree> + </field> + <field name="supplier" invisible="True"/> + <field name="customer" invisible="True"/> + <field name="lang" invisible="True"/> + <field name="image" invisible="True"/> + <field name="user_id" invisible="True"/> + <field name="ur_id" invisible="True" options='{"no_open": True, "no_create": True}'/> + </sheet> + </form> + </field> + </record> + <record id="view_partner_form_firstname_scop" model="ir.ui.view"> <field name="name">Add firstname and surnames for CGScop</field> -- GitLab