[FIX] point_of_sale: improve perf on saving res.partner edits

Issue -->

`saveChanges` at https://github.com/odoo/odoo/blob/saass-16.3/addons/point_of_sale/static/src/js/Screens/ClientListScreen/ClientListScreen.js#L155
calls `load_new_partners` that calls `prepare_new_partners_domain` to compute
the domain on which the res.partner model is to be searched on, after the save has been
 commited. The search is done to update client side res.partner data.

Domain in question --> https://github.com/odoo/odoo/blob/5404f3367a611e527fcecc2dd49e683864ba4b81/addons/point_of_sale/static/src/js/models.js#L784

This domain has the potential to make `search_read` return every res.partner
record and compute fields such as 'total_due' on each one of them.
This presents the issue of overworking postgres when we only need to update one
res.partner record.

Solution -->

Use the `_loadPartners` method instead to only reload the current partner being edited + saved.

opw-3619941

closes odoo/odoo#157120

X-original-commit: 7477978482bc3c22338faab486d67085452b006d
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Aditya Dasgupta (adda) <adda@odoo.com>
This commit is contained in:
adda-odoo
2024-03-09 00:24:57 +00:00
parent 1032eacb6c
commit 37d797f6d6
@@ -168,7 +168,7 @@ export class PartnerListScreen extends Component {
}
async saveChanges(processedChanges) {
const partnerId = await this.orm.call("res.partner", "create_from_ui", [processedChanges]);
await this.pos.load_new_partners();
await this.pos._loadPartners([partnerId]);
this.state.selectedPartner = this.pos.db.get_partner_by_id(partnerId);
this.confirm();
}