diff --git a/l10n_br_purchase_stock/models/purchase_order.py b/l10n_br_purchase_stock/models/purchase_order.py index d28159cbbc68..7ade7287e5f6 100644 --- a/l10n_br_purchase_stock/models/purchase_order.py +++ b/l10n_br_purchase_stock/models/purchase_order.py @@ -42,7 +42,8 @@ def _compute_get_button_create_invoice_invisible(self): @api.model def _prepare_picking(self): values = super()._prepare_picking() - values.update(self._prepare_br_fiscal_dict()) + if self.fiscal_operation_id: + values.update(self._prepare_br_fiscal_dict()) if self.company_id.purchase_create_invoice_policy == "stock_picking": values["invoice_state"] = "2binvoiced" diff --git a/l10n_br_purchase_stock/models/purchase_order_line.py b/l10n_br_purchase_stock/models/purchase_order_line.py index ea1028327029..d351dc91f5b7 100644 --- a/l10n_br_purchase_stock/models/purchase_order_line.py +++ b/l10n_br_purchase_stock/models/purchase_order_line.py @@ -15,8 +15,9 @@ def _prepare_stock_moves(self, picking): """ values = super()._prepare_stock_moves(picking) for v in values: - v.update(self._prepare_br_fiscal_dict()) - if self.env.company.purchase_create_invoice_policy == "stock_picking": + if self.order_id.fiscal_operation_id: + v.update(self._prepare_br_fiscal_dict()) + if self.order_id.purchase_create_invoice_policy == "stock_picking": v["invoice_state"] = "2binvoiced" return values