From 2f9b17fe8cd4fa81739c21e9a4b357fbb62f9235 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 25 Mar 2024 10:58:09 +0100 Subject: [PATCH] shopinvader_api_cart: improve convert_to_sale_write Pass the current cart because: * you might need an env * you might need to determine a value based on the current record This we don't need any other hook on the helpers. --- shopinvader_api_cart/routers/cart.py | 2 +- shopinvader_api_cart/schemas/cart.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shopinvader_api_cart/routers/cart.py b/shopinvader_api_cart/routers/cart.py index dbf75e90cb..45624bc815 100644 --- a/shopinvader_api_cart/routers/cart.py +++ b/shopinvader_api_cart/routers/cart.py @@ -236,5 +236,5 @@ def _update(self, partner, data, uuid): cart = self.env["sale.order"]._find_open_cart(partner.id, uuid) if not cart: cart = self.env["sale.order"]._create_empty_cart(partner.id) - cart.write(data.convert_to_sale_write()) + cart.write(data.convert_to_sale_write(cart)) return cart diff --git a/shopinvader_api_cart/schemas/cart.py b/shopinvader_api_cart/schemas/cart.py index 886440cd12..db564ad38e 100644 --- a/shopinvader_api_cart/schemas/cart.py +++ b/shopinvader_api_cart/schemas/cart.py @@ -31,7 +31,7 @@ class CartUpdateInput(StrictExtendableBaseModel, extra="ignore"): invoicing: InvoicingUpdateInfo | None = None note: str | None = None - def convert_to_sale_write(self): + def convert_to_sale_write(self, cart): vals = {} data = self.model_dump(exclude_unset=True) if "client_order_ref" in data: