From b1c7b43c51c670e42a0dd2399139fbd9a600f121 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 24 Jul 2025 16:16:36 +0700 Subject: is disc item from web --- indoteknik_custom/models/sale_order_line.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 5e9fc362..f2799319 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -1,6 +1,9 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError from datetime import datetime, timedelta +import logging + +__logger = logging.getLogger(__name__) class SaleOrderLine(models.Model): @@ -49,6 +52,17 @@ class SaleOrderLine(models.Model): qty_free_bu = fields.Float(string='Free BU', compute='_get_qty_free_bandengan') desc_updatable = fields.Boolean(string='desc boolean', default=True, compute='_get_desc_updatable') + is_has_disc = fields.Boolean('FlashSale Item', compute='_compute_is_has_disc', default=False) + + @api.depends('discount', 'order_id.source_id') + def _compute_is_has_disc(self): + 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 + ) + def _get_outgoing_incoming_moves(self): outgoing_moves = self.env['stock.move'] incoming_moves = self.env['stock.move'] -- cgit v1.2.3 From ae201ad5ac392a75da087a5e1215f9b8fcd50dba Mon Sep 17 00:00:00 2001 From: Miqdad Date: Sat, 26 Jul 2025 12:35:36 +0700 Subject: push --- indoteknik_custom/models/sale_order_line.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'indoteknik_custom/models') 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'] -- cgit v1.2.3 From aeb450314a0440806ceb300c71c5776d42289ad4 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Sat, 26 Jul 2025 21:02:52 +0700 Subject: push --- indoteknik_custom/models/sale_order_line.py | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index bc1fcd09..ff2e9009 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -2,8 +2,9 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError from datetime import datetime, timedelta import logging +from odoo.tools.float_utils import float_compare -__logger = logging.getLogger(__name__) +_logger = logging.getLogger(__name__) class SaleOrderLine(models.Model): @@ -52,31 +53,8 @@ class SaleOrderLine(models.Model): qty_free_bu = fields.Float(string='Free BU', compute='_get_qty_free_bandengan') desc_updatable = fields.Boolean(string='desc boolean', default=True, compute='_get_desc_updatable') - is_has_disc = fields.Boolean('FlashSale Item', compute='_compute_is_has_disc', default=False) + is_has_disc = fields.Boolean('FlashSale Item', default=False) - @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 = 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'] -- cgit v1.2.3 From e2c727fc2d1a2c9c3601368df7d4701d9b71fb82 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 28 Jul 2025 08:46:21 +0700 Subject: done(?) --- indoteknik_custom/models/sale_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index ff2e9009..428e1a9c 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -53,7 +53,7 @@ class SaleOrderLine(models.Model): qty_free_bu = fields.Float(string='Free BU', compute='_get_qty_free_bandengan') desc_updatable = fields.Boolean(string='desc boolean', default=True, compute='_get_desc_updatable') - is_has_disc = fields.Boolean('FlashSale Item', default=False) + is_has_disc = fields.Boolean('Website Disc?', default=False) def _get_outgoing_incoming_moves(self): -- cgit v1.2.3 From d5eb5c9139f016498cc70d6f241b8597b0b4b06b Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 28 Jul 2025 11:05:50 +0700 Subject: push --- indoteknik_custom/models/sale_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 428e1a9c..64b9f9bc 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -53,7 +53,7 @@ class SaleOrderLine(models.Model): qty_free_bu = fields.Float(string='Free BU', compute='_get_qty_free_bandengan') desc_updatable = fields.Boolean(string='desc boolean', default=True, compute='_get_desc_updatable') - is_has_disc = fields.Boolean('Website Disc?', default=False) + is_has_disc = fields.Boolean('Flash Sale', default=False) def _get_outgoing_incoming_moves(self): -- cgit v1.2.3