summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-05-26 09:33:56 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-05-26 09:33:56 +0700
commitce4c8c6b5e8b61877a66b483f46c1c808f10a8b1 (patch)
tree1672520b36bb0f11d37a7876ed991e59a33d45fe /indoteknik_custom/models/product_template.py
parent8fefc2e71c5e8a9f040f2fe6c9310b20cd88db3f (diff)
parent64c86581b469e962789ea6a7ea45c17ed020fe9a (diff)
Merge branch 'odoo-backup' of bitbucket.org:altafixco/indoteknik-addons into odoo-backup
# Conflicts: # indoteknik_custom/models/sale_order_line.py
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 89392033..c62ca63e 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -870,9 +870,9 @@ class ProductTemplate(models.Model):
record.message_post(body=f"<b>Updated:</b><ul>{''.join(changes)}</ul>")
# log changes to product variants
- # variant_message = f"<b>Updated:</b><ul>{''.join(changes)}</ul>"
- # for variant in record.product_variant_ids:
- # variant.message_post(body=variant_message)
+ variant_message = f"<b>Updated:</b><ul>{''.join(changes)}</ul>"
+ for variant in record.product_variant_ids:
+ variant.message_post(body=variant_message)
# simpan data lama dan log perubahan field
def write(self, vals):
@@ -913,7 +913,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')
@@ -1115,12 +1116,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([
@@ -1132,7 +1145,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):
@@ -1334,6 +1347,7 @@ class ProductProduct(models.Model):
else:
return super().write(vals)
+
class OutstandingMove(models.Model):
_name = 'v.move.outstanding'
_auto = False
@@ -1345,6 +1359,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
@@ -1353,8 +1369,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',