summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_api/controllers/api_v1/user.py2
-rw-r--r--indoteknik_custom/models/approval_unreserve.py5
-rwxr-xr-xindoteknik_custom/models/crm_lead.py28
-rwxr-xr-xindoteknik_custom/models/purchase_order.py6
-rw-r--r--indoteknik_custom/models/report_stock_forecasted.py1
-rw-r--r--indoteknik_custom/models/stock_picking.py18
-rwxr-xr-xindoteknik_custom/views/sale_order.xml1
-rw-r--r--indoteknik_custom/views/stock_picking.xml1
8 files changed, 50 insertions, 12 deletions
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py
index c7bfe91a..e4f8b97f 100644
--- a/indoteknik_api/controllers/api_v1/user.py
+++ b/indoteknik_api/controllers/api_v1/user.py
@@ -248,7 +248,7 @@ class User(controller.Controller):
if type_acc == 'individu':
user.partner_id.customer_type = 'nonpkp'
- user.partner_id.npwp = '0.000.000.0-000.000'
+ user.partner_id.npwp = '00.000.000.0-000.000'
user.partner_id.sppkp = '-'
user.partner_id.nama_wajib_pajak = name
user.partner_id.user_id = 3222
diff --git a/indoteknik_custom/models/approval_unreserve.py b/indoteknik_custom/models/approval_unreserve.py
index 88409c37..85dfffff 100644
--- a/indoteknik_custom/models/approval_unreserve.py
+++ b/indoteknik_custom/models/approval_unreserve.py
@@ -31,12 +31,12 @@ class ApprovalUnreserve(models.Model):
if not self.picking_id:
raise ValidationError("Picking is required")
- stock_move = self.env['stock.move'].search([('picking_id', '=', self.picking_id.id), ('state', '=', 'assigned')])
+ stock_move = self.env['stock.move'].search([('picking_id', '=', self.picking_id.id), ('state', 'in', ['assigned', 'partially_available'])])
if not stock_move:
raise ValidationError("Picking is not found")
- for move in stock_move:
+ for move in stock_move:
self.approval_line.create({
'approval_id': self.id,
'move_id': move.id
@@ -86,6 +86,7 @@ class ApprovalUnreserve(models.Model):
})
# Trigger the unreserve function
self._trigger_unreserve()
+ self.picking_id.check_state_reserve()
def action_reject(self, reason):
if self.env.user.id != self.user_id.id:
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py
index b0d3430c..de2bdb12 100755
--- a/indoteknik_custom/models/crm_lead.py
+++ b/indoteknik_custom/models/crm_lead.py
@@ -98,7 +98,27 @@ class CrmLead(models.Model):
lead.user_id = salesperson_id
- def _cancel_pipeline(self, delta=48):
+ def _update_pipeline(self, delta=48, limit=100):
+ # Get the current time
+ current_time = datetime.now()
+
+ # Calculate the time 24 hours ago
+ time_48_hours_ago = current_time - timedelta(hours=delta)
+
+ # Define the allowed states
+ allowed_states = ['sale', 'done']
+
+ # Search for sale orders with date_order greater than 24 hours ago and opportunity_id is null
+ orders = self.env['sale.order'].search([
+ ('write_date', '>=', time_48_hours_ago),
+ ('opportunity_id', '!=', False),
+ ('state', 'in', allowed_states)
+ ], limit=limit)
+ for order in orders:
+ order.opportunity_id.stage_id = 4
+ _logger.info('finish order stage pipeline %s' % order.id)
+
+ def _cancel_pipeline(self, delta=48, limit=100):
# Get the current time
current_time = datetime.now()
@@ -113,12 +133,12 @@ class CrmLead(models.Model):
('write_date', '>=', time_48_hours_ago),
('opportunity_id', '!=', False),
('state', 'in', allowed_states)
- ])
+ ], limit=limit)
for order in orders:
order.opportunity_id.stage_id = 7
_logger.info('cancel order stage pipeline %s' % order.id)
- def _convert_to_pipeline(self, delta=48):
+ def _convert_to_pipeline(self, delta=48, limit=100):
# Get the current time
current_time = datetime.now()
@@ -133,7 +153,7 @@ class CrmLead(models.Model):
('write_date', '>=', time_48_hours_ago),
('opportunity_id', '=', False),
('state', 'in', allowed_states)
- ])
+ ], limit=limit)
# stage
# 1 potensi baru, 2 proses quotation, 3 proses lain visit, 4 proses berhasil, 5 proses negosiasi, 7 tidak terpakai / gagal
for order in orders:
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 340df49e..21f3265e 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -508,10 +508,10 @@ class PurchaseOrder(models.Model):
if self.amount_untaxed >= 50000000 and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'):
raise UserError("Hanya Merchandiser yang bisa approve")
- if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.is_purchasing_manager and not self.env.user.is_leader:
+ if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader:
raise UserError("Beda Margin dengan Sales, harus approval Manager")
if not self.from_apo:
- if not self.sale_order_id and not self.env.user.is_purchasing_manager and not self.env.user.is_leader:
+ if not self.sale_order_id and self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader:
raise UserError("Tidak ada link dengan SO, harus approval Manager")
send_email = False
@@ -641,7 +641,7 @@ class PurchaseOrder(models.Model):
def po_approve(self):
if self.amount_untaxed >= 50000000 and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'):
raise UserError("Hanya Merchandiser yang bisa approve")
- if self.env.user.is_leader or self.env.user.is_purchasing_manager:
+ if self.env.user.is_leader or self.env.user.has_group('indoteknik_custom.group_role_merchandiser'):
raise UserError("Bisa langsung Confirm")
elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id:
raise UserError("Bisa langsung Confirm")
diff --git a/indoteknik_custom/models/report_stock_forecasted.py b/indoteknik_custom/models/report_stock_forecasted.py
index 5f9427f8..ebdc7d4a 100644
--- a/indoteknik_custom/models/report_stock_forecasted.py
+++ b/indoteknik_custom/models/report_stock_forecasted.py
@@ -33,7 +33,6 @@ class ReplenishmentReport(models.AbstractModel):
'reserved_from': result,
'qty_fullfillment': quantity,
})
-
return lines
def _calculate_result(self, line):
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 14190474..33e577bc 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -101,6 +101,13 @@ class StockPicking(models.Model):
('no', 'Nothing to Invoice')
], string='Invoice Status', related="sale_id.invoice_status")
+ state_reserve = fields.Selection([
+ ('waiting', 'Waiting For Fullfilment'),
+ ('ready', 'Ready to Ship'),
+ ('done', 'Done'),
+ ('cancel', 'Cancelled'),
+ ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.")
+
@api.constrains('driver_departure_date')
def constrains_driver_departure_date(self):
self.date_doc_kirim = self.driver_departure_date
@@ -134,9 +141,18 @@ class StockPicking(models.Model):
res = super(StockPicking, self).do_unreserve()
current_time = datetime.datetime.utcnow()
self.date_unreserve = current_time
+ self.check_state_reserve()
return res
+ def check_state_reserve(self):
+ self.state_reserve = 'ready'
+
+ for line in self.move_ids_without_package:
+ if line.product_uom_qty > line.reserved_availability:
+ self.state_reserve = 'waiting'
+ break
+
def _create_approval_notification(self, approval_role):
title = 'Warning'
message = f'Butuh approval sales untuk unreserved'
@@ -275,6 +291,7 @@ class StockPicking(models.Model):
current_time = datetime.datetime.utcnow()
self.real_shipping_id = self.sale_id.real_shipping_id
self.date_availability = current_time
+ self.check_state_reserve()
return res
def ask_approval(self):
@@ -421,6 +438,7 @@ class StockPicking(models.Model):
res = super(StockPicking, self).button_validate()
self.calculate_line_no()
self.date_done = datetime.datetime.utcnow()
+ self.state_reserve = 'done'
return res
@api.model
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 895b242c..9a637441 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -140,7 +140,6 @@
<field name="weight" optional="hide"/>
<field name="amount_voucher_disc" string="Voucher" readonly="1" optional="hide"/>
<field name="order_promotion_id" string="Promotion" readonly="1" optional="hide"/>
- <field name="md_vendor_id" string="MD Vendor" readonly="1" optional="hide"/>
</xpath>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="before">
<field name="line_no" readonly="1" optional="hide"/>
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index 899d29eb..af1af563 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -16,6 +16,7 @@
<field name="driver_arrival_date" optional="hide"/>
<field name="note_logistic" optional="hide"/>
<field name="note" optional="hide"/>
+ <field name="state_reserve" optional="hide"/>
</field>
<field name="partner_id" position="after">
<field name="purchase_representative_id"/>