From 1229b9a19c7aa8e3669d96f73aedd3d7c4a3e1d3 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 26 May 2020 08:38:01 +0000 Subject: [PATCH] [FIX] sale_purchase: do not set Drop Ship Address - Create 2 companies A & B - Customers are not shared between companies - Intercompany transactions activated (SO/PO + automatic validation) - Create a service product P with MTO + Buy route - Company B is a supplier for the product P - Sell the product in company A to a customer C => a PO is generated in A thanks to the MTO rule - Confirm the PO => a SO is generated in company B - Set the user to have access to company B only - Open the SO An `AccessError` is raised during a `read` call on `res.partner` C. The partner C is set as a delivery address of the SO because it is set on the PO as a `dest_address_id`: https://github.com/odoo/enterprise/blob/5a841b25389106ce254828a0383b4c71987b9f3a/inter_company_rules/models/purchase_order.py#L62 Looking further, it is set on the PO in the `sale_purchase` module. Actually, there is no point of setting the field on the PO: `dest_address_id` is a Dropship address only used in Stock: https://github.com/odoo/odoo/blob/f705c4088ea7584b17769220a0a7ffcb00546e0b/addons/purchase_stock/views/purchase_views.xml#L38 Dropshipping is not supported for services. Moreover, in that specific case the picking type usage is internal, so it should be `False`: https://github.com/odoo/odoo/blob/f705c4088ea7584b17769220a0a7ffcb00546e0b/addons/purchase_stock/models/purchase.py#L55 opw-2260553 closes odoo/odoo#51888 X-original-commit: 9d6da7724a40bcc6b5c76aa733e7deee1b0ce922 Signed-off-by: Nicolas Martinelli (nim) --- addons/sale_purchase/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_purchase/models/sale_order.py b/addons/sale_purchase/models/sale_order.py index bfed4ae42cc..36fd34699c7 100644 --- a/addons/sale_purchase/models/sale_order.py +++ b/addons/sale_purchase/models/sale_order.py @@ -201,7 +201,7 @@ class SaleOrderLine(models.Model): 'partner_ref': partner_supplier.ref, 'company_id': self.company_id.id, 'currency_id': partner_supplier.property_purchase_currency_id.id or self.env.company.currency_id.id, - 'dest_address_id': self.order_id.partner_shipping_id.id, + 'dest_address_id': False, # False since only supported in stock 'origin': self.order_id.name, 'payment_term_id': partner_supplier.property_supplier_payment_term_id.id, 'date_order': date_order,