Ejemplo n.º 1
0
 def _get_image(self, cr, uid, ids, name, args, context=None):
     result = dict.fromkeys(ids, False)
     for obj in self.browse(cr, uid, ids, context=context):
         return_dict = dict()
         return_dict['image_medium'] = tools.image_resize_image_medium(obj.image, size=(275, 145))
         result[obj.id] = return_dict
     return result
Ejemplo n.º 2
0
 def _compute_image(self):
     if self.image:
         self.image_small = tools.image_resize_image_small(self.image)
         self.image_medium = tools.image_resize_image_medium(self.image)
     else:
         self.image_small = False
         self.image_medium = False
Ejemplo n.º 3
0
 def write(self, vals):
     if vals.get('image'):
         vals.update({
             'image_medium':
             tools.image_resize_image_medium(vals.get('image'), (256, 128))
         })
     return super(StockWarehouseMain, self).write(vals)
Ejemplo n.º 4
0
    def create(self, cr, uid, values, context=None):
        if 'image_medium' in values and values['image_medium']:
            mediana = tools.image_resize_image_medium(values['image_medium'])
            values['image_medium'] = mediana
        # if 'unidades_originales' in values:
        #     values['unidades_actuales'] = values['unidades_originales']
        if 'user_id' in values and values['user_id']:
            values['estado_responsable'] = 'AC'
        asset_id = super(account_asset_asset, self).create(cr,
                                                           uid,
                                                           values,
                                                           context=context)
        # group_id = self._get_groups_by_category(cr, uid, asset_id, context)
        # res_users = self.pool['res.users']
        # user_ids = res_users.search(cr, uid, [('groups_id', 'in', group_id)], context=context)
        # partner_ids = list(set(u.partner_id.id for u in res_users.browse(cr, SUPERUSER_ID, user_ids, context=context)))
        partner_ids = self._get_partners_notification(cr,
                                                      uid,
                                                      asset_id,
                                                      context=context)
        body = "Se ha creado un activo fijo, favor de ingresar los datos adicionales que\
                corresponden para que el mismo pueda ser dado de alta en el sistema"

        self.message_post(cr,
                          uid, [asset_id],
                          body=body,
                          partner_ids=partner_ids,
                          context=context)
        return asset_id
Ejemplo n.º 5
0
 def _compute_image(self):
     if self.image:
         self.image_small = tools.image_resize_image_small(self.image)
         self.image_medium = tools.image_resize_image_medium(self.image)
     else:
         self.image_small = False
         self.image_medium = False
Ejemplo n.º 6
0
 def _get_image(self, cr, uid, ids, name, args, context=None):
     result = dict.fromkeys(ids, False)
     for obj in self.browse(cr, uid, ids, context=context):
         return_dict = dict()
         return_dict['image_medium'] = tools.image_resize_image_medium(
             obj.image, size=(275, 145))
         result[obj.id] = return_dict
     return result
Ejemplo n.º 7
0
 def _resize_image_generic(self):
     for image in self:
         try:
             image_64 = image.read().encode('base64')
             self.image_generic_medium = tools.image_resize_image_medium(image_64)
             self.image_generic_small = tools.image_resize_image_small(image_64)
         except binascii.Error:
             print "no correct base64"
Ejemplo n.º 8
0
    def write(self, cr, uid, ids, values, context=None):
        if 'image_medium' in values and values['image_medium']:
            mediana = tools.image_resize_image_medium(values['image_medium'])
            values['image_medium'] = mediana
        # if 'unidades_originales' in values:
        #     values['unidades_actuales'] = values['unidades_originales']

        #TODO: Se debe revisar el tema que este procedimiento se está haciendo comparando solo con el primer valor
        if 'user_id' in values:
            # si estado responsable esta seteado, pregunto por el primero
            if len(ids) > 0 and self.browse(cr, uid, ids[0],
                                            context).estado_responsable:
                values['estado_responsable'] = 'EP'
            # al primero se lo marca como aceptado
            else:
                values['estado_responsable'] = 'AC'
        #---------------------------------------------------------------------------------------------------------
        #Llamado a super
        res = super(account_asset_asset, self).write(cr,
                                                     uid,
                                                     ids,
                                                     values,
                                                     context=context)
        if 'user_id' in values:
            for activo in self.browse(cr, uid, ids, context=context):
                valores = {
                    'department_id': activo.department_id.id,
                    'user_id': activo.user_id.id,
                    'estado_responsable': 'EP',
                    'hist_resp_id': activo.id,
                }
                self.pool.get('grp.historial_responsable').create(
                    cr, uid, valores, context=context)
                if activo.state == 'open' and activo.estado_responsable == 'EP':
                    if activo.user_id:
                        body = "Tiene un activo asignado para aceptar."
                        self.message_post(
                            cr,
                            uid,
                            ids,
                            type="notification",
                            subtype='mt_comment',
                            body=body,
                            partner_ids=[activo.user_id.partner_id.id],
                            context=context)
        elif 'department_id' in values:
            for activo in self.browse(cr, uid, ids, context=context):
                self.pool.get('grp.historial_responsable').create(
                    cr,
                    uid, {
                        'department_id': activo.department_id.id,
                        'user_id': activo.user_id.id,
                        'estado_responsable': 'AC',
                        'hist_resp_id': activo.id,
                    },
                    context=context)
        return res
Ejemplo n.º 9
0
 def _get_image_sizes(self):
     for s in self:
         try:
             image = s.with_context(bin_size=False).image_main
             vals = dict()
             vals["image_medium"] = tools.image_resize_image_medium(
                 image, size=(300, 300))
             vals["image_small"] = tools.image_resize_image_small(image)
         except:
             vals = {"image_medium": False, "image_small": False}
         s.update(vals)
Ejemplo n.º 10
0
    def _save_file(self, path, b64_file):
        """Save a file encoded in base 64"""
        self._check_filestore(path)
        name, extention = os.path.splitext(path)
        with open(path, "w") as ofile:
            resize = tools.image_resize_image_medium(b64_file, size=(200, 150))
            ofile.write(base64.b64decode(resize))

        path_small = name + "small" + extention
        with open(path_small, "w") as ofile:
            resize_small = tools.image_resize_image_small(b64_file, size=(100, 75))
            ofile.write(base64.b64decode(resize_small))
        path_medium = name + "medium" + extention
        with open(path_medium, "w") as ofile:
            resize_medium = tools.image_resize_image_medium(b64_file, size=(600, 450))
            ofile.write(base64.b64decode(resize_medium))
        path_big = name + "big" + extention
        with open(path_big, "w") as ofile:
            resize_big = tools.image_resize_image_big(b64_file, size=(800, 600))
            ofile.write(base64.b64decode(resize_big))
        return True
Ejemplo n.º 11
0
    def _save_file(self, path, b64_file):
        """Save a file encoded in base 64"""
        self._check_filestore(path)
        name, extention = os.path.splitext(path)
        with open(path, 'w') as ofile:
            resize = tools.image_resize_image_medium(b64_file, size=(200, 150))
            ofile.write(base64.b64decode(resize))

        path_small = name + 'small' + extention
        with open(path_small, 'w') as ofile:
            resize_small = tools.image_resize_image_small(b64_file,
                                                          size=(100, 75))
            ofile.write(base64.b64decode(resize_small))
        path_medium = name + 'medium' + extention
        with open(path_medium, 'w') as ofile:
            resize_medium = tools.image_resize_image_medium(b64_file,
                                                            size=(600, 450))
            ofile.write(base64.b64decode(resize_medium))
        path_big = name + 'big' + extention
        with open(path_big, 'w') as ofile:
            resize_big = tools.image_resize_image_big(b64_file,
                                                      size=(800, 600))
            ofile.write(base64.b64decode(resize_big))
        return True
Ejemplo n.º 12
0
 def _get_image(self):
     for record in self:
         record.image_medium = tools.image_resize_image_medium(record.image)
Ejemplo n.º 13
0
 def _compute_aadhar_images(self):
     for rec in self:
         rec.x_aadhar_image_medium = tools.image_resize_image_medium(
             rec.x_aadhar_id_image)
Ejemplo n.º 14
0
 def write(self, values):
     if values.get('image_medium'):
         mediana = tools.image_resize_image_medium(values.get('image_medium'))
         values.update({'image_medium': mediana})
     return super(CuerpoTecnico, self).write(values)
Ejemplo n.º 15
0
 def _compute_images(self):
     for rec in self:
         rec.image_xlarge = tools.image_resize_image_big(rec.image)
         rec.image_large = tools.image_resize_image(rec.image, (384, 384),
                                                    'base64', None, True)
         rec.image_medium = tools.image_resize_image_medium(rec.image)
Ejemplo n.º 16
0
 def _compute_images(self):
     for record in self:
         record.image_medium = tools.image_resize_image_medium(record.image)
Ejemplo n.º 17
0
 def _compute_isometric(self):
     for rec in self:
         rec.isometric_medium = tools.image_resize_image_medium(
             rec.isometric, avoid_if_small=True)
         rec.isometric_small = tools.image_resize_image_small(rec.isometric)
Ejemplo n.º 18
0
 def _get_image(self):
     self.image_medium = tools.image_resize_image_medium(self.image)
     self.image_small = tools.image_resize_image_small(self.image)
Ejemplo n.º 19
0
 def _compute_image_medium(self):
     self.image_medium = tools.image_resize_image_medium(self.image)
Ejemplo n.º 20
0
 def create(self, values):
     if values.get('image_medium'):
         mediana = tools.image_resize_image_medium(values.get('image_medium'))
         values.update({'image_medium': mediana})
     return super(Jugador, self).create(values)
Ejemplo n.º 21
0
    def _get_default_generic_image_medium(self, colorize=False):
        image = open(get_module_resource('tcd_website','static/img', 'sails.png')).read()

        return tools.image_resize_image_medium(image.encode('base64'))
Ejemplo n.º 22
0
 def get_payslip_signature(self, cr, uid, ids, context=None):
     """ returns lower resolution image for widget to limit place usage """
     signature = self.get_payslip_signature_big(cr, uid, ids, context=context)
     signature = tools.image_resize_image_medium(signature, avoid_if_small=True)
     return signature
Ejemplo n.º 23
0
 def _get_image(self):
     self.image_medium = tools.image_resize_image_medium(self.image)
     self.image_small = tools.image_resize_image_small(self.image)
Ejemplo n.º 24
0
    def companyweb_information(self, cr, uid, ids, vat_number, context=None):
        login = self.pool.get('ir.config_parameter').get_param(
            cr, uid, 'companyweb.login', False)
        pswd = self.pool.get('ir.config_parameter').get_param(
            cr, uid, 'companyweb.pswd', False)
        url = "http://odm.outcome.be/alacarte_onvat.asp?login="******"&pswd=" + pswd + "&vat=" + vat_number

        if context.get('lang', '').startswith('fr'):
            url = url + "&lang=1"
        elif context.get('lang', '').startswith('nl'):
            url = url + "&lang=2"

        try:
            tree = etree.parse(url)
        except:
            logging.error("Error parsing companyweb url %s", url,
                          exc_info=True)
            raise orm.except_orm('Warning !',
                                 "System error loading Companyweb data.\n"
                                 "Please retry and contact your "
                                 "system administrator if the error persists.")

        message = tree.xpath("/Companies")[0].get("Message")
        if message:
            raise orm.except_orm('Warning !',
                                 "Error loading Companyweb data:\n%s.\n"
                                 "\n"
                                 "Please check your credentials in settings/"
                                 "configuration/Companyweb.\n"
                                 "\n"
                                 "Login on www.companyweb.be with login "
                                 "'cwacsone' and password 'demo' "
                                 "to obtain test credentials." % message)

        if tree.xpath("/Companies")[0].get("Count") == "0":
            raise orm.except_orm(
                'Warning !', "VAT number of this company is not known in the "
                "Companyweb database")

        firm = tree.xpath("/Companies/firm")

        startDate = firm[0].xpath("StartDate")[0].text
        endDate = firm[0].xpath("EndDate")[0].text
        if endDate == "0":
            endDate = False
            endOfActivity = False
        else:
            endOfActivity = True

        warningstxt = ""
        for warning in firm[0].xpath("Warnings/Warning"):
            warningstxt = warningstxt + "- " + warning.text + "\n"

        if endOfActivity:
            fichier = "barometer_stop.png"
            im = urllib.urlopen(
                'http://www.companyweb.be/img/barometer/' + fichier)
            source = im.read()
        elif len(firm[0].xpath("Score")) > 0:
            score = firm[0].xpath("Score")[0].text
            if score[0] == '-':
                signe = "neg-"
                if len(score) == 2:
                    chiffre = "0" + score[1:]
                else:
                    chiffre = score[1:]
            else:
                signe = "pos-"
                if len(score) == 1:
                    chiffre = "0" + score[0:]
                else:
                    chiffre = score[0:]

            fichier = signe + chiffre + ".png"
            im = urllib.urlopen(
                'http://www.companyweb.be/img/barometer/' + fichier)
            source = im.read()
        else:
            fichier = "barometer_none.png"
            img_path = openerp.modules.get_module_resource(
                'account_companyweb', 'images/barometer', fichier)
            with open(img_path, 'rb') as f:
                source = f.read()

        image = tools.image_resize_image_medium(source.encode('base64'))

        dicoRoot = dict()
        for Element in firm[0]:
            dicoRoot[Element.tag] = Element.text
        balance_year = ""
        if len(firm[0].xpath("Balans/Year")) > 0:
            balance_year = firm[0].xpath("Balans/Year")[0].get("value")
            for Element2 in firm[0].xpath("Balans/Year")[0]:
                if Element2.text:
                    dicoRoot[Element2.tag] = Element2.text

        def getValue(attr):
            return dicoRoot.get(attr, 'N/A')

        def getFloatValue(attr):
            r = dicoRoot.get(attr)
            if r:
                return float(r)
            else:
                return False

        valeur = {
            'name': getValue('Name'),
            'jur_form': getValue('JurForm'),
            'vat_number': "BE0" + getValue('Vat'),
            'street': getValue('Street') + ", " + getValue('Nr'),
            'zip': getValue('PostalCode'),
            'city': getValue('City'),
            'creditLimit': getFloatValue('CreditLimit'),
            'startDate': startDate,
            'endDate': endDate,
            'image': image,
            'warnings': warningstxt,
            'url': dicoRoot['Report'],
            'vat_liable': getValue('VATenabled') == "True",
            'balance_year': balance_year,
            'equityCapital': getFloatValue('Rub10_15'),
            'addedValue': getFloatValue('Rub9800'),
            'turnover': getFloatValue('Rub70'),
            'result': getFloatValue('Rub9904'),
        }

        wizard_id = self.pool.get('account.companyweb.wizard').create(
            cr, uid, valeur, context=None)

        return {
            'name': "Companyweb Informations",
            'view_mode': 'form',
            'view_id': False,
            'view_type': 'form',
            'res_model': 'account.companyweb.wizard',
            'res_id': wizard_id,
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'new',
            'domain': '[]',
            'context': context,
        }
Ejemplo n.º 25
0
 def _compute_images(self):
     for rec in self:
         rec.image_medium = tools.image_resize_image_medium(rec.image)
         rec.image_small = tools.image_resize_image_small(rec.image)
