Add Tryton synchronization for CatalogSale
- Add external_id field to CatalogSale model for tracking synced sales - Create migration 0047 for external_id field - Add TrytonCatalogSale and TrytonCatalogSaleLine classes for Tryton RPC format - Add send_catalog_sales_to_tryton() method to SaleTrytonService - Create CatalogSalesToTrytonView API endpoint (POST) - Register endpoint at /don_confiao/api/enviar_catalog_sales_a_tryton - Add test for external_id field functionality - Catalog sales sync to same Tryton model as Sale (model.sale.sale.create) - Differentiated by reference 'don_confiao_catalog X' and description 'Venta de catálogo' - Filters only catalog sales without external_id to avoid duplicates
This commit is contained in:
@@ -20,9 +20,7 @@ class SaleLineAbstractModel(models.Model):
|
||||
product = models.ForeignKey(
|
||||
Product, null=False, blank=False, on_delete=models.CASCADE
|
||||
)
|
||||
quantity = models.DecimalField(
|
||||
max_digits=10, decimal_places=2, null=True
|
||||
)
|
||||
quantity = models.DecimalField(max_digits=10, decimal_places=2, null=True)
|
||||
unit_price = models.DecimalField(max_digits=9, decimal_places=2)
|
||||
description = models.CharField(max_length=255, null=True, blank=True)
|
||||
|
||||
@@ -55,9 +53,7 @@ class Sale(SaleAbstractModel):
|
||||
|
||||
def clean(self):
|
||||
if self.payment_method not in PaymentMethods.values:
|
||||
raise ValidationError(
|
||||
{"payment_method": "Invalid payment method"}
|
||||
)
|
||||
raise ValidationError({"payment_method": "Invalid payment method"})
|
||||
|
||||
@classmethod
|
||||
def sale_header_csv(cls):
|
||||
@@ -67,7 +63,6 @@ class Sale(SaleAbstractModel):
|
||||
|
||||
|
||||
class SaleLine(SaleLineAbstractModel):
|
||||
|
||||
sale = models.ForeignKey(Sale, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
@@ -75,6 +70,7 @@ class SaleLine(SaleLineAbstractModel):
|
||||
|
||||
|
||||
class CatalogSale(SaleAbstractModel):
|
||||
external_id = models.CharField(max_length=100, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.date} {self.customer}"
|
||||
|
||||
Reference in New Issue
Block a user