diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-05-08 07:12:04 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-05-08 07:12:04 +0700 |
| commit | 667ae638f2e9ec9c699037e8f2dac9f53199bc07 (patch) | |
| tree | 10633ebc43ec323cea0a6cd71fbd50fdf7308e97 /indoteknik_custom/models/automatic_purchase.py | |
| parent | a045b3dc711fb049a78db0e65088a561e0fd9c4a (diff) | |
| parent | 5bd86996e2af3eb9ce1167a3229cb290cca22e29 (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into feat_voucher_category
Diffstat (limited to 'indoteknik_custom/models/automatic_purchase.py')
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index d619e160..b66121e1 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -67,6 +67,15 @@ class AutomaticPurchase(models.Model): if count > 0: raise UserError('Ada sekitar %s SO Yang sudah create PO, berikut SO nya: %s' % (count, ', '.join(names))) + + def unlink_note_pj(self): + product = self.purchase_lines.mapped('product_id') + pj_state = self.env['purchasing.job.state'].search([ + ('purchasing_job_id', 'in', product.ids) + ]) + + for line in pj_state: + line.unlink() def create_po_from_automatic_purchase(self): if not self.purchase_lines: @@ -75,6 +84,7 @@ class AutomaticPurchase(models.Model): raise UserError('Sudah pernah di create PO') current_time = datetime.now() + self.unlink_note_pj() vendor_ids = self.env['automatic.purchase.line'].read_group( [('automatic_purchase_id', '=', self.id), ('partner_id', '!=', False)], fields=['partner_id'], @@ -699,7 +709,7 @@ class SaleNotInMatchPO(models.Model): where apsm.sale_line_id not in ( select distinct coalesce(posm.sale_line_id,0) from purchase_order_sales_match posm - left join purchase_order po on po.id = posm.purchase_order_id + join purchase_order po on po.id = posm.purchase_order_id where po.state not in ('cancel') ) ) |
