summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchasing_job.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/purchasing_job.py')
-rw-r--r--indoteknik_custom/models/purchasing_job.py15
1 files changed, 15 insertions, 0 deletions
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)