summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2025-02-24 11:32:06 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2025-02-24 11:32:06 +0700
commit7df979b8d5312bb90d13d338f2a787dc35373f17 (patch)
tree12a5fd7b487781b52900505a2cffa999da692f9f
parenta9c4cd0c5ac694074f0e3a4359182a97f27f542e (diff)
parent38f8ddd9aaaad58c8d7ea27235cd109ba288693d (diff)
Merge branch 'odoo-production' into feature/integrasi_biteship
# Conflicts: # indoteknik_custom/models/__init__.py # indoteknik_custom/models/product_template.py # indoteknik_custom/models/sale_order.py # indoteknik_custom/security/ir.model.access.csv
-rw-r--r--indoteknik_api/controllers/api_v1/stock_picking.py2
-rw-r--r--indoteknik_api/controllers/api_v1/user.py3
-rwxr-xr-xindoteknik_custom/__manifest__.py3
-rwxr-xr-xindoteknik_custom/models/__init__.py4
-rw-r--r--indoteknik_custom/models/account_move.py14
-rw-r--r--indoteknik_custom/models/account_move_line.py9
-rw-r--r--indoteknik_custom/models/account_payment_register.py48
-rw-r--r--indoteknik_custom/models/automatic_purchase.py141
-rw-r--r--indoteknik_custom/models/barcoding_product.py45
-rw-r--r--indoteknik_custom/models/coretax_fatur.py2
-rw-r--r--indoteknik_custom/models/invoice_reklas.py4
-rw-r--r--indoteknik_custom/models/invoice_reklas_penjualan.py2
-rw-r--r--indoteknik_custom/models/ir_actions_report.py51
-rwxr-xr-xindoteknik_custom/models/product_template.py39
-rwxr-xr-xindoteknik_custom/models/purchase_order.py5
-rw-r--r--indoteknik_custom/models/purchase_order_multi_uangmuka.py2
-rw-r--r--indoteknik_custom/models/purchasing_job.py1
-rw-r--r--indoteknik_custom/models/report_logbook_sj.py2
-rw-r--r--indoteknik_custom/models/report_stock_forecasted.py49
-rw-r--r--indoteknik_custom/models/res_partner.py14
-rwxr-xr-xindoteknik_custom/models/sale_order.py77
-rw-r--r--indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py2
-rw-r--r--indoteknik_custom/models/solr/product_template.py7
-rw-r--r--indoteknik_custom/models/stock_immediate_transfer.py1
-rw-r--r--indoteknik_custom/models/stock_move.py4
-rw-r--r--indoteknik_custom/models/stock_picking.py302
-rw-r--r--indoteknik_custom/models/uangmuka_pembelian.py2
-rw-r--r--indoteknik_custom/models/uangmuka_penjualan.py2
-rw-r--r--indoteknik_custom/models/user_company_request.py6
-rw-r--r--indoteknik_custom/models/user_pengajuan_tempo_request.py73
-rw-r--r--indoteknik_custom/models/website_telegram.py193
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv6
-rw-r--r--indoteknik_custom/views/account_move.xml3
-rw-r--r--indoteknik_custom/views/barcoding_product.xml76
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml6
-rw-r--r--indoteknik_custom/views/report_logbook_sj.xml10
-rw-r--r--indoteknik_custom/views/res_partner.xml1
-rwxr-xr-xindoteknik_custom/views/sale_order.xml3
-rw-r--r--indoteknik_custom/views/stock_backorder_confirmation_views.xml14
-rw-r--r--indoteknik_custom/views/stock_picking.xml27
-rw-r--r--indoteknik_custom/views/user_pengajuan_tempo.xml2
-rw-r--r--indoteknik_custom/views/user_pengajuan_tempo_request.xml18
-rw-r--r--indoteknik_custom/views/website_telegram.xml59
43 files changed, 1109 insertions, 225 deletions
diff --git a/indoteknik_api/controllers/api_v1/stock_picking.py b/indoteknik_api/controllers/api_v1/stock_picking.py
index 01269724..9da9575b 100644
--- a/indoteknik_api/controllers/api_v1/stock_picking.py
+++ b/indoteknik_api/controllers/api_v1/stock_picking.py
@@ -57,7 +57,7 @@ class StockPicking(controller.Controller):
if params['status'] == 'pending':
domain += pending_domain
elif params['status'] == 'shipment':
- domain += shipment_domain
+ domain += shipment_domain + shipment_domain2
elif params['status'] == 'completed':
domain += completed_domain
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py
index f71af89f..1d26d356 100644
--- a/indoteknik_api/controllers/api_v1/user.py
+++ b/indoteknik_api/controllers/api_v1/user.py
@@ -171,7 +171,8 @@ class User(controller.Controller):
query = """
SELECT id, name, levenshtein(name::text, %s) AS distance
FROM res_partner
- WHERE levenshtein(name::text, %s) < 3
+ WHERE is_company = true AND active = true
+ AND levenshtein(name::text, %s) < 3
ORDER BY distance ASC
"""
params = (business_name, business_name)
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 580f43de..38c60f50 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -60,6 +60,7 @@
'views/website_brand_homepage.xml',
'views/website_categories_homepage.xml',
'views/website_categories_management.xml',
+ 'views/website_telegram.xml',
'views/website_categories_lob.xml',
'views/sales_target.xml',
'views/purchase_outstanding.xml',
@@ -150,6 +151,8 @@
'views/form_vendor_approval_multi_approve.xml',
'views/form_vendor_approval_multi_reject.xml',
'views/user_pengajuan_tempo.xml',
+ 'views/stock_backorder_confirmation_views.xml',
+ 'views/barcoding_product.xml',
'report/report.xml',
'report/report_banner_banner.xml',
'report/report_banner_banner2.xml',
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 4c1ef68c..ed9d69be 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -131,6 +131,7 @@ from . import account_tax
from . import approval_unreserve
from . import vendor_approval
from . import partner
+from . import website_telegram
from . import find_page
from . import user_pengajuan_tempo_line
from . import user_pengajuan_tempo
@@ -141,3 +142,6 @@ from . import vendor_sla
from . import stock_immediate_transfer
from . import coretax_fatur
from . import public_holiday
+from . import ir_actions_report
+from . import barcoding_product
+from . import account_payment_register
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index d62f19ae..b2ac47c2 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -63,6 +63,19 @@ class AccountMove(models.Model):
flag_delivery_amt = fields.Boolean(string="Flag Delivery Amount", compute='compute_flag_delivery_amt')
nomor_kwitansi = fields.Char(string="Nomor Kwitansi")
other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal')
+ other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes')
+ is_hr = fields.Boolean(string="Is HR?", default=False)
+
+ def _update_line_name_from_ref(self):
+ """Update all account.move.line name fields with ref from account.move"""
+ for move in self:
+ if move.move_type == 'entry' and move.ref and move.line_ids:
+ for line in move.line_ids:
+ line.name = move.ref
+
+ def compute_other_taxes(self):
+ for rec in self:
+ rec.other_taxes = rec.other_subtotal * 0.12
def compute_other_subtotal(self):
for rec in self:
@@ -102,6 +115,7 @@ class AccountMove(models.Model):
def create(self, vals):
vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0'
result = super(AccountMove, self).create(vals)
+ # result._update_line_name_from_ref()
return result
def compute_so_shipping_paid_by(self):
diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py
index a4b25109..7c95d4ef 100644
--- a/indoteknik_custom/models/account_move_line.py
+++ b/indoteknik_custom/models/account_move_line.py
@@ -7,6 +7,7 @@ class AccountMoveLine(models.Model):
cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre')
is_required = fields.Boolean(string='Is Required', compute='_compute_is_required')
analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account')
+ line_no = fields.Integer('No', default=0)
@api.onchange('account_id')
def _onchange_account_id(self):
@@ -22,3 +23,11 @@ class AccountMoveLine(models.Model):
else:
account.is_required = False
+ @api.model_create_multi
+ def create(self, vals_list):
+ for vals in vals_list:
+ if 'move_id' in vals:
+ move = self.env['account.move'].browse(vals['move_id'])
+ if move.move_type == 'entry' and move.is_hr == True:
+ vals['name'] = move.ref
+ return super().create(vals_list) \ No newline at end of file
diff --git a/indoteknik_custom/models/account_payment_register.py b/indoteknik_custom/models/account_payment_register.py
new file mode 100644
index 00000000..4ebb7e4e
--- /dev/null
+++ b/indoteknik_custom/models/account_payment_register.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+
+from odoo import models, fields, api, _
+from odoo.exceptions import UserError
+
+
+class AccountPaymentRegister(models.TransientModel):
+ _inherit = 'account.payment.register'
+ def _create_payment_vals_from_wizard(self):
+ payment_vals = {
+ 'date': self.payment_date,
+ 'amount': self.amount,
+ 'payment_type': self.payment_type,
+ 'partner_type': self.partner_type,
+ 'ref': self.communication,
+ 'journal_id': self.journal_id.id,
+ 'is_hr': True,
+ 'currency_id': self.currency_id.id,
+ 'partner_id': self.partner_id.id,
+ 'partner_bank_id': self.partner_bank_id.id,
+ 'payment_method_id': self.payment_method_id.id,
+ 'destination_account_id': self.line_ids[0].account_id.id
+ }
+
+ if not self.currency_id.is_zero(self.payment_difference) and self.payment_difference_handling == 'reconcile':
+ payment_vals['write_off_line_vals'] = {
+ 'name': self.writeoff_label,
+ 'amount': self.payment_difference,
+ 'account_id': self.writeoff_account_id.id,
+ }
+ return payment_vals
+
+ def _create_payment_vals_from_batch(self, batch_result):
+ batch_values = self._get_wizard_values_from_batch(batch_result)
+ return {
+ 'date': self.payment_date,
+ 'amount': batch_values['source_amount_currency'],
+ 'payment_type': batch_values['payment_type'],
+ 'partner_type': batch_values['partner_type'],
+ 'ref': self._get_batch_communication(batch_result),
+ 'journal_id': self.journal_id.id,
+ 'is_hr': True,
+ 'currency_id': batch_values['source_currency_id'],
+ 'partner_id': batch_values['partner_id'],
+ 'partner_bank_id': batch_result['key_values']['partner_bank_id'],
+ 'payment_method_id': self.payment_method_id.id,
+ 'destination_account_id': batch_result['lines'][0].account_id.id
+ }
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index 09d283eb..fbdf8dae 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -183,89 +183,94 @@ class AutomaticPurchase(models.Model):
def create_po_by_vendor(self, vendor_id):
current_time = datetime.now()
- if not self.apo_type =='reordering':
- name = "/PJ/"
- else:
- name = "/A/"
+ name = "/PJ/" if not self.apo_type == 'reordering' else "/A/"
PRODUCT_PER_PO = 20
-
auto_purchase_line = self.env['automatic.purchase.line']
- last_po = self.env['purchase.order'].search([
- ('partner_id', '=', vendor_id),
- ('state', '=', 'done'),
- ], order='id desc', limit=1)
-
- param_header = {
- 'partner_id': vendor_id,
- 'currency_id': 12,
- 'user_id': self.env.user.id,
- 'company_id': 1, # indoteknik dotcom gemilang
- 'picking_type_id': 28, # indoteknik bandengan receipts
- 'date_order': current_time,
- 'from_apo': True,
- 'note_description': 'Automatic PO'
- }
-
+ # Domain untuk semua baris dengan vendor_id tertentu
domain = [
('automatic_purchase_id', '=', self.id),
('partner_id', '=', vendor_id),
('qty_purchase', '>', 0)
]
- products_len = auto_purchase_line.search_count(domain)
- page = math.ceil(products_len / PRODUCT_PER_PO)
-
- # i start from zero (0)
- for i in range(page):
- new_po = self.env['purchase.order'].create([param_header])
- new_po.payment_term_id = new_po.partner_id.property_supplier_payment_term_id
- new_po.name = new_po.name + name + str(i + 1)
+ # Tambahkan domain khusus untuk brand_id 22 dan 564
+ special_brand_domain = domain + [('brand_id', 'in', [22, 564])]
+ regular_domain = domain + [('brand_id', 'not in', [22, 564])]
+
+ # Fungsi untuk membuat PO berdasarkan domain tertentu
+ def create_po_for_domain(domain, special_payment_term=False):
+ products_len = auto_purchase_line.search_count(domain)
+ page = math.ceil(products_len / PRODUCT_PER_PO)
+
+ for i in range(page):
+ # Buat PO baru
+ param_header = {
+ 'partner_id': vendor_id,
+ 'currency_id': 12,
+ 'user_id': self.env.user.id,
+ 'company_id': 1, # indoteknik dotcom gemilang
+ 'picking_type_id': 28, # indoteknik bandengan receipts
+ 'date_order': current_time,
+ 'from_apo': True,
+ 'note_description': 'Automatic PO'
+ }
- self.env['automatic.purchase.match'].create([{
- 'automatic_purchase_id': self.id,
- 'order_id': new_po.id
- }])
+ new_po = self.env['purchase.order'].create([param_header])
- lines = auto_purchase_line.search(
- domain,
- offset=i * PRODUCT_PER_PO,
- limit=PRODUCT_PER_PO
- )
+ # Set payment_term_id khusus jika diperlukan
+ if special_payment_term:
+ new_po.payment_term_id = 29
+ else:
+ new_po.payment_term_id = new_po.partner_id.property_supplier_payment_term_id
- lines = auto_purchase_line.search(
- domain,
- offset=i * PRODUCT_PER_PO,
- limit=PRODUCT_PER_PO
- )
+ new_po.name = new_po.name + name + str(i + 1)
+ self.env['automatic.purchase.match'].create([{
+ 'automatic_purchase_id': self.id,
+ 'order_id': new_po.id
+ }])
+
+ # Ambil baris sesuai halaman
+ lines = auto_purchase_line.search(
+ domain,
+ offset=i * PRODUCT_PER_PO,
+ limit=PRODUCT_PER_PO
+ )
+
+ for line in lines:
+ product = line.product_id
+ sales_match = self.env['automatic.purchase.sales.match'].search([
+ ('automatic_purchase_id', '=', self.id),
+ ('product_id', '=', product.id),
+ ])
+ param_line = {
+ 'order_id': new_po.id,
+ 'product_id': product.id,
+ 'product_qty': line.qty_purchase,
+ 'qty_available_store': product.qty_available_bandengan,
+ 'suggest': product._get_po_suggest(line.qty_purchase),
+ 'product_uom_qty': line.qty_purchase,
+ 'price_unit': line.last_price,
+ 'ending_price': line.last_price,
+ 'taxes_id': [line.taxes_id.id] if line.taxes_id else None,
+ 'so_line_id': sales_match[0].sale_line_id.id if sales_match else None,
+ 'so_id': sales_match[0].sale_id.id if sales_match else None
+ }
+ new_po_line = self.env['purchase.order.line'].create([param_line])
+ line.current_po_id = new_po.id
+ line.current_po_line_id = new_po_line.id
+
+ self.create_purchase_order_sales_match(new_po)
+
+ # Buat PO untuk special brand
+ if vendor_id == 23:
+ create_po_for_domain(special_brand_domain, special_payment_term=True)
+
+ # Buat PO untuk regular domain
+ create_po_for_domain(regular_domain, "")
- for line in lines:
- product = line.product_id
- sales_match = self.env['automatic.purchase.sales.match'].search([
- ('automatic_purchase_id', '=', self.id),
- ('product_id', '=', product.id),
- ])
- param_line = {
- 'order_id': new_po.id,
- 'product_id': product.id,
- 'product_qty': line.qty_purchase,
- 'qty_available_store': product.qty_available_bandengan,
- 'suggest': product._get_po_suggest(line.qty_purchase),
- 'product_uom_qty': line.qty_purchase,
- 'price_unit': line.last_price,
- 'ending_price': line.last_price,
- 'taxes_id': [line.taxes_id.id] if line.taxes_id else None,
- 'so_line_id': sales_match[0].sale_line_id.id if sales_match else None,
- 'so_id': sales_match[0].sale_id.id if sales_match else None
- }
- new_po_line = self.env['purchase.order.line'].create([param_line])
- line.current_po_id = new_po.id
- line.current_po_line_id = new_po_line.id
- # self.update_purchase_price_so_line(line)
-
- self.create_purchase_order_sales_match(new_po)
def update_purchase_price_so_line(self, apo):
sales_match = self.env['automatic.purchase.sales.match'].search([
diff --git a/indoteknik_custom/models/barcoding_product.py b/indoteknik_custom/models/barcoding_product.py
new file mode 100644
index 00000000..e1b8f41f
--- /dev/null
+++ b/indoteknik_custom/models/barcoding_product.py
@@ -0,0 +1,45 @@
+from odoo import models, api, fields
+from odoo.exceptions import AccessError, UserError, ValidationError
+from datetime import timedelta, date, datetime
+import logging
+
+_logger = logging.getLogger(__name__)
+
+class BarcodingProduct(models.Model):
+ _name = "barcoding.product"
+ _description = "Barcoding Product"
+
+ barcoding_product_line = fields.One2many('barcoding.product.line', 'barcoding_product_id', string='Barcoding Product Lines', auto_join=True)
+ product_id = fields.Many2one('product.product', string="Product", tracking=3)
+ quantity = fields.Float(string="Quantity", tracking=3)
+ type = fields.Selection([('print', 'Print Barcode'), ('barcoding', 'Add Barcode To Product')], string='Type', default='print')
+ barcode = fields.Char(string="Barcode")
+
+ @api.constrains('barcode')
+ def _send_barcode_to_product(self):
+ for record in self:
+ if record.barcode and not record.product_id.barcode:
+ record.product_id.barcode = record.barcode
+
+ @api.onchange('product_id', 'quantity')
+ def _onchange_product_or_quantity(self):
+ """Update barcoding_product_line based on product_id and quantity"""
+ if self.product_id and self.quantity > 0:
+ # Clear existing lines
+ self.barcoding_product_line = [(5, 0, 0)]
+
+ # Add a new line with the current product and quantity
+ self.barcoding_product_line = [(0, 0, {
+ 'product_id': self.product_id.id,
+ 'barcoding_product_id': self.id,
+ }) for _ in range(int(self.quantity))]
+
+
+class BarcodingProductLine(models.Model):
+ _name = 'barcoding.product.line'
+ _description = 'Barcoding Product Line'
+ _order = 'barcoding_product_id, id'
+
+ barcoding_product_id = fields.Many2one('barcoding.product', string='Barcoding Product Ref', required=True, ondelete='cascade', index=True, copy=False)
+ product_id = fields.Many2one('product.product', string="Product")
+ qr_code_variant = fields.Binary("QR Code Variant", related='product_id.qr_code_variant') \ No newline at end of file
diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py
index ae6dd2ae..706a4f44 100644
--- a/indoteknik_custom/models/coretax_fatur.py
+++ b/indoteknik_custom/models/coretax_fatur.py
@@ -77,7 +77,7 @@ class CoretaxFaktur(models.Model):
otherTaxBase = round(line.price_subtotal * (11/12)) if line.price_subtotal else 0
good_service = ET.SubElement(list_of_good_service, 'GoodService')
ET.SubElement(good_service, 'Opt').text = 'A'
- ET.SubElement(good_service, 'Code')
+ ET.SubElement(good_service, 'Code').text = '000000'
ET.SubElement(good_service, 'Name').text = line.name
ET.SubElement(good_service, 'Unit').text = 'UM.0018'
ET.SubElement(good_service, 'Price').text = str(round(line.price_subtotal/line.quantity, 2)) if line.price_subtotal else '0'
diff --git a/indoteknik_custom/models/invoice_reklas.py b/indoteknik_custom/models/invoice_reklas.py
index 30da02d1..f5bb5a25 100644
--- a/indoteknik_custom/models/invoice_reklas.py
+++ b/indoteknik_custom/models/invoice_reklas.py
@@ -49,7 +49,7 @@ class InvoiceReklas(models.TransientModel):
if self.reklas_type == 'penjualan':
parameter_debit = {
'move_id': account_move.id,
- 'account_id': 449, # uang muka penjualan
+ 'account_id': 668, # penerimaan belum alokasi
'partner_id': invoice.partner_id.id,
'currency_id': 12,
'debit': self.pay_amt,
@@ -77,7 +77,7 @@ class InvoiceReklas(models.TransientModel):
}
parameter_credit = {
'move_id': account_move.id,
- 'account_id': 401,
+ 'account_id': 669,
'partner_id': invoice.partner_id.id,
'currency_id': 12,
'debit': 0,
diff --git a/indoteknik_custom/models/invoice_reklas_penjualan.py b/indoteknik_custom/models/invoice_reklas_penjualan.py
index 5027c8af..80c3ed43 100644
--- a/indoteknik_custom/models/invoice_reklas_penjualan.py
+++ b/indoteknik_custom/models/invoice_reklas_penjualan.py
@@ -33,7 +33,7 @@ class InvoiceReklasPenjualan(models.TransientModel):
parameter_debit = {
'move_id': account_move.id,
- 'account_id': 449, # uang muka penjualan
+ 'account_id': 668, # uang muka penjualan
'partner_id': invoice.partner_id.id,
'currency_id': 12,
'debit': invoice.pay_amt,
diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py
new file mode 100644
index 00000000..83636945
--- /dev/null
+++ b/indoteknik_custom/models/ir_actions_report.py
@@ -0,0 +1,51 @@
+from odoo import models
+from odoo.http import request
+import requests
+class IrActionsReport(models.Model):
+ _inherit = 'ir.actions.report'
+
+ def _get_readable_fields(self):
+ if self.env.context.get('active_model') == 'sale.order':
+ self.send_to_telegram()
+ return super()._get_readable_fields()
+
+ def send_to_telegram(self):
+ so_id = self.env.context.get('active_id')
+ if so_id:
+ sale_order = self.env['sale.order'].browse(so_id)
+ if sale_order.amount_total < 50000000:
+ return
+ # ci_vita 7751529082:AAE9XsZa_Pj2Pi2IN1grX98WkwTaIt32pbI & 5081411103
+ # iman 7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY & 6592318498
+ bot_name_iman = '7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY'
+ chat_id_iman = '-1002493002821'
+ bot_name_vita = '7751529082:AAE9XsZa_Pj2Pi2IN1grX98WkwTaIt32pbI'
+ chat_id_vita = '5081411103'
+ apiURL = f'https://api.telegram.org/bot{bot_name_iman}/sendMessage'
+ try:
+ requests.post(apiURL, json={'chat_id': chat_id_iman, 'text': sale_order.name + " senilai Rp" + self.format_currency(sale_order.amount_total) + ' untuk customer ' + sale_order.partner_id.name + ' telah dibuat oleh sales ' +sale_order.user_id.name})
+ except Exception as e:
+ print(e)
+
+ # id ci vita 79160
+ # id iman 112718
+ # partner = request.env['res.partner'].search([('id', '=', 112718)], limit=1)
+ # telegram_data = {
+ # 'tittle': sale_order.name,
+ # 'about': sale_order.name,
+ # 'user_id': partner,
+ # 'id_data': sale_order.id,
+ # 'username': '@' + sale_order.name.replace('/', '')
+ # }
+ # channel_data = self.env['website.telegram'].search([('tittle', '=', sale_order.name)])
+ # if channel_data:
+ # channel_data.send_to_telegram(sale_order.name + " Telah di print Oleh " + self.env.user.name)
+ # for pick in self:
+ # self._check_telegram(pick)
+ # else:
+ # telegram = self.env['website.telegram'].create(telegram_data)
+ # telegram.create_channel(sale_order.name + " Telah di print Oleh " + self.env.user.name)
+
+ def format_currency(self, number):
+ number = int(number)
+ return "{:,}".format(number).replace(',', '.') \ No newline at end of file
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 8c57774e..600dd90e 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -67,6 +67,25 @@ class ProductTemplate(models.Model):
print_barcode = fields.Boolean(string='Print Barcode', default=True)
# qr_code = fields.Binary("QR Code", compute='_compute_qr_code')
+ @api.model
+ def create(self, vals):
+ group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ active_model = self.env.context.get('active_model')
+ if self.env.user.id not in users_in_group.mapped('id') and active_model == None:
+ raise UserError('Hanya MD yang bisa membuat Product')
+ result = super(ProductTemplate, self).create(vals)
+ return result
+
+ # def write(self, values):
+ # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ # active_model = self.env.context.get('active_model')
+ # if self.env.user.id not in users_in_group.mapped('id') and active_model == None:
+ # raise UserError('Hanya MD yang bisa mengedit Product')
+ # result = super(ProductTemplate, self).write(values)
+ # return result
+
# def _compute_qr_code(self):
# for rec in self.product_variant_ids:
# qr = qrcode.QRCode(
@@ -415,6 +434,24 @@ class ProductProduct(models.Model):
'product_variant_id': product_variant.id,
})
new_sla_record.generate_product_sla()
+ @api.model
+ def create(self, vals):
+ group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ active_model = self.env.context.get('active_model')
+ users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ if self.env.user.id not in users_in_group.mapped('id') and active_model == None:
+ raise UserError('Hanya MD yang bisa membuat Product')
+ result = super(ProductProduct, self).create(vals)
+ return result
+
+ # def write(self, values):
+ # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ # active_model = self.env.context.get('active_model')
+ # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ # if self.env.user.id not in users_in_group.mapped('id') and active_model == None:
+ # raise UserError('Hanya MD yang bisa mengedit Product')
+ # result = super(ProductProduct, self).write(values)
+ # return result
def _compute_qr_code_variant(self):
for rec in self:
@@ -429,7 +466,7 @@ class ProductProduct(models.Model):
box_size=5,
border=4,
)
- qr.add_data(rec.default_code)
+ qr.add_data(rec.barcode if rec.barcode else rec.default_code)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index d487ada3..54d771ba 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -86,6 +86,7 @@ class PurchaseOrder(models.Model):
total_cost_service = fields.Float(string='Total Cost Service')
total_delivery_amt = fields.Float(string='Total Delivery Amt')
store_name = fields.Char(string='Nama Toko')
+ purchase_order_count = fields.Integer('Purchase Order Count', related='partner_id.purchase_order_count')
@api.onchange('total_cost_service')
def _onchange_total_cost_service(self):
@@ -178,7 +179,7 @@ class PurchaseOrder(models.Model):
'move_id': bills.id,
'product_id': product_dp.id, # product down payment
'name': '[IT.121456] Down Payment', # product down payment
- 'account_id': 401, # Uang Muka persediaan barang dagang
+ 'account_id': 669, # Uang Muka persediaan barang dagang
# 'price_unit': move_line.price_unit,
'quantity': -1,
'product_uom_id': 1,
@@ -240,7 +241,7 @@ class PurchaseOrder(models.Model):
data_line_bills = {
'move_id': bills.id,
'product_id': product_dp.id, # product down payment
- 'account_id': 401, # Uang Muka persediaan barang dagang
+ 'account_id': 669, # Uang Muka persediaan barang dagang
'quantity': 1,
'product_uom_id': 1,
'tax_ids': [line[0].taxes_id.id for line in self.order_line],
diff --git a/indoteknik_custom/models/purchase_order_multi_uangmuka.py b/indoteknik_custom/models/purchase_order_multi_uangmuka.py
index dd63e698..0570efd9 100644
--- a/indoteknik_custom/models/purchase_order_multi_uangmuka.py
+++ b/indoteknik_custom/models/purchase_order_multi_uangmuka.py
@@ -76,7 +76,7 @@ class PurchaseOrderMultiUangmuka(models.TransientModel):
param_debit = {
'move_id': account_move.id,
- 'account_id': 401, # uang muka persediaan barang dagang
+ 'account_id': 669, # uang muka persediaan barang dagang
'partner_id': partner_id,
'currency_id': 12,
'debit': order.amount_total,
diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py
index 4efb0cd4..902bc34b 100644
--- a/indoteknik_custom/models/purchasing_job.py
+++ b/indoteknik_custom/models/purchasing_job.py
@@ -183,6 +183,7 @@ class OutstandingSales(models.Model):
join product_template pt on pt.id = pp.product_tmpl_id
left join x_manufactures xm on xm.id = pt.x_manufacture
where sp.state in ('draft', 'waiting', 'confirmed', 'assigned')
+ and sm.state in ('draft', 'waiting', 'confirmed', 'partially_available')
and sp.name like '%OUT%'
)
""")
diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py
index a1b6299c..17119c12 100644
--- a/indoteknik_custom/models/report_logbook_sj.py
+++ b/indoteknik_custom/models/report_logbook_sj.py
@@ -29,6 +29,8 @@ class ReportLogbookSJ(models.Model):
string='Status',
tracking=True,
)
+
+ sj_number = fields.Char(string='Picking', related='report_logbook_sj_line.name')
count_line = fields.Char(string='Count Line', compute='_compute_count_line')
diff --git a/indoteknik_custom/models/report_stock_forecasted.py b/indoteknik_custom/models/report_stock_forecasted.py
index c9d54a15..37082869 100644
--- a/indoteknik_custom/models/report_stock_forecasted.py
+++ b/indoteknik_custom/models/report_stock_forecasted.py
@@ -1,51 +1,4 @@
from odoo import api, models
class ReplenishmentReport(models.AbstractModel):
- _inherit = 'report.stock.report_product_product_replenishment'
-
- @api.model
- def _get_report_lines(self, product_template_ids, product_variant_ids, wh_location_ids):
- lines = super(ReplenishmentReport, self)._get_report_lines(product_template_ids, product_variant_ids, wh_location_ids)
- # result_dict = {}
- #
- # for line in lines:
- # document_out = line.get('document_out')
- #
- # if document_out and "SO/" in document_out.name:
- # order_id = document_out.id
- # if document_out == False:
- # continue
- # product_id = line.get('product', {}).get('id')
- # query = [('product_id', '=', product_id)]
- #
- # if order_id:
- # result = self._calculate_result(line)
- # quantity = line.get('quantity', 0)
- # result_dict.setdefault(order_id, []).append((result, quantity))
- #
- # for order_id, results in result_dict.items():
- # sales_order = self.env['sale.order'].browse(order_id)
- #
- # for result, quantity in results:
- # self.env['sales.order.fullfillment'].create({
- # 'sales_order_id': sales_order.id,
- # 'product_id': product_id,
- # 'reserved_from': result,
- # 'qty_fullfillment': quantity,
- # })
- return lines
-
- def _calculate_result(self, line):
- if line['document_in']:
- return str(line["document_in"].name)
- elif line['reservation'] and not line['document_in']:
- return 'Reserved from stock'
- elif line['replenishment_filled']:
- if line['document_out']:
- return 'Inventory On Hand'
- else:
- return 'Free Stock'
- else:
- return 'Unfulfilled'
-
-
+ _inherit = 'report.stock.report_product_product_replenishment' \ No newline at end of file
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index f081e274..7e574a72 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -147,6 +147,7 @@ class ResPartner(models.Model):
"customer is crossed blocking amount."
"Set its value to 0.00 to disable "
"this feature", tracking=3)
+ telegram_id = fields.Char(string="Telegram")
@api.model
def _default_payment_term(self):
@@ -182,6 +183,19 @@ class ResPartner(models.Model):
# # raise UserError('You name it')
#
return res
+
+ @api.constrains('name')
+ def _check_duplicate_name(self):
+ for record in self:
+ if record.name:
+ # Mencari partner lain yang memiliki nama sama (case-insensitive)
+ existing_partner = self.env['res.partner'].search([
+ ('id', '!=', record.id), # Hindari mencocokkan diri sendiri
+ ('name', '=', record.name) # Case-insensitive search
+ ], limit=1)
+
+ if existing_partner:
+ raise ValidationError(f"Nama '{record.name}' sudah digunakan oleh partner lain!")
def write(self, vals):
# Fungsi rekursif untuk meng-update semua child, termasuk child dari child
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index c6f8adc4..d0b57a3d 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -28,11 +28,11 @@ class SaleOrder(models.Model):
shipping_cost_covered = fields.Selection([
('indoteknik', 'Indoteknik'),
('customer', 'Customer')
- ], string='Shipping Covered by', help='Siapa yang menanggung biaya ekspedisi?', copy=False)
+ ], string='Shipping Covered by', help='Siapa yang menanggung biaya ekspedisi?', copy=False, tracking=3)
shipping_paid_by = fields.Selection([
('indoteknik', 'Indoteknik'),
('customer', 'Customer')
- ], string='Shipping Paid by', help='Siapa yang talangin dulu Biaya ekspedisi-nya?', copy=False)
+ ], string='Shipping Paid by', help='Siapa yang talangin dulu Biaya ekspedisi-nya?', copy=False, tracking=3)
sales_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)])
have_outstanding_invoice = fields.Boolean('Have Outstanding Invoice', compute='_have_outstanding_invoice')
have_outstanding_picking = fields.Boolean('Have Outstanding Picking', compute='_have_outstanding_picking')
@@ -155,6 +155,15 @@ class SaleOrder(models.Model):
copy=False,
store=True
)
+ shipping_method_picking = fields.Char(string='Shipping Method Picking', compute='_compute_shipping_method_picking')
+
+ def _compute_shipping_method_picking(self):
+ for order in self:
+ if order.picking_ids:
+ carrier_names = order.picking_ids.mapped('carrier_id.name')
+ order.shipping_method_picking = ', '.join(filter(None, carrier_names))
+ else:
+ order.shipping_method_picking = False
@api.onchange('payment_status')
def _is_continue_transaction(self):
@@ -584,22 +593,22 @@ class SaleOrder(models.Model):
redirect_url = json.loads(lookup_json)['redirect_url']
self.payment_link_midtrans = str(redirect_url)
- # Generate QR code
- qr = qrcode.QRCode(
- version=1,
- error_correction=qrcode.constants.ERROR_CORRECT_L,
- box_size=10,
- border=4,
- )
- qr.add_data(redirect_url)
- qr.make(fit=True)
- img = qr.make_image(fill_color="black", back_color="white")
+ if 'redirect_url' in response:
+ qr = qrcode.QRCode(
+ version=1,
+ error_correction=qrcode.constants.ERROR_CORRECT_L,
+ box_size=10,
+ border=4,
+ )
+ qr.add_data(redirect_url)
+ qr.make(fit=True)
+ img = qr.make_image(fill_color="black", back_color="white")
- buffer = BytesIO()
- img.save(buffer, format="PNG")
- qr_code_img = base64.b64encode(buffer.getvalue()).decode()
+ buffer = BytesIO()
+ img.save(buffer, format="PNG")
+ qr_code_img = base64.b64encode(buffer.getvalue()).decode()
- self.payment_qr_code = qr_code_img
+ self.payment_qr_code = qr_code_img
@api.model
def _generate_so_access_token(self, limit=50):
@@ -804,6 +813,7 @@ class SaleOrder(models.Model):
def sale_order_approve(self):
self.check_credit_limit()
+ self.check_limit_so_to_invoice()
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()
@@ -862,6 +872,7 @@ class SaleOrder(models.Model):
return self._create_approval_notification('Pimpinan')
elif order._requires_approval_margin_manager():
self.check_credit_limit()
+ self.check_limit_so_to_invoice()
order.approval_status = 'pengajuan1'
return self._create_approval_notification('Sales Manager')
@@ -968,6 +979,29 @@ class SaleOrder(models.Model):
raise UserError(_("%s is in Blocking Stage, Remaining credit limit is %s, from %s and outstanding %s")
% (rec.partner_id.name, remaining_credit_limit, block_stage, outstanding_amount))
+ def check_limit_so_to_invoice(self):
+ for rec in self:
+ # Ambil jumlah outstanding_amount dan rec.amount_total sebagai current_total
+ outstanding_amount = rec.outstanding_amount
+ current_total = rec.amount_total + outstanding_amount
+
+ # Ambil blocking stage dari partner
+ block_stage = rec.partner_id.parent_id.blocking_stage if rec.partner_id.parent_id else rec.partner_id.blocking_stage or 0
+ is_cbd = rec.partner_id.parent_id.property_payment_term_id.id == 26 if rec.partner_id.parent_id else rec.partner_id.property_payment_term_id.id == 26 or False
+
+ # Ambil jumlah nilai dari SO yang invoice_status masih 'to invoice'
+ so_to_invoice = 0
+ for sale in rec.partner_id.sale_order_ids:
+ if sale.invoice_status == 'to invoice':
+ so_to_invoice = so_to_invoice + sale.amount_total
+ # Hitung remaining credit limit
+ remaining_credit_limit = block_stage - current_total - so_to_invoice
+
+ # Validasi limit
+ if remaining_credit_limit <= 0 and block_stage > 0 and not is_cbd:
+ raise UserError(_("The credit limit for %s will exceed the Blocking Stage if the Sale Order is confirmed. The remaining credit limit is %s, from %s and the outstanding amount is %s.")
+ % (rec.partner_id.name, block_stage - current_total, block_stage, outstanding_amount))
+
def validate_different_vendor(self):
if self.vendor_approval_id.filtered(lambda v: v.state == 'draft'):
draft_names = ", ".join(self.vendor_approval_id.filtered(lambda v: v.state == 'draft').mapped('number'))
@@ -1016,6 +1050,8 @@ class SaleOrder(models.Model):
def action_confirm(self):
for order in self:
+ order.check_credit_limit()
+ order.check_limit_so_to_invoice()
if self.validate_different_vendor() and not self.vendor_approval:
return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor')
@@ -1078,9 +1114,14 @@ class SaleOrder(models.Model):
if self.have_outstanding_invoice:
raise UserError("Invoice harus di Cancel dahulu")
+
+ disallow_states = ['draft', 'waiting', 'confirmed', 'assigned']
+ for picking in self.picking_ids:
+ if picking.state in disallow_states:
+ raise UserError("DO yang draft, waiting, confirmed, atau assigned harus di-cancel oleh Logistik")
for line in self.order_line:
if line.qty_delivered > 0:
- raise UserError("DO harus di-cancel terlebih dahulu.")
+ raise UserError("DO yang done harus di-Return oleh Logistik")
if not self.web_approval:
self.web_approval = 'company'
@@ -1124,7 +1165,7 @@ class SaleOrder(models.Model):
return False
def _requires_approval_margin_leader(self):
- return self.total_percent_margin <= 13 and not self.env.user.is_leader
+ return self.total_percent_margin < 15 and not self.env.user.is_leader
def _requires_approval_margin_manager(self):
return self.total_percent_margin <= 20 and not self.env.user.is_leader and not self.env.user.is_sales_manager
diff --git a/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py b/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py
index f9120290..96c2f676 100644
--- a/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py
+++ b/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py
@@ -68,7 +68,7 @@ class PurchaseOrderMultiUangmukaPenjualan(models.TransientModel):
param_credit = {
'move_id': account_move.id,
- 'account_id': 449, # uang muka penjualan
+ 'account_id': 668, # penerimaan belum alokasi
'partner_id': partner_id,
'currency_id': 12,
'debit': 0,
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 87e8370f..8afff6e3 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -76,8 +76,11 @@ class ProductTemplate(models.Model):
('product_id', 'in', template.product_variant_ids.ids),
('location_id', 'in', target_locations),
])
-
- is_in_bu = any(quant.available_quantity > 0 for quant in stock_quant)
+ is_in_bu = False
+ for quant in stock_quant:
+ if quant.product_id.qty_free_bandengan > 0:
+ is_in_bu = True
+ break
cleaned_desc = BeautifulSoup(template.website_description or '', "html.parser").get_text()
website_description = template.website_description if cleaned_desc else ''
diff --git a/indoteknik_custom/models/stock_immediate_transfer.py b/indoteknik_custom/models/stock_immediate_transfer.py
index 4be0dff2..21210619 100644
--- a/indoteknik_custom/models/stock_immediate_transfer.py
+++ b/indoteknik_custom/models/stock_immediate_transfer.py
@@ -16,7 +16,6 @@ class StockImmediateTransfer(models.TransientModel):
pickings_not_to_do |= line.picking_id
for picking in pickings_to_do:
- picking.send_mail_bills()
# If still in draft => confirm and assign
if picking.state == 'draft':
picking.action_confirm()
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index e1d4e74c..6b631713 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -12,9 +12,13 @@ class StockMove(models.Model):
default=lambda self: self.product_id.print_barcode,
)
qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant')
+ barcode = fields.Char(string='Barcode', related='product_id.barcode')
def _compute_qr_code_variant(self):
for rec in self:
+ if rec.picking_id.picking_type_code == 'outgoing' and rec.picking_id and rec.picking_id.origin and rec.picking_id.origin.startswith('SO/'):
+ rec.qr_code_variant = rec.product_id.qr_code_variant
+ rec.print_barcode = True
if rec.print_barcode and rec.print_barcode == True and rec.product_id and rec.product_id.qr_code_variant:
rec.qr_code_variant = rec.product_id.qr_code_variant
else:
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 49c17788..1690a4ed 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -23,7 +23,8 @@ _biteship_api_key = "biteship_test.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1l
class StockPicking(models.Model):
_inherit = 'stock.picking'
- # check_product_lines = fields.One2many('check.product', 'picking_id', string='Check Product', auto_join=True)
+ check_product_lines = fields.One2many('check.product', 'picking_id', string='Check Product', auto_join=True)
+ barcode_product_lines = fields.One2many('barcode.product', 'picking_id', string='Barcode Product', auto_join=True)
is_internal_use = fields.Boolean('Internal Use', help='flag which is internal use or not')
account_id = fields.Many2one('account.account', string='Account')
efaktur_id = fields.Many2one('vit.efaktur', string='Faktur Pajak')
@@ -216,7 +217,8 @@ class StockPicking(models.Model):
pickings = self.env['stock.picking'].search([
('picking_type_code', '=', 'outgoing'),
('state', '=', 'done'),
- ('carrier_id', '=', 9)
+ ('carrier_id', '=', 9),
+ ('lalamove_order_id', '!=', False)
])
for picking in pickings:
try:
@@ -524,18 +526,52 @@ class StockPicking(models.Model):
def check_state_reserve(self):
pickings = self.search([
('state', 'not in', ['cancel', 'draft', 'done']),
+ ('picking_type_code', '=', 'outgoing'),
+ ('name', 'ilike', 'BU/OUT/'),
+ ])
+
+ count = self.search_count([
+ ('state', 'not in', ['cancel', 'draft', 'done']),
('picking_type_code', '=', 'outgoing')
])
for picking in pickings:
- fullfillments = self.env['sales.order.fullfillment'].search([
- ('sales_order_id', '=', picking.sale_id.id)
+ fullfillments = self.env['sales.order.fulfillment.v2'].search([
+ ('sale_order_id', '=', picking.sale_id.id)
])
picking.state_reserve = 'ready'
picking.date_reserved = picking.date_reserved or datetime.datetime.utcnow()
- if any(rec.reserved_from not in ['Inventory On Hand', 'Reserved from stock', 'Free Stock'] for rec in fullfillments):
+ if any(rec.so_qty != rec.reserved_stock_qty for rec in fullfillments):
+ picking.state_reserve = 'waiting'
+ picking.date_reserved = ''
+
+ self.check_state_reserve_backorder()
+
+ def check_state_reserve_backorder(self):
+ pickings = self.search([
+ ('backorder_id', '!=', False),
+ ('name', 'ilike', 'BU/OUT/'),
+ ('picking_type_code', '=', 'outgoing'),
+ ('state', 'not in', ['cancel', 'draft', 'done'])
+ ])
+
+ count = self.search_count([
+ ('backorder_id', '!=', False),
+ ('picking_type_code', '=', 'outgoing'),
+ ('state', 'not in', ['cancel', 'draft', 'done'])
+ ])
+
+ for picking in pickings:
+ fullfillments = self.env['sales.order.fulfillment.v2'].search([
+ ('sale_order_id', '=', picking.sale_id.id)
+ ])
+
+ picking.state_reserve = 'ready'
+ picking.date_reserved = picking.date_reserved or datetime.datetime.utcnow()
+
+ if any(rec.so_qty != rec.reserved_stock_qty for rec in fullfillments):
picking.state_reserve = 'waiting'
picking.date_reserved = ''
@@ -867,8 +903,26 @@ class StockPicking(models.Model):
self.calculate_line_no()
self.date_done = datetime.datetime.utcnow()
self.state_reserve = 'done'
+ self.send_mail_bills()
return res
-
+
+
+ def check_qty_done_stock(self):
+ for line in self.move_line_ids_without_package:
+ def check_qty_per_inventory(self, product, location):
+ quant = self.env['stock.quant'].search([
+ ('product_id', '=', product.id),
+ ('location_id', '=', location.id),
+ ])
+
+ if quant:
+ return quant.quantity
+
+ return 0
+
+ qty_onhand = check_qty_per_inventory(self, line.product_id, line.location_id)
+ if line.qty_done > qty_onhand:
+ raise UserError('Quantity Done melebihi Quantity Onhand')
def send_mail_bills(self):
if self.picking_type_code == 'incoming' and self.purchase_id:
@@ -933,10 +987,39 @@ class StockPicking(models.Model):
@api.model
def create(self, vals):
self._use_faktur(vals)
+ if vals.get('picking_type_code') == 'incoming' and vals.get('location_dest_id') == 58:
+ if 'name' in vals and vals['name'].startswith('BU/IN/'):
+ vals['name'] = vals['name'].replace('BU/IN/', 'BU/INPUT/', 1)
+
+ if vals.get('picking_type_code') == 'internal' and vals.get('location_id') == 58:
+ if 'name' in vals and vals['name'].startswith('BU/INT'):
+ new_name = vals['name'].replace('BU/INT', 'BU/IN', 1)
+ # Periksa apakah nama sudah ada
+ if self.env['stock.picking'].search_count([('name', '=', new_name), ('company_id', '=', vals.get('company_id'))]) > 0:
+ new_name = f"{new_name}-DUP"
+ vals['name'] = new_name
return super(StockPicking, self).create(vals)
def write(self, vals):
self._use_faktur(vals)
+ for picking in self:
+ # Periksa apakah kondisi terpenuhi saat data diubah
+ if (vals.get('picking_type_code', picking.picking_type_code) == 'incoming' and
+ vals.get('location_dest_id', picking.location_dest_id.id) == 58):
+ if 'name' in vals or picking.name.startswith('BU/IN/'):
+ name_to_modify = vals.get('name', picking.name)
+ if name_to_modify.startswith('BU/IN/'):
+ vals['name'] = name_to_modify.replace('BU/IN/', 'BU/INPUT/', 1)
+
+ if (vals.get('picking_type_code', picking.picking_type_code) == 'internal' and
+ vals.get('location_id', picking.location_id.id) == 58):
+ name_to_modify = vals.get('name', picking.name)
+ if name_to_modify.startswith('BU/INT'):
+ new_name = name_to_modify.replace('BU/INT', 'BU/IN', 1)
+ # Periksa apakah nama sudah ada
+ if self.env['stock.picking'].search_count([('name', '=', new_name), ('company_id', '=', picking.company_id.id)]) > 0:
+ new_name = f"{new_name}-DUP"
+ vals['name'] = new_name
return super(StockPicking, self).write(vals)
def _use_faktur(self, vals):
@@ -1138,48 +1221,165 @@ class StockPicking(models.Model):
return f'{formatted_fastest_eta} - {formatted_longest_eta}'
-# class CheckProduct(models.Model):
-# _name = 'check.product'
-# _description = 'Check Product'
-# _order = 'picking_id, id'
-
-# picking_id = fields.Many2one('stock.picking', string='Picking Reference', required=True, ondelete='cascade', index=True, copy=False)
-# product_id = fields.Many2one('product.product', string='Product')
-
-
-# @api.constrains('product_id')
-# def check_product_validity(self):
-# """
-# Validate if the product exists in the related stock.picking's move_ids_without_package
-# and ensure that the product's quantity does not exceed the available product_uom_qty.
-# """
-# for record in self:
-# if not record.picking_id or not record.product_id:
-# continue
-
-# # Filter move lines in the related picking for the selected product
-# moves = record.picking_id.move_ids_without_package.filtered(
-# lambda move: move.product_id.id == record.product_id.id
-# )
-
-# if not moves:
-# raise UserError((
-# "The product '%s' is not available in the related stock picking's moves. "
-# "Please check and try again."
-# ) % record.product_id.display_name)
-
-# # Calculate the total entries for the product in check.product for the same picking
-# product_entries_count = self.search_count([
-# ('picking_id', '=', record.picking_id.id),
-# ('product_id', '=', record.product_id.id)
-# ])
-
-# # Sum the product_uom_qty for all relevant moves
-# total_qty_in_moves = sum(moves.mapped('product_uom_qty'))
-
-# # Compare the count of entries against the available quantity
-# if product_entries_count > total_qty_in_moves:
-# raise UserError((
-# "The product '%s' exceeds the allowable quantity (%s) in the related stock picking's moves. "
-# "You can only add it %s times."
-# ) % (record.product_id.display_name, total_qty_in_moves, total_qty_in_moves))
+class CheckProduct(models.Model):
+ _name = 'check.product'
+ _description = 'Check Product'
+ _order = 'picking_id, id'
+
+ picking_id = fields.Many2one(
+ 'stock.picking',
+ string='Picking Reference',
+ required=True,
+ ondelete='cascade',
+ index=True,
+ copy=False,
+ )
+ product_id = fields.Many2one('product.product', string='Product', required=True)
+ quantity = fields.Float(string='Quantity', default=1.0, required=True)
+ status = fields.Char(string='Status', compute='_compute_status')
+
+ @api.depends('quantity')
+ def _compute_status(self):
+ for record in self:
+ moves = record.picking_id.move_ids_without_package.filtered(
+ lambda move: move.product_id.id == record.product_id.id
+ )
+ total_qty_in_moves = sum(moves.mapped('product_uom_qty'))
+
+ if record.quantity < total_qty_in_moves:
+ record.status = 'Pending'
+ else:
+ record.status = 'Done'
+
+
+ def create(self, vals):
+ # Create the record
+ record = super(CheckProduct, self).create(vals)
+ # Ensure uniqueness after creation
+ if not self.env.context.get('skip_consolidate'):
+ record.with_context(skip_consolidate=True)._consolidate_duplicate_lines()
+ return record
+
+ def write(self, vals):
+ # Write changes to the record
+ result = super(CheckProduct, self).write(vals)
+ # Ensure uniqueness after writing
+ if not self.env.context.get('skip_consolidate'):
+ self.with_context(skip_consolidate=True)._consolidate_duplicate_lines()
+ return result
+
+ def _sync_check_product_to_moves(self, picking):
+ """
+ Sinkronisasi quantity_done di move_ids_without_package
+ dengan total quantity dari check.product berdasarkan product_id.
+ """
+ for product_id in picking.check_product_lines.mapped('product_id'):
+ # Totalkan quantity dari semua baris check.product untuk product_id ini
+ total_quantity = sum(
+ line.quantity for line in picking.check_product_lines.filtered(lambda line: line.product_id == product_id)
+ )
+ # Update quantity_done di move yang relevan
+ moves = picking.move_ids_without_package.filtered(lambda move: move.product_id == product_id)
+ for move in moves:
+ move.quantity_done = total_quantity
+
+ def _consolidate_duplicate_lines(self):
+ """
+ Consolidate duplicate lines with the same product_id under the same picking_id
+ and sync the total quantity to related moves.
+ """
+ for picking in self.mapped('picking_id'):
+ lines_to_remove = self.env['check.product'] # Recordset untuk menyimpan baris yang akan dihapus
+ product_lines = picking.check_product_lines.filtered(lambda line: line.product_id)
+
+ # Group lines by product_id
+ product_groups = {}
+ for line in product_lines:
+ product_groups.setdefault(line.product_id.id, []).append(line)
+
+ for product_id, lines in product_groups.items():
+ if len(lines) > 1:
+ # Consolidate duplicate lines
+ first_line = lines[0]
+ total_quantity = sum(line.quantity for line in lines)
+
+ # Update the first line's quantity
+ first_line.with_context(skip_consolidate=True).write({'quantity': total_quantity})
+
+ # Add the remaining lines to the lines_to_remove recordset
+ lines_to_remove |= self.env['check.product'].browse([line.id for line in lines[1:]])
+
+ # Perform unlink after consolidation
+ if lines_to_remove:
+ lines_to_remove.unlink()
+
+ # Sync total quantities to moves
+ self._sync_check_product_to_moves(picking)
+
+ @api.onchange('product_id', 'quantity')
+ def check_product_validity(self):
+ for record in self:
+ if not record.picking_id or not record.product_id:
+ continue
+
+ # Filter moves related to the selected product
+ moves = record.picking_id.move_ids_without_package.filtered(
+ lambda move: move.product_id.id == record.product_id.id
+ )
+
+ if not moves:
+ raise UserError((
+ "The product '%s' tidak ada di operations. "
+ ) % record.product_id.display_name)
+
+ total_qty_in_moves = sum(moves.mapped('product_uom_qty'))
+
+ # Find existing lines for the same product, excluding the current line
+ existing_lines = record.picking_id.check_product_lines.filtered(
+ lambda line: line.product_id == record.product_id and line.id != record.id
+ )
+
+ if existing_lines:
+ # Get the first existing line
+ first_line = existing_lines[0]
+
+ # Calculate the total quantity after addition
+ total_quantity = sum(existing_lines.mapped('quantity')) - record.quantity
+
+ if total_quantity > total_qty_in_moves:
+ raise UserError((
+ "Quantity Product '%s' sudah melebihi quantity demand."
+ ) % (record.product_id.display_name))
+ else:
+ # Check if the quantity exceeds the allowed total
+ if record.quantity > total_qty_in_moves:
+ raise UserError((
+ "Quantity Product '%s' sudah melebihi quantity demand."
+ ) % (record.product_id.display_name))
+
+ # Set the quantity to the entered value
+ record.quantity = record.quantity
+
+class BarcodeProduct(models.Model):
+ _name = 'barcode.product'
+ _description = 'Barcode Product'
+ _order = 'picking_id, id'
+
+ picking_id = fields.Many2one(
+ 'stock.picking',
+ string='Picking Reference',
+ required=True,
+ ondelete='cascade',
+ index=True,
+ copy=False,
+ )
+ product_id = fields.Many2one('product.product', string='Product', required=True)
+ barcode = fields.Char(string='Barcode')
+
+ @api.constrains('barcode')
+ def send_barcode_to_product(self):
+ for record in self:
+ if record.barcode and not record.product_id.barcode:
+ record.product_id.barcode = record.barcode
+ else:
+ raise UserError('Barcode sudah terisi') \ No newline at end of file
diff --git a/indoteknik_custom/models/uangmuka_pembelian.py b/indoteknik_custom/models/uangmuka_pembelian.py
index 204855d3..ba41f814 100644
--- a/indoteknik_custom/models/uangmuka_pembelian.py
+++ b/indoteknik_custom/models/uangmuka_pembelian.py
@@ -64,7 +64,7 @@ class UangmukaPembelian(models.TransientModel):
param_debit = {
'move_id': account_move.id,
- 'account_id': 401, # uang muka persediaan barang dagang
+ 'account_id': 669, # uang muka persediaan barang dagang
'partner_id': partner_id,
'currency_id': 12,
'debit': self.pay_amt,
diff --git a/indoteknik_custom/models/uangmuka_penjualan.py b/indoteknik_custom/models/uangmuka_penjualan.py
index 5acf604d..a3e95ecd 100644
--- a/indoteknik_custom/models/uangmuka_penjualan.py
+++ b/indoteknik_custom/models/uangmuka_penjualan.py
@@ -74,7 +74,7 @@ class UangmukaPenjualan(models.TransientModel):
# sisa di credit untuk uang muka penjualan, diluar ongkir dan selisih
param_credit = {
'move_id': account_move.id,
- 'account_id': 449, # uang muka penjualan
+ 'account_id': 668, # penerimaan belum alokasi
'partner_id': partner_id,
'currency_id': 12,
'debit': 0,
diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py
index af8a86ba..9216e8eb 100644
--- a/indoteknik_custom/models/user_company_request.py
+++ b/indoteknik_custom/models/user_company_request.py
@@ -104,9 +104,9 @@ class UserCompanyRequest(models.Model):
self.user_company_id.active = True
user.send_company_switch_approve_mail() if vals.get('is_switch_account') == True else user.send_company_request_approve_mail()
else:
- new_company = self.env['res.partner'].create({
- 'name': self.user_input
- })
+ # new_company = self.env['res.partner'].create({
+ # 'name': self.user_input
+ # })
# self.user_id.parent_id = new_company.id
user.send_company_request_reject_mail()
return super(UserCompanyRequest, self).write(vals)
diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py
index b43f56ac..be4293a0 100644
--- a/indoteknik_custom/models/user_pengajuan_tempo_request.py
+++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py
@@ -7,7 +7,7 @@ class RejectReasonWizard(models.TransientModel):
_description = 'Wizard for Reject Reason'
request_id = fields.Many2one('user.pengajuan.tempo.request', string='Request')
- reason_reject = fields.Text(string='Reason for Rejection', required=True)
+ reason_reject = fields.Text(string='Reason for Rejection', required=True, tracking=True)
def confirm_reject(self):
tempo = self.request_id
@@ -55,7 +55,27 @@ class UserPengajuanTempoRequest(models.Model):
('approval_director', 'Approved by Director'),
('reject', 'Rejected'),
], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft')
- reason_reject = fields.Char(string='Limit Tempo')
+ last_state_tempo = fields.Selection([
+ ('draft', 'Pengajuan Tempo'),
+ ('approval_sales', 'Approved by Sales Manager'),
+ ('approval_finance', 'Approved by Finance'),
+ ('approval_director', 'Approved by Director'),
+ ('reject', 'Rejected'),
+ ], string='Status',)
+ reason_reject = fields.Char(string='Reason Reaject', tracking=True, track_visibility='onchange')
+ state_tempo_text = fields.Char(string="Status", compute="_compute_state_tempo_text")
+
+ @api.depends('state_tempo')
+ def _compute_state_tempo_text(self):
+ for record in self:
+ status_mapping = {
+ 'draft': "Menunggu Approve Manager",
+ 'approval_sales': "Menunggu Approve Finance",
+ 'approval_finance': "Menunggu Approve Direktur",
+ 'approval_director': "Approved",
+ 'reject': "Rejected",
+ }
+ record.state_tempo_text = status_mapping.get(record.state_tempo, "Unknown")
# informasi perusahaan
name_tempo = fields.Many2one('res.partner', string='Nama Perusahaan', related='pengajuan_tempo_id.name_tempo', store=True, tracking=True, readonly=False)
@@ -71,7 +91,7 @@ class UserPengajuanTempoRequest(models.Model):
website_tempo = fields.Char(string='Website', related='pengajuan_tempo_id.website_tempo', store=True, tracking=True, readonly=False)
portal = fields.Boolean(string='Portal Website', related='pengajuan_tempo_id.portal', store=True, tracking=True, readonly=False)
estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun', related='pengajuan_tempo_id.estimasi_tempo', store=True, tracking=True, readonly=False)
- tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='pengajuan_tempo_id.tempo_duration', store=True, tracking=True, readonly=False, domain=[('id', 'in', [24, 25, 29, 32])])
+ tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='tempo_duration', store=True, tracking=True, readonly=False, domain=[('id', 'in', [24, 25, 29, 32])])
tempo_limit_origin = fields.Char(string='Limit Tempo', related='pengajuan_tempo_id.tempo_limit' , store=True, tracking=True, readonly=False)
category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', related='pengajuan_tempo_id.category_produk_ids', readonly=False)
@@ -334,13 +354,13 @@ class UserPengajuanTempoRequest(models.Model):
@api.onchange('tempo_duration')
def _tempo_duration_change(self):
for tempo in self:
- if tempo.env.user.id not in (7, 377, 12182):
+ if tempo.env.user.id not in (7, 688, 28, 377, 12182):
raise UserError("Durasi tempo hanya bisa di ubah oleh Sales Manager atau Direktur")
@api.onchange('tempo_limit')
def _onchange_tempo_limit(self):
for tempo in self:
- if tempo.env.user.id not in (7, 377, 12182):
+ if tempo.env.user.id not in (7, 688, 28, 377, 12182):
raise UserError("Limit tempo hanya bisa diubah oleh Sales Manager atau Direktur")
def button_approve(self):
for tempo in self:
@@ -409,6 +429,9 @@ class UserPengajuanTempoRequest(models.Model):
'target': 'new',
'context': {'default_request_id': self.id},
}
+ def button_draft(self):
+ for tempo in self:
+ tempo.state_tempo = tempo.last_state_tempo if tempo.last_state_tempo else 'draft'
def write(self, vals):
is_approve = True if self.state_tempo == 'approval_director' or vals.get('state_tempo') == 'approval_director' else False
@@ -507,10 +530,38 @@ class UserPengajuanTempoRequest(models.Model):
# Buat kontak baru untuk company_id
for contact_data in contacts_data:
- self.env['res.partner'].create({
- "parent_id": self.user_company_id.id, # Hubungkan ke perusahaan
- **contact_data, # Tambahkan data kontak
- })
+ existing_contact = self.env['res.partner'].search([
+ ('parent_id', '=', self.user_company_id.id),
+ ('name', '=', contact_data['name'])
+ ], limit=1)
+
+ if existing_contact:
+ # Pastikan tidak ada duplikasi nama dalam perusahaan yang sama
+ duplicate_check = self.env['res.partner'].search([
+ ('name', '=', contact_data['name']),
+ ('id', '!=', existing_contact.id) # Hindari update yang menyebabkan duplikasi global
+ ], limit=1)
+
+ if not duplicate_check:
+ # Perbarui hanya field yang tidak menyebabkan konflik
+ update_data = {k: v for k, v in contact_data.items() if k != 'name'}
+ existing_contact.write(update_data)
+ else:
+ raise UserError(f"Skipping update for {contact_data['name']} due to existing duplicate.")
+ else:
+ # Pastikan tidak ada partner lain dengan nama yang sama sebelum membuat baru
+ duplicate_check = self.env['res.partner'].search([
+ ('name', '=', contact_data['name'])
+ ], limit=1)
+
+ if duplicate_check:
+ # Jika nama sudah ada tetapi di perusahaan lain, tambahkan nama perusahaan
+ contact_data['name'] = f"{contact_data['name']} ({self.user_company_id.name})"
+
+ self.env['res.partner'].create({
+ "parent_id": self.user_company_id.id, # Hubungkan ke perusahaan
+ **contact_data, # Tambahkan data kontak
+ })
# Pengiriman
self.user_company_id.pic_name = self.pengajuan_tempo_id.pic_name
@@ -596,10 +647,10 @@ class UserPengajuanTempoRequest(models.Model):
attachment_ids=[self.user_company_id.dokumen_tempat_bekerja.id])
# self.user_company_id.active = True
# user.send_company_request_approve_mail()
- self.user_company_id.property_payment_term_id = self.pengajuan_tempo_id.tempo_duration.id
+ self.user_company_id.property_payment_term_id = self.tempo_duration.id
self.user_company_id.active_limit = True
- self.user_company_id.warning_stage = float(limit_tempo) - (float(limit_tempo)/2)
self.user_company_id.blocking_stage = limit_tempo
+ self.user_company_id.warning_stage = float(limit_tempo) - (float(limit_tempo)/2)
# Internal Notes
comment = []
diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py
new file mode 100644
index 00000000..c877a067
--- /dev/null
+++ b/indoteknik_custom/models/website_telegram.py
@@ -0,0 +1,193 @@
+import requests
+# import clipboard
+from odoo import models, fields, api
+from telethon.sessions import StringSession
+from telethon.sync import TelegramClient
+from odoo.exceptions import UserError
+from telethon import functions, types
+from telethon.tl.types import InputPeerChannel
+import asyncio
+from telethon.tl.functions.messages import SendMessageRequest
+# from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, PeerChannel
+import datetime
+from telethon.tl.types import MessageMediaPoll
+# from telethon.tl.functions.messages import SendMediaRequest
+# from telethon.tl.types import TextWithEntities
+
+class WebsiteTelegram(models.Model):
+ _name = 'website.telegram'
+ _description = 'Telegram Channel'
+
+
+ tittle = fields.Char("Channel Title")
+ invite_link = fields.Char("Channel invite link")
+ username = fields.Char("Channel Name")
+ user_id = fields.Many2many('res.partner', string='User Member', store=True)
+ id_data = fields.Char("Channel ID")
+ about = fields.Char("Channel Description")
+ is_broadcast = fields.Boolean("Is Broadcast", default=True)
+ is_megagroup = fields.Boolean("Is Megagroup", default=False)
+ is_accept = fields.Boolean("Is Megagroup", default=False)
+
+ # session_string = 'MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIRyy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwvplUUI1PLTktZ9uW2WE23b+ixNwJjJGwBDJPQEQFBE+vfmH0JP503wr5INS1poWg/j25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCOj4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB'
+
+
+ def create_channel(self, message):
+ asyncio.run(self._async_create_channel(message))
+
+ async def _async_create_channel(self, message):
+ async with TelegramClient(StringSession(
+ '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='),
+ 27799517, 'df8ee44b0ed11108245037d47b511201') as client:
+ result = await client(functions.channels.CreateChannelRequest(
+ title=self.tittle,
+ about=self.about,
+ broadcast=False,
+ megagroup=True,
+ ))
+ channel = result.updates[3].message.peer_id
+ channel_link = await client(functions.messages.ExportChatInviteRequest(
+ peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash),
+ ))
+ self.invite_link = channel_link.link
+
+ # Iterasi untuk setiap username
+ for name in self.user_id:
+ if name.telegram_id:
+ user_to_add = await client.get_entity(name.telegram_id)
+ result_add_user = await client(functions.channels.InviteToChannelRequest(
+ channel=channel,
+ users=[user_to_add.id],
+ ))
+ else:
+ raise UserError('ID Telegram '+ name.name + ' salah atau belum diisi')
+ # message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101'
+ message_template = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=357&model=sale.order&view_type=form&cids=1&menu_id=212'
+ message2 = self.tittle + ' di print oleh ' + self.env.user.name
+ result_massage = await client(SendMessageRequest(channel, message_template))
+ result_massage2 = await client(SendMessageRequest(channel, message))
+
+ # Send the poll to the channel using PeerChannel with the channel's ID
+ # result_polling = await client(SendMediaRequest(
+ # peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash),
+ # media=InputMediaPoll(poll=Poll(
+ # question=TextWithEntities(text="ASK RETURN?", entities=[]),
+ # answers=[
+ # PollAnswer(text=TextWithEntities(text="Accept", entities=[]), option=b'\x01'),
+ # PollAnswer(text=TextWithEntities(text="Reject", entities=[]), option=b'\x02'),
+ # ],
+ # id=2
+ # )),
+ # message='Ask Return Polling'
+ # ))
+
+ def receive_messages(self):
+ return asyncio.run(self._async_receive_messages())
+
+ async def _async_receive_messages(self):
+ async with TelegramClient(StringSession(
+ '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='),
+ 27799517, 'df8ee44b0ed11108245037d47b511201') as client:
+ channel = await client.get_entity(self.invite_link)
+ result = await client(functions.messages.GetHistoryRequest(
+ peer=channel,
+ offset_id=42,
+ offset_date=datetime.datetime(2024, 12, 31),
+ add_offset=0,
+ limit=100,
+ max_id=0,
+ min_id=0,
+ hash=channel.access_hash
+ ))
+ accept_found = False
+
+ for message in result.messages:
+ if not isinstance(message.media, MessageMediaPoll):
+ continue
+ if message.media.results.total_voters > 0:
+ if message.media.results.results[0].voters > message.media.results.results[1].voters:
+ accept_found = True
+ break
+
+ return accept_found
+
+ def send_to_telegram(self, message):
+ # apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage'
+ try:
+ # requests.post(apiURL, json={'chat_id': self.chatID, 'text': message})
+ asyncio.run(self._async_send_to_telegram(message))
+ except Exception as e:
+ print(e)
+
+ async def _async_send_to_telegram(self, message):
+ async with TelegramClient(StringSession(
+ '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='),
+ 27799517, 'df8ee44b0ed11108245037d47b511201') as client:
+ channel = await client.get_entity(self.invite_link)
+
+ # Iterasi untuk setiap username
+ for username in self.user_id:
+ if username:
+ try:
+ user_to_add = await client.get_entity(username.telegram_id)
+
+ result_add_user = await client(functions.channels.InviteToChannelRequest(
+ channel=channel,
+ users=[user_to_add.id],
+ ))
+ except Exception as e:
+ print(f"Error adding user {username}: {e}")
+
+ result_message = await client(SendMessageRequest(channel, message))
+
+ def test_send(self):
+ try:
+ self.env.cr.savepoint()
+
+ self.env['website.telegram'].search([('tittle', '=', self.tittle)])[0].send_to_telegram('test message')
+ except Exception as e:
+ print(e)
+
+ # @api.depends('name', 'chatID', 'bot_name')
+ # def _calc_python_code(self):
+ # for record in self:
+ # if not record.name:
+ # record.python_code = "pleas put a name"
+ # elif not record.test_message:
+ # record.test_message = "test"
+ # else:
+ # record.python_code = "self.env['website.telegram'].search([('name', '=', '" + record.name + "')])[0].send_to_telegram('" + record.test_message + "')"
+ #
+ # def copy_chat_id(self):
+ # record = self.browse(self.id)
+ # clipboard.copy(record.python_code)
+ #
+ # def paste_chat_id(self):
+ # record = self.browse(self.id)
+ # chat_id = clipboard.paste()
+ # record.write({'chatID': chat_id})
+ #
+ # def paste_bot_name(self):
+ # record = self.browse(self.id)
+ # bot_name = clipboard.paste()
+ # record.write({'bot_name': bot_name})
+ #
+ # def get_updates(self):
+ # apiURL = f'https://api.telegram.org/bot{self.bot_name}/getUpdates'
+ # try:
+ # response = requests.get(apiURL)
+ # updates = response.json()
+ # return updates
+ # except Exception as e:
+ # print(e)
+ # return None
+
+ # def receive_messages(self):
+ # updates = self.get_updates()
+ # if updates and 'result' in updates:
+ # for update in updates['result']:
+ # if 'text' in update['channel_post']:
+ # message_text = update['channel_post']['text']
+ # chat_id = update['channel_post']['chat']['id']
+ # chat_name = update['channel_post']['chat']['username']
+ # print(f"Received message: {message_text} from chat_id: {chat_id}, that is: {chat_name}")
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index 1f3835fa..37f5aeab 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -24,6 +24,7 @@ access_website_categories_homepage,access.website.categories.homepage,model_webs
access_website_categories_lob,access.website.categories.lob,model_website_categories_lob,,1,1,1,1
access_website_categories_management,access.website.categories.management,model_website_categories_management,,1,1,1,1
access_website_categories_management_line,access.website.categories.management.line,model_website_categories_management_line,,1,1,1,1
+access_website_telegram,access.website.telegram,model_website_telegram,,1,1,1,1
access_sales_target,access.sales.target,model_sales_target,,1,1,1,1
access_purchase_outstanding,access.purchase.outstanding,model_purchase_outstanding,,1,1,1,1
access_sales_outstanding,access.sales.outstanding,model_sales_outstanding,,1,1,1,1
@@ -150,6 +151,7 @@ access_v_move_outstanding,access.v.move.outstanding,model_v_move_outstanding,,1,
access_va_multi_approve,access.va.multi.approve,model_va_multi_approve,,1,1,1,1
access_va_multi_reject,access.va.multi.reject,model_va_multi_reject,,1,1,1,1
access_vendor_sla,access.vendor_sla,model_vendor_sla,,1,1,1,1
+access_check_product,access.check.product,model_check_product,,1,1,1,1
access_stock_immediate_transfer,access.stock.immediate.transfer,model_stock_immediate_transfer,,1,1,1,1
access_coretax_faktur,access.coretax.faktur,model_coretax_faktur,,1,1,1,1
access_purchase_order_unlock_wizard,access.purchase.order.unlock.wizard,model_purchase_order_unlock_wizard,,1,1,1,1
@@ -158,3 +160,7 @@ access_user_pengajuan_tempo,access.user.pengajuan.tempo,model_user_pengajuan_tem
access_reject_reason_wizard,reject.reason.wizard,model_reject_reason_wizard,,1,1,1,0
access_confirm_approval_wizard,confirm.approval.wizard,model_confirm_approval_wizard,,1,1,1,0
access_hr_public_holiday,confirm.hr.public.holiday,model_hr_public_holiday,,1,1,1,0
+access_barcode_product,access.barcode.product,model_barcode_product,,1,1,1,1
+access_barcoding_product,access.barcoding.product,model_barcoding_product,,1,1,1,1
+access_barcoding_product_line,access.barcoding.product.line,model_barcoding_product_line,,1,1,1,1
+access_account_payment_register,access.account.payment.register,model_account_payment_register,,1,1,1,1
diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml
index 36b292e8..50a34e11 100644
--- a/indoteknik_custom/views/account_move.xml
+++ b/indoteknik_custom/views/account_move.xml
@@ -137,6 +137,9 @@
{'column_invisible': [('parent.move_type', '!=', 'in_invoice')]}
</attribute>
</field>
+ <field name="product_id" position="before">
+ <field name="line_no" optional="hide"/>
+ </field>
<field name="invoice_incoterm_id" position="after">
<field name="date_terima_tukar_faktur"/>
</field>
diff --git a/indoteknik_custom/views/barcoding_product.xml b/indoteknik_custom/views/barcoding_product.xml
new file mode 100644
index 00000000..c7473d39
--- /dev/null
+++ b/indoteknik_custom/views/barcoding_product.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<odoo>
+ <data>
+ <record id="barcoding_product_tree" model="ir.ui.view">
+ <field name="name">barcoding.product.tree</field>
+ <field name="model">barcoding.product</field>
+ <field name="arch" type="xml">
+ <tree default_order="create_date desc">
+ <field name="product_id"/>
+ <field name="quantity"/>
+ <field name="type"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="barcoding_product_line_tree" model="ir.ui.view">
+ <field name="name">barcoding.product.line.tree</field>
+ <field name="model">barcoding.product.line</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="product_id"/>
+ <field name="qr_code_variant" widget="image"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="barcoding_product_form" model="ir.ui.view">
+ <field name="name">barcoding.product.form</field>
+ <field name="model">barcoding.product</field>
+ <field name="arch" type="xml">
+ <form >
+ <sheet>
+ <group>
+ <group>
+ <field name="product_id" required="1"/>
+ <field name="type" required="1"/>
+ <field name="quantity" attrs="{'invisible': [['type', 'in', ('barcoding')]], 'required': [['type', 'not in', ('barcoding')]]}"/>
+ <field name="barcode" attrs="{'invisible': [['type', 'in', ('print')]], 'required': [['type', 'not in', ('print')]]}"/>
+ </group>
+ </group>
+ <notebook>
+ <page string="Line" attrs="{'invisible': [['type', 'in', ('barcoding')]]}">
+ <field name="barcoding_product_line"/>
+ </page>
+ </notebook>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <record id="barcoding_product_view_search" model="ir.ui.view">
+ <field name="name">barcoding.product.search.view</field>
+ <field name="model">barcoding.product</field>
+ <field name="arch" type="xml">
+ <search string="Search Barcoding Product">
+ <field name="product_id"/>
+ </search>
+ </field>
+ </record>
+
+ <record id="barcoding_product_action" model="ir.actions.act_window">
+ <field name="name">Barcoding Product</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">barcoding.product</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_barcoding_product"
+ name="Barcoding Product"
+ parent="stock.menu_stock_warehouse_mgmt"
+ sequence="4"
+ action="barcoding_product_action"
+ />
+ </data>
+</odoo>
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 022937f4..3e4dd89c 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -51,6 +51,9 @@
<field name="approval_status" position="after">
<field name="approval_status_unlock" invisible="True"/>
</field>
+ <field name="partner_id" position="after">
+ <field name="purchase_order_count"/>
+ </field>
<field name="incoterm_id" position="after">
<field name="amount_total_without_service"/>
<field name="delivery_amt"/>
@@ -78,6 +81,9 @@
<field name="product_id" position="attributes">
<attribute name="options">{'no_create': True}</attribute>
</field>
+ <field name="date_planned" position="attributes">
+ <attribute name="invisible">1</attribute>
+ </field>
<field name="product_qty" position="before">
<field name="is_edit_product_qty" readonly="1" optional="hide"/>
<field name="qty_onhand" readonly="1" optional="hide"/>
diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml
index 896594bb..94f6c2ab 100644
--- a/indoteknik_custom/views/report_logbook_sj.xml
+++ b/indoteknik_custom/views/report_logbook_sj.xml
@@ -77,6 +77,16 @@
</field>
</record>
+ <record id="report_logbook_sj_view_search" model="ir.ui.view">
+ <field name="name">report.logbook.sj.search.view</field> <!-- Made the name more descriptive -->
+ <field name="model">report.logbook.sj</field>
+ <field name="arch" type="xml">
+ <search string="Search Report">
+ <field name="sj_number"/>
+ </search>
+ </field>
+ </record>
+
<record id="report_logbook_sj_action" model="ir.actions.act_window">
<field name="name">Report Logbook SJ</field>
<field name="type">ir.actions.act_window</field>
diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml
index bd664890..af5e0db3 100644
--- a/indoteknik_custom/views/res_partner.xml
+++ b/indoteknik_custom/views/res_partner.xml
@@ -68,6 +68,7 @@
<field name="vat" position="after">
<field name="email_finance" widget="email"/>
<field name="email_sales" widget="email"/>
+ <field name="telegram_id"/>
<field name="use_so_approval" attrs="{'invisible': [('parent_id', '!=', False), ('company_type', '!=', 'company')]}" />
<field name="use_only_ready_stock" attrs="{'invisible': [('parent_id', '!=', False), ('company_type', '!=', 'company')]}" />
<field name="web_role" attrs="{'invisible': ['|', ('parent_id', '=', False), ('company_type', '=', 'company')]}" />
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 74fc6e54..b267eee4 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -112,7 +112,7 @@
<field name="desc_updatable" invisible="1"/>
</xpath>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='name']" position="attributes">
- <attribute name="attrs">
+ <attribute name="modifiers">
{'readonly': [('desc_updatable', '=', False)]}
</attribute>
</xpath>
@@ -297,6 +297,7 @@
<field name="payment_type" optional="hide"/>
<field name="payment_status" optional="hide"/>
<field name="pareto_status" optional="hide"/>
+ <field name="shipping_method_picking" optional="hide"/>
</field>
</field>
</record>
diff --git a/indoteknik_custom/views/stock_backorder_confirmation_views.xml b/indoteknik_custom/views/stock_backorder_confirmation_views.xml
new file mode 100644
index 00000000..a622899e
--- /dev/null
+++ b/indoteknik_custom/views/stock_backorder_confirmation_views.xml
@@ -0,0 +1,14 @@
+<odoo>
+ <record id="view_backorder_confirmation_inherit" model="ir.ui.view">
+ <field name="name">stock_backorder_confirmation_inherit</field>
+ <field name="model">stock.backorder.confirmation</field>
+ <field name="inherit_id" ref="stock.view_backorder_confirmation"/>
+ <field name="arch" type="xml">
+ <xpath expr="//group/p[1]" position="replace">
+ <p>
+ Ada product yang quantity done nya kurang dari quantity demand.
+ </p>
+ </xpath>
+ </field>
+ </record>
+</odoo>
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index ae6ae940..1832c31e 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -89,9 +89,9 @@
<field name="partner_id" position="after">
<field name="real_shipping_id"/>
</field>
- <field name="product_uom_qty" position="attributes">
+ <!-- <field name="product_uom_qty" position="attributes">
<attribute name="attrs">{'readonly': [('parent.picking_type_code', '=', 'incoming')]}</attribute>
- </field>
+ </field> -->
<field name="date_done" position="after">
<field name="arrival_time"/>
</field>
@@ -135,6 +135,7 @@
<field name="sale_id" attrs="{'readonly': 1}" optional="hide"/>
<field name="print_barcode" optional="hide"/>
<field name="qr_code_variant" widget="image" optional="hide"/>
+ <field name="barcode" optional="hide"/>
</field>
<page name="note" position="after">
<page string="E-Faktur" name="efaktur" attrs="{'invisible': [['is_internal_use', '=', False]]}">
@@ -194,15 +195,18 @@
</group>
</group>
</page>
- <!-- <page string="Check Product" name="check_product">
+ <page string="Check Product" name="check_product">
<field name="check_product_lines"/>
- </page> -->
+ </page>
+ <page string="Barcode Product" name="barcode_product" attrs="{'invisible': [('picking_type_code', '!=', 'incoming')]}">
+ <field name="barcode_product_lines"/>
+ </page>
</page>
</field>
</record>
- <!-- <record id="check_product_tree" model="ir.ui.view">
+ <record id="check_product_tree" model="ir.ui.view">
<field name="name">check.product.tree</field>
<field name="model">check.product</field>
<field name="arch" type="xml">
@@ -212,7 +216,18 @@
<field name="status"/>
</tree>
</field>
- </record> -->
+ </record>
+
+ <record id="barcode_product_tree" model="ir.ui.view">
+ <field name="name">barcode.product.tree</field>
+ <field name="model">barcode.product</field>
+ <field name="arch" type="xml">
+ <tree editable="bottom">
+ <field name="product_id"/>
+ <field name="barcode"/>
+ </tree>
+ </field>
+ </record>
<record id="view_stock_move_line_detailed_operation_tree_inherit" model="ir.ui.view">
<field name="name">stock.move.line.operations.tree.inherit</field>
diff --git a/indoteknik_custom/views/user_pengajuan_tempo.xml b/indoteknik_custom/views/user_pengajuan_tempo.xml
index 33ad91cf..7f1faa41 100644
--- a/indoteknik_custom/views/user_pengajuan_tempo.xml
+++ b/indoteknik_custom/views/user_pengajuan_tempo.xml
@@ -269,7 +269,7 @@
<field name="subject">Pengajuan Tempo Harus di Periksa!</field>
<field name="email_from">"Indoteknik.com" &lt;noreply@indoteknik.com&gt;</field>
<field name="reply_to">sales@indoteknik.com</field>
- <field name="email_to">widyariyanti97@gmail.com, stephan@indoteknik.co.id</field>
+ <field name="email_to">finance@indoteknik.co.id, stephan@indoteknik.co.id, sapiabon768@gmail.com</field>
<!-- <field name="email_to">sapiabon768@gmail.com</field>-->
<field name="body_html" type="html">
<table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;">
diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml
index bb8262c9..7063231b 100644
--- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml
+++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml
@@ -10,7 +10,17 @@
<field name="create_date"/>
<field name="tempo_duration" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}"/>
<field name="tempo_limit" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}" placeholder="Contoh format, misalnya '10000000'" widget="monetary" options="{'currency_field': 'currency_id'}"/>
- <field name="state_tempo" decoration-success="state_tempo == 'approval_director'" decoration-danger="state_tempo == 'reject'" widget="badge" optional="show"/>
+<!-- <field name="state_tempo"-->
+<!-- decoration-danger="state_tempo == 'reject'"-->
+<!-- decoration-warning="state_tempo in ('draft', 'approval_sales', 'approval_finance')"-->
+<!-- decoration-success="state_tempo == 'approval_director'">-->
+<!-- <tree>-->
+<!-- <field name="state_tempo" invisible="1"/>-->
+<!-- <field name="state_tempo_text" string="Status"/>-->
+<!-- </tree>-->
+<!-- </field>-->
+ <field name="state_tempo" invisible="1"/>
+ <field name="state_tempo_text" decoration-success="state_tempo_text == 'Approved'" decoration-danger="state_tempo_text == 'Rejected'" widget="badge" optional="show"/>
</tree>
</field>
</record>
@@ -30,7 +40,11 @@
string="Reject"
attrs="{'invisible': [('state_tempo', 'in', ['approval_director','reject'])]}"
type="object"
- groups="purchase.group_purchase_manager"
+ class="oe_highlight"/>
+ <button name="button_draft"
+ string="Reset to Draft"
+ attrs="{'invisible': [('state_tempo', '!=', 'reject')]}"
+ type="object"
class="oe_highlight"/>
<field name="state_tempo" widget="statusbar"
statusbar_visible="draft,approval_sales,approval_finance,approval_director"
diff --git a/indoteknik_custom/views/website_telegram.xml b/indoteknik_custom/views/website_telegram.xml
new file mode 100644
index 00000000..d8590fc0
--- /dev/null
+++ b/indoteknik_custom/views/website_telegram.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="website_telegram_action" model="ir.actions.act_window">
+ <field name="name">Channel Telegram</field>
+ <field name="res_model">website.telegram</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <record id="website_telegram_tree" model="ir.ui.view">
+ <field name="name">website.telegram.tree</field>
+ <field name="model">website.telegram</field>
+ <field name="arch" type="xml">
+ <tree string="Channel List">
+ <field name="tittle"/>
+ <field name="about"/>
+ <field name="user_id"/>
+ <button name="test_send" type="object" icon="fa-paper-plane" string="Send Test"/>
+<!-- <button name="create_channel" type="object" icon="fa-paper-plane" string="Create Channel"/>-->
+<!-- <button name="receive_messages" type="object" icon="fa-paper-plane" string="GET Test"/>-->
+ </tree>
+ </field>
+ </record>
+
+ <record id="website_telegram_form" model="ir.ui.view">
+ <field name="name">website.telegram.form</field>
+ <field name="model">website.telegram</field>
+ <field name="arch" type="xml">
+ <form create="0">
+ <sheet>
+ <group>
+ <group>
+ <field name="tittle"/>
+ <field name="about"/>
+ <field name="user_id" widget="many2many_tags"/>
+ </group>
+ </group>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <record id="ir_actions_server_website_telegram_sync_to_solr" model="ir.actions.server">
+ <field name="name">Sync to solr</field>
+ <field name="model_id" ref="indoteknik_custom.model_website_telegram"/>
+ <field name="binding_model_id" ref="indoteknik_custom.model_website_telegram"/>
+ <field name="state">code</field>
+ <field name="code">model.action_sync_to_solr()</field>
+ </record>
+
+ <menuitem
+ id="website_telegram"
+ name="Channel Telegram"
+ parent="website_sale.menu_orders"
+ sequence="1"
+ action="website_telegram_action"
+ />
+ </data>
+</odoo>