diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-09-17 11:28:17 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-09-17 11:28:17 +0000 |
| commit | cd125948ff6d11a2da567db25dc15ab11b2052e2 (patch) | |
| tree | 9fcaa8dfa5b671f95966c8e4e5e697de093c14ae | |
| parent | 1fdeef8073eb35b407bb0b3cdb26bf635b3b1629 (diff) | |
| parent | 701db966d5780ab0322e8cd9ca13acf06e10acdb (diff) | |
Merged in cr_bu-related (pull request #420)
<Miqdad> BU related PO
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 68180235..0304b5e2 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -198,8 +198,11 @@ class PurchaseOrder(models.Model): # Ambil semua BU awal dari PO base_bu = StockPicking.search([ + '|', + '&', ('name', 'ilike', 'BU/'), - ('origin', 'ilike', order.name) + ('group_id.id', '=', order.group_id.id), + ('origin', '=', order.name), ]) all_bu = base_bu @@ -229,10 +232,12 @@ class PurchaseOrder(models.Model): # Step 1: cari semua BU pertama (PUT, INT) yang berasal dari PO ini base_bu = StockPicking.search([ + '|', + '&', ('name', 'ilike', 'BU/'), - ('origin', 'ilike', self.name) + ('group_id.id', '=', self.group_id.id), + ('origin', '=', self.name), ]) - all_bu = base_bu seen_names = set(base_bu.mapped('name')) @@ -243,10 +248,10 @@ class PurchaseOrder(models.Model): ('origin', 'in', ['Return of %s' % name for name in seen_names]) ]) next_names = set(next_bu.mapped('name')) - + if not next_names - seen_names: break - + all_bu |= next_bu seen_names |= next_names |
