Skip to Content
Menu
This question has been flagged
1 Reply
3657 Views

I'm trying to pass data to my custom model field of POS Order Line, but I'm getting the error: "can't adapt type 'dict'". I'm assuming I have to enter only an ID value to the field but then how do I add new data to it?

Python:

class Special(models.Model):
_name = 'example_module.special'

text = fields.Char('Text')

class PosOrderLine(models.Model):
_inherit = 'pos.order.line'

special = fields.Many2one('example_module.special', 'Special')

JavaScript:

models.Orderline = models.Orderline.extend({
export_as_JSON: function () {
var orderline = _super_orderline.export_as_JSON.call(this);

if(this.product.is_special) {
orderline.special = [0, false, {text: 'SPECIAL!!11'}];
}
return orderline;
},
});

Avatar
Discard
Author Best Answer

Nevermind, I was supposed to use One2many field. That way I can just pass it like:

orderline.special = [];
orderline.special.push([0, false, {text: 'SPECIAL!!11'}]);
Avatar
Discard
Related Posts Replies Views Activity
1
Nov 24
108
4
Oct 24
1439
2
Aug 23
1985
0
Mar 23
976
0
Oct 22
4147