summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/partial_delivery.py
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2025-11-25 08:59:41 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2025-11-25 08:59:41 +0700
commit1e10f5149dcd753018b919aa9fac5e54c81a533c (patch)
tree4e561a147c6250b7d4eb41bb8bce500eee0014bd /indoteknik_custom/models/partial_delivery.py
parentbb2be920076aabc49b4f9fdd896d14e096e633eb (diff)
parent61aabd2a7be015a19d9a16d8e160f5a3c3c6efaf (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into locator_mqddlocator_mqdd
merge
Diffstat (limited to 'indoteknik_custom/models/partial_delivery.py')
-rw-r--r--indoteknik_custom/models/partial_delivery.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/indoteknik_custom/models/partial_delivery.py b/indoteknik_custom/models/partial_delivery.py
index 519f505c..4e8ddbda 100644
--- a/indoteknik_custom/models/partial_delivery.py
+++ b/indoteknik_custom/models/partial_delivery.py
@@ -213,14 +213,22 @@ class PartialDeliveryWizard(models.TransientModel):
new_picking.action_assign()
picking.action_assign()
- existing_partials = self.env['stock.picking'].search([
- ('origin', '=', picking.origin),
- ('state_reserve', '=', 'partial'),
+ origin_name = picking.name
+
+ existing_siblings = self.env['stock.picking'].search([
+ ('name', 'like', f"{origin_name}/%"),
('id', '!=', new_picking.id),
- ], order='name asc')
+ ])
+
+ suffixes = []
+ for p in existing_siblings:
+ match = re.search(r'/(\d+)$', p.name)
+ if match:
+ suffixes.append(int(match.group(1)))
+
+ next_suffix = max(suffixes) + 1 if suffixes else 1
- suffix_number = len(existing_partials) + 1
- new_picking.name = f"{picking.name}/{suffix_number}"
+ new_picking.name = f"{origin_name}/{next_suffix}"
if picking.origin:
sale_order = self.env['sale.order'].search([('name', '=', picking.origin)], limit=1)