Compare commits
No commits in common. "b36c0233db8fa6955ade79993287d0dbe71833f5" and "c7d079e9bf1aa5c785a65c8b80c6bf5489a8ec6c" have entirely different histories.
b36c0233db
...
c7d079e9bf
2 changed files with 7 additions and 25 deletions
|
@ -184,28 +184,11 @@ class BillingEntity(ServalaModelMixin, models.Model):
|
|||
return instance
|
||||
|
||||
@classmethod
|
||||
@transaction.atomic
|
||||
def create_from_id(cls, name, odoo_id):
|
||||
parent_data = CLIENT.search_read(
|
||||
model="res.partner",
|
||||
domain=[["id", "=", odoo_id]],
|
||||
fields=["parent_id"],
|
||||
limit=1,
|
||||
)
|
||||
# Data validation: If the data is not as expected, we just return None,
|
||||
# rather than raising an exception, for now.
|
||||
if not parent_data:
|
||||
return
|
||||
if not (parent_info := parent_data[0].get("parent_id")):
|
||||
return
|
||||
if not isinstance(parent_info, (list, tuple)) or not len(parent_info) > 0:
|
||||
# parent_info is a tuple of the parent’s ID and name
|
||||
return
|
||||
|
||||
instance = cls.objects.create(
|
||||
name=name, odoo_invoice_id=odoo_id, odoo_company_id=parent_info[0]
|
||||
)
|
||||
return instance
|
||||
def create_from_id(cls, odoo_id):
|
||||
# TODO implement odoo creation from ID
|
||||
# instance = BillingEntity.objects.create(name=odoo_data.get("name"))
|
||||
# return instance
|
||||
pass
|
||||
|
||||
@cached_property
|
||||
def odoo_data(self):
|
||||
|
|
|
@ -10,12 +10,11 @@ Servala is run using environment variables. Documentation:
|
|||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import sentry_sdk
|
||||
from django.contrib import messages
|
||||
from pathlib import Path
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
|
||||
from django.contrib import messages
|
||||
from servala.__about__ import __version__ as version
|
||||
|
||||
SERVALA_ENVIRONMENT = os.environ.get("SERVALA_ENVIRONMENT", "development")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue