diff --git a/l10n_br_stock_account/models/stock_picking.py b/l10n_br_stock_account/models/stock_picking.py index 8bcf3775a753..a0170c815009 100644 --- a/l10n_br_stock_account/models/stock_picking.py +++ b/l10n_br_stock_account/models/stock_picking.py @@ -28,7 +28,7 @@ def _default_fiscal_operation(self): if hasattr(self, "purchase_id") and hasattr( self.purchase_id, "fiscal_operation_id" ): - if not self.purchase_id.fiscal_operation_id: + if self.purchase_id and not self.purchase_id.fiscal_operation_id: fiscal_operation = False if hasattr(self, "sale_id") and hasattr( self.sale_id, "fiscal_operation_id" @@ -40,7 +40,7 @@ def _default_fiscal_operation(self): # 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: + if self.sale_id and not self.sale_id.fiscal_operation_id: fiscal_operation = False return fiscal_operation