Пример #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 _set_image_value(self, value):
     if isinstance(value, pycompat.text_type):
         value = value.encode('ascii')
     image = tools.image_resize_image_big(value)
     if self.product_tmpl_id.image:
         self.image_variant = image
     else:
         self.product_tmpl_id.image = image
Пример #3
0
 def _get_default_image(self, is_company, colorize=False):
     '''Method to get default Image'''
     # added in try-except because import statements are in try-except
     try:
         img_path = get_module_resource('base', 'static/src/img',
                                        '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
Пример #4
0
 def write(self, vals):
     # if not vals['active']:
     #     return super(LoanBorrower, self).write(vals)
     if vals.get('phone'):
         if not self.valid_phone(vals.get('phone')):
             return self.env.user.notify_warning(u'手机号码格式不正确!')
     elif not self.valid_phone(self.phone):
         return self.env.user.notify_warning(u'手机号码格式不正确!')
     if vals.get('frontimage'):
         vals['frontimage'] = tools.image_resize_image_big(
             vals.get('frontimage'))
     return super(LoanBorrower, self).write(vals)
Пример #5
0
 def _get_default_image(self, vals):
     res = super(MedicalPatient, self)._get_default_image(vals)
     if res:
         return res
     img_path = get_module_resource(
         'medical',
         'static/src/img',
         'patient-avatar.png',
     )
     with open(img_path, 'r') as image:
         base64_image = image.read().encode('base64')
     return tools.image_resize_image_big(base64_image)
Пример #6
0
    def _set_image_value(self, value):
        if isinstance(value, pycompat.text_type):
            value = value.encode('ascii')
        image = tools.image_resize_image_big(value)

        # This is needed because when there is only one variant, the user
        # doesn't know there is a difference between template and variant, he
        # expects both images to be the same.
        if self.product_tmpl_id.image and self.product_variant_count > 1:
            self.image_variant = image
        else:
            self.product_tmpl_id.image = image
Пример #7
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'))
Пример #8
0
 def update_avatar_image(self):
     for r in self:
         img_path = get_module_resource('buiding_unit_inherit',
                                        'static/img', 'toanha.jpg')
         if img_path:
             with open(img_path, 'rb') as f:
                 image = f.read()
         else:
             raise UserError(
                 'Thiếu hình ở buiding_unit_inherit/static/img/toanha.jpg')
         image_data = tools.image_resize_image_big(base64.b64encode(image))
         r.image = image_data
Пример #9
0
 def get_dingding_employees(self, department, url, data, s_avatar=None):
     result = requests.get(url=url, params=data, timeout=5)
     result = json.loads(result.text)
     if result.get('errcode') == 0:
         for user in result.get('userlist'):
             data = {
                 'name': user.get('name'),  # 员工名称
                 'din_id': user.get('userid'),  # 钉钉用户Id
                 'din_unionid': user.get('unionid'),  # 钉钉唯一标识
                 'mobile_phone': user.get('mobile'),  # 手机号
                 'work_phone': user.get('tel'),  # 分机号
                 'work_location': user.get('workPlace'),  # 办公地址
                 'notes': user.get('remark'),  # 备注
                 'job_title': user.get('position'),  # 职位
                 'work_email': user.get('email'),  # email
                 'din_jobnumber': user.get('jobnumber'),  # 工号
                 'department_id': department[0].id,  # 部门
                 'din_avatar': user.get('avatar')
                 if user.get('avatar') else '',  # 钉钉头像url
             }
             if user.get('hiredDate'):
                 time_stamp = self.get_time_stamp(user.get('hiredDate'))
                 data.update({
                     'din_hiredDate': time_stamp,
                 })
             if s_avatar and user.get('avatar'):
                 try:
                     binary_data = tools.image_resize_image_big(
                         base64.b64encode(
                             requests.get(user.get('avatar')).content))
                     data.update({'image': binary_data})
                 except Exception as e:
                     logging.info(">>>--------------------------------")
                     logging.info(">>>SSL异常:{}".format(e))
                     logging.info(">>>--------------------------------")
             if user.get('department'):
                 dep_din_ids = user.get('department')
                 dep_list = self.env['hr.department'].sudo().search([
                     ('din_id', 'in', dep_din_ids)
                 ])
                 data.update({'department_ids': [(6, 0, dep_list.ids)]})
             employee = self.env['hr.employee'].search([
                 '|', ('din_id', '=', user.get('userid')),
                 ('name', '=', user.get('name'))
             ])
             if employee:
                 employee.sudo().write(data)
             else:
                 self.env['hr.employee'].sudo().create(data)
         return result.get('hasMore')
     else:
         raise UserError("同步部门员工时发生意外,原因为:{}".format(result.get('errmsg')))
Пример #10
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))
Пример #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
        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))
