I have defined a variable that gets updated, on my odoo 11 JS file but the value gets lost when I close the POS, I want to store this value in a very simple model, do any one know if this is possible?
this is my JS code, I want to store this value into a python model and access the value again if needed:
odoo.define('testing_global.pos', function (require) {
"use strict";
var globalCashierTotal = 0;
var screens = require('point_of_sale.screens');
var AlertPaymentScreenWidget = screens.PaymentScreenWidget.include({
validate_order: function(force_validation) {
var self = this;
var order = this.pos.get_order();
if (this.order_is_valid(force_validation)) {
this.finalize_validation();
}
if(order.is_paid_with_cash()){
globalCashierTotal += Number(order.get_total_with_tax())
}
if(globalCashierTotal >= 3000){
alert("Some alert");
}
rpc.query(
model: 'send.cash.data',
method: 'cash_data',
args: [ globalCashierTotal ]
)
alert(globalCashierTotal)
},
});
});
This is my python model:
from odoo import models, api
class SendCashData(models.Model):
_name = 'send.cash.data'
@api.model
def cash_data(self, pos_sale):
total_cash = 0
total_cash += pos_sale
return total_cash
The value that I want to store is globalCashierTotal. Thanks in advance.