diff options
| author | Urvi Soni <uso@odoo.com> | 2021-04-27 06:17:36 +0000 |
|---|---|---|
| committer | Barad Mahendra <mba@openerp.com> | 2021-04-27 10:25:34 +0000 |
| commit | 2aedd076317b37ceffba061c48e3d4fc38f02ea9 (patch) | |
| tree | 071c9a7a04765446fd4f3ce58fad62b652ded2c6 /addons | |
| parent | 60e83f03b871605b7aa281503269f66ac3ea940b (diff) | |
[FIX] hr_expense: do not create a payment when expense is paid by company
Currently, when we create an expense that is paid by company,
then create and approve a report, then post entries, 2 entries are
created. 1 is posted and is correct, the other one is in draft due to
the creation of the payment for employee and should not be there.
As when a company pays for an expense, in 99% of the cases,
it's because employees have a credit card funded by the company.
It happens often that company owners have this kind of card or even
employees but that's more common in the US. In such case,
it's just an account payable to visa or mastercard. so no need to
create a payment for the employee.
So this commit, draft entry will not be created when payment paid
by the company while posting the entries from the expense.
closes odoo/odoo#69875
Taskid: 2410551
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/hr_expense/models/hr_expense.py | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index cb5292a242b..98cd80a1f02 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -510,37 +510,11 @@ Or send your receipts at <a href="mailto:%(email)s?subject=Lunch%%20with%%20cust move_line_values_by_expense = self._get_account_move_line_values() for expense in self: - company_currency = expense.company_id.currency_id - different_currency = expense.currency_id != company_currency - # get the account move of the related sheet move = move_group_by_sheet[expense.sheet_id.id] # get move line values move_line_values = move_line_values_by_expense.get(expense.id) - move_line_dst = move_line_values[-1] - total_amount = move_line_dst['debit'] or -move_line_dst['credit'] - total_amount_currency = move_line_dst['amount_currency'] - - # create one more move line, a counterline for the total on payable account - if expense.payment_mode == 'company_account': - if not expense.sheet_id.bank_journal_id.default_account_id: - raise UserError(_("No account found for the %s journal, please configure one.") % (expense.sheet_id.bank_journal_id.name)) - journal = expense.sheet_id.bank_journal_id - # create payment - payment_methods = journal.outbound_payment_method_ids if total_amount < 0 else journal.inbound_payment_method_ids - journal_currency = journal.currency_id or journal.company_id.currency_id - payment = self.env['account.payment'].create({ - 'payment_method_id': payment_methods and payment_methods[0].id or False, - 'payment_type': 'outbound' if total_amount < 0 else 'inbound', - 'partner_id': expense.employee_id.sudo().address_home_id.commercial_partner_id.id, - 'partner_type': 'supplier', - 'journal_id': journal.id, - 'date': expense.date, - '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), - 'ref': expense.name, - }) # link move lines to move, and move to expense sheet move.write({'line_ids': [(0, 0, line) for line in move_line_values]}) |