Ejemplo n.º 26
0
    def companyweb_information(self, cr, uid, ids, vat_number, context=None):
        login = self.pool['ir.config_parameter'].get_param(
            cr, uid, 'companyweb.login', False)
        pswd = self.pool['ir.config_parameter'].get_param(
            cr, uid, 'companyweb.pswd', False)
        url = "http://odm.outcome.be/alacarte_onvat.asp?login="******"&pswd=" + pswd + "&vat=" + vat_number

        if context.get('lang', '').startswith('fr'):
            url = url + "&lang=1"
        elif context.get('lang', '').startswith('nl'):
            url = url + "&lang=2"

        try:
            p = etree.XMLParser(no_network=False)
            tree = etree.parse(url, parser=p)
        except:
            logging.error("Error parsing companyweb url %s",
                          url,
                          exc_info=True)
            raise orm.except_orm(
                'Warning !', "System error loading Companyweb data.\n"
                "Please retry and contact your "
                "system administrator if the error persists.")

        message = tree.xpath("/Companies")[0].get("Message")
        if message:
            raise orm.except_orm(
                'Warning !', "Error loading Companyweb data:\n%s.\n"
                "\n"
                "Please check your credentials in settings/"
                "configuration/Companyweb.\n"
                "\n"
                "Login on www.companyweb.be with login "
                "'cwacsone' and password 'demo' "
                "to obtain test credentials." % message)

        if tree.xpath("/Companies")[0].get("Count") == "0":
            raise orm.except_orm(
                'Warning !', "VAT number of this company is not known in the "
                "Companyweb database")

        firm = tree.xpath("/Companies/firm")

        startDate = firm[0].xpath("StartDate")[0].text
        endDate = firm[0].xpath("EndDate")[0].text
        if endDate == "0":
            endDate = False
            endOfActivity = False
        else:
            endOfActivity = True

        warningstxt = ""
        for warning in firm[0].xpath("Warnings/Warning"):
            warningstxt = warningstxt + "- " + warning.text + "\n"

        if endOfActivity:
            fichier = "barometer_stop.png"
            im = urllib.urlopen('http://www.companyweb.be/img/barometer/' +
                                fichier)
            source = im.read()
        elif len(firm[0].xpath("Score")) > 0:
            score = firm[0].xpath("Score")[0].text
            if score[0] == '-':
                signe = "neg-"
                if len(score) == 2:
                    chiffre = "0" + score[1:]
                else:
                    chiffre = score[1:]
            else:
                signe = "pos-"
                if len(score) == 1:
                    chiffre = "0" + score[0:]
                else:
                    chiffre = score[0:]

            fichier = signe + chiffre + ".png"
            im = urllib.urlopen('http://www.companyweb.be/img/barometer/' +
                                fichier)
            source = im.read()
        else:
            fichier = "barometer_none.png"
            img_path = openerp.modules.get_module_resource(
                'account_companyweb', 'images/barometer', fichier)
            with open(img_path, 'rb') as f:
                source = f.read()

        image = tools.image_resize_image_medium(source.encode('base64'))

        dicoRoot = dict()
        for Element in firm[0]:
            dicoRoot[Element.tag] = Element.text
        balance_year = ""
        if len(firm[0].xpath("Balans/Year")) > 0:
            balance_year = firm[0].xpath("Balans/Year")[0].get("value")
            for Element2 in firm[0].xpath("Balans/Year")[0]:
                if Element2.text:
                    dicoRoot[Element2.tag] = Element2.text

        def getValue(attr):
            return dicoRoot.get(attr, 'N/A')

        def getFloatValue(attr):
            r = dicoRoot.get(attr)
            if r:
                return float(r)
            else:
                return False

        valeur = {
            'name': getValue('Name'),
            'jur_form': getValue('JurForm'),
            'vat_number': "BE0" + getValue('Vat'),
            'street': getValue('Street') + ", " + getValue('Nr'),
            'zip': getValue('PostalCode'),
            'city': getValue('City'),
            'creditLimit': getFloatValue('CreditLimit'),
            'startDate': startDate,
            'endDate': endDate,
            'image': image,
            'warnings': warningstxt,
            'url': dicoRoot['Report'],
            'vat_liable': getValue('VATenabled') == "True",
            'balance_year': balance_year,
            'equityCapital': getFloatValue('Rub10_15'),
            'addedValue': getFloatValue('Rub9800'),
            'turnover': getFloatValue('Rub70'),
            'result': getFloatValue('Rub9904'),
        }

        wizard_id = self.pool['account.companyweb.wizard'].create(cr,
                                                                  uid,
                                                                  valeur,
                                                                  context=None)

        return {
            'name': "Companyweb Informations",
            'view_mode': 'form',
            'view_id': False,
            'view_type': 'form',
            'res_model': 'account.companyweb.wizard',
            'res_id': wizard_id,
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'new',
            'domain': '[]',
            'context': context,
        }
Ejemplo n.º 27
0
 def _compute_images(self):
     for rec in self:
         rec.image_medium = tools.image_resize_image_medium(rec.image)
         rec.image_small = tools.image_resize_image_small(rec.image)
Ejemplo n.º 28
0
 def _compute_image_medium(self):
     self.image_medium = tools.image_resize_image_medium(self.image)