diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 3f7da184698..3466a6c72c0 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -354,7 +354,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 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 73a304daa2e..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,6 +35,7 @@ class HrPayslipEmployees(models.TransientModel): 'date_from': from_date, 'date_to': to_date, 'credit_note': run_data.get('credit_note'), + 'company_id': employee.company_id.id, } payslips += self.env['hr.payslip'].create(res) payslips.compute_sheet() 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 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_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 @@ - + 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'