[IMP] web: allow caching get_fonts calls in NameAndSignature
In sign many NameAndSignature widgets are opened and closed since it is expected that documents have multiple initial/signature fields. Everytime the widget is opened, an rpc call to get_fonts is done, even if the request has already been done before. This commit prevents this rpc call if the fonts are already loaded. task-2735814 closes odoo/odoo#83208 Related: odoo/enterprise#23653 Signed-off-by: Arnaud Joset <arj@odoo.com>
This commit is contained in:
@@ -84,11 +84,17 @@ var NameAndSignature = Widget.extend({
|
||||
* @override
|
||||
*/
|
||||
willStart: function () {
|
||||
var self = this;
|
||||
/** LPR: in sign module, the web/sign/get_fonts call is cached since
|
||||
* many NameAndSignature widgets are created. This way, we prevent
|
||||
* doing the rpc call if it was already done inside sign
|
||||
*/
|
||||
if (this.fonts && this.fonts.length > 0) {
|
||||
return this._super.apply(this, arguments);
|
||||
}
|
||||
return Promise.all([
|
||||
this._super.apply(this, arguments),
|
||||
this._rpc({route: '/web/sign/get_fonts/' + self.defaultFont}).then(function (data) {
|
||||
self.fonts = data;
|
||||
this._rpc({route: '/web/sign/get_fonts/' + this.defaultFont}).then(data => {
|
||||
this.fonts = data;
|
||||
})
|
||||
]);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user