Beispiel #1
0
 def write(self, vals):
     if 'image' in vals:
         image = ustr(vals['image'] or '').encode('utf-8')
         vals['image_payment_form'] = image_resize_image(image,
                                                         size=(45, 30))
         vals['image'] = image_resize_image(image, size=(64, 64))
     return super(PaymentIcon, self).write(vals)
Beispiel #2
0
    def ftp_connection_push_image_file(
            self, ftp, distant_folder_path, local_folder_path,
            obj, field):

        # Generate temporary image file
        f_name = self._generate_image_file_name(obj, field)
        if not f_name:
            # No image define
            return False
        local_path = os.path.join(local_folder_path, f_name)
        distant_path = os.path.join(distant_folder_path, f_name)
        image_base64 = getattr(obj, field.name)
        # Resize and save image
        tools.image_resize_image(
            base64_source=image_base64, size=(120, 120), encoding='base64',
            filetype='PNG')
        image_data = base64.b64decode(image_base64)
        f = open(local_path, 'wb')
        f.write(image_data)
        f.close()

        # Send File by FTP
        f = open(local_path, 'rb')
        ftp.storbinary('STOR ' + distant_path, f)

        # Delete temporary file
        os.remove(local_path)
Beispiel #3
0
 def _compute_logo_web(self):
     for company in self:
         if company.theme_logo:
             company.logo_web = tools.image_resize_image(
                 company.theme_logo, (180, None))
         else:
             company.logo_web = tools.image_resize_image(
                 company.partner_id.image, (180, None))
Beispiel #4
0
def get_resized_images(base64_source, medium_name='image_medium', small_name='image_small',
                       medium_size=(500, 500), small_size=(64, 64),
                       encoding='base64', filetype=None):
    if isinstance(base64_source, pycompat.text_type):
        base64_source = base64_source.encode('ascii')

    return_dict = dict()
    return_dict[medium_name] = tools.image_resize_image(base64_source, medium_size, encoding, filetype, True)
    return_dict[small_name] = tools.image_resize_image(base64_source, small_size, encoding, filetype, True)

    return return_dict
Beispiel #5
0
 def create(self, vals):
     #here we resize the image first to avoid bloating the filestore
     mimetype = vals.get('mimitype') or self._compute_mimetype(vals)
     if mimetype in IMAGE_TYPES and 'datas' in vals:
         # image_resize_image requires a binary object instead of string.
         # For situations like adding images to the product_image_ids
         # through Odoo's standard way, vals['datas'] will be in string
         # form therefore conversion is needed
         datas = vals['datas'].encode('utf8') if type(vals['datas']) is \
                                                 str else vals['datas']
         vals['datas'] = image_resize_image(datas,
                                            size=(1024, 1024),
                                            encoding='base64',
                                            filetype=None,
                                            avoid_if_small=True)
     attachment = super(IrAttachment, self).create(vals)
     #if datas_fname is False, then we judge it as the main image, and we
     #do not want to add carousel image for that
     if attachment and attachment.mimetype in IMAGE_TYPES and \
                     attachment.res_model in ['product.template',
                                              'product.product'] and \
                     attachment.datas_fname:
         #assignment for pt
         if attachment.res_model == 'product.template':
             pt = self.env['product.template'].browse(attachment.res_id)
         if attachment.res_model == 'product.product':
             pt = self.env['product.product'].browse(
                 attachment.res_id).product_tmpl_id
         vals = {
             'name': attachment.name,
             'image': attachment.datas,
             'product_tmpl_id': pt.id,
         }
         self.env['product.image'].sudo().create(vals)
     return attachment
    def _set_resized_to_cache(self, width, height, field=None):
        content = self.datas
        content = tools.image_resize_image(base64_source=content,
                                           size=(width or None, height
                                                 or None),
                                           encoding='base64',
                                           filetype='PNG')

        new_resized_attachment_data = {
            'name': '%sx%s %s' % (width, height, self.name),
            'datas': content,
        }
        if field:
            new_resized_attachment_data.update({
                'res_model': self.res_model,
                'res_field': field,
                'res_id': self.res_id,
            })
        context = self._get_context_for_resized_att_creating()
        resized_attachment = self.env['ir.attachment'].with_context(
            context).sudo().create(new_resized_attachment_data)
        return self.env['ir.attachment.resized'].sudo().create({
            'attachment_id':
            self.id,
            'width':
            width,
            'height':
            height,
            'resized_attachment_id':
            resized_attachment.id,
        })
