Skip to content

Commit

Permalink
[FIX] hr_expense: doesn't post if journal.post_at == 'bank_rec'
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
fmdl committed May 21, 2020
1 parent 62c1d0a commit 0b45a83
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion addons/hr_expense/models/hr_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ def action_move_create(self):

move_line_values_by_expense = self._get_account_move_line_values()

move_to_keep_draft = self.env['account.move']

for expense in self:
company_currency = expense.company_id.currency_id
different_currency = expense.currency_id != company_currency
Expand Down Expand Up @@ -475,7 +477,7 @@ def action_move_create(self):
'partner_type': 'supplier',
'journal_id': journal.id,
'payment_date': expense.date,
'state': 'reconciled',
'state': 'draft',
'currency_id': expense.currency_id.id if different_currency else journal_currency.id,
'amount': abs(total_amount_currency) if different_currency else abs(total_amount),
'name': expense.name,
Expand All @@ -487,10 +489,18 @@ def action_move_create(self):
expense.sheet_id.write({'account_move_id': move.id})

if expense.payment_mode == 'company_account':
if journal.post_at == 'pay_val':
payment.state = 'reconciled'
elif journal.post_at == 'bank_rec':
payment.state = 'posted'
move_to_keep_draft |= move

expense.sheet_id.paid_expense_sheets()

# post the moves
for move in move_group_by_sheet.values():
if move in move_to_keep_draft:
continue
move.post()

return move_group_by_sheet
Expand Down

0 comments on commit 0b45a83

Please sign in to comment.