From 8a3717c34e0968f3f6ddd7d0cc4fb18aeb218bfe Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Fri, 20 Jun 2025 10:04:01 +0700 Subject: (andri) ganti no dokumen yang lama (CC) sesuai dengan commision type yang dipilih (RB/FE/CB) --- indoteknik_custom/models/commision.py | 35 ++++++++++++++++++++++++--------- indoteknik_custom/views/ir_sequence.xml | 32 +++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 215e2ded..46718397 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -175,7 +175,7 @@ class CustomerCommision(models.Model): ('approved', 'Approved'), ('reject', 'Rejected'), ], string='Status') - + # commision_percent = fields.Float(string='Commision %', tracking=3) commision_percent = fields.Float(string='Cashback %', tracking=3) @@ -357,14 +357,31 @@ class CustomerCommision(models.Model): @api.model def create(self, vals): - vals['number'] = self.env['ir.sequence'].next_by_code('customer.commision') or '0' - # if vals['commision_amt'] > 0: - # commision_amt = vals['commision_amt'] - # total_dpp = vals['total_dpp'] - # commision_percent = commision_amt / total_dpp * 100 - # vals['commision_percent'] = commision_percent - result = super(CustomerCommision, self).create(vals) - return result + commision_type = vals.get('commision_type') + + if commision_type == 'cashback': + sequence_code = 'customer.commision.cashback' + elif commision_type == 'fee': + sequence_code = 'customer.commision.fee' + elif commision_type == 'rebate': + sequence_code = 'customer.commision.rebate' + else: + raise UserError('Tipe komisi tidak dikenal!') + + vals['number'] = self.env['ir.sequence'].next_by_code(sequence_code) or '0' + + return super(CustomerCommision, self).create(vals) + + # @api.model + # def create(self, vals): + # vals['number'] = self.env['ir.sequence'].next_by_code('customer.commision') or '0' + # # if vals['commision_amt'] > 0: + # # commision_amt = vals['commision_amt'] + # # total_dpp = vals['total_dpp'] + # # commision_percent = commision_amt / total_dpp * 100 + # # vals['commision_percent'] = commision_percent + # result = super(CustomerCommision, self).create(vals) + # return result def action_confirm_customer_commision(self): jakarta_tz = pytz.timezone('Asia/Jakarta') diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index 97bf40bb..bb8848c4 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -131,7 +131,7 @@ 1 - + + + + Customer Commision Cashback + customer.commision.cashback + CB/%(year)s/ + 5 + 1 + 1 + True + + + + Customer Commision Fee + customer.commision.fee + FE/%(year)s/ + 5 + 1 + 1 + True + + + + Customer Commision Rebate + customer.commision.rebate + RB/%(year)s/ + 5 + 1 + 1 + True -- cgit v1.2.3