parent
d8ceaf4b1b
commit
3b49b17360
3 changed files with 46 additions and 2 deletions
|
|
@ -83,7 +83,7 @@ class BillingEntityAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
@admin.register(OrganizationOrigin)
|
@admin.register(OrganizationOrigin)
|
||||||
class OrganizationOriginAdmin(admin.ModelAdmin):
|
class OrganizationOriginAdmin(admin.ModelAdmin):
|
||||||
list_display = ("name", "billing_entity")
|
list_display = ("name", "billing_entity", "default_odoo_sale_order_id")
|
||||||
search_fields = ("name",)
|
search_fields = ("name",)
|
||||||
autocomplete_fields = ("billing_entity",)
|
autocomplete_fields = ("billing_entity",)
|
||||||
filter_horizontal = ("limit_cloudproviders",)
|
filter_horizontal = ("limit_cloudproviders",)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 5.2.7 on 2025-10-22 09:32
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("core", "0015_organizationorigin_limit_cloudproviders"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="organizationorigin",
|
||||||
|
name="default_odoo_sale_order_id",
|
||||||
|
field=models.IntegerField(
|
||||||
|
blank=True,
|
||||||
|
help_text="If set, this sale order will be used for new organizations with this origin.",
|
||||||
|
null=True,
|
||||||
|
verbose_name="Default Odoo Sale Order ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -129,7 +129,20 @@ class Organization(ServalaModelMixin, models.Model):
|
||||||
if owner:
|
if owner:
|
||||||
instance.set_owner(owner)
|
instance.set_owner(owner)
|
||||||
|
|
||||||
if (
|
if instance.origin and instance.origin.default_odoo_sale_order_id:
|
||||||
|
sale_order_id = instance.origin.default_odoo_sale_order_id
|
||||||
|
sale_order_data = CLIENT.search_read(
|
||||||
|
model="sale.order",
|
||||||
|
domain=[["id", "=", sale_order_id]],
|
||||||
|
fields=["name"],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
instance.odoo_sale_order_id = sale_order_id
|
||||||
|
if sale_order_data:
|
||||||
|
instance.odoo_sale_order_name = sale_order_data[0]["name"]
|
||||||
|
instance.save(update_fields=["odoo_sale_order_id", "odoo_sale_order_name"])
|
||||||
|
elif (
|
||||||
instance.billing_entity.odoo_company_id
|
instance.billing_entity.odoo_company_id
|
||||||
and instance.billing_entity.odoo_invoice_id
|
and instance.billing_entity.odoo_invoice_id
|
||||||
):
|
):
|
||||||
|
|
@ -385,6 +398,14 @@ class OrganizationOrigin(ServalaModelMixin, models.Model):
|
||||||
"If set, all organizations with this origin will be limited to these cloud providers."
|
"If set, all organizations with this origin will be limited to these cloud providers."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
default_odoo_sale_order_id = models.IntegerField(
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
verbose_name=_("Default Odoo Sale Order ID"),
|
||||||
|
help_text=_(
|
||||||
|
"If set, this sale order will be used for new organizations with this origin."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Organization origin")
|
verbose_name = _("Organization origin")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue