From d479b810abfdd67b3b0dd4184587a58f5bfd0e6a Mon Sep 17 00:00:00 2001 From: ilo Date: Wed, 21 Aug 2024 17:16:19 -0300 Subject: [PATCH] [15.0][FIX] product_supplierinfo_for_customer_sale: onchange NewId --- product_supplierinfo_for_customer_sale/README.rst | 1 + .../models/sale_order_line.py | 14 ++++++++------ .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/product_supplierinfo_for_customer_sale/README.rst b/product_supplierinfo_for_customer_sale/README.rst index 25a9c5280de..b7b0a1ef2c3 100644 --- a/product_supplierinfo_for_customer_sale/README.rst +++ b/product_supplierinfo_for_customer_sale/README.rst @@ -114,6 +114,7 @@ Contributors * Sergio Teruel * Lois Rilo * Juany Davila +* Italo Lopes Maintainers ~~~~~~~~~~~ diff --git a/product_supplierinfo_for_customer_sale/models/sale_order_line.py b/product_supplierinfo_for_customer_sale/models/sale_order_line.py index a64123d8b9c..430a1fecfe7 100644 --- a/product_supplierinfo_for_customer_sale/models/sale_order_line.py +++ b/product_supplierinfo_for_customer_sale/models/sale_order_line.py @@ -35,12 +35,14 @@ def _update_description(self): """ # We need to repeat the search here, as passing the value by context or any # other trick makes the ORM to do ugly things in "onchange" mode - customerinfo = self.product_id._select_customerinfo( - partner=self.order_partner_id - ) - if customerinfo.product_code: - # Avoid to put the standard internal reference - self = self.with_context(display_default_code=False) + customerinfo = self.env["product.customerinfo"] + if self.product_id: + customerinfo = self.product_id._select_customerinfo( + partner=self.order_partner_id + ) + if customerinfo.product_code: + # Avoid to put the standard internal reference + self = self.with_context(display_default_code=False) res = super()._update_description() if customerinfo.product_code: self.name = f"[{customerinfo.product_code}] {self.name}" diff --git a/product_supplierinfo_for_customer_sale/readme/CONTRIBUTORS.rst b/product_supplierinfo_for_customer_sale/readme/CONTRIBUTORS.rst index b062d1c9beb..748a582341d 100644 --- a/product_supplierinfo_for_customer_sale/readme/CONTRIBUTORS.rst +++ b/product_supplierinfo_for_customer_sale/readme/CONTRIBUTORS.rst @@ -7,3 +7,4 @@ * Sergio Teruel * Lois Rilo * Juany Davila +* Italo Lopes diff --git a/product_supplierinfo_for_customer_sale/static/description/index.html b/product_supplierinfo_for_customer_sale/static/description/index.html index 77942fc09ba..ff32e5a77d3 100644 --- a/product_supplierinfo_for_customer_sale/static/description/index.html +++ b/product_supplierinfo_for_customer_sale/static/description/index.html @@ -458,6 +458,7 @@

Contributors

  • Sergio Teruel <sergio.teruel@tecnativa.com>
  • Lois Rilo <lois.rilo@forgeflow.com>
  • Juany Davila <juany.davila@forgeflow.com>
  • +
  • Italo Lopes <italo.lopes@camptocamp.com>