From 80da0a90852cc589f5e2f10cc1b7df1c48ddb0b2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 23 Jun 2023 16:48:08 +0700 Subject: Add used percentage on program line response --- indoteknik_custom/models/promotion_program_line.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/promotion_program_line.py b/indoteknik_custom/models/promotion_program_line.py index 55331aea..e300a5d1 100644 --- a/indoteknik_custom/models/promotion_program_line.py +++ b/indoteknik_custom/models/promotion_program_line.py @@ -129,6 +129,9 @@ class PromotionProgramLine(models.Model): def format(self, user = None): ir_attachment = self.env['ir.attachment'] product_price = self.product_id.calculate_website_price() + limit_qty = self._res_limit_qty() + remaining_qty = self._get_remaining_qty(user) + percent_remaining = (remaining_qty['all'] - limit_qty['all']) / remaining_qty['all'] return { 'id': self.id, 'name': self.name, @@ -137,8 +140,9 @@ class PromotionProgramLine(models.Model): 'applies_multiply': self.applies_multiply, 'remaining_time': self._get_remaining_time(), 'type': self._res_promotion_type(), - 'limit_qty': self._res_limit_qty(), - 'remaining_qty': self._get_remaining_qty(user), + 'limit_qty': limit_qty, + 'remaining_qty': remaining_qty, + 'percent_remaining': percent_remaining, 'price': self.calculate_price(price=product_price) } -- cgit v1.2.3