summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2025-12-23 10:59:19 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2025-12-23 10:59:19 +0700
commit739efe5bbcce20b3fdb524d9045a310ffa84c0f1 (patch)
tree32fa45c5fac49a558a15ab0e4b2254bc559c6a22 /indoteknik_custom/models
parent56a252e8accd9c330826ea2e8e596792b5925af9 (diff)
<Miqdad> action seen purchasing job
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/purchasing_job.py52
1 files changed, 32 insertions, 20 deletions
diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py
index 3151f0f6..29928bbb 100644
--- a/indoteknik_custom/models/purchasing_job.py
+++ b/indoteknik_custom/models/purchasing_job.py
@@ -61,11 +61,23 @@ class PurchasingJob(models.Model):
@api.depends('so_number')
def _get_check_pj(self):
- Seen = self.env['purchasing.job.seen']
+ seen = self.env['purchasing.job.seen']
for rec in self:
- seen = Seen.search([('product_id', '=', rec.product_id.id)], limit=1)
+ seen = seen.search([('product_id', '=', rec.product_id.id)], limit=1)
rec.check_pj = bool(seen and seen.so_snapshot == rec.so_number)
+
+ def _set_as_seen(self):
+ seen_model = self.env['purchasing.job.seen']
+
+ for rec in self:
+ seen_model.create({
+ 'user_id': self.env.user.id,
+ 'product_id': rec.product_id.id,
+ 'so_snapshot': rec.so_number,
+ })
+ rec.check_pj = True
+
def unlink(self):
# Example: Delete related records from the underlying model
underlying_records = self.env['purchasing.job'].search([
@@ -78,7 +90,7 @@ class PurchasingJob(models.Model):
states = self.env['purchasing.job.state'].search([
('purchasing_job_id', '=', self.id),
],limit=1, order='id desc')
-
+
return {
'name': _('Purchasing Job State'),
'view_mode': 'form',
@@ -115,12 +127,12 @@ class PurchasingJob(models.Model):
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 (
+ LEFT JOIN (
SELECT vso.product_id,
max(sol.vendor_id) as vendor_id
FROM v_sales_outstanding vso
LEFT JOIN sale_order_line sol ON sol.id = vso.sale_line_id
- group by vso.product_id
+ group by vso.product_id
) sub ON sub.product_id = pmp.product_id
WHERE pmp.action = 'kurang'::text AND sub.vendor_id IS NOT NULL
GROUP BY pmp.product_id, pmp.brand, pmp.item_code, pmp.product, pmp.action, sub.vendor_id, pmp.so_number;
@@ -132,7 +144,7 @@ class PurchasingJob(models.Model):
'product_ids': [x.id for x in self]
}
return action
-
+
def generate_request_po(self):
# print(1)
# TODO create document automatic purchase
@@ -180,7 +192,7 @@ class PurchasingJob(models.Model):
class OutstandingSales(models.Model):
_name = 'v.sales.outstanding'
- _auto = False
+ _auto = False
_rec_name = 'move_id'
id = fields.Integer()
@@ -205,21 +217,21 @@ class OutstandingSales(models.Model):
tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""
CREATE OR REPLACE VIEW v_sales_outstanding AS (
- select sm.id,
- sm.id as move_id,
- sp.id as picking_id,
- sm.product_id,
- so.id as sale_id,
- sol.id as sale_line_id,
- rp.id as partner_id,
- so.user_id as salesperson_id,
+ select sm.id,
+ sm.id as move_id,
+ sp.id as picking_id,
+ sm.product_id,
+ so.id as sale_id,
+ sol.id as sale_line_id,
+ rp.id as partner_id,
+ so.user_id as salesperson_id,
so.partner_invoice_id,
- sp.origin,
- rp2.name as salesperson,
- coalesce(pp.default_code, pt.default_code) as item_code,
+ sp.origin,
+ rp2.name as salesperson,
+ coalesce(pp.default_code, pt.default_code) as item_code,
pt.name as product,
- sm.product_uom_qty as outgoing,
- xm.x_name as brand,
+ sm.product_uom_qty as outgoing,
+ xm.x_name as brand,
rp.name as invoice_partner,
so.create_date as sale_order_create_date
from stock_move sm