Files
Odoo-Modules/fusion-woo-odoo/fusion_woocommerce/models/woo_pricelist_map.py
gsinghpal cc35c28760 feat: implement returns/refunds, customer sync, tax/pricelist mapping
- Add woo.return workflow: action_approve (creates reverse picking),
  action_reject, action_receive, action_refund (creates credit note + WC refund)
- Add woo.customer._find_or_create class method for customer lookup/creation
- Replace _sync_customers placeholder to push address updates to WC
- Add _sync_customer_from_wc webhook handler for inbound customer updates
- Add woo.tax.map helpers: get_odoo_tax, get_wc_tax_class
- Add woo.pricelist.map helper: get_pricelist_for_role

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 21:02:07 -04:00

36 lines
1.2 KiB
Python

from odoo import api, fields, models
class WooPricelistMap(models.Model):
_name = 'woo.pricelist.map'
_description = 'WooCommerce Pricelist Mapping'
instance_id = fields.Many2one('woo.instance', required=True, ondelete='cascade')
pricelist_id = fields.Many2one('product.pricelist', required=True)
woo_role = fields.Char(required=True)
woo_role_name = fields.Char()
company_id = fields.Many2one(
'res.company', required=True, default=lambda self: self.env.company,
)
# ------------------------------------------------------------------
# Lookup helper (Task 26)
# ------------------------------------------------------------------
@api.model
def get_pricelist_for_role(self, instance, wc_role):
"""Return the Odoo product.pricelist mapped to a WC customer role.
Args:
instance: woo.instance record
wc_role: WC customer role slug (e.g. 'wholesale', 'customer')
Returns:
product.pricelist record or empty recordset
"""
mapping = self.search([
('instance_id', '=', instance.id),
('woo_role', '=', wc_role),
], limit=1)
return mapping.pricelist_id if mapping else self.env['product.pricelist']