[REF] *: adapt codebase to new RelationalModel

This commit adapts the code in addons w.r.t. the introduction of
the RelationalModel.

Main changes that were requested are:
 - record datapoints no longer always have an "id" key in their
 data (they still do if the id field is in the view), so we use
 record.resId instead
 - the new model is based on fined-grained reactivity, so several
 components that previously relied on onWillUpdateProps to update
 their internal state no longer worked. Typically, using the hook
 "observeRecord" is the way to go now.
 - specialdata are no longer handled in the model, so the components
 needing specialData can use the hook "useSpecialData"
 - more generally, all overrides of models (RelationalModel or
 KanbanModel) needed to be reworked.

Part of task~3179751

Part-of: odoo/odoo#114024
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: FrancoisGe <fge@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
Co-authored-by: Pierre Rousseau <pro@odoo.com>
This commit is contained in:
Aaron Bohy
2023-07-24 20:17:50 +02:00
co-authored by FrancoisGe Jorge Pinna Puissant Pierre Rousseau
parent 8723f020c3
commit 218ad8456a
90 changed files with 584 additions and 792 deletions
@@ -18,7 +18,8 @@ class EventBoothConfiguratorController extends formView.Controller {
this.action = useService("action");
}
onRecordSaved(record) {
async onRecordSaved(record) {
await super.onRecordSaved(...arguments);
const { event_id, event_booth_category_id, event_booth_ids } = record.data;
return this.action.doAction({
type: "ir.actions.act_window_close",
@@ -26,15 +27,7 @@ class EventBoothConfiguratorController extends formView.Controller {
eventBoothConfiguration: {
event_id,
event_booth_category_id,
event_booth_pending_ids: {
operation: "MULTI",
commands: [
{
operation: "REPLACE_WITH",
ids: event_booth_ids.currentIds,
},
],
},
event_booth_pending_ids: event_booth_ids.currentIds,
},
},
});
@@ -39,7 +39,7 @@ patch(SaleOrderLineProductField.prototype, 'event_booth_sale', {
if (recordData.event_booth_pending_ids) {
actionContext.default_event_booth_ids = recordData.event_booth_pending_ids.records.map(
record => {
return [4, record.data.id];
return [4, record.resId];
}
);
}
@@ -58,11 +58,15 @@ patch(SaleOrderLineProductField.prototype, 'event_booth_sale', {
});
}
} else {
const eventBoothConfiguration = closeInfo.eventBoothConfiguration;
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: eventBoothConfiguration.event_id,
event_booth_category_id: eventBoothConfiguration.event_booth_category_id,
event_booth_pending_ids: eventBoothConfiguration.event_booth_pending_ids,
event_id,
event_booth_category_id,
});
}
}