//-------------------------------------------------------------------basic_fields.js
init: function () { this._setCurrency();
//-------------------------------------------------------------------
_setCurrency: function () { var currencyField = this.nodeOptions.currency_field || this.field.currency_field || ‘currency_id‘; var currencyID = this.record.data[currencyField] && this.record.data[currencyField].res_id; this.currency = session.get_currency(currencyID); this.formatOptions.currency = this.currency;
//-------------------------------------------------------------------core/session.js
get_currency: function (currency_id) { return this.currencies[currency_id];},
//-------------------------------------------------------------------service/session.js
odoo.define(‘web.session‘, function (require) {"use strict"; var Session = require(‘web.Session‘); var modules = odoo._modules; var session = new Session(undefined, undefined, {modules: modules, use_cors: false}); session.is_bound = session.session_bind(); return session; });
//-------------------------------------------------------------------在session_bind()中调用this.session_init() 在this.session_init()中调用this.session_reload()
session_reload: function () { var result = _.extend({}, window.odoo.session_info); delete result.session_id; _.extend(this, result); return $.when();} 在运行到session_reload时session_info中已经拿到了res_currency的币种信息 wfk!!!再往底层就搞不明时什么意思了:window.odoo是什么玩意?window 又是什么?
interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch, WindowOrWorkerGlobalScope, WindowEventHandlers {
//-------------------------------------------------------------------
原文地址:https://www.cnblogs.com/yanhuaqiang/p/11708509.html
时间: 2024-10-23 01:58:43