summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-06-24 09:43:30 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-06-24 09:43:30 +0700
commitedbad751e9f370285baa221ca26a683d202e8541 (patch)
treed4bfd495a72a59ba01131e97970ab48246239af3
parent05283d3ec0c49449e2ed7b14b2d824739db19174 (diff)
parenta6aa700b5016c98d579a52125e3686acc615ce88 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
-rw-r--r--indoteknik_custom/models/automatic_purchase.py2
-rw-r--r--indoteknik_custom/models/purchase_order_sales_match.py14
-rw-r--r--indoteknik_custom/models/stock_picking.py12
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml1
4 files changed, 27 insertions, 2 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index c9edf07c..83a7cb3c 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -486,7 +486,7 @@ class AutomaticPurchase(models.Model):
# _logger.info('test %s' % point.product_id.name)
if point.product_id.qty_available_bandengan > point.product_min_qty:
continue
- qty_purchase = point.product_max_qty - point.product_id.qty_incoming_bandengan - point.product_id.qty_onhand_bandengan
+ qty_purchase = point.product_max_qty - point.product_id.qty_incoming_bandengan - point.product_id.qty_available_bandengan
po_line = self.env['purchase.order.line'].search([('product_id', '=', point.product_id.id), ('order_id.state', '=', 'done')], order='id desc', limit=1)
if self.vendor_id:
diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py
index 0bd0092b..2ea89dab 100644
--- a/indoteknik_custom/models/purchase_order_sales_match.py
+++ b/indoteknik_custom/models/purchase_order_sales_match.py
@@ -28,6 +28,20 @@ class PurchaseOrderSalesMatch(models.Model):
purchase_price_po = fields.Float('Purchase Price PO', compute='_compute_purchase_price_po')
purchase_line_id = fields.Many2one('purchase.order.line', string='Purchase Line', compute='_compute_purchase_line_id')
hold_outgoing_so = fields.Boolean(string='Hold Outgoing SO', related='sale_id.hold_outgoing')
+ bu_pick = fields.Many2one('stock.picking', string='BU Pick', compute='compute_bu_pick')
+
+ def compute_bu_pick(self):
+ for rec in self:
+ stock_move = self.env['stock.move'].search([
+ ('reference', 'ilike', 'BU/PICK'),
+ ('state', 'in', ['confirmed','waiting','partially_available']),
+ ('product_id', '=', rec.product_id.id),
+ ('sale_line_id', '=', rec.sale_line_id.id),
+ ])
+ if stock_move:
+ rec.bu_pick = stock_move.picking_id.id
+ else:
+ rec.bu_pick = ''
def _compute_purchase_line_id(self):
for line in self:
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index eabef37c..27046063 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -1309,7 +1309,6 @@ class StockPicking(models.Model):
self.final_seq = 0
self.set_picking_code_out()
self.send_koli_to_so()
-
if (self.state_reserve == 'done' and self.picking_type_code == 'internal' and 'BU/PICK/' in self.name
and self.linked_manual_bu_out):
if not self.linked_manual_bu_out.date_reserved:
@@ -1346,7 +1345,18 @@ class StockPicking(models.Model):
'target': 'new',
}
self.send_mail_bills()
+ if 'BU/PUT' in self.name:
+ self.automatic_reserve_product()
return res
+
+ def automatic_reserve_product(self):
+ if self.state == 'done':
+ po = self.env['purchase.order'].search([
+ ('name', '=', self.group_id.name)
+ ])
+
+ for line in po.order_sales_match_line:
+ line.bu_pick.action_assign()
def check_invoice_date(self):
for picking in self:
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 7b568d07..530fd115 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -332,6 +332,7 @@
<field name="delivery_amt" optional="hide"/>
<field name="margin_deduct" optional="hide"/>
<field name="hold_outgoing_so" optional="hide"/>
+ <field name="bu_pick" optional="hide"/>
<field name="margin_so"/>
</tree>
</field>