Beispiel #7
0
 def create(self, vals):
     #here we resize the image first to avoid bloating the filestore
     if vals.get('res_model') in ['product.template', 'product.product']:
         mimetype = vals.get('mimitype') or self._compute_mimetype(vals)
         if mimetype in IMAGE_TYPES:
             vals['datas'] = image_resize_image(vals['datas'],
                                                size=(1600, 1600),
                                                encoding='base64',
                                                filetype=None,
                                                avoid_if_small=True)
     attachment = super(IrAttachment, self).create(vals)
     #if datas_fname is False, then we judge it as the main image, and we
     #do not want to add carousel image for that
     if attachment and attachment.mimetype in IMAGE_TYPES and \
                     attachment.res_model in ['product.template',
                                              'product.product'] and \
                     attachment.datas_fname:
         #FIXME in case variants are used, how should we normalize the value
         #assignment for pt and pp below?
         if attachment.res_model == 'product.template':
             pt = self.env['product.template'].browse(attachment.res_id)
             pp = pt.product_variant_id
         if attachment.res_model == 'product.product':
             pp = self.env['product.product'].browse(attachment.res_id)
             pt = pp.product_tmpl_id
         vals = {
             'name': attachment.name,
             'image': attachment.datas,
             'image_url': attachment.local_url,
             'product_tmpl_id': pt.id,
             'product_variant_id': pp.id,
         }
         self.env['product.image'].sudo().create(vals)
     return attachment
Beispiel #8
0
 def _get_logo_topbar(self):
     result = dict.fromkeys(False)
     for record in self:
         size = (48, 48)
         result[record.id] = image_resize_image(record.partner_id.image,
                                                size)
     return result
Beispiel #9
0
    def create_or_update_from_manifest(
            self, info, repository_branch, full_module_path):
        module_obj = self.env['odoo.module']
        module_version = self.search([
            ('technical_name', '=', str(info['technical_name'])),
            ('repository_branch_id', '=', repository_branch.id)])

        if not module_version:
            # Create new module version
            module = module_obj.create_if_not_exist(info['technical_name'])
            module_version = self.create(
                self.manifest_2_odoo(info, repository_branch, module))

        else:
            # Update module Version
            value = self.manifest_2_odoo(
                info, repository_branch, module_version.module_id)
            module_version.write(value)
        icon_path = False
        for current_icon_path in self._ICON_PATH:
            full_current_icon_path = os.path.join(
                full_module_path, current_icon_path, 'icon.png')
            if os.path.exists(full_current_icon_path):
                icon_path = full_current_icon_path
        if icon_path:
            resized_image = False
            try:
                with open(icon_path, 'rb') as f:
                    image = f.read()
                resized_image = tools.image_resize_image(
                    image.encode('base64'), size=(96, 96),
                    encoding='base64', filetype='PNG')
            except Exception:
                _logger.warning("Unable to read or resize %s" % icon_path)
            module_version.write({'image': resized_image})
    def _set_resized_to_cache(self, width, height, field=None):
        content = self.datas
        content = tools.image_resize_image(
            base64_source=content,
            size=(width or None, height or None),
            encoding="base64",
            filetype="PNG",
        )

        new_resized_attachment_data = {
            "name": "{}x{} {}".format(width, height, self.name),
            "datas": content,
        }
        if field:
            new_resized_attachment_data.update({
                "res_model": self.res_model,
                "res_field": field,
                "res_id": self.res_id
            })
        context = self._get_context_for_resized_att_creating()
        resized_attachment = (self.env["ir.attachment"].with_context(
            context).sudo().create(new_resized_attachment_data))
        return (self.env["ir.attachment.resized"].sudo().create({
            "attachment_id":
            self.id,
            "width":
            width,
            "height":
            height,
            "resized_attachment_id":
            resized_attachment.id,
        }))
Beispiel #11
0
 def _get_thumbnail(self):
     for record in self:
         if record.mimetype:
             if re.match('image.*(gif|jpeg|jpg|png)', record.mimetype):
                 if not record.thumbnail:
                     temp_image = crop_image(record.datas, type='center', size=(100, 100), ratio=(1, 1))
                     record.thumbnail = image_resize_image(base64_source=temp_image, size=(100, 100),
                                                           encoding='base64', filetype='PNG')
 def write(self, vals):
     image = vals.get('image', vals.get('image_medium_big', vals.get('image_medium', vals.get('image_small'))))
     if image:
         if not vals.get('image'):
             vals['image'] = image
         vals['image_medium_big'] = tools.image_resize_image(image, size=(320, 320), avoid_if_small=True)
     res = super(ProductTemplate, self).write(vals)
     return res
 def _compute_med_big_image(self):
     if self._context.get('bin_size'):
         self.image_medium_big = self.image_variant
     else:
         resized_image = tools.image_resize_image(self.image_variant, size=(320, 320), avoid_if_small=True)
         self.image_medium_big = resized_image
     if not self.image_medium_big:
         self.image_medium_big = self.product_tmpl_id.image_medium_big
Beispiel #14
0
 def _resize_large_image(self, vals):
     if vals.get('image'):
         base64_source = vals['image'].encode('ascii') if isinstance(
             vals['image'], pycompat.text_type) else vals['image']
         vals.update({
             'image':
             tools.image_resize_image(base64_source, size=(1024, None))
         })
    def create_or_update_from_manifest(
            self, info, repository_branch, full_module_path):
        module_obj = self.env['odoo.module']
        module_version = self.search([
            ('technical_name', '=', str(info['technical_name'])),
            ('repository_branch_id', '=', repository_branch.id)])

        if not module_version:
            # Create new module version
            module = module_obj.create_if_not_exist(info['technical_name'])
            module_version = self.create(
                self.manifest_2_odoo(info, repository_branch, module))

        else:
            # Update module Version
            value = self.manifest_2_odoo(
                info, repository_branch, module_version.module_id)
            module_version.write(value)
        icon_path = False
        resize = False
        if info.get('images'):
            full_current_icon_path = os.path.join(
                full_module_path, info.get('images')[0])
            if os.path.exists(full_current_icon_path):
                icon_path = full_current_icon_path
        else:
            for current_icon_path in self._ICON_PATH:
                full_current_icon_path = os.path.join(
                    full_module_path, current_icon_path, 'icon.png')
                if os.path.exists(full_current_icon_path):
                    icon_path = full_current_icon_path
                    resize = True
                    break
        if icon_path:
            image_enc = False
            try:
                with open(icon_path, 'rb') as f:
                    image = f.read()
                if resize:
                    image_enc = tools.image_resize_image(
                        base64.b64encode(image), size=(96, 96),
                        encoding='base64', filetype='PNG')
                else:
                    image_enc = base64.b64encode(image)
            except Exception:
                _logger.warning("Unable to read or resize %s", icon_path)
            module_version.write({'image': image_enc})
        else:
            # Set the default icon
            try:
                with open(os.path.join(
                        os.path.dirname(__file__),
                        '../data/oca.png'), 'rb') as f:
                    image = base64.b64encode(f.read())
                    module_version.write({'image': image})
            except Exception as e:
                _logger.error(
                    'Unable to read the OCA icon image, error is %s', e)
    def create_or_update_from_manifest(
            self, info, repository_branch, full_module_path):
        module_obj = self.env['odoo.module']
        module_version = self.search([
            ('technical_name', '=', str(info['technical_name'])),
            ('repository_branch_id', '=', repository_branch.id)])

        if not module_version:
            # Create new module version
            module = module_obj.create_if_not_exist(info['technical_name'])
            module_version = self.create(
                self.manifest_2_odoo(info, repository_branch, module))

        else:
            # Update module Version
            value = self.manifest_2_odoo(
                info, repository_branch, module_version.module_id)
            module_version.write(value)
        icon_path = False
        resize = False
        if info.get('images'):
            full_current_icon_path = os.path.join(
                full_module_path, info.get('images')[0])
            if os.path.exists(full_current_icon_path):
                icon_path = full_current_icon_path
        else:
            for current_icon_path in self._ICON_PATH:
                full_current_icon_path = os.path.join(
                    full_module_path, current_icon_path, 'icon.png')
                if os.path.exists(full_current_icon_path):
                    icon_path = full_current_icon_path
                    resize = True
                    break
        if icon_path:
            image_enc = False
            try:
                with open(icon_path, 'rb') as f:
                    image = f.read()
                if resize:
                    image_enc = tools.image_resize_image(
                        base64.b64encode(image), size=(96, 96),
                        encoding='base64', filetype='PNG')
                else:
                    image_enc = base64.b64encode(image)
            except Exception:
                _logger.warning("Unable to read or resize %s", icon_path)
            module_version.write({'image': image_enc})
        else:
            # Set the default icon
            try:
                with open(os.path.join(
                        os.path.dirname(__file__),
                        '../data/oca.png'), 'rb') as f:
                    image = base64.b64encode(f.read())
                    module_version.write({'image': image})
            except Exception as e:
                _logger.error(
                    'Unable to read the OCA icon image, error is %s', e)
