Esempio n. 1
0
    def _get_default_image(self, partner_type, is_company, parent_id):
        if getattr(threading.currentThread(), 'testing', False):
            return False

        colorize, img_path, image = False, False, False

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

        if not image and partner_type == 'invoice':
            img_path = openerp.modules.get_module_resource('base', 'static/src/img', 'money.png')
        elif not image and partner_type == 'delivery':
            img_path = openerp.modules.get_module_resource('base', 'static/src/img', 'truck.png')
        elif not image and is_company:
            img_path = openerp.modules.get_module_resource('base', 'static/src/img', 'company_image.png')
        elif not image:
            img_path = openerp.modules.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'))
Esempio n. 2
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 = 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')
        elif self.env.context.get('partner_type') == 'identity':
            img_path = openerp.modules.get_module_resource(
                'base_indonesia', 'static/src/img', 'identity.png')
        elif self.env.context.get('partner_type') == 'mailing':
            img_path = openerp.modules.get_module_resource(
                'base_indonesia', 'static/src/img', 'mailing.png')
        elif self.env.context.get('partner_type') == 'work':
            img_path = openerp.modules.get_module_resource(
                'base_indonesia', 'static/src/img', 'work.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()

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

        return tools.image_resize_image_big(image.encode('base64'))
Esempio n. 3
0
    def _get_default_image(self, partner_type, is_company, parent_id):
        if getattr(threading.currentThread(), 'testing', False):
            return False

        colorize, img_path, image = False, False, False

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

        if not image and partner_type == 'invoice':
            img_path = openerp.modules.get_module_resource(
                'base', 'static/src/img', 'money.png')
        elif not image and partner_type == 'delivery':
            img_path = openerp.modules.get_module_resource(
                'base', 'static/src/img', 'truck.png')
        elif not image and is_company:
            img_path = openerp.modules.get_module_resource(
                'base', 'static/src/img', 'company_image.png')
        elif not image:
            img_path = openerp.modules.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'))
 def get_default_image(cls):
     """
     Associate an image helper to the shape
     :return:
     """
     image_path = openerp.modules.get_module_resource('glass', 'static/src/img', 'avatar.png')
     if image_path:
         image = image_colorize(open(image_path, 'rb').read())
         return image_resize_image_big(image.encode('base64'))
Esempio n. 5
0
    def _get_default_image(self, cr, uid, is_company, context=None, colorize=False):
        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()
        # colorize user avatars
        if not is_company:
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(image.encode('base64'))
Esempio n. 6
0
    def _get_default_image(self, is_company, colorize=False):
        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()

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

        return tools.image_resize_image_big(image.encode('base64'))
    def _get_default_image_oschool(self, cr, uid, context=None):
        img_path = openerp.modules.get_module_resource(
            'oschool', 'static/src/img', 'avatar.png' if context.get('default_is_responsible') else 'student.png')
        with open(img_path, 'rb') as f:
            image = f.read()

        # colorize user avatars
        if context.get('default_is_responsible'):
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(image.encode('base64'))
Esempio n. 8
0
 def _get_default_image(self,
                        cr,
                        uid,
                        is_company,
                        context=None,
                        colorize=False):
     image = image_colorize(
         open(
             openerp.modules.get_module_resource('base', 'static/src/img',
                                                 'avatar.png')).read())
     return image_resize_image_big(image.encode('base64'))
    def _get_default_image_oschool(self, cr, uid, context=None):
        img_path = openerp.modules.get_module_resource(
            'oschool', 'static/src/img', 'avatar.png'
            if context.get('default_is_responsible') else 'student.png')
        with open(img_path, 'rb') as f:
            image = f.read()

        # colorize user avatars
        if context.get('default_is_responsible'):
            image = tools.image_colorize(image)

        return tools.image_resize_image_big(image.encode('base64'))
Esempio n. 10
0
 def _get_default_image(self,
                        cr,
                        uid,
                        is_company,
                        context=None,
                        colorize=False):
     image_medium = image_colorize(
         open(
             openerp.modules.get_module_resource('library_management',
                                                 'static/src/img',
                                                 'book1.png')).read())
     return image_resize_image_big(image_medium.encode('base64'))
Esempio n. 11
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

        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()

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

        return tools.image_resize_image_big(image.encode('base64'))
Esempio n. 12
0
    def _get_default_image(self, colorize=False):
        if getattr(threading.currentThread(), 'testing', False) or self.env.context.get('install_mode'):
            return False

        img_path = openerp.modules.get_module_resource(
            'best_deal', 'static/src/img', 'best_deal.png')
        
        with open(img_path, 'rb') as f:
            image = f.read()

        # colorize deal
        if colorize:
            image = tools.image_colorize(image)

        return best_deal_image.deal_image_resize_image_banner(image.encode('base64'))
    def _get_default_image_encoded(self, vals):
        """ It returns the base64 encoded image string for the default avatar.

        Args:
            vals (dict): Values dict as passed to create.

        Returns:
            str: A base64 encoded image.
            NoneType: None if no result.
        """
        colorize, image_path, image = False, False, False

        image_path = self._get_default_image_path(vals)
        if not image_path:
            return

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

        if image and colorize:
            image = tools.image_colorize(image)

        return base64.b64encode(image)
Esempio n. 14
0
 def _get_default_image(self):
     image = image_colorize(
         open(
             openerp.modules.get_module_resource('base', 'static/src/img',
                                                 'avatar.png')).read())
     return image_resize_image_big(image.encode('base64'))
Esempio n. 15
0
 def _get_img(self, is_company, colorize=False):
     avatar_img = openerp.modules.get_module_resource('base',
                                                      'static/src/img',
                                                      'avatar.png')
     image = image_colorize(open(avatar_img).read())
     return image_resize_image_big(image.encode('base64'))