From 965d2119ca5e784a7fa8ec418b2999c5b6cee03a Mon Sep 17 00:00:00 2001 From: Raphael Lee <51208020+RLeeOSI@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:13:48 -0700 Subject: [PATCH 1/2] [FIX] osi_partner_credit_limit: error on hold --- .../models/stock_picking.py | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/osi_partner_credit_limit/models/stock_picking.py b/osi_partner_credit_limit/models/stock_picking.py index 34141768c..5a2231e8c 100644 --- a/osi_partner_credit_limit/models/stock_picking.py +++ b/osi_partner_credit_limit/models/stock_picking.py @@ -44,23 +44,17 @@ def _compute_allow_transfer(self): def button_validate(self): # Only outgoing picking - for picking in self: - if picking.picking_type_code == "outgoing": - if picking.dont_allow_transfer: - hold_tx_names = self.filtered("dont_allow_transfer").mapped( - "display_name" - ) - raise UserError( - _( - "Customer on transfer(s) (%s) has a credit hold." - "\n\nContact Sales/Accounting to verify " - "sales hold/credit hold/overdue payments.", - ", ".join(hold_tx_names), - ) - ) - else: - return super(StockPicking, self).button_validate() - - # Incoming shipments / internal transfers - else: - return super(StockPicking, self).button_validate() + hold_transfers = self.filtered( + lambda p: p.picking_type_code == "outgoing" + and p.dont_allow_transfer + ) + if hold_transfers: + raise UserError( + _( + "Customer on transfer(s) (%s) has a credit hold." + "\n\nContact Sales/Accounting to verify " + "sales hold/credit hold/overdue payments.", + ", ".join(hold_transfers.mapped("display_name")), + ) + ) + return super().button_validate() From 40c00e8dbd8703e30717a943e11a79a8d9a41253 Mon Sep 17 00:00:00 2001 From: Raphael Lee <51208020+RLeeOSI@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:15:42 -0700 Subject: [PATCH 2/2] [REF] pre-commit --- osi_partner_credit_limit/models/stock_picking.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osi_partner_credit_limit/models/stock_picking.py b/osi_partner_credit_limit/models/stock_picking.py index 5a2231e8c..9b460041c 100644 --- a/osi_partner_credit_limit/models/stock_picking.py +++ b/osi_partner_credit_limit/models/stock_picking.py @@ -45,8 +45,7 @@ def _compute_allow_transfer(self): def button_validate(self): # Only outgoing picking hold_transfers = self.filtered( - lambda p: p.picking_type_code == "outgoing" - and p.dont_allow_transfer + lambda p: p.picking_type_code == "outgoing" and p.dont_allow_transfer ) if hold_transfers: raise UserError(