Пример #12
0
 def _set_image(self):
     for record in self:
         if record.img_proof_of_delivery == record.img_tmp_proof_of_delivery: continue
         self.img_tmp_proof_of_delivery = tools.image_resize_image_big(self.img_proof_of_delivery)
         # self.image_medium = Image.open(BytesIO(self.image_medium))
         #print "#######################_______#################################"
         #print self.image
         #self.image.rotate(90, Image.BILINEAR, expand=True)
         # self.image = Image.open(base64.dencodestring(self.image)).rotate(90, expand=not, resample=Image.BILINEAR).save(self.image)
         # self.image = cStringIO.StringIO(self.image.decode('base64'))
         # self.image = base64.encodestring(self.image)
         self.img_proof_of_delivery = self.img_tmp_proof_of_delivery
     return
Пример #13
0
    def _get_default_image_value(self, img_path):
        try:
            image = False
            if img_path:
                with open(img_path, 'rb') as f:  # read the image from the path
                    image = f.read()

            return tools.image_resize_image_big(base64.b64encode(image))

        except Exception as error_mesage:

            valor_bool = self.actualizar(True)[0]
            if valor_bool:
                seccion_ciiu = self.comment[0]
                img_path = get_module_resource('l10n_ec_partner', 'static/src/img', 'ciiu_seccion_' + seccion_ciiu + '.png')
                image = False
            else:
                img_path = get_module_resource('l10n_ec_partner', 'static/src/img', 'ciiu_seccion_PAS.png')
                image = False
            if img_path:
                with open(img_path, 'rb') as f:  # read the image from the path
                    image = f.read()
            return tools.image_resize_image_big(base64.b64encode(image))
Пример #14
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))
Пример #15
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'))
Пример #16
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))
Пример #17
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'))
Пример #18
0
    def modifyDetailed(self, **post):
        username = post.get('username')
        telephone = post.get('telephone')
        address = post.get('address')
        user_id = post.get("user_id")
        commonuser = request.env['hrstore.commonuser'].sudo().search([
            ('user_id', '=', user_id)
        ])

        image_route = post.get('user_image')
        if ':' in image_route:
            print(image_route)
        else:
            image_route = "D://picture//" + image_route
        print(image_route)
        if image_route:
            user_image = tools.image_resize_image_big(
                base64.b64encode(open(image_route, 'rb').read()))
            info = {
                'user_image': user_image,
                'username': username,
                'telephone': telephone,
                'address': address
            }
            commonuser.write(info)
        else:
            info = {
                'username': username,
                'telephone': telephone,
                'address': address
            }
            commonuser.write(info)

        commonuser_new = request.env['hrstore.commonuser'].sudo().search([
            ('user_id', '=', user_id)
        ])
        user = request.env['hrstore.user'].sudo().search([('user_id', '=',
                                                           user_id)])

        return request.render(
            'HRStore.customer_modifyInfo', {
                'user_id': user_id,
                'message': "个人信息修改成功",
                'user_info': user,
                'commonuser_info': commonuser_new
            })
Пример #19
0
    def updateDetailed(self, **post):
        shopname = post.get('shopname')
        telephone = post.get('telephone')
        address = post.get('address')
        image_route = post.get('user_image')
        if ':' in image_route:
            print(image_route)
        else:
            image_route = "D://picture//" + image_route
        print(image_route)
        username = post.get('user_id')
        supplier = request.env['hrstore.shop'].search([('user_id', '=',
                                                        username)])

        if image_route:
            user_image = tools.image_resize_image_big(
                base64.b64encode(open(image_route, 'rb').read()))
            info = {
                'shopname': shopname,
                'telephone': telephone,
                'address': address,
                'user_image': user_image
            }
            supplier.write(info)
        else:
            info = {
                'shopname': shopname,
                'telephone': telephone,
                'address': address
            }
            supplier.write(info)

        request.session['telephone'] = supplier.telephone
        request.session['address'] = supplier.address
        request.session['user_image'] = supplier.user_image

        supplier_new = request.env['hrstore.shop'].search([('user_id', '=',
                                                            username)])
        print(supplier_new.address)

        return request.render('HRStore.supplier_updateInfo', {
            'message': "个人信息修改成功",
            'supplier': supplier_new,
            'user_id': username
        })
Пример #20
0
    def mixin_get_image_as_base_64(self,
                                   module_name='base',
                                   relative_path='static/src/img',
                                   image_name='avatar.png'):
        # Permite cargar el base64 de 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:
                return tools.image_resize_image_big(base64.b64encode(image))

        return None
Пример #21
0
    def get_image(self, vals={}):
        image = None
        if vals:
            is_company = vals
        else:
            is_company = self.is_company
        if is_company:
            img_path = get_module_resource('base', 'static/img',
                                           'company_image.png')
        else:
            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:
            return tools.image_resize_image_big(base64.b64encode(image))
Пример #22
0
 def create(self, vals):
     if vals.get('image_url'):
         log_val = {
             'object': 'Product',
             'resource_id': None,
             'result': 'success',
         }
         try:
             binary_data = tools.image_resize_image_big(
                 base64.b64encode(
                     requests.get(vals.get('image_url')).content))
             vals.update({'image': binary_data})
         except Exception as e:
             log_val.update({
                 'result': 'error',
                 'error_message': str(e),
             })
         self.env['import.image.url.log'].create(log_val)
     return super(ProductTemplate, self).create(vals)
