I modified the PosOrderLine model this way:
class PosOrderLine(models.Model):
_inherit = "pos.order.line"
child_products = fields.Many2many(comodel_name="product.product",
relation="m2m_pos_testing_child_products",
column1="m2m_id",
column2="product_id",
string="Child Products")
And I extended models.Orderline:
export_as_JSON: function () {
var orderline = _super_orderline.export_as_JSON.call(this);
orderline.child_products = [];
//Loop through a Collection of models.Product
this.child_products.each(_.bind(function (item) {
//Python: [(6, None, item_ids)]
return orderline.child_products.push([6, false, [item.id]]);
}, this));
return orderline;
},
This works fine when there's only one child product. But when I add multiple child products, only the first is saved.
How do I fix that?