Hello. I am trying to update a custom model, this is loaded when starting POS. But I want the records to update (maybe reload them?) when I press a button on the screen.
I tried to do it by calling python method
from action button with 'rpc.query' but that has not worked, I don't
know if there is any way to do it from javascript.
models.load_models({
model: 'citas',
fields: ['folio', 'name', 'paciente', 'fisio_id', 'date_only', 'status_general'],
domain: [['status_general', 'in', ['realizado','agendado']], ['date_only','=', today]],
loaded: function(self, citas){
self.citas = citas;
}
});
UPDATE:
I tried to return the updated ids from 'rpc.query' and filter the object this.pos.citas but when assigning the result to self.pos.citas. does not show any record, I do not understand why, because the object assigned to this.pos.citas has the same structure as the original
var citas_pos = this.pos.citas;
var citas_ = this.pos.citas;
rpc.query({
model: 'pos.order',
method: 'getCitasIdsActualizadas',
args: [],
}).then(function (citas_ids){
for (var i=0; i<citas_pos.length; i++){
if (citas_pos[i].id in citas_ids_update){
citas_updated.splice(1,0,citas_pos[i]); //remove id that is not in the updated list
}
}
});
this.pos.citas = citas_updated
return this.pos.citas;
// in python I have this method, it works fine
@api.model
def getCitasIdsActualizadas(self):
citas_agendadas_ids = self.env['citas'].search([('status_general', 'in', ['Agendada', 'Realizado', 'realizado', 'agendado'])]).ids
return citas_agendadas_ids
Please suggest any solution. Thanks