[FIX] hr_expense: expense of zero

- Create an expense of 0.00, validate
- The expense can never be set as paid since it's not possible to create
  a payment of 0.00.

An expense of 0.00 still makes sense in the following use case.

An expense is paid by salary before the expense is actually made, i.e.
I get 1000 EUR to redecorate my homeoffice, I get the money beginning of
the year. After that I want to book expenses against the initial payment
until the 1000 EUR is gone and I would like to make use of the expense
workflow to approve the costs.

opw-710695
This commit is contained in:
Nicolas Martinelli
2017-03-13 08:15:26 +01:00
parent 00435d6384
commit cab436819f
+4 -2
View File
@@ -5,7 +5,7 @@ import re
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.tools import email_split
from odoo.tools import email_split, float_is_zero
import odoo.addons.decimal_precision as dp
@@ -511,7 +511,9 @@ class HrExpenseSheet(models.Model):
if any(not sheet.journal_id for sheet in self):
raise UserError(_("Expenses must have an expense journal specified to generate accounting entries."))
res = self.mapped('expense_line_ids').action_move_create()
res = self.mapped('expense_line_ids')\
.filtered(lambda r: not float_is_zero(r.total_amount, precision_rounding=(r.currency_id or self.env.user.company_id.currency_id).rounding))\
.action_move_create()
if not self.accounting_date:
self.accounting_date = self.account_move_id.date