[FIX] hr_expense: mark expense paid by company as paid

Expenses paid by company are marked as paid but the related journal
entry is not paid and cannot be paid

Steps to reproduce:
1. Install Expenses and Accounting
2. Create an expense payable to company and set an amount
3. Create report
4. Submit report
5. Approve report
6. Post journal entries
7. Open the related journal entry
8. Attempt to register payment: an error is raised

Solution:
Mark the journal entries created for the expense as paid if the expense
is paid by the company

opw-3075818

closes odoo/odoo#109375

X-original-commit: f5dd4e3326a17c1f6d06630503d1ede8cc6c59fe
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
MerlinGuillaume
2023-01-06 20:49:43 +01:00
parent 6cf1e722e3
commit 6059a7e20c
+7
View File
@@ -37,6 +37,13 @@ class AccountMove(models.Model):
return _("Expense entry Created")
return super()._creation_message()
@api.depends('expense_sheet_id.payment_mode')
def _compute_payment_state(self):
company_paid = self.filtered(lambda m: m.expense_sheet_id.payment_mode == 'company_account')
for move in company_paid:
move.payment_state = move._get_invoice_in_payment_state()
super(AccountMove, self - company_paid)._compute_payment_state()
@api.depends('expense_sheet_id')
def _compute_needed_terms(self):
# EXTENDS account