From 30b00e5c1b7b5d434c05af13855687af75b6d9b5 Mon Sep 17 00:00:00 2001
From: "Ricardo Gomes Rodrigues (rigr)" <rigr@odoo.com>
Date: Fri, 25 Aug 2023 08:43:04 +0000
Subject: [PATCH] [FIX] l10n_it_stock_ddt: condition to create the
 l10n_it_ddt_sequence_id

The condition to create is wrongly evaluated and does not take into account
the country code and the picking type code. This commit fixes this by
reordering the conditions.

closes odoo/odoo#133146

Signed-off-by: Josse Colpaert <jco@odoo.com>
---
 addons/l10n_it_stock_ddt/models/stock_picking.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/addons/l10n_it_stock_ddt/models/stock_picking.py b/addons/l10n_it_stock_ddt/models/stock_picking.py
index 2707b0f10190..60e737bf2321 100644
--- a/addons/l10n_it_stock_ddt/models/stock_picking.py
+++ b/addons/l10n_it_stock_ddt/models/stock_picking.py
@@ -74,8 +74,7 @@ class StockPickingType(models.Model):
     @api.model
     def create(self, vals):
         company = self.env['res.company'].browse(vals.get('company_id', False)) or self.env.company
-        if 'l10n_it_ddt_sequence_id' not in vals or not vals['l10n_it_ddt_sequence_id'] and vals['code'] == 'outgoing' \
-                and company.country_id.code == 'IT':
+        if company.country_id.code == 'IT' and vals['code'] == 'outgoing' and ('l10n_it_ddt_sequence_id' not in vals or not vals['l10n_it_ddt_sequence_id']):
             ir_seq_name, ir_seq_prefix = self._get_dtt_ir_seq_vals(vals.get('warehouse_id'), vals['sequence_code'])
             vals['l10n_it_ddt_sequence_id'] = self.env['ir.sequence'].create({
                     'name': ir_seq_name,
-- 
GitLab