From 7a05887cd092971ef256dc0d3c7cafd817415d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Baranx=20=28bar=29?= Date: Mon, 5 Oct 2020 12:52:28 +0000 Subject: [PATCH] [FIX] stock_dropshipping: create missing dropship picking type In the function `create_missing_dropship_picking_type()`, the way to search companies that already have dropship picking type was not robust enough as it used the translatable `name` field in a search domain and the ORM `search` method used the translated value of `Dropship` name value instead of the raw value. A better approach is to search `stock.picking.type` with a default source location usage set to `supplier` and a default destination location usage set to `customer`. Related to upgrade request: #54154 closes odoo/odoo#59142 X-original-commit: 203bb4d9c113f5c24ad00d39e2ae46b4689117f4 Signed-off-by: Arnold Moyaux --- addons/stock_dropshipping/models/res_company.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/stock_dropshipping/models/res_company.py b/addons/stock_dropshipping/models/res_company.py index 09b217a7517..ef2aff2fb01 100644 --- a/addons/stock_dropshipping/models/res_company.py +++ b/addons/stock_dropshipping/models/res_company.py @@ -60,7 +60,14 @@ class ResCompany(models.Model): @api.model def create_missing_dropship_picking_type(self): company_ids = self.env['res.company'].search([]) - company_has_dropship_picking_type = self.env['stock.picking.type'].search([('name', '=', 'Dropship')]).mapped('company_id') + company_has_dropship_picking_type = ( + self.env['stock.picking.type'] + .search([ + ('default_location_src_id.usage', '=', 'supplier'), + ('default_location_dest_id.usage', '=', 'customer'), + ]) + .mapped('company_id') + ) company_todo_picking_type = company_ids - company_has_dropship_picking_type company_todo_picking_type._create_dropship_picking_type()