summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchasing_job.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-04-02 10:06:12 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-04-02 10:06:12 +0700
commit020f545e8214ce8a32f004f1b35e03a16cec1dfb (patch)
tree217669b263e5d2ef443de192f4b1f14fa855d283 /indoteknik_custom/models/purchasing_job.py
parentedc044818cf8ec9fc16dea7fd18a62c277502657 (diff)
fix partner_id on logbook sj and add purchase representative on purchasing job
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)