feat: add WC Price and Odoo Price columns to product mapping UI

Added woo_price field to woo.product.map model, populated during fetch.
Search endpoint now returns both odoo_price and woo_price for side-by-side
comparison in the mapped products table.

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

View File

@@ -140,6 +140,10 @@ class WooProductSearchController(http.Controller):
'odoo_product_id': m.product_id.id if m.product_id else False,
'odoo_product_name': m.product_id.name if m.product_id else '',
'odoo_default_code': m.product_id.default_code or '' if m.product_id else '',
'odoo_price': m.product_id.list_price if m.product_id else 0.0,
'woo_price': m.woo_price or 0.0,
'sync_price': m.sync_price,
'sync_inventory': m.sync_inventory,
'instance_id': m.instance_id.id if m.instance_id else False,
'instance_name': m.instance_id.name if m.instance_id else '',
}

View File

@@ -196,12 +196,19 @@ class WooInstance(models.Model):
match_state = 'mapped'
auto_matched += 1
wc_price = 0.0
try:
wc_price = float(wc_prod.get('regular_price') or wc_prod.get('price') or 0)
except (ValueError, TypeError):
pass
ProductMap.create({
'instance_id': self.id,
'product_id': odoo_product.id if odoo_product else False,
'woo_product_id': wc_id,
'woo_product_name': wc_name,
'woo_sku': wc_sku,
'woo_price': wc_price,
'woo_product_type': wc_type if wc_type in ('simple', 'variable', 'grouped', 'external') else 'simple',
'state': match_state,
'company_id': self.company_id.id,
@@ -239,12 +246,19 @@ class WooInstance(models.Model):
var_state = 'mapped'
auto_matched += 1
var_price = 0.0
try:
var_price = float(var.get('regular_price') or var.get('price') or 0)
except (ValueError, TypeError):
pass
ProductMap.create({
'instance_id': self.id,
'product_id': var_product.id if var_product else False,
'woo_product_id': var_id,
'woo_product_name': var_name,
'woo_sku': var_sku,
'woo_price': var_price,
'woo_product_type': 'simple',
'woo_parent_id': wc_id,
'is_variation': True,

View File

@@ -25,6 +25,7 @@ class WooProductMap(models.Model):
('grouped', 'Grouped'),
('external', 'External'),
])
woo_price = fields.Float(string='WC Price', digits='Product Price')
woo_parent_id = fields.Integer()
is_variation = fields.Boolean()
sync_price = fields.Boolean(default=True)

View File

@@ -130,6 +130,8 @@
<th>WooCommerce Product</th>
<th>SKU</th>
<th>Odoo Product</th>
<th>WC Price</th>
<th>Odoo Price</th>
<th>Instance</th>
<th>Price Sync</th>
<th>Inventory Sync</th>
@@ -146,6 +148,14 @@
<td><t t-esc="p.woo_product_name"/></td>
<td><span class="woo-code"><t t-esc="p.woo_sku"/></span></td>
<td><t t-esc="p.odoo_product_name"/></td>
<td class="text-end">
<t t-if="p.woo_price">$<t t-esc="p.woo_price.toFixed(2)"/></t>
<t t-else=""><span class="woo-text-muted"></span></t>
</td>
<td class="text-end">
<t t-if="p.odoo_price">$<t t-esc="p.odoo_price.toFixed(2)"/></t>
<t t-else=""><span class="woo-text-muted"></span></t>
</td>
<td><t t-esc="p.instance_name"/></td>
<td>
<input type="checkbox"