summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent de Labarre <florent.mirieu@gmail.com>2020-05-21 19:39:57 +0000
committerGoffin Simon <sig@odoo.com>2020-06-03 06:23:53 +0000
commitaccfe5e089da921993d769ff57ff54a3b2236588 (patch)
tree823236353b5bd0666b41c639d54f35e7c7c26027
parent8ac95195fceaccf988f219e5527ac8e740b6d29e (diff)
[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/odoo#52260 X-original-commit: 0b45a8317f1e4538ad93aa169b8be08f5403340a Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
-rw-r--r--addons/hr_expense/models/hr_expense.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py
index 7c1c6734234..be398e3ca9d 100644
--- a/addons/hr_expense/models/hr_expense.py
+++ b/addons/hr_expense/models/hr_expense.py
@@ -480,6 +480,8 @@ class HrExpense(models.Model):
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
@@ -508,7 +510,7 @@ class HrExpense(models.Model):
'partner_type': 'supplier',
'journal_id': journal.id,
'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,
@@ -520,10 +522,18 @@ class HrExpense(models.Model):
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