summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-02-19 09:39:37 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-02-19 09:39:37 +0700
commit069b3ba1af8025c75a5a1c2a772137aafb428a85 (patch)
tree980d045c3600d38ae832a45482c7dc62e3fbf730
parent10c0cd096353397ce26ad13b6967a35d13072fb6 (diff)
parenta9abc6b63f1bafb1e007da4446636ec2da10d493 (diff)
Merge branch 'odoo-production' of bitbucket.org:altafixco/indoteknik-addons into odoo-production
-rwxr-xr-xindoteknik_custom/models/sale_order.py5
-rw-r--r--indoteknik_custom/models/user_pengajuan_tempo_request.py13
-rw-r--r--indoteknik_custom/views/user_pengajuan_tempo_request.xml12
3 files changed, 27 insertions, 3 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 9631fe6e..430b4526 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -942,6 +942,7 @@ class SaleOrder(models.Model):
# Ambil blocking stage dari partner
block_stage = rec.partner_id.parent_id.blocking_stage if rec.partner_id.parent_id else rec.partner_id.blocking_stage or 0
+ is_cbd = rec.partner_id.parent_id.property_payment_term_id.id == 26 if rec.partner_id.parent_id else rec.partner_id.property_payment_term_id.id == 26 or False
# Ambil jumlah nilai dari SO yang invoice_status masih 'to invoice'
so_to_invoice = 0
@@ -952,7 +953,7 @@ class SaleOrder(models.Model):
remaining_credit_limit = block_stage - current_total - so_to_invoice
# Validasi limit
- if remaining_credit_limit <= 0 and block_stage > 0:
+ if remaining_credit_limit <= 0 and block_stage > 0 and not is_cbd:
raise UserError(_("The credit limit for %s will exceed the Blocking Stage if the Sale Order is confirmed. The remaining credit limit is %s, from %s and the outstanding amount is %s.")
% (rec.partner_id.name, block_stage - current_total, block_stage, outstanding_amount))
@@ -1118,7 +1119,7 @@ class SaleOrder(models.Model):
return False
def _requires_approval_margin_leader(self):
- return self.total_percent_margin <= 13 and not self.env.user.is_leader
+ return self.total_percent_margin < 15 and not self.env.user.is_leader
def _requires_approval_margin_manager(self):
return self.total_percent_margin <= 20 and not self.env.user.is_leader and not self.env.user.is_sales_manager
diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py
index 4a1994fb..be4293a0 100644
--- a/indoteknik_custom/models/user_pengajuan_tempo_request.py
+++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py
@@ -63,6 +63,19 @@ class UserPengajuanTempoRequest(models.Model):
('reject', 'Rejected'),
], string='Status',)
reason_reject = fields.Char(string='Reason Reaject', tracking=True, track_visibility='onchange')
+ state_tempo_text = fields.Char(string="Status", compute="_compute_state_tempo_text")
+
+ @api.depends('state_tempo')
+ def _compute_state_tempo_text(self):
+ for record in self:
+ status_mapping = {
+ 'draft': "Menunggu Approve Manager",
+ 'approval_sales': "Menunggu Approve Finance",
+ 'approval_finance': "Menunggu Approve Direktur",
+ 'approval_director': "Approved",
+ 'reject': "Rejected",
+ }
+ record.state_tempo_text = status_mapping.get(record.state_tempo, "Unknown")
# informasi perusahaan
name_tempo = fields.Many2one('res.partner', string='Nama Perusahaan', related='pengajuan_tempo_id.name_tempo', store=True, tracking=True, readonly=False)
diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml
index f7ad9afb..7063231b 100644
--- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml
+++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml
@@ -10,7 +10,17 @@
<field name="create_date"/>
<field name="tempo_duration" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}"/>
<field name="tempo_limit" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}" placeholder="Contoh format, misalnya '10000000'" widget="monetary" options="{'currency_field': 'currency_id'}"/>
- <field name="state_tempo" decoration-success="state_tempo == 'approval_director'" decoration-danger="state_tempo == 'reject'" widget="badge" optional="show"/>
+<!-- <field name="state_tempo"-->
+<!-- decoration-danger="state_tempo == 'reject'"-->
+<!-- decoration-warning="state_tempo in ('draft', 'approval_sales', 'approval_finance')"-->
+<!-- decoration-success="state_tempo == 'approval_director'">-->
+<!-- <tree>-->
+<!-- <field name="state_tempo" invisible="1"/>-->
+<!-- <field name="state_tempo_text" string="Status"/>-->
+<!-- </tree>-->
+<!-- </field>-->
+ <field name="state_tempo" invisible="1"/>
+ <field name="state_tempo_text" decoration-success="state_tempo_text == 'Approved'" decoration-danger="state_tempo_text == 'Rejected'" widget="badge" optional="show"/>
</tree>
</field>
</record>