diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-07-26 12:35:36 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-07-26 12:35:36 +0700 |
| commit | ae201ad5ac392a75da087a5e1215f9b8fcd50dba (patch) | |
| tree | 7aa1d1f93a893bee75e8edefbe36fff738e984de | |
| parent | e829c7b307083b4d1fa49459e25365981ff12732 (diff) | |
<miqdad> push
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index f2799319..bc1fcd09 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -54,14 +54,29 @@ class SaleOrderLine(models.Model): is_has_disc = fields.Boolean('FlashSale Item', compute='_compute_is_has_disc', default=False) - @api.depends('discount', 'order_id.source_id') + @api.depends('product_id', 'price_unit', 'order_id.source_id') def _compute_is_has_disc(self): + website_source_id = 59 + excluded_pricelist_ids = [17022, 17027, 17026, 17025, 17024, 17023] + for line in self: - line.is_has_disc = ( - line.discount > 0 and - line.order_id.source_id and - line.order_id.source_id.id == 59 - ) + line.is_has_disc = False # default + + # Step 1: Bukan dari website? Skip + if not line.order_id.source_id or line.order_id.source_id.id != website_source_id: + continue + + # Step 2: Ambil semua pricelist item berdasarkan produk + pricelist_items = self.env['product.pricelist.item'].search([ + ('product_id', '=', line.product_id.id), + ('pricelist_id', 'not in', excluded_pricelist_ids), + ]) + + # Step 3: Jika ada pricelist_items, tandai sebagai flashsale + if pricelist_items: + line.is_has_disc = True + elif not pricelist_items: + line.is_has_disc = False def _get_outgoing_incoming_moves(self): outgoing_moves = self.env['stock.move'] |
