I'd like to automatically reload the page after I add an attachment in the sales form.
I can't find the method that adds attachments.
I use odoo 11.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I'd like to automatically reload the page after I add an attachment in the sales form.
I can't find the method that adds attachments.
I use odoo 11.
Hi,
Do you speak about the top entry 'attachments'?
If so, the js is placed in document/static/src/js/document.js. Here is the method '_onFileUploaded'. After that you can trigger reload of a form or of the whole window (the most generic is location.reload)
Thanks, that's what I'm looking for, but I can't make it work. Here's my javascript file:
odoo.define('mymodule.document', function (require){
"use strict";
var core = require('web.core');
var Dialog = require('web.Dialog');
var framework = require('web.framework');
var Sidebar = require('web.Sidebar');
var field_utils = require('web.field_utils');
var _t = core._t;
var document = require('document.document');
document.include({
_onFileUploaded: function () {
var attachments = Array.prototype.slice.call(arguments, 1);
var uploadErrors = _.filter(attachments, function (attachment) {
return attachment.error;
});
if (uploadErrors.length) {
this.do_warn(_t('Uploading Error'), uploadErrors[0].error);
}
this._updateAttachments().then(this._redraw.bind(this));
framework.unblockUI();
location.reload();
}
});
}
Hi, you should upgrade not document.document, but 'Sidebar' which is overwritten in 'document.document'. So, something like
Sidebar.include({
_onFileUploaded: function () {
this._super.apply(this, arguments);
window.location.reload();
});
});
and var Sidebar = require('document.Sidebar');
Unfortunately, this does not work. I think that this file is not even loaded because I added the line:
console.log('myfile.js');
And I don't see anything in the logs.
Have you imported it? https://www.odoo.yenthevg.com/adding-static-resources-css-and-javascript-to-odoo/
Yes, I imported it. Sorry but I forgot to tell you that I am getting a blank page when I login, I only get the full menu when I comment the line that imports the assets file in __manifest__.py or when I put in the address ba ?debug=assets.
1. Try to clean your browser cashe. 2. Turn on the browser to save logs. ('preserve logs' of console). 3. Look at logs. There must be some error which should be fixed
Yes, I imported it. Sorry but I forgot to tell you that I am getting a blank page when I login, I only get the full menu when I comment the line that imports the assets file in __manifest__.py or when I put in the address ba ?debug=assets.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Feb 24
|
1740 | ||
|
5
May 23
|
13461 | ||
|
1
Jan 24
|
12762 | ||
|
2
Dec 23
|
3122 | ||
|
1
May 22
|
992 |