summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-12-22 09:04:41 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-12-22 09:04:41 +0700
commitfbb11ab07e66b28459375af175459c3a23148597 (patch)
tree53483794d588dd3467c1fbc625280b005799602b
parent9abad8c8ee173626b05d13a5db9e81352dce0bb6 (diff)
parent80afbdeecd286c990ddc80c277287df6c95f5ee8 (diff)
Merge branch 'production' into purchasing-job
-rwxr-xr-xindoteknik_custom/models/product_template.py20
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py10
-rwxr-xr-xindoteknik_custom/models/sale_order.py2
3 files changed, 26 insertions, 6 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 90e8a144..34aff4fa 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -339,8 +339,10 @@ class ProductProduct(models.Model):
usage = fields.Char(string='Usage')
specification = fields.Char(string='Specification')
material = fields.Char(string='Material')
- qty_onhand_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_onhand_bandengan')
+ qty_onhand_bandengan = fields.Float(string='Qty Onhand Bandengan', compute='_get_qty_onhand_bandengan')
qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan')
+ qty_outgoing_bandengan = fields.Float(string='Qty Outgoing Bandengan', compute='_get_qty_outgoing_bandengan')
+ qty_available_bandengan = fields.Float(string='Qty Available Bandengan', compute='_get_qty_available_bandengan')
qty_upcoming = fields.Float(string='Qty Upcoming', compute='_get_qty_upcoming')
sla_version = fields.Integer(string="SLA Version", default=0)
is_edited = fields.Boolean(string='Is Edited')
@@ -408,6 +410,17 @@ class ProductProduct(models.Model):
qty = sum(qty_incoming.mapped('product_uom_qty'))
product.qty_incoming_bandengan = qty
+ def _get_qty_outgoing_bandengan(self):
+ for product in self:
+ qty_incoming = self.env['stock.move'].search([
+ ('product_id', '=', product.id),
+ ('location_dest_id', '=', 5),
+ ('location_id', '=', 57),
+ ('state', 'not in', ['done', 'cancel'])
+ ])
+ qty = sum(qty_incoming.mapped('product_uom_qty'))
+ product.qty_outgoing_bandengan = qty
+
def _get_qty_onhand_bandengan(self):
for product in self:
qty_onhand = self.env['stock.quant'].search([
@@ -417,6 +430,11 @@ class ProductProduct(models.Model):
qty = sum(qty_onhand.mapped('quantity'))
product.qty_onhand_bandengan = qty
+ def _get_qty_available_bandengan(self):
+ for product in self:
+ qty_available = product.qty_incoming_bandengan + product.qty_onhand_bandengan - product.qty_outgoing_bandengan
+ product.qty_available_bandengan = qty_available
+
# def write(self, vals):
# if 'solr_flag' not in vals:
# for variant in self:
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py
index 06ffd57a..95813e0d 100755
--- a/indoteknik_custom/models/purchase_order_line.py
+++ b/indoteknik_custom/models/purchase_order_line.py
@@ -37,7 +37,7 @@ class PurchaseOrderLine(models.Model):
def suggest_purchasing(self):
for line in self:
- if line.qty_available < 0:
+ if line.qty_available < line.product_qty:
line.suggest = 'harus beli'
else:
line.suggest = 'masih cukup'
@@ -58,10 +58,10 @@ class PurchaseOrderLine(models.Model):
def _compute_qty_stock(self):
for line in self:
- line.qty_available = line.product_id.virtual_available
- line.qty_onhand = line.product_id.qty_available
- line.qty_incoming = line.product_id.incoming_qty
- line.qty_outgoing = line.product_id.outgoing_qty
+ line.qty_available = line.product_id.qty_available_bandengan
+ line.qty_onhand = line.product_id.qty_onhand_bandengan
+ line.qty_incoming = line.product_id.qty_incoming_bandengan
+ line.qty_outgoing = line.product_id.qty_outgoing_bandengan
@api.onchange('product_id')
def _onchange_product_custom(self):
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index d1a3015d..b1a2f674 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -414,8 +414,10 @@ class SaleOrder(models.Model):
return self._create_notification_action('Notification', 'Terdapat invoice yang telah melewati batas waktu, mohon perbarui pada dokumen Due Extension')
if order._requires_approval_margin_leader():
+ order.approval_status = 'pengajuan2'
return self._create_approval_notification('Pimpinan')
elif order._requires_approval_margin_manager():
+ order.approval_status = 'pengajuan1'
return self._create_approval_notification('Sales Manager')
order.approval_status = 'approved'