odoo.define("hotel_reservation.hotel_room_summary", function (require) {
"use strict";
var core = require("web.core");
var registry = require("web.field_registry");
var basicFields = require("web.basic_fields");
var FieldText = basicFields.FieldText;
var QWeb = core.qweb;
var FormView = require("web.FormView");
var py = window.py;
var MyWidget = FieldText.extend({
events: _.extend({}, FieldText.prototype.events, {
change: "_onFieldChanged",
}),
init: function () {
this._super.apply(this, arguments);
if (this.mode === "edit") {
this.tagName = "span";
}
this.set({
date_to: false,
date_from: false,
summary_header: false,
room_summary: false,
});
this.set({
summary_header: py.eval(this.recordData.summary_header),
});
this.set({
room_summary: py.eval(this.recordData.room_summary),
});
},
start: function () {
var self = this;
if (self.setting) {
return;
}
if (!this.get("summary_header") || !this.get("room_summary")) {
return;
}
this.renderElement();
this.view_loading();
},
initialize_field: function () {
FormView.ReinitializeWidgetMixin.initialize_field.call(this);
var self = this;
self.on("change:summary_header", self, self.start);
self.on("change:room_summary", self, self.start);
},
view_loading: function (r) {
return this.load_form(r);
},
load_form: function () {
var self = this;
this.$el.find(".table_free").bind("click", function () {
self.do_action({
type: "ir.actions.act_window",
res_model: "quick.room.reservation",
views: [[false, "form"]],
target: "new",
context: {
room_id: $(this).attr("data"),
date: $(this).attr("date"),
default_adults: 1,
},
});
});
},
renderElement: function () {
this._super();
this.$el.html(
QWeb.render("RoomSummary", {
widget: this,
})
);
},
_onFieldChanged: function (event) {
this._super();
this.lastChangeEvent = event;
this.set({
summary_header: py.eval(this.recordData.summary_header),
});
this.set({
room_summary: py.eval(this.recordData.room_summary),
});
this.renderElement();
this.view_loading();
},
});
registry.add("Room_Reservation", MyWidget);
return MyWidget;
});
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilitat
- Inventari
- PoS
- Project
- MRP
This question has been flagged
1329
Vistes
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-seRelated Posts | Respostes | Vistes | Activitat | |
---|---|---|---|---|
|
1
de set. 19
|
2172 | ||
|
5
d’ag. 25
|
1326 | ||
|
1
de febr. 25
|
12235 | ||
|
0
de nov. 24
|
1145 | ||
|
0
d’oct. 23
|
102 |