Beispiel #17
0
    def custom_logo(self, dbname=None, **kw):
        imgname = 'logo'
        imgext = '.png'
        # Here we are changing the default logo with logo selected on debrand settings
        company_logo = request.env['website'].sudo().search([])[0].company_logo
        custom_logo = tools.image_resize_image(company_logo, (150, None))
        placeholder = functools.partial(get_resource_path, 'web', 'static',
                                        'src', 'img')
        uid = None
        if request.session.db:
            dbname = request.session.db
            uid = request.session.uid
        elif dbname is None:
            dbname = db_monodb()

        if not uid:
            uid = odoo.SUPERUSER_ID

        if not dbname:
            response = http.send_file(placeholder(imgname + imgext))
        else:
            try:
                # create an empty registry
                registry = odoo.modules.registry.Registry(dbname)
                if custom_logo:
                    image_base64 = base64.b64decode(custom_logo)
                    image_data = io.BytesIO(image_base64)
                    imgext = '.' + (imghdr.what(None, h=image_base64) or 'png')
                    response = http.send_file(image_data,
                                              filename=imgname + imgext,
                                              mtime=None)
                else:
                    with registry.cursor() as cr:
                        cr.execute(
                            """SELECT c.logo_web, c.write_date
                                        FROM res_users u
                                   LEFT JOIN res_company c
                                          ON c.id = u.company_id
                                       WHERE u.id = %s
                                   """, (uid, ))
                        row = cr.fetchone()
                        if row and row[0]:
                            image_base64 = str(row[0]).decode('base64')
                            image_data = io.BytesIO(image_base64)
                            imgext = '.' + (imghdr.what(None, h=image_base64)
                                            or 'png')
                            response = http.send_file(image_data,
                                                      filename=imgname +
                                                      imgext,
                                                      mtime=row[1])
                        else:
                            response = http.send_file(
                                placeholder('nologo.png'))
            except Exception as e:
                _logger.warning('EXCEPT custom_logo: %s', e)
                response = http.send_file(placeholder(imgname + imgext))
        return response
Beispiel #18
0
 def _image_get_resized_signature(
         self, base64_source, image_name='x_signature_img'):
     return_dict = dict()
     return_dict[image_name] = tools.image_resize_image(
             base64_source,
             size=(200, 100),
             encoding='base64',
             filetype=None,
             avoid_if_small=True)
     return return_dict
Beispiel #19
0
 def _compute_med_big_image(self):
     if self._context.get('bin_size'):
         self.image_medium_big = self.image_variant
     else:
         resized_image = tools.image_resize_image(self.image_variant,
                                                  size=(320, 320),
                                                  avoid_if_small=True)
         self.image_medium_big = resized_image
     if not self.image_medium_big:
         self.image_medium_big = self.product_tmpl_id.image_medium_big
Beispiel #20
0
 def _make_thumbnail(self, vals):
     if vals.get('datas') and not vals.get('res_field'):
         vals['thumbnail'] = False
         if vals.get('mimetype') and re.match('image.*(gif|jpeg|jpg|png)', vals['mimetype']):
             try:
                 temp_image = crop_image(vals['datas'], type='center', size=(80, 80), ratio=(1, 1))
                 vals['thumbnail'] = image_resize_image(base64_source=temp_image, size=(80, 80),
                                                        encoding='base64')
             except Exception:
                 pass
     return vals
Beispiel #21
0
 def _resize(self, image, size_x, size_y, fmt):
     image_resize_server = (
         self.env["ir.config_parameter"]
         .sudo()
         .get_param("storage.image.resize.server")
     )
     if image_resize_server and image.backend_id.served_by != "odoo":
         values = {"url": image.url, "width": size_x, "height": size_y, "fmt": fmt}
         url = image_resize_server.format(**values)
         return base64.encodestring(requests.get(url).content)
     return image_resize_image(image.data, size=(size_x, size_y))
Beispiel #22
0
 def _make_thumbnail(self, vals):
     if vals.get('datas') and not vals.get('res_field'):
         vals['thumbnail'] = False
         if vals.get('mimetype') and re.match('image.*(gif|jpeg|jpg|png)', vals['mimetype']):
             try:
                 temp_image = crop_image(vals['datas'], type='center', size=(80, 80), ratio=(1, 1))
                 vals['thumbnail'] = image_resize_image(base64_source=temp_image, size=(80, 80),
                                                        encoding='base64')
             except Exception:
                 pass
     return vals
Beispiel #23
0
 def create(self, vals):
     image = vals.get(
         'image',
         vals.get('image_medium_big',
                  vals.get('image_medium', vals.get('image_small'))))
     if image:
         if not vals.get('image'):
             vals['image'] = image
         vals['image_medium_big'] = tools.image_resize_image(
             image, size=(320, 320), avoid_if_small=True)
     template = super(ProductTemplate, self).create(vals)
     return template
