summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-05-26 11:25:15 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-05-26 11:25:15 +0700
commit7d7a6d4421a664e2ddd9308b15ea9f9e5e54c4a9 (patch)
treefd8b1877af11acdbbb627f03ea5b7189281a009b /indoteknik_custom/models/product_template.py
parentbab061bc003f132e738d7ad2f9d99df903392d1a (diff)
parentc1aefea6e72798848d090abb32bb753c550ce76b (diff)
(andri) resolved conflict
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py43
1 files changed, 36 insertions, 7 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 5480204f..3bb54f44 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -909,7 +909,8 @@ class ProductProduct(models.Model):
qty_onhand_bandengan = fields.Float(string='Onhand BU', compute='_get_qty_onhand_bandengan')
clean_website_description = fields.Char(string='Clean Website Description', compute='_get_clean_website_description')
qty_incoming_bandengan = fields.Float(string='Incoming BU', compute='_get_qty_incoming_bandengan')
- qty_outgoing_bandengan = fields.Float(string='Outgoing BU', compute='_get_qty_outgoing_bandengan')
+ qty_outgoing_bandengan = fields.Float(string='Outgoing BU', compute='_get_qty_outgoing_bandengan', help='only outgoing from sales order bandengan')
+ qty_outgoing_mo_bandengan = fields.Float(string='Outgoing MO BU', compute='_get_qty_outgoing_mo_bandengan', help='only outgoing from manufacturing order bandengan')
qty_available_bandengan = fields.Float(string='Available BU', compute='_get_qty_available_bandengan')
qty_free_bandengan = fields.Float(string='Free BU', compute='_get_qty_free_bandengan')
qty_upcoming = fields.Float(string='Qty Upcoming', compute='_get_qty_upcoming')
@@ -1111,12 +1112,24 @@ class ProductProduct(models.Model):
domain=[
('product_id', '=', product.id),
('location_id', 'in', [57, 83]),
+ ('mo_id', '=', False),
+ ('hold_outgoing', '=', False)
],
fields=['qty_need'],
groupby=[]
)[0].get('qty_need', 0.0)
product.qty_outgoing_bandengan = qty
+ def _get_qty_outgoing_mo_bandengan(self):
+ for product in self:
+ records = self.env['v.move.outstanding'].search([
+ ('product_id.id', '=', product.id),
+ ('location_id.id', 'in', [57, 83]),
+ ('mo_id.id', '>', 0)
+ ])
+ qty = sum(records.mapped('qty_need') or [0.0])
+ product.qty_outgoing_mo_bandengan = qty
+
def _get_qty_onhand_bandengan(self):
for product in self:
qty_onhand = self.env['stock.quant'].search([
@@ -1128,7 +1141,7 @@ class ProductProduct(models.Model):
def _get_qty_available_bandengan(self):
for product in self:
- qty_available = product.qty_incoming_bandengan + product.qty_onhand_bandengan - product.qty_outgoing_bandengan
+ qty_available = product.qty_incoming_bandengan + product.qty_onhand_bandengan - product.qty_outgoing_bandengan - product.qty_outgoing_mo_bandengan
product.qty_available_bandengan = qty_available or 0
def _get_qty_free_bandengan(self):
@@ -1292,10 +1305,20 @@ class ProductProduct(models.Model):
# simpan data lama dan log perubahan field
def write(self, vals):
- old_values = self._collect_old_values(vals)
- result = super().write(vals)
- self._log_field_changes_product_variants(vals, old_values)
- return result
+ tracked_fields = [
+ 'default_code', 'name', 'weight', 'x_manufacture',
+ 'public_categ_ids', 'search_rank', 'search_rank_weekly',
+ 'image_1920', 'unpublished', 'image_carousel_lines'
+ ]
+
+ if any(field in vals for field in tracked_fields):
+ old_values = self._collect_old_values(vals)
+ result = super().write(vals)
+ self._log_field_changes_product_variants(vals, old_values)
+ return result
+ else:
+ return super().write(vals)
+
class OutstandingMove(models.Model):
_name = 'v.move.outstanding'
@@ -1308,6 +1331,8 @@ class OutstandingMove(models.Model):
qty_need = fields.Float(string='Qty Need', help='Qty yang akan outgoing / incoming')
location_id = fields.Many2one('stock.location', string='Location', help='Lokasi asal')
location_dest_id = fields.Many2one('stock.location', string='Location To', help='Lokasi tujuan')
+ mo_id = fields.Many2one('mrp.production', string='Manufacturing Order')
+ hold_outgoing = fields.Boolean(string='Hold Outgoing')
def init(self):
# where clause 'state in' follow the origin of outgoing and incoming odoo
@@ -1316,8 +1341,12 @@ class OutstandingMove(models.Model):
CREATE OR REPLACE VIEW %s AS
select sm.id, sm.reference, sm.product_id,
sm.product_uom_qty as qty_need,
- sm.location_id, sm.location_dest_id
+ sm.location_id, sm.location_dest_id,
+ sm.raw_material_production_id as mo_id,
+ so.hold_outgoing
from stock_move sm
+ left join procurement_group pg on pg.id = sm.group_id
+ left join sale_order so on so.id = pg.sale_id
where 1=1
and sm.state in(
'waiting',