diff options
| author | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-18 15:26:50 +0700 |
|---|---|---|
| committer | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-18 15:26:50 +0700 |
| commit | a4363a5468a5a9d6a3815cb8ae304fe1da3aef30 (patch) | |
| tree | caf2b1280cd19e4e4ede9574000da34d7b804ec1 | |
| parent | ef67567976a24d59fe8859b55480e4053b64f65f (diff) | |
(andri) fix field + readonly action view journal
| -rw-r--r-- | indoteknik_custom/models/advance_payment_request.py | 35 | ||||
| -rw-r--r-- | indoteknik_custom/views/advance_payment_request.xml | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/advance_payment_settlement.xml | 6 |
3 files changed, 38 insertions, 6 deletions
diff --git a/indoteknik_custom/models/advance_payment_request.py b/indoteknik_custom/models/advance_payment_request.py index eba01550..ad97755a 100644 --- a/indoteknik_custom/models/advance_payment_request.py +++ b/indoteknik_custom/models/advance_payment_request.py @@ -146,6 +146,17 @@ class AdvancePaymentRequest(models.Model): compute='_compute_total_reimburse' ) + is_current_user_ap = fields.Boolean( + string="Is Current User AP", + compute='_compute_is_current_user_ap' + ) + + def _compute_is_current_user_ap(self): + ap_user_ids = [23, 9468] + is_ap = self.env.user.id in ap_user_ids + for line in self: + line.is_current_user_ap = is_ap + @api.depends('reimburse_line_ids.total') def _compute_total_reimburse(self): for request in self: @@ -429,7 +440,7 @@ class AdvancePaymentRequest(models.Model): 'target': 'current', 'context': { 'default_pum_id': self.id, - 'default_value_down_payment': self.nominal, + # 'default_value_down_payment': self.nominal, 'default_name': f'Realisasi - {self.number or ""}', # 'default_pemberian_line_ids': [ # (0, 0, { @@ -849,7 +860,7 @@ class AdvancePaymentSettlement(models.Model): _inherit = ['mail.thread'] _rec_name = 'name' - pum_id = fields.Many2one('advance.payment.request', string='No PUM') + pum_id = fields.Many2one('advance.payment.request', string='No PUM', ondelete='cascade') name = fields.Char(string='Nama', readonly=True, tracking=3) title = fields.Char(string='Judul', tracking=3) goals = fields.Text(string='Tujuan', tracking=3) @@ -862,9 +873,14 @@ class AdvancePaymentSettlement(models.Model): 'advance.payment.usage.line', 'realization_id', string='Rincian Penggunaan' ) + nominal_pum = fields.Float( + string='Nominal Pemberian PUM', + related='pum_id.nominal', + readonly=True ) + # 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) + # 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) @@ -933,6 +949,16 @@ class AdvancePaymentSettlement(models.Model): related='pum_id.applicant_name', readonly=True ) + is_current_user_ap = fields.Boolean( + string="Is Current User AP", + compute='_compute_is_current_user_ap' + ) + + def _compute_is_current_user_ap(self): + ap_user_ids = [23, 9468] + is_ap = self.env.user.id in ap_user_ids + for line in self: + line.is_current_user_ap = is_ap def action_toggle_check_attachment(self): ap_user_ids = [23, 9468] @@ -1003,7 +1029,10 @@ class AdvancePaymentSettlement(models.Model): for rec in self: rec.grand_total_use = sum(line.nominal for line in rec.penggunaan_line_ids) + @api.depends('nominal_pum', 'grand_total_use') def _compute_remaining_value(self): + for rec in self: + rec.remaining_value = rec.nominal_pum - rec.grand_total_use return def action_validation(self): diff --git a/indoteknik_custom/views/advance_payment_request.xml b/indoteknik_custom/views/advance_payment_request.xml index ba565ce7..073fa815 100644 --- a/indoteknik_custom/views/advance_payment_request.xml +++ b/indoteknik_custom/views/advance_payment_request.xml @@ -51,11 +51,12 @@ <field name="settlement_name" widget="statinfo" string="Realisasi PUM"/> </button> <field name="is_cab_visible" invisible="1"/> + <field name="is_current_user_ap" invisible="1"/> <button type="object" name="action_view_journal_uangmuka" class="oe_stat_button" icon="fa-book" - attrs="{'invisible': [('is_cab_visible', '=', False)]}" + attrs="{'invisible': [('is_cab_visible', '=', False)], 'readonly': [('is_current_user_ap', '=', False)]}" style="width: 200px;"> <field name="move_id" widget="statinfo" string="Journal Uang Muka"/> <span class="o_stat_text"> diff --git a/indoteknik_custom/views/advance_payment_settlement.xml b/indoteknik_custom/views/advance_payment_settlement.xml index 7834d494..d6eaa649 100644 --- a/indoteknik_custom/views/advance_payment_settlement.xml +++ b/indoteknik_custom/views/advance_payment_settlement.xml @@ -31,11 +31,12 @@ <widget name="web_ribbon" title="Realized" attrs="{'invisible': [('done_status', '!=', 'done_realized')]}"/> <div class="oe_button_box" name="button_box"> <field name="is_cab_visible" invisible="1"/> + <field name="is_current_user_ap" invisible="1"/> <button type="object" name="action_view_journal_uangmuka" class="oe_stat_button" icon="fa-book" - attrs="{'invisible': [('is_cab_visible', '=', False)]}" + attrs="{'invisible': [('is_cab_visible', '=', False)], 'readonly': [('is_current_user_ap', '=', False)]}" style="width: 200px;"> <field name="move_id" widget="statinfo" string="Journal Entries"/> <span class="o_stat_text"> @@ -145,7 +146,8 @@ <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="nominal_pum" readonly="1" widget="monetary" options="{'currency_field': 'currency_id'}" style="font-weight: bold;"/> + <!-- <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> |
