Skip to content

Commit 0b45a83

Browse files
committed
[FIX] hr_expense: doesn't post if journal.post_at == 'bank_rec'
Steps to reproduce: - Create a bank journal, with "post at" = "Bank reconciliation" - Create a new expense paid by "Company" - Create a report and confirm Current behavior: - the bank move is posted Expected behavior: - the bank move is not posted (and i will posted during the bank reconciliation" closes odoo#51650 Signed-off-by: Simon Goffin (sig) <[email protected]>
1 parent 62c1d0a commit 0b45a83

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

addons/hr_expense/models/hr_expense.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ def action_move_create(self):
447447

448448
move_line_values_by_expense = self._get_account_move_line_values()
449449

450+
move_to_keep_draft = self.env['account.move']
451+
450452
for expense in self:
451453
company_currency = expense.company_id.currency_id
452454
different_currency = expense.currency_id != company_currency
@@ -475,7 +477,7 @@ def action_move_create(self):
475477
'partner_type': 'supplier',
476478
'journal_id': journal.id,
477479
'payment_date': expense.date,
478-
'state': 'reconciled',
480+
'state': 'draft',
479481
'currency_id': expense.currency_id.id if different_currency else journal_currency.id,
480482
'amount': abs(total_amount_currency) if different_currency else abs(total_amount),
481483
'name': expense.name,
@@ -487,10 +489,18 @@ def action_move_create(self):
487489
expense.sheet_id.write({'account_move_id': move.id})
488490

489491
if expense.payment_mode == 'company_account':
492+
if journal.post_at == 'pay_val':
493+
payment.state = 'reconciled'
494+
elif journal.post_at == 'bank_rec':
495+
payment.state = 'posted'
496+
move_to_keep_draft |= move
497+
490498
expense.sheet_id.paid_expense_sheets()
491499

492500
# post the moves
493501
for move in move_group_by_sheet.values():
502+
if move in move_to_keep_draft:
503+
continue
494504
move.post()
495505

496506
return move_group_by_sheet

0 commit comments

Comments
 (0)