[IMP] web: update accepts commands for x2m

Before this commit, the record.update function did not allow x2m fields
to be updated. Thanks to this commit, you can update an x2m by passing
a list of commands that will be applied to the x2m's static list.

This makes it possible to update several fields, including x2m fields,
while triggering only one onchange to the server.

closes odoo/odoo#129507

Related: odoo/enterprise#44532
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
FrancoisGe
2023-07-27 14:47:00 +02:00
parent 6b2117049c
commit 2d61351705
9 changed files with 130 additions and 40 deletions
@@ -1,7 +1,8 @@
/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { SaleOrderLineProductField } from '@sale/js/sale_product_field';
import { x2ManyCommands } from "@web/core/orm_service";
import { patch } from "@web/core/utils/patch";
patch(SaleOrderLineProductField.prototype, 'event_booth_sale', {
@@ -60,13 +61,10 @@ patch(SaleOrderLineProductField.prototype, 'event_booth_sale', {
} else {
const { event_id, event_booth_category_id, event_booth_pending_ids } =
closeInfo.eventBoothConfiguration;
this.props.record.data.event_booth_pending_ids.replaceWith(
event_booth_pending_ids,
{ silent: true }
);
this.props.record.update({
event_id,
event_booth_category_id,
event_booth_pending_ids: [x2ManyCommands.replaceWith(event_booth_pending_ids)],
});
}
}