From 62587f18422c32c3096b4bb3cebb3e8da19c2a1f Mon Sep 17 00:00:00 2001 From: Goffin Simon <sig@odoo.com> Date: Fri, 12 Feb 2016 17:07:08 +0100 Subject: [PATCH] [FIX] base: _get_default_image When a shipping/invoice contact is created, the picture with the truck/dollar must be used. Inspired from 66d4de7 --- openerp/addons/base/res/res_partner.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py index b040bc83fa22..ff2124a4b7f9 100644 --- a/openerp/addons/base/res/res_partner.py +++ b/openerp/addons/base/res/res_partner.py @@ -307,8 +307,13 @@ class res_partner(osv.Model, format_address): if getattr(threading.currentThread(), 'testing', False) or self.env.context.get('install_mode'): return False - img_path = openerp.modules.get_module_resource( - 'base', 'static/src/img', 'company_image.png' if is_company else 'avatar.png') + if self.env.context.get('partner_type') == 'delivery': + img_path = openerp.modules.get_module_resource('base', 'static/src/img', 'truck.png') + elif self.env.context.get('partner_type') == 'invoice': + img_path = openerp.modules.get_module_resource('base', 'static/src/img', 'money.png') + else: + img_path = openerp.modules.get_module_resource( + 'base', 'static/src/img', 'company_image.png' if is_company else 'avatar.png') with open(img_path, 'rb') as f: image = f.read() @@ -544,6 +549,10 @@ class res_partner(osv.Model, format_address): @api.model def create(self, vals): + if vals.get('type') == 'delivery': + vals['image'] = self.with_context(partner_type='delivery')._get_default_image(False, False) + elif vals.get('type') == 'invoice': + vals['image'] = self.with_context(partner_type='invoice')._get_default_image(False, False) if vals.get('website'): vals['website'] = self._clean_website(vals['website']) # function field not correctly triggered at create -> remove me when -- GitLab