OCA / stock-logistics-transport

Transport management in Odoo
GNU Affero General Public License v3.0
61 stars 126 forks source link

Set ID's in One2many field from JavaScript #142

Closed EdgarRetes closed 1 month ago

EdgarRetes commented 2 months ago

Hi, I'm stuck with a problem with JavaScript and I was wondering if someone could help me a little bit.

In tms_sale module (https://github.com/OCA/stock-logistics-transport/pull/134), I'm trying to implement the logic of selling seat tickets for each line in sale orders:

image

The problem is that when I save the records, they aren't stored in the line model. I have already tried multiple ways of storing the values but I haven't been able to do it. The logic basically consists of this:

image image

As you may notice, I was able to do so for Many2one fields (when selling trips for each line), but when I try to do it for this One2many field, I get an error of "field not iterable" or the field isn't stored at all. I would appreciate if someone could give it a look and help me find a way to do it.

The module I'm taking as a reference is event_sale: https://github.com/odoo/odoo/tree/62d46fca5d9dee911676f5224aa1c993e31f3d8c/addons/event_sale

Thanks ;)