From cab436819f2f93b290b2401e769e72e16784a66e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 10 Mar 2017 11:40:11 +0100 Subject: [PATCH] [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 --- addons/hr_expense/models/hr_expense.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 2dc00149bc1..26eb023efc4 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -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