27 lines
901 B
Python
27 lines
901 B
Python
from apps.integrations.odoo.client import OdooClientInterface, get_odoo_client
|
|
|
|
|
|
class OdooPartnerService:
|
|
def __init__(self, client: OdooClientInterface | None = None):
|
|
self.client = client or get_odoo_client()
|
|
|
|
def lookup(self, key: str, value) -> dict | None:
|
|
return self.client.search_partner(key, value)
|
|
|
|
def create(self, payload: dict) -> dict:
|
|
return self.client.create_partner(payload)
|
|
|
|
|
|
class OdooInvoiceService:
|
|
def __init__(self, client: OdooClientInterface | None = None):
|
|
self.client = client or get_odoo_client()
|
|
|
|
def sync_invoice(self, invoice) -> dict:
|
|
payload = {
|
|
"reference": invoice.number,
|
|
"amount": str(invoice.amount),
|
|
"currency": invoice.currency,
|
|
"partner_ref": invoice.order.customer.odoo_partner_id or "",
|
|
}
|
|
return self.client.create_invoice(payload)
|