Beispiel #24
0
 def write(self, vals):
     image = vals.get(
         'image',
         vals.get('image_medium_big',
                  vals.get('image_medium', vals.get('image_small', None))))
     if image:
         if not vals.get('image'):
             vals['image'] = image
         vals['image_medium_big'] = tools.image_resize_image(
             image, size=(320, 320), avoid_if_small=True)
     if image == False:
         vals['image'] = False
     res = super(ProductTemplate, self).write(vals)
     return res
Beispiel #25
0
 def _get_thumbnail(self):
     for record in self:
         if record.mimetype:
             if re.match('image.*(gif|jpeg|jpg|png)', record.mimetype):
                 if not record.thumbnail:
                     temp_image = crop_image(record.datas,
                                             type='center',
                                             size=(100, 100),
                                             ratio=(1, 1))
                     record.thumbnail = image_resize_image(
                         base64_source=temp_image,
                         size=(100, 100),
                         encoding='base64',
                         filetype='PNG')
Beispiel #26
0
    def img(self, **kwargs):
        link, doc, doc_abspath = self._get_link(**kwargs)
        if not ft.guess(doc_abspath) or ft.guess(
                doc_abspath).extension not in IMG_EXT:
            abort(404)

        if not kwargs.get("thumb"):
            return http.send_file(doc_abspath,
                                  mimetype=ft.guess(doc_abspath).mime)

        # Generate thumbnail
        img = base64.b64encode(open(doc_abspath, "rb").read())
        img_new = tools.image_resize_image(img, (None, 200))
        with NamedTemporaryFile(mode="wb") as img_new_tmp:
            img_new_tmp.write(base64.b64decode(img_new))
            img_new_tmp.flush()
            return http.send_file(img_new_tmp.name,
                                  mimetype=ft.guess(img_new_tmp.name).mime)
Beispiel #27
0
 def write(self, vals):
     if 'image' in vals:
        vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30))
        vals['image'] = image_resize_image(vals['image'], size=(64,64))
     return super(PaymentIcon, self).write(vals)
Beispiel #28
0
 def _compute_logo_web(self):
     for company in self:
         company.logo_web = tools.image_resize_image(company.partner_id.image, (180, None))
Beispiel #29
0
 def write(self, vals):
     if 'image' in vals:
         image = ustr(vals['image'] or '').encode('utf-8')
         vals['image_payment_form'] = image_resize_image(image, size=(45,30))
         vals['image'] = image_resize_image(image, size=(64,64))
     return super(PaymentIcon, self).write(vals)
Beispiel #30
0
	def _resize_large_image(self, base64_str=None):
		if base64_str:
			base64_source = base64_str.encode('ascii') if isinstance(base64_str, pycompat.text_type) else base64_str
			return tools.image_resize_image(base64_source, size=self._max_public_file_size)
Beispiel #31
0
 def write(self, vals):
     if image in vals:
         vals.update(
             {image: tools.image_resize_image(vals[image], image_size)})
     return super(website_cpo_advertising, self).write(vals)
    def order_line_create(self):
        print(
            "****************************************************************************************************"
        )
        print(
            "***************************order_line_create in mim_module_update_total*****************************"
        )
        print(
            "****************************************************************************************************"
        )

        sale_order_line_obj = self.env[
            'sale.order.line']  #on recupère l'objet sale.order.line pour l'utiliser avec la fonction ORM create
        #### début de la récupèration des différents paramètres saisi sur le pop-up####
        select_type = self.select_type
        type_fix = self.type_fixe
        inegalite = self.inegalite
        vitrage = self.vitre
        type_vitre = self.type_vitre
        decoratif = self.decoratif
        serr = self.serr
        poigne = self.poigne
        nb_poigne = self.nb_poigne
        nb_serr = self.nb_serr
        oscillo_battant = self.oscillo_battant
        va_et_vient = self.va_et_vient
        butoir = self.butoir
        remplissage_vitre = self.remplissage_vitre
        cintre = self.cintre
        triangle = self.triangle
        division = self.division
        nb_division = self.nb_division
        laque = self.laque
        moustiquaire = self.moustiquaire
        type_moustiquaire = self.type_moustiquaire
        tms = self.tms
        rec_largeur = self.largeur
        rec_hauteur = self.hauteur
        intermediaire = self.intermediaire
        rec_dimension = self.dimension
        rec_pu_ttc = self.pu_ttc
        rec_ref = self.order_ref
        rec_qty = self.quantity
        image = self.image
        #rec_total = self.browse(cr, uid, ids, context=context)[0].totalcacher
        total = self.calcul()
        #### début de formatisation de champ select_type pour evité d'afficher par ex coullissante2vtx ####
        types = select_type.name
        vitre = ''
        poignee = ''
        btr = ''
        oscillo = ''
        v_et_v = ''
        rempli = ''
        ctr = ''
        lq = ''
        trgl = ''
        mstqr = ''
        dvs = ''
        tmss = ''
        simple_double = ''
        deco = ''
        #name = ''
        intermdr = ''
        inegalit = ''
        if type_vitre:
            if type_vitre == 'double':
                simple_double = ' double,'
        dec = decoratif.name
        if ((decoratif.name is not None) and (decoratif.name != False)):
            if dec == u'Compliqué':
                deco = u' compliqué,'
        if intermediaire:
            if intermediaire == 'sans':
                intermdr = ''
        if intermediaire == 'avec':
            intermdr = u' avec intermédiaire, '
        if inegalite:
            if inegalite == 'egaux':
                inegalit = ''
        if inegalite == u'inegaux':
            inegalit = u'inégaux,'
            if ((vitrage.name == False) or (vitrage.name is None)):
                vitre = '\n largeur, hauteur, dimension, pu_ttc, quantity, select_type, vitre, type_vitre, decoratif, poigne, serr, nb_poigne, nb_serr, oscillo_battant, va_et_vient, butoir, remplissage_vitre, cintre, triangle, division, nb_division, laque, moustiquaire, type_moustiquaire, tms, intermediaire- Vitrage : standard, '
            else:
                vitre = u"\n - Vitrage : " + vitrage.name + ", "
        if ((poigne.name is not None) and (poigne.name != False)):
            poignee = u'' + poigne.name + ''

            if butoir:
                btr = " avec butoir, "
            if va_et_vient:
                v_et_v = " avec va et vient,"
            if oscillo_battant:
                oscillo = " oscillo battant, "
            if remplissage_vitre:
                if remplissage_vitre == 'standard':
                    remplissage_vitre = ''
                if remplissage_vitre == u'pleine_2_3':
                    remplissage_vitre = u'2/3 pleine'
                if remplissage_vitre == u'pleine_1_2':
                    remplissage_vitre = u'1/2 pleine'
                if remplissage_vitre == u'pleine_1_3':
                    remplissage_vitre = u'1/3 pleine'
                if remplissage_vitre == u'pleine_bardage':
                    remplissage_vitre = u'Pleine/bardage'

                rempli = " " + str(remplissage_vitre) + ", "
            if cintre:
                ctr = u" cintré, "
            if laque:
                lq = u" laqué, "
            if triangle:
                trgl = u" Triangle, "
            if moustiquaire:
                mstqr = "  avec moustiquaire "
            if division:
                if (nb_division > 1):
                    dvs = " " + str(nb_division) + " divisions, "
                else:
                    dvs = " " + str(nb_division) + " division, "
            if tms != 0.0:
                tmss = " TMS, "
        type_porte = u'Fenêtre'
        if types == 'Coulissante 2VTX':
            serrure = ''
            if tms != 0.0:
                type_porte = 'Porte'
        if serr.name is not None:
            if moustiquaire:
                serrure = u' 2 serrures encastrées 2 points '
            else:
                serrure = u' 1 poignee 4 points à  clef'
        else:
            if moustiquaire:
                serrure = u' 2 serrures encastrées 2 points'
            else:
                serrure = u' 1 poignee et 1 serrures encastrées 2 points'
                types = u" " + type_porte + " Coulissante 2VTX " + "\n - Accessoires :" + " ".join(
                    (tmss + " " + dvs + " " + btr + " " + oscillo + " " +
                     v_et_v + " " + ctr + " " + lq + " " + trgl + " " +
                     serrure + " ").split()) + vitre + " ".join(
                         (simple_double + deco + " " + rempli + " " +
                          mstqr).split()) + " \n"

            if types == 'Coulissante 1VTL':
                serrure = ''
                if serr.name is not None:
                    if moustiquaire:
                        serrure = u' 2 serrures encastrées 2 points'
                    else:
                        serrure = u' 1 poignée 4 points à  clef'
                else:
                    if moustiquaire:
                        serrure = u' 2 serrures encastrées 2 points'
                    else:
                        serrure = u' 1 poignée 2 points'
                types = u"Porte Coulissante 1VTL " + "\n - Accessoires :" + " ".join(
                    (tmss + " " + dvs + " " + btr + " " + oscillo + " " +
                     v_et_v + " " + ctr + " " + lq + " " + trgl + " " +
                     serrure + " ").split()) + vitre + " ".join(
                         (simple_double + deco + " " + rempli + " " +
                          mstqr).split()) + " \n"
        if types == 'Glandage':
            types = "Glandage" + "\n"
            if types == 'Coulissante 3VTX':
                serrure = ''
                if tms != 0.0:
                    type_porte = 'Porte'
                if serr.name is not None:
                    if moustiquaire:
                        serrure = u' 2 serrures encastrées 2 points'
                    else:
                        serrure = u' 1 poignée 4 points à  clef et 1 serrure encastrée 2 point'
                else:
                    if moustiquaire:
                        serrure = u' 2 serrures encastrées 2 points'
                    else:
                        serrure = u' 1 poignée et 1 serrures encastrées 2 points'
                types = u" " + type_porte + " Coulissante 3VTX " + "\n - Accessoires :" + " ".join(
                    (tmss + " " + dvs + " " + btr + " " + oscillo + " " +
                     v_et_v + " " + ctr + " " + lq + " " + trgl + " " +
                     serrure + " ").split()) + vitre + " ".join(
                         (simple_double + deco + " " + rempli + " " +
                          mstqr).split()) + " \n"
            if types == 'Coulissante 4VTX':
                serrure = ''
                if tms != 0.0:
                    type_porte = 'Porte'
                if serr.name is not None:
                    if moustiquaire:
                        serrure = u' 3 serrures encastrées 2 points'
                    else:
                        serrure = u' 1 poignée 4 points à  clef'
                else:
                    if moustiquaire:
                        serrure = u' 3 serrures encastrées 2 points'
                    else:
                        serrure = u' 1 poignée et 2 serrures encastrées 2 points'
                types = u" " + type_porte + " Coulissante 4VTX " + "\n - Accessoires :" + " ".join(
                    (tmss + " " + dvs + " " + btr + " " + oscillo + " " +
                     v_et_v + " " + ctr + " " + lq + " " + trgl + " " +
                     serrure + " ").split()) + vitre + " ".join(
                         (simple_double + deco + " " + rempli + " " +
                          mstqr).split()) + " \n"
            if types == 'Porte ouvrante 1VTL':
                types = u" Porte ouvrante 1VTL " + "\n - Accessoires :" + " ".join(
                    (tmss + " " + intermdr + " " + dvs + " " + btr + " " +
                     oscillo + " " + v_et_v + " " + ctr + " " + lq + " " +
                     trgl + " ").split()) + vitre + " ".join(
                         (simple_double + deco + " " + rempli + " " +
                          mstqr).split()) + " \n"
        if types == u'Fenêtre ouvrante 1VTL':
            types = u" Fenêtre ouvrante 1VTL  " + "\n - Accessoires :" + " ".join(
                (tmss + " " + dvs + " " + btr + " " + oscillo + " " + v_et_v +
                 " " + ctr + " " + lq + " " + trgl +
                 " ").split()) + vitre + " ".join(
                     (simple_double + deco + " " + rempli + " " +
                      mstqr).split()) + " \n"
            if types == 'Porte ouvrante 2VTX':
                types = u" Porte ouvrante 2VTX  " + "\n - Accessoires :" + " ".join(
                    (inegalit + " " + tmss + " " + dvs + " " + btr + " " +
                     oscillo + " " + v_et_v + " " + ctr + " " + lq + " " +
                     trgl + " ").split()) + vitre + " ".join(
                         (simple_double + deco + " " + rempli + " " +
                          mstqr).split()) + " \n"
            if types == u'Fenêtre ouvrante 2VTX':
                types = u" Fenêtre ouvrante 2VTX  " + "\n - Accessoires :" + " ".join(
                    (tmss + " " + dvs + " " + btr + " " + oscillo + " " +
                     v_et_v + " " + ctr + " " + lq + " " + trgl +
                     " ").split()) + vitre + " ".join(
                         (simple_double + deco + " " + rempli + " " +
                          mstqr).split()) + " \n"

        if types == 'A soufflet':
            types = u" A soufflet  " + "\n - Accessoires :" + " ".join(
                (tmss + " " + dvs + " " + btr + " " + oscillo + " " + v_et_v +
                 " " + ctr + " " + lq + " " + trgl +
                 " ").split()) + vitre + " ".join(
                     (simple_double + deco + " " + rempli + " " +
                      mstqr).split()) + " \n"
            if types == 'Fixe':
                if type_fix:
                    if type_fix == 'imposte':
                        types = "Imposte Fixe" + "\n - Accessoires :" + " ".join(
                            (tmss + " " + dvs + " " + btr + " " + oscillo +
                             " " + v_et_v + " " + ctr + " " + lq + " " + trgl +
                             " ").split()) + vitre + " ".join(
                                 (simple_double + deco + " " + rempli + " " +
                                  mstqr).split()) + " \n"
                    if type_fix == 'soubassement':
                        types = "Soubassement Fixe" + "\n - Accessoires :" + " ".join(
                            (tmss + " " + dvs + " " + btr + " " + oscillo +
                             " " + v_et_v + " " + ctr + " " + lq + " " + trgl +
                             " ").split()) + vitre + " ".join(
                                 (simple_double + deco + " " + rempli + " " +
                                  mstqr).split()) + " \n"
                    if type_fix == 'lateral':
                        types = u"Latéral Fixe" + "\n - Accessoires :" + " ".join(
                            (tmss + " " + dvs + " " + btr + " " + oscillo +
                             " " + v_et_v + " " + ctr + " " + lq + " " + trgl +
                             " ").split()) + vitre + " ".join(
                                 (simple_double + deco + " " + rempli + " " +
                                  mstqr).split()) + " \n"
                else:
                    types = u"Fixe" + "\n"
                    if types == 'Moustiquaire':
                        types = u"Moustiquaire indépendant" + "\n"
                    if types == 'Naco':
                        types = u"Naco" + "\n - Accessoires :" + " ".join(
                            (tmss + " " + dvs + " " + btr + " " + oscillo +
                             " " + v_et_v + " " + ctr + " " + lq + " " + trgl +
                             " ").split()) + vitre + " ".join(
                                 (simple_double + deco + " " + rempli + " " +
                                  mstqr).split()) + " \n"
                    if types == 'Poteau rectangle' or 'Poteau d\'angle' or 'Tendeur':

                        if types == 'Poteau rectangle':
                            types = "Poteau rectangle" + "\n"
                        if types == 'Poteau d\'angle':
                            types = "Poteau d'angle" + "\n"
                        if types == "Tendeur":
                            types = "Tendeur" + "\n"
                        if types == 'Bardage PVC':
                            types = "Bardage PVC" + "\n"

                        if types == 'Projetant':
                            types = "Projetant" + "\n"

        lxh = types
        if types == 'Poteau rectangle':
            if (rec_dimension and rec_pu_ttc):
                lxh = lxh + " \n\t - Dimension : %d x %d \n" % (
                    rec_dimension,
                    rec_pu_ttc,
                )
        else:
            if (rec_largeur and rec_hauteur):
                lxh = lxh + "- Dimension : %d x %d HT \n" % (
                    rec_largeur,
                    rec_hauteur,
                )
        #i = 0
        #product_obj = self.pool.get('product.product')
        #product_ids = product_obj.search(cr, uid, [('type','=',type)])
        #for prod in product_obj.browse(cr, uid, ids, context=context):

        #raise osv.except_osv('Error!','Please define sales journal for this company: "%s" .' % (product_ids))

        name = lxh

        res_image = tools.image_resize_image(image, (64, 64), 'base64', 'PNG',
                                             False)
        sale_order_line_obj.create({
            'product_id': select_type.id,
            'name': name,
            'order_id': rec_ref,
            'product_uom_qty': rec_qty,
            'price_subtotal': total['totalcacher'],
            'price_unit': total['totalcacher'] / rec_qty,
            'image': res_image
        })
        return True
 def resize_signature(self):
     if self.user_signature:
         self.resized_user_signature = image_resize_image(self.user_signature, size=(100, 50))
Beispiel #34
0
 def _resize(self, image, size_x, size_y):
     return image_resize_image(image.datas, size=(size_x, size_y))
Beispiel #35
0
 def _website_logo(self):
     for website in self:
         website.website_logo = tools.image_resize_image(
             website.website_filter_id.image, (180, None))
Beispiel #36
0
 def resize_to_48(b64source):
     if not b64source:
         b64source = base64.b64encode(Binary().placeholder())
     return image_resize_image(b64source, size=(48, 48))
Beispiel #37
0
 def resize_to_48(b64source):
     if not b64source:
         b64source = base64.b64encode(Binary().placeholder())
     return image_resize_image(b64source, size=(48, 48))
 def _resize_thumbnail(self, image, crop=True):
     data = crop_image(image, type='center', size=(256, 256), ratio=(1, 1)) if crop else image
     return image_resize_image(base64_source=data, size=(256, 256), encoding='base64')
Beispiel #39
0
 def write(self, vals):
     if 'image' in vals:
        vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30))
        vals['image'] = image_resize_image(vals['image'], size=(64,64))
     return super(PaymentIcon, self).write(vals)