From 9700140d52f0ee42083fa9cfc902b9e6d4d7d41f Mon Sep 17 00:00:00 2001 From: Diego Paradeda Date: Fri, 16 Aug 2024 13:15:22 -0300 Subject: [PATCH 1/2] [IMP] set picking fop at creation from PO --- l10n_br_purchase_stock/models/purchase_order.py | 2 ++ l10n_br_stock_account/models/stock_picking.py | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/l10n_br_purchase_stock/models/purchase_order.py b/l10n_br_purchase_stock/models/purchase_order.py index 4ae3e89bf185..3b1c667bee08 100644 --- a/l10n_br_purchase_stock/models/purchase_order.py +++ b/l10n_br_purchase_stock/models/purchase_order.py @@ -44,6 +44,8 @@ def _prepare_picking(self): values = super()._prepare_picking() if self.fiscal_operation_id: values.update(self._prepare_br_fiscal_dict()) + else: + values["fiscal_operation_id"] = False if self.company_id.purchase_invoicing_policy == "stock_picking": values["invoice_state"] = "2binvoiced" diff --git a/l10n_br_stock_account/models/stock_picking.py b/l10n_br_stock_account/models/stock_picking.py index 8bcf3775a753..b53ea7038a22 100644 --- a/l10n_br_stock_account/models/stock_picking.py +++ b/l10n_br_stock_account/models/stock_picking.py @@ -25,11 +25,6 @@ def _default_fiscal_operation(self): # Casos onde o usuário definiu o Pedido de Compra/Venda como # 'Sem Operação Fiscal' - if hasattr(self, "purchase_id") and hasattr( - self.purchase_id, "fiscal_operation_id" - ): - if not self.purchase_id.fiscal_operation_id: - fiscal_operation = False if hasattr(self, "sale_id") and hasattr( self.sale_id, "fiscal_operation_id" ): From 578839a9947eba70d4e0ce646cab4ff932c68218 Mon Sep 17 00:00:00 2001 From: Diego Paradeda Date: Fri, 16 Aug 2024 13:26:16 -0300 Subject: [PATCH 2/2] [RMV] redundancy: 'fop' already comes from SO whether set or not --- l10n_br_stock_account/models/stock_picking.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/l10n_br_stock_account/models/stock_picking.py b/l10n_br_stock_account/models/stock_picking.py index b53ea7038a22..254fad31126f 100644 --- a/l10n_br_stock_account/models/stock_picking.py +++ b/l10n_br_stock_account/models/stock_picking.py @@ -23,21 +23,6 @@ def _default_fiscal_operation(self): else company.stock_out_fiscal_operation_id ) - # Casos onde o usuário definiu o Pedido de Compra/Venda como - # 'Sem Operação Fiscal' - if hasattr(self, "sale_id") and hasattr( - self.sale_id, "fiscal_operation_id" - ): - # Necessário para evitar o erro quando o l10n_br_purchase_stock - # é instalado: - # /l10n_br_stock_account/models/stock_picking.py", line 34, - # in _default_fiscal_operation - # if not self.sale_id.fiscal_operation_id: - # AttributeError: 'sale.order' object has no attribute - # 'fiscal_operation_id' - if not self.sale_id.fiscal_operation_id: - fiscal_operation = False - return fiscal_operation @api.model