Skip to content
Extraits de code Groupes Projets
Valider 4369c2a5 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[UPD] set type other for provider and incubated

parent b0322970
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -292,6 +292,16 @@ class ResPartner(models.Model): ...@@ -292,6 +292,16 @@ class ResPartner(models.Model):
# ------------------------------------------------------ # ------------------------------------------------------
# Onchange / Constraints # Onchange / Constraints
# ------------------------------------------------------ # ------------------------------------------------------
@api.onchange("is_company")
def onchange_is_company(self):
"""
Set contact_type to False for person
"""
if not self.is_company:
self.contact_type = False
if self.is_incubated or self.is_provider:
self.type = "other"
@api.onchange("parent_id") @api.onchange("parent_id")
def onchange_parent_id(self): def onchange_parent_id(self):
""" """
...@@ -300,7 +310,10 @@ class ResPartner(models.Model): ...@@ -300,7 +310,10 @@ class ResPartner(models.Model):
result = super().onchange_parent_id() result = super().onchange_parent_id()
if self.env.context.get("default_parent_id"): if self.env.context.get("default_parent_id"):
self.parent_id = self.env.context.get("default_parent_id") self.parent_id = self.env.context.get("default_parent_id")
if not self.parent_id:
self.type = "contact"
else:
self.type = "other"
return result return result
# ------------------------------------------------------ # ------------------------------------------------------
......
...@@ -121,6 +121,9 @@ ...@@ -121,6 +121,9 @@
<xpath expr="//field[@name='parent_id']" position="attributes"> <xpath expr="//field[@name='parent_id']" position="attributes">
<attribute name="options">{'no_create': 1, 'no_edit': 1}</attribute> <attribute name="options">{'no_create': 1, 'no_edit': 1}</attribute>
<attribute name="domain">parent_id_domain</attribute> <attribute name="domain">parent_id_domain</attribute>
<attribute
name="required"
>context.get('default_is_incubated') or context.get('default_is_provider')</attribute>
</xpath> </xpath>
<!-- Type de contact --> <!-- Type de contact -->
...@@ -828,7 +831,7 @@ ...@@ -828,7 +831,7 @@
>[('is_provider', '=', True),('is_company', '!=', True)]</field> >[('is_provider', '=', True),('is_company', '!=', True)]</field>
<field <field
name="context" name="context"
>{'default_is_company': False, 'default_is_provider': True}</field> >{'default_is_company': False, 'default_is_provider': True,}</field>
</record> </record>
</data> </data>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter