Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
3552 Zobrazení
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
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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