diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2025-05-23 09:02:14 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2025-05-23 09:02:14 +0700 |
| commit | cc6e4b9e48752ee54b42db2c16fae7cd5d5af1c4 (patch) | |
| tree | 95d42034b88b19ae568efd8fb3221fce1b7eded3 | |
| parent | cbf9eff4c2f934491b3a1adbf56255c14c4852ea (diff) | |
quick fix purchasing job conflict with manufacturing order sync to po
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 21 | ||||
| -rw-r--r-- | indoteknik_custom/views/product_product.xml | 1 |
3 files changed, 21 insertions, 5 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index ff10b814..518dc74c 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -728,10 +728,10 @@ class SaleNotInMatchPO(models.Model): apsm.purchase_tax_id, apsm.note_procurement FROM automatic_purchase_sales_match apsm WHERE apsm.sale_line_id NOT IN ( - SELECT posm.sale_line_id + SELECT distinct coalesce(posm.sale_line_id,0) FROM purchase_order_sales_match posm JOIN purchase_order po ON po.id = posm.purchase_order_id WHERE po.state NOT IN ('cancel') ) ) - """ % self._table)
\ No newline at end of file + """ % self._table) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 89392033..6903b53e 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -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,23 @@ class ProductProduct(models.Model): domain=[ ('product_id', '=', product.id), ('location_id', 'in', [57, 83]), + ('mo_id', '=', 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 +1144,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 +1346,7 @@ class ProductProduct(models.Model): else: return super().write(vals) + class OutstandingMove(models.Model): _name = 'v.move.outstanding' _auto = False @@ -1345,6 +1358,7 @@ 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') def init(self): # where clause 'state in' follow the origin of outgoing and incoming odoo @@ -1353,7 +1367,8 @@ 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 from stock_move sm where 1=1 and sm.state in( diff --git a/indoteknik_custom/views/product_product.xml b/indoteknik_custom/views/product_product.xml index b214dc87..1d04e708 100644 --- a/indoteknik_custom/views/product_product.xml +++ b/indoteknik_custom/views/product_product.xml @@ -15,6 +15,7 @@ <field name="qty_onhand_bandengan" optional="hide"/> <field name="qty_incoming_bandengan" optional="hide"/> <field name="qty_outgoing_bandengan" optional="hide"/> + <field name="qty_outgoing_mo_bandengan" optional="hide"/> <field name="qty_available_bandengan" optional="hide"/> <field name="qty_free_bandengan" optional="hide"/> <field name="qty_rpo" optional="hide"/> |
