feat: add Refresh Prices button to pull WC prices for existing mappings

Existing mapped products had no WC price since they were fetched before
the woo_price field existed. action_refresh_prices fetches current prices
from WC API for all mapped products.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-03-31 22:35:13 -04:00
parent 919dbcb4cf
commit 3ea283247a
3 changed files with 55 additions and 0 deletions

View File

@@ -426,6 +426,29 @@ export class ProductMapping extends Component {
}
}
async refreshPrices() {
if (!this.state.instanceId) {
this.notification.add("Please select an instance first.", { type: "warning" });
return;
}
try {
this.state.loading = true;
await rpc("/web/dataset/call_kw", {
model: "woo.instance",
method: "action_refresh_prices",
args: [[this.state.instanceId]],
kwargs: {},
});
this.notification.add("Prices refreshed from WooCommerce.", { type: "success" });
await this._refreshAll();
} catch (err) {
console.error("[ProductMapping] refreshPrices error:", err);
this.notification.add("Failed to refresh prices.", { type: "danger" });
} finally {
this.state.loading = false;
}
}
async syncNow() {
if (!this.state.instanceId) {
this.notification.add("Please select an instance first.", { type: "warning" });

View File

@@ -44,6 +44,10 @@
t-att-disabled="state.loading">
<i class="fa fa-refresh me-1"/> Sync Now
</button>
<button class="woo-btn woo-btn-secondary" t-on-click="refreshPrices"
t-att-disabled="state.loading">
<i class="fa fa-dollar me-1"/> Refresh Prices
</button>
<!-- Spacer -->
<div class="flex-grow-1"/>