Skip to content

Commit 2d9c408

Browse files
committed
Merge PR #3590 into 15.0
Signed-off-by rvalyi
2 parents 1ef39e6 + ee7f1cd commit 2d9c408

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

l10n_br_purchase/models/purchase_order.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,22 @@ def _prepare_invoice(self):
112112
invoice_vals = super()._prepare_invoice()
113113
if self.fiscal_operation_id:
114114
# O caso Brasil se caracteriza por ter a Operação Fiscal
115+
document_type_id = (
116+
self.order_line[0].fiscal_operation_line_id.document_type_id.id
117+
if self.order_line
118+
and self.order_line[0].fiscal_operation_line_id.document_type_id
119+
else (
120+
self.fiscal_operation_id.document_type_ids[0].document_type_id.id
121+
if self.fiscal_operation_id
122+
and self.fiscal_operation_id.document_type_ids
123+
else self.company_id.document_type_id.id
124+
)
125+
)
115126
invoice_vals.update(
116127
{
117128
"ind_final": self.ind_final,
118129
"fiscal_operation_id": self.fiscal_operation_id.id,
119-
"document_type_id": self.company_id.document_type_id.id,
130+
"document_type_id": document_type_id,
120131
}
121132
)
122133
return invoice_vals

0 commit comments

Comments
 (0)