summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2019-08-26 15:50:28 +0000
committerSébastien Theys <seb@odoo.com>2019-08-26 15:50:28 +0000
commitf10f120de3017bc8d0e9a5ac72eeec1280374a1d (patch)
tree4ac95c64dd0767d97088042aef451dcd2f54cd55
parentcab25b690cd9541801e553a9f50512d2db126647 (diff)
[IMP] base: remove default image from res.partner
Processing the default image takes too much time. Creating 1000 partners without image takes around: - 7s before this commit - 1.5s after this commit Moreover by saving the default image it's impossible to tell which partners have a default image and which have an actual image. After this commit, the views should handle displaying a placeholder when no image is set, which is already the case since the default image could already be missing if it was removed from `write`. closes odoo/odoo#36093 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
-rw-r--r--odoo/addons/base/models/res_partner.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py
index 629f27d2558..7be6deab206 100644
--- a/odoo/addons/base/models/res_partner.py
+++ b/odoo/addons/base/models/res_partner.py
@@ -310,35 +310,6 @@ class Partner(models.Model):
partner.commercial_company_name = p.is_company and p.name or partner.company_name
@api.model
- def _get_default_image(self, partner_type, is_company, parent_id):
- if getattr(threading.currentThread(), 'testing', False) or self._context.get('install_mode'):
- return False
-
- colorize, img_path, image_base64 = False, False, False
-
- if partner_type in ['other'] and parent_id:
- parent_image = self.browse(parent_id).image_1920
- image_base64 = parent_image or None
-
- if not image_base64 and partner_type == 'invoice':
- img_path = get_module_resource('base', 'static/img', 'money.png')
- elif not image_base64 and partner_type == 'delivery':
- img_path = get_module_resource('base', 'static/img', 'truck.png')
- elif not image_base64 and is_company:
- img_path = get_module_resource('base', 'static/img', 'company_image.png')
- elif not image_base64:
- img_path = get_module_resource('base', 'static/img', 'avatar.png')
- colorize = True
-
- if img_path:
- with open(img_path, 'rb') as f:
- image_base64 = base64.b64encode(f.read())
- if image_base64 and colorize:
- image_base64 = tools.image_process(image_base64, colorize=True)
-
- return image_base64
-
- @api.model
def _fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
if (not view_id) and (view_type == 'form') and self._context.get('force_email'):
view_id = self.env.ref('base.view_partner_simple_form').id
@@ -586,10 +557,6 @@ class Partner(models.Model):
vals['website'] = self._clean_website(vals['website'])
if vals.get('parent_id'):
vals['company_name'] = False
- # compute default image in create, because computing gravatar in the onchange
- # cannot be easily performed if default images are in the way
- if not vals.get('image_1920'):
- vals['image_1920'] = self._get_default_image(vals.get('type'), vals.get('is_company'), vals.get('parent_id'))
partners = super(Partner, self).create(vals_list)
if self.env.context.get('_partners_skip_fields_sync'):