From e819131a029681b10d5bafb2f4dc3948c429e776 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 20 Jun 2024 09:41:19 +0700 Subject: activate fullfilment on sale order --- indoteknik_custom/models/sale_order.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 91792b59..de61fb72 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -9,7 +9,7 @@ _logger = logging.getLogger(__name__) class SaleOrder(models.Model): _inherit = "sale.order" - # fullfillment_line = fields.One2many('sales.order.fullfillment', 'sales_order_id', string='Fullfillment') + fullfillment_line = fields.One2many('sales.order.fullfillment', 'sales_order_id', string='Fullfillment') order_sales_match_line = fields.One2many('sales.order.purchase.match', 'sales_order_id', string='Purchase Match Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True) total_margin = fields.Float('Total Margin', compute='_compute_total_margin', help="Total Margin in Sales Order Header") total_percent_margin = fields.Float('Total Percent Margin', compute='_compute_total_percent_margin', help="Total % Margin in Sales Order Header") @@ -96,16 +96,16 @@ class SaleOrder(models.Model): ('cust_director', 'Customer Director'), ('cust_procurement', 'Customer Procurement') ], string='Web Approval', copy=False) - # compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment") + compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment") - # def _compute_fullfillment(self): - # for rec in self: - # rec.fullfillment_line.unlink() + def _compute_fullfillment(self): + for rec in self: + rec.fullfillment_line.unlink() - # for line in rec.order_line: - # line._compute_reserved_from() + for line in rec.order_line: + line._compute_reserved_from() - # rec.compute_fullfillment = True + rec.compute_fullfillment = True def _compute_eta_date(self): max_leadtime = 0 -- cgit v1.2.3 From c3557f2c8b5837285558c8742aa0eb8bb6be1353 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 24 Jun 2024 10:05:58 +0700 Subject: change request alamat tempel --- indoteknik_custom/models/sale_order.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index de61fb72..02ac4c5f 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -97,6 +97,7 @@ class SaleOrder(models.Model): ('cust_procurement', 'Customer Procurement') ], string='Web Approval', copy=False) compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment") + note_ekspedisi = fields.Char(string="Note Ekspedisi") def _compute_fullfillment(self): for rec in self: -- cgit v1.2.3 From de28ec85c504b10098abdf53cfebebef68aaf626 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 26 Jun 2024 15:52:21 +0700 Subject: add alert if customer reference null --- indoteknik_custom/models/sale_order.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 02ac4c5f..efcbf606 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -454,6 +454,8 @@ class SaleOrder(models.Model): raise UserError("Credit Limit pada Master Data Customer harus diisi") if order.payment_term_id != partner.property_payment_term_id: raise UserError("Payment Term berbeda pada Master Data Customer") + if not order.client_order_ref and order.create_date > datetime(2024, 6, 27): + raise UserError("Customer Reference kosong, di isi dengan NO PO jika PO tidak ada mohon ditulis Tanpa PO") if order.validate_partner_invoice_due(): return self._create_notification_action('Notification', 'Terdapat invoice yang telah melewati batas waktu, mohon perbarui pada dokumen Due Extension') @@ -484,6 +486,9 @@ class SaleOrder(models.Model): if FROM_WEBSITE and main_parent.use_so_approval and order.web_approval not in ['cust_procurement', 'cust_director']: raise UserError("This order not yet approved by customer procurement or director") + + if not order.client_order_ref and order.create_date > datetime(2024, 6, 27): + raise UserError("Customer Reference kosong, di isi dengan NO PO jika PO tidak ada mohon ditulis Tanpa PO") if order.validate_partner_invoice_due(): return self._create_notification_action('Notification', 'Terdapat invoice yang telah melewati batas waktu, mohon perbarui pada dokumen Due Extension') -- cgit v1.2.3 From 0346d579b0db5969bf3a4e475cf8abb1b788cdd2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 28 Jun 2024 13:37:44 +0700 Subject: multi create uang muka penjualan --- indoteknik_custom/models/sale_order.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index efcbf606..ce54bc74 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -99,6 +99,13 @@ class SaleOrder(models.Model): compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment") note_ekspedisi = fields.Char(string="Note Ekspedisi") + def open_form_multi_create_uang_muka(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_sale_order_multi_uangmuka') + action['context'] = { + 'so_ids': [x.id for x in self] + } + return action + def _compute_fullfillment(self): for rec in self: rec.fullfillment_line.unlink() -- cgit v1.2.3 From e50ec098e7eff86bfc372ffec74fffd5e4284770 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 28 Jun 2024 13:53:10 +0700 Subject: email notif to salesperson --- indoteknik_custom/models/sale_order.py | 78 +++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index ce54bc74..826315f2 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -2,6 +2,7 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError, ValidationError from datetime import datetime, timedelta import logging, random, string, requests, math, json, re +from collections import defaultdict _logger = logging.getLogger(__name__) @@ -476,11 +477,75 @@ class SaleOrder(models.Model): raise UserError("Bisa langsung Confirm") - def send_notif_to_salesperson(self): - for rec in self: - if not rec.partner_id.main_parent_id.use_so_approval: continue - template = self.env.ref('indoteknik_custom.mail_template_sale_order_notification_to_salesperson') - template.send_mail(rec.id, force_send=True) + def send_notif_to_salesperson(self, cancel=False): + + if not cancel: + grouping_so = self.search([ + ('partner_id.parent_id.id', '=', self.partner_id.parent_id.id), + ('partner_id.site_id.id', '=', self.partner_id.site_id.id), + ]) + else: + grouping_so = self.search([ + ('partner_id.parent_id.id', '=', self.partner_id.parent_id.id), + ('partner_id.site_id.id', '=', self.partner_id.site_id.id), + ('id', '!=', self.id), + ]) + # Kelompokkan data berdasarkan salesperson + salesperson_data = {} + for rec in grouping_so: + if rec.user_id.id not in salesperson_data: + salesperson_data[rec.user_id.id] = {'name': rec.user_id.name, 'orders': [], 'total_amount': 0, 'sum_total_amount': 0, 'business_partner': '', 'site': ''} # Menetapkan nilai awal untuk 'site' + if rec.picking_ids: + if not any(picking.state in ['assigned', 'confirmed', 'waiting'] for picking in rec.picking_ids): + continue + if all(picking.state == 'done' for picking in rec.picking_ids): + continue + if all(picking.state == 'cancel' for picking in rec.picking_ids): + continue + if not rec.partner_id.main_parent_id.use_so_approval: + continue + order_total_amount = rec.amount_total # Mengakses langsung rec.amount_total + salesperson_data[rec.user_id.id]['orders'].append({ + 'order_name': rec.name, + 'parent_name': rec.partner_id.name, + 'site_name': rec.partner_id.site_id.name, + 'total_amount': rec.amount_total, + }) + salesperson_data[rec.user_id.id]['sum_total_amount'] += order_total_amount + salesperson_data[rec.user_id.id]['business_partner'] = grouping_so[0].partner_id.main_parent_id.name + salesperson_data[rec.user_id.id]['site'] = grouping_so[0].partner_id.site_id.name # Menambahkan nilai hanya jika ada + + # Kirim email untuk setiap salesperson + for salesperson_id, data in salesperson_data.items(): + if data['orders']: + # Buat isi tabel untuk email + table_content = '' + for order_data in data['orders']: + table_content += f""" + + {order_data['order_name']} + {order_data['parent_name']} + {order_data['site_name']} + {order_data['total_amount']} + + """ + + # Dapatkan email salesperson + salesperson_email = self.env['res.users'].browse(salesperson_id).partner_id.email + + # Kirim email hanya jika ada data yang dikumpulkan + template = self.env.ref('indoteknik_custom.mail_template_sale_order_notification_to_salesperson') + email_body = template.body_html.replace('${table_content}', table_content) + email_body = email_body.replace('${salesperson_name}', data['name']) + email_body = email_body.replace('${sum_total_amount}', str(data['sum_total_amount'])) + email_body = email_body.replace('${site}', str(data['site'])) + email_body = email_body.replace('${business_partner}', str(data['business_partner'])) + # Kirim email + self.env['mail.mail'].create({ + 'subject': 'Notification: Sale Orders', + 'body_html': email_body, + 'email_to': salesperson_email, + }).send() def action_confirm(self): for order in self: @@ -518,6 +583,7 @@ class SaleOrder(models.Model): def action_cancel(self): # TODO stephan prevent cancel if have invoice, do, and po + main_parent = self.partner_id.get_main_parent() if self._name != 'sale.order': return super(SaleOrder, self).action_cancel() @@ -533,6 +599,8 @@ class SaleOrder(models.Model): self.approval_status = False self.due_id = False + if main_parent.use_so_approval: + self.send_notif_to_salesperson(cancel=True) return super(SaleOrder, self).action_cancel() def validate_partner_invoice_due(self): -- cgit v1.2.3 From 53e3cacd7d32df44ce8637284c3ec16050e07e5b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 1 Jul 2024 09:20:09 +0700 Subject: add flash sale to sales order --- indoteknik_custom/models/sale_order.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 826315f2..03b37229 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -72,6 +72,8 @@ class SaleOrder(models.Model): gross_amount = fields.Float(string='Gross Amount', help='Jumlah pembayaran yang dilakukan dengan Midtrans') notification = fields.Char(string='Notification', help='Dapat membantu error dari approval') delivery_service_type = fields.Char(string='Delivery Service Type', help='data dari rajaongkir') + flash_sale = fields.Char(string='Flash Sale', help='data dari web') + flash_sale_icon = fields.Html(string='Flash Sale', compute='_compute_flash_sale_icon') grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') payment_link_midtrans = fields.Char(string='Payment Link', help='Url payment yg digenerate oleh midtrans, harap diserahkan ke customer agar dapat dilakukan pembayaran secara mandiri') due_id = fields.Many2one('due.extension', string="Due Extension", readonly=True, tracking=True) @@ -99,7 +101,15 @@ class SaleOrder(models.Model): ], string='Web Approval', copy=False) compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment") note_ekspedisi = fields.Char(string="Note Ekspedisi") - + + @api.depends('flash_sale') + def _compute_flash_sale_icon(self): + for order in self: + if order.flash_sale and order.flash_sale.lower() == 'true': + order.flash_sale_icon = '' + else: + order.flash_sale_icon = '' + def open_form_multi_create_uang_muka(self): action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_sale_order_multi_uangmuka') action['context'] = { -- cgit v1.2.3 From a54492e34db2a43d9aae2d575b2b3c073669631c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 1 Jul 2024 11:19:19 +0700 Subject: update flash sale & get_request_params untuk boolean --- indoteknik_custom/models/sale_order.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 03b37229..6886f5a8 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -72,8 +72,7 @@ class SaleOrder(models.Model): gross_amount = fields.Float(string='Gross Amount', help='Jumlah pembayaran yang dilakukan dengan Midtrans') notification = fields.Char(string='Notification', help='Dapat membantu error dari approval') delivery_service_type = fields.Char(string='Delivery Service Type', help='data dari rajaongkir') - flash_sale = fields.Char(string='Flash Sale', help='data dari web') - flash_sale_icon = fields.Html(string='Flash Sale', compute='_compute_flash_sale_icon') + flash_sale = fields.Boolean(string='Flash Sale', help='Data dari web') grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') payment_link_midtrans = fields.Char(string='Payment Link', help='Url payment yg digenerate oleh midtrans, harap diserahkan ke customer agar dapat dilakukan pembayaran secara mandiri') due_id = fields.Many2one('due.extension', string="Due Extension", readonly=True, tracking=True) @@ -102,14 +101,6 @@ class SaleOrder(models.Model): compute_fullfillment = fields.Boolean(string='Compute Fullfillment', compute="_compute_fullfillment") note_ekspedisi = fields.Char(string="Note Ekspedisi") - @api.depends('flash_sale') - def _compute_flash_sale_icon(self): - for order in self: - if order.flash_sale and order.flash_sale.lower() == 'true': - order.flash_sale_icon = '' - else: - order.flash_sale_icon = '' - def open_form_multi_create_uang_muka(self): action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_sale_order_multi_uangmuka') action['context'] = { -- cgit v1.2.3 From 0c36919ea3a5e254f361002ddddb437a8c208eb9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 1 Jul 2024 15:39:35 +0700 Subject: move flash sale to other info --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 6886f5a8..ac81737d 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -72,7 +72,6 @@ class SaleOrder(models.Model): gross_amount = fields.Float(string='Gross Amount', help='Jumlah pembayaran yang dilakukan dengan Midtrans') notification = fields.Char(string='Notification', help='Dapat membantu error dari approval') delivery_service_type = fields.Char(string='Delivery Service Type', help='data dari rajaongkir') - flash_sale = fields.Boolean(string='Flash Sale', help='Data dari web') grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') payment_link_midtrans = fields.Char(string='Payment Link', help='Url payment yg digenerate oleh midtrans, harap diserahkan ke customer agar dapat dilakukan pembayaran secara mandiri') due_id = fields.Many2one('due.extension', string="Due Extension", readonly=True, tracking=True) @@ -92,6 +91,7 @@ class SaleOrder(models.Model): picking_iu_id = fields.Many2one('stock.picking', 'Picking IU') helper_by_id = fields.Many2one('res.users', 'Helper By') eta_date = fields.Datetime(string='ETA Date', copy=False, compute='_compute_eta_date') + flash_sale = fields.Boolean(string='Flash Sale', help='Data dari web') web_approval = fields.Selection([ ('company', 'Company'), ('cust_manager', 'Customer Manager'), -- cgit v1.2.3