summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-09-16 09:11:18 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-09-16 09:11:18 +0700
commitaf7fc5db50d7c3f78b70a2b75186db4b4c1f3674 (patch)
treea373827d750fcc0035c0b91a909b4d8b271c485e
parentee9dab9b220b63e4c018a63aeea37a47895704ae (diff)
parent78a4f924fa9ba38c58954b5840632806b04fff19 (diff)
<Miqdad> merge
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py213
-rw-r--r--indoteknik_api/controllers/api_v1/user.py4
-rw-r--r--indoteknik_api/models/sale_order.py14
-rwxr-xr-xindoteknik_custom/__manifest__.py2
-rw-r--r--indoteknik_custom/models/account_move.py33
-rw-r--r--indoteknik_custom/models/approval_payment_term.py10
-rw-r--r--indoteknik_custom/models/dunning_run.py3
-rw-r--r--indoteknik_custom/models/logbook_sj.py5
-rw-r--r--indoteknik_custom/models/manufacturing.py22
-rwxr-xr-xindoteknik_custom/models/purchase_order.py7
-rw-r--r--indoteknik_custom/models/purchase_order_sales_match.py2
-rw-r--r--indoteknik_custom/models/refund_sale_order.py46
-rw-r--r--indoteknik_custom/models/report_logbook_sj.py63
-rw-r--r--indoteknik_custom/models/res_partner.py11
-rwxr-xr-xindoteknik_custom/models/sale_order.py152
-rw-r--r--indoteknik_custom/models/sale_order_line.py6
-rw-r--r--indoteknik_custom/models/stock_move.py4
-rw-r--r--indoteknik_custom/models/tukar_guling.py4
-rw-r--r--indoteknik_custom/report/purchase_report.xml183
-rw-r--r--indoteknik_custom/views/account_move.xml1
-rw-r--r--indoteknik_custom/views/approval_payment_term.xml2
-rw-r--r--indoteknik_custom/views/dunning_run.xml5
-rw-r--r--indoteknik_custom/views/refund_sale_order.xml10
-rw-r--r--indoteknik_custom/views/report_logbook_sj.xml2
-rw-r--r--indoteknik_custom/views/res_partner.xml13
-rwxr-xr-xindoteknik_custom/views/sale_order.xml15
-rw-r--r--indoteknik_custom/views/stock_move_line.xml9
-rw-r--r--indoteknik_custom/views/stock_picking.xml105
28 files changed, 678 insertions, 268 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 65894d8a..accc7531 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -22,7 +22,7 @@ class SaleOrder(controller.Controller):
})
sale_order_line = request.env['sale.order.line'].search([
- ('product_id', '=', product_id),
+ ('product_id', '=', product_id),
('order_id', '=', so_id)
], limit=1)
@@ -41,7 +41,7 @@ class SaleOrder(controller.Controller):
return self.response('work')
else:
return self.response('Sale order line not found', status=404)
-
+
@http.route(prefix + "sale_order_number", auth='public', method=['GET', 'OPTIONS'])
@controller.Controller.must_authorized()
def get_number_sale_order(self, **kw):
@@ -116,14 +116,12 @@ class SaleOrder(controller.Controller):
if not params['valid']:
return self.response(code=400, description=params)
- partner_child_ids = self.get_partner_child_ids(
- params['value']['partner_id'])
+ partner_child_ids = self.get_partner_child_ids(params['value']['partner_id'])
domain = [('partner_id', 'in', partner_child_ids)]
context = params['value']['context']
if context == 'quotation':
- domain += ["|", "|", ("state", "=", "draft"),
- ("state", "=", "sent"), ("state", "=", "cancel")]
+ domain += ["|", "|", ("state", "=", "draft"), ("state", "=", "sent"), ("state", "=", "cancel")]
if not context:
domain += ["|", ("state", "=", "sale"), ("state", "=", "done")]
@@ -135,39 +133,39 @@ class SaleOrder(controller.Controller):
('product_id.name', 'ilike', name),
('product_id.default_code', 'ilike', name),
])
-
sale_order_ids_from_lines = order_lines.mapped('order_id.id')
-
domain += ['|', '|',
- ('name', 'ilike', name),
- ('partner_purchase_order_name', 'ilike', name),
- ('id', 'in', sale_order_ids_from_lines)
- ]
-
+ ('name', 'ilike', name),
+ ('partner_purchase_order_name', 'ilike', name),
+ ('id', 'in', sale_order_ids_from_lines)
+ ]
+
if params['value']['site']:
site = params['value']['site'].replace(' ', '%')
- domain += [
- ('partner_id.site_id.name', 'ilike', '%' + site + '%')
- ]
+ domain += [('partner_id.site_id.name', 'ilike', '%' + site + '%')]
status = params['value'].get('status')
if status:
if status == 'quotation':
domain += [('state', '=', 'draft')]
domain += [('approval_status', '=', False)]
-
elif status == 'cancel':
domain += [('state', '=', 'cancel')]
-
+ elif status == 'belum_bayar':
+ domain += [
+ ('state', '=', 'draft'),
+ ('approval_status', 'in', ['pengajuan1', 'pengajuan2']),
+ ('payment_status', 'in', [False, None, '', 'pending', 'expire'])
+ ]
elif status == 'diproses':
domain += [
('state', '=', 'draft'),
('approval_status', 'in', ['pengajuan1', 'pengajuan2']),
+ ('payment_status', '!=', False),
+ ('payment_status', 'not in', ['', 'pending', 'expire']),
]
-
elif status in ['dikemas', 'dikirim', 'selesai', 'partial']:
domain += [('state', '=', 'sale')]
-
elif status == 'all':
domain += []
@@ -179,7 +177,7 @@ class SaleOrder(controller.Controller):
elif params['value']['sort'] == 'desc':
order = 'amount_total desc'
- # Filter berdasarkan tanggal order
+ # Filter tanggal
try:
if params['value']['startDate'] and params['value']['endDate']:
start_date = datetime.strptime(params['value']['startDate'], '%d/%m/%Y').strftime('%Y-%m-%d 00:00:00')
@@ -190,22 +188,17 @@ class SaleOrder(controller.Controller):
domain.append(('date_order', '>=', start_date))
domain.append(('date_order', '<=', end_date))
-
except ValueError:
return self.response(code=400, description="Invalid date format. Use 'DD/MM/YYYY'.")
+ sale_orders = request.env['sale.order'].search(domain, order=order)
-
- sale_orders = request.env['sale.order'].search(
- domain, order=order)
+ # Filter status pengiriman
status = params['value'].get('status')
if status in ['dikemas', 'dikirim', 'selesai', 'partial']:
filtered_orders = []
for sale_order in sale_orders:
- bu_pickings = [
- p for p in sale_order.picking_ids
- if p.picking_type_id and p.picking_type_id.id == 29
- ]
+ bu_pickings = [p for p in sale_order.picking_ids if p.picking_type_id and p.picking_type_id.id == 29]
total = len(bu_pickings)
done_pickings = [p for p in bu_pickings if p.state == 'done']
done_with_driver = [p for p in done_pickings if p.sj_return_date]
@@ -213,25 +206,56 @@ class SaleOrder(controller.Controller):
if status == 'dikemas' and len(done_pickings) == 0:
filtered_orders.append(sale_order)
- elif status == 'dikirim' and len(done_pickings) == total and len(done_pickings) > 0 and len(done_without_driver) == total:
+ elif status == 'dikirim' and len(done_pickings) == total and len(done_pickings) > 0 and len(
+ done_without_driver) == total:
filtered_orders.append(sale_order)
- elif status == 'selesai' and len(done_pickings) == total and len(done_pickings) > 0 and len(done_with_driver) == total:
+ elif status == 'selesai' and len(done_pickings) == total and len(done_pickings) > 0 and len(
+ done_with_driver) == total:
filtered_orders.append(sale_order)
elif status == 'partial' and (
- len(done_pickings) != total or
- (done_with_driver and done_without_driver)
- ):
+ len(done_pickings) != total or (done_with_driver and done_without_driver)):
filtered_orders.append(sale_order)
else:
filtered_orders = sale_orders
filtered_orders_paginated = filtered_orders[offset: offset + limit]
+ # === Ringkasan (tanpa auto-generate) ===
+ CBD_PAYMENT_TERM_ID = 26
+ ALLOWED_CONTINUE = {'', 'pending', 'capture', 'expire', 'cancel'} # boleh munculkan "Bayar Sekarang"
+
+ def _is_website_order(so):
+ return bool(so.source_id and so.source_id.id == 59)
+
+ sale_orders_payload = []
+ for so in filtered_orders_paginated:
+ item = request.env['sale.order'].api_v1_single_response(so)
+
+ approval_ok = (so.approval_status in ('pengajuan1', 'pengajuan2'))
+ source_ok = _is_website_order(so)
+ term_ok = bool(so.payment_term_id and so.payment_term_id.id == CBD_PAYMENT_TERM_ID)
+ pay_status = (getattr(so, 'payment_status', '') or '').strip().lower()
+ eligible = bool(approval_ok and source_ok and term_ok and pay_status in ALLOWED_CONTINUE)
+
+ redirect_url = getattr(so, 'payment_link_midtrans', '') or ''
+
+ item.update({
+ 'eligibleContinue': eligible,
+ 'paymentSummary': {
+ 'eligible': eligible,
+ 'approvalStatus': so.approval_status or '',
+ 'paymentStatus': pay_status,
+ 'paymentTermId': so.payment_term_id.id if so.payment_term_id else None,
+ 'sourceId': so.source_id.id if so.source_id else None,
+ 'redirectUrl': redirect_url,
+ }
+ })
+ sale_orders_payload.append(item)
+
data = {
'sale_order_total': len(filtered_orders),
- 'sale_orders': [request.env['sale.order'].api_v1_single_response(x) for x in filtered_orders_paginated]
+ 'sale_orders': sale_orders_payload
}
-
return self.response(data)
@http.route(PREFIX_PARTNER + 'sale_order/<id>', auth='public', method=['GET', 'OPTIONS'])
@@ -240,6 +264,7 @@ class SaleOrder(controller.Controller):
params = self.get_request_params(kw, {
'partner_id': ['number'],
'id': ['number'],
+ 'ensure_payment_link': [], # optional flag
})
if not params['valid']:
return self.response(code=400, description=params)
@@ -247,9 +272,60 @@ class SaleOrder(controller.Controller):
partner_child_ids = self.get_partner_child_ids(params['value']['partner_id'])
domain = [('id', '=', params['value']['id']), ('partner_id', 'in', partner_child_ids)]
data = {}
+
sale_order = request.env['sale.order'].search(domain)
if sale_order:
data = request.env['sale.order'].api_v1_single_response(sale_order, context='with_detail')
+
+ CBD_PAYMENT_TERM_ID = 26
+ ALLOWED_CONTINUE = {'', 'pending', 'capture', 'expire', 'cancel'}
+
+ def _is_website_order(so):
+ return bool(so.source_id and so.source_id.id == 59)
+
+ pay_status = (getattr(sale_order, 'payment_status', '') or '').strip().lower()
+ eligible = (
+ sale_order.approval_status in ('pengajuan1', 'pengajuan2') and
+ _is_website_order(sale_order) and
+ sale_order.payment_term_id and sale_order.payment_term_id.id == CBD_PAYMENT_TERM_ID and
+ pay_status in ALLOWED_CONTINUE
+ )
+
+ redirect_url = getattr(sale_order, 'payment_link_midtrans', '') or ''
+
+ ensure_raw = params['value'].get('ensure_payment_link')
+ ensure_flag = False
+ if ensure_raw is not None:
+ s = str(ensure_raw).strip().lower()
+ ensure_flag = s not in ('', '0', 'false', 'no', 'none')
+
+ if ensure_flag and eligible:
+ should_generate = False
+ if not redirect_url:
+ should_generate = True
+ elif pay_status in ('expire', 'cancel'):
+ should_generate = True
+
+ if should_generate:
+ try:
+ sale_order.sudo().generate_payment_link_midtrans_sales_order()
+ redirect_url = getattr(sale_order, 'payment_link_midtrans', '') or ''
+ except Exception as e:
+ _logger.warning(f'Generate Midtrans gagal untuk SO {sale_order.id}: {e}')
+
+ data.update({
+ 'eligible_continue': eligible,
+ 'payment_summary': {
+ 'eligible': eligible,
+ 'approval_status': sale_order.approval_status or '',
+ 'payment_status': pay_status,
+ 'payment_term_id': sale_order.payment_term_id.id if sale_order.payment_term_id else None,
+ 'source_id': sale_order.source_id.id if sale_order.source_id else None,
+ 'redirect_url': redirect_url,
+ }
+ })
+
+ # formatting tanggal (tetap sama)
if sale_order.expected_ready_to_ship:
bulan_id = [
"Januari", "Februari", "Maret", "April", "Mei", "Juni",
@@ -259,6 +335,7 @@ class SaleOrder(controller.Controller):
bulan = bulan_id[sale_order.expected_ready_to_ship.month - 1]
tahun = sale_order.expected_ready_to_ship.year
data['expected_ready_to_ship'] = f"{tanggal} {bulan} {tahun}"
+
if sale_order.eta_date_start:
bulan_id = [
"Januari", "Februari", "Maret", "April", "Mei", "Juni",
@@ -307,12 +384,12 @@ class SaleOrder(controller.Controller):
sale_order.approval_status = 'pengajuan2'
elif sale_order._requires_approval_margin_manager():
sale_order.approval_status = 'pengajuan1'
-
+
data = request.env['sale.order'].api_v1_single_response(
sale_order, context='with_detail')
return self.response(data)
-
+
@http.route(PREFIX_PARTNER + 'sale_order/<id>/approve', auth='public', method=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized(private=True, private_key='partner_id')
def partner_approve_sale_order_by_id(self, **kw):
@@ -320,27 +397,27 @@ class SaleOrder(controller.Controller):
'partner_id': ['number'],
'id': ['number']
})
-
+
if not params['valid']:
return self.response(code=400, description=params)
-
+
value = params['value']
partner_child_ids = self.get_partner_child_ids(value['partner_id'])
-
+
sale_order = request.env['sale.order'].search([
('id', '=', value['id']),
('partner_id', 'in', partner_child_ids)
])
if not sale_order:
return self.response(code=404, description='Sale Order not found')
-
+
partner = request.env['res.partner'].browse(value['partner_id'])
if not partner.web_role:
return self.response(code=400, description='Unauthorized')
-
+
if partner.web_role:
sale_order.web_approval = 'cust_%s' % partner.web_role
-
+
if sale_order.web_approval in ['cust_procurement', 'cust_director']:
if sale_order._requires_approval_margin_leader():
sale_order.approval_status = 'pengajuan2'
@@ -348,7 +425,7 @@ class SaleOrder(controller.Controller):
sale_order.approval_status = 'pengajuan1'
return self.response('success')
-
+
@http.route(PREFIX_PARTNER + 'sale_order/<id>/reject', auth='public', method=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized(private=True, private_key='partner_id')
def partner_reject_sale_order_by_id(self, **kw):
@@ -356,27 +433,27 @@ class SaleOrder(controller.Controller):
'partner_id': ['number'],
'id': ['number']
})
-
+
if not params['valid']:
return self.response(code=400, description=params)
-
+
value = params['value']
partner_child_ids = self.get_partner_child_ids(value['partner_id'])
-
+
sale_order = request.env['sale.order'].search([
('id', '=', value['id']),
('partner_id', 'in', partner_child_ids)
])
if not sale_order:
return self.response(code=404, description='Sale Order not found')
-
+
partner = request.env['res.partner'].browse(value['partner_id'])
if not partner.web_role:
return self.response(code=400, description='Unauthorized')
-
+
if partner.web_role:
sale_order.web_approval = 'cust_%s' % partner.web_role
-
+
sale_order.state = 'cancel'
sale_order.approval_status = False
@@ -447,7 +524,7 @@ class SaleOrder(controller.Controller):
sale_order = request.env['sale.order'].sudo().search_read([('id', '=', id)], ['name'])
# pdf, type = request.env['ir.actions.report'].sudo().search([('report_name', '=', 'quotation_so_new')]).render_jasper([id], {})
pdf, type = request.env['ir.actions.report'].sudo().search([('report_name', '=', 'indoteknik_custom.report_saleorder_website')])._render_qweb_pdf([id])
-
+
if pdf and len(sale_order) > 0:
return rest_api.response_attachment({
'content': pdf,
@@ -478,27 +555,27 @@ class SaleOrder(controller.Controller):
sale_order.state = 'cancel'
data = sale_order.id
return self.response(data)
-
+
@http.route(prefix + 'user/<user_id>/sale_order/checkout', auth='public', method=['GET', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized(private=True, private_key='user_id')
def get_user_checkout_so(self, user_id, **kw):
m_voucher = request.env['voucher']
m_cart = request.env['website.user.cart']
-
+
voucher_code = kw.get('voucher')
voucher_shipping_code = kw.get('voucher_shipping')
source = kw.get('source')
-
+
voucher = m_voucher.search([('code', '=', voucher_code), ('apply_type', 'in', ['all', 'brand'])], limit=1)
voucher_shipping = m_voucher.search([('code', '=', voucher_shipping_code), ('apply_type', '=', 'shipping')], limit=1)
result = m_cart.with_context(price_for="web").get_user_checkout(
- user_id,
- voucher=voucher,
- voucher_shipping=voucher_shipping,
+ user_id,
+ voucher=voucher,
+ voucher_shipping=voucher_shipping,
source=source
)
return self.response(result)
-
+
@http.route(PREFIX_PARTNER + 'sale_order/checkout', auth='public', method=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized()
def create_partner_sale_order(self, **kw):
@@ -544,7 +621,7 @@ class SaleOrder(controller.Controller):
main_partner = partner_invoice.get_main_parent()
_logger.info(
f"Partner Info - Sales: {sales_partner.id}, Invoice: {partner_invoice.id}, Main: {main_partner.id}")
-
+
def _get_request_context(params, kw):
# 1) kw (querystring di route)
ctx = kw.get('context')
@@ -582,7 +659,7 @@ class SaleOrder(controller.Controller):
f"form={repr(request.httprequest.form.get('context'))}, "
f"json={(request.httprequest.get_json(force=False, silent=True) or {}).get('context') if hasattr(request.httprequest,'get_json') else None}, "
f"normalized={ctx}")
-
+
payment_term_id_value = 26
ctx = str((kw.get('context') or ''))
@@ -607,7 +684,7 @@ class SaleOrder(controller.Controller):
payment_term_id_value = term.id
except Exception as e:
_logger.warning(f"Gagal resolve payment term dari user: {e}")
-
+
parameters = {
'warehouse_id': 8,
'carrier_id': 1,
@@ -767,7 +844,7 @@ class SaleOrder(controller.Controller):
except Exception as e:
_logger.error(f"Error in create_partner_sale_order: {str(e)}", exc_info=True)
return self.response(code=500, description=str(e))
-
+
@http.route(PREFIX_PARTNER + 'sale-order/<id>/awb', auth='public', methods=['GET', 'OPTIONS'])
@controller.Controller.must_authorized(private=True, private_key='partner_id')
def get_airway_bill_by_sale_order_id(self, **kw):
@@ -782,8 +859,8 @@ class SaleOrder(controller.Controller):
for airway_bill in airway_bills:
data = airway_bill.decode_response()
delivery_order = airway_bill.do_id
- result = data['rajaongkir']['result']
-
+ result = data['rajaongkir']['result']
+
manifests_data = []
for manifest in airway_bill.manifest_ids:
manifest_data = {
@@ -793,7 +870,7 @@ class SaleOrder(controller.Controller):
'city': manifest.city,
}
manifests_data.append(manifest_data)
-
+
airways.append({
'delivery_order': {
'name': delivery_order.name,
@@ -801,7 +878,7 @@ class SaleOrder(controller.Controller):
'receiver_name': airway_bill.receiver_name,
'receiver_city': airway_bill.receiver_city,
},
- 'delivered': result['delivered'],
+ 'delivered': result['delivered'],
'waybill_number': result['summary']['waybill_number'],
'delivery_status': result['delivery_status'],
'manifests': manifests_data
@@ -809,7 +886,7 @@ class SaleOrder(controller.Controller):
response = {'airways': airways}
return self.response(response)
-
+
@http.route('/api/sale_order/invoiced', auth='public', methods=['GET'])
def get_sale_order_invoiced_by_partner_id(self, **kw):
if not self.authenticate():
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py
index dde30fec..3511bc52 100644
--- a/indoteknik_api/controllers/api_v1/user.py
+++ b/indoteknik_api/controllers/api_v1/user.py
@@ -89,7 +89,9 @@ class User(controller.Controller):
'name': name,
'login': email,
'oauth_provider_id': request.env.ref('auth_oauth.provider_google').id,
- 'sel_groups_1_9_10': 9
+ 'sel_groups_1_9_10': 9,
+ 'active': True,
+
}
user = request.env['res.users'].create(user_data)
diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py
index 9be03927..c59dead9 100644
--- a/indoteknik_api/models/sale_order.py
+++ b/indoteknik_api/models/sale_order.py
@@ -60,13 +60,17 @@ class SaleOrder(models.Model):
# 'tracking_number': picking.delivery_tracking_no or '',
# 'delivered': picking.waybill_id.delivered or picking.driver_arrival_date != False or picking.sj_return_date != False,
})
+
if sale_order.state == 'cancel':
data['status'] = 'cancel'
- if sale_order.state == 'draft' and sale_order.approval_status == False:
- data['status'] = 'draft'
- if sale_order.state == 'draft' and sale_order.approval_status in ['pengajuan1', 'pengajuan2']:
- data['status'] = 'waiting'
-
+ elif sale_order.state == 'draft':
+ if not sale_order.approval_status:
+ data['status'] = 'draft'
+ elif sale_order.approval_status in ('pengajuan1', 'pengajuan2'):
+ if sale_order.payment_status in ('', 'pending', False, None, 'expire'):
+ data['status'] = 'belum_bayar'
+ elif sale_order.payment_status not in ['', 'pending', False, None, 'expire']:
+ data['status'] = 'waiting'
if sale_order.state == 'sale':
bu_pickings = [
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index d852d2e1..791f77f6 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -166,6 +166,7 @@
'report/report_invoice.xml',
'report/report_picking.xml',
'report/report_sale_order.xml',
+ 'report/purchase_report.xml',
'views/vendor_sla.xml',
'views/coretax_faktur.xml',
'views/public_holiday.xml',
@@ -177,6 +178,7 @@
'views/tukar_guling_po.xml',
# 'views/refund_sale_order.xml',
'views/update_date_planned_po_wizard_view.xml',
+ # 'views/reimburse.xml',
'views/sj_tele.xml'
],
'demo': [],
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index c44cad78..70cd07e4 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -105,6 +105,34 @@ class AccountMove(models.Model):
tracking=True
)
+ # def _check_and_lock_cbd(self):
+ # cbd_term = self.env['account.payment.term'].browse(26)
+ # today = date.today()
+
+ # # Cari semua invoice overdue
+ # overdue_invoices = self.search([
+ # ('move_type', '=', 'out_invoice'),
+ # ('state', '=', 'posted'),
+ # ('payment_state', 'not in', ['paid', 'in_payment', 'reversed']),
+ # ('invoice_date_due', '!=', False),
+ # ('invoice_date_due', '<=', today - timedelta(days=30)),
+ # ], limit=3)
+
+ # _logger.info(f"Found {len(overdue_invoices)} overdue invoices for CBD lock check.")
+ # _logger.info(f"Overdue Invoices: {overdue_invoices.mapped('name')}")
+
+ # # Ambil partner unik dari invoice
+ # partners_to_lock = overdue_invoices.mapped('partner_id').filtered(lambda p: not p.is_cbd_locked)
+ # _logger.info(f"Partners to lock: {partners_to_lock.mapped('name')}")
+
+ # # Lock hanya partner yang belum locked
+ # if partners_to_lock:
+ # partners_to_lock.write({
+ # 'is_cbd_locked': True,
+ # 'property_payment_term_id': cbd_term.id,
+ # })
+
+
def compute_partial_payment(self):
for move in self:
if move.amount_total_signed > 0 and move.amount_residual_signed > 0 and move.payment_state == 'partial':
@@ -179,9 +207,8 @@ class AccountMove(models.Model):
('state', '=', 'posted'),
('payment_state', 'not in', ['paid', 'in_payment', 'reversed']),
('invoice_date_due', 'in', target_dates),
- ('date_terima_tukar_faktur', '!=', False),
- ('partner_id', 'in' , [94603])
- ], limit=5)
+ ('date_terima_tukar_faktur', '!=', False)
+ ])
_logger.info(f"Invoices: {invoices}")
invoices = invoices.filtered(
diff --git a/indoteknik_custom/models/approval_payment_term.py b/indoteknik_custom/models/approval_payment_term.py
index 8618856a..449bd90b 100644
--- a/indoteknik_custom/models/approval_payment_term.py
+++ b/indoteknik_custom/models/approval_payment_term.py
@@ -69,8 +69,8 @@ class ApprovalPaymentTerm(models.Model):
return res
def _track_changes_for_user_688(self, vals, old_values_dict):
- if self.env.user.id != 688:
- return
+ # if self.env.user.id != 688:
+ # return
tracked_fields = {"blocking_stage", "warning_stage", "property_payment_term_id"}
@@ -106,7 +106,8 @@ class ApprovalPaymentTerm(models.Model):
if changes:
timestamp = fields.Datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- rec.change_log_688 = f"{timestamp} - Perubahan oleh Widya:\n" + "\n".join(changes)
+ user = self.env.user
+ rec.change_log_688 = f"{timestamp} - Perubahan oleh {user.name}:\n" + "\n".join(changes)
@staticmethod
@@ -171,7 +172,8 @@ class ApprovalPaymentTerm(models.Model):
'blocking_stage': self.blocking_stage,
'warning_stage': self.warning_stage,
'active_limit': self.active_limit,
- 'property_payment_term_id': self.property_payment_term_id.id
+ 'property_payment_term_id': self.property_payment_term_id.id,
+ 'is_cbd_locked': False,
})
self.approve_date = datetime.utcnow()
self.state = 'approved'
diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py
index 5a6aebac..9feea1d1 100644
--- a/indoteknik_custom/models/dunning_run.py
+++ b/indoteknik_custom/models/dunning_run.py
@@ -1,6 +1,6 @@
from odoo import models, api, fields
from odoo.exceptions import AccessError, UserError, ValidationError
-from datetime import timedelta
+from datetime import timedelta, date
import logging
@@ -149,4 +149,5 @@ class DunningRunLine(models.Model):
total_amt = fields.Float(string='Total Amount')
open_amt = fields.Float(string='Open Amount')
due_date = fields.Date(string='Due Date')
+ payment_term = fields.Many2one('account.payment.term', related='invoice_id.invoice_payment_term_id', string='Payment Term')
diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py
index 75b2622f..0cda9c8b 100644
--- a/indoteknik_custom/models/logbook_sj.py
+++ b/indoteknik_custom/models/logbook_sj.py
@@ -24,6 +24,7 @@ class LogbookSJ(models.TransientModel):
}
report_logbook = self.env['report.logbook.sj'].create([parameters_header])
+ seq=1
for line in logbook_line:
picking = self.env['stock.picking'].search([('picking_code', '=', line.name)], limit=1)
if not picking:
@@ -43,9 +44,11 @@ class LogbookSJ(models.TransientModel):
'tracking_no': stock.delivery_tracking_no,
'partner_id': parent_id,
'report_logbook_sj_id': report_logbook.id,
- 'note': line.note
+ 'note': line.note,
+ 'line_num': seq
}
self.env['report.logbook.sj.line'].create([data])
+ seq += 1
report_logbook_ids.append(report_logbook.id)
line.unlink()
diff --git a/indoteknik_custom/models/manufacturing.py b/indoteknik_custom/models/manufacturing.py
index aea01362..f986fd4f 100644
--- a/indoteknik_custom/models/manufacturing.py
+++ b/indoteknik_custom/models/manufacturing.py
@@ -4,54 +4,56 @@ import logging
_logger = logging.getLogger(__name__)
+
class Manufacturing(models.Model):
_inherit = 'mrp.production'
unbuild_counter = fields.Integer(string='Unbuild Counter', default=0, help='For restrict unbuild more than once')
-
+
def action_confirm(self):
if self._name != 'mrp.production':
return super(Manufacturing, self).action_confirm()
if not self.env.user.is_purchasing_manager:
raise UserError("Hanya bisa di confirm oleh Purchasing Manager")
-
+
# if self.location_src_id.id != 75:
# raise UserError('Component Location hanya bisa di AS/Stock')
# elif self.location_dest_id.id != 75:
# raise UserError('Finished Product Location hanya bisa di AS/Stock')
-
+
result = super(Manufacturing, self).action_confirm()
return result
-
+
def button_mark_done(self):
if self._name != 'mrp.production':
return super(Manufacturing, self).button_mark_done()
# Check product category
if self.product_id.categ_id.name != 'Finish Good':
raise UserError('Tidak bisa di complete karna product category bukan Unit / Finish Good')
-
+
if self.sale_order and self.sale_order.state != 'sale':
raise UserError(
('Tidak bisa Mark as Done.\nSales Order "%s" (Nomor: %s) belum dikonfirmasi.')
% (self.sale_order.partner_id.name, self.sale_order.name)
)
-
+
for line in self.move_raw_ids:
# if line.quantity_done > 0 and line.quantity_done != self.product_uom_qty:
# raise UserError('Qty Consume per Line tidak sama dengan Qty to Produce')
if line.forecast_availability != line.product_uom_qty:
- raise UserError('Qty Reserved belum sesuai dengan yang seharusnya, product: %s' % line.product_id.display_name)
+ raise UserError(
+ 'Qty Reserved belum sesuai dengan yang seharusnya, product: %s' % line.product_id.display_name)
result = super(Manufacturing, self).button_mark_done()
return result
-
+
def button_unbuild(self):
if self._name != 'mrp.production':
return super(Manufacturing, self).button_unbuild()
-
+
if self.unbuild_counter >= 1:
raise UserError('Tidak bisa unbuild lebih dari 1 kali')
-
+
self.unbuild_counter = self.unbuild_counter + 1
result = super(Manufacturing, self).button_unbuild()
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 50913a80..98cf6ff1 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -66,7 +66,7 @@ class PurchaseOrder(models.Model):
sale_order = fields.Char(string='Sale Order')
matches_so = fields.Many2many('sale.order', string='Matches SO', compute='_compute_matches_so')
is_create_uangmuka = fields.Boolean(string='Uang Muka?')
- move_id = fields.Many2one('account.move', string='Journal Entries Uang Muka', domain=[('move_type', '=', 'entry')])
+ move_id = fields.Many2one('account.move', string='Journal Entries Uang Muka', domain=[('move_type', '=', 'entry')], copy=False)
logbook_bill_id = fields.Many2one('report.logbook.bill', string='Logbook Bill')
status_printed = fields.Selection([
('not_printed', 'Belum Print'),
@@ -1066,8 +1066,11 @@ class PurchaseOrder(models.Model):
# sticky=True
# )
+ has_bom = self.product_bom_id.id
+ has_manufacturing = self.manufacturing_id.id
+
if not self.from_apo:
- if not self.matches_so and not self.env.user.is_purchasing_manager and not self.env.user.is_leader:
+ if not self.matches_so and not self.env.user.is_purchasing_manager and not self.env.user.is_leader and not has_bom and not has_manufacturing:
raise UserError("Tidak ada link dengan SO, harus di confirm oleh Purchasing Manager")
send_email = False
diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py
index b18864f3..084b93f7 100644
--- a/indoteknik_custom/models/purchase_order_sales_match.py
+++ b/indoteknik_custom/models/purchase_order_sales_match.py
@@ -39,7 +39,7 @@ class PurchaseOrderSalesMatch(models.Model):
('sale_line_id', '=', rec.sale_line_id.id),
])
if stock_move:
- rec.bu_pick = stock_move.picking_id.id
+ rec.bu_pick = stock_move[0].picking_id.id
else:
rec.bu_pick = None
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py
index 731d8e41..55128080 100644
--- a/indoteknik_custom/models/refund_sale_order.py
+++ b/indoteknik_custom/models/refund_sale_order.py
@@ -76,7 +76,8 @@ class RefundSaleOrder(models.Model):
transfer_move_id = fields.Many2one(
'account.move',
string="Journal Payment",
- help="Pilih transaksi salah transfer dari jurnal Uang Muka (journal_id=11) yang tidak terkait SO."
+ copy=False,
+ help="Pilih transaksi salah transfer dari jurnal Uang Muka yang tidak terkait SO."
)
tukar_guling_count = fields.Integer(
@@ -296,6 +297,14 @@ class RefundSaleOrder(models.Model):
total_invoice = sum(self.env['account.move'].browse(invoice_ids).mapped('amount_total_signed')) if invoice_ids else 0.0
vals['total_invoice'] = total_invoice
amount_refund = vals.get('amount_refund', 0.0)
+ can_refund = sisa_uang_masuk - total_invoice
+
+ if amount_refund > can_refund or can_refund == 0.0:
+ raise ValidationError(
+ _("Maksimal refund yang bisa dilakukan adalah sebesar %s. "
+ "Silakan sesuaikan jumlah refund.") % (can_refund)
+ )
+
if amount_refund <= 0.00:
raise ValidationError('Total Refund harus lebih dari 0 jika ingin mengajukan refund')
@@ -392,9 +401,16 @@ class RefundSaleOrder(models.Model):
total_invoice = sum(self.env['account.move'].browse(invoice_ids).mapped('amount_total_signed'))
vals['total_invoice'] = total_invoice
uang_masuk = rec.uang_masuk
+ can_refund = uang_masuk - total_invoice
amount_refund = vals.get('amount_refund', rec.amount_refund)
+ if amount_refund > can_refund:
+ raise ValidationError(
+ _("Maksimal refund yang bisa dilakukan adalah sebesar %s. "
+ "Silakan sesuaikan jumlah refund.") % (can_refund)
+ )
+
if amount_refund <= 0:
raise ValidationError("Total Refund harus lebih dari 0.")
@@ -462,7 +478,7 @@ class RefundSaleOrder(models.Model):
total_invoice = 0.0
so_ids = self.sale_order_ids.ids
-
+ amount_refund_before = 0.0
for so in self.sale_order_ids:
self.ongkir += so.delivery_amt or 0.0
valid_invoices = so.invoice_ids.filtered(
@@ -470,6 +486,10 @@ class RefundSaleOrder(models.Model):
)
all_invoices |= valid_invoices
total_invoice += sum(valid_invoices.mapped('amount_total_signed'))
+ refunds = self.env['refund.sale.order'].search([
+ ('sale_order_ids', 'in', so_ids)
+ ])
+ amount_refund_before += sum(refunds.mapped('amount_refund')) if refunds else 0.0
moves = self.env['account.move'].search([
('sale_id', 'in', so_ids),
@@ -478,7 +498,7 @@ class RefundSaleOrder(models.Model):
])
total_uang_muka = sum(moves.mapped('amount_total_signed')) if moves else 0.0
total_midtrans = sum(self.env['sale.order'].browse(so_ids).mapped('gross_amount')) if so_ids else 0.0
- self.uang_masuk = total_uang_muka + total_midtrans
+ self.uang_masuk = (total_uang_muka + total_midtrans) - amount_refund_before
self.invoice_ids = all_invoices
@@ -819,15 +839,26 @@ class RefundSaleOrder(models.Model):
# Ambil label refund type
refund_type_label = dict(
self.fields_get(allfields=['refund_type'])['refund_type']['selection']
- ).get(refund.refund_type, '').replace("Refund ", "").upper()
-
+ ).get(refund.refund_type, '')
+
+ # Normalisasi
+ refund_type_label = refund_type_label.upper()
+
+ if refund.refund_type in ['barang_kosong', 'barang_kosong_sebagian']:
+ refund_type_label = "REFUND BARANG KOSONG"
+ elif refund.refund_type in ['retur_half', 'retur']:
+ refund_type_label = "REFUND RETUR BARANG"
+ elif refund.refund_type == 'uang':
+ refund_type_label = "REFUND LEBIH BAYAR"
+ elif refund.refund_type == 'salah_transfer':
+ refund_type_label = "REFUND SALAH TRANSFER"
if not partner:
raise UserError("❌ Partner tidak ditemukan.")
# Ref format
- ref_text = f"REFUND {refund_type_label} {refund.name or ''} {partner.display_name}".upper()
+ ref_text = f"{refund_type_label} {refund.name or ''} {partner.display_name}".upper()
# Buat Account Move (Journal Entry)
account_move = self.env['account.move'].create({
@@ -877,7 +908,8 @@ class RefundSaleOrder(models.Model):
def _compute_journal_refund_move_id(self):
for rec in self:
move = self.env['account.move'].search([
- ('refund_id', '=', rec.id)
+ ('refund_id', '=', rec.id),
+ ('state', '!=', 'cancel')
], limit=1)
rec.journal_refund_move_id = move
diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py
index e67ea724..b45eab03 100644
--- a/indoteknik_custom/models/report_logbook_sj.py
+++ b/indoteknik_custom/models/report_logbook_sj.py
@@ -1,3 +1,5 @@
+from operator import index
+
from odoo import models, fields, api
from odoo.exceptions import UserError
from pytz import timezone
@@ -47,8 +49,6 @@ class ReportLogbookSJ(models.Model):
@api.model
def create(self, vals):
vals['name'] = self.env['ir.sequence'].next_by_code('report.logbook.sj') or '0'
- # if self.env.user.has_group('indoteknik_custom.group_role_logistic'):
- # self.action_send_to_telegram()
result = super(ReportLogbookSJ, self).create(vals)
return result
@@ -67,7 +67,28 @@ class ReportLogbookSJ(models.Model):
self.state = 'terima_semua'
else:
raise UserError('Hanya Accounting yang bisa Approve')
-
+
+
+ def write(self, vals):
+ res = super(ReportLogbookSJ, self).write(vals)
+ if 'report_logbook_sj_line' in vals or any(f in vals for f in ()):
+ self._resequence_lines()
+ return res
+
+ def _resequence_lines(self):
+ for rec in self:
+ lines = rec.report_logbook_sj_line.sorted(key=lambda l: (l.line_num or 0, l.id))
+ for idx, line in enumerate(lines, start=1):
+ if line.line_num != idx:
+ line.line_num = idx
+
+ @api.onchange('report_logbook_sj_line')
+ def _onchange_report_logbook_sj_line(self):
+ self._resequence_lines()
+
+from odoo import models, fields, api
+
+
def action_send_to_telegram(self):
@@ -104,9 +125,10 @@ class ReportLogbookSJ(models.Model):
except Exception as e:
print(e)
-
+
class ReportLogbookSJLine(models.Model):
_name = 'report.logbook.sj.line'
+ _order = 'sequence, id' # urut default di UI & ORM (drag pakai sequence)
name = fields.Char(string='SJ Number')
driver_id = fields.Many2one(comodel_name='res.users', string='Driver')
@@ -114,10 +136,41 @@ class ReportLogbookSJLine(models.Model):
arrival_date = fields.Char(string='Arrival Date')
carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method')
tracking_no = fields.Char(string='Tracking No')
- logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ') # Corrected model name
+
+ # NOTE: field ini duplikat relasi; pakai salah satu saja.
+ # kamu boleh hapus logbook_sj_id kalau tidak dipakai di tempat lain.
+ logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ')
+
partner_id = fields.Many2one('res.partner', string='Customer')
picking_id = fields.Many2one('stock.picking', string='Picking')
sale_id = fields.Many2one('sale.order', string='Sale Order')
+
report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ')
not_exist = fields.Boolean(string='Not Exist')
note = fields.Char(string='Note')
+
+ sequence = fields.Integer(string='Sequence', default=0, index=True)
+
+ line_num = fields.Integer(string='No', compute='_compute_line_num', store=False)
+
+ @api.depends(
+ 'report_logbook_sj_id.report_logbook_sj_line',
+ 'report_logbook_sj_id.report_logbook_sj_line.sequence'
+ )
+ def _compute_line_num(self):
+ for parent in self.mapped('report_logbook_sj_id'):
+ lines = parent.report_logbook_sj_line.sorted(key=lambda l: (l.sequence or 0, l.id))
+ for i, l in enumerate(lines, start=1):
+ l.line_num = i
+ for rec in self.filtered(lambda r: not r.report_logbook_sj_id):
+ rec.line_num = 0
+
+ @api.model
+ def create(self, vals):
+ if not vals.get('sequence') and vals.get('report_logbook_sj_id'):
+ last = self.search(
+ [('report_logbook_sj_id', '=', vals['report_logbook_sj_id'])],
+ order='sequence desc, id desc', limit=1
+ )
+ vals['sequence'] = (last.sequence or 0) + 1
+ return super().create(vals)
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index 148a3fd0..36570e8f 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -1,6 +1,6 @@
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError
-from datetime import datetime
+from datetime import datetime, timedelta
from odoo.http import request
import re
import requests
@@ -181,10 +181,8 @@ class ResPartner(models.Model):
payment_difficulty = fields.Selection([('bermasalah', 'Bermasalah'),('sulit', 'Sulit'),('agak_sulit', 'Agak Sulit'),('normal', 'Normal')], string='Payment Difficulty', tracking=3)
payment_history_url = fields.Text(string='Payment History URL')
- # no compute
- # payment_diff = fields.Selection([('bermasalah', 'Bermasalah'),('sulit', 'Sulit'),('agak_sulit', 'Agak Sulit'),('normal', 'Normal')], string='Payment Difficulty', tracking=3)
-
- # tidak terpakai
+ is_cbd_locked = fields.Boolean("Locked to CBD?", default=False, tracking=True, help="Jika dicentang, maka partner ini terkunci pada payment term CBD karena memiliki invoice yang sudah jatuh tempo lebih dari 30 hari.")
+
@api.model
def _default_payment_term(self):
@@ -193,9 +191,10 @@ class ResPartner(models.Model):
property_payment_term_id = fields.Many2one(
'account.payment.term',
string='Payment Terms',
- default=_default_payment_term
+ default=_default_payment_term, tracking=3
)
+
@api.depends("street", "street2", "city", "state_id", "country_id", "blok", "nomor", "rt", "rw", "kelurahan_id",
"kecamatan_id")
def _alamat_lengkap_text(self):
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 903f834b..8f49b579 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -234,9 +234,9 @@ class SaleOrder(models.Model):
customer_type = fields.Selection([
('pkp', 'PKP'),
('nonpkp', 'Non PKP')
- ], required=True, compute='_compute_partner_field')
- sppkp = fields.Char(string="SPPKP", required=True, tracking=True, compute='_compute_partner_field')
- npwp = fields.Char(string="NPWP", required=True, tracking=True, compute='_compute_partner_field')
+ ], related="partner_id.customer_type", string="Customer Type", readonly=True)
+ sppkp = fields.Char(string="SPPKP", related="partner_id.sppkp")
+ npwp = fields.Char(string="NPWP", related="partner_id.npwp")
purchase_total = fields.Monetary(string='Purchase Total', compute='_compute_purchase_total')
voucher_id = fields.Many2one(comodel_name='voucher', string='Voucher', copy=False)
applied_voucher_id = fields.Many2one(comodel_name='voucher', string='Applied Voucher', copy=False)
@@ -393,6 +393,26 @@ class SaleOrder(models.Model):
('paid', 'Full Paid'),
('no_invoice', 'No Invoice'),
], string="Payment Status Invoice", compute="_compute_payment_state_custom", store=False)
+ partner_is_cbd_locked = fields.Boolean(
+ string="Partner Locked CBD",
+ compute="_compute_partner_is_cbd_locked"
+ )
+
+ @api.depends('partner_id.is_cbd_locked')
+ def _compute_partner_is_cbd_locked(self):
+ for order in self:
+ order.partner_is_cbd_locked = order.partner_id.is_cbd_locked
+
+
+ @api.constrains('payment_term_id', 'partner_id', 'state')
+ def _check_cbd_lock_sale_order(self):
+ # cbd_term = self.env['account.payment.term'].browse(26)
+ for rec in self:
+ if rec.state == 'draft' and rec.partner_id.is_cbd_locked:
+ # if rec.payment_term_id and rec.payment_term_id != cbd_term:
+ raise ValidationError(
+ "Customer ini terkunci ke CBD, hanya boleh pakai Payment Term CBD."
+ )
@api.depends('invoice_ids.payment_state', 'invoice_ids.amount_total', 'invoice_ids.amount_residual')
def _compute_payment_state_custom(self):
@@ -1899,26 +1919,30 @@ class SaleOrder(models.Model):
# raise UserError('Kelurahan Real Delivery Address harus diisi')
def generate_payment_link_midtrans_sales_order(self):
- # midtrans_url = 'https://app.sandbox.midtrans.com/snap/v1/transactions' # dev - sandbox
- # midtrans_auth = 'Basic U0ItTWlkLXNlcnZlci1uLVY3ZDJjMlpCMFNWRUQyOU95Q1dWWXA6' # dev - sandbox
- midtrans_url = 'https://app.midtrans.com/snap/v1/transactions' # production
- midtrans_auth = 'Basic TWlkLXNlcnZlci1SbGMxZ2gzWGpSVW5scl9JblZzTV9OTnU6' # production
+ # midtrans_url = 'https://app.sandbox.midtrans.com/snap/v1/transactions' # dev - sandbox
+ # midtrans_auth = 'Basic U0ItTWlkLXNlcnZlci1uLVY3ZDJjMlpCMFNWRUQyOU95Q1dWWXA6' # dev - sandbox
+ midtrans_url = 'https://app.midtrans.com/snap/v1/transactions' # production
+ midtrans_auth = 'Basic TWlkLXNlcnZlci1SbGMxZ2gzWGpSVW5scl9JblZzTV9OTnU6' # production
+
so_number = self.name
so_number = so_number.replace('/', '-')
so_grandtotal = math.floor(self.grand_total)
+
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': midtrans_auth,
}
- check_url = f'https://api.midtrans.com/v2/{so_number}/status'
- check_response = requests.get(check_url, headers=headers)
+ # ==== ENV ====
+ # check_url = f'https://api.sandbox.midtrans.com/v2/{so_number}/status' # dev - sandbox
+ check_url = f'https://api.midtrans.com/v2/{so_number}/status' # production
+ # =============================================
+ check_response = requests.get(check_url, headers=headers)
if check_response.status_code == 200:
status_response = check_response.json()
- if status_response.get('transaction_status') == 'expire' or status_response.get(
- 'transaction_status') == 'cancel':
+ if status_response.get('transaction_status') in ('expire', 'cancel'):
so_number = so_number + '-cpl'
json_data = {
@@ -1950,7 +1974,6 @@ class SaleOrder(models.Model):
buffer = BytesIO()
img.save(buffer, format="PNG")
qr_code_img = base64.b64encode(buffer.getvalue()).decode()
-
self.payment_qr_code = qr_code_img
@api.model
@@ -2026,22 +2049,22 @@ class SaleOrder(models.Model):
# return [('id', 'not in', order_ids)]
# return ['&', ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)]
- @api.depends('partner_id')
- def _compute_partner_field(self):
- for order in self:
- partner = order.partner_id.parent_id or order.partner_id
- order.npwp = partner.npwp
- order.sppkp = partner.sppkp
- order.customer_type = partner.customer_type
+ # @api.depends('partner_id')
+ # def _compute_partner_field(self):
+ # for order in self:
+ # partner = order.partner_id.parent_id or order.partner_id
+ # order.npwp = partner.npwp
+ # order.sppkp = partner.sppkp
+ # order.customer_type = partner.customer_type
@api.onchange('partner_id')
def onchange_partner_contact(self):
parent_id = self.partner_id.parent_id
parent_id = parent_id if parent_id else self.partner_id
- self.npwp = parent_id.npwp
- self.sppkp = parent_id.sppkp
- self.customer_type = parent_id.customer_type
+ # self.npwp = parent_id.npwp
+ # self.sppkp = parent_id.sppkp
+ # self.customer_type = parent_id.customer_type
self.email = parent_id.email
self.pareto_status = parent_id.pareto_status
self.user_id = parent_id.user_id
@@ -2112,15 +2135,21 @@ class SaleOrder(models.Model):
if self.payment_term_id.id == 31 and self.total_percent_margin < 25:
raise UserError("Jika ingin menggunakan Tempo 90 Hari maka margin harus di atas 25%")
- if self.warehouse_id.id != 8 and self.warehouse_id.id != 10: # GD Bandengan
- raise UserError('Gudang harus Bandengan')
+ if self.warehouse_id.id != 8 and self.warehouse_id.id != 10 and self.warehouse_id.id != 12: # GD Bandengan / Pameran
+ raise UserError('Gudang harus Bandengan atau Pameran')
if self.state not in ['draft', 'sent']:
raise UserError("Status harus draft atau sent")
- self._validate_npwp()
-
def _validate_npwp(self):
+ if not self.npwp:
+ raise UserError("NPWP partner kosong, silahkan isi terlebih dahulu npwp nya di contact partner")
+
+ if not self.customer_type:
+ raise UserError("Customer Type partner kosong, silahkan isi terlebih dahulu Customer Type nya di contact partner")
+
+ if not self.sppkp:
+ raise UserError("SPPKP partner kosong, silahkan isi terlebih dahulu SPPKP nya di contact partner")
num_digits = sum(c.isdigit() for c in self.npwp)
if num_digits < 10:
@@ -2134,6 +2163,7 @@ class SaleOrder(models.Model):
self._validate_order()
for order in self:
+ order._validate_npwp()
order._validate_uniform_taxes()
order.order_line.validate_line()
@@ -2188,9 +2218,8 @@ class SaleOrder(models.Model):
if self.validate_different_vendor() and not self.vendor_approval:
return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor')
self.check_due()
-
- self._validate_order()
for order in self:
+ order._validate_npwp()
order._validate_delivery_amt()
order._validate_uniform_taxes()
order.order_line.validate_line()
@@ -2457,6 +2486,7 @@ class SaleOrder(models.Model):
order.check_data_real_delivery_address()
order.sale_order_check_approve()
order._validate_order()
+ order._validate_npwp()
order.order_line.validate_line()
main_parent = order.partner_id.get_main_parent()
@@ -2614,7 +2644,7 @@ class SaleOrder(models.Model):
if user.is_leader or user.is_sales_manager:
return True
- if user.id in (3401, 20, 3988): # admin (fida, nabila, ninda)
+ if user.id in (3401, 20, 3988, 17340): # admin (fida, nabila, ninda)
return True
if self.env.context.get("ask_approval") and user.id in (3401, 20, 3988):
@@ -2642,23 +2672,17 @@ class SaleOrder(models.Model):
def _set_sppkp_npwp_contact(self):
partner = self.partner_id.parent_id or self.partner_id
- if not partner.sppkp:
- partner.sppkp = self.sppkp
- if not partner.npwp:
- partner.npwp = self.npwp
+ # if not partner.sppkp:
+ # partner.sppkp = self.sppkp
+ # if not partner.npwp:
+ # partner.npwp = self.npwp
if not partner.email:
partner.email = self.email
- if not partner.customer_type:
- partner.customer_type = self.customer_type
+ # if not partner.customer_type:
+ # partner.customer_type = self.customer_type
if not partner.user_id:
partner.user_id = self.user_id.id
- # if not partner.sppkp or not partner.npwp or not partner.email or partner.customer_type:
- # partner.customer_type = self.customer_type
- # partner.npwp = self.npwp
- # partner.sppkp = self.sppkp
- # partner.email = self.email
-
def _compute_total_margin(self):
for order in self:
total_margin = sum(line.item_margin for line in order.order_line if line.product_id)
@@ -3100,52 +3124,6 @@ class SaleOrder(models.Model):
# order._update_partner_details()
return order
- # def write(self, vals):
- # Call the super method to handle the write operation
- # res = super(SaleOrder, self).write(vals)
- # self._compute_etrts_date()
- # Check if the update is coming from a save operation
- # if any(field in vals for field in ['sppkp', 'npwp', 'email', 'customer_type']):
- # self._update_partner_details()
-
- # return res
-
- def _update_partner_details(self):
- for order in self:
- partner = order.partner_id.parent_id or order.partner_id
- if partner:
- # Update partner details
- partner.sppkp = order.sppkp
- partner.npwp = order.npwp
- partner.email = order.email
- partner.customer_type = order.customer_type
-
- # Save changes to the partner record
- partner.write({
- 'sppkp': partner.sppkp,
- 'npwp': partner.npwp,
- 'email': partner.email,
- 'customer_type': partner.customer_type,
- })
-
- # def write(self, vals):
- # for order in self:
- # if order.state in ['sale', 'cancel']:
- # if 'order_line' in vals:
- # new_lines = vals.get('order_line', [])
- # for command in new_lines:
- # if command[0] == 0: # A new line is being added
- # raise UserError(
- # "SO tidak dapat ditambahkan produk baru karena SO sudah menjadi sale order.")
- #
- # res = super(SaleOrder, self).write(vals)
- # # self._check_total_margin_excl_third_party()
- # if any(fields in vals for fields in ['delivery_amt', 'carrier_id', 'shipping_cost_covered']):
- # self._validate_delivery_amt()
- # if any(field in vals for field in ["order_line", "client_order_ref"]):
- # self._calculate_etrts_date()
- # return res
-
# @api.depends('commitment_date')
def _compute_ready_to_ship_status_detail(self):
def is_empty(val):
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py
index 47a24264..1f2ea1fb 100644
--- a/indoteknik_custom/models/sale_order_line.py
+++ b/indoteknik_custom/models/sale_order_line.py
@@ -71,23 +71,17 @@ class SaleOrderLine(models.Model):
if order_qty > 0:
for move in line.move_ids:
- # --- CASE 1: Move belum selesai ---
if move.state not in ('done', 'cancel'):
reserved_qty += move.reserved_availability or 0.0
continue
- # --- CASE 2: Move sudah done ---
if move.location_dest_id.usage == 'customer':
- # Barang dikirim ke customer
delivered_qty += move.quantity_done or 0.0
elif move.location_id.usage == 'customer':
- # Barang balik dari customer (retur)
delivered_qty -= move.quantity_done or 0.0
- # Clamp supaya delivered gak minus
delivered_qty = max(delivered_qty, 0)
- # Hitung persen
line.reserved_percent = min((reserved_qty / order_qty) * 100, 100) if order_qty else 0
line.delivered_percent = min((delivered_qty / order_qty) * 100, 100) if order_qty else 0
line.unreserved_percent = max(100 - line.reserved_percent - line.delivered_percent, 0)
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index 90ab30a4..d6505a86 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -1,6 +1,9 @@
from odoo import fields, models, api
from odoo.tools.misc import format_date, OrderedSet
from odoo.exceptions import UserError
+import logging
+
+_logger = logging.getLogger(__name__)
class StockMove(models.Model):
_inherit = 'stock.move'
@@ -15,6 +18,7 @@ class StockMove(models.Model):
barcode = fields.Char(string='Barcode', related='product_id.barcode')
vendor_id = fields.Many2one('res.partner' ,string='Vendor')
hold_outgoingg = fields.Boolean('Hold Outgoing', default=False)
+ product_image = fields.Binary(related="product_id.image_128", string="Product Image", readonly=True)
# @api.model_create_multi
# def create(self, vals_list):
diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py
index 6e839bf0..d718ba0f 100644
--- a/indoteknik_custom/models/tukar_guling.py
+++ b/indoteknik_custom/models/tukar_guling.py
@@ -710,7 +710,7 @@ class TukarGuling(models.Model):
### ======== SRT dari BU/OUT =========
srt_return_lines = []
- if mapping_koli:
+ if mapping_koli and record.operations.picking_type_id.id == 29:
for prod in mapping_koli.mapped('product_id'):
qty_total = sum(mk.qty_return for mk in mapping_koli.filtered(lambda m: m.product_id == prod))
move = bu_out.move_lines.filtered(lambda m: m.product_id == prod)
@@ -723,7 +723,7 @@ class TukarGuling(models.Model):
}))
_logger.info(f"📟 SRT line: {prod.display_name} | qty={qty_total}")
- elif not mapping_koli:
+ elif not mapping_koli and record.operations.picking_type_id.id == 29:
for line in record.line_ids:
move = bu_out.move_lines.filtered(lambda m: m.product_id == line.product_id)
if not move:
diff --git a/indoteknik_custom/report/purchase_report.xml b/indoteknik_custom/report/purchase_report.xml
new file mode 100644
index 00000000..6666235a
--- /dev/null
+++ b/indoteknik_custom/report/purchase_report.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <data>
+ <!-- Report Action -->
+ <record id="action_report_purchaseorder_website" model="ir.actions.report">
+ <field name="name">Purchase Order (Website)</field>
+ <field name="model">purchase.order</field>
+ <field name="report_type">qweb-pdf</field>
+ <field name="report_name">indoteknik_custom.report_purchaseorder_website</field>
+ <field name="report_file">indoteknik_custom.report_purchaseorder_website</field>
+ <field name="print_report_name">
+ ('PO - %s - %s' % (object.partner_id.name, object.name))
+ </field>
+ <field name="binding_model_id" ref="purchase.model_purchase_order"/>
+ <field name="binding_type">report</field>
+ </record>
+ </data>
+
+ <!-- Wrapper Template -->
+ <template id="report_purchaseorder_website">
+ <t t-call="web.html_container">
+ <t t-foreach="docs" t-as="doc">
+ <t t-call="indoteknik_custom.report_purchaseorder_website_document" t-lang="doc.partner_id.lang"/>
+ </t>
+ </t>
+ </template>
+
+ <template id="report_purchaseorder_website_document">
+ <t t-call="web.html_container">
+ <t t-set="doc" t-value="doc.with_context(lang=doc.partner_id.lang)" />
+
+ <!-- HEADER -->
+ <div class="header">
+ <img src="https://erp.indoteknik.com/api/image/ir.attachment/datas/2498521"
+ style="width:100%; display:block;"/>
+ </div>
+
+ <!-- PAGE CONTENT -->
+ <div class="article" style="margin: 0 1.5cm 0 1.5cm; font-family:Arial, sans-serif; font-size:14px; color:#333;">
+
+ <!-- TITLE -->
+ <h2 style="text-align:center; margin:8px 0 0 0; color:#d32f2f; font-weight:800; letter-spacing:1px;">
+ PURCHASE ORDER
+ </h2>
+ <h4 style="text-align:center; margin:4px 0 20px 0; font-weight:normal; color:#555;">
+ No. <span t-field="doc.name"/>
+ </h4>
+
+ <!-- TOP INFO -->
+ <table style="width:100%; margin-bottom:20px; border-radius:8px; box-shadow:0 1px 4px rgba(0,0,0,0.1); overflow:hidden; border:1px solid #ddd;">
+ <tr style="background:#fafafa;">
+ <td style="padding:10px 12px;"><strong>Term Of Payment:</strong> <span t-field="doc.payment_term_id.name"/></td>
+ <td style="padding:10px 12px;"><strong>Order Date:</strong> <span t-field="doc.date_order" t-options='{"widget": "date"}'/></td>
+ <td style="padding:10px 12px;"><strong>Responsible:</strong> <span t-field="doc.user_id"/></td>
+ </tr>
+ </table>
+
+ <!-- VENDOR & DELIVERY -->
+ <table style="width:100%; margin-bottom:24px; border-spacing:16px 0;">
+ <tr>
+ <td style="width:50%; border:1px solid #ccc; border-radius:8px; padding:10px; background:#fcfcfc; vertical-align:top;">
+ <strong style="color:#d32f2f;">Alamat Pengiriman</strong><br/>
+ PT Indoteknik (Bandengan 1 Depan)<br/>
+ Jl. Bandengan Utara Komp A 8 B<br/>
+ RT. Penjaringan, Kec. Penjaringan, Jakarta (BELAKANG INDOMARET)<br/>
+ JK 14440 - Indonesia
+ </td>
+ <td style="width:50%; border:1px solid #ccc; border-radius:8px; padding:10px; background:#fcfcfc; vertical-align:top;">
+ <strong style="color:#d32f2f;">Nama Vendor</strong><br/>
+ <span t-field="doc.partner_id.name"/><br/>
+ <span t-field="doc.partner_id.street"/><br/>
+ <span t-field="doc.partner_id.city"/> - <span t-field="doc.partner_id.zip"/>
+ </td>
+ </tr>
+ </table>
+
+ <!-- ORDER LINES -->
+ <table style="border-collapse:collapse; width:100%; margin-top:16px; font-size:14px;">
+ <tbody>
+ <!-- HEADER -->
+ <tr style="background:#e53935; color:white;">
+ <th style="border:1px solid #ccc; padding:8px; text-align:left;">No. &amp; Description</th>
+ <th style="border:1px solid #ccc; padding:8px; text-align:left;">Image</th>
+ <th style="border:1px solid #ccc; padding:8px; text-align:center;">Quantity</th>
+ <th style="border:1px solid #ccc; padding:8px; text-align:center;">Unit Price</th>
+ <th style="border:1px solid #ccc; padding:8px; text-align:center;">Taxes</th>
+ <th style="border:1px solid #ccc; padding:8px; text-align:center;">Subtotal</th>
+ </tr>
+
+ <!-- ISI ORDER LINE -->
+ <t t-foreach="doc.order_line" t-as="line" t-index="line_index">
+ <tr t-attf-style="background-color: #{ '#fafafa' if line_index % 2 == 0 else 'white' };">
+
+ <!-- NO & DESCRIPTION + IMAGE -->
+ <td style="border:1px solid #ccc; padding: 6px; display:flex; align-items:center; gap:10px;">
+ <t t-if="not line.image_small">
+ <div style="width:40px; height:40px; background:#f5f5f5; border:1px solid #ddd; border-radius:6px; display:flex; align-items:center; justify-content:center; color:#999; font-size:10px;">
+ N/A
+ </div>
+ </t>
+
+ <!-- TEKS -->
+ <div style="display:flex; flex-direction:column; flex:1;">
+ <span style="font-weight:bold; margin-bottom:2px;">
+ <t t-esc="line_index + 1"/>. <t t-esc="line.name"/>
+ </span>
+ </div>
+ </td>
+
+ <t t-if="line.image_small">
+ <td style="border:1px solid #ccc; padding:6px; text-align:center;">
+ <img t-att-src="image_data_uri(line.image_small)"
+ style="width:100px; height:100px; object-fit:contain; border:1px solid #ddd; border-radius:6px; background:#fff;"/>
+ </td>
+ </t>
+ <!-- QTY -->
+ <td style="border:1px solid #ccc; padding:6px; text-align:center;">
+ <span t-field="line.product_qty"/> <span t-field="line.product_uom"/>
+ </td>
+
+ <!-- UNIT PRICE -->
+ <td style="border:1px solid #ccc; padding:6px; text-align:center;">
+ <span t-field="line.price_unit"/>
+ </td>
+
+ <!-- TAXES -->
+ <td style="border:1px solid #ccc; padding:6px; text-align:center;">
+ <span t-esc="', '.join(map(lambda x: (x.description or x.name), line.taxes_id))"/>
+ </td>
+
+ <!-- SUBTOTAL -->
+ <td style="border:1px solid #ccc; padding:6px; text-align:right; font-weight:bold;">
+ <span t-field="line.price_subtotal"/>
+ </td>
+ </tr>
+
+ <!-- WEBSITE DESCRIPTION -->
+ <t t-if="line.product_id.website_description">
+ <tr t-attf-style="background-color: #{ '#fef5f5' if line_index % 2 == 0 else '#fffafa' }; ">
+ <td colspan="6" style="padding: 10px 14px; font-size:12px; line-height:1.3; font-style:italic; color:#555; border-left:1px solid #ccc; border-right:1px solid #ccc; border-bottom:1px solid #ccc;">
+ <div t-raw="line.product_id.website_description"/>
+ </td>
+ </tr>
+ </t>
+ </t>
+ </tbody>
+ </table>
+
+
+ <!-- TOTALS -->
+ <table style="margin-top:24px; margin-left:auto; width:40%; font-size:14px; border:1px solid #ddd; border-radius:6px; box-shadow:0 1px 3px rgba(0,0,0,0.08);">
+ <tr style="background:#fafafa;">
+ <td style="padding:8px;"><strong>Subtotal</strong></td>
+ <td style="text-align:right; padding:8px;"><span t-field="doc.amount_untaxed"/></td>
+ </tr>
+ <tr>
+ <td style="padding:8px;">Taxes</td>
+ <td style="text-align:right; padding:8px;"><span t-field="doc.amount_tax"/></td>
+ </tr>
+ <tr style="background:#fbe9e7; font-weight:bold; color:#d32f2f;">
+ <td style="padding:8px;">Total</td>
+ <td style="text-align:right; padding:8px;"><span t-field="doc.amount_total"/></td>
+ </tr>
+ </table>
+
+ <!-- NOTES -->
+ <div style="margin-top:24px; padding:12px; border-top:1px solid #ddd; font-style:italic; color:#555;">
+ <p t-field="doc.notes"/>
+ </div>
+ </div>
+
+ <!-- STATIC FOOTER -->
+ <div class="footer">
+ <img src="https://erp.indoteknik.com/api/image/ir.attachment/datas/2859765"
+ style="width:100%; display:block;"/>
+ </div>
+
+ </t>
+ </template>
+
+
+
+</odoo>
diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml
index 1b477c6d..c88effd5 100644
--- a/indoteknik_custom/views/account_move.xml
+++ b/indoteknik_custom/views/account_move.xml
@@ -39,6 +39,7 @@
</field>
<field name="ref" position="after">
<field name="sale_id" readonly="1" attrs="{'invisible': ['|', ('move_type', '!=', 'entry'), ('has_refund_so', '=', True)]}"/>
+ <field name="refund_id" readonly="1" attrs="{'invisible': ['|', ('move_type', '!=', 'entry'), ('has_refund_so', '=', False)]}"/>
<field name="refund_so_links" readonly="1" widget="html" attrs="{'invisible': ['|', ('move_type', '!=', 'entry'), ('has_refund_so', '=', False)]}"/>
<field name="has_refund_so" invisible="1"/>
</field>
diff --git a/indoteknik_custom/views/approval_payment_term.xml b/indoteknik_custom/views/approval_payment_term.xml
index 5c130f3f..b0b99689 100644
--- a/indoteknik_custom/views/approval_payment_term.xml
+++ b/indoteknik_custom/views/approval_payment_term.xml
@@ -7,7 +7,7 @@
<tree default_order="create_date desc">
<field name="number"/>
<field name="partner_id"/>
- <field name="parent_id"/>
+ <field name="parent_id" optional="hide"/>
<field name="property_payment_term_id"/>
<field name="create_date" optional="hide"/>
<field name="approve_date" optional="hide"/>
diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml
index f624c42e..51377f78 100644
--- a/indoteknik_custom/views/dunning_run.xml
+++ b/indoteknik_custom/views/dunning_run.xml
@@ -25,13 +25,14 @@
<field name="arch" type="xml">
<tree>
<field name="partner_id"/>
+ <field name="reference"/>
<field name="invoice_id"/>
<field name="date_invoice"/>
- <field name="efaktur_id"/>
- <field name="reference"/>
+ <field name="efaktur_id" optional="hide"/>
<field name="total_amt" sum="Grand Total Amount"/>
<field name="open_amt"/>
<field name="due_date"/>
+ <field name="payment_term"/>
</tree>
</field>
</record>
diff --git a/indoteknik_custom/views/refund_sale_order.xml b/indoteknik_custom/views/refund_sale_order.xml
index ae0861e2..51f3deab 100644
--- a/indoteknik_custom/views/refund_sale_order.xml
+++ b/indoteknik_custom/views/refund_sale_order.xml
@@ -92,7 +92,7 @@
</div>
<field name="show_approval_alert" invisible="1"/>
<div class="alert alert-info" role="alert"
- attrs="{'invisible': ['|', ('show_approval_alert', '=', False), ('status', 'in', ['reject', 'refund'])]}">
+ attrs="{'invisible': ['|', ('show_approval_alert', '=', False), '|', ('status', 'in', ['reject', 'refund']), ('refund_type', 'not in', ['retur_full', 'retur_sebagian'])]}">
⚠️ SO sudah melakukan retur barang. Silakan lanjutkan refund.
</div>
</xpath>
@@ -214,12 +214,12 @@
<page string="Finance Note">
<group col="2">
<group>
- <field name="finance_note" attrs="{'readonly': [('is_locked', '=', True)]}"/>
+ <field name="finance_note"/>
</group>
<group>
- <field name="bukti_refund_type" reqiured="1" attrs="{'readonly': [('is_locked', '=', True)]}"/>
- <field name="bukti_transfer_refund_pdf" widget="pdf_viewer" attrs="{'invisible': [('bukti_refund_type', '=', 'image')], 'readonly': [('is_locked', '=', True)]}"/>
- <field name="bukti_transfer_refund_image" widget="image" attrs="{'invisible': [('bukti_refund_type', '=', 'pdf')], 'readonly': [('is_locked', '=', True)]}"/>
+ <field name="bukti_refund_type" reqiured="1"/>
+ <field name="bukti_transfer_refund_pdf" widget="pdf_viewer" attrs="{'invisible': [('bukti_refund_type', '=', 'image')]}"/>
+ <field name="bukti_transfer_refund_image" widget="image" attrs="{'invisible': [('bukti_refund_type', '=', 'pdf')]}"/>
</group>
</group>
</page>
diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml
index 6458af40..14bfecfb 100644
--- a/indoteknik_custom/views/report_logbook_sj.xml
+++ b/indoteknik_custom/views/report_logbook_sj.xml
@@ -22,6 +22,8 @@
<field name="model">report.logbook.sj.line</field>
<field name="arch" type="xml">
<tree editable="bottom">
+<!-- <field name="sequence" widget="handle"/>-->
+ <field name="line_num" string="No" readonly="1"/>
<field name="name"/>
<field name="driver_id"/>
<field name="departure_date"/>
diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml
index ca1a36de..c32151d8 100644
--- a/indoteknik_custom/views/res_partner.xml
+++ b/indoteknik_custom/views/res_partner.xml
@@ -21,6 +21,7 @@
<field name="reference_number"/>
</field>
<field name="property_payment_term_id" position="after">
+ <field name="is_cbd_locked" readonly="1"/>
<field name="user_payment_terms_sales" readonly="1"/>
<field name="date_payment_terms_sales" readonly="1"/>
</field>
@@ -35,9 +36,9 @@
<field name="pareto_status"/>
<field name="digital_invoice_tax"/>
</field>
- <field name="nama_wajib_pajak" position="attributes">
+ <!-- <field name="nama_wajib_pajak" position="attributes">
<attribute name="required">1</attribute>
- </field>
+ </field> -->
<field name="kota_id" position="attributes">
<attribute name="required">0</attribute>
</field>
@@ -47,14 +48,14 @@
<field name="kelurahan_id" position="attributes">
<attribute name="required">0</attribute>
</field>
- <field name="npwp" position="attributes">
+ <!-- <field name="npwp" position="attributes">
<attribute name="required">1</attribute>
</field>
<field name="alamat_lengkap_text" position="attributes">
<attribute name="required">1</attribute>
- </field>
+ </field> -->
<field name="npwp" position="before">
- <field name="customer_type" required="1"/>
+ <field name="customer_type"/>
</field>
<field name="alamat_lengkap_text" position="after">
<field name="nitku" />
@@ -107,7 +108,7 @@
<field name="reminder_invoices"/>
</xpath>
<xpath expr="//field[@name='property_payment_term_id']" position="attributes">
- <attribute name="readonly">0</attribute>
+ <attribute name="readonly">1</attribute>
</xpath>
<xpath expr="//field[@name='property_supplier_payment_term_id']" position="attributes">
<attribute name="readonly">1</attribute>
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 156c48d7..44da3e13 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -41,6 +41,15 @@
string="Refund"
class="btn-primary" />
</xpath>
+ <xpath expr="//sheet" position="before">
+ <field name="partner_is_cbd_locked" invisible="1"/>
+ <div class="alert alert-danger"
+ role="alert"
+ style="height: 40px; margin-bottom:0px;"
+ attrs="{'invisible':['|', ('partner_is_cbd_locked','=',False), ('state', 'not in', ['draft', 'cancel'])]}">
+ <strong>Warning!</strong> Payment Terms Customer terkunci menjadi <b>Cash Before Delivery (C.B.D.)</b> karena ada invoice telah jatuh tempo <b>30 hari</b>. Silakan ajukan <b>Approval Payment Term</b> untuk membuka kunci.
+ </div>
+ </xpath>
<div class="oe_button_box" name="button_box">
<field name="advance_payment_move_ids" invisible="1"/>
<button name="action_open_advance_payment_moves"
@@ -139,9 +148,9 @@
<field name="pareto_status"/>
</field>
<field name="analytic_account_id" position="after">
- <field name="customer_type" readonly="1"/>
- <field name="npwp" placeholder='99.999.999.9-999.999' readonly="1"/>
- <field name="sppkp" attrs="{'required': [('customer_type', '=', 'pkp')]}" readonly="1"/>
+ <field name="customer_type"/>
+ <field name="npwp" placeholder='99.999.999.9-999.999'/>
+ <field name="sppkp" attrs="{'required': [('customer_type', '=', 'pkp')]}"/>
<field name="email" required="1"/>
<field name="unreserve_id"/>
<field name="due_id" readonly="1"/>
diff --git a/indoteknik_custom/views/stock_move_line.xml b/indoteknik_custom/views/stock_move_line.xml
index 757d2522..94c0bf53 100644
--- a/indoteknik_custom/views/stock_move_line.xml
+++ b/indoteknik_custom/views/stock_move_line.xml
@@ -3,18 +3,19 @@
<record id="stock_move_line_form_view_inherited" model="ir.ui.view">
<field name="name">Stock Move Line</field>
<field name="model">stock.move.line</field>
- <field name="inherit_id" ref="stock.view_move_line_form" />
+ <field name="inherit_id" ref="stock.view_move_line_form"/>
+ <field name="priority" eval="100"/>
<field name="arch" type="xml">
- <field name="qty_done" position="after">
+ <xpath expr="(//form//group[.//field[@name='qty_done']])[last()]" position="inside">
<field name="manufacture"/>
- </field>
+ </xpath>
</field>
</record>
<record id="stock_move_line_tree_view_inherited" model="ir.ui.view">
<field name="name">Stock Move Line</field>
<field name="model">stock.move.line</field>
- <field name="inherit_id" ref="stock.view_move_line_tree" />
+ <field name="inherit_id" ref="stock.view_move_line_tree"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="manufacture"/>
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index b3f0ce9f..fc8be790 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -8,7 +8,7 @@
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="default_order">final_seq asc</attribute>
- <!-- <attribute name="default_order">create_date desc</attribute> -->
+ <!-- <attribute name="default_order">create_date desc</attribute> -->
</tree>
<field name="json_popover" position="after">
<field name="date_done" optional="hide"/>
@@ -20,9 +20,11 @@
<field name="sj_return_date" optional="hide"/>
<field name="date_reserved" optional="hide"/>
<field name="state_reserve" optional="hide"/>
- <field name="state_packing" widget="badge" decoration-success="state_packing == 'packing_done'" decoration-danger="state_packing == 'not_packing'" optional="hide"/>
+ <field name="state_packing" widget="badge" decoration-success="state_packing == 'packing_done'"
+ decoration-danger="state_packing == 'not_packing'" optional="hide"/>
<field name="final_seq"/>
- <field name="state_approve_md" widget="badge" decoration-success="state_approve_md == 'done'" decoration-warning="state_approve_md == 'pending'" optional="hide"/>
+ <field name="state_approve_md" widget="badge" decoration-success="state_approve_md == 'done'"
+ decoration-warning="state_approve_md == 'pending'" optional="hide"/>
<!-- <field name="countdown_hours" optional="hide"/>
<field name="countdown_ready_to_ship" /> -->
</field>
@@ -50,11 +52,11 @@
type="object"
attrs="{'invisible': ['|', ('state', 'in', ['done']), ('approval_receipt_status', '=', 'pengajuan1')]}"
/>
-<!-- <button name="ask_return_approval"-->
-<!-- string="Ask Return/Acc"-->
-<!-- type="object"-->
-<!-- attrs="{'invisible': [('state', 'in', ['draft', 'cancel', 'assigned'])]}"-->
-<!-- />-->
+ <!-- <button name="ask_return_approval"-->
+ <!-- string="Ask Return/Acc"-->
+ <!-- type="object"-->
+ <!-- attrs="{'invisible': [('state', 'in', ['draft', 'cancel', 'assigned'])]}"-->
+ <!-- />-->
<button name="action_create_invoice_from_mr"
string="Create Bill"
type="object"
@@ -64,12 +66,12 @@
string="Biteship"
type="object"
/>
- <!-- <button name="action_sync_biteship_tracking"
- type="object"
- string="Lacak dari Biteship"
- class="btn-primary"
- attrs="{'invisible': [('biteship_id', '=', False)]}"
- /> -->
+ <!-- <button name="action_sync_biteship_tracking"
+ type="object"
+ string="Lacak dari Biteship"
+ class="btn-primary"
+ attrs="{'invisible': [('biteship_id', '=', False)]}"
+ /> -->
<button name="track_envio_shipment"
string="Tracking Envio"
type="object"
@@ -97,6 +99,11 @@
attrs="{'invisible': [('state_approve_md', 'not in', ['waiting'])]}"
/>
</button>
+ <!-- <xpath expr="//field[@name='move_ids_without_package']//tree//field[@name='product_uom']"
+ position="after">
+ <field name="product_image" widget="image"
+ style="height:128px;width:128px;" readonly="1"/>
+ </xpath> -->
<field name="backorder_id" position="after">
<field name="select_shipping_option_so"/>
<field name="shipping_method_so_id"/>
@@ -105,7 +112,8 @@
<field name="count_line_detail"/>
<field name="dokumen_tanda_terima"/>
<field name="dokumen_pengiriman"/>
- <field name="quantity_koli" attrs="{'invisible': [('location_dest_id', '!=', 60)], 'required': [('location_dest_id', '=', 60)]}"/>
+ <field name="quantity_koli"
+ attrs="{'invisible': [('location_dest_id', '!=', 60)], 'required': [('location_dest_id', '=', 60)]}"/>
<field name="total_mapping_koli" attrs="{'invisible': [('location_id', '!=', 60)]}"/>
<field name="total_koli_display" readonly="1" attrs="{'invisible': [('location_id', '!=', 60)]}"/>
<field name="linked_out_picking_id" readonly="1" attrs="{'invisible': [('location_id', '=', 60)]}"/>
@@ -132,8 +140,13 @@
<field name="scheduled_date" position="attributes">
<attribute name="readonly">1</attribute>
</field>
+ <xpath expr="//field[@name='move_ids_without_package']/form/group/field[@name='description_picking']"
+ position="after">
+ <field name="product_image" widget="image" string="Product Image"/>
+ </xpath>
+
<field name="origin" position="after">
-<!-- <field name="show_state_approve_md" invisible="1" optional="hide"/>-->
+ <!-- <field name="show_state_approve_md" invisible="1" optional="hide"/>-->
<field name="state_approve_md" widget="badge"/>
<field name="purchase_id"/>
<field name="sale_order"/>
@@ -141,7 +154,8 @@
<field name="date_doc_kirim" attrs="{'readonly':[('invoice_status', '=', 'invoiced')]}"/>
<field name="summary_qty_operation"/>
<field name="count_line_operation"/>
- <field name="linked_manual_bu_out" attrs="{'invisible': [('location_id', '=', 60)]}" domain="[('picking_type_code', '=', 'outgoing'),('state', 'not in', ['done','cancel']), ('group_id', '=', group_id)]"/>
+ <field name="linked_manual_bu_out" attrs="{'invisible': [('location_id', '=', 60)]}"
+ domain="[('picking_type_code', '=', 'outgoing'),('state', 'not in', ['done','cancel']), ('group_id', '=', group_id)]"/>
<field name="account_id"
attrs="{
'readonly': [['state', 'in', ['done', 'cancel']]],
@@ -189,29 +203,35 @@
</group>
</group>
</page>
- <page string="Delivery" name="delivery_order" attrs="{'invisible': [('location_dest_id', '=', 60)]}">
+ <page string="Delivery" name="delivery_order"
+ attrs="{'invisible': [('location_dest_id', '=', 60)]}">
<group>
<group>
<field name="notee"/>
<field name="note_logistic"/>
<field name="note_info"/>
- <field name="responsible" />
- <field name="carrier_id" attrs="{'invisible': [('select_shipping_option_so', '=', 'biteship')]}" />
+ <field name="responsible"/>
+ <field name="carrier_id"
+ attrs="{'invisible': [('select_shipping_option_so', '=', 'biteship')]}"/>
<field name="biteship_id" invisible="1"/>
<field name="out_code" attrs="{'invisible': [['out_code', '=', False]]}"/>
<field name="picking_code" attrs="{'invisible': [['picking_code', '=', False]]}"/>
- <field name="picking_code" string="Picking code (akan digenerate ketika sudah di-validate)" attrs="{'invisible': [['picking_code', '!=', False]]}"/>
- <field name="driver_departure_date" attrs="{'readonly':[('invoice_status', '=', 'invoiced')]}"/>
+ <field name="picking_code"
+ string="Picking code (akan digenerate ketika sudah di-validate)"
+ attrs="{'invisible': [['picking_code', '!=', False]]}"/>
+ <field name="driver_departure_date"
+ attrs="{'readonly':[('invoice_status', '=', 'invoiced')]}"/>
<field name="driver_arrival_date"/>
- <field name="delivery_tracking_no" attrs="{'invisible': [('select_shipping_option_so', '=', 'biteship')]}"/>
+ <field name="delivery_tracking_no"
+ attrs="{'invisible': [('select_shipping_option_so', '=', 'biteship')]}"/>
<field name="driver_id"/>
<field name='sj_return_date'/>
- <field name="sj_documentation" widget="image" />
- <field name="paket_documentation" widget="image" />
+ <field name="sj_documentation" widget="image"/>
+ <field name="paket_documentation" widget="image"/>
</group>
<!-- Biteship Group -->
<group attrs="{'invisible': [('select_shipping_option_so', '!=', 'biteship')]}">
- <field name="delivery_tracking_no" />
+ <field name="delivery_tracking_no"/>
<field name="shipping_method_so_id"/>
<field name="shipping_option_so_id"/>
<field name="biteship_shipping_price" readonly="1"/>
@@ -220,7 +240,8 @@
<field name="biteship_driver_name" readonly="1"/>
<field name="biteship_driver_phone" readonly="1"/>
<field name="biteship_driver_plate_number" readonly="1"/>
- <button name="action_open_biteship_tracking" string="Visit Biteship Tracking" type="object"/>
+ <button name="action_open_biteship_tracking" string="Visit Biteship Tracking"
+ type="object"/>
</group>
<group attrs="{'invisible': [('carrier_id', '!=', 151)]}">
@@ -261,23 +282,27 @@
</group>
</group>
</page>
- <page string="Check Product" name="check_product" attrs="{'invisible': [('picking_type_code', '=', 'outgoing')]}">
+ <page string="Check Product" name="check_product"
+ attrs="{'invisible': [('picking_type_code', '=', 'outgoing')]}">
<field name="check_product_lines"/>
</page>
- <page string="Barcode Product" name="barcode_product" attrs="{'invisible': [('picking_type_code', '!=', 'incoming')]}">
+ <page string="Barcode Product" name="barcode_product"
+ attrs="{'invisible': [('picking_type_code', '!=', 'incoming')]}">
<field name="barcode_product_lines"/>
</page>
<page string="Check Koli" name="check_koli" attrs="{'invisible': [('location_dest_id', '!=', 60)]}">
<field name="check_koli_lines"/>
</page>
- <page string="Mapping Koli" name="konfirm_koli" attrs="{'invisible': [('picking_type_code', '!=', 'outgoing')]}">
+ <page string="Mapping Koli" name="konfirm_koli"
+ attrs="{'invisible': [('picking_type_code', '!=', 'outgoing')]}">
<field name="konfirm_koli_lines"/>
</page>
- <page string="Konfirm Koli" name="scan_koli" attrs="{'invisible': [('picking_type_code', '!=', 'outgoing')]}">
+ <page string="Konfirm Koli" name="scan_koli"
+ attrs="{'invisible': [('picking_type_code', '!=', 'outgoing')]}">
<field name="scan_koli_lines"/>
</page>
</page>
-
+
</field>
</record>
@@ -287,18 +312,20 @@
<field name="arch" type="xml">
<tree editable="bottom">
<field name="code_koli"/>
- <field name="koli_id" options="{'no_create': True}" domain="[('state', '=', 'not_delivered')]"/>
+ <field name="koli_id" options="{'no_create': True}" domain="[('state', '=', 'not_delivered')]"/>
<field name="scan_koli_progress"/>
</tree>
</field>
</record>
+
<record id="konfirm_koli_tree" model="ir.ui.view">
<field name="name">konfirm.koli.tree</field>
<field name="model">konfirm.koli</field>
<field name="arch" type="xml">
<tree editable="bottom">
- <field name="pick_id" options="{'no_create': True}" required="1" domain="[('picking_type_code', '=', 'internal'), ('group_id', '=', parent.group_id), ('linked_manual_bu_out', '=', parent.id)]"/>
+ <field name="pick_id" options="{'no_create': True}" required="1"
+ domain="[('picking_type_code', '=', 'internal'), ('group_id', '=', parent.group_id), ('linked_manual_bu_out', '=', parent.id)]"/>
</tree>
</field>
</record>
@@ -307,7 +334,7 @@
<field name="name">check.koli.tree</field>
<field name="model">check.koli</field>
<field name="arch" type="xml">
- <tree editable="bottom">
+ <tree editable="bottom">
<field name="koli"/>
<field name="reserved_id"/>
<field name="check_koli_progress"/>
@@ -344,12 +371,14 @@
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree"/>
<field name="arch" type="xml">
- <tree editable="bottom" decoration-muted="(state == 'done' and is_locked == True)" decoration-danger="qty_done&gt;product_uom_qty and state!='done' and parent.picking_type_code != 'incoming'" decoration-success="qty_done==product_uom_qty and state!='done' and not result_package_id">
+ <tree editable="bottom" decoration-muted="(state == 'done' and is_locked == True)"
+ decoration-danger="qty_done&gt;product_uom_qty and state!='done' and parent.picking_type_code != 'incoming'"
+ decoration-success="qty_done==product_uom_qty and state!='done' and not result_package_id">
<field name="note" placeholder="Add a note here"/>
</tree>
</field>
</record>
-
+
<record id="view_picking_internal_search_inherit" model="ir.ui.view">
<field name="name">stock.picking.internal.search.inherit</field>
@@ -382,7 +411,7 @@
</form>
</field>
</record>
-
+
<record id="action_warning_modal_wizard" model="ir.actions.act_window">
<field name="name">Peringatan Koli</field>
<field name="res_model">warning.modal.wizard</field>