Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Resize client upload web/static/src /js/fields/relational_fields.js (Odoo 11)

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
3562 Vistas
Avatar
Edwin valdez

Hi, modifying the web base file web/static/src /js/fields/relational_fields.js
I am resizing the images on the client side using the many2many_binary widget managed to modify it but it has problems since when it selected 10 images for example it only shows me 8 images that were uploaded to the analysis in the console it shows me that 10 images were loaded but it shows less I think it is not possible to climb due to lack of time I hope you can help me thanks.

_onFileChanged: function (ev) {
var self = this;
var files = ev.target.files;
var attachment_ids = this.value.res_ids;


// Don't create an attachment if the upload window is cancelled.
if(files.length === 0)
return;

var dataurl=null;
var filesnew=[];
var filesname=[];
var finaliza=false;
var conteo=0;
_.each(files, function (file) {

var record = _.find(self.value.data, function (attachment) {
return attachment.data.name === file.name;
});
if (record) {
var metadata = self.metadata[record.id];
if (!metadata || metadata.allowUnlink) {
// there is a existing attachment with the same name so we
// replace it
attachment_ids = _.without(attachment_ids, record.res_id);
self._rpc({
model: 'ir.attachment',
method: 'unlink',
args: [record.res_id],
});
}
}
if (file.type.match('image.*')) {
var MAX_WIDTH = 800;
var MAX_HEIGHT = 600;
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function(e) {
var img = new Image();

img.src = e.target.result;
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
img.onload = function(){
var height = img.height;
var width = img.width;
ctx.drawImage(img, 0, 0);

if (width > MAX_WIDTH || height> MAX_HEIGHT ) {
if (width > MAX_WIDTH) {
var scaleFactor = MAX_WIDTH / width;
width = MAX_WIDTH;
height = height * scaleFactor;

} else if (height > MAX_HEIGHT) {
var scaleFactor = MAX_HEIGHT / height;
height = MAX_HEIGHT;
width = width * scaleFactor;

}
canvas.width = width;
canvas.height = height;
ctx.drawImage(img, 0, 0, width, height);


}
dataurl = canvas.toDataURL(file.type);
console.log("cantidad archivos");
console.log(files.length);
file.src = dataurl;
filesnew.push(dataurl);
filesname.push(file.name);

conteo++;

if(files.length == conteo){
finaliza=true;

}


};//fin onload image
};//fin onload reader
} else { //onload image type
conteo++;
}
self.uploadingFiles.push(file);
});
this._setValue({
operation: 'REPLACE_WITH',
ids: attachment_ids,
});


var thiss=this;
var interv = setInterval(function(){
console.log(finaliza);
console.log("SET INTERVAL");
if(finaliza){
console.log(files.length);
for(var i=0;i<filesnew.length;i++){
console.log(filesnew.src);
console.log("llama a upload");
uploadFile(filesnew[i],thiss.fileupload_id,thiss.model,filesname[i]);
}
finaliza=false;
console.log("FINALIZA");
thiss.$('.oe_fileupload').hide();
ev.target.value = "";
clearInterval(interv);
}
},3000);

function uploadFile (imagen,fileupload_id,model,name) {
console.log("ENTRA A UPLOAD");
var nombreIframe=fileupload_id;
fetch(imagen).then(res => res.blob()).then(blob => {

var xhr = new XMLHttpRequest();
xhr.open('POST', '/web/binary/upload_attachment', true);

// define new form
var formData = new FormData();
formData.append('ufile', blob,name);
formData.append('csrf_token', core.csrf_token);
formData.append('callback',nombreIframe);
formData.append('model',model);
formData.append('id','0');
// action after uploading happens
xhr.onload = function(e) {
console.log("File uploading completed! ");

var regex = new RegExp("\"", "g");
var textojavascript=(xhr.responseText.toString().replace(regex,"'").replace("<script language='javascript' type='text/javascript'>",'').replace('</script>',''));
var html = '<html><head></head><body></body></html>';


var eScript = document.createElement("script");
var script = document.createTextNode(textojavascript);
eScript.appendChild(script);

var eHead = document.createElement("head");
eHead.appendChild(eScript);


var iframe=document.getElementById(nombreIframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(html);
iframe.contentWindow.document.close();
//document.body.appendChild(iframe);

//document.getElementById("oe_fileupload_temp43").contentWindow.document.write(eHead);
var doc = iframe.contentWindow.document.head;
doc.append(eHead);
//document.getElementById("oe_fileupload_temp43")=eIframe;
};
// do the uploading
xhr.send(formData);
xhr.onreadystatechange = (e) => {

}
});
}



0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now