summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-01 17:30:48 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-01 17:30:48 +0700
commitafda28eb5bcda235c3c0b9479884894f9cd88c8c (patch)
treebd1531a10958d08e306d0182cf973700c84d7d78
parentd3d354b67fe8865d29521f8c23d336176e394f64 (diff)
<iman> add inrernal input
-rw-r--r--indoteknik_custom/models/user_company_request.py20
-rw-r--r--indoteknik_custom/views/user_company_request.xml4
2 files changed, 23 insertions, 1 deletions
diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py
index d540b0f6..f86f3872 100644
--- a/indoteknik_custom/models/user_company_request.py
+++ b/indoteknik_custom/models/user_company_request.py
@@ -1,4 +1,4 @@
-from odoo import models, fields
+from odoo import models, fields, api
from odoo.exceptions import UserError
from odoo.http import request
@@ -13,14 +13,32 @@ class UserCompanyRequest(models.Model):
('approved', 'Approve'),
('rejected', 'Reject'),
], string='Approval')
+ internal_input = fields.Char(string='Internal Input')
+ company_type = fields.Char(string='Company Type', compute='_compute_company_type')
+
+ @api.depends('user_company_id.customer_type')
+ def _compute_company_type(self):
+ for record in self:
+ if record.user_company_id.customer_type == 'nonpkp':
+ record.company_type = 'Non PKP'
+ elif record.user_company_id.customer_type == 'pkp':
+ record.company_type = 'PKP'
+ else:
+ record.company_type = 'company type belum di set'
def write(self, vals):
user = self.get_user_by_email(self.user_id.email)
user.parent_name = self.user_input
is_approve = vals.get('is_approve')
+ is_internal_input = vals.get('internal_input')
if self.is_approve and is_approve:
raise UserError('Tidak dapat mengubah approval yang sudah diisi')
+ if is_internal_input:
+ if self.user_company_id.nama_wajib_pajak == self.user_company_id.name:
+ self.user_company_id.nama_wajib_pajak = is_internal_input
+ self.user_company_id.name = is_internal_input
+
if not self.is_approve and is_approve:
if is_approve == 'approved':
self.user_id.parent_id = self.user_company_id.id
diff --git a/indoteknik_custom/views/user_company_request.xml b/indoteknik_custom/views/user_company_request.xml
index c9edd3f8..bff06ecd 100644
--- a/indoteknik_custom/views/user_company_request.xml
+++ b/indoteknik_custom/views/user_company_request.xml
@@ -14,6 +14,8 @@
decoration-success="is_approve == 'approved'"
decoration-danger="is_approve == 'rejected'"
/>
+ <field name="internal_input"/>
+ <field name="company_type"/>
<field name="create_date"/>
</tree>
</field>
@@ -36,6 +38,8 @@
decoration-success="is_approve == 'approved'"
decoration-danger="is_approve == 'rejected'"
/>
+ <field name="internal_input" />
+ <field name="company_type" readonly="1"/>
</group>
</group>
</sheet>