diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-08-09 14:35:00 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-08-09 14:35:00 +0700 |
| commit | ba20997c842be46b6759aad7d4dfa3736c522982 (patch) | |
| tree | 67e8522f96bef1bca54088f4d31625177aed7289 | |
| parent | 48159b92cfa466ff7df454aa3c860b79c7e18467 (diff) | |
<miqdad> origin po can be clicked
| -rw-r--r-- | indoteknik_custom/models/tukar_guling_po.py | 11 | ||||
| -rw-r--r-- | indoteknik_custom/views/tukar_guling_po.xml | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 0badc117..03d7668f 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -62,6 +62,16 @@ class TukarGulingPO(models.Model): is_has_bill = fields.Boolean('Has Bill?', compute='_compute_is_has_bill', readonly=True, default=False) bill_id = fields.Many2many('account.move', string='Bill Ref', readonly=True) + origin_po = fields.Many2one('purchase.order', string='Origin PO', compute='_compute_origin_po') + + @api.depends('origin', 'operations') + def _compute_origin_po(self): + for rec in self: + rec.origin_po = False + origin_str = rec.origin or rec.operations.origin + if origin_str: + so = self.env['purchase.order'].search([('name', '=', origin_str)], limit=1) + rec.origin_po = so.id if so else False @api.depends('origin') def _compute_is_has_bill(self): @@ -133,6 +143,7 @@ class TukarGulingPO(models.Model): # Hanya update origin, jangan ubah lines if self.operations.origin: self.origin = self.operations.origin + self.origin_po = self.operations.group_id.id return if from_return_picking: diff --git a/indoteknik_custom/views/tukar_guling_po.xml b/indoteknik_custom/views/tukar_guling_po.xml index bc696a3d..739a4f9c 100644 --- a/indoteknik_custom/views/tukar_guling_po.xml +++ b/indoteknik_custom/views/tukar_guling_po.xml @@ -89,11 +89,11 @@ attrs="{ 'required': [('return_type', 'in', ['revisi_po', 'tukar_guling'])] }"/> - <field name="origin" readonly="1"/> +<!-- <field name="origin" readonly="1"/>--> + <field name="origin_po" readonly="1"/> <field name="is_has_bill" readonly="1"/> <!-- <field name="bill_id" readonly="1" />--> <field name="bill_id" readonly="1" widget="many2many_tags"/> - <!-- <field name="origin_so" readonly="1"/>--> </group> <group> <field name="val_bil_opt" attrs="{'invisible': [('is_has_bill', '=', False)]}"/> |
