Пример #1
0
    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 = False, False, False

        if partner_type in ['contact', 'other'] and parent_id:
            parent_image = self.browse(parent_id).image
            image = parent_image and parent_image.decode('base64') or None

        if not image and partner_type == 'invoice':
            img_path = get_module_resource('base', 'static/src/img', 'money.png')
        elif not image and partner_type == 'delivery':
            img_path = get_module_resource('base', 'static/src/img', 'truck.png')
        elif not image and is_company:
            img_path = get_module_resource('base', 'static/src/img', 'company_image.png')
        elif not image:
            img_path = get_module_resource('base', 'static/src/img', 'avatar.png')
            colorize = True

        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
        if image and colorize:
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(image.encode('base64'))
Пример #2
0
    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 = False, False, False

        if partner_type in ['other'] and parent_id:
            parent_image = self.browse(parent_id).image
            image = parent_image and base64.b64decode(parent_image) or None

        if not image and partner_type == 'invoice':
            img_path = get_module_resource('base', 'static/img', 'money.png')
        elif not image and partner_type == 'delivery':
            img_path = get_module_resource('base', 'static/img', 'truck.png')
        elif not image and is_company:
            img_path = get_module_resource('base', 'static/img',
                                           'company_image.png')
        elif not image:
            img_path = get_module_resource('base', 'static/img', 'avatar.png')
            colorize = True

        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
        if image and colorize:
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(base64.b64encode(image))
Пример #3
0
 def _get_default_image(self):
     image_path = get_module_resource('faculty', 'static/src/img',
                                      'default_image.png')
     with open(image_path, 'rb') as f:
         image = f.read()
     if image:
         image = tools.image_colorize(image)
     return tools.image_resize_image_big(base64.b64encode(image))
Пример #4
0
 def _get_default_image(self):
     image = False
     img_path = get_module_resource('berp_usuarios', 'static/src/img',
                                    'avatar.png')
     if img_path:
         with open(img_path, 'rb') as f:
             image = f.read()
     if image:
         image = tools.image_colorize(image)
     return tools.image_resize_image_big(base64.b64encode(image))
Пример #5
0
    def _get_default_image(self, is_company, colorize=False):
        img_path = get_module_resource('sistemerp_ereport_template',
                                       'static/src/img', 'avatar.png')
        with open(img_path, 'rb') as f:
            image = f.read()

        # colorize user avatars
        if not is_company:
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(base64.b64encode(image))
Пример #6
0
 def _default_image(self):
     if getattr(threading.currentThread(), 'testing', False) or self._context.get('install_mode'):
         return False
     colorize, img_path, image = False, False, False
     img_path = get_module_resource('etablissement', 'static/src/img', 'company_image.png')
     if img_path:
         with open(img_path, 'rb') as f:
             image = f.read()
     if image and colorize:
         image = tools.image_colorize(image)
     return tools.image_resize_image_big(base64.b64encode(image))
 def _get_default_image(self):
     '''Method to get default Image'''
     # added in try-except because import statements are in try-except
     try:
         img_path = get_module_resource('user_management', 'static',
                                        'avatar.png')
         with open(img_path, 'rb') as f:
             image = f.read()
         image = image_colorize(image)
         return image_resize_image_big(image.encode('base64'))
     except:
         return False
Пример #8
0
    def _get_default_image(self, is_company, colorize=False):
        img_path = odoo.modules.get_module_resource('general_template',
                                                    'static/src/img',
                                                    'avatar.png')
        with open(img_path, 'rb') as f:
            image = f.read()

        # colorize user avatars
        if not is_company:
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(image.encode('base64'))
Пример #9
0
    def _get_default_image(self):
        if getattr(threading.currentThread(), 'testing', False) or self._context.get('install_mode'):
            return False
        colorize, img_path, image = False, False, False
        img_path = get_module_resource('library', 'static/description/img', 'dummy.png')
        colorize = True

        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
        if image and colorize:
            image = tools.image_colorize(image)
        return tools.image_resize_image_big(base64.b64encode(image))
Пример #10
0
    def _get_default_image(self):
        colorize, img_path, image = False, False, False
        if not image:
            img_path = get_module_resource('wolftrakglobal', 'static/src/img',
                                           'gps.png')
            colorize = True
        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
        if image and colorize:
            image = tools.image_colorize(image)

        return tools.image_resize_image_medium(image.encode('base64'))
Пример #11
0
 def _get_default_image(self):
     if getattr(threading.currentThread(), 'testing',
                False) or self._context.get('install_mode'):
         return False
     colorize, img_path, image = False, False, False
     if not image:
         img_path = get_module_resource('base', 'static/src/img',
                                        'avatar.png')
         colorize = True
     if img_path:
         with open(img_path, 'rb') as f:
             image = f.read()
     if image and colorize:
         image = tools.image_colorize(image)
     return tools.image_resize_image_big(image.encode('base64'))
Пример #12
0
    def _get_default_image(self):
        colorize, img_path, image = False, False, False

        if not image:
            img_path = get_module_resource('base', 'static/src/img',
                                           'community.png')
            colorize = True

        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
        if image and colorize:
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(base64.b64encode(image))
Пример #13
0
    def _get_default_image(self):
        if getattr(threading.currentThread(), 'testing',
                   False) or self._context.get('install_mode'):
            return False
        colorize, img_path, image = False, False, False
        img_path = get_module_resource('library', 'static/description/img',
                                       'dummy.png')
        colorize = True

        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
        if image and colorize:
            image = tools.image_colorize(image)
        return tools.image_resize_image_big(base64.b64encode(image))
Пример #14
0
    def _get_default_image(self, partner_type, is_company, parent_id):

        if partner_type not in ['land','building']:
            return super(Partner, self)._get_default_image(partner_type, is_company, parent_id)


        if partner_type == 'land':
            img_path = get_module_resource('deltatech_property', 'static/src/img', 'land.png')
        else:
            img_path = get_module_resource('deltatech_property', 'static/src/img', 'building.png')

        with open(img_path, 'rb') as f:
            image = f.read()

        image = tools.image_colorize(image)

        return tools.image_resize_image_big(image.encode('base64'))
Пример #15
0
    def mixin_get_image(self,
                        module_name='base',
                        relative_path='static/src/img',
                        image_name='avatar.png'):
        # Permite cargar una imagen que este dentro de un modulo
        # :param module_name:
        # :param relative_path:
        # :param image_name:
        # :return:
        img_path = odoo.modules.get_module_resource(module_name, relative_path,
                                                    image_name)
        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
            if image:
                image = tools.image_colorize(image)
                return tools.image_resize_image_big(base64.b64encode(image))

        return None
Пример #16
0
    def _get_default_image(self, is_company, colorize=False):
        if getattr(threading.currentThread(), 'testing',
                   False) or self.env.context.get('install_mode'):
            return False

        if self.env.context.get('partner_type') == 'delivery':
            img_path = get_module_resource('base', 'static/src/img',
                                           'truck.png')
        elif self.env.context.get('partner_type') == 'invoice':
            img_path = get_module_resource('base', 'static/src/img',
                                           'money.png')
        else:
            img_path = 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()

        # colorize user avatars
        if not is_company and colorize:
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(image.encode('base64'))
Пример #17
0
    def _get_default_image(self, partner_type, is_company, parent_id):
        # Réécriture de la fonction Odoo pour retirer la couleur de fond aléatoire
        # Ainsi, chaque nouveau partenaire a les mêmes image/image_medium/image_small
        # Ce qui évite de surcharger le filestore
        if getattr(threading.currentThread(), 'testing',
                   False) or self._context.get('install_mode'):
            return False

        colorize, img_path, image = False, False, False

        if partner_type in ['other'] and parent_id:
            parent_image = self.browse(parent_id).image
            image = parent_image and parent_image.decode('base64') or None

        if not image and partner_type == 'invoice':
            img_path = get_module_resource('base', 'static/src/img',
                                           'money.png')
        elif not image and partner_type == 'delivery':
            img_path = get_module_resource('base', 'static/src/img',
                                           'truck.png')
        elif not image and is_company:
            img_path = get_module_resource('base', 'static/src/img',
                                           'company_image.png')
        elif not image:
            img_path = get_module_resource('base', 'static/src/img',
                                           'avatar.png')
            colorize = True

        if img_path:
            with open(img_path, 'rb') as f:
                image = f.read()
        if image and colorize:
            # Un rouge orange, censé rappeler la douce chaleur de la flamme
            # Dans l'âtre, les soirs d'hiver, quand le vent glacial rugit au-dehors
            image = tools.image_colorize(image, False, (250, 150, 0))

        return tools.image_resize_image_big(image.encode('base64'))