From 1c015283753df0bdc201b2e010a27be398960b03 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Thu, 1 Mar 2018 11:49:10 +0100 Subject: [PATCH 1/3] [FIX] hr_expense: ensure message_new has only one record (singleton) Before this commit: Expense emails title are parsed to find a product that match the given [CODE]. For example, an email title like '[CARD] Graphic Card $900' will create an expense for the product having 'CARD' as internal reference. Since the search is done with an 'ilike' and with no 'limit', it could return multiple product: all the one containing the CODE in their internal reference. This would throw a singleton error when trying afterward to read product.id. Then, the mail would not go through the mail.thread flow and it would return a Mail System Delivery fail saying the address does not exist. Users would get stuck with this, having no way to understand where the error comes from. Now, we ensure to find only 1 product. To avoid breaking the ilike behavior that could be used by users only typing the first caracters of a long CODE, we still use ilike but force exact match if there is multiple results. Closes #23419 opw-1816340 --- addons/hr_expense/models/hr_expense.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index e83b9ca66a8..53c64c4a5ac 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -348,7 +348,8 @@ class HrExpense(models.Model): product = default_product else: expense_description = expense_description.replace(product_code.group(), '') - product = self.env['product.product'].search([('default_code', 'ilike', product_code.group(1))]) or default_product + products = self.env['product.product'].search([('default_code', 'ilike', product_code.group(1))]) or default_product + product = products.filtered(lambda p: p.default_code == product_code.group(1)) or products[0] pattern = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?' # Match the last occurence of a float in the string From 2f46f3bdb2e1e1baf69e9a548975813d5fe61d31 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 7 Mar 2018 16:11:39 +0100 Subject: [PATCH 2/3] [FIX] hr_payroll: generate payslips sets the employee company In a multi-company environment, if a user in company A created a Payslips batch for an employee in the company B and used the `generate payslips` button, the created payslip was set with the user company (A) while it must be the employee company (B). opw-1820138 --- addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py index 251eec34b18..64cf6e331b9 100644 --- a/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py +++ b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py @@ -46,6 +46,7 @@ class hr_payslip_employees(osv.osv_memory): 'date_from': from_date, 'date_to': to_date, 'credit_note': credit_note, + 'company_id': emp.company_id.id, } slip_ids.append(slip_pool.create(cr, uid, res, context=context)) slip_pool.compute_sheet(cr, uid, slip_ids, context=context) From 41af298d9d8a68be29cee57a4352e49d269594b7 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 8 Mar 2018 11:11:44 +0100 Subject: [PATCH 3/3] [FIX] hr_payroll: use defined variable Oversight of previous forward-port --- addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py index 715fb3cb1c6..d9a59cba3a0 100644 --- a/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py +++ b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py @@ -35,7 +35,7 @@ class HrPayslipEmployees(models.TransientModel): 'date_from': from_date, 'date_to': to_date, 'credit_note': run_data.get('credit_note'), - 'company_id': emp.company_id.id, + 'company_id': employee.company_id.id, } payslips += self.env['hr.payslip'].create(res) payslips.compute_sheet()