I am trying to send my data in the list to their fields so i can retrieve them into another screen in same module / project.
The list i am trying to send :
var vals = {
'token_number':Token,
'partner_id':customer_name,
'queue_line_ids':queue_lines,
}
where Token is random number generated on custom_button click,customer_name is the id of customer obtained by "this.pos.get_order().cid" and queuelines is array of product and their info obtained from orderlines.
The rpc.query
i wrote by referring to point_of_sale in odoo13/addon/ :
return rpc.query({
model: 'pos.queue',
method: 'create',
args: [vals],
}).then(function () {
console.log("Success")
}).catch(function (reason){
var error = reason.message;
console.log(error);
});
The pos.queue
in my module's model.py :
class POSOrderQueue(models.Model):
_name = 'pos.queue'
token_number = fields.Integer(string="Token Number", store=True)
partner_id = fields.Char(store=True)
pos_order_id = fields.Char(store=True)
order_progress = fields.Selection([('in_queue', 'In Queue'),
('in_progress', 'In Progress'),
('done', 'Done')], string="Order progress", default='inqueue', store=True)
no_items = fields.Integer(string='No of Items', store=True)
queue_line_ids = fields.One2many('pos.queue.line', 'queue_id')
def create(self):
val = {
"token_number": self.token_number,
"partner_id": self.partner_id,
"queue_line_ids": self.queue_line_ids,
}
self.env['pos.queue'].create(val)
Yes so i was finding solution to pass orderline data in my database along with other as i came a long way from time this question was passed so i felt obliged to share my findings and modification which enable to pass token number
Customer id
Estimated time
& status
.
Following are the modification i did so far
The list :
val_list = {
'token_number':Token,
'partner_id':customer_name,
'pos_order_id':torder.name,
'est_time':e_time,
'order_progress':torder.order_progress,
};
where torder
is this.pos.get_order()
.
MY rpc query become like (thanks to my supervisor)
return rpc.query({
model: 'pos.queue',
method: 'create_token',
args:[val_list],
}).then(function () {
console.log("Success")
}).catch(function (reason){
var error = reason.message;
console.log(error);
});
the model became like:
class POSOrderQueue(models.Model):
_name = 'pos.queue'
token_number = fields.Integer(string="Token Number", store=True)
partner_id = fields.Char(store=True)
pos_order_id = fields.Char(store=True)
est_time = fields.Text(string="estimated time", store=True)
order_progress = fields.Selection([('in_queue', 'In Queue'),
('in_progress', 'In Progress'), ('cancel', 'Cancel'),
('done', 'Done')], string="Order progress", default='in_queue', store=True)
no_items = fields.Integer(string='No of Items', store=True)
queue_line_ids = fields.One2many('pos.queue.line', 'queue_id')
@api.model
def create_token(self, val_list):
res = super(POSOrderQueue, self).create(val_list)
print("yes working")
return res
class POSOrderQueueLine(models.Model):
_name = 'pos.queue.line'
queue_id = fields.Many2one('pos.queue')
product_name = fields.Char(store=True)
product_quant = fields.Integer()
product_price = fields.Float()
def create(self, vals):
res = super(POSOrderQueueLine, self).create(vals)
return res
The problem is partially solved but i can't acheive my last objective which is to pass orderline
data through rpc query into my model pos.queue.line
so it can be viewable in my custom view of odoo13 which is like this
screenshot of my view table