Пример #23
0
    def write(self, values):
        ''' Store the standard price change in order to be able to retrieve the cost of a product for a given date'''
        for obj in self:
            if values.get('image_url'):
                log_val = {
                    'object': 'Product Variants',
                    'resource_id': obj.id,
                    'result': 'success',
                }
                try:
                    binary_data = tools.image_resize_image_big(
                        base64.b64encode(
                            requests.get(values.get('image_url')).content))
                    values.update({'image': binary_data})
                except Exception as e:
                    log_val.update({
                        'result': 'error',
                        'error_message': str(e),
                    })
                self.env['import.image.url.log'].create(log_val)

        return super(ProductProduct, self).write(values)
Пример #24
0
 def update_avatar_image(self):
     for r in self:
         if r.is_unit:
             if r.product_id.image and not r.image:
                 r.image = r.product_id.image
             elif not r.image:
                 img_path = get_module_resource(
                     'buiding_management_inherit', 'static/img',
                     'toanha.jpg')
                 if img_path:
                     with open(img_path, 'rb') as f:
                         image = f.read()
                 else:
                     raise UserError(
                         'Thiếu hình ở buiding_management_inherit/static/img/toanha.jpg'
                     )
                 image_data = tools.image_resize_image_big(
                     base64.b64encode(image))
                 r.image = image_data
         elif r.is_resident:
             if r.relationship_owner_id.image and not r.image:
                 r.image = r.relationship_owner_id.image
Пример #25
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'))
Пример #26
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'))
Пример #27
0
    def supplier_addProduct(self, **post):
        name = post.get('pro_name')
        price = post.get('pro_price')
        detail = post.get('pro_detail')
        type = post.get('pro_type')
        state = '0'
        view = 0
        image_route = post.get('pro_image')
        if ':' in image_route:
            print(image_route)
        else:
            image_route = "D://picture//" + image_route
        print(image_route)
        pro_image = tools.image_resize_image_big(
            base64.b64encode(open(image_route, 'rb').read()))

        username = post.get('user_id')
        supplier = request.env['hrstore.shop'].search([('user_id', '=',
                                                        username)])
        userID = supplier.id

        request.env['hrstore.product'].sudo().create({
            'pro_name': name,
            'pro_price': price,
            'pro_detail': detail,
            'pro_type': type,
            'state': state,
            'pro_view': view,
            'user_id': userID,
            'pro_image': pro_image
        })

        return request.render('HRStore.supplier_addProduct', {
            'message': "产品添加成功",
            'supplier': supplier,
            'user_id': username
        })
Пример #28
0
 def _default_image(self):
     image_path = get_module_resource('hr', 'static/src/img',
                                      'default_image.png')
     return tools.image_resize_image_big(
         base64.b64encode(open(image_path, 'rb').read()))
Пример #29
0
 def _get_default_image(self, cr, uid, context=None):
     image_path = get_module_resource("hr", "static/src/img", "default_image.png")
     return tools.image_resize_image_big(open(image_path, "rb").read().encode("base64"))
Пример #30
0
 def _inverse_image_small(self):
     for rec in self:
         rec.image = tools.image_resize_image_big(rec.image_small)
Пример #31
0
 def _inverse_image_medium(self):
     for rec in self:
         rec.image = tools.image_resize_image_big(rec.image_medium)
Пример #32
0
 def _default_image(self):
     image_path = get_module_resource('hr', 'static/src/img', 'default_image.png')
     return tools.image_resize_image_big(base64.b64encode(open(image_path, 'rb').read()))
Пример #33
0
 def _set_image(self):
     return self.write(
         {'image': tools.image_resize_image_big(self.image_medium)})
Пример #34
0
 def _inverse_image_small(self):
     for rec in self:
         rec.image = tools.image_resize_image_big(rec.image_small)
Пример #35
0
 def _inverse_image_medium(self):
     for rec in self:
         rec.image = tools.image_resize_image_big(rec.image_medium)
Пример #36
0
 def _set_image_value(self, value):
     image = tools.image_resize_image_big(value)
     if self.product_tmpl_id.image:
         self.image_variant = image
     else:
         self.product_tmpl_id.image = image
Пример #37
0
 def _get_default_image(self, cr, uid, context=None):
     image_path = get_module_resource('hr', 'static/src/img', 'default_image.png')
     return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
Пример #38
0
 def _get_default_image(self):
     image_path = modules.get_module_resource('mail', 'static/src/img',
                                              'groupdefault.png')
     return tools.image_resize_image_big(
         base64.b64encode(open(image_path, 'rb').read()))
Пример #39
0
 def _default_image(self):
     image_path = modules.get_module_resource('im_livechat',
                                              'static/src/img',
                                              'default.png')
     return tools.image_resize_image_big(
         open(image_path, 'rb').read().encode('base64'))
Пример #40
0
 def _get_default_image(self):
     image_path = modules.get_module_resource('mail', 'static/src/img', 'groupdefault.png')
     return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))