diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-04-21 07:20:58 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-04-21 07:20:58 +0000 |
| commit | dd776fedab7a86f5c031f9cdd76bf2084e894f21 (patch) | |
| tree | 6a2c5b5fd5bc5af2c9a92d6f5a29637cdffe093b | |
| parent | e5936e3e03e467f26a1047e808a9144b5c5ec3cb (diff) | |
| parent | ad139f4c1613f4571074006276d29448bfe95ff8 (diff) | |
Merged in min-deliv-amt-afp (pull request #273)
(andrifp) fix validate NPWP
| -rw-r--r-- | indoteknik_custom/models/res_partner.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 451577c5..06945301 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -39,6 +39,10 @@ class ResPartner(models.Model): estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun') tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo') tempo_limit = fields.Char(string='Limit Tempo') + minimum_amount = fields.Float( + string="Minimum Order", + help="Jika total belanja kurang dari ini, maka payment term akan otomatis menjadi CBD." + ) category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', domain=lambda self: self._get_default_category_domain()) @api.model @@ -203,13 +207,14 @@ class ResPartner(models.Model): @api.constrains('npwp') def _check_npwp(self): for record in self: - if record.npwp: - if not record.npwp.isdigit(): - raise ValidationError("NPWP hanya boleh berisi angka.") - if len(record.npwp) < 15: - raise ValidationError("Digit NPWP yang dimasukkan kurang dari batas minimal (15 digit)") - if len(record.npwp) > 16: - raise ValidationError("Digit NPWP yang dimasukkan lebih dari batas maksimal (16 digit)") + npwp = record.npwp.strip() if record.npwp else '' + # Abaikan validasi jika NPWP kosong atau diisi "0" + if not npwp or npwp == '0' or npwp == '00.000.000.0-000.000': + continue + if len(npwp) < 15: + raise ValidationError("Digit NPWP yang dimasukkan kurang dari batas minimal (15 digit)") + if len(npwp) > 16: + raise ValidationError("Digit NPWP yang dimasukkan lebih dari batas maksimal (16 digit)") def write(self, vals): # Fungsi rekursif untuk meng-update semua child, termasuk child dari child @@ -476,6 +481,8 @@ class ResPartner(models.Model): def _onchange_customer_type(self): if self.customer_type == 'nonpkp': self.npwp = '00.000.000.0-000.000' + elif self.customer_type == 'pkp': + self.npwp = '00.000.000.0-000.000' def get_check_payment_term(self): self.ensure_one() |
