[FIX] base: fetch gravatar images only from views

Before this commit, at each partner creation (including data import,
RPC import and tests) Gravatar server was polled, slowing down partner
batch import.

We then enable this feature only where it is needed: when creating a
partner from a view.
This commit is contained in:
Richard Mathot
2017-07-03 15:04:29 +02:00
parent 42621febc1
commit c47c52bfd9
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -361,7 +361,7 @@ class Partner(models.Model):
@api.onchange('email')
def onchange_email(self):
if not self.image and not self._context.get('yaml_onchange') and self.email:
if not self.image and self._context.get('gravatar_image') and self.email:
self.image = self._get_gravatar_image(self.email)
@api.depends('name', 'email')
+2 -2
View File
@@ -77,7 +77,7 @@
<group>
<field name="function" placeholder="e.g. Sales Director"/>
<field name="user_ids" invisible="1"/>
<field name="email" widget="email" required="context.get('force_email', False)" attrs="{'required': [('user_ids','!=', [])]}"/>
<field name="email" widget="email" context="{'gravatar_image': True}" required="context.get('force_email', False)" attrs="{'required': [('user_ids','!=', [])]}"/>
<field name="phone" widget="phone"/>
<field name="mobile" widget="phone"/>
</group>
@@ -190,7 +190,7 @@
<field name="mobile" widget="phone"/>
<field name="fax"/>
<field name="user_ids" invisible="1"/>
<field name="email" widget="email" attrs="{'required': [('user_ids','!=', [])]}"/>
<field name="email" widget="email" context="{'gravatar_image': True}" attrs="{'required': [('user_ids','!=', [])]}"/>
<field name="title" options='{"no_open": True}'
attrs="{'invisible': [('is_company', '=', True)]}"/>
<field name="lang"/>