summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-07-18 11:35:02 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-07-18 11:35:02 +0700
commitb839d55d39856031b6abfeb8f304b77b0fb145ce (patch)
tree33ddef5a0822b25bba72d98b63148639f1588744
parent2fe077d802bf143b110bc681ac039ba8bcfccb26 (diff)
(andri) add chatter & make realization form
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rw-r--r--indoteknik_custom/models/down_payment.py138
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv5
-rw-r--r--indoteknik_custom/views/down_payment.xml45
-rw-r--r--indoteknik_custom/views/down_payment_realization.xml69
5 files changed, 215 insertions, 43 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 7539f23f..29039f8b 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -171,6 +171,7 @@
'views/stock_inventory.xml',
'views/sale_order_delay.xml',
'views/down_payment.xml',
+ 'views/down_payment_realization.xml',
],
'demo': [],
'css': [],
diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py
index 7a3a39f1..14f0b171 100644
--- a/indoteknik_custom/models/down_payment.py
+++ b/indoteknik_custom/models/down_payment.py
@@ -3,6 +3,7 @@ from odoo.exceptions import UserError
from datetime import datetime
# import datetime
import logging
+_logger = logging.getLogger(__name__)
from terbilang import Terbilang
import pytz
from pytz import timezone
@@ -12,6 +13,7 @@ class DownPayment(models.Model):
_name = 'down.payment'
_description = 'Down Payment Management'
_rec_name = 'number'
+ _inherit = ['mail.thread']
user_id = fields.Many2one('res.users', string='Diajukan Oleh', default=lambda self: self.env.user, tracking=3)
@@ -34,6 +36,15 @@ class DownPayment(models.Model):
('reject', 'Rejected')
], string='Status', default='draft', tracking=3, index=True, track_visibility='onchange')
+ last_status = fields.Selection([
+ ('draft', 'Draft'),
+ ('pengajuan1', 'Menunggu Approval Departement'),
+ ('pengajuan2', 'Menunggu Pengecekan AP'),
+ ('pengajuan3', 'Menunggu Approval Pimpinan'),
+ ('approved', 'Approved'),
+ ('reject', 'Rejected')
+ ], string='Status')
+
status_pay_down_payment = fields.Selection([
('pending', 'Pending'),
('payment', 'Payment'),
@@ -57,25 +68,56 @@ class DownPayment(models.Model):
# ---------------------------------------
# AP : Manzila (Finance) ID 23
+ def _get_departement_approver(self):
+ mapping = {
+ 'sales': 19,
+ 'merchandiser': 19,
+ 'marketing': 216,
+ 'logistic': 21,
+ 'procurement': 21,
+ 'fat': 28,
+ 'hr_ga': 7,
+ }
+ return mapping.get(self.departement_type)
+
def action_realisasi_pum(self):
- self.ensure_one()
- # Logic untuk realisasi PUM
- return
+ return {
+ 'type': 'ir.actions.act_window',
+ 'name': 'Realisasi PUM',
+ 'res_model': 'realization.down.payment',
+ 'view_mode': 'form',
+ 'target': 'current',
+ 'context': {
+ 'default_pum_id': self.id,
+ 'default_value_down_payment': self.nominal,
+ }
+ }
+
def action_confirm_payment(self):
- self.ensure_one()
# Logic untuk konfirmasi pembayaran
return
- def action_reject(self):
- self.ensure_one()
- # Logic untuk konfirmasi pembayaran
+ def action_approval_check(self):
+ for record in self:
+ # user = record.user_id
+ user = self.env['res.users'].browse(3401)
+ roles = sorted(set(
+ f"{group.name} (Category: {group.category_id.name})"
+ for group in user.groups_id
+ if group.category_id.name == 'Roles'
+ ))
+ _logger.info(f"[ROLE CHECK] User: {user.name} (Login: {user.login}) Roles: {roles}")
return
- def action_approval_check(self):
- self.ensure_one()
+ def action_reject(self):
# Logic untuk konfirmasi pembayaran
- return
+ return
+
+ def action_draft(self):
+ for record in self:
+ record.status = record.last_status if record.last_status else 'draft'
+ return
@api.model
def create(self, vals):
@@ -84,33 +126,71 @@ class DownPayment(models.Model):
return super(DownPayment, self).create(vals)
+class RealizationDownPaymentLine(models.Model):
+ _name = 'realization.down.payment.line'
+ _description = 'Rincian Pemberian PUM'
+
+ realization_id = fields.Many2one('realization.down.payment', string='Realization')
+ date = fields.Date(string='Tanggal', required=True, default=fields.Date.today)
+ description = fields.Char(string='Description', required=True)
+ value = fields.Float(string='Nilai', required=True)
+
+
+class RealizationDownPaymentUseLine(models.Model):
+ _name = 'realization.down.payment.use.line'
+ _description = 'Rincian Penggunaan PUM'
+
+ realization_id = fields.Many2one('realization.down.payment', string='Realization')
+ date = fields.Date(string='Tanggal', required=True, default=fields.Date.today)
+ description = fields.Char(string='Description', required=True)
+ nominal = fields.Float(string='Nominal', required=True)
+ attachment = fields.Boolean(string='Lampiran', default=False)
+
class RealizationDownPayment(models.Model):
_name = 'realization.down.payment'
_description = 'Realization Down Payment Management'
+ _inherit = ['mail.thread']
- # number = fields.Char(string='No. Dokumen', tracking=3)
- title = fields.Char(string='Judul', required=True, tracking=3)
- goals = fields.Text(string='Tujuan', tracking=3, required=True)
- related = fields.Char(string='Terkait', tracking=3, required=True)
-
- # Page Rincian Pemberian PUM
- date_line = fields.Date(string='Tanggal', required=True, tracking=3, default=lambda self: fields.Date.today())
- info_line = fields.Char(string='Description', required=True, tracking=3)
- value_line = fields.Float(string='Nilai', required=True, tracking=3)
- grand_total = fields.Float(string='Grand Total', tracking=3)
-
- # Page Rincian Penggunaan PUM
- date_line_use = fields.Date(string='Tanggal', required=True, tracking=3, default=lambda self: fields.Date.today())
- info_line_use = fields.Char(string='Description', required=True, tracking=3)
- value_line_use = fields.Float(string='Nominal', required=True, tracking=3)
- attachment = fields.Boolean(string='Attachment', tracking=3, default=False)
- grand_total_use = fields.Float(string='Grand Total', tracking=3)
- value_down_payment = fields.Float(string='PUM', required=True, tracking=3)
- remaining_value = fields.Float(string='Sisa Uang PUM', tracking=3)
+ pum_id = fields.Many2one('down.payment', string='No PUM')
+ title = fields.Char(string='Judul', tracking=3)
+ goals = fields.Text(string='Tujuan', tracking=3)
+ related = fields.Char(string='Terkait', tracking=3,)
+
+ pemberian_line_ids = fields.One2many(
+ 'realization.down.payment.line', 'realization_id', string='Rincian Pemberian'
+ )
+ penggunaan_line_ids = fields.One2many(
+ 'realization.down.payment.use.line', 'realization_id', string='Rincian Penggunaan'
+ )
+
+ grand_total = fields.Float(string='Grand Total Pemberian', tracking=3, compute='_compute_grand_total')
+ grand_total_use = fields.Float(string='Grand Total Penggunaan', tracking=3, compute='_compute_grand_total_use')
+ value_down_payment = fields.Float(string='PUM', tracking=3)
+ remaining_value = fields.Float(string='Sisa Uang PUM', tracking=3, compute='_compute_remaining_value')
note_approval = fields.Text(string='Note Persetujuan', tracking=3)
+ currency_id = fields.Many2one(
+ 'res.currency', string='Currency',
+ default=lambda self: self.env.company.currency_id
+ )
+
+ @api.depends('pemberian_line_ids.value')
+ def _compute_grand_total(self):
+ for rec in self:
+ rec.grand_total = sum(line.value for line in rec.pemberian_line_ids)
+
+ @api.depends('penggunaan_line_ids.nominal')
+ def _compute_grand_total_use(self):
+ for rec in self:
+ rec.grand_total_use = sum(line.nominal for line in rec.penggunaan_line_ids)
+
+ @api.depends('grand_total', 'grand_total_use')
+ def _compute_remaining_value(self):
+ for rec in self:
+ rec.remaining_value = rec.value_down_payment - rec.grand_total_use
+
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index c4347709..349ed40b 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -183,4 +183,7 @@ access_production_purchase_match,access.production.purchase.match,model_producti
access_image_carousel,access.image.carousel,model_image_carousel,,1,1,1,1
access_v_sale_notin_matchpo,access.v.sale.notin.matchpo,model_v_sale_notin_matchpo,,1,1,1,1
access_approval_payment_term,access.approval.payment.term,model_approval_payment_term,,1,1,1,1
-access_down_payment,access.down.payment,model_down_payment,,1,1,1,1 \ No newline at end of file
+access_down_payment,access.down.payment,model_down_payment,,1,1,1,1
+access_realization_down_payment,access.realization.down.payment,model_realization_down_payment,,1,1,1,1
+access_realization_down_payment_line,access.realization.down.payment.line,model_realization_down_payment_line,,1,1,1,1
+access_realization_down_payment_use_line,access.realization.down.payment.use.line,model_realization_down_payment_use_line,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/down_payment.xml b/indoteknik_custom/views/down_payment.xml
index f418b932..3830154f 100644
--- a/indoteknik_custom/views/down_payment.xml
+++ b/indoteknik_custom/views/down_payment.xml
@@ -11,10 +11,14 @@
string="Realisasi"
class="btn-primary"
attrs="{}"/>
+ <button name="action_draft"
+ string="Reset to Draft"
+ attrs="{'invisible': [('status', '!=', 'reject')]}"
+ type="object"/>
<button name="action_reject"
type="object"
string="Reject"
- attrs="{}"/>
+ attrs="{'invisible': [('status', 'in', ['approved','reject'])]}"/>
<button name="action_confirm_payment"
type="object"
string="Konfirmasi Pembayaran"
@@ -34,11 +38,11 @@
</h1>
<group col="2">
<group string="">
- <field name="applicant_name" colspan="2"/>
- <field name="nominal" colspan="2"/>
- <field name="bank_name" colspan="2"/>
- <field name="account_name" colspan="2"/>
- <field name="bank_account" colspan="2"/>
+ <field name="applicant_name" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
+ <field name="nominal" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
+ <field name="bank_name" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
+ <field name="account_name" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
+ <field name="bank_account" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
</group>
<group string="" col="2">
@@ -46,13 +50,14 @@
<field name="departement_type"/>
<field name="status_pay_down_payment" readonly="1"/>
<field name="create_date" readonly="1"/>
+ <field name="detail_note" attrs="{'readonly': [('status', '=', 'approved')]}"/>
</group>
</group>
-
- <group string="">
- <field name="detail_note"/>
- </group>
</sheet>
+ <div class="oe_chatter">
+ <field name="message_follower_ids" widget="mail_followers"/>
+ <field name="message_ids" widget="mail_thread"/>
+ </div>
</form>
</field>
</record>
@@ -66,8 +71,15 @@
<field name="applicant_name"/>
<field name="nominal"/>
<field name="departement_type" optional='hide'/>
- <field name="status"/>
- <field name="status_pay_down_payment"/>
+ <field name="status"
+ readonly="1"
+ decoration-success="status == 'approved'"
+ widget="badge" optional="show"/>
+ <field name="status_pay_down_payment"
+ readonly="1"
+ decoration-success="status_pay_down_payment == 'payment'"
+ decoration-danger="status_pay_down_payment == 'pending'"
+ widget="badge"/>
</tree>
</field>
</record>
@@ -78,7 +90,14 @@
<field name="view_mode">tree,form</field>
</record>
- <menuitem id="menu_down_payment"
+ <menuitem id="menu_down_payment_acct"
+ name="Pengajuan Uang Muka (Down Payment)"
+ parent="account.menu_finance_entries"
+ sequence="114"
+ action="action_down_payment"
+ />
+
+ <menuitem id="menu_down_payment_sales"
name="Pengajuan Uang Muka (Down Payment)"
parent="sale.product_menu_catalog"
sequence="101"
diff --git a/indoteknik_custom/views/down_payment_realization.xml b/indoteknik_custom/views/down_payment_realization.xml
new file mode 100644
index 00000000..ab8034c6
--- /dev/null
+++ b/indoteknik_custom/views/down_payment_realization.xml
@@ -0,0 +1,69 @@
+<odoo>
+ <record id="view_form_realization_down_payment" model="ir.ui.view">
+ <field name="name">realization.down.payment.form</field>
+ <field name="model">realization.down.payment</field>
+ <field name="arch" type="xml">
+ <form string="Realisasi Uang Muka">
+ <sheet>
+ <h1>
+ <field name="title" class="oe_title"/>
+ </h1>
+
+ <group col="2">
+ <group>
+ <field name="pum_id" readonly="1"/>
+ <field name="goals" required="1"/>
+ <field name="related" required="1"/>
+ </group>
+ <group>
+ <field name="note_approval" required="1"/>
+ </group>
+ </group>
+
+ <notebook>
+ <page string="Rincian Pemberian">
+ <field name="pemberian_line_ids" nolabel="1">
+ <tree editable="bottom">
+ <field name="date"/>
+ <field name="description"/>
+ <field name="value" sum="Total Pemberian"/>
+ </tree>
+ </field>
+ </page>
+
+ <page string="Rincian Penggunaan">
+ <field name="penggunaan_line_ids" nolabel="1">
+ <tree editable="bottom">
+ <field name="date"/>
+ <field name="description"/>
+ <field name="nominal" sum="Total Penggunaan"/>
+ <field name="attachment"/>
+ </tree>
+ </field>
+ </page>
+ </notebook>
+
+ <group col="2">
+ <group class="oe_subtotal_footer oe_right">
+ <field name="currency_id" invisible="1"/>
+ <field name="grand_total" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
+ <field name="grand_total_use" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
+ <field name="value_down_payment" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}" style="font-weight: bold;"/>
+ <field name="remaining_value" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
+ </group>
+ </group>
+ </sheet>
+ <div class="oe_chatter">
+ <field name="message_follower_ids" widget="mail_followers"/>
+ <field name="message_ids" widget="mail_thread"/>
+ </div>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_realization_down_payment" model="ir.actions.act_window">
+ <field name="name">Realisasi PUM</field>
+ <field name="res_model">realization.down.payment</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+</odoo>