refactor: reduce customer fetch limit from 100 to 25 in partner list sync
This commit is contained in:
parent
0dfe27fadb
commit
fce0369533
@ -24,17 +24,17 @@ patch(PartnerList.prototype, {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.state.loading = true;
|
this.state.loading = true;
|
||||||
// console.log("[pos_loyalty_multi_level] Fetching the latest 100 customers from the backend...");
|
// console.log("[pos_loyalty_multi_level] Fetching the latest 100 customers from the backend...");
|
||||||
|
|
||||||
// In Odoo 19, data.searchRead fetches data AND creates/updates the local reactive models invisibly
|
// In Odoo 19, data.searchRead fetches data AND creates/updates the local reactive models invisibly
|
||||||
const newPartners = await this.pos.data.searchRead(
|
const newPartners = await this.pos.data.searchRead(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
[["active", "=", true]],
|
[["active", "=", true]],
|
||||||
this.pos.data.fields["res.partner"],
|
this.pos.data.fields["res.partner"],
|
||||||
{ limit: 100, order: 'id desc' }
|
{ limit: 25, order: 'id desc' }
|
||||||
);
|
);
|
||||||
|
|
||||||
let addedCount = 0;
|
let addedCount = 0;
|
||||||
@ -47,18 +47,18 @@ patch(PartnerList.prototype, {
|
|||||||
addedCount++;
|
addedCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh initial view
|
// Refresh initial view
|
||||||
this.state.initialPartners = this.pos.models["res.partner"].filter((p) => {
|
this.state.initialPartners = this.pos.models["res.partner"].filter((p) => {
|
||||||
const par = p.property_account_receivable_id;
|
const par = p.property_account_receivable_id;
|
||||||
return !par || par.non_trade !== true;
|
return !par || par.non_trade !== true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.notification) {
|
if (this.notification) {
|
||||||
this.notification.add(`Successfully synced list. Found ${addedCount} new customers.`, 3000);
|
this.notification.add(`Successfully synced list. Found ${addedCount} new customers.`, 3000);
|
||||||
}
|
}
|
||||||
// console.log(`[pos_loyalty_multi_level] Fetch complete. Added ${addedCount} customers to the session.`);
|
// console.log(`[pos_loyalty_multi_level] Fetch complete. Added ${addedCount} customers to the session.`);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("[pos_loyalty_multi_level] Failed to update customer data:", e);
|
console.warn("[pos_loyalty_multi_level] Failed to update customer data:", e);
|
||||||
if (this.notification) {
|
if (this.notification) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user