summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-04-04 15:51:57 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-04-04 15:51:57 +0700
commitc4c4591591bf72ddda400492c904d28a8a5324cd (patch)
treede57be97e0d8ba705b07987b17e07cfefce8a59a
parent4c192d7999b343f7211e3365132e8103d236f1b3 (diff)
fix purchase representative on purchasing job and remove approval edit line
-rwxr-xr-xindoteknik_custom/models/purchase_order.py12
-rw-r--r--indoteknik_custom/models/purchasing_job.py13
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml5
-rw-r--r--indoteknik_custom/views/purchasing_job.xml1
4 files changed, 10 insertions, 21 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 35fefbe2..098d05cb 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -56,18 +56,6 @@ class PurchaseOrder(models.Model):
from_apo = fields.Boolean(string='From APO', tracking=3)
approval_edit_line = fields.Boolean(string='Approval Edit Line', tracking=3)
- def approve_edit_line(self):
- if self.env.user.is_purchasing_manager:
- self.approval_edit_line = True
- else:
- raise UserError('Tidak memiliki akses')
-
- @api.constrains('order_line')
- def constrains_order_line(self):
- for purchase in self:
- if purchase.from_apo and not purchase.approval_edit_line:
- raise UserError('Harus approve edit line terlebih dahulu, minta ke purchasing manager')
-
@api.model
def action_multi_cancel(self):
for purchase in self:
diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py
index 6276d554..ea8f9298 100644
--- a/indoteknik_custom/models/purchasing_job.py
+++ b/indoteknik_custom/models/purchasing_job.py
@@ -48,9 +48,10 @@ class PurchasingJob(models.Model):
SELECT
pol.product_id,
po.user_id,
- ROW_NUMBER() OVER (PARTITION BY pol.product_id ORDER BY po.create_date DESC) AS order_rank
+ ROW_NUMBER() OVER (PARTITION BY po.partner_id ORDER BY po.create_date DESC) AS order_rank
FROM purchase_order po
RIGHT JOIN purchase_order_line pol ON pol.order_id = po.id
+ LEFT JOIN res_partner rp ON rp.id = po.partner_id
)
SELECT
pmp.product_id AS id,
@@ -65,7 +66,11 @@ class PurchasingJob(models.Model):
pmp.action,
MAX(pjs.status_apo) AS status_apo,
MAX(pjs.note) AS note,
- MAX(po.user_id) AS purchase_representative_id
+ CASE
+ WHEN sub.vendor_id = 5571 THEN 27
+ WHEN sub.vendor_id = 9688 THEN 397
+ ELSE (CASE WHEN RANDOM() < 0.5 THEN 397 ELSE 1036 END)
+ END AS purchase_representative_id
FROM v_procurement_monitoring_by_product pmp
LEFT JOIN purchasing_job_state pjs ON pjs.purchasing_job_id = pmp.product_id
LEFT JOIN (
@@ -76,9 +81,9 @@ class PurchasingJob(models.Model):
LEFT JOIN sale_order_line sol ON sol.id = vso.sale_line_id
LEFT JOIN res_partner rp ON rp.id = sol.vendor_id
) AS sub ON sub.product_id = pmp.product_id
- LEFT JOIN latest_purchase_orders po ON po.product_id = pmp.product_id AND po.order_rank = 1
+ LEFT JOIN latest_purchase_orders po ON po.product_id = pmp.product_id
WHERE pmp.action = 'kurang'
- AND sub.vendor_id <> 1
+ AND sub.vendor_id IS NOT NULL
GROUP BY
pmp.product_id,
pmp.brand,
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 68622a8e..33603216 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -20,11 +20,6 @@
type="object"
attrs="{'invisible': [('approval_status', '=', 'approved')]}"
/>
- <button name="approve_edit_line"
- string="Approve Edit"
- type="object"
- attrs="{'invisible': [('from_apo', '=', False), ('approval_edit_line', '=', True)]}"
- />
<button name="indoteknik_custom.action_view_uangmuka_pembelian" string="UangMuka"
type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/>
</button>
diff --git a/indoteknik_custom/views/purchasing_job.xml b/indoteknik_custom/views/purchasing_job.xml
index b0ecd359..290955cf 100644
--- a/indoteknik_custom/views/purchasing_job.xml
+++ b/indoteknik_custom/views/purchasing_job.xml
@@ -46,6 +46,7 @@
<field name="incoming"/>
<field name="outgoing"/>
<field name="purchase_representative_id"/>
+ <field name="vendor_id"/>
<field name="note"/>
</group>
</group>