Files
Odoo-Modules/fusion-woo-odoo/fusion_woocommerce/models/woo_tax_map.py
gsinghpal 05c84d077d feat: move tax and pricelist mapping inline to Sync Settings tab
Tax mapping and pricelist mapping now live directly on the instance
form under Sync Settings. Added Fetch WC Tax Classes button that pulls
tax classes from WC API and auto-matches. Removed standalone menu items.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 16:58:01 -04:00

53 lines
1.7 KiB
Python

from odoo import api, fields, models
class WooTaxMap(models.Model):
_name = 'woo.tax.map'
_description = 'WooCommerce Tax Mapping'
instance_id = fields.Many2one('woo.instance', required=True, ondelete='cascade')
tax_id = fields.Many2one('account.tax', string='Odoo Tax')
woo_tax_class = fields.Char(required=True)
woo_tax_class_name = fields.Char()
company_id = fields.Many2one(
'res.company', required=True, default=lambda self: self.env.company,
)
# ------------------------------------------------------------------
# Lookup helpers (Task 26)
# ------------------------------------------------------------------
@api.model
def get_odoo_tax(self, instance, wc_tax_class):
"""Return the Odoo account.tax mapped to a WC tax class.
Args:
instance: woo.instance record
wc_tax_class: WC tax class slug (e.g. 'standard', 'reduced-rate')
Returns:
account.tax record or empty recordset
"""
mapping = self.search([
('instance_id', '=', instance.id),
('woo_tax_class', '=', wc_tax_class),
], limit=1)
return mapping.tax_id if mapping else self.env['account.tax']
@api.model
def get_wc_tax_class(self, instance, tax_id):
"""Return the WC tax class slug mapped to an Odoo tax.
Args:
instance: woo.instance record
tax_id: account.tax record id
Returns:
str: WC tax class slug, or empty string if not mapped
"""
mapping = self.search([
('instance_id', '=', instance.id),
('tax_id', '=', tax_id),
], limit=1)
return mapping.woo_tax_class if mapping else ''