From 1c015283753df0bdc201b2e010a27be398960b03 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Thu, 1 Mar 2018 11:49:10 +0100 Subject: [PATCH 1/6] [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/6] [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 1048fc6ed5e57c96fe1ada4529654c10d98a1246 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 8 Mar 2018 08:14:58 +0100 Subject: [PATCH 3/6] [FIX] purchase, stock_dropshipping: fix tests Astonishingly, some people really need a green runbot to work. --- addons/purchase/test/fifo_price.yml | 2 +- addons/stock_dropshipping/test/lifo_price.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/purchase/test/fifo_price.yml b/addons/purchase/test/fifo_price.yml index 29a6fea4e08..89029799ab7 100644 --- a/addons/purchase/test/fifo_price.yml +++ b/addons/purchase/test/fifo_price.yml @@ -3,7 +3,7 @@ - !python {model: res.company}: | company = self.env.ref('base.main_company') - company.currency_id = self.env.ref('base.EUR') + self.env.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.env.ref("base.EUR").id, company.id]) - Set a product as using fifo price - diff --git a/addons/stock_dropshipping/test/lifo_price.yml b/addons/stock_dropshipping/test/lifo_price.yml index 3cff45c24fa..1d34b828f4d 100644 --- a/addons/stock_dropshipping/test/lifo_price.yml +++ b/addons/stock_dropshipping/test/lifo_price.yml @@ -2,7 +2,7 @@ Set the company currency as EURO for the sake of repeatibility - !python {model: res.company, id: base.main_company}: | - self.write({'currency_id':ref('base.EUR')}) + self.env.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.env.ref("base.EUR").id, self.id]) - Set product category removal strategy as LIFO @@ -116,4 +116,4 @@ Check standard price became 80 euro - !python {model: product.product, id: product_lifo_icecream}: | - assert self.standard_price == 80.0, 'Price should have been 80 euro' \ No newline at end of file + assert self.standard_price == 80.0, 'Price should have been 80 euro' From 9f226528bd69968b662a87a19086dc3b14091101 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 5 Mar 2018 15:48:16 +0100 Subject: [PATCH 4/6] [FIX] stock_account: Force accounting date on validated inventory adjustment When the inventory adjustement has been validated, changing accounting_date has no impact on the stock moves created by the inventory adjustement. This behavior cannot be changed in stable version. opw:1817813 --- addons/stock_account/views/stock_account_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/views/stock_account_views.xml b/addons/stock_account/views/stock_account_views.xml index bd817ab8bd3..cea114b735c 100644 --- a/addons/stock_account/views/stock_account_views.xml +++ b/addons/stock_account/views/stock_account_views.xml @@ -8,7 +8,7 @@ - + From 622399c796756827783b1b58017bc61479019747 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 8 Mar 2018 09:35:22 +0100 Subject: [PATCH 5/6] [FIX] purchase: Changing the price of a confirmed PO before the receipt Steps to reproduce the bug: - Set your company in anglo-saxon - Create a product P in a category which is in real price and perpetual - Create a PO with P at 500$ and validate it - Change the unit price of P in the PO line and set 100$ - Receive the product Bug: The two journal entries generated for the goods were created with the price unit 500$ instead of 100$. Fix: Now the right price is taken into account to generate the journal entries. opw:1813946 --- addons/purchase/models/stock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/stock.py b/addons/purchase/models/stock.py index 4f10e405165..e3fa460f4f1 100644 --- a/addons/purchase/models/stock.py +++ b/addons/purchase/models/stock.py @@ -45,7 +45,8 @@ class StockMove(models.Model): order = self.purchase_line_id.order_id #if the currency of the PO is different than the company one, the price_unit on the move must be reevaluated #(was created at the rate of the PO confirmation, but must be valuated at the rate of stock move execution) - if order.currency_id != self.company_id.currency_id: + #also change when the unit price on the PO line changes in the meantime + if order.currency_id != self.company_id.currency_id or self.purchase_line_id.price_unit != self.price_unit: #we don't pass the move.date in the compute() for the currency rate on purpose because # 1) get_price_unit() is supposed to be called only through move.action_done(), # 2) the move hasn't yet the correct date (currently it is the expected date, after From 41af298d9d8a68be29cee57a4352e49d269594b7 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 8 Mar 2018 11:11:44 +0100 Subject: [PATCH 6/6] [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()