feat: add pagination, individual price sync arrows, and bulk price sync
- Pagination with page nav for mapped, unmatched Odoo, and unmatched WC tabs - Per-product arrow buttons to push price in either direction - Bulk price sync buttons: All Prices Odoo→WC and All Prices WC→Odoo - Server-side offset/limit with total count in search endpoints Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -727,6 +727,30 @@ class WooInstance(models.Model):
|
||||
'price_unit': total,
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Bulk Price Sync (UI actions)
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def action_bulk_price_odoo_to_wc(self):
|
||||
"""Push all Odoo prices to WooCommerce for mapped products."""
|
||||
self.ensure_one()
|
||||
maps = self.env['woo.product.map'].search([
|
||||
('instance_id', '=', self.id),
|
||||
('state', '=', 'mapped'),
|
||||
('product_id', '!=', False),
|
||||
])
|
||||
maps.action_push_price_to_wc()
|
||||
|
||||
def action_bulk_price_wc_to_odoo(self):
|
||||
"""Pull all WC prices to Odoo for mapped products."""
|
||||
self.ensure_one()
|
||||
maps = self.env['woo.product.map'].search([
|
||||
('instance_id', '=', self.id),
|
||||
('state', '=', 'mapped'),
|
||||
('product_id', '!=', False),
|
||||
])
|
||||
maps.action_push_price_to_odoo()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Product / Price Sync (Task 22)
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@@ -43,6 +43,33 @@ class WooProductMap(models.Model):
|
||||
('error', 'Error'),
|
||||
], default='unmapped')
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Individual Price Sync
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def action_push_price_to_odoo(self):
|
||||
"""Update Odoo product price from WC price."""
|
||||
for rec in self:
|
||||
if rec.product_id and rec.woo_price:
|
||||
rec.product_id.list_price = rec.woo_price
|
||||
rec.instance_id._log_sync(
|
||||
'product', 'woo_to_odoo', rec.product_id.name, 'success',
|
||||
'Price updated from WC: $%.2f' % rec.woo_price,
|
||||
)
|
||||
|
||||
def action_push_price_to_wc(self):
|
||||
"""Update WC product price from Odoo price."""
|
||||
for rec in self:
|
||||
if rec.product_id and rec.instance_id:
|
||||
client = rec.instance_id._get_client()
|
||||
new_price = str(rec.product_id.list_price)
|
||||
client.update_product(rec.woo_product_id, {'regular_price': new_price})
|
||||
rec.woo_price = rec.product_id.list_price
|
||||
rec.instance_id._log_sync(
|
||||
'product', 'odoo_to_woo', rec.product_id.name, 'success',
|
||||
'Price pushed to WC: $%.2f' % rec.product_id.list_price,
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Image Sync (Task 22)
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user