From dff1e96ed35481c9805ec65b483a5e01e0593d98 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 9 May 2018 14:35:59 +0200 Subject: [PATCH] [FIX] purchase: Wrong property fields in multicompany Steps to reproduce the bug: - Enable multi companies and multi-currencies - Multi company: Your Company and Test - Users: Admin and Demo - Login as admin user with the current company: Your Company - Allowed companies: Your Company, Test - Login as Demo user with the current company: Test - Allowed companies: Test - From the admin user with the current company: Test, do the following configuration in the product, - product: iPad mini, select vendor: Delta PC with price $100 with company: test, currency: USD - Change the admin's company from Test to Your Company, do the following configuration in the vendor, - vendor: Delta PC, set supplier currency: EUR and payment terms: 30 Daya Net Payment - Log in with the demo user - Create SO for that product by selecting routes: Make to order and Confirm it. - Open the PO which is generated from this SO Bug: The Currency and payment terms were set with the data set for Your Company Excpected behavior: Nothing is set for supplier currency and Payment terms as nothing is set for the company: Test Closes #24564 opw:1841379 --- addons/purchase/models/purchase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 56583bdda35..f97c8cf7b75 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -1022,10 +1022,10 @@ class ProcurementRule(models.Model): 'partner_id': partner.id, 'picking_type_id': self.picking_type_id.id, 'company_id': values['company_id'].id, - 'currency_id': partner.property_purchase_currency_id.id or self.env.user.company_id.currency_id.id, + 'currency_id': partner.with_context(force_company=values['company_id'].id).property_purchase_currency_id.id or self.env.user.company_id.currency_id.id, 'dest_address_id': values.get('partner_dest_id', False) and values['partner_dest_id'].id, 'origin': origin, - 'payment_term_id': partner.property_supplier_payment_term_id.id, + 'payment_term_id': partner.with_context(force_company=values['company_id'].id).property_supplier_payment_term_id.id, 'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT), 'fiscal_position_id': fpos, 'group_id': group