summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/logbook_sj.py4
-rw-r--r--indoteknik_custom/models/purchasing_job.py15
-rw-r--r--indoteknik_custom/views/purchasing_job.xml2
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>