diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-28 10:55:56 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-28 10:55:56 +0700 |
| commit | 7909b937bf9484b38f16be1f4be955094e0c25ab (patch) | |
| tree | e0d615aaeefca002c8627dc32e74929c2ce7be36 | |
| parent | 4d8dee6da82637f406373a8cd3258a47529bb59f (diff) | |
<iman> aupdate company request
| -rw-r--r-- | indoteknik_custom/models/user_company_request.py | 19 | ||||
| -rw-r--r-- | indoteknik_custom/views/user_company_request.xml | 10 |
2 files changed, 25 insertions, 4 deletions
diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index d540b0f6..706bb245 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,6 +13,18 @@ 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) @@ -21,6 +33,11 @@ class UserCompanyRequest(models.Model): if self.is_approve and is_approve: raise UserError('Tidak dapat mengubah approval yang sudah diisi') + if self.internal_input: + if self.user_company_id.nama_wajib_pajak == self.user_company_id.name: + self.user_company_id.nama_wajib_pajak = self.internal_input + self.user_company_id.name = self.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..ad121a89 100644 --- a/indoteknik_custom/views/user_company_request.xml +++ b/indoteknik_custom/views/user_company_request.xml @@ -8,12 +8,14 @@ <field name="user_id"/> <field name="user_company_id"/> <field name="user_input"/> - <field + <field name="is_approve" widget="badge" decoration-success="is_approve == 'approved'" decoration-danger="is_approve == 'rejected'" /> + <field name="internal_input"/> + <field name="company_type"/> <field name="create_date"/> </tree> </field> @@ -30,12 +32,14 @@ <field name="user_id" readonly="1"/> <field name="user_company_id" readonly="1"/> <field name="user_input" readonly="1"/> - <field - name="is_approve" + <field + name="is_approve" required="1" decoration-success="is_approve == 'approved'" decoration-danger="is_approve == 'rejected'" /> + <field name="internal_input" /> + <field name="company_type" readonly="1"/> </group> </group> </sheet> |
