summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/res_partner.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-04 17:15:20 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-04 17:15:20 +0700
commit4643df754b03eb3f8ae9567bc5b5327934b6cc83 (patch)
tree5725139840da5ce148682848b7d0dd9cac4a7f20 /indoteknik_custom/models/res_partner.py
parent066f8b9d9499be72cdbb4fb0a8d0e6ee766fdc4d (diff)
<iman> update new register
Diffstat (limited to 'indoteknik_custom/models/res_partner.py')
-rw-r--r--indoteknik_custom/models/res_partner.py46
1 files changed, 36 insertions, 10 deletions
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index 6a1257f8..9f2c82e2 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -98,20 +98,46 @@ class ResPartner(models.Model):
alamat_lengkap = fields.Char(string="Alamat Lengkap", required=False, compute="_alamat_lengkap")
alamat_lengkap_text = fields.Text(string="Alamat Lengkap", required=False)
- def write(self, vals):
- res = super(ResPartner, self).write(vals)
-
- # if 'property_payment_term_id' in vals:
- # if not self.env.user.is_accounting and vals['property_payment_term_id'] != 26:
- # raise UserError('Hanya Finance Accounting yang dapat merubah payment term')
+ # def write(self, vals):
+ # res = super(ResPartner, self).write(vals)
+ #
+ # # if 'property_payment_term_id' in vals:
+ # # if not self.env.user.is_accounting and vals['property_payment_term_id'] != 26:
+ # # raise UserError('Hanya Finance Accounting yang dapat merubah payment term')
+ #
+ # # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ # # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ # # if self.env.user.id not in users_in_group.mapped('id'):
+ # # raise UserError('You name it')
+ #
+ # return res
- # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
- # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
- # if self.env.user.id not in users_in_group.mapped('id'):
- # raise UserError('You name it')
+ def write(self, vals):
+ if self.company_type == 'person':
+ if self.parent_id:
+ parent = self.parent_id
+ vals['customer_type'] = parent.customer_type
+ vals['nama_wajib_pajak'] = parent.nama_wajib_pajak
+ vals['npwp'] = parent.npwp
+ vals['sppkp'] = parent.sppkp
+ vals['alamat_lengkap_text'] = parent.alamat_lengkap_text
+ vals['industry_id'] = parent.industry_id.id
+ vals['company_type_id'] = parent.company_type_id.id
+ res = super(ResPartner, self).write(vals)
return res
+ @api.onchange('company_type')
+ def _onchange_company_type(self):
+ if self.company_type == 'person' and self.parent_id:
+ self.customer_type = self.parent_id.customer_type
+ self.npwp = self.parent_id.npwp
+ self.sppkp = self.parent_id.sppkp
+ self.nama_wajib_pajak = self.parent_id.nama_wajib_pajak
+ self.alamat_lengkap_text = self.parent_id.alamat_lengkap_text
+ self.industry_id = self.parent_id.industry_id.id
+ self.company_type_id = self.parent_id.company_type_id.id
+
@api.constrains('property_payment_term_id')
def updated_by_payment_term(self):
for rec in self: