Skip to content

Commit

Permalink
[FIX] purchse_operating_unit: allow to generate invoices from purchas…
Browse files Browse the repository at this point in the history
…e orders
  • Loading branch information
alan196 committed Oct 6, 2023
1 parent 2bcadfa commit 3c5524a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion purchase_operating_unit/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@ def _check_company_operating_unit(self):

def _prepare_invoice(self):
invoice_vals = super()._prepare_invoice()
invoice_vals["operating_unit_id"] = self.operating_unit_id.id
journal = self.env["account.journal"].search(
[
("operating_unit_id", "=", self.operating_unit_id.id),
("type", "=", "purchase"),
],
limit=1,
)
if not journal:
raise ValidationError(
_("You need to create a purchase journal for this operating unit.")
)
invoice_vals.update({
"journal_id": journal.id,
"operating_unit_id": self.operating_unit_id.id,
})
return invoice_vals


Expand Down

0 comments on commit 3c5524a

Please sign in to comment.