Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sale_order_type_automation/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ def onchange_sale_type_set_pay_now(self):
self.pay_now_journal_id = self.sale_type_id.payment_journal_id.id
else:
self.pay_now_journal_id = False

def _compute_company_id(self):
super()._compute_company_id()
# If company_id is empty after super (because _accessible_branches returned empty),
# assign the journal's company directly. This happens when in sudo mode and the user
# has no access to any company
for move in self.filtered(
lambda m: not m.company_id and m.sale_type_id.journal_id and m.sale_type_id.invoicing_atomation != "none"
):
move.company_id = move.sale_type_id.journal_id.company_id