changes
This commit is contained in:
11
fusion-woo-odoo/check_products.sh
Normal file
11
fusion-woo-odoo/check_products.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "=== Recently created products ==="
|
||||||
|
PGPASSWORD='DevSecure2025!' psql -h db -U odoo -d westin-v19 -c "SELECT id, name, default_code, list_price, create_date FROM product_product ORDER BY create_date DESC LIMIT 5;"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Recent woo.product.map changes ==="
|
||||||
|
PGPASSWORD='DevSecure2025!' psql -h db -U odoo -d westin-v19 -c "SELECT id, woo_product_name, woo_sku, product_id, state, write_date FROM woo_product_map ORDER BY write_date DESC LIMIT 5;"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Unmapped WC products ==="
|
||||||
|
PGPASSWORD='DevSecure2025!' psql -h db -U odoo -d westin-v19 -c "SELECT id, woo_product_name, woo_sku, product_id, state FROM woo_product_map WHERE state='unmapped' LIMIT 5;"
|
||||||
Binary file not shown.
@@ -38,7 +38,6 @@
|
|||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'fusion_woocommerce/static/src/js/theme_detect.js',
|
|
||||||
'fusion_woocommerce/static/src/css/woo_styles.css',
|
'fusion_woocommerce/static/src/css/woo_styles.css',
|
||||||
'fusion_woocommerce/static/src/js/ajax_search.js',
|
'fusion_woocommerce/static/src/js/ajax_search.js',
|
||||||
'fusion_woocommerce/static/src/js/product_mapping.js',
|
'fusion_woocommerce/static/src/js/product_mapping.js',
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ class WooProductSearchController(http.Controller):
|
|||||||
'woo_product_name': m.woo_product_name or '',
|
'woo_product_name': m.woo_product_name or '',
|
||||||
'woo_sku': m.woo_sku or '',
|
'woo_sku': m.woo_sku or '',
|
||||||
'woo_product_type': m.woo_product_type or '',
|
'woo_product_type': m.woo_product_type or '',
|
||||||
|
'woo_category_name': m.woo_category_name or '',
|
||||||
}
|
}
|
||||||
for m in maps
|
for m in maps
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class WooWebhookController(http.Controller):
|
|||||||
|
|
||||||
# Simple in-memory rate limiter: {ip: [(timestamp, ...),]}
|
# Simple in-memory rate limiter: {ip: [(timestamp, ...),]}
|
||||||
_rate_tracker = defaultdict(list)
|
_rate_tracker = defaultdict(list)
|
||||||
_RATE_LIMIT = 100 # max requests per minute
|
_RATE_LIMIT = 60 # max requests per minute (1/sec sustained)
|
||||||
_RATE_WINDOW = 60 # seconds
|
_RATE_WINDOW = 60 # seconds
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -2,17 +2,102 @@ import base64
|
|||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import logging
|
import logging
|
||||||
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Shared circuit breaker state — one per WC base URL so all Odoo workers
|
||||||
|
# referencing the same WooCommerce store share the same breaker.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
_circuit_breakers = {}
|
||||||
|
_cb_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
|
class _CircuitBreaker:
|
||||||
|
"""Per-host circuit breaker: CLOSED → OPEN after N failures, auto-resets
|
||||||
|
after a cooldown period to HALF_OPEN (allows one probe request)."""
|
||||||
|
|
||||||
|
CLOSED = 'closed'
|
||||||
|
OPEN = 'open'
|
||||||
|
HALF_OPEN = 'half_open'
|
||||||
|
|
||||||
|
def __init__(self, failure_threshold=5, cooldown_seconds=60):
|
||||||
|
self.failure_threshold = failure_threshold
|
||||||
|
self.cooldown_seconds = cooldown_seconds
|
||||||
|
self.state = self.CLOSED
|
||||||
|
self.consecutive_failures = 0
|
||||||
|
self.last_failure_time = 0
|
||||||
|
self._lock = threading.Lock()
|
||||||
|
|
||||||
|
def record_success(self):
|
||||||
|
with self._lock:
|
||||||
|
self.consecutive_failures = 0
|
||||||
|
self.state = self.CLOSED
|
||||||
|
|
||||||
|
def record_failure(self):
|
||||||
|
with self._lock:
|
||||||
|
self.consecutive_failures += 1
|
||||||
|
self.last_failure_time = time.monotonic()
|
||||||
|
if self.consecutive_failures >= self.failure_threshold:
|
||||||
|
self.state = self.OPEN
|
||||||
|
_logger.warning(
|
||||||
|
"Circuit breaker OPEN after %d consecutive failures — "
|
||||||
|
"blocking requests for %ds",
|
||||||
|
self.consecutive_failures, self.cooldown_seconds,
|
||||||
|
)
|
||||||
|
|
||||||
|
def allow_request(self):
|
||||||
|
with self._lock:
|
||||||
|
if self.state == self.CLOSED:
|
||||||
|
return True
|
||||||
|
elapsed = time.monotonic() - self.last_failure_time
|
||||||
|
if elapsed >= self.cooldown_seconds:
|
||||||
|
self.state = self.HALF_OPEN
|
||||||
|
_logger.info("Circuit breaker HALF_OPEN — allowing probe request")
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class _TokenBucket:
|
||||||
|
"""Simple token-bucket rate limiter. Tokens refill at *rate* per second
|
||||||
|
up to *capacity*. ``consume()`` blocks until a token is available."""
|
||||||
|
|
||||||
|
def __init__(self, rate, capacity):
|
||||||
|
self.rate = rate
|
||||||
|
self.capacity = capacity
|
||||||
|
self.tokens = capacity
|
||||||
|
self.last_refill = time.monotonic()
|
||||||
|
self._lock = threading.Lock()
|
||||||
|
|
||||||
|
def consume(self):
|
||||||
|
while True:
|
||||||
|
with self._lock:
|
||||||
|
now = time.monotonic()
|
||||||
|
elapsed = now - self.last_refill
|
||||||
|
self.tokens = min(self.capacity, self.tokens + elapsed * self.rate)
|
||||||
|
self.last_refill = now
|
||||||
|
if self.tokens >= 1:
|
||||||
|
self.tokens -= 1
|
||||||
|
return
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
class WooApiClient:
|
class WooApiClient:
|
||||||
"""WooCommerce REST API v3 client wrapper."""
|
"""WooCommerce REST API v3 client wrapper with rate limiting and circuit
|
||||||
|
breaker protection."""
|
||||||
|
|
||||||
def __init__(self, url, consumer_key, consumer_secret, api_version='wc/v3', timeout=30):
|
# Default: 3 requests/sec, burst up to 5.
|
||||||
|
# WooCommerce typically allows ~240 req/min (4/sec) so 3/sec is safe.
|
||||||
|
DEFAULT_RATE = 3
|
||||||
|
DEFAULT_BURST = 5
|
||||||
|
|
||||||
|
def __init__(self, url, consumer_key, consumer_secret,
|
||||||
|
api_version='wc/v3', timeout=30,
|
||||||
|
rate_limit=None, burst_limit=None):
|
||||||
self.base_url = url.rstrip('/')
|
self.base_url = url.rstrip('/')
|
||||||
self.api_version = api_version
|
self.api_version = api_version
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
@@ -24,40 +109,105 @@ class WooApiClient:
|
|||||||
'User-Agent': 'FusionWooCommerce/1.0',
|
'User-Agent': 'FusionWooCommerce/1.0',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
rate = rate_limit or self.DEFAULT_RATE
|
||||||
|
burst = burst_limit or self.DEFAULT_BURST
|
||||||
|
self._bucket = _TokenBucket(rate, burst)
|
||||||
|
|
||||||
|
with _cb_lock:
|
||||||
|
if self.base_url not in _circuit_breakers:
|
||||||
|
_circuit_breakers[self.base_url] = _CircuitBreaker(
|
||||||
|
failure_threshold=5, cooldown_seconds=60,
|
||||||
|
)
|
||||||
|
self._breaker = _circuit_breakers[self.base_url]
|
||||||
|
|
||||||
def _url(self, endpoint):
|
def _url(self, endpoint):
|
||||||
return f"{self.base_url}/wp-json/{self.api_version}/{endpoint}"
|
return f"{self.base_url}/wp-json/{self.api_version}/{endpoint}"
|
||||||
|
|
||||||
def _request(self, method, endpoint, data=None, params=None, retries=3):
|
def _request(self, method, endpoint, data=None, params=None, retries=3):
|
||||||
url = self._url(endpoint)
|
url = self._url(endpoint)
|
||||||
|
|
||||||
|
if not self._breaker.allow_request():
|
||||||
|
raise ConnectionError(
|
||||||
|
"WooCommerce API circuit breaker is OPEN for %s — "
|
||||||
|
"too many consecutive failures. Retry later." % self.base_url
|
||||||
|
)
|
||||||
|
|
||||||
last_exc = None
|
last_exc = None
|
||||||
for attempt in range(retries):
|
for attempt in range(retries):
|
||||||
|
self._bucket.consume()
|
||||||
try:
|
try:
|
||||||
response = self.session.request(
|
response = self.session.request(
|
||||||
method,
|
method, url,
|
||||||
url,
|
json=data, params=params,
|
||||||
json=data,
|
|
||||||
params=params,
|
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
)
|
)
|
||||||
if response.status_code >= 400:
|
|
||||||
_logger.error(
|
# --- Handle rate-limit response from WC / server ---
|
||||||
"WC API %s %s returned %s: %s",
|
if response.status_code == 429:
|
||||||
method, endpoint, response.status_code, response.text[:500],
|
retry_after = int(response.headers.get('Retry-After', 10))
|
||||||
|
retry_after = min(retry_after, 120)
|
||||||
|
_logger.warning(
|
||||||
|
"WC API 429 on %s %s — backing off %ds (attempt %d/%d)",
|
||||||
|
method, endpoint, retry_after, attempt + 1, retries,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
time.sleep(retry_after)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# --- Non-retryable client errors (400-499 except 429) ---
|
||||||
|
if 400 <= response.status_code < 500:
|
||||||
|
_logger.error(
|
||||||
|
"WC API %s %s returned %s (non-retryable): %s",
|
||||||
|
method, endpoint, response.status_code,
|
||||||
|
response.text[:500],
|
||||||
|
)
|
||||||
|
self._breaker.record_success()
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
# --- Server errors (500+) are retryable ---
|
||||||
|
if response.status_code >= 500:
|
||||||
|
_logger.warning(
|
||||||
|
"WC API %s %s returned %s (attempt %d/%d): %s",
|
||||||
|
method, endpoint, response.status_code,
|
||||||
|
attempt + 1, retries, response.text[:300],
|
||||||
|
)
|
||||||
|
last_exc = requests.HTTPError(response=response)
|
||||||
|
wait = min(2 ** attempt * 2, 30)
|
||||||
|
time.sleep(wait)
|
||||||
|
continue
|
||||||
|
|
||||||
|
self._breaker.record_success()
|
||||||
return response.json()
|
return response.json()
|
||||||
except Exception as exc:
|
|
||||||
|
except requests.exceptions.ConnectionError as exc:
|
||||||
last_exc = exc
|
last_exc = exc
|
||||||
wait = 2 ** attempt
|
wait = min(2 ** attempt * 2, 30)
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
"WooCommerce API %s %s failed (attempt %d/%d): %s — retrying in %ds",
|
"WC API connection error %s %s (attempt %d/%d): %s — "
|
||||||
|
"retrying in %ds",
|
||||||
method, endpoint, attempt + 1, retries, exc, wait,
|
method, endpoint, attempt + 1, retries, exc, wait,
|
||||||
)
|
)
|
||||||
if attempt < retries - 1:
|
time.sleep(wait)
|
||||||
time.sleep(wait)
|
|
||||||
|
except requests.exceptions.Timeout as exc:
|
||||||
|
last_exc = exc
|
||||||
|
wait = min(2 ** attempt * 2, 30)
|
||||||
|
_logger.warning(
|
||||||
|
"WC API timeout %s %s (attempt %d/%d) — retrying in %ds",
|
||||||
|
method, endpoint, attempt + 1, retries, wait,
|
||||||
|
)
|
||||||
|
time.sleep(wait)
|
||||||
|
|
||||||
|
except Exception as exc:
|
||||||
|
last_exc = exc
|
||||||
|
_logger.error(
|
||||||
|
"WC API unexpected error %s %s: %s", method, endpoint, exc,
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
|
self._breaker.record_failure()
|
||||||
raise last_exc
|
raise last_exc
|
||||||
|
|
||||||
# Convenience methods
|
# --- Convenience methods ---
|
||||||
|
|
||||||
def get(self, endpoint, params=None):
|
def get(self, endpoint, params=None):
|
||||||
return self._request('GET', endpoint, params=params)
|
return self._request('GET', endpoint, params=params)
|
||||||
@@ -71,7 +221,7 @@ class WooApiClient:
|
|||||||
def delete(self, endpoint):
|
def delete(self, endpoint):
|
||||||
return self._request('DELETE', endpoint)
|
return self._request('DELETE', endpoint)
|
||||||
|
|
||||||
# Product endpoints
|
# --- Product endpoints ---
|
||||||
|
|
||||||
def get_products(self, page=1, per_page=100, **kwargs):
|
def get_products(self, page=1, per_page=100, **kwargs):
|
||||||
params = {'page': page, 'per_page': per_page, **kwargs}
|
params = {'page': page, 'per_page': per_page, **kwargs}
|
||||||
@@ -90,7 +240,7 @@ class WooApiClient:
|
|||||||
def create_product(self, data):
|
def create_product(self, data):
|
||||||
return self.post('products', data)
|
return self.post('products', data)
|
||||||
|
|
||||||
# Attribute endpoints
|
# --- Attribute endpoints ---
|
||||||
|
|
||||||
def get_product_attributes(self):
|
def get_product_attributes(self):
|
||||||
return self.get('products/attributes', params={'per_page': 100})
|
return self.get('products/attributes', params={'per_page': 100})
|
||||||
@@ -99,12 +249,15 @@ class WooApiClient:
|
|||||||
return self.post('products/attributes', data)
|
return self.post('products/attributes', data)
|
||||||
|
|
||||||
def get_attribute_terms(self, attribute_id, page=1, per_page=100):
|
def get_attribute_terms(self, attribute_id, page=1, per_page=100):
|
||||||
return self.get(f'products/attributes/{attribute_id}/terms', params={'page': page, 'per_page': per_page})
|
return self.get(
|
||||||
|
f'products/attributes/{attribute_id}/terms',
|
||||||
|
params={'page': page, 'per_page': per_page},
|
||||||
|
)
|
||||||
|
|
||||||
def create_attribute_term(self, attribute_id, data):
|
def create_attribute_term(self, attribute_id, data):
|
||||||
return self.post(f'products/attributes/{attribute_id}/terms', data)
|
return self.post(f'products/attributes/{attribute_id}/terms', data)
|
||||||
|
|
||||||
# Variation endpoints
|
# --- Variation endpoints ---
|
||||||
|
|
||||||
def create_product_variation(self, product_id, data):
|
def create_product_variation(self, product_id, data):
|
||||||
return self.post(f'products/{product_id}/variations', data)
|
return self.post(f'products/{product_id}/variations', data)
|
||||||
@@ -117,9 +270,12 @@ class WooApiClient:
|
|||||||
|
|
||||||
def batch_create_variations(self, product_id, variations_data):
|
def batch_create_variations(self, product_id, variations_data):
|
||||||
"""Create multiple variations at once using WC batch endpoint."""
|
"""Create multiple variations at once using WC batch endpoint."""
|
||||||
return self.post(f'products/{product_id}/variations/batch', {'create': variations_data})
|
return self.post(
|
||||||
|
f'products/{product_id}/variations/batch',
|
||||||
|
{'create': variations_data},
|
||||||
|
)
|
||||||
|
|
||||||
# Order endpoints
|
# --- Order endpoints ---
|
||||||
|
|
||||||
def get_orders(self, page=1, per_page=100, **kwargs):
|
def get_orders(self, page=1, per_page=100, **kwargs):
|
||||||
params = {'page': page, 'per_page': per_page, **kwargs}
|
params = {'page': page, 'per_page': per_page, **kwargs}
|
||||||
@@ -131,7 +287,7 @@ class WooApiClient:
|
|||||||
def update_order(self, order_id, data):
|
def update_order(self, order_id, data):
|
||||||
return self.put(f'orders/{order_id}', data)
|
return self.put(f'orders/{order_id}', data)
|
||||||
|
|
||||||
# Customer endpoints
|
# --- Customer endpoints ---
|
||||||
|
|
||||||
def get_customers(self, page=1, per_page=100, **kwargs):
|
def get_customers(self, page=1, per_page=100, **kwargs):
|
||||||
params = {'page': page, 'per_page': per_page, **kwargs}
|
params = {'page': page, 'per_page': per_page, **kwargs}
|
||||||
@@ -146,7 +302,7 @@ class WooApiClient:
|
|||||||
def update_customer(self, customer_id, data):
|
def update_customer(self, customer_id, data):
|
||||||
return self.put(f'customers/{customer_id}', data)
|
return self.put(f'customers/{customer_id}', data)
|
||||||
|
|
||||||
# Webhook endpoints
|
# --- Webhook endpoints ---
|
||||||
|
|
||||||
def create_webhook(self, data):
|
def create_webhook(self, data):
|
||||||
return self.post('webhooks', data)
|
return self.post('webhooks', data)
|
||||||
@@ -157,12 +313,12 @@ class WooApiClient:
|
|||||||
def delete_webhook(self, webhook_id):
|
def delete_webhook(self, webhook_id):
|
||||||
return self.delete(f'webhooks/{webhook_id}')
|
return self.delete(f'webhooks/{webhook_id}')
|
||||||
|
|
||||||
# Tax endpoints
|
# --- Tax endpoints ---
|
||||||
|
|
||||||
def get_tax_classes(self):
|
def get_tax_classes(self):
|
||||||
return self.get('taxes/classes')
|
return self.get('taxes/classes')
|
||||||
|
|
||||||
# Utility
|
# --- Utility ---
|
||||||
|
|
||||||
def test_connection(self):
|
def test_connection(self):
|
||||||
try:
|
try:
|
||||||
@@ -174,16 +330,7 @@ class WooApiClient:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def verify_webhook_signature(payload, signature, secret):
|
def verify_webhook_signature(payload, signature, secret):
|
||||||
"""Verify a WooCommerce webhook HMAC-SHA256 signature.
|
"""Verify a WooCommerce webhook HMAC-SHA256 signature."""
|
||||||
|
|
||||||
Args:
|
|
||||||
payload (bytes): Raw request body bytes.
|
|
||||||
signature (str): Value of the X-WC-Webhook-Signature header.
|
|
||||||
secret (str): The webhook secret configured in WooCommerce.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: True if the signature matches, False otherwise.
|
|
||||||
"""
|
|
||||||
if isinstance(payload, str):
|
if isinstance(payload, str):
|
||||||
payload = payload.encode('utf-8')
|
payload = payload.encode('utf-8')
|
||||||
if isinstance(secret, str):
|
if isinstance(secret, str):
|
||||||
|
|||||||
@@ -365,6 +365,10 @@ class WooInstance(models.Model):
|
|||||||
|
|
||||||
wc_permalink = wc_prod.get('permalink', '')
|
wc_permalink = wc_prod.get('permalink', '')
|
||||||
|
|
||||||
|
wc_categories = wc_prod.get('categories', [])
|
||||||
|
wc_cat_id = wc_categories[0].get('id', 0) if wc_categories else 0
|
||||||
|
wc_cat_name = wc_categories[0].get('name', '') if wc_categories else ''
|
||||||
|
|
||||||
ProductMap.create({
|
ProductMap.create({
|
||||||
'instance_id': self.id,
|
'instance_id': self.id,
|
||||||
'product_id': odoo_product.id if odoo_product else False,
|
'product_id': odoo_product.id if odoo_product else False,
|
||||||
@@ -374,6 +378,8 @@ class WooInstance(models.Model):
|
|||||||
'woo_regular_price': wc_regular_price,
|
'woo_regular_price': wc_regular_price,
|
||||||
'woo_sale_price': wc_sale_price,
|
'woo_sale_price': wc_sale_price,
|
||||||
'woo_permalink': wc_permalink,
|
'woo_permalink': wc_permalink,
|
||||||
|
'woo_category_id': wc_cat_id,
|
||||||
|
'woo_category_name': wc_cat_name,
|
||||||
'woo_product_type': wc_type if wc_type in ('simple', 'variable', 'grouped', 'external') else 'simple',
|
'woo_product_type': wc_type if wc_type in ('simple', 'variable', 'grouped', 'external') else 'simple',
|
||||||
'state': match_state,
|
'state': match_state,
|
||||||
'company_id': self.company_id.id,
|
'company_id': self.company_id.id,
|
||||||
@@ -451,6 +457,9 @@ class WooInstance(models.Model):
|
|||||||
'Fetched %d products, auto-matched %d by SKU' % (total_fetched, auto_matched))
|
'Fetched %d products, auto-matched %d by SKU' % (total_fetched, auto_matched))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Max consecutive API errors before aborting a sync loop
|
||||||
|
_MAX_CONSECUTIVE_ERRORS = 5
|
||||||
|
|
||||||
def action_refresh_prices(self):
|
def action_refresh_prices(self):
|
||||||
"""Refresh WC standard + sale prices for all products from WooCommerce API."""
|
"""Refresh WC standard + sale prices for all products from WooCommerce API."""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
@@ -462,9 +471,11 @@ class WooInstance(models.Model):
|
|||||||
('woo_product_id', '>', 0),
|
('woo_product_id', '>', 0),
|
||||||
])
|
])
|
||||||
updated = 0
|
updated = 0
|
||||||
|
consecutive_errors = 0
|
||||||
for m in maps:
|
for m in maps:
|
||||||
try:
|
try:
|
||||||
wc_prod = client.get_product(m.woo_product_id)
|
wc_prod = client.get_product(m.woo_product_id)
|
||||||
|
consecutive_errors = 0
|
||||||
regular = 0.0
|
regular = 0.0
|
||||||
sale = 0.0
|
sale = 0.0
|
||||||
try:
|
try:
|
||||||
@@ -485,7 +496,14 @@ class WooInstance(models.Model):
|
|||||||
if changed:
|
if changed:
|
||||||
updated += 1
|
updated += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
consecutive_errors += 1
|
||||||
_logger.warning("Failed to refresh price for WC#%s: %s", m.woo_product_id, e)
|
_logger.warning("Failed to refresh price for WC#%s: %s", m.woo_product_id, e)
|
||||||
|
if consecutive_errors >= self._MAX_CONSECUTIVE_ERRORS:
|
||||||
|
_logger.error(
|
||||||
|
"Aborting price refresh after %d consecutive errors", consecutive_errors)
|
||||||
|
self._log_sync('product', 'woo_to_odoo', self.name, 'failed',
|
||||||
|
'Aborted after %d consecutive API errors' % consecutive_errors)
|
||||||
|
return True
|
||||||
self._log_sync('product', 'woo_to_odoo', self.name, 'success',
|
self._log_sync('product', 'woo_to_odoo', self.name, 'success',
|
||||||
'Refreshed prices for %d products' % updated)
|
'Refreshed prices for %d products' % updated)
|
||||||
return True
|
return True
|
||||||
@@ -589,8 +607,20 @@ class WooInstance(models.Model):
|
|||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
client = self._get_client()
|
client = self._get_client()
|
||||||
page = 1
|
page = 1
|
||||||
|
consecutive_fetch_errors = 0
|
||||||
while True:
|
while True:
|
||||||
orders = client.get_orders(page=page, status='processing,on-hold,pending')
|
try:
|
||||||
|
orders = client.get_orders(page=page, status='processing,on-hold,pending')
|
||||||
|
consecutive_fetch_errors = 0
|
||||||
|
except Exception as e:
|
||||||
|
consecutive_fetch_errors += 1
|
||||||
|
_logger.error("Failed to fetch orders page %d: %s", page, e)
|
||||||
|
if consecutive_fetch_errors >= 3:
|
||||||
|
self._log_sync('order', 'woo_to_odoo', self.name, 'failed',
|
||||||
|
'Aborted order fetch after %d consecutive page errors' % consecutive_fetch_errors)
|
||||||
|
return
|
||||||
|
page += 1
|
||||||
|
continue
|
||||||
if not orders:
|
if not orders:
|
||||||
break
|
break
|
||||||
for wc_order in orders:
|
for wc_order in orders:
|
||||||
@@ -644,37 +674,51 @@ class WooInstance(models.Model):
|
|||||||
|
|
||||||
# Add fee lines
|
# Add fee lines
|
||||||
for fee in wc_order.get('fee_lines', []):
|
for fee in wc_order.get('fee_lines', []):
|
||||||
|
fee_product = self._get_service_product('WC Fee', 'WC-FEE')
|
||||||
fee_vals = {
|
fee_vals = {
|
||||||
'order_id': sale_order.id,
|
'order_id': sale_order.id,
|
||||||
'name': fee.get('name', 'Fee'),
|
'name': fee.get('name', 'Fee'),
|
||||||
|
'product_id': fee_product.id,
|
||||||
'product_uom_qty': 1,
|
'product_uom_qty': 1,
|
||||||
'price_unit': float(fee.get('total', 0)),
|
'price_unit': float(fee.get('total', 0)),
|
||||||
}
|
}
|
||||||
self.env['sale.order.line'].create(fee_vals)
|
self.env['sale.order.line'].create(fee_vals)
|
||||||
|
|
||||||
# Confirm SO
|
# Create woo.order tracking record FIRST to prevent infinite retries
|
||||||
sale_order.action_confirm()
|
# if action_confirm or invoicing fails later.
|
||||||
|
|
||||||
# Create draft invoice
|
|
||||||
invoice = False
|
|
||||||
if self.sync_invoices:
|
|
||||||
try:
|
|
||||||
invoice = sale_order._create_invoices()
|
|
||||||
except Exception as e:
|
|
||||||
_logger.warning("Could not auto-create invoice for %s: %s", sale_order.name, e)
|
|
||||||
|
|
||||||
# Create woo.order tracking record
|
|
||||||
woo_order = self.env['woo.order'].create({
|
woo_order = self.env['woo.order'].create({
|
||||||
'instance_id': self.id,
|
'instance_id': self.id,
|
||||||
'sale_order_id': sale_order.id,
|
'sale_order_id': sale_order.id,
|
||||||
'woo_order_id': woo_order_id,
|
'woo_order_id': woo_order_id,
|
||||||
'woo_order_number': wc_order.get('number', str(woo_order_id)),
|
'woo_order_number': wc_order.get('number', str(woo_order_id)),
|
||||||
'woo_status': wc_order.get('status', ''),
|
'woo_status': wc_order.get('status', ''),
|
||||||
'invoice_id': invoice.id if invoice else False,
|
|
||||||
'state': 'confirmed',
|
'state': 'confirmed',
|
||||||
'company_id': self.company_id.id,
|
'company_id': self.company_id.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Confirm SO (non-fatal — keeps SO in draft if it fails)
|
||||||
|
try:
|
||||||
|
sale_order.action_confirm()
|
||||||
|
except Exception as e:
|
||||||
|
_logger.warning(
|
||||||
|
"Could not auto-confirm SO %s (WC#%s): %s — order left in draft",
|
||||||
|
sale_order.name, woo_order_id, e,
|
||||||
|
)
|
||||||
|
self._log_sync(
|
||||||
|
'order', 'woo_to_odoo', sale_order.name, 'failed',
|
||||||
|
f'Order imported but could not auto-confirm: {e}',
|
||||||
|
)
|
||||||
|
return woo_order
|
||||||
|
|
||||||
|
# Create draft invoice
|
||||||
|
invoice = False
|
||||||
|
if self.sync_invoices:
|
||||||
|
try:
|
||||||
|
invoice = sale_order._create_invoices()
|
||||||
|
woo_order.invoice_id = invoice.id
|
||||||
|
except Exception as e:
|
||||||
|
_logger.warning("Could not auto-create invoice for %s: %s", sale_order.name, e)
|
||||||
|
|
||||||
# Link invoice to woo.order
|
# Link invoice to woo.order
|
||||||
if invoice:
|
if invoice:
|
||||||
invoice.woo_order_id = woo_order.id
|
invoice.woo_order_id = woo_order.id
|
||||||
@@ -860,16 +904,41 @@ class WooInstance(models.Model):
|
|||||||
'|', ('company_id', '=', self.company_id.id), ('company_id', '=', False),
|
'|', ('company_id', '=', self.company_id.id), ('company_id', '=', False),
|
||||||
], limit=1)
|
], limit=1)
|
||||||
|
|
||||||
|
if not product:
|
||||||
|
wc_name = line_item.get('name', 'WooCommerce Product')
|
||||||
|
wc_sku = line_item.get('sku', '')
|
||||||
|
wc_price = float(line_item.get('price', 0))
|
||||||
|
product = self.env['product.product'].create({
|
||||||
|
'name': wc_name.upper() if wc_name else 'WC PRODUCT',
|
||||||
|
'default_code': wc_sku,
|
||||||
|
'list_price': wc_price,
|
||||||
|
'type': 'consu',
|
||||||
|
})
|
||||||
|
if lookup_id:
|
||||||
|
self.env['woo.product.map'].create({
|
||||||
|
'instance_id': self.id,
|
||||||
|
'product_id': product.id,
|
||||||
|
'woo_product_id': lookup_id,
|
||||||
|
'woo_product_name': wc_name,
|
||||||
|
'woo_sku': wc_sku,
|
||||||
|
'woo_regular_price': wc_price,
|
||||||
|
'woo_product_type': 'simple',
|
||||||
|
'state': 'mapped',
|
||||||
|
'company_id': self.company_id.id,
|
||||||
|
})
|
||||||
|
_logger.info(
|
||||||
|
"Auto-created Odoo product '%s' (SKU: %s) for WC order line",
|
||||||
|
product.name, wc_sku,
|
||||||
|
)
|
||||||
|
|
||||||
vals = {
|
vals = {
|
||||||
'order_id': sale_order.id,
|
'order_id': sale_order.id,
|
||||||
'name': line_item.get('name', 'WooCommerce Product'),
|
'name': line_item.get('name', 'WooCommerce Product'),
|
||||||
|
'product_id': product.id,
|
||||||
'product_uom_qty': line_item.get('quantity', 1),
|
'product_uom_qty': line_item.get('quantity', 1),
|
||||||
'price_unit': float(line_item.get('price', 0)),
|
'price_unit': float(line_item.get('price', 0)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if product:
|
|
||||||
vals['product_id'] = product.id
|
|
||||||
|
|
||||||
# Tax mapping
|
# Tax mapping
|
||||||
taxes = []
|
taxes = []
|
||||||
for tax_entry in line_item.get('taxes', []):
|
for tax_entry in line_item.get('taxes', []):
|
||||||
@@ -891,15 +960,34 @@ class WooInstance(models.Model):
|
|||||||
|
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
def _get_service_product(self, name, internal_ref):
|
||||||
|
"""Find or create a generic service product (for shipping, fees, etc.)."""
|
||||||
|
product = self.env['product.product'].search([
|
||||||
|
('default_code', '=', internal_ref),
|
||||||
|
'|', ('company_id', '=', self.company_id.id), ('company_id', '=', False),
|
||||||
|
], limit=1)
|
||||||
|
if not product:
|
||||||
|
product = self.env['product.product'].create({
|
||||||
|
'name': name,
|
||||||
|
'default_code': internal_ref,
|
||||||
|
'type': 'service',
|
||||||
|
'list_price': 0,
|
||||||
|
'sale_ok': True,
|
||||||
|
'purchase_ok': False,
|
||||||
|
})
|
||||||
|
return product
|
||||||
|
|
||||||
def _prepare_shipping_line_vals(self, sale_order, shipping_line):
|
def _prepare_shipping_line_vals(self, sale_order, shipping_line):
|
||||||
"""Build sale.order.line vals from a WC shipping_lines entry."""
|
"""Build sale.order.line vals from a WC shipping_lines entry."""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
total = float(shipping_line.get('total', 0))
|
total = float(shipping_line.get('total', 0))
|
||||||
if not total:
|
if not total:
|
||||||
return False
|
return False
|
||||||
|
shipping_product = self._get_service_product('WC Shipping', 'WC-SHIPPING')
|
||||||
return {
|
return {
|
||||||
'order_id': sale_order.id,
|
'order_id': sale_order.id,
|
||||||
'name': shipping_line.get('method_title', 'Shipping'),
|
'name': shipping_line.get('method_title', 'Shipping'),
|
||||||
|
'product_id': shipping_product.id,
|
||||||
'product_uom_qty': 1,
|
'product_uom_qty': 1,
|
||||||
'price_unit': total,
|
'price_unit': total,
|
||||||
}
|
}
|
||||||
@@ -967,29 +1055,26 @@ class WooInstance(models.Model):
|
|||||||
('product_id', '!=', False),
|
('product_id', '!=', False),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
consecutive_errors = 0
|
||||||
for pm in maps:
|
for pm in maps:
|
||||||
try:
|
try:
|
||||||
wc_product = client.get_product(pm.woo_product_id)
|
wc_product = client.get_product(pm.woo_product_id)
|
||||||
|
consecutive_errors = 0
|
||||||
wc_price = float(wc_product.get('regular_price') or 0)
|
wc_price = float(wc_product.get('regular_price') or 0)
|
||||||
odoo_price = pm.product_id.list_price
|
odoo_price = pm.product_id.list_price
|
||||||
|
|
||||||
if abs(wc_price - odoo_price) < 0.01:
|
if abs(wc_price - odoo_price) < 0.01:
|
||||||
# Prices match — nothing to do
|
|
||||||
pm.last_synced = fields.Datetime.now()
|
pm.last_synced = fields.Datetime.now()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check if Odoo price was changed since last sync
|
|
||||||
odoo_changed = True
|
odoo_changed = True
|
||||||
woo_changed = True
|
woo_changed = True
|
||||||
|
|
||||||
if pm.last_synced:
|
if pm.last_synced:
|
||||||
# If product write_date is newer than last sync, Odoo changed
|
|
||||||
odoo_changed = pm.product_id.write_date > pm.last_synced
|
odoo_changed = pm.product_id.write_date > pm.last_synced
|
||||||
# WC always returns current price, assume changed if different
|
|
||||||
woo_changed = True
|
woo_changed = True
|
||||||
|
|
||||||
if odoo_changed and woo_changed:
|
if odoo_changed and woo_changed:
|
||||||
# Both changed — conflict
|
|
||||||
self.env['woo.conflict'].create({
|
self.env['woo.conflict'].create({
|
||||||
'instance_id': self.id,
|
'instance_id': self.id,
|
||||||
'conflict_type': 'product',
|
'conflict_type': 'product',
|
||||||
@@ -999,13 +1084,11 @@ class WooInstance(models.Model):
|
|||||||
'woo_value': str(wc_price),
|
'woo_value': str(wc_price),
|
||||||
'company_id': self.company_id.id,
|
'company_id': self.company_id.id,
|
||||||
})
|
})
|
||||||
# Keep state as mapped — conflict is tracked separately
|
|
||||||
self._log_sync(
|
self._log_sync(
|
||||||
'product', 'woo_to_odoo', pm.product_id.display_name,
|
'product', 'woo_to_odoo', pm.product_id.display_name,
|
||||||
'conflict', f'Price conflict: Odoo=${odoo_price}, WC=${wc_price}',
|
'conflict', f'Price conflict: Odoo=${odoo_price}, WC=${wc_price}',
|
||||||
)
|
)
|
||||||
elif odoo_changed:
|
elif odoo_changed:
|
||||||
# Odoo is authoritative — push to WC
|
|
||||||
client.update_product(pm.woo_product_id, {
|
client.update_product(pm.woo_product_id, {
|
||||||
'regular_price': str(odoo_price),
|
'regular_price': str(odoo_price),
|
||||||
})
|
})
|
||||||
@@ -1014,7 +1097,6 @@ class WooInstance(models.Model):
|
|||||||
'success', f'Price updated to ${odoo_price}',
|
'success', f'Price updated to ${odoo_price}',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# WC changed — pull into Odoo
|
|
||||||
pm.product_id.list_price = wc_price
|
pm.product_id.list_price = wc_price
|
||||||
self._log_sync(
|
self._log_sync(
|
||||||
'product', 'woo_to_odoo', pm.product_id.display_name,
|
'product', 'woo_to_odoo', pm.product_id.display_name,
|
||||||
@@ -1023,15 +1105,22 @@ class WooInstance(models.Model):
|
|||||||
|
|
||||||
pm.last_synced = fields.Datetime.now()
|
pm.last_synced = fields.Datetime.now()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
consecutive_errors += 1
|
||||||
_logger.error(
|
_logger.error(
|
||||||
"Product price sync failed for %s (WC#%s): %s",
|
"Product price sync failed for %s (WC#%s): %s",
|
||||||
pm.product_id.display_name, pm.woo_product_id, e,
|
pm.product_id.display_name, pm.woo_product_id, e,
|
||||||
)
|
)
|
||||||
# Don't change map state on sync errors — keep it mapped
|
|
||||||
self._log_sync(
|
self._log_sync(
|
||||||
'product', 'odoo_to_woo',
|
'product', 'odoo_to_woo',
|
||||||
pm.product_id.display_name, 'failed', str(e),
|
pm.product_id.display_name, 'failed', str(e),
|
||||||
)
|
)
|
||||||
|
if consecutive_errors >= self._MAX_CONSECUTIVE_ERRORS:
|
||||||
|
_logger.error(
|
||||||
|
"Aborting product sync after %d consecutive errors",
|
||||||
|
consecutive_errors)
|
||||||
|
self._log_sync('product', 'woo_to_odoo', self.name, 'failed',
|
||||||
|
'Aborted after %d consecutive API errors' % consecutive_errors)
|
||||||
|
return
|
||||||
|
|
||||||
def _sync_product_from_wc(self, wc_data):
|
def _sync_product_from_wc(self, wc_data):
|
||||||
"""Handle an inbound WC product webhook — update price if mapped."""
|
"""Handle an inbound WC product webhook — update price if mapped."""
|
||||||
@@ -1074,11 +1163,11 @@ class WooInstance(models.Model):
|
|||||||
('product_id', '!=', False),
|
('product_id', '!=', False),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
consecutive_errors = 0
|
||||||
for pm in maps:
|
for pm in maps:
|
||||||
try:
|
try:
|
||||||
product = pm.product_id
|
product = pm.product_id
|
||||||
if self.default_warehouse_id:
|
if self.default_warehouse_id:
|
||||||
# Get qty for specific warehouse
|
|
||||||
quant = self.env['stock.quant'].search([
|
quant = self.env['stock.quant'].search([
|
||||||
('product_id', '=', product.id),
|
('product_id', '=', product.id),
|
||||||
('location_id', 'child_of',
|
('location_id', 'child_of',
|
||||||
@@ -1094,12 +1183,14 @@ class WooInstance(models.Model):
|
|||||||
'stock_quantity': qty,
|
'stock_quantity': qty,
|
||||||
'manage_stock': True,
|
'manage_stock': True,
|
||||||
})
|
})
|
||||||
|
consecutive_errors = 0
|
||||||
pm.last_synced = fields.Datetime.now()
|
pm.last_synced = fields.Datetime.now()
|
||||||
self._log_sync(
|
self._log_sync(
|
||||||
'inventory', 'odoo_to_woo', product.display_name,
|
'inventory', 'odoo_to_woo', product.display_name,
|
||||||
'success', f'Stock set to {qty}',
|
'success', f'Stock set to {qty}',
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
consecutive_errors += 1
|
||||||
_logger.error(
|
_logger.error(
|
||||||
"Inventory sync failed for %s (WC#%s): %s",
|
"Inventory sync failed for %s (WC#%s): %s",
|
||||||
pm.product_id.display_name, pm.woo_product_id, e,
|
pm.product_id.display_name, pm.woo_product_id, e,
|
||||||
@@ -1108,6 +1199,13 @@ class WooInstance(models.Model):
|
|||||||
'inventory', 'odoo_to_woo',
|
'inventory', 'odoo_to_woo',
|
||||||
pm.product_id.display_name, 'failed', str(e),
|
pm.product_id.display_name, 'failed', str(e),
|
||||||
)
|
)
|
||||||
|
if consecutive_errors >= self._MAX_CONSECUTIVE_ERRORS:
|
||||||
|
_logger.error(
|
||||||
|
"Aborting inventory sync after %d consecutive errors",
|
||||||
|
consecutive_errors)
|
||||||
|
self._log_sync('inventory', 'odoo_to_woo', self.name, 'failed',
|
||||||
|
'Aborted after %d consecutive API errors' % consecutive_errors)
|
||||||
|
return
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Customer Sync (Task 25)
|
# Customer Sync (Task 25)
|
||||||
@@ -1122,10 +1220,10 @@ class WooInstance(models.Model):
|
|||||||
('woo_customer_id', '>', 0),
|
('woo_customer_id', '>', 0),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
consecutive_errors = 0
|
||||||
for cust in customers:
|
for cust in customers:
|
||||||
try:
|
try:
|
||||||
partner = cust.partner_id
|
partner = cust.partner_id
|
||||||
# Only sync if partner was modified since last sync
|
|
||||||
if cust.last_synced and partner.write_date <= cust.last_synced:
|
if cust.last_synced and partner.write_date <= cust.last_synced:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -1146,6 +1244,7 @@ class WooInstance(models.Model):
|
|||||||
'billing': billing_data,
|
'billing': billing_data,
|
||||||
'shipping': billing_data,
|
'shipping': billing_data,
|
||||||
})
|
})
|
||||||
|
consecutive_errors = 0
|
||||||
|
|
||||||
cust.last_synced = fields.Datetime.now()
|
cust.last_synced = fields.Datetime.now()
|
||||||
self._log_sync(
|
self._log_sync(
|
||||||
@@ -1153,6 +1252,7 @@ class WooInstance(models.Model):
|
|||||||
'success', 'Address updated in WooCommerce',
|
'success', 'Address updated in WooCommerce',
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
consecutive_errors += 1
|
||||||
_logger.error(
|
_logger.error(
|
||||||
"Customer sync failed for %s (WC#%s): %s",
|
"Customer sync failed for %s (WC#%s): %s",
|
||||||
cust.partner_id.display_name, cust.woo_customer_id, e,
|
cust.partner_id.display_name, cust.woo_customer_id, e,
|
||||||
@@ -1161,6 +1261,13 @@ class WooInstance(models.Model):
|
|||||||
'customer', 'odoo_to_woo',
|
'customer', 'odoo_to_woo',
|
||||||
cust.partner_id.display_name, 'failed', str(e),
|
cust.partner_id.display_name, 'failed', str(e),
|
||||||
)
|
)
|
||||||
|
if consecutive_errors >= self._MAX_CONSECUTIVE_ERRORS:
|
||||||
|
_logger.error(
|
||||||
|
"Aborting customer sync after %d consecutive errors",
|
||||||
|
consecutive_errors)
|
||||||
|
self._log_sync('customer', 'odoo_to_woo', self.name, 'failed',
|
||||||
|
'Aborted after %d consecutive API errors' % consecutive_errors)
|
||||||
|
return
|
||||||
|
|
||||||
def _sync_customer_from_wc(self, wc_data):
|
def _sync_customer_from_wc(self, wc_data):
|
||||||
"""Handle an inbound WC customer webhook — update partner if linked."""
|
"""Handle an inbound WC customer webhook — update partner if linked."""
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class WooProductMap(models.Model):
|
|||||||
woo_regular_price = fields.Float(string='WC Standard Price', digits='Product Price')
|
woo_regular_price = fields.Float(string='WC Standard Price', digits='Product Price')
|
||||||
woo_sale_price = fields.Float(string='WC Sale Price', digits='Product Price')
|
woo_sale_price = fields.Float(string='WC Sale Price', digits='Product Price')
|
||||||
woo_permalink = fields.Char(string='WC Product URL')
|
woo_permalink = fields.Char(string='WC Product URL')
|
||||||
|
woo_category_id = fields.Integer(string='WC Category ID')
|
||||||
|
woo_category_name = fields.Char(string='WC Category')
|
||||||
woo_parent_id = fields.Integer()
|
woo_parent_id = fields.Integer()
|
||||||
is_variation = fields.Boolean()
|
is_variation = fields.Boolean()
|
||||||
sync_price = fields.Boolean(default=True)
|
sync_price = fields.Boolean(default=True)
|
||||||
@@ -312,6 +314,54 @@ class WooProductMap(models.Model):
|
|||||||
pass
|
pass
|
||||||
return client.create_attribute_term(attr_id, {'name': term_name})
|
return client.create_attribute_term(attr_id, {'name': term_name})
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Create in Odoo (from unmapped WC product)
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
def action_create_in_odoo(self):
|
||||||
|
"""Create an Odoo product from WC mapping data, link the mapping, and
|
||||||
|
return the new product ID so the JS can open the form."""
|
||||||
|
self.ensure_one()
|
||||||
|
if self.product_id:
|
||||||
|
raise UserError("This mapping already has an Odoo product linked.")
|
||||||
|
|
||||||
|
wc_price = self.woo_sale_price or self.woo_regular_price or 0.0
|
||||||
|
|
||||||
|
# Resolve Odoo category from WC category mapping
|
||||||
|
categ_id = False
|
||||||
|
if self.woo_category_id and self.instance_id:
|
||||||
|
cat_map = self.env['woo.category.map'].search([
|
||||||
|
('instance_id', '=', self.instance_id.id),
|
||||||
|
('woo_category_id', '=', self.woo_category_id),
|
||||||
|
('odoo_category_id', '!=', False),
|
||||||
|
], limit=1)
|
||||||
|
if cat_map:
|
||||||
|
categ_id = cat_map.odoo_category_id.id
|
||||||
|
|
||||||
|
product_vals = {
|
||||||
|
'name': (self.woo_product_name or 'New Product').upper(),
|
||||||
|
'default_code': self.woo_sku or '',
|
||||||
|
'list_price': wc_price,
|
||||||
|
'type': 'consu',
|
||||||
|
}
|
||||||
|
if categ_id:
|
||||||
|
product_vals['categ_id'] = categ_id
|
||||||
|
|
||||||
|
product = self.env['product.product'].create(product_vals)
|
||||||
|
|
||||||
|
self.write({
|
||||||
|
'product_id': product.id,
|
||||||
|
'state': 'mapped',
|
||||||
|
})
|
||||||
|
|
||||||
|
if self.instance_id:
|
||||||
|
self.instance_id._log_sync(
|
||||||
|
'product', 'woo_to_odoo', product.name, 'success',
|
||||||
|
'Created Odoo product from WC #%s' % self.woo_product_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
return {'product_id': product.id}
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# SKU Sync
|
# SKU Sync
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,144 +1,37 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
Fusion WooCommerce — Theme-Aware Styles
|
Fusion WooCommerce — Layout-Only Styles
|
||||||
Uses Odoo's CSS custom properties for dark/light mode support.
|
All colors are inherited from Odoo's compiled theme.
|
||||||
Odoo 19 sets color_scheme cookie to "dark" or "bright" and
|
No CSS custom properties for colors — Odoo handles theming
|
||||||
applies .o_dark on the body or uses Bootstrap variables.
|
via SCSS compilation, not Bootstrap's data-bs-theme.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
CSS Custom Properties — light defaults, dark overrides
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
:root {
|
|
||||||
--woo-bg-primary: #ffffff;
|
|
||||||
--woo-bg-secondary: #f9fafb;
|
|
||||||
--woo-bg-tertiary: #f3f4f6;
|
|
||||||
--woo-bg-hover: #f3f4f6;
|
|
||||||
--woo-bg-selected: #ede9fe;
|
|
||||||
--woo-border: #e5e7eb;
|
|
||||||
--woo-border-light: #f3f4f6;
|
|
||||||
--woo-text-primary: #111827;
|
|
||||||
--woo-text-secondary: #374151;
|
|
||||||
--woo-text-muted: #6b7280;
|
|
||||||
--woo-text-faint: #9ca3af;
|
|
||||||
--woo-accent: #7c3aed;
|
|
||||||
--woo-accent-hover: #6d28d9;
|
|
||||||
--woo-accent-glow: rgba(124, 58, 237, 0.15);
|
|
||||||
--woo-success: #059669;
|
|
||||||
--woo-success-bg: #d1fae5;
|
|
||||||
--woo-success-text: #065f46;
|
|
||||||
--woo-warning: #d97706;
|
|
||||||
--woo-warning-bg: #fef3c7;
|
|
||||||
--woo-warning-text: #92400e;
|
|
||||||
--woo-danger: #dc2626;
|
|
||||||
--woo-danger-bg: #fee2e2;
|
|
||||||
--woo-danger-text: #991b1b;
|
|
||||||
--woo-info-bg: #dbeafe;
|
|
||||||
--woo-info-text: #1e40af;
|
|
||||||
--woo-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
|
|
||||||
--woo-card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
||||||
--woo-progress-bg: #e5e7eb;
|
|
||||||
--woo-spinner-track: #e5e7eb;
|
|
||||||
--woo-btn-secondary-bg: #ffffff;
|
|
||||||
--woo-btn-secondary-border: #d1d5db;
|
|
||||||
--woo-btn-secondary-hover: #f3f4f6;
|
|
||||||
--woo-input-bg: #ffffff;
|
|
||||||
--woo-input-border: #d1d5db;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Dark mode — theme_detect.js reads Odoo's color_scheme cookie and sets
|
|
||||||
data-woo-theme="dark" on <html>. We also include @media query as fallback. */
|
|
||||||
html[data-woo-theme="dark"],
|
|
||||||
html[style*="color-scheme: dark"] {
|
|
||||||
--woo-bg-primary: #1e1e2e;
|
|
||||||
--woo-bg-secondary: #262637;
|
|
||||||
--woo-bg-tertiary: #2e2e42;
|
|
||||||
--woo-bg-hover: #33334a;
|
|
||||||
--woo-bg-selected: #3b2d6b;
|
|
||||||
--woo-border: #3c3c54;
|
|
||||||
--woo-border-light: #33334a;
|
|
||||||
--woo-text-primary: #e4e4e7;
|
|
||||||
--woo-text-secondary: #c4c4cc;
|
|
||||||
--woo-text-muted: #9ca3af;
|
|
||||||
--woo-text-faint: #6b7280;
|
|
||||||
--woo-accent: #a78bfa;
|
|
||||||
--woo-accent-hover: #8b5cf6;
|
|
||||||
--woo-accent-glow: rgba(167, 139, 250, 0.2);
|
|
||||||
--woo-success: #34d399;
|
|
||||||
--woo-success-bg: #064e3b;
|
|
||||||
--woo-success-text: #6ee7b7;
|
|
||||||
--woo-warning: #fbbf24;
|
|
||||||
--woo-warning-bg: #451a03;
|
|
||||||
--woo-warning-text: #fcd34d;
|
|
||||||
--woo-danger: #f87171;
|
|
||||||
--woo-danger-bg: #450a0a;
|
|
||||||
--woo-danger-text: #fca5a5;
|
|
||||||
--woo-info-bg: #1e3a5f;
|
|
||||||
--woo-info-text: #93c5fd;
|
|
||||||
--woo-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
|
||||||
--woo-card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
|
|
||||||
--woo-progress-bg: #3c3c54;
|
|
||||||
--woo-spinner-track: #3c3c54;
|
|
||||||
--woo-btn-secondary-bg: #2e2e42;
|
|
||||||
--woo-btn-secondary-border: #3c3c54;
|
|
||||||
--woo-btn-secondary-hover: #33334a;
|
|
||||||
--woo-input-bg: #2e2e42;
|
|
||||||
--woo-input-border: #3c3c54;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Status badges
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.woo-badge {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 2px 10px;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 0.78rem;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: 0.02em;
|
|
||||||
}
|
|
||||||
.woo-badge-mapped, .woo-badge-success {
|
|
||||||
background: var(--woo-success-bg);
|
|
||||||
color: var(--woo-success-text);
|
|
||||||
}
|
|
||||||
.woo-badge-unmapped {
|
|
||||||
background: var(--woo-bg-tertiary);
|
|
||||||
color: var(--woo-text-muted);
|
|
||||||
}
|
|
||||||
.woo-badge-conflict {
|
|
||||||
background: var(--woo-warning-bg);
|
|
||||||
color: var(--woo-warning-text);
|
|
||||||
}
|
|
||||||
.woo-badge-error, .woo-badge-failed {
|
|
||||||
background: var(--woo-danger-bg);
|
|
||||||
color: var(--woo-danger-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Tab navigation
|
Tab navigation
|
||||||
---------------------------------------------------------- */
|
---------------------------------------------------------- */
|
||||||
.woo-tabs {
|
.woo-tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
border-bottom: 2px solid var(--woo-border);
|
border-bottom: 2px solid;
|
||||||
|
border-color: inherit;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
.woo-tab {
|
.woo-tab {
|
||||||
padding: 8px 20px;
|
padding: 8px 20px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--woo-text-muted);
|
opacity: 0.6;
|
||||||
|
border: none;
|
||||||
border-bottom: 2px solid transparent;
|
border-bottom: 2px solid transparent;
|
||||||
margin-bottom: -2px;
|
margin-bottom: -2px;
|
||||||
background: none;
|
background: none;
|
||||||
border-top: none;
|
color: inherit;
|
||||||
border-left: none;
|
transition: opacity 0.15s, border-color 0.15s;
|
||||||
border-right: none;
|
|
||||||
transition: color 0.15s, border-color 0.15s;
|
|
||||||
}
|
}
|
||||||
.woo-tab:hover { color: var(--woo-text-secondary); }
|
.woo-tab:hover { opacity: 0.85; }
|
||||||
.woo-tab.active {
|
.woo-tab.active {
|
||||||
color: var(--woo-accent);
|
opacity: 1;
|
||||||
border-bottom-color: var(--woo-accent);
|
font-weight: 600;
|
||||||
|
border-bottom-color: currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
@@ -149,34 +42,35 @@ html[style*="color-scheme: dark"] {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
background: var(--woo-bg-secondary);
|
border-bottom: 1px solid;
|
||||||
border-bottom: 1px solid var(--woo-border);
|
border-color: inherit;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
.woo-topbar select,
|
.woo-topbar select,
|
||||||
.woo-topbar input {
|
.woo-topbar input {
|
||||||
border: 1px solid var(--woo-input-border);
|
border: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
padding: 6px 10px;
|
padding: 6px 10px;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
background: var(--woo-input-bg);
|
background: inherit;
|
||||||
color: var(--woo-text-primary);
|
color: inherit;
|
||||||
}
|
}
|
||||||
.woo-stat {
|
.woo-stat {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 4px 14px;
|
padding: 4px 14px;
|
||||||
border-left: 1px solid var(--woo-border);
|
border-left: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
}
|
}
|
||||||
.woo-stat-value {
|
.woo-stat-value {
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--woo-text-primary);
|
|
||||||
}
|
}
|
||||||
.woo-stat-label {
|
.woo-stat-label {
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
color: var(--woo-text-muted);
|
opacity: 0.6;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.04em;
|
letter-spacing: 0.04em;
|
||||||
}
|
}
|
||||||
@@ -192,57 +86,59 @@ html[style*="color-scheme: dark"] {
|
|||||||
.woo-search-wrap .woo-search-icon {
|
.woo-search-wrap .woo-search-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
color: var(--woo-text-faint);
|
opacity: 0.5;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.woo-search-input {
|
.woo-search-input {
|
||||||
padding: 6px 10px 6px 32px;
|
padding: 6px 10px 6px 32px;
|
||||||
border: 1px solid var(--woo-input-border);
|
border: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
width: 240px;
|
width: 240px;
|
||||||
background: var(--woo-input-bg);
|
background: inherit;
|
||||||
color: var(--woo-text-primary);
|
color: inherit;
|
||||||
transition: border-color 0.15s;
|
|
||||||
}
|
}
|
||||||
.woo-search-input:focus {
|
.woo-search-input:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
border-color: var(--woo-accent);
|
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
|
||||||
box-shadow: 0 0 0 2px var(--woo-accent-glow);
|
|
||||||
}
|
|
||||||
.woo-search-input::placeholder {
|
|
||||||
color: var(--woo-text-faint);
|
|
||||||
}
|
}
|
||||||
|
.woo-search-input::placeholder { opacity: 0.5; }
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Tables
|
Tables
|
||||||
---------------------------------------------------------- */
|
---------------------------------------------------------- */
|
||||||
.woo-table-wrap {
|
.woo-table-wrap {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
|
border: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
.woo-table {
|
.woo-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
.woo-table th {
|
.woo-table th {
|
||||||
background: var(--woo-bg-tertiary);
|
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--woo-text-secondary);
|
border-bottom: 2px solid;
|
||||||
border-bottom: 2px solid var(--woo-border);
|
border-color: inherit;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
opacity: 0.85;
|
||||||
}
|
}
|
||||||
.woo-table td {
|
.woo-table td {
|
||||||
padding: 9px 12px;
|
padding: 9px 12px;
|
||||||
border-bottom: 1px solid var(--woo-border-light);
|
border-bottom: 1px solid;
|
||||||
color: var(--woo-text-secondary);
|
border-color: inherit;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.woo-table tr:hover td { background: var(--woo-bg-hover); }
|
.woo-table tbody tr:last-child td { border-bottom: none; }
|
||||||
.woo-table tr.selected td { background: var(--woo-bg-selected); }
|
.woo-table tr:hover td { opacity: 0.9; }
|
||||||
|
.woo-table tr.selected td { font-weight: 500; }
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Split view (unmatched tab)
|
Split view (unmatched tab)
|
||||||
@@ -254,17 +150,16 @@ html[style*="color-scheme: dark"] {
|
|||||||
align-items: start;
|
align-items: start;
|
||||||
}
|
}
|
||||||
.woo-split-panel {
|
.woo-split-panel {
|
||||||
border: 1px solid var(--woo-border);
|
border: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: var(--woo-bg-primary);
|
|
||||||
}
|
}
|
||||||
.woo-split-panel-header {
|
.woo-split-panel-header {
|
||||||
background: var(--woo-bg-tertiary);
|
|
||||||
padding: 10px 14px;
|
padding: 10px 14px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--woo-text-secondary);
|
border-bottom: 1px solid;
|
||||||
border-bottom: 1px solid var(--woo-border);
|
border-color: inherit;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -276,7 +171,7 @@ html[style*="color-scheme: dark"] {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding-top: 60px;
|
padding-top: 60px;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
color: var(--woo-text-faint);
|
opacity: 0.5;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
.woo-split-list {
|
.woo-split-list {
|
||||||
@@ -286,13 +181,15 @@ html[style*="color-scheme: dark"] {
|
|||||||
.woo-split-item {
|
.woo-split-item {
|
||||||
padding: 10px 14px;
|
padding: 10px 14px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-bottom: 1px solid var(--woo-border-light);
|
border-bottom: 1px solid;
|
||||||
transition: background 0.1s;
|
border-color: inherit;
|
||||||
|
transition: opacity 0.1s;
|
||||||
}
|
}
|
||||||
.woo-split-item:hover { background: var(--woo-bg-hover); }
|
.woo-split-item:last-child { border-bottom: none; }
|
||||||
.woo-split-item.selected { background: var(--woo-bg-selected); }
|
.woo-split-item:hover { opacity: 0.8; }
|
||||||
.woo-split-item-name { font-weight: 500; color: var(--woo-text-primary); }
|
.woo-split-item.selected { font-weight: 600; }
|
||||||
.woo-split-item-sub { font-size: 0.75rem; color: var(--woo-text-muted); margin-top: 1px; }
|
.woo-split-item-name { font-weight: 500; }
|
||||||
|
.woo-split-item-sub { font-size: 0.75rem; opacity: 0.6; margin-top: 1px; }
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Map actions bar
|
Map actions bar
|
||||||
@@ -302,52 +199,23 @@ html[style*="color-scheme: dark"] {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
padding: 10px 0 14px;
|
padding: 10px 0 14px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
border-bottom: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
|
margin-bottom: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Buttons
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.woo-btn {
|
|
||||||
padding: 6px 14px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
transition: background 0.15s, border-color 0.15s;
|
|
||||||
}
|
|
||||||
.woo-btn-primary { background: var(--woo-accent); color: #fff; border-color: var(--woo-accent); }
|
|
||||||
.woo-btn-primary:hover { background: var(--woo-accent-hover); }
|
|
||||||
.woo-btn-success { background: var(--woo-success); color: #fff; border-color: var(--woo-success); }
|
|
||||||
.woo-btn-success:hover { background: #047857; }
|
|
||||||
.woo-btn-warning { background: var(--woo-warning); color: #fff; border-color: var(--woo-warning); }
|
|
||||||
.woo-btn-warning:hover { background: #b45309; }
|
|
||||||
.woo-btn-danger { background: var(--woo-danger); color: #fff; border-color: var(--woo-danger); }
|
|
||||||
.woo-btn-danger:hover { background: #b91c1c; }
|
|
||||||
.woo-btn-secondary {
|
|
||||||
background: var(--woo-btn-secondary-bg);
|
|
||||||
color: var(--woo-text-secondary);
|
|
||||||
border-color: var(--woo-btn-secondary-border);
|
|
||||||
}
|
|
||||||
.woo-btn-secondary:hover { background: var(--woo-btn-secondary-hover); }
|
|
||||||
.woo-btn-sm { padding: 3px 10px; font-size: 0.8rem; }
|
|
||||||
.woo-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Dashboard cards
|
Dashboard cards
|
||||||
---------------------------------------------------------- */
|
---------------------------------------------------------- */
|
||||||
.woo-dashboard {
|
.woo-dashboard { padding: 20px; }
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.woo-dashboard-title {
|
.woo-dashboard-title {
|
||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--woo-text-primary);
|
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
.woo-dashboard-subtitle {
|
.woo-dashboard-subtitle {
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: var(--woo-text-muted);
|
opacity: 0.6;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
.woo-cards {
|
.woo-cards {
|
||||||
@@ -357,57 +225,43 @@ html[style*="color-scheme: dark"] {
|
|||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
.woo-card {
|
.woo-card {
|
||||||
background: var(--woo-bg-primary);
|
border: 1px solid;
|
||||||
border: 1px solid var(--woo-border);
|
border-color: inherit;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
box-shadow: var(--woo-card-shadow);
|
|
||||||
transition: box-shadow 0.15s;
|
|
||||||
}
|
}
|
||||||
.woo-card:hover { box-shadow: var(--woo-card-shadow-hover); }
|
|
||||||
.woo-card-clickable { cursor: pointer; }
|
.woo-card-clickable { cursor: pointer; }
|
||||||
.woo-card-icon {
|
.woo-card-clickable:hover { opacity: 0.85; }
|
||||||
font-size: 1.6rem;
|
.woo-card-icon { font-size: 1.6rem; margin-bottom: 4px; }
|
||||||
margin-bottom: 4px;
|
.woo-card-value { font-size: 2rem; font-weight: 700; line-height: 1; }
|
||||||
}
|
|
||||||
.woo-card-value {
|
|
||||||
font-size: 2rem;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
.woo-card-label {
|
.woo-card-label {
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
color: var(--woo-text-muted);
|
opacity: 0.6;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.04em;
|
letter-spacing: 0.04em;
|
||||||
}
|
}
|
||||||
.woo-card-sub {
|
.woo-card-sub { font-size: 0.78rem; opacity: 0.5; margin-top: 2px; }
|
||||||
font-size: 0.78rem;
|
.woo-card-pending { border-left-width: 4px; border-left-style: solid; }
|
||||||
color: var(--woo-text-faint);
|
.woo-card-errors { border-left-width: 4px; border-left-style: solid; }
|
||||||
margin-top: 2px;
|
.woo-card-mapped { border-left-width: 4px; border-left-style: solid; }
|
||||||
}
|
.woo-card-sync { border-left-width: 4px; border-left-style: solid; }
|
||||||
.woo-card-pending { border-left: 4px solid #f59e0b; }
|
|
||||||
.woo-card-errors { border-left: 4px solid #ef4444; }
|
|
||||||
.woo-card-mapped { border-left: 4px solid #10b981; }
|
|
||||||
.woo-card-sync { border-left: 4px solid #6366f1; }
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Progress bar
|
Progress bar
|
||||||
---------------------------------------------------------- */
|
---------------------------------------------------------- */
|
||||||
.woo-progress-wrap {
|
.woo-progress-wrap {
|
||||||
background: var(--woo-progress-bg);
|
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
|
opacity: 0.15;
|
||||||
|
background: currentColor;
|
||||||
}
|
}
|
||||||
.woo-progress-bar {
|
.woo-progress-bar {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: linear-gradient(90deg, #10b981, #059669);
|
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
transition: width 0.4s ease;
|
transition: width 0.4s ease;
|
||||||
}
|
}
|
||||||
@@ -420,15 +274,16 @@ html[style*="color-scheme: dark"] {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 40px;
|
padding: 40px;
|
||||||
color: var(--woo-text-muted);
|
opacity: 0.6;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
.woo-spinner {
|
.woo-spinner {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
border: 2px solid var(--woo-spinner-track);
|
border: 2px solid currentColor;
|
||||||
border-top-color: var(--woo-accent);
|
opacity: 0.3;
|
||||||
|
border-top-color: currentColor;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
animation: woo-spin 0.7s linear infinite;
|
animation: woo-spin 0.7s linear infinite;
|
||||||
}
|
}
|
||||||
@@ -440,7 +295,7 @@ html[style*="color-scheme: dark"] {
|
|||||||
.woo-empty {
|
.woo-empty {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 48px 20px;
|
padding: 48px 20px;
|
||||||
color: var(--woo-text-faint);
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
.woo-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
|
.woo-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
|
||||||
.woo-empty-text { font-size: 0.9rem; }
|
.woo-empty-text { font-size: 0.9rem; }
|
||||||
@@ -461,10 +316,10 @@ html[style*="color-scheme: dark"] {
|
|||||||
.woo-section-title {
|
.woo-section-title {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--woo-text-secondary);
|
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
border-bottom: 1px solid var(--woo-border-light);
|
border-bottom: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
@@ -477,82 +332,14 @@ html[style*="color-scheme: dark"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Theme-aware utility classes
|
Utility classes
|
||||||
---------------------------------------------------------- */
|
---------------------------------------------------------- */
|
||||||
.woo-text-muted { color: var(--woo-text-muted) !important; }
|
|
||||||
.woo-text-faint { color: var(--woo-text-faint) !important; }
|
|
||||||
|
|
||||||
/* Inline code snippets (SKU etc.) */
|
|
||||||
.woo-code {
|
.woo-code {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-size: 0.85em;
|
font-size: 0.85em;
|
||||||
padding: 1px 6px;
|
padding: 1px 6px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: var(--woo-bg-tertiary);
|
opacity: 0.8;
|
||||||
color: var(--woo-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Client action wrapper — ensure background matches theme
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.o_action.o_client_action .woo-dashboard,
|
|
||||||
.o_action.o_client_action .p-3 {
|
|
||||||
background: var(--woo-bg-primary);
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
min-height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Form view overrides — theme-aware inputs in Odoo forms
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.o_form_view .woo-table th {
|
|
||||||
background: var(--woo-bg-tertiary);
|
|
||||||
color: var(--woo-text-secondary);
|
|
||||||
}
|
|
||||||
.o_form_view .woo-table td {
|
|
||||||
color: var(--woo-text-secondary);
|
|
||||||
border-bottom-color: var(--woo-border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Checkbox overrides for dark mode
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.woo-table input[type="checkbox"],
|
|
||||||
.woo-topbar input[type="checkbox"] {
|
|
||||||
accent-color: var(--woo-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Select dropdown — theme aware
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.woo-topbar select {
|
|
||||||
background: var(--woo-input-bg);
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
border-color: var(--woo-input-border);
|
|
||||||
}
|
|
||||||
.woo-topbar select option {
|
|
||||||
background: var(--woo-bg-primary);
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Odoo native overrides for our views
|
|
||||||
These ensure Odoo's own notebook/tab/statusbar elements
|
|
||||||
inside our module's form views respect the theme.
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.o_form_view .o_notebook .nav-link {
|
|
||||||
color: var(--woo-text-muted);
|
|
||||||
}
|
|
||||||
.o_form_view .o_notebook .nav-link.active {
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
|
||||||
Ensure strong/bold text uses theme colour
|
|
||||||
---------------------------------------------------------- */
|
|
||||||
.woo-table strong,
|
|
||||||
.woo-card strong {
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
@@ -564,102 +351,58 @@ html[style*="color-scheme: dark"] {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 12px 0;
|
padding: 12px 0;
|
||||||
|
border-top: 1px solid;
|
||||||
|
border-color: inherit;
|
||||||
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
.woo-pagination-info {
|
.woo-pagination-info {
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
color: var(--woo-text-muted);
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Icon buttons (price sync arrows)
|
Icon buttons (sync arrows)
|
||||||
---------------------------------------------------------- */
|
---------------------------------------------------------- */
|
||||||
.woo-btn-icon {
|
.woo-btn-icon {
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
color: var(--woo-text-muted);
|
opacity: 0.5;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
transition: color 0.15s, background 0.15s;
|
color: inherit;
|
||||||
}
|
transition: opacity 0.15s;
|
||||||
.woo-btn-icon:hover {
|
|
||||||
color: var(--woo-accent);
|
|
||||||
background: var(--woo-bg-hover);
|
|
||||||
}
|
}
|
||||||
|
.woo-btn-icon:hover { opacity: 1; }
|
||||||
|
|
||||||
/* Product link to WooCommerce */
|
/* Product link to WooCommerce */
|
||||||
.woo-product-link {
|
.woo-product-link { text-decoration: none; }
|
||||||
color: var(--woo-accent);
|
.woo-product-link:hover { text-decoration: underline; }
|
||||||
text-decoration: none;
|
.woo-external-icon { font-size: 0.7rem; opacity: 0.5; }
|
||||||
transition: color 0.15s;
|
.woo-product-link:hover .woo-external-icon { opacity: 1; }
|
||||||
}
|
|
||||||
.woo-product-link:hover {
|
|
||||||
color: var(--woo-accent-hover);
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
.woo-external-icon {
|
|
||||||
font-size: 0.7rem;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
.woo-product-link:hover .woo-external-icon {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sale price highlight */
|
/* Sale price highlight */
|
||||||
.woo-sale-price {
|
.woo-sale-price { font-weight: 600; }
|
||||||
color: var(--woo-success);
|
.woo-price-sync-col { width: 60px; white-space: nowrap; }
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.woo-price-sync-col {
|
|
||||||
width: 60px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
Editable price cells
|
Editable price cells
|
||||||
---------------------------------------------------------- */
|
---------------------------------------------------------- */
|
||||||
.woo-editable-cell {
|
.woo-editable-cell { cursor: pointer; position: relative; }
|
||||||
cursor: pointer;
|
.woo-editable-cell:hover { opacity: 0.8; }
|
||||||
position: relative;
|
.woo-margin-cell { font-weight: 600; }
|
||||||
}
|
|
||||||
.woo-editable-cell:hover {
|
|
||||||
background: var(--woo-bg-hover) !important;
|
|
||||||
}
|
|
||||||
.woo-margin-cell {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--woo-success);
|
|
||||||
}
|
|
||||||
|
|
||||||
.woo-edit-input {
|
.woo-edit-input {
|
||||||
width: 90px;
|
width: 90px;
|
||||||
padding: 2px 6px;
|
padding: 2px 6px;
|
||||||
border: 1px solid var(--woo-accent);
|
border: 2px solid;
|
||||||
|
border-color: inherit;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
background: var(--woo-input-bg);
|
background: inherit;
|
||||||
color: var(--woo-text-primary);
|
color: inherit;
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: 0 0 0 2px var(--woo-accent-glow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Category filter dropdown */
|
|
||||||
.woo-filter-select {
|
|
||||||
padding: 3px 8px;
|
|
||||||
border: 1px solid var(--woo-input-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
background: var(--woo-input-bg);
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
max-width: 200px;
|
|
||||||
}
|
|
||||||
.woo-filter-select option {
|
|
||||||
background: var(--woo-bg-primary);
|
|
||||||
color: var(--woo-text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.woo-edit-input-text {
|
|
||||||
text-align: left;
|
|
||||||
width: 120px;
|
|
||||||
}
|
}
|
||||||
|
.woo-edit-input-text { text-align: left; width: 120px; }
|
||||||
|
|||||||
@@ -492,7 +492,38 @@ export class ProductMapping extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createInOdoo(wooMapId) {
|
async createInOdoo(wooMapId) {
|
||||||
this.notification.add("Create in Odoo queued.", { type: "info" });
|
if (!this.state.instanceId) {
|
||||||
|
this.notification.add("Please select an instance first.", { type: "warning" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const result = await rpc("/web/dataset/call_kw", {
|
||||||
|
model: "woo.product.map",
|
||||||
|
method: "action_create_in_odoo",
|
||||||
|
args: [[wooMapId]],
|
||||||
|
kwargs: {},
|
||||||
|
});
|
||||||
|
if (!result || !result.product_id) {
|
||||||
|
this.notification.add("Failed to create product.", { type: "danger" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.notification.add("Product created and mapped. Opening for editing…", { type: "success" });
|
||||||
|
this.actionService.doAction({
|
||||||
|
type: 'ir.actions.act_window',
|
||||||
|
res_model: 'product.product',
|
||||||
|
res_id: result.product_id,
|
||||||
|
views: [[false, 'form']],
|
||||||
|
target: 'new',
|
||||||
|
context: { form_view_initial_mode: 'edit' },
|
||||||
|
}, {
|
||||||
|
onClose: async () => {
|
||||||
|
await this._refreshAll();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[ProductMapping] createInOdoo error:", err);
|
||||||
|
this.notification.add(err.message || "Failed to create product in Odoo.", { type: "danger" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async ignoreWoo(wooMapId) {
|
async ignoreWoo(wooMapId) {
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
/** @odoo-module **/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Theme detection for Fusion WooCommerce.
|
|
||||||
*
|
|
||||||
* Odoo 19 stores dark mode preference in the "color_scheme" cookie ("dark" or "bright").
|
|
||||||
* It also sets `color-scheme: dark` on .o_web_client via SCSS.
|
|
||||||
*
|
|
||||||
* This script reads the cookie and adds a `data-woo-theme="dark"` attribute on <html>
|
|
||||||
* so our CSS can target it reliably. It also observes for changes (user toggles theme).
|
|
||||||
*/
|
|
||||||
import { cookie } from "@web/core/browser/cookie";
|
|
||||||
|
|
||||||
function applyTheme() {
|
|
||||||
const scheme = cookie.get("color_scheme");
|
|
||||||
const isDark = scheme === "dark";
|
|
||||||
document.documentElement.setAttribute("data-woo-theme", isDark ? "dark" : "light");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply on load
|
|
||||||
applyTheme();
|
|
||||||
|
|
||||||
// Re-apply periodically in case user toggles theme mid-session
|
|
||||||
// (Odoo doesn't fire a DOM event for this, so we poll the cookie)
|
|
||||||
setInterval(applyTheme, 2000);
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<div class="woo-cards">
|
<div class="woo-cards">
|
||||||
|
|
||||||
<!-- Pending orders -->
|
<!-- Pending orders -->
|
||||||
<div class="woo-card woo-card-pending woo-card-clickable"
|
<div class="woo-card border-start border-warning border-3 woo-card-clickable"
|
||||||
t-on-click="openOrders">
|
t-on-click="openOrders">
|
||||||
<div class="woo-card-icon">🛒</div>
|
<div class="woo-card-icon">🛒</div>
|
||||||
<div class="woo-card-value" t-esc="state.pendingOrders"/>
|
<div class="woo-card-value" t-esc="state.pendingOrders"/>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Last sync -->
|
<!-- Last sync -->
|
||||||
<div class="woo-card woo-card-sync">
|
<div class="woo-card border-start border-info border-3">
|
||||||
<div class="woo-card-icon">🔄</div>
|
<div class="woo-card-icon">🔄</div>
|
||||||
<div class="woo-card-value" style="font-size:1.1rem;" t-esc="lastSyncRelative"/>
|
<div class="woo-card-value" style="font-size:1.1rem;" t-esc="lastSyncRelative"/>
|
||||||
<div class="woo-card-label">Last Sync</div>
|
<div class="woo-card-label">Last Sync</div>
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Errors -->
|
<!-- Errors -->
|
||||||
<div class="woo-card woo-card-errors woo-card-clickable"
|
<div class="woo-card border-start border-danger border-3 woo-card-clickable"
|
||||||
t-on-click="openSyncLogs">
|
t-on-click="openSyncLogs">
|
||||||
<div class="woo-card-icon">⚠️</div>
|
<div class="woo-card-icon">⚠️</div>
|
||||||
<div class="woo-card-value" t-esc="state.errors24h"/>
|
<div class="woo-card-value" t-esc="state.errors24h"/>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Products mapped -->
|
<!-- Products mapped -->
|
||||||
<div class="woo-card woo-card-mapped">
|
<div class="woo-card border-start border-success border-3">
|
||||||
<div class="woo-card-icon">🔗</div>
|
<div class="woo-card-icon">🔗</div>
|
||||||
<div class="woo-card-value">
|
<div class="woo-card-value">
|
||||||
<t t-esc="mappedPercent"/>%
|
<t t-esc="mappedPercent"/>%
|
||||||
@@ -75,19 +75,19 @@
|
|||||||
<div class="woo-section-title">Quick Actions</div>
|
<div class="woo-section-title">Quick Actions</div>
|
||||||
<div class="woo-quick-actions">
|
<div class="woo-quick-actions">
|
||||||
|
|
||||||
<button class="woo-btn woo-btn-primary" t-on-click="syncNow">
|
<button class="btn btn-primary" t-on-click="syncNow">
|
||||||
<i class="fa fa-refresh me-1"/> Sync Now
|
<i class="fa fa-refresh me-1"/> Sync Now
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="woo-btn woo-btn-warning" t-on-click="openConflicts">
|
<button class="btn btn-warning" t-on-click="openConflicts">
|
||||||
<i class="fa fa-exclamation-triangle me-1"/> View Conflicts
|
<i class="fa fa-exclamation-triangle me-1"/> View Conflicts
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="woo-btn woo-btn-secondary" t-on-click="openMapping">
|
<button class="btn btn-secondary" t-on-click="openMapping">
|
||||||
<i class="fa fa-th-list me-1"/> Open Product Mapping
|
<i class="fa fa-th-list me-1"/> Open Product Mapping
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="woo-btn woo-btn-secondary" t-on-click="openOrders">
|
<button class="btn btn-secondary" t-on-click="openOrders">
|
||||||
<i class="fa fa-shopping-cart me-1"/> View Orders
|
<i class="fa fa-shopping-cart me-1"/> View Orders
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -111,13 +111,13 @@
|
|||||||
<td><strong><t t-esc="inst.name"/></strong></td>
|
<td><strong><t t-esc="inst.name"/></strong></td>
|
||||||
<td>
|
<td>
|
||||||
<t t-if="inst.state === 'connected'">
|
<t t-if="inst.state === 'connected'">
|
||||||
<span class="woo-badge woo-badge-mapped">Connected</span>
|
<span class="badge text-bg-success">Connected</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-elif="inst.state === 'error'">
|
<t t-elif="inst.state === 'error'">
|
||||||
<span class="woo-badge woo-badge-error">Error</span>
|
<span class="badge text-bg-danger">Error</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-else="">
|
<t t-else="">
|
||||||
<span class="woo-badge woo-badge-unmapped">Draft</span>
|
<span class="badge text-bg-secondary">Draft</span>
|
||||||
</t>
|
</t>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
<t t-esc="inst.last_sync"/>
|
<t t-esc="inst.last_sync"/>
|
||||||
</t>
|
</t>
|
||||||
<t t-else="">
|
<t t-else="">
|
||||||
<span class="woo-text-muted">Never</span>
|
<span class="text-muted">Never</span>
|
||||||
</t>
|
</t>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -36,15 +36,15 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- Fetch / Sync buttons -->
|
<!-- Fetch / Sync buttons -->
|
||||||
<button class="woo-btn woo-btn-secondary" t-on-click="fetchProducts"
|
<button class="btn btn-secondary" t-on-click="fetchProducts"
|
||||||
t-att-disabled="state.loading">
|
t-att-disabled="state.loading">
|
||||||
<i class="fa fa-download me-1"/> Fetch Products
|
<i class="fa fa-download me-1"/> Fetch Products
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-primary" t-on-click="syncNow"
|
<button class="btn btn-primary" t-on-click="syncNow"
|
||||||
t-att-disabled="state.loading">
|
t-att-disabled="state.loading">
|
||||||
<i class="fa fa-refresh me-1"/> Sync Now
|
<i class="fa fa-refresh me-1"/> Sync Now
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-secondary" t-on-click="refreshPrices"
|
<button class="btn btn-secondary" t-on-click="refreshPrices"
|
||||||
t-att-disabled="state.loading">
|
t-att-disabled="state.loading">
|
||||||
<i class="fa fa-dollar me-1"/> Refresh Prices
|
<i class="fa fa-dollar me-1"/> Refresh Prices
|
||||||
</button>
|
</button>
|
||||||
@@ -82,17 +82,17 @@
|
|||||||
<button class="woo-tab" t-att-class="state.activeTab === 'mapped' ? 'active' : ''"
|
<button class="woo-tab" t-att-class="state.activeTab === 'mapped' ? 'active' : ''"
|
||||||
t-on-click="() => this.setTab('mapped')">
|
t-on-click="() => this.setTab('mapped')">
|
||||||
Mapped Products
|
Mapped Products
|
||||||
<span class="ms-1 woo-badge woo-badge-mapped" t-esc="state.mappedTotal"/>
|
<span class="ms-1 badge text-bg-success" t-esc="state.mappedTotal"/>
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-tab" t-att-class="state.activeTab === 'unmatched' ? 'active' : ''"
|
<button class="woo-tab" t-att-class="state.activeTab === 'unmatched' ? 'active' : ''"
|
||||||
t-on-click="() => this.setTab('unmatched')">
|
t-on-click="() => this.setTab('unmatched')">
|
||||||
Unmatched Products
|
Unmatched Products
|
||||||
<span class="ms-1 woo-badge woo-badge-unmapped" t-esc="state.unmatchedWooTotal"/>
|
<span class="ms-1 badge text-bg-secondary" t-esc="state.unmatchedWooTotal"/>
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-tab" t-att-class="state.activeTab === 'conflicts' ? 'active' : ''"
|
<button class="woo-tab" t-att-class="state.activeTab === 'conflicts' ? 'active' : ''"
|
||||||
t-on-click="() => this.setTab('conflicts')">
|
t-on-click="() => this.setTab('conflicts')">
|
||||||
Conflicts
|
Conflicts
|
||||||
<span class="ms-1 woo-badge woo-badge-conflict" t-esc="state.conflictCount"/>
|
<span class="ms-1 badge text-bg-warning" t-esc="state.conflictCount"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -105,26 +105,26 @@
|
|||||||
endpoint="'/woo/search/mapped'"
|
endpoint="'/woo/search/mapped'"
|
||||||
t-props="{ instanceId: state.instanceId, onResults: onMappedResults.bind(this), placeholder: 'Search mapped products…' }"
|
t-props="{ instanceId: state.instanceId, onResults: onMappedResults.bind(this), placeholder: 'Search mapped products…' }"
|
||||||
/>
|
/>
|
||||||
<button class="woo-btn woo-btn-danger woo-btn-sm"
|
<button class="btn btn-outline-danger btn-sm"
|
||||||
t-on-click="unmapSelected"
|
t-on-click="unmapSelected"
|
||||||
t-att-disabled="!state.selectedMapped.length">
|
t-att-disabled="!state.selectedMapped.length">
|
||||||
<i class="fa fa-unlink me-1"/> Unmap Selected
|
<i class="fa fa-unlink me-1"/> Unmap Selected
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-success woo-btn-sm"
|
<button class="btn btn-success btn-sm"
|
||||||
t-on-click="syncSelected"
|
t-on-click="syncSelected"
|
||||||
t-att-disabled="!state.selectedMapped.length">
|
t-att-disabled="!state.selectedMapped.length">
|
||||||
<i class="fa fa-refresh me-1"/> Sync Selected
|
<i class="fa fa-refresh me-1"/> Sync Selected
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="bulkPriceOdooToWC">
|
<button class="btn btn-secondary btn-sm" t-on-click="bulkPriceOdooToWC">
|
||||||
<i class="fa fa-arrow-right me-1"/> All Prices Odoo → WC
|
<i class="fa fa-arrow-right me-1"/> All Prices Odoo → WC
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="bulkPriceWCToOdoo">
|
<button class="btn btn-secondary btn-sm" t-on-click="bulkPriceWCToOdoo">
|
||||||
<i class="fa fa-arrow-left me-1"/> All Prices WC → Odoo
|
<i class="fa fa-arrow-left me-1"/> All Prices WC → Odoo
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="bulkSkuOdooToWC">
|
<button class="btn btn-secondary btn-sm" t-on-click="bulkSkuOdooToWC">
|
||||||
<i class="fa fa-arrow-right me-1"/> All SKUs Odoo → WC
|
<i class="fa fa-arrow-right me-1"/> All SKUs Odoo → WC
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="bulkSkuWCToOdoo">
|
<button class="btn btn-secondary btn-sm" t-on-click="bulkSkuWCToOdoo">
|
||||||
<i class="fa fa-arrow-left me-1"/> All SKUs WC → Odoo
|
<i class="fa fa-arrow-left me-1"/> All SKUs WC → Odoo
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -211,8 +211,8 @@
|
|||||||
<td>
|
<td>
|
||||||
<t t-esc="p.odoo_product_name"/>
|
<t t-esc="p.odoo_product_name"/>
|
||||||
<t t-if="p.odoo_variant_count > 1 and !p.is_variation">
|
<t t-if="p.odoo_variant_count > 1 and !p.is_variation">
|
||||||
<button class="woo-btn woo-btn-sm ms-2"
|
<button class="btn btn-sm ms-2"
|
||||||
t-att-class="p.needs_variant_push ? 'woo-btn woo-btn-primary woo-btn-sm ms-2' : 'woo-btn woo-btn-secondary woo-btn-sm ms-2'"
|
t-att-class="p.needs_variant_push ? 'btn btn-primary btn-sm ms-2' : 'btn btn-secondary btn-sm ms-2'"
|
||||||
t-on-click.stop="() => this.pushVariantsToWC(p.id)"
|
t-on-click.stop="() => this.pushVariantsToWC(p.id)"
|
||||||
title="Manage variants — create new or update existing">
|
title="Manage variants — create new or update existing">
|
||||||
<i class="fa fa-sitemap me-1"/>
|
<i class="fa fa-sitemap me-1"/>
|
||||||
@@ -242,9 +242,9 @@
|
|||||||
</t>
|
</t>
|
||||||
<t t-else="">
|
<t t-else="">
|
||||||
<t t-if="p.woo_sale_price">
|
<t t-if="p.woo_sale_price">
|
||||||
<span class="woo-sale-price" t-esc="this.formatPrice(p.woo_sale_price)"/>
|
<span class="text-success fw-bold" t-esc="this.formatPrice(p.woo_sale_price)"/>
|
||||||
</t>
|
</t>
|
||||||
<t t-else=""><span class="woo-text-muted">—</span></t>
|
<t t-else=""><span class="text-muted">—</span></t>
|
||||||
</t>
|
</t>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center woo-price-sync-col">
|
<td class="text-center woo-price-sync-col">
|
||||||
@@ -279,7 +279,7 @@
|
|||||||
</t>
|
</t>
|
||||||
<t t-else="" t-esc="this.formatPrice(p.odoo_cost)"/>
|
<t t-else="" t-esc="this.formatPrice(p.odoo_cost)"/>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-end woo-editable-cell woo-margin-cell" t-on-click.stop="() => this.startEdit(p.id, 'margin', this.calcMargin(p.odoo_cost, p.odoo_price))">
|
<td class="text-end woo-editable-cell text-success fw-bold" t-on-click.stop="() => this.startEdit(p.id, 'margin', this.calcMargin(p.odoo_cost, p.odoo_price))">
|
||||||
<t t-if="this.isEditing(p.id, 'margin')">
|
<t t-if="this.isEditing(p.id, 'margin')">
|
||||||
<input type="number" step="1" min="0" max="99" class="woo-edit-input"
|
<input type="number" step="1" min="0" max="99" class="woo-edit-input"
|
||||||
t-att-value="state.editValue"
|
t-att-value="state.editValue"
|
||||||
@@ -307,7 +307,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="woo-pagination">
|
<div class="woo-pagination">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="mappedPrevPage"
|
<button class="btn btn-secondary btn-sm" t-on-click="mappedPrevPage"
|
||||||
t-att-disabled="state.mappedPage <= 1">
|
t-att-disabled="state.mappedPage <= 1">
|
||||||
<i class="fa fa-chevron-left"/> Prev
|
<i class="fa fa-chevron-left"/> Prev
|
||||||
</button>
|
</button>
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
Page <t t-esc="state.mappedPage"/> of <t t-esc="mappedTotalPages"/>
|
Page <t t-esc="state.mappedPage"/> of <t t-esc="mappedTotalPages"/>
|
||||||
(<t t-esc="state.mappedTotal"/> total)
|
(<t t-esc="state.mappedTotal"/> total)
|
||||||
</span>
|
</span>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="mappedNextPage"
|
<button class="btn btn-secondary btn-sm" t-on-click="mappedNextPage"
|
||||||
t-att-disabled="state.mappedPage >= mappedTotalPages">
|
t-att-disabled="state.mappedPage >= mappedTotalPages">
|
||||||
Next <i class="fa fa-chevron-right"/>
|
Next <i class="fa fa-chevron-right"/>
|
||||||
</button>
|
</button>
|
||||||
@@ -329,13 +329,13 @@
|
|||||||
<t t-if="state.activeTab === 'unmatched'">
|
<t t-if="state.activeTab === 'unmatched'">
|
||||||
<!-- Map action bar -->
|
<!-- Map action bar -->
|
||||||
<div class="woo-map-actions">
|
<div class="woo-map-actions">
|
||||||
<button class="woo-btn woo-btn-primary"
|
<button class="btn btn-primary"
|
||||||
t-on-click="mapSelected"
|
t-on-click="mapSelected"
|
||||||
t-att-disabled="!canMap">
|
t-att-disabled="!canMap">
|
||||||
<i class="fa fa-link me-1"/> Map Selected
|
<i class="fa fa-link me-1"/> Map Selected
|
||||||
</button>
|
</button>
|
||||||
<t t-if="!canMap">
|
<t t-if="!canMap">
|
||||||
<small class="woo-text-muted align-self-center">
|
<small class="text-muted align-self-center">
|
||||||
Select one Odoo product and one WooCommerce product to map them.
|
Select one Odoo product and one WooCommerce product to map them.
|
||||||
</small>
|
</small>
|
||||||
</t>
|
</t>
|
||||||
@@ -347,7 +347,7 @@
|
|||||||
<div class="woo-split-panel-header" style="flex-wrap: wrap; gap: 6px;">
|
<div class="woo-split-panel-header" style="flex-wrap: wrap; gap: 6px;">
|
||||||
<span>Odoo Products</span>
|
<span>Odoo Products</span>
|
||||||
<div class="d-flex gap-2 align-items-center">
|
<div class="d-flex gap-2 align-items-center">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm"
|
<button class="btn btn-secondary btn-sm"
|
||||||
t-on-click="openCategoryFilter"
|
t-on-click="openCategoryFilter"
|
||||||
title="Manage hidden categories">
|
title="Manage hidden categories">
|
||||||
<i class="fa fa-filter me-1"/>
|
<i class="fa fa-filter me-1"/>
|
||||||
@@ -357,7 +357,7 @@
|
|||||||
</t>
|
</t>
|
||||||
</button>
|
</button>
|
||||||
<t t-if="state.excludedCategoryCount">
|
<t t-if="state.excludedCategoryCount">
|
||||||
<button t-att-class="'woo-btn woo-btn-sm ' + (state.categoryFilterActive ? 'woo-btn-primary' : 'woo-btn-secondary')"
|
<button t-att-class="'btn btn-sm ' + (state.categoryFilterActive ? 'btn-primary' : 'btn-secondary')"
|
||||||
t-on-click="toggleCategoryFilter"
|
t-on-click="toggleCategoryFilter"
|
||||||
t-att-title="state.categoryFilterActive ? 'Filter active — click to show all' : 'Filter off — click to hide categories'">
|
t-att-title="state.categoryFilterActive ? 'Filter active — click to show all' : 'Filter off — click to hide categories'">
|
||||||
<i t-att-class="'fa ' + (state.categoryFilterActive ? 'fa-eye-slash' : 'fa-eye')"/>
|
<i t-att-class="'fa ' + (state.categoryFilterActive ? 'fa-eye-slash' : 'fa-eye')"/>
|
||||||
@@ -382,7 +382,7 @@
|
|||||||
<div class="woo-split-item-name">
|
<div class="woo-split-item-name">
|
||||||
<t t-esc="op.name"/>
|
<t t-esc="op.name"/>
|
||||||
<t t-if="op.has_variants">
|
<t t-if="op.has_variants">
|
||||||
<span class="woo-badge woo-badge-unmapped ms-2">
|
<span class="badge text-bg-secondary ms-2">
|
||||||
<t t-esc="op.variant_count"/> variants
|
<t t-esc="op.variant_count"/> variants
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
@@ -396,7 +396,7 @@
|
|||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
<div class="woo-pagination">
|
<div class="woo-pagination">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="unmatchedOdooPrevPage"
|
<button class="btn btn-secondary btn-sm" t-on-click="unmatchedOdooPrevPage"
|
||||||
t-att-disabled="state.unmatchedOdooPage <= 1">
|
t-att-disabled="state.unmatchedOdooPage <= 1">
|
||||||
<i class="fa fa-chevron-left"/> Prev
|
<i class="fa fa-chevron-left"/> Prev
|
||||||
</button>
|
</button>
|
||||||
@@ -404,7 +404,7 @@
|
|||||||
Page <t t-esc="state.unmatchedOdooPage"/> of <t t-esc="unmatchedOdooTotalPages"/>
|
Page <t t-esc="state.unmatchedOdooPage"/> of <t t-esc="unmatchedOdooTotalPages"/>
|
||||||
(<t t-esc="state.unmatchedOdooTotal"/> total)
|
(<t t-esc="state.unmatchedOdooTotal"/> total)
|
||||||
</span>
|
</span>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="unmatchedOdooNextPage"
|
<button class="btn btn-secondary btn-sm" t-on-click="unmatchedOdooNextPage"
|
||||||
t-att-disabled="state.unmatchedOdooPage >= unmatchedOdooTotalPages">
|
t-att-disabled="state.unmatchedOdooPage >= unmatchedOdooTotalPages">
|
||||||
Next <i class="fa fa-chevron-right"/>
|
Next <i class="fa fa-chevron-right"/>
|
||||||
</button>
|
</button>
|
||||||
@@ -413,7 +413,7 @@
|
|||||||
|
|
||||||
<!-- Divider -->
|
<!-- Divider -->
|
||||||
<div class="woo-split-divider">
|
<div class="woo-split-divider">
|
||||||
<i class="fa fa-exchange woo-text-muted"/>
|
<i class="fa fa-exchange text-muted"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- WooCommerce products panel -->
|
<!-- WooCommerce products panel -->
|
||||||
@@ -439,14 +439,15 @@
|
|||||||
<div class="woo-split-item-sub">
|
<div class="woo-split-item-sub">
|
||||||
<t t-if="wp.woo_sku">SKU: <t t-esc="wp.woo_sku"/> · </t>
|
<t t-if="wp.woo_sku">SKU: <t t-esc="wp.woo_sku"/> · </t>
|
||||||
<t t-esc="wp.woo_product_type"/>
|
<t t-esc="wp.woo_product_type"/>
|
||||||
|
<t t-if="wp.woo_category_name"> · <t t-esc="wp.woo_category_name"/></t>
|
||||||
</div>
|
</div>
|
||||||
<!-- Per-item actions -->
|
<!-- Per-item actions -->
|
||||||
<div class="mt-1 d-flex gap-1">
|
<div class="mt-1 d-flex gap-1">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm"
|
<button class="btn btn-secondary btn-sm"
|
||||||
t-on-click.stop="() => this.createInOdoo(wp.id)">
|
t-on-click.stop="() => this.createInOdoo(wp.id)">
|
||||||
Create in Odoo
|
<i class="fa fa-plus me-1"/>Create & Edit in Odoo
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-danger woo-btn-sm"
|
<button class="btn btn-outline-danger btn-sm"
|
||||||
t-on-click.stop="() => this.ignoreWoo(wp.id)">
|
t-on-click.stop="() => this.ignoreWoo(wp.id)">
|
||||||
Ignore
|
Ignore
|
||||||
</button>
|
</button>
|
||||||
@@ -455,7 +456,7 @@
|
|||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
<div class="woo-pagination">
|
<div class="woo-pagination">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="unmatchedWooPrevPage"
|
<button class="btn btn-secondary btn-sm" t-on-click="unmatchedWooPrevPage"
|
||||||
t-att-disabled="state.unmatchedWooPage <= 1">
|
t-att-disabled="state.unmatchedWooPage <= 1">
|
||||||
<i class="fa fa-chevron-left"/> Prev
|
<i class="fa fa-chevron-left"/> Prev
|
||||||
</button>
|
</button>
|
||||||
@@ -463,7 +464,7 @@
|
|||||||
Page <t t-esc="state.unmatchedWooPage"/> of <t t-esc="unmatchedWooTotalPages"/>
|
Page <t t-esc="state.unmatchedWooPage"/> of <t t-esc="unmatchedWooTotalPages"/>
|
||||||
(<t t-esc="state.unmatchedWooTotal"/> total)
|
(<t t-esc="state.unmatchedWooTotal"/> total)
|
||||||
</span>
|
</span>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm" t-on-click="unmatchedWooNextPage"
|
<button class="btn btn-secondary btn-sm" t-on-click="unmatchedWooNextPage"
|
||||||
t-att-disabled="state.unmatchedWooPage >= unmatchedWooTotalPages">
|
t-att-disabled="state.unmatchedWooPage >= unmatchedWooTotalPages">
|
||||||
Next <i class="fa fa-chevron-right"/>
|
Next <i class="fa fa-chevron-right"/>
|
||||||
</button>
|
</button>
|
||||||
@@ -474,7 +475,7 @@
|
|||||||
<!-- Odoo-only actions (create in WC) shown below list -->
|
<!-- Odoo-only actions (create in WC) shown below list -->
|
||||||
<t t-if="state.selectedOdooId">
|
<t t-if="state.selectedOdooId">
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm"
|
<button class="btn btn-secondary btn-sm"
|
||||||
t-on-click="() => this.createInWC(state.selectedOdooId)">
|
t-on-click="() => this.createInWC(state.selectedOdooId)">
|
||||||
<i class="fa fa-cloud-upload me-1"/> Create Selected in WooCommerce
|
<i class="fa fa-cloud-upload me-1"/> Create Selected in WooCommerce
|
||||||
</button>
|
</button>
|
||||||
@@ -494,11 +495,11 @@
|
|||||||
</t>
|
</t>
|
||||||
<t t-else="">
|
<t t-else="">
|
||||||
<div class="woo-map-actions">
|
<div class="woo-map-actions">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm"
|
<button class="btn btn-secondary btn-sm"
|
||||||
t-on-click="() => this.resolveAllConflicts('use_odoo')">
|
t-on-click="() => this.resolveAllConflicts('use_odoo')">
|
||||||
Use Odoo for All
|
Use Odoo for All
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm"
|
<button class="btn btn-secondary btn-sm"
|
||||||
t-on-click="() => this.resolveAllConflicts('use_woo')">
|
t-on-click="() => this.resolveAllConflicts('use_woo')">
|
||||||
Use WooCommerce for All
|
Use WooCommerce for All
|
||||||
</button>
|
</button>
|
||||||
@@ -519,7 +520,7 @@
|
|||||||
<t t-foreach="state.conflicts" t-as="c" t-key="c.id">
|
<t t-foreach="state.conflicts" t-as="c" t-key="c.id">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span class="woo-badge woo-badge-conflict">
|
<span class="badge text-bg-warning">
|
||||||
<t t-esc="c.conflict_type"/>
|
<t t-esc="c.conflict_type"/>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
@@ -528,11 +529,11 @@
|
|||||||
<td><t t-esc="c.woo_value"/></td>
|
<td><t t-esc="c.woo_value"/></td>
|
||||||
<td>
|
<td>
|
||||||
<div class="d-flex gap-1">
|
<div class="d-flex gap-1">
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm"
|
<button class="btn btn-secondary btn-sm"
|
||||||
t-on-click="() => this.resolveConflict(c.id, 'use_odoo')">
|
t-on-click="() => this.resolveConflict(c.id, 'use_odoo')">
|
||||||
Use Odoo
|
Use Odoo
|
||||||
</button>
|
</button>
|
||||||
<button class="woo-btn woo-btn-secondary woo-btn-sm"
|
<button class="btn btn-secondary btn-sm"
|
||||||
t-on-click="() => this.resolveConflict(c.id, 'use_woo')">
|
t-on-click="() => this.resolveConflict(c.id, 'use_woo')">
|
||||||
Use WooCommerce
|
Use WooCommerce
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<field name="woo_product_name"/>
|
<field name="woo_product_name"/>
|
||||||
<field name="woo_sku"/>
|
<field name="woo_sku"/>
|
||||||
<field name="woo_product_type"/>
|
<field name="woo_product_type"/>
|
||||||
|
<field name="woo_category_name" optional="show"/>
|
||||||
<field name="sync_price"/>
|
<field name="sync_price"/>
|
||||||
<field name="sync_inventory"/>
|
<field name="sync_inventory"/>
|
||||||
<field name="last_synced"/>
|
<field name="last_synced"/>
|
||||||
@@ -41,6 +42,8 @@
|
|||||||
<field name="woo_product_name"/>
|
<field name="woo_product_name"/>
|
||||||
<field name="woo_sku"/>
|
<field name="woo_sku"/>
|
||||||
<field name="woo_product_type"/>
|
<field name="woo_product_type"/>
|
||||||
|
<field name="woo_category_id"/>
|
||||||
|
<field name="woo_category_name"/>
|
||||||
<field name="woo_parent_id"/>
|
<field name="woo_parent_id"/>
|
||||||
<field name="is_variation"/>
|
<field name="is_variation"/>
|
||||||
</group>
|
</group>
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ class WooProductFetch(models.TransientModel):
|
|||||||
is_variation = wc_product.get('_is_variation', False)
|
is_variation = wc_product.get('_is_variation', False)
|
||||||
parent_id = wc_product.get('_parent_id') or wc_product.get('parent_id') or 0
|
parent_id = wc_product.get('_parent_id') or wc_product.get('parent_id') or 0
|
||||||
|
|
||||||
|
wc_categories = wc_product.get('categories', [])
|
||||||
|
wc_cat_id = wc_categories[0].get('id', 0) if wc_categories else 0
|
||||||
|
wc_cat_name = wc_categories[0].get('name', '') if wc_categories else ''
|
||||||
|
|
||||||
map_vals = {
|
map_vals = {
|
||||||
'instance_id': instance.id,
|
'instance_id': instance.id,
|
||||||
'woo_product_id': woo_id,
|
'woo_product_id': woo_id,
|
||||||
@@ -112,6 +116,8 @@ class WooProductFetch(models.TransientModel):
|
|||||||
'woo_product_type': woo_type if not is_variation else 'variable',
|
'woo_product_type': woo_type if not is_variation else 'variable',
|
||||||
'is_variation': is_variation,
|
'is_variation': is_variation,
|
||||||
'woo_parent_id': parent_id,
|
'woo_parent_id': parent_id,
|
||||||
|
'woo_category_id': wc_cat_id,
|
||||||
|
'woo_category_name': wc_cat_name,
|
||||||
'company_id': instance.company_id.id,
|
'company_id': instance.company_id.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user