diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-16 07:50:57 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-16 07:50:57 +0700 |
| commit | 32f33ae528f4f9883f38b8afba2ce79222eed4e5 (patch) | |
| tree | 624cb5bdb3953130f83fb5e7276b9e22f8a53fc2 | |
| parent | 1fecc88986f5621c4db37ef3e76bdff5cf33f577 (diff) | |
<miqdad> tukar guling fill bu/in or bu/out
| -rw-r--r-- | indoteknik_custom/models/tukar_guling.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index b4a901d0..f62206e8 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -30,13 +30,17 @@ class TukarGuling(models.Model): line_ids = fields.One2many('tukar.guling.line', 'tukar_guling_id', string='Product Lines') - @api.constrains('return_type', 'out_num', 'in_num') - def _check_return_type_fields(self): - for rec in self: - if rec.return_type in ['tukar_guling', 'credit_memo', 'revisi_so'] and not rec.out_num: - raise ValidationError("Field BU/Out wajib diisi untuk jenis return type tersebut.") - if rec.return_type in ['debit_memo', 'revisi_po'] and not rec.in_num: - raise ValidationError("Field BU/In wajib diisi untuk jenis return type tersebut.") + @api.onchange('return_type') + def _onchange_return_type(self): + domain = [] + if self.return_type in ['debit_memo', 'revisi_po']: + domain = [('picking_type_id.code', '=', 'incoming')] + elif self.return_type in ['revisi_so', 'credit_memo']: + domain = [('picking_type_id.code', '=', 'outgoing')] + elif self.return_type == 'tukar_guling': + domain = [('picking_type_id.code', 'in', ['incoming', 'outgoing'])] + + return {'domain': {'in_num': domain}} @api.constrains('line_ids', 'state') def _check_product_lines(self): |
