diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-02 10:06:12 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-02 10:06:12 +0700 |
| commit | 020f545e8214ce8a32f004f1b35e03a16cec1dfb (patch) | |
| tree | 217669b263e5d2ef443de192f4b1f14fa855d283 | |
| parent | edc044818cf8ec9fc16dea7fd18a62c277502657 (diff) | |
fix partner_id on logbook sj and add purchase representative on purchasing job
| -rw-r--r-- | indoteknik_custom/models/logbook_sj.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchasing_job.py | 15 | ||||
| -rw-r--r-- | indoteknik_custom/views/purchasing_job.xml | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py index d12d3feb..9e3daf20 100644 --- a/indoteknik_custom/models/logbook_sj.py +++ b/indoteknik_custom/models/logbook_sj.py @@ -27,6 +27,8 @@ class LogbookSJ(models.TransientModel): for line in logbook_line: picking = self.env['stock.picking'].search([('picking_code', '=', line.name)], limit=1) stock = picking + parent_id = stock.partner_id.parent_id.id + parent_id = parent_id if parent_id else stock.partner_id.id data = { 'picking_id': stock.id, @@ -37,7 +39,7 @@ class LogbookSJ(models.TransientModel): 'arrival_date': stock.driver_arrival_date, 'carrier_id': stock.carrier_id.id, 'tracking_no': stock.delivery_tracking_no, - 'partner_id': stock.partner_id.id, + 'partner_id': parent_id, 'report_logbook_sj_id': report_logbook.id } self.env['report.logbook.sj.line'].create([data]) diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index ac9ea272..a4cb3893 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -23,6 +23,21 @@ class PurchasingJob(models.Model): ('not_apo', 'Belum APO'), ('apo', 'APO') ], string='APO?') + purchase_representative_id = fields.Many2one('res.users', string="Purchase Representative", readonly=True, compute='compute_purchase_representative') + + def compute_purchase_representative(self): + for rec in self: + po = self.env['purchase.order'].search([ + ('order_line.product_id', '=', rec.product_id.id), + ('user_id', '!=', False) + ], limit=1, order='id desc') + + user_id = False + + if po: + user_id = po.user_id + + rec.purchase_representative_id = user_id def init(self): tools.drop_view_if_exists(self.env.cr, self._table) diff --git a/indoteknik_custom/views/purchasing_job.xml b/indoteknik_custom/views/purchasing_job.xml index c307ce11..bad4b938 100644 --- a/indoteknik_custom/views/purchasing_job.xml +++ b/indoteknik_custom/views/purchasing_job.xml @@ -7,6 +7,7 @@ <tree create="false" multi_edit="1"> <field name="product_id"/> <field name="vendor_id"/> + <field name="purchase_representative_id"/> <field name="brand"/> <field name="item_code"/> <field name="product"/> @@ -37,6 +38,7 @@ <field name="onhand"/> <field name="incoming"/> <field name="outgoing"/> + <field name="purchase_representative_id"/> </group> </group> </sheet> |
