From bfe76859e8b0790abf4f20432d4c54fd2053ca2f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 24 May 2019 08:03:03 +0000 Subject: [PATCH] [FIX] sale_stock: change shipping address - Create a SO for a stockable product - Validate the SO - Change the 'Delivery Address' Nothing warns the user that the address was not changed on the corresponding pickings. opw-2002084 closes odoo/odoo#33636 Signed-off-by: Nicolas Martinelli (nim) --- addons/sale_stock/i18n/sale_stock.pot | 12 ++++++++++++ addons/sale_stock/models/sale_order.py | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/addons/sale_stock/i18n/sale_stock.pot b/addons/sale_stock/i18n/sale_stock.pot index 7218a7dbe00..d8b1b66dae9 100644 --- a/addons/sale_stock/i18n/sale_stock.pot +++ b/addons/sale_stock/i18n/sale_stock.pot @@ -166,6 +166,12 @@ msgstr "" msgid "Display incoterms on orders & invoices" msgstr "" +#. module: sale_stock +#: code:addons/sale_stock/models/sale_order.py:101 +#, python-format +msgid "Do not forget to change the partner on the following delivery orders: %s" +msgstr "" + #. module: sale_stock #: model:ir.model.fields,field_description:sale_stock.field_sale_order__effective_date msgid "Effective Date" @@ -491,6 +497,12 @@ msgstr "" msgid "Warning" msgstr "" +#. module: sale_stock +#: code:addons/sale_stock/models/sale_order.py:100 +#, python-format +msgid "Warning!" +msgstr "" + #. module: sale_stock #: model_terms:ir.ui.view,arch_db:sale_stock.res_config_settings_view_form_stock msgid "When to reserve sold products" diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 51c1d66a606..942b4f6824e 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -89,6 +89,21 @@ class SaleOrder(models.Model): if self.warehouse_id.company_id: self.company_id = self.warehouse_id.company_id.id + @api.onchange('partner_shipping_id') + def _onchange_partner_shipping_id(self): + res = {} + pickings = self.picking_ids.filtered( + lambda p: p.state not in ['done', 'cancel'] and p.partner_id != self.partner_shipping_id + ) + if pickings: + res['warning'] = { + 'title': _('Warning!'), + 'message': _( + 'Do not forget to change the partner on the following delivery orders: %s' + ) % (','.join(pickings.mapped('name'))) + } + return res + @api.multi def action_view_delivery(self): '''