From 4c2325d4a983ced3a25a9d53d7613a9186360b17 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 16 Oct 2024 13:15:11 +0700 Subject: update ready stock picup quantity --- indoteknik_api/controllers/api_v1/product.py | 15 +++++++++++++++ indoteknik_api/controllers/api_v1/sale_order.py | 3 ++- indoteknik_api/models/sale_order.py | 1 + indoteknik_custom/models/sale_order_line.py | 1 + indoteknik_custom/models/website_user_cart.py | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 9673b3ef..b68eb0f9 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -96,6 +96,21 @@ class Product(controller.Controller): return self.response(data, headers=[('Cache-Control', 'max-age=600, private')]) + @http.route(prefix + 'product_variant//qty_available', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_product_variant_stock_available_by_id(self, **kw): + id = int(kw.get('id')) + product = request.env['product.product'].search( + [('id', '=', id)], limit=1) + + qty_available = product.free_qty + + data = { + 'qty': qty_available, + } + + return self.response(data, headers=[('Cache-Control', 'max-age=600, private')]) + @http.route(prefix + 'product/template/price/', auth='public', methods=['GET', 'OPTIONS']) def get_product_template_price_by_id(self, **kw): if not self.authenticate(): diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index e7664c79..905795b0 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -446,7 +446,8 @@ class SaleOrder(controller.Controller): 'company_id': 1, 'order_id': sale_order.id, 'product_id': cart['id'], - 'product_uom_qty': cart['quantity'] + 'product_uom_qty': cart['quantity'], + 'product_available_quantity': cart['available_quantity'] }) order_line.product_id_change() order_line.onchange_vendor_id() diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 725dbb4b..8e0371a3 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -84,6 +84,7 @@ class SaleOrder(models.Model): 'subtotal': line.price_subtotal } product['quantity'] = line.product_uom_qty + product['available_quantity'] = line.product_available_quantity data_with_detail['products'].append(product) for invoice in sale_order.invoice_ids: if invoice.state == 'posted': diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 5e01067a..964b3ff2 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -31,6 +31,7 @@ class SaleOrderLine(models.Model): vendor_subtotal = fields.Float(string='Vendor Subtotal', compute="_compute_vendor_subtotal") amount_voucher_disc = fields.Float(string='Voucher Discount') qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') + product_available_quantity = fields.Float(string='Qty pickup by user',) reserved_from = fields.Char(string='Reserved From', copy=False) item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction') weight = fields.Float(string='Weight') diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 26e217cb..9dadc40b 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -65,9 +65,11 @@ class WebsiteUserCart(models.Model): if stock_quant: res['is_in_bu'] = True res['on_hand_qty'] = sum(stock_quant.mapped('quantity')) + res['available_quantity'] = stock_quant.available_quantity else: res['is_in_bu'] = False res['on_hand_qty'] = 0 + res['available_quantity'] = 0 flashsales = self.product_id._get_active_flash_sale() res['has_flashsale'] = True if len(flashsales) > 0 else False -- cgit v1.2.3 From 9b86d64f64e149d26b5e33254fefd5dfc15ce1c4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 31 Oct 2024 09:03:21 +0700 Subject: approval retur picking --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/approval_retur_picking.py | 38 ++++++++++++++++++++++ indoteknik_custom/models/stock_picking.py | 16 ++++++++- indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/approval_retur_picking.xml | 27 +++++++++++++++ 6 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/approval_retur_picking.py create mode 100644 indoteknik_custom/views/approval_retur_picking.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index c8a658b5..da44ebf3 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -145,6 +145,7 @@ 'views/approval_unreserve.xml', 'views/vendor_approval.xml', 'views/find_page.xml', + 'views/approval_retur_picking.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 e62fbb4a..4983cc17 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -131,3 +131,4 @@ from . import approval_unreserve from . import vendor_approval from . import partner from . import find_page +from . import approval_retur_picking diff --git a/indoteknik_custom/models/approval_retur_picking.py b/indoteknik_custom/models/approval_retur_picking.py new file mode 100644 index 00000000..63639782 --- /dev/null +++ b/indoteknik_custom/models/approval_retur_picking.py @@ -0,0 +1,38 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class ApprovalReturPicking(models.TransientModel): + _name = 'approval.retur.picking' + _description = 'Wizard to add Note Return' + + note_return = fields.Text(string="Note Return", required=True) + + def action_confirm_note_return(self): + picking_ids = self._context.get('picking_ids') + picking = self.env['stock.picking'].browse(picking_ids) + + # Update the note_return field + picking.update({ + 'note_return': self.note_return + }) + + # Post a highlighted message to lognote + picking.message_post( + body=f"
" + f"Note Return (Pinned):
{self.note_return}
", + subtype_id=self.env.ref("mail.mt_note").id + ) + + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'Note berhasil ditambah', + 'next': {'type': 'ir.actions.act_window_close'}, + } + } + diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 4c9d7658..107a6e72 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -104,6 +104,7 @@ class StockPicking(models.Model): ('to invoice', 'To Invoice'), ('no', 'Nothing to Invoice') ], string='Invoice Status', related="sale_id.invoice_status") + note_return = fields.Text(string="Note Return", help="Catatan untuk kirim barang kembali") state_reserve = fields.Selection([ ('waiting', 'Waiting For Fullfilment'), @@ -445,6 +446,11 @@ class StockPicking(models.Model): pick.approval_return_status = 'approved' else: pick.approval_return_status = 'pengajuan1' + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action def calculate_line_no(self): for picking in self: @@ -503,6 +509,9 @@ class StockPicking(models.Model): def button_validate(self): + if not self.env.user.is_logistic_approver and 'Return of' in self.origin: + raise UserError("Button ini hanya untuk Logistik") + if self._name != 'stock.picking': return super(StockPicking, self).button_validate() @@ -553,6 +562,11 @@ class StockPicking(models.Model): self.date_done = datetime.datetime.utcnow() self.state_reserve = 'done' return res + def action_cancel(self): + if not self.env.user.is_logistic_approver and 'Return of' in self.origin: + raise UserError("Button ini hanya untuk Logistik") + res = super(StockPicking, self).action_cancel() + return res @api.model def create(self, vals): @@ -688,4 +702,4 @@ class StockPicking(models.Model): formatted_fastest_eta = fastest_eta.strftime(format_time_fastest) formatted_longest_eta = longest_eta.strftime(format_time) - return f'{formatted_fastest_eta} - {formatted_longest_eta}' + return f'{formatted_fastest_eta} - {formatted_longest_eta}' \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 553047e6..06848ad7 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -143,3 +143,4 @@ access_vendor_approval_line,access.vendor.approval.line,model_vendor_approval_li access_vit_kota,access.vit.kota,model_vit_kota,,1,1,1,1 access_v_brand_product_category,access.v.brand.product.category,model_v_brand_product_category,,1,1,1,1 access_web_find_page,access.web.find.page,model_web_find_page,,1,1,1,1 +access_approval_retur_picking,access.approval.retur.picking,model_approval_retur_picking,,1,1,1,1 diff --git a/indoteknik_custom/views/approval_retur_picking.xml b/indoteknik_custom/views/approval_retur_picking.xml new file mode 100644 index 00000000..ebe038d1 --- /dev/null +++ b/indoteknik_custom/views/approval_retur_picking.xml @@ -0,0 +1,27 @@ + + + + approval.retur.picking.form + approval.retur.picking + +
+ + + +
+
+
+
+
+ + + + Add Return Note + approval.retur.picking + form + + new + +
-- cgit v1.2.3 From 926ab9c6d505eff4accbfd1e5472e0e63e900a30 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Nov 2024 10:50:52 +0700 Subject: cr approval unreserve --- indoteknik_custom/models/approval_unreserve.py | 2 +- indoteknik_custom/models/logbook_sj.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/approval_unreserve.py b/indoteknik_custom/models/approval_unreserve.py index 07ddda1f..ba8b8da7 100644 --- a/indoteknik_custom/models/approval_unreserve.py +++ b/indoteknik_custom/models/approval_unreserve.py @@ -74,7 +74,7 @@ class ApprovalUnreserve(models.Model): raise UserError("Quantity yang di unreserve melebihi quantity yang ada") def action_approve(self): - if self.env.user.id != self.user_id.id: + if self.env.user.id != self.user_id.id and not self.env.user.has_group('indoteknik_custom.group_role_it'): raise UserError("Hanya Sales nya yang bisa approve.") if self.state != 'waiting_approval': diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py index f84619ad..9f349882 100644 --- a/indoteknik_custom/models/logbook_sj.py +++ b/indoteknik_custom/models/logbook_sj.py @@ -101,14 +101,16 @@ class LogbookSJLine(models.TransientModel): delivery_type = self.get_delivery_type(picking.driver_departure_date, picking.driver_arrival_date) if delivery_type != 'departure': - self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') + if picking.driver_departure_date: + self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') if delivery_type == 'departure': self.departure_date = current_time elif delivery_type == 'arrival': self.arrival_date = current_time else: - self.arrival_date = picking.driver_arrival_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') + if picking.driver_arrival_date: + self.arrival_date = picking.driver_arrival_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') else: raise UserError('Nomor DO tidak ditemukan') -- cgit v1.2.3 From d55ed85f466cc437645a19756c8d13694b1f9305 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Nov 2024 11:15:41 +0700 Subject: cr delivery order sj retur date --- indoteknik_custom/models/delivery_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/delivery_order.py b/indoteknik_custom/models/delivery_order.py index be5fd2e0..04b99711 100644 --- a/indoteknik_custom/models/delivery_order.py +++ b/indoteknik_custom/models/delivery_order.py @@ -37,7 +37,7 @@ class DeliveryOrder(models.TransientModel): if delivery_type == 'departure': picking.driver_departure_date = current_time elif delivery_type == 'arrival': - picking.driver_arrival_date = current_time + picking.sj_return_date = datetime.utcnow() sale_order = False if picking.origin: -- cgit v1.2.3 From 388942b58b47da9425c253db13036a80fbcf4ce4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Nov 2024 14:33:53 +0700 Subject: fix bug purchasing job --- indoteknik_custom/models/delivery_order.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/delivery_order.py b/indoteknik_custom/models/delivery_order.py index 04b99711..2ed49a54 100644 --- a/indoteknik_custom/models/delivery_order.py +++ b/indoteknik_custom/models/delivery_order.py @@ -103,14 +103,16 @@ class DeliveryOrderLine(models.TransientModel): delivery_type = self.get_delivery_type(picking.driver_departure_date, picking.driver_arrival_date) if delivery_type != 'departure': - self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') + if picking.driver_departure_date: + self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') if delivery_type == 'departure': self.departure_date = current_time elif delivery_type == 'arrival': self.arrival_date = current_time else: - self.arrival_date = picking.driver_arrival_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') + if picking.driver_arrival_date: + self.arrival_date = picking.driver_arrival_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') else: raise UserError('Nomor DO tidak ditemukan') -- cgit v1.2.3 From f59c345864c67fbcedb06a15f8a7cf44c9a37e05 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Nov 2024 16:18:43 +0700 Subject: cr stock picking --- indoteknik_custom/views/stock_picking.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index c230bc7b..69b29f9b 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -134,7 +134,7 @@ - + -- cgit v1.2.3 From 100fa7ec1d9ccfc02712096dceca3decc2311abb Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Nov 2024 16:42:46 +0700 Subject: cr view stock picking --- indoteknik_custom/views/stock_picking.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 69b29f9b..c230bc7b 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -134,7 +134,7 @@ - + -- cgit v1.2.3 From 7afd1ef51e18f9dcb1c0e71ea1e512b52284d3d1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 5 Nov 2024 11:09:46 +0700 Subject: add sticky note while ask approval --- indoteknik_custom/models/purchase_order.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 393fc562..6fc0c497 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -730,7 +730,20 @@ class PurchaseOrder(models.Model): elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id: raise UserError("Bisa langsung Confirm") else: + reason = '' self.approval_status = 'pengajuan1' + if self.amount_untaxed >= 50000000: + reason = 'above 50jt, ' + if self.total_percent_margin < self.total_so_percent_margin: + reason += 'diff margin, ' + if not self.from_apo and not self.sale_order_id: + reason += 'not link with sales, ' + # Post a highlighted message to lognote + self.message_post( + body=f"
" + f"Note Return (Pinned):
{reason}
", + subtype_id=self.env.ref("mail.mt_note").id + ) def re_calculate(self): if self.from_apo: -- cgit v1.2.3 From 772d42fba3fddccd3ca951bbedadeca4044593a9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 5 Nov 2024 12:04:45 +0700 Subject: add error handling ask aproval --- indoteknik_custom/models/sale_order.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 1ad08154..8e170b1c 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -768,7 +768,28 @@ class SaleOrder(models.Model): self._validate_order() for order in self: order.order_line.validate_line() + order.check_data_real_delivery_address() + order._validate_order() + order.sale_order_check_approve() + + main_parent = order.partner_id.get_main_parent() + SYSTEM_UID = 25 + FROM_WEBSITE = order.create_uid.id == SYSTEM_UID + 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 not order.commitment_date and order.create_date > datetime(2024, 9, 12): + raise UserError("Expected Delivery Date kosong, wajib diisi") + + if not order.real_shipping_id: + UserError('Real Delivery Address harus di isi') + + 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') term_days = 0 for term_line in order.payment_term_id.line_ids: -- cgit v1.2.3 From 9602db0d08b64f50e02d3e25ab3846221bf2cb08 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 5 Nov 2024 13:22:35 +0700 Subject: temporary disable reserve stock --- indoteknik_custom/views/purchase_order.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 06c76a82..0e6b6792 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -212,7 +212,6 @@ model.procure_calculation() code 75 - True -- cgit v1.2.3 From 4a3ff9e6fc85f534c106198c0ceee4e8c33eba5c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 6 Nov 2024 09:50:38 +0700 Subject: update bug products_inactive on user carts --- indoteknik_api/controllers/api_v1/cart.py | 21 +++++++++++++++++++-- indoteknik_custom/models/website_user_cart.py | 24 +++++++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py index 2a24b205..7a40b1e2 100644 --- a/indoteknik_api/controllers/api_v1/cart.py +++ b/indoteknik_api/controllers/api_v1/cart.py @@ -46,8 +46,25 @@ class Cart(controller.Controller): def get_cart_count_by_user_id(self, user_id, **kw): user_id = int(user_id) query = [('user_id', '=', user_id)] - carts = request.env['website.user.cart'].search_count(query) - return self.response(carts) + carts = request.env['website.user.cart'].search(query) + products_active = [] + products_inactive = [] + for cart in carts: + if cart.product_id: + price = cart.product_id._v2_get_website_price_include_tax() + if cart.product_id.active and price > 0: + product = cart.with_context(price_for="web").get_products() + for product_active in product: + products_active.append(product_active) + else: + product_inactives = cart.with_context(price_for="web").get_products() + for inactives in product_inactives: + products_inactive.append(inactives) + else: + program = cart.with_context(price_for="web").get_products() + for programs in program: + products_active.append(programs) + return self.response(len(products_active)) @http.route(PREFIX_USER + 'cart/create-or-update', auth='public', methods=['POST', 'OPTIONS'], csrf=False) @controller.Controller.must_authorized(private=True, private_key='user_id') diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 26e217cb..fbcb0aa4 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -108,8 +108,30 @@ class WebsiteUserCart(models.Model): parameters.append(('is_selected', '=', True)) carts = self.search(parameters) + products_active = [] + products_inactive = [] + for cart in carts: + if cart.product_id: + price = cart.product_id._v2_get_website_price_include_tax() + if cart.product_id.active and price > 0: + product = cart.with_context(price_for="web").get_products() + for product_active in product: + products_active.append(product_active) + else: + product_inactives = cart.with_context(price_for="web").get_products() + for inactives in product_inactives: + products_inactive.append(inactives) + else: + program = cart.with_context(price_for="web").get_products() + for programs in program: + products_active.append(programs) + data = { + 'product_total': self.search_count(parameters), + 'products': products_active, + 'products_inactive': products_inactive + } products = carts.get_products() - return products + return products_active def get_user_checkout(self, user_id, voucher=False, voucher_shipping=False, source=False): products = self.get_product_by_user(user_id=user_id, selected=True, source=source) -- cgit v1.2.3 From 7712141e5fa515eb6b966ae63956e7bbb3f384f3 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 6 Nov 2024 11:19:34 +0700 Subject: fix bug wati --- indoteknik_custom/models/wati.py | 50 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index d9fb7247..eed5413e 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -192,27 +192,6 @@ class WatiHistory(models.Model): is_get_attribute = fields.Boolean(string='Get Attribute', default=False) def _get_attribute_wati(self): - # url = 'https://live-server-2106.wati.io/api/v1/getContacts' - - # cookies = { - # 'affinity': '1701232090.884.1520.321410|ff187ffce9bc0bae13542bb446e41008', - # } - - # headers = { - # 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3MGM5ZmJhNy00MWRlLTRkMWEtYjY2NS1hM2Q5ODc2ZjhlZWIiLCJ1bmlxdWVfbmFtZSI6InR5YXNAaW5kb3Rla25pay5jb20iLCJuYW1laWQiOiJ0eWFzQGluZG90ZWtuaWsuY29tIiwiZW1haWwiOiJ0eWFzQGluZG90ZWtuaWsuY29tIiwiYXV0aF90aW1lIjoiMTEvMjkvMjAyMyAwNDoxNzo0NyIsImRiX25hbWUiOiIyMTA2IiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiQURNSU5JU1RSQVRPUiIsImV4cCI6MjUzNDAyMzAwODAwLCJpc3MiOiJDbGFyZV9BSSIsImF1ZCI6IkNsYXJlX0FJIn0.--KHv4GCOG2MM3lNW9Nm-0-d8OAVpn5kbcSX4JKqATQ', - # # 'Cookie': 'affinity=1701232090.884.1520.321410|ff187ffce9bc0bae13542bb446e41008', - # } - - # files = { - # 'pageSize': (None, '1'), - # 'pageNumber': (None, '1'), - # 'name': (None, ''), - # 'attribute': (None, '[{name: "phone", operator: "contain", value: "6285751430014"}]'), - # 'createdDate': (None, ''), - # } - - # response = requests.get(url, cookies=cookies, headers=headers, files=files) - # print(response.json()) domain = [ '&', ('is_get_attribute', '=', False), @@ -226,29 +205,36 @@ class WatiHistory(models.Model): for wati_history in wati_histories: count += 1 _logger.info('[Parse Notification] Process: %s/%s' % (str(count), str(limit))) + wati_api = self.env['wati.api'] + + # Perbaikan pada params 'attribute' untuk menghindari masalah "type object is not subscriptable" params = { - 'pageSize':1, - 'pageNumber':1, - 'attribute':[{'name': "phone", 'operator': "contain", 'value': wati_history.wa_id}], + 'pageSize': 1, + 'pageNumber': 1, + 'attribute': json.dumps([{'name': "phone", 'operator': "contain", 'value': wati_history.wa_id}]), } + wati_contacts = wati_api.http_get('/api/v1/getContacts', params) - if wati_contacts['result'] != 'success': + + if wati_contacts.get('result') != 'success': return - json_dump = json.dumps(wati_contacts, indent=4, sort_keys=True) - contact_list = json.loads(json_dump)['contact_list'] + + contact_list = wati_contacts.get('contact_list', []) + perusahaan = email = '' for data in contact_list: - custom_params = data['customParams'] + custom_params = data.get('customParams', []) for custom_param in custom_params: - name = custom_param['name'] - value = custom_param['value'] + name = custom_param.get('name') + value = custom_param.get('value') if name == 'perusahaan': perusahaan = value elif name == 'email': email = value - # end for 2 - # end for 1 + # End inner loop + + # Update wati_history fields wati_history.perusahaan = perusahaan wati_history.email = email wati_history.is_get_attribute = True -- cgit v1.2.3 From a9afcfa5b6c6e071aefe708b865b37124ba54d1f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 6 Nov 2024 14:11:52 +0700 Subject: add image mobile to solr --- indoteknik_custom/models/solr/product_product.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 7c10a910..dd1d40f6 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -67,6 +67,7 @@ class ProductProduct(models.Model): 'product_id_i': variant.id, 'template_id_i': variant.product_tmpl_id.id, 'image_s': ir_attachment.api_image('product.template', 'image_512', variant.product_tmpl_id.id), + 'image_mobile_s': ir_attachment.api_image('product.template', 'image_256', variant.product_tmpl_id.id), 'stock_total_f': variant.qty_stock_vendor, 'weight_f': variant.weight, 'manufacture_id_i': variant.product_tmpl_id.x_manufacture.id or 0, -- cgit v1.2.3 From 295088070b43c409c2114a0a98d898ff3ff4ae7b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 6 Nov 2024 14:47:19 +0700 Subject: cr solr product --- indoteknik_custom/models/solr/product_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 1d54cc9b..87e8370f 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -91,6 +91,7 @@ class ProductTemplate(models.Model): "product_rating_f": template.virtual_rating, "product_id_i": template.id, "image_s": self.env['ir.attachment'].api_image('product.template', 'image_512', template.id), + 'image_mobile_s': self.env['ir.attachment'].api_image('product.template', 'image_256', template.id), "variant_total_i": template.product_variant_count, "stock_total_f": template.qty_stock_vendor, "weight_f": template.weight, -- cgit v1.2.3 From 3b1c519848d69709aa64ff6078c7d2d45dc356b1 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Wed, 6 Nov 2024 16:46:40 +0700 Subject: bugfix date time --- indoteknik_api/controllers/api_v1/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/stock_picking.py b/indoteknik_api/controllers/api_v1/stock_picking.py index f0c7456d..ea8c6400 100644 --- a/indoteknik_api/controllers/api_v1/stock_picking.py +++ b/indoteknik_api/controllers/api_v1/stock_picking.py @@ -123,7 +123,7 @@ class StockPicking(controller.Controller): params = {'sj_documentation': sj_document, 'paket_documentation': paket_document, - 'driver_arrival_date': self.time_to_str(datetime.utcnow(), '%Y-%m-%d %H:%M:%S'), + 'driver_arrival_date': datetime.utcnow(), } picking_data = request.env['stock.picking'].search([('picking_code', '=', picking_code)], limit=1) -- cgit v1.2.3 From 8b54606ef925ff2e6feb2794aabaafa4864e6961 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 6 Nov 2024 17:00:48 +0700 Subject: initial commit max plafon qty order --- indoteknik_custom/models/product_template.py | 25 +++++++++++++++++++++++-- indoteknik_custom/models/purchase_order.py | 11 ++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 2ca4925b..35844c22 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -374,6 +374,8 @@ class ProductProduct(models.Model): is_edited = fields.Boolean(string='Is Edited') qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') short_spesification = fields.Char(string='Short Spesification') + max_qty_reorder = fields.Float(string='Max Qty Reorder', compute='_get_max_qty_reordering_rule') + plafon_qty = fields.Float(string='Max Plafon', compute='_get_plafon_qty_product') def _get_clean_website_description(self): for rec in self: @@ -487,13 +489,32 @@ class ProductProduct(models.Model): def _get_qty_available_bandengan(self): for product in self: qty_available = product.qty_incoming_bandengan + product.qty_onhand_bandengan - product.qty_outgoing_bandengan - product.qty_available_bandengan = qty_available + product.qty_available_bandengan = qty_available or 0 def _get_qty_free_bandengan(self): for product in self: qty_free = product.qty_onhand_bandengan - product.qty_outgoing_bandengan product.qty_free_bandengan = qty_free - + + def _get_max_qty_reordering_rule(self): + for product in self: + reordering = self.env['stock.warehouse.orderpoint'].search([ + ('product_id', '=', product.id) + ], limit=1) + if not reordering: + product.max_qty_reorder = 0 + else: + product.max_qty_reorder = reordering.product_max_qty + test = reordering.product_max_qty + print(test) + + def _get_plafon_qty_product(self): + for product in self: + qty_available = product.qty_available_bandengan + max_qty = product.max_qty_reorder + product.plafon_qty = max_qty - qty_available + + # def write(self, vals): # if 'solr_flag' not in vals: # for variant in self: diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 6fc0c497..510695a6 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -583,6 +583,14 @@ class PurchaseOrder(models.Model): picking.scheduled_date = self.date_planned picking.date_deadline = self.date_planned + def _check_qty_plafon_product(self): + for line in self.order_line: + if not line.product_id: + continue + test = line.product_id.plafon_qty + if line.product_uom_qty > line.product_id.plafon_qty: + raise UserError('Product '+line.product_id.name+' melebihi plafon') + def button_confirm(self): res = super(PurchaseOrder, self).button_confirm() current_time = datetime.now() @@ -635,7 +643,8 @@ class PurchaseOrder(models.Model): self.date_planned = delta_time self.date_deadline_ref_date_planned() self.unlink_purchasing_job_state() - + + self._check_qty_plafon_product() return res -- cgit v1.2.3 From ca625dc60de8bbf53e21326abc24c210ea0f8f71 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 7 Nov 2024 11:51:13 +0700 Subject: cr archive and unpublished product variant --- indoteknik_custom/models/product_template.py | 49 ++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 2ca4925b..e64b63d7 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -389,23 +389,46 @@ class ProductProduct(models.Model): @api.constrains('active') def archive_product(self): for product in self: + if self.env.context.get('skip_unpublished_constraint'): + continue # Mencegah looping saat dipanggil dari metode lain + product_template = product.product_tmpl_id variants = product_template.product_variant_ids - if product_template.active and product.active: - if not product.active and len(variants) == 1: - product_template.with_context(skip_active_constraint=True).active = False - product_template.unpublished = True - elif not product.active and len(variants) > 1: + if len(variants) == 1: + # Jika hanya ada satu varian, atur status `unpublished` berdasarkan `active` + product_template.with_context(skip_unpublished_constraint=True).unpublished = not product.active + product.with_context(skip_unpublished_constraint=True).unpublished = not product.active + else: + if product.active: + product.with_context(skip_unpublished_constraint=True).unpublished = False + product_template.with_context(skip_unpublished_constraint=True).unpublished = any(variant.active for variant in variants) + else: + product.with_context(skip_unpublished_constraint=True).unpublished = True all_inactive = all(not variant.active for variant in variants) - if all_inactive: - product_template.with_context(skip_active_constraint=True).active = False - product_template.unpublished = True - else: - continue - if any(variant.active for variant in variants): - product_template.unpublished = False - variants.unpublished = False + product_template.with_context(skip_unpublished_constraint=True).unpublished = all_inactive + + @api.constrains('unpublished') + def archive_product_unpublished(self): + for product in self: + if self.env.context.get('skip_active_constraint'): + continue # Mencegah looping saat dipanggil dari metode lain + + product_template = product.product_tmpl_id + variants = product_template.product_variant_ids + + if len(variants) == 1: + # Jika hanya ada satu varian, atur status `unpublished` pada template, tetapi biarkan `active` tetap True + product_template.with_context(skip_active_constraint=True).unpublished = product.unpublished + else: + if not product.unpublished: + # Jika `unpublished` adalah False, pastikan `active` tetap True + product.with_context(skip_active_constraint=True).active = True + product_template.with_context(skip_active_constraint=True).active = any(not variant.unpublished for variant in variants) + else: + # Jika `unpublished` adalah True, atur template hanya jika semua varian di-unpublished + all_unpublished = all(variant.unpublished for variant in variants) + product_template.with_context(skip_active_constraint=True).active = not all_unpublished def update_internal_reference_variants(self, limit=100): variants = self.env['product.product'].search([ -- cgit v1.2.3 From 0e87cd50902756c86c975505a7dde2239d94968c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 7 Nov 2024 13:47:35 +0700 Subject: bug fix wrong price in website user cart --- indoteknik_custom/models/website_user_cart.py | 41 +++++++++------------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index fbcb0aa4..2142dada 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -93,45 +93,32 @@ class WebsiteUserCart(models.Model): def get_product_by_user(self, user_id, selected=False, source=False): user_id = int(user_id) - + if source == 'buy': source = ['buy'] else: source = ['add_to_cart', 'buy'] parameters = [ - ('user_id', '=', user_id), + ('user_id', '=', user_id), ('source', 'in', source) ] - - if selected: - parameters.append(('is_selected', '=', True)) - carts = self.search(parameters) - products_active = [] - products_inactive = [] + for cart in carts: if cart.product_id: price = cart.product_id._v2_get_website_price_include_tax() - if cart.product_id.active and price > 0: - product = cart.with_context(price_for="web").get_products() - for product_active in product: - products_active.append(product_active) - else: - product_inactives = cart.with_context(price_for="web").get_products() - for inactives in product_inactives: - products_inactive.append(inactives) - else: - program = cart.with_context(price_for="web").get_products() - for programs in program: - products_active.append(programs) - data = { - 'product_total': self.search_count(parameters), - 'products': products_active, - 'products_inactive': products_inactive - } - products = carts.get_products() - return products_active + if not cart.product_id.active and price < 1: + cart.is_selected = False + + if selected: + parameters.append(('is_selected', '=', True)) + + products_active = self.search(parameters) + + products = products_active.get_products() + + return products def get_user_checkout(self, user_id, voucher=False, voucher_shipping=False, source=False): products = self.get_product_by_user(user_id=user_id, selected=True, source=source) -- cgit v1.2.3 From 779002da16637df255b7f8ead65ccb49078d6190 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 7 Nov 2024 13:57:38 +0700 Subject: bf --- indoteknik_custom/models/website_user_cart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 2142dada..6cb282f8 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -108,7 +108,7 @@ class WebsiteUserCart(models.Model): for cart in carts: if cart.product_id: price = cart.product_id._v2_get_website_price_include_tax() - if not cart.product_id.active and price < 1: + if not cart.product_id.active or price < 1: cart.is_selected = False if selected: -- cgit v1.2.3 From f787f06a341f1775151d98be4490fe6126c511cd Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 7 Nov 2024 15:59:57 +0700 Subject: excelude incoming --- indoteknik_custom/models/product_template.py | 12 ++++++++++-- indoteknik_custom/models/purchase_order.py | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 35844c22..d3343e75 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -466,6 +466,16 @@ class ProductProduct(models.Model): qty = sum(qty_incoming.mapped('product_uom_qty')) product.qty_incoming_bandengan = qty + def _get_qty_incoming_bandengan_with_exclude(self): + for product in self: + qty_incoming = self.env['stock.move'].search([ + ('product_id', '=', product.id), + ('location_dest_id', 'in', [57, 83]), + ('state', 'not in', ['done', 'cancel']) + ]) + qty = sum(qty_incoming.mapped('product_uom_qty')) + product.qty_incoming_bandengan = qty + def _get_qty_outgoing_bandengan(self): for product in self: qty_incoming = self.env['stock.move'].search([ @@ -505,8 +515,6 @@ class ProductProduct(models.Model): product.max_qty_reorder = 0 else: product.max_qty_reorder = reordering.product_max_qty - test = reordering.product_max_qty - print(test) def _get_plafon_qty_product(self): for product in self: diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 510695a6..231acb4c 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -72,6 +72,8 @@ class PurchaseOrder(models.Model): grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') total_margin_match = fields.Float(string='Total Margin Match', compute='_compute_total_margin_match') approve_by = fields.Many2one('res.users', string='Approve By') + exclude_incoming = fields.Boolean(string='Exclude Incoming', default=False, + help='Centang jika tidak mau masuk perhitungan Incoming Qty') def _compute_total_margin_match(self): for purchase in self: -- cgit v1.2.3 From 9c54bae83c5fc50d2ca894a7e75d9beb156d3e9c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 7 Nov 2024 16:13:00 +0700 Subject: must link with matches so if want to skip approval --- indoteknik_custom/models/purchase_order.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 6fc0c497..ef86bc61 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -595,7 +595,7 @@ class PurchaseOrder(models.Model): if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader: raise UserError("Beda Margin dengan Sales, harus approval Merchandise") if not self.from_apo: - if not self.sale_order_id and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader: + if not self.matches_so and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader: raise UserError("Tidak ada link dengan SO, harus approval Merchandise") send_email = False @@ -727,7 +727,7 @@ class PurchaseOrder(models.Model): raise UserError("Hanya Merchandiser yang bisa approve") if self.env.user.is_leader or self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): raise UserError("Bisa langsung Confirm") - elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id: + elif self.total_percent_margin == self.total_so_percent_margin and self.matches_so: raise UserError("Bisa langsung Confirm") else: reason = '' @@ -736,12 +736,14 @@ class PurchaseOrder(models.Model): reason = 'above 50jt, ' if self.total_percent_margin < self.total_so_percent_margin: reason += 'diff margin, ' - if not self.from_apo and not self.sale_order_id: - reason += 'not link with sales, ' + if not self.from_apo and not self.matches_so: + reason += 'not link with pj and reorder, ' + if not self.matches_so: + reason += 'not link with so, ' # Post a highlighted message to lognote self.message_post( body=f"
" - f"Note Return (Pinned):
{reason}
", + f"Note (Pinned):
{reason}", subtype_id=self.env.ref("mail.mt_note").id ) -- cgit v1.2.3 From 8d4ba8a22aa90a7c2dfad48c5de38ee17b68db60 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 7 Nov 2024 16:21:20 +0700 Subject: deactivate function constrains driver departure date date doc kirim --- indoteknik_custom/models/stock_picking.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 4c9d7658..a4031d52 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -192,9 +192,9 @@ class StockPicking(models.Model): else: raise UserError(f"Error saat mengirim ke Biteship: {response.content}") - @api.constrains('driver_departure_date') - def constrains_driver_departure_date(self): - self.date_doc_kirim = self.driver_departure_date + # @api.constrains('driver_departure_date') + # def constrains_driver_departure_date(self): + # self.date_doc_kirim = self.driver_departure_date @api.constrains('arrival_time') def constrains_arrival_time(self): -- cgit v1.2.3 From 02e7b5f913c4f740124d28c078c4f6f1185d9b0f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 8 Nov 2024 11:12:06 +0700 Subject: cr sj return date do --- indoteknik_custom/models/delivery_order.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/delivery_order.py b/indoteknik_custom/models/delivery_order.py index 2ed49a54..3473197b 100644 --- a/indoteknik_custom/models/delivery_order.py +++ b/indoteknik_custom/models/delivery_order.py @@ -33,11 +33,13 @@ class DeliveryOrder(models.TransientModel): picking.driver_id = self.env.uid picking.delivery_tracking_no = line_tracking_no + if picking.driver_departure_date: + picking.sj_return_date = datetime.utcnow() + delivery_type = self.env['delivery.order.line'].get_delivery_type(picking.driver_departure_date, picking.driver_arrival_date) if delivery_type == 'departure': picking.driver_departure_date = current_time elif delivery_type == 'arrival': - picking.sj_return_date = datetime.utcnow() sale_order = False if picking.origin: -- cgit v1.2.3 From 1d7d90b35078c82ed1904bfb4486e172488bf747 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 8 Nov 2024 14:08:10 +0700 Subject: cr function state reserve transfer --- indoteknik_custom/models/stock_picking.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index a4031d52..1906dae0 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -246,25 +246,22 @@ class StockPicking(models.Model): # break def check_state_reserve(self): - picking = self.search([ + pickings = self.search([ ('state', 'not in', ['cancel', 'draft', 'done']), ('picking_type_code', '=', 'outgoing') - ]) + ]) - for data in picking: - fullfilment = self.env['sales.order.fullfillment'].search([ - ('sales_order_id', '=', data.sale_id.id) + for picking in pickings: + fullfillments = self.env['sales.order.fullfillment'].search([ + ('sales_order_id', '=', picking.sale_id.id) ]) - - data.state_reserve = 'ready' - if not data.date_reserved: - data.date_reserved = datetime.datetime.utcnow() - - for rec in fullfilment: - if rec.reserved_from not in ['Inventory On Hand', 'Reserved from stock', 'Free Stock']: - data.state_reserve = 'waiting' - data.date_reserved = '' - break + + 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): + picking.state_reserve = 'waiting' + picking.date_reserved = '' def _create_approval_notification(self, approval_role): title = 'Warning' -- cgit v1.2.3 From 8423e5b2facd32aec17ac67d95ffc83e7bc311b7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 8 Nov 2024 15:39:37 +0700 Subject: cr vendor approval --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 8e170b1c..5545e28c 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -78,7 +78,7 @@ class SaleOrder(models.Model): 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') payment_qr_code = fields.Binary("Payment QR Code") due_id = fields.Many2one('due.extension', string="Due Extension", readonly=True, tracking=True) - vendor_approval_id = fields.Many2one('vendor.approval', string="Vendor Approval", readonly=True, tracking=True) + vendor_approval_id = fields.Many2one('vendor.approval', string="Vendor Approval", readonly=True, tracking=True, copy=False) customer_type = fields.Selection([ ('pkp', 'PKP'), ('nonpkp', 'Non PKP') -- cgit v1.2.3 From 5a53288558a0adf7bff223f745be75cf48cb252f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 8 Nov 2024 16:16:04 +0700 Subject: fix bug approval date doc --- indoteknik_custom/models/approval_date_doc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/approval_date_doc.py b/indoteknik_custom/models/approval_date_doc.py index 441ada3d..751bae82 100644 --- a/indoteknik_custom/models/approval_date_doc.py +++ b/indoteknik_custom/models/approval_date_doc.py @@ -40,6 +40,7 @@ class ApprovalDateDoc(models.Model): raise UserError("Hanya Accounting Yang Bisa Approve") self.check_invoice_so_picking self.picking_id.driver_departure_date = self.driver_departure_date + self.picking_id.date_doc_kirim = self.driver_departure_date self.state = 'done' self.approve_date = datetime.utcnow() self.approve_by = self.env.user.id -- cgit v1.2.3 From de1fa6223484ea424ae9b6bcf3f3fedf75ae6bb1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 10:11:59 +0700 Subject: fix vendor approval bug --- indoteknik_custom/models/sale_order_line.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 5e01067a..f218757b 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -251,12 +251,9 @@ class SaleOrderLine(models.Model): # purchase_price = self.env['purchase.pricelist'].search( # query, limit=1, order='count_trx_po desc, count_trx_po_vendor desc') price, taxes, vendor_id = self._get_purchase_price(line.product_id) - line.vendor_md_id = vendor_id line.vendor_id = vendor_id - line.margin_md = line.item_percent_margin line.tax_id = line.order_id.sales_tax_id # price, taxes = line._get_valid_purchase_price(purchase_price) - line.purchase_price_md = price line.purchase_price = price line.purchase_tax_id = taxes @@ -270,6 +267,14 @@ class SaleOrderLine(models.Model): line.name = line_name line.weight = line.product_id.weight + @api.constrains('vendor_id') + def _check_vendor_id(self): + for line in self: + price, taxes, vendor_id = self._get_purchase_price(line.product_id) + line.vendor_md_id = vendor_id + line.margin_md = line.item_percent_margin + line.purchase_price_md = price + def compute_delivery_amt_line(self): for line in self: try: -- cgit v1.2.3 From 20060408d381fddf859d3e99ee9dcdd187ac1329 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 10:30:56 +0700 Subject: fix bug --- indoteknik_custom/models/sale_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index f218757b..fe6d9b8c 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -271,7 +271,7 @@ class SaleOrderLine(models.Model): def _check_vendor_id(self): for line in self: price, taxes, vendor_id = self._get_purchase_price(line.product_id) - line.vendor_md_id = vendor_id + line.vendor_md_id = vendor_id if vendor_id else '' line.margin_md = line.item_percent_margin line.purchase_price_md = price -- cgit v1.2.3 From 3404e2526fd4d95fc93224fbcfb5ddbfd254dcb5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 10:37:35 +0700 Subject: fix bug vendor md --- indoteknik_custom/models/sale_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index fe6d9b8c..978b1f69 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -271,7 +271,7 @@ class SaleOrderLine(models.Model): def _check_vendor_id(self): for line in self: price, taxes, vendor_id = self._get_purchase_price(line.product_id) - line.vendor_md_id = vendor_id if vendor_id else '' + line.vendor_md_id = vendor_id if vendor_id else None line.margin_md = line.item_percent_margin line.purchase_price_md = price -- cgit v1.2.3 From 3c5b4bbecca6614c0b6f894e41e9551793957b00 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 13:24:11 +0700 Subject: bug fix match requisition and purchase order --- indoteknik_custom/models/requisition.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index c4104ec5..92b222a8 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -108,6 +108,13 @@ class Requisition(models.Model): 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.env['requisition.purchase.match'].create([{ + 'requisition_id': self.id, + 'order_id': new_po.id + }]) + self.is_po = True + return po_ids # def create_po_from_requisition(self): -- cgit v1.2.3 From c8359019759d78dcddea6d419c4a8f8eebe23c69 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 13:27:04 +0700 Subject: validasi SO harus diisi pada saat create PO di requisition --- indoteknik_custom/models/requisition.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 92b222a8..576857df 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -35,6 +35,8 @@ class Requisition(models.Model): raise UserError('Tidak ada Lines, belum bisa create PO') if self.is_po: raise UserError('Sudah pernah di create PO') + if self.sale_order_id: + raise UserError('Tidak ada link dengan Sales Order, tidak bisa dihitung sebagai Plafon Qty di PO') vendor_ids = self.env['requisition.line'].read_group([ ('requisition_id', '=', self.id), -- cgit v1.2.3 From 1bb2d9edb764ee3de50b0a005ff40aeef60bf5d6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 13:38:49 +0700 Subject: add approval sales manager and marketing manager on rpo --- indoteknik_custom/models/requisition.py | 16 ++++++++++++++++ indoteknik_custom/views/requisition.xml | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index c4104ec5..a90a5718 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -22,15 +22,31 @@ class Requisition(models.Model): requisition_match = fields.One2many('requisition.purchase.match', 'requisition_id', string='Matches', auto_join=True) sale_order_id = fields.Many2one('sale.order', string='SO', help='harus diisi nomor SO yang ingin digenerate', domain="[('state', '=', 'sale')]") + sales_approve = fields.Boolean(string='Sales Approve', tracking=3, copy=False) + merchandise_approve = fields.Boolean(string='Merchandise Approve', tracking=3, copy=False) @api.model def create(self, vals): vals['number'] = self.env['ir.sequence'].next_by_code('requisition') or '0' result = super(Requisition, self).create(vals) return result + + def button_approve(self): + if self.env.user.id not in [377, 19]: + raise UserError('Hanya Vita dan Darren Yang Bisa Approve') + if self.env.user.id == 377: + self.sales_approve = True + elif self.env.user.id == 19: + if not self.sales_approve: + raise UserError('Vita Belum Approve') + self.merchandise_approve = True def create_po_from_requisition(self): + if not self.sales_approve: + raise UserError('Harus Di Approve oleh Vita') + if not self.merchandise_approve: + raise UserError('Harus Di Approve oleh Darren') if not self.requisition_lines: raise UserError('Tidak ada Lines, belum bisa create PO') if self.is_po: diff --git a/indoteknik_custom/views/requisition.xml b/indoteknik_custom/views/requisition.xml index b704baaf..cc537eda 100644 --- a/indoteknik_custom/views/requisition.xml +++ b/indoteknik_custom/views/requisition.xml @@ -50,6 +50,13 @@ requisition
+
+
-- cgit v1.2.3 From beefbce9a41d0210582cf8ceb6e4e7a6a5bc8fef Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 13:41:46 +0700 Subject: add view of requisition match po --- indoteknik_custom/models/requisition.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 576857df..e5053d34 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -1,4 +1,4 @@ -from odoo import models, fields, api, _ +from odoo import models, fields, api, tools, _ from odoo.exceptions import UserError from datetime import datetime import math @@ -7,6 +7,30 @@ import logging _logger = logging.getLogger(__name__) +class RequisitionMatchPO(models.Model): + _name = 'v.requisition.match.po' + _auto = False + _rec_name = 'purchase_id' + + id = fields.Integer(string='ID') + requisition_id = fields.Many2one('requisition', string='Requisition') + line_id = fields.Many2one('requisition.line', string='Requisition Line') + product_id = fields.Many2one('product.product', string='Product') + partner_id = fields.Many2one('res.partner', string='Partner') + purchase_id = fields.Many2one('purchase.order', string='Purchase Order') + + def init(self): + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" + create or replace view %s as + select rpm.id as id, r.id as requisition_id, rl.id as line_id, rl.product_id, rl.partner_id, + rpm.order_id as purchase_id + from requisition_line rl + join requisition r on r.id = rl.requisition_id + join requisition_purchase_match rpm on rpm.requisition_id = r.id + """ % self._table) + + class Requisition(models.Model): _name = 'requisition' _order = 'id desc' -- cgit v1.2.3 From 03e9f9e8997836e37a5ab38798edb310ce6a6c76 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 13:43:48 +0700 Subject: add sale order --- indoteknik_custom/models/requisition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index e5053d34..68c57e4c 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -24,7 +24,7 @@ class RequisitionMatchPO(models.Model): self.env.cr.execute(""" create or replace view %s as select rpm.id as id, r.id as requisition_id, rl.id as line_id, rl.product_id, rl.partner_id, - rpm.order_id as purchase_id + rpm.order_id as purchase_id, r.sale_order_id as sale_id from requisition_line rl join requisition r on r.id = rl.requisition_id join requisition_purchase_match rpm on rpm.requisition_id = r.id -- cgit v1.2.3 From e40f5a21ec251363b3b71d81b7801a782716ca0a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 13:43:58 +0700 Subject: add approval sales manager and marketing manager on rpo --- indoteknik_custom/models/requisition.py | 17 ++++++++++++++++- indoteknik_custom/views/requisition.xml | 7 +++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index c4104ec5..e09c9e41 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -22,15 +22,30 @@ class Requisition(models.Model): requisition_match = fields.One2many('requisition.purchase.match', 'requisition_id', string='Matches', auto_join=True) sale_order_id = fields.Many2one('sale.order', string='SO', help='harus diisi nomor SO yang ingin digenerate', domain="[('state', '=', 'sale')]") + sales_approve = fields.Boolean(string='Sales Approve', tracking=3, copy=False) + merchandise_approve = fields.Boolean(string='Merchandise Approve', tracking=3, copy=False) @api.model def create(self, vals): vals['number'] = self.env['ir.sequence'].next_by_code('requisition') or '0' result = super(Requisition, self).create(vals) return result - + + def button_approve(self): + if self.env.user.id not in [377, 19]: + raise UserError('Hanya Vita dan Darren Yang Bisa Approve') + if self.env.user.id == 377: + self.sales_approve = True + elif self.env.user.id == 19: + if not self.sales_approve: + raise UserError('Vita Belum Approve') + self.merchandise_approve = True def create_po_from_requisition(self): + if not self.sales_approve: + raise UserError('Harus di Approve Vita') + if not self.merchandise_approve: + raise UserError('Harus di Approve Darren') if not self.requisition_lines: raise UserError('Tidak ada Lines, belum bisa create PO') if self.is_po: diff --git a/indoteknik_custom/views/requisition.xml b/indoteknik_custom/views/requisition.xml index b704baaf..a866690d 100644 --- a/indoteknik_custom/views/requisition.xml +++ b/indoteknik_custom/views/requisition.xml @@ -50,6 +50,13 @@ requisition +
+
-- cgit v1.2.3 From e573a766b997e4dc60935f8cc87e887d09f64b7a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 13:53:22 +0700 Subject: add sale order condition in match requisition --- indoteknik_custom/models/requisition.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 68c57e4c..583a25c4 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -28,6 +28,11 @@ class RequisitionMatchPO(models.Model): from requisition_line rl join requisition r on r.id = rl.requisition_id join requisition_purchase_match rpm on rpm.requisition_id = r.id + join purchase_order po on po.id = rpm.order_id + join sale_order so on so.id = r.sale_order_id + where r.date_doc >= '2024-11-11' + and po.state in ('done', 'purchase') + and so.state in ('draft', 'sent') """ % self._table) -- cgit v1.2.3 From 9a0fd25e54491bd14a5b29b62b31a440dfa1bebc Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 14:10:13 +0700 Subject: change view requisition match --- indoteknik_custom/models/requisition.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 0ab78530..704ae8c0 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -13,26 +13,24 @@ class RequisitionMatchPO(models.Model): _rec_name = 'purchase_id' id = fields.Integer(string='ID') - requisition_id = fields.Many2one('requisition', string='Requisition') - line_id = fields.Many2one('requisition.line', string='Requisition Line') product_id = fields.Many2one('product.product', string='Product') - partner_id = fields.Many2one('res.partner', string='Partner') - purchase_id = fields.Many2one('purchase.order', string='Purchase Order') + qty_rpo = fields.Float(string='Qty RPO', help='Qty RPO yang sudah di PO namun SO masih Draft') def init(self): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" create or replace view %s as - select rpm.id as id, r.id as requisition_id, rl.id as line_id, rl.product_id, rl.partner_id, - rpm.order_id as purchase_id, r.sale_order_id as sale_id + select rl.product_id as id, rl.product_id, sum(rl.qty_purchase) as qty_rpo from requisition_line rl join requisition r on r.id = rl.requisition_id join requisition_purchase_match rpm on rpm.requisition_id = r.id join purchase_order po on po.id = rpm.order_id join sale_order so on so.id = r.sale_order_id - where r.date_doc >= '2024-11-11' + where 1=1 + and r.date_doc >= '2024-11-11' and po.state in ('done', 'purchase') and so.state in ('draft', 'sent') + group by rl.product_id """ % self._table) -- cgit v1.2.3 From ad4c738cb9a03f96cd4d7035ec13cafe4763e233 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 14:38:05 +0700 Subject: add qty rpo on plafon qty --- indoteknik_custom/models/product_template.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 3bb06eaf..25473ab8 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -375,6 +375,7 @@ class ProductProduct(models.Model): qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') short_spesification = fields.Char(string='Short Spesification') max_qty_reorder = fields.Float(string='Max Qty Reorder', compute='_get_max_qty_reordering_rule') + qty_rpo = fields.Float(string='Qty RPO', compute='_get_qty_rpo') plafon_qty = fields.Float(string='Max Plafon', compute='_get_plafon_qty_product') def _get_clean_website_description(self): @@ -539,11 +540,22 @@ class ProductProduct(models.Model): else: product.max_qty_reorder = reordering.product_max_qty + def _get_qty_rpo(self): + for product in self: + rpo = self.env['v.requisition.match.po'].search([ + ('product_id', '=', product.id) + ], limit=1) + if not rpo: + product.qty_rpo = 0 + else: + product.qty_rpo = rpo.qty_rpo + def _get_plafon_qty_product(self): for product in self: qty_available = product.qty_available_bandengan max_qty = product.max_qty_reorder - product.plafon_qty = max_qty - qty_available + qty_rpo = product.qty_rpo + product.plafon_qty = max_qty - qty_available + qty_rpo # def write(self, vals): -- cgit v1.2.3 From 17d46cf9f4eede8177b2373c03d5b36123f712c1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 14:39:26 +0700 Subject: change rec name view match requisition --- indoteknik_custom/models/requisition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 704ae8c0..3d9ca876 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -10,7 +10,7 @@ _logger = logging.getLogger(__name__) class RequisitionMatchPO(models.Model): _name = 'v.requisition.match.po' _auto = False - _rec_name = 'purchase_id' + _rec_name = 'product_id' id = fields.Integer(string='ID') product_id = fields.Many2one('product.product', string='Product') -- cgit v1.2.3 From 8fd1bb1a05f0b98ca25750abb2f75c13e44b623e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 15:24:05 +0700 Subject: add view xml product --- indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/product_product.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 553047e6..28794f41 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -143,3 +143,4 @@ access_vendor_approval_line,access.vendor.approval.line,model_vendor_approval_li access_vit_kota,access.vit.kota,model_vit_kota,,1,1,1,1 access_v_brand_product_category,access.v.brand.product.category,model_v_brand_product_category,,1,1,1,1 access_web_find_page,access.web.find.page,model_web_find_page,,1,1,1,1 +access_v_requisition_match_po,access.v.requisition.match.po,model_v_requisition_match_po,,1,1,1,1 diff --git a/indoteknik_custom/views/product_product.xml b/indoteknik_custom/views/product_product.xml index c06cc5f1..71748e44 100644 --- a/indoteknik_custom/views/product_product.xml +++ b/indoteknik_custom/views/product_product.xml @@ -11,11 +11,14 @@ + + + -- cgit v1.2.3 From 98c75272a5ee571de134b8e5746a026f1654ed80 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 11 Nov 2024 15:51:51 +0700 Subject: add message while check plafon qty --- indoteknik_custom/models/purchase_order.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index f5b5979b..a8fd68e9 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -589,9 +589,8 @@ class PurchaseOrder(models.Model): for line in self.order_line: if not line.product_id: continue - test = line.product_id.plafon_qty if line.product_uom_qty > line.product_id.plafon_qty: - raise UserError('Product '+line.product_id.name+' melebihi plafon') + raise UserError('Product '+line.product_id.name+' melebihi plafon, harus Approval MD') def button_confirm(self): res = super(PurchaseOrder, self).button_confirm() @@ -751,6 +750,10 @@ class PurchaseOrder(models.Model): reason += 'not link with pj and reorder, ' if not self.matches_so: reason += 'not link with so, ' + # Check Plafon Qty and Get Message every Line Product + greater_than_plafon, message = self._get_msg_plafon_qty() + if greater_than_plafon: + reason += message # Post a highlighted message to lognote self.message_post( body=f"
" @@ -758,6 +761,20 @@ class PurchaseOrder(models.Model): subtype_id=self.env.ref("mail.mt_note").id ) + def _get_msg_plafon_qty(self): + message = '' + greater_than_plafon = False + for line in self.order_line: + if not line.product_id: + continue + if line.product_uom_qty > line.product_id.plafon_qty: + message = (message + line.product_id.default_code + 'melebihi plafon ' + + str(line.product_uom_qty) + ' vs ' + str(line.product_id.plafon_qty) + + ', ') + greater_than_plafon = True + print(1) + return greater_than_plafon, message + def re_calculate(self): if self.from_apo: self.re_calculate_from_apo() -- cgit v1.2.3 From 4be403f544f63a5161275f0d600c6f6950f3a30c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 16:13:27 +0700 Subject: push --- indoteknik_custom/models/approval_retur_picking.py | 16 ++++++------- indoteknik_custom/models/requisition.py | 2 +- indoteknik_custom/models/stock_picking.py | 26 +++++++++++++++++----- indoteknik_custom/views/approval_retur_picking.xml | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/indoteknik_custom/models/approval_retur_picking.py b/indoteknik_custom/models/approval_retur_picking.py index 63639782..34c449a8 100644 --- a/indoteknik_custom/models/approval_retur_picking.py +++ b/indoteknik_custom/models/approval_retur_picking.py @@ -8,7 +8,7 @@ class ApprovalReturPicking(models.TransientModel): _name = 'approval.retur.picking' _description = 'Wizard to add Note Return' - note_return = fields.Text(string="Note Return", required=True) + note_return = fields.Text(string="Note Return") def action_confirm_note_return(self): picking_ids = self._context.get('picking_ids') @@ -16,22 +16,22 @@ class ApprovalReturPicking(models.TransientModel): # Update the note_return field picking.update({ - 'note_return': self.note_return + 'approval_return_status': 'pengajuan1' }) # Post a highlighted message to lognote - picking.message_post( - body=f"
" - f"Note Return (Pinned):
{self.note_return}
", - subtype_id=self.env.ref("mail.mt_note").id - ) + # picking.message_post( + # body=f"
" + # f"Note Return (Pinned):
{self.note_return}
", + # subtype_id=self.env.ref("mail.mt_note").id + # ) return { 'type': 'ir.actions.client', 'tag': 'display_notification', 'params': { 'title': 'Notification', - 'message': 'Note berhasil ditambah', + 'message': 'Status pengajuan telah berubah', 'next': {'type': 'ir.actions.act_window_close'}, } } diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index a90a5718..89ed4a27 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -117,7 +117,7 @@ class Requisition(models.Model): 'product_id': product.id, 'product_qty': line.qty_purchase, 'product_uom_qty': line.qty_purchase, - 'name': product.name, + 'name': product.display_name, 'price_unit': line.price_unit, 'taxes_id': tax, } diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 107a6e72..ad31a2ba 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -445,14 +445,28 @@ class StockPicking(models.Model): if self.env.user.is_accounting: pick.approval_return_status = 'approved' else: - pick.approval_return_status = 'pengajuan1' - action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') - action['context'] = { - 'picking_ids': [x.id for x in self] - } - return action + if self.picking_type_code == 'outgoing': + if self.env.user.id in [3988, 3401, 20]: + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action + else: + raise UserError('Harus Sales Admin yang Ask Return') + elif self.picking_type_code == 'incoming': + if self.env.user.has_group('indoteknik_custom.group_role_purchasing'): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action + else: + raise UserError('Harus Purchasing yang Ask Return') + def calculate_line_no(self): + for picking in self: name = picking.group_id.name for move in picking.move_ids_without_package: diff --git a/indoteknik_custom/views/approval_retur_picking.xml b/indoteknik_custom/views/approval_retur_picking.xml index ebe038d1..5ce28e20 100644 --- a/indoteknik_custom/views/approval_retur_picking.xml +++ b/indoteknik_custom/views/approval_retur_picking.xml @@ -6,7 +6,7 @@ - + Ask Approval Retur?
+
+
-- cgit v1.2.3 From 9f293c1270e29db78ac8542221a4bbe6d208ea8f Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 12 Nov 2024 13:35:24 +0700 Subject: bf plafon --- indoteknik_custom/models/purchase_order.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 9faa6464..d65e1d66 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -589,7 +589,10 @@ class PurchaseOrder(models.Model): for line in self.order_line: if not line.product_id: continue - if line.product_uom_qty > line.product_id.plafon_qty and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): + # test = line.product_uom_qty + # test2 = line.product_id.plafon_qty + # test3 = test2 + line.product_uom_qty + if line.product_uom_qty > line.product_id.plafon_qty + line.product_uom_qty and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): raise UserError('Product '+line.product_id.name+' melebihi plafon, harus Approval MD') def button_confirm(self): @@ -772,7 +775,6 @@ class PurchaseOrder(models.Model): + str(line.product_id.plafon_qty) + ') vs Qty PO ('+str(line.product_uom_qty)+')' + ', ') greater_than_plafon = True - print(1) return greater_than_plafon, message def re_calculate(self): -- cgit v1.2.3 From 537e3afa70512c084516b7c11aef970252d83e58 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 12 Nov 2024 13:41:57 +0700 Subject: bf plafon in po --- indoteknik_custom/models/purchase_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index d65e1d66..3397616d 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -738,9 +738,10 @@ class PurchaseOrder(models.Model): def po_approve(self): # if self.amount_untaxed >= 50000000 and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): # raise UserError("Hanya Merchandiser yang bisa approve") + greater_than_plafon, message = self._get_msg_plafon_qty() if self.env.user.is_leader or self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): raise UserError("Bisa langsung Confirm") - elif self.total_percent_margin == self.total_so_percent_margin and self.matches_so: + elif self.total_percent_margin == self.total_so_percent_margin and self.matches_so and not greater_than_plafon: raise UserError("Bisa langsung Confirm") else: reason = '' @@ -754,7 +755,6 @@ class PurchaseOrder(models.Model): if not self.matches_so: reason += 'not link with so, ' # Check Plafon Qty and Get Message every Line Product - greater_than_plafon, message = self._get_msg_plafon_qty() if greater_than_plafon: reason += message # Post a highlighted message to lognote -- cgit v1.2.3 From a2211259c5bc20fe78b44ae7da60991038919a58 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Nov 2024 14:12:46 +0700 Subject: cr so --- indoteknik_custom/models/sale_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 5545e28c..694624cd 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -482,8 +482,8 @@ class SaleOrder(models.Model): if not real_delivery_address.state_id: raise UserError('State Real Delivery Address harus diisi') - if not real_delivery_address.zip: - raise UserError('Zip code Real Delivery Address harus diisi') + # if not real_delivery_address.zip: + # raise UserError('Zip code Real Delivery Address harus diisi') if not real_delivery_address.mobile: raise UserError('Mobile Real Delivery Address harus diisi') if not real_delivery_address.phone: -- cgit v1.2.3 From bd3826b66e647306b46052375620291e2962ae31 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Nov 2024 14:53:11 +0700 Subject: cr so --- indoteknik_custom/models/sale_order.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 694624cd..39243fc9 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -625,19 +625,19 @@ class SaleOrder(models.Model): # return ['&', ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)] - def check_data_real_delivery_address(self): - real_delivery_address = self.real_shipping_id - - if not real_delivery_address.state_id: - raise UserError('State Real Delivery Address harus diisi') - if not real_delivery_address.zip: - raise UserError('Zip code Real Delivery Address harus diisi') - if not real_delivery_address.mobile: - raise UserError('Mobile Real Delivery Address harus diisi') - if not real_delivery_address.phone: - raise UserError('Phone Real Delivery Address harus diisi') - if not real_delivery_address.kecamatan_id: - raise UserError('Kecamatan Real Delivery Address harus diisi') + # def check_data_real_delivery_address(self): + # real_delivery_address = self.real_shipping_id + + # if not real_delivery_address.state_id: + # raise UserError('State Real Delivery Address harus diisi') + # if not real_delivery_address.zip: + # raise UserError('Zip code Real Delivery Address harus diisi') + # if not real_delivery_address.mobile: + # raise UserError('Mobile Real Delivery Address harus diisi') + # if not real_delivery_address.phone: + # raise UserError('Phone Real Delivery Address harus diisi') + # if not real_delivery_address.kecamatan_id: + # raise UserError('Kecamatan Real Delivery Address harus diisi') @api.onchange('partner_id') def onchange_partner_contact(self): -- cgit v1.2.3 From a3c057d4ddf660ce1214b55c791fd436cc7a6100 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 12 Nov 2024 15:35:12 +0700 Subject: add new table of fulfillment v2 --- indoteknik_custom/models/sales_order_fullfillment.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/indoteknik_custom/models/sales_order_fullfillment.py b/indoteknik_custom/models/sales_order_fullfillment.py index ab416e8d..9e9457f1 100644 --- a/indoteknik_custom/models/sales_order_fullfillment.py +++ b/indoteknik_custom/models/sales_order_fullfillment.py @@ -6,6 +6,22 @@ import logging _logger = logging.getLogger(__name__) +class SalesOrderFullfillmentV2(models.Model): + _name = 'sales.order.fulfillment.v2' + + sale_order_id = fields.Many2one('sale.order', string='Sale Order') + sale_order_line_id = fields.Many2one('sale.order.line', string='Sale Order Line') + picking_id = fields.Many2one('stock.picking', string='Picking') + move_id = fields.Many2one('stock.move', string='Move') + move_line_id = fields.Many2one('stock.move.line', string='Move Line') + product_id = fields.Many2one('product.product', string='Product') + so_qty = fields.Float(string='SO Qty') + reserved_stock_qty = fields.Float(string='Reserved Stock Qty') + po_ids = fields.Many2many('purchase.order', string='Purchase Order') + po_qty = fields.Float(string='PO Qty', help='Totalan dari semua PO Outstanding') + received_qty = fields.Float(string='Received Qty', help='Totalan dari barang yang diterima dari PO tsb') + + class SalesOrderFullfillment(models.Model): _name = 'sales.order.fullfillment' -- cgit v1.2.3 From 08e490b3f6a1dc90ebe8fd39bd9cf5fe64cd64a3 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Nov 2024 16:11:25 +0700 Subject: add attrs to delivery amt sale order --- indoteknik_custom/views/sale_order.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 98001589..88fcd8a1 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -29,7 +29,7 @@ - + -- cgit v1.2.3 From ffec5d50ef5be0bea5dd9a658b54d053ed67344b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Nov 2024 17:15:28 +0700 Subject: cr kelurahan so --- indoteknik_custom/models/sale_order.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 39243fc9..e2399ecc 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -482,16 +482,16 @@ class SaleOrder(models.Model): if not real_delivery_address.state_id: raise UserError('State Real Delivery Address harus diisi') - # if not real_delivery_address.zip: - # raise UserError('Zip code Real Delivery Address harus diisi') + if not real_delivery_address.zip: + raise UserError('Zip code Real Delivery Address harus diisi') if not real_delivery_address.mobile: raise UserError('Mobile Real Delivery Address harus diisi') if not real_delivery_address.phone: raise UserError('Phone Real Delivery Address harus diisi') if not real_delivery_address.kecamatan_id: raise UserError('Kecamatan Real Delivery Address harus diisi') - if not real_delivery_address.kelurahan_id: - raise UserError('Kelurahan Real Delivery Address harus diisi') + # if not real_delivery_address.kelurahan_id: + # raise UserError('Kelurahan Real Delivery Address harus diisi') def generate_payment_link_midtrans_sales_order(self): # midtrans_url = 'https://app.sandbox.midtrans.com/snap/v1/transactions' # dev - sandbox -- cgit v1.2.3 From b44f26591a67b1a33132bcbcb9190920eb52e6f3 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 13 Nov 2024 09:04:27 +0700 Subject: view of fulfillment version 2 --- indoteknik_custom/models/sale_order.py | 9 +++++---- indoteknik_custom/models/sales_order_fullfillment.py | 5 +++-- indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/sale_order.xml | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 5545e28c..31ea8902 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -11,6 +11,7 @@ _logger = logging.getLogger(__name__) class SaleOrder(models.Model): _inherit = "sale.order" + fulfillment_line_v2 = fields.One2many('sales.order.fulfillment.v2', 'sale_order_id', string='Fullfillment2') fullfillment_line = fields.One2many('sales.order.fullfillment', 'sales_order_id', string='Fullfillment') reject_line = fields.One2many('sales.order.reject', 'sale_order_id', string='Reject Lines') 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) @@ -346,10 +347,10 @@ class SaleOrder(models.Model): def _compute_fullfillment(self): for rec in self: - rec.fullfillment_line.unlink() - - for line in rec.order_line: - line._compute_reserved_from() + # rec.fullfillment_line.unlink() + # + # for line in rec.order_line: + # line._compute_reserved_from() rec.compute_fullfillment = True diff --git a/indoteknik_custom/models/sales_order_fullfillment.py b/indoteknik_custom/models/sales_order_fullfillment.py index 9e9457f1..42544c15 100644 --- a/indoteknik_custom/models/sales_order_fullfillment.py +++ b/indoteknik_custom/models/sales_order_fullfillment.py @@ -16,8 +16,9 @@ class SalesOrderFullfillmentV2(models.Model): move_line_id = fields.Many2one('stock.move.line', string='Move Line') product_id = fields.Many2one('product.product', string='Product') so_qty = fields.Float(string='SO Qty') - reserved_stock_qty = fields.Float(string='Reserved Stock Qty') - po_ids = fields.Many2many('purchase.order', string='Purchase Order') + reserved_stock_qty = fields.Float(string='Reserved Stock Qty', help='Sudah ter-reserved oleh sistem') + delivered_qty = fields.Float(string='Delivered Qty', help='Yang sudah terkirim ke Customer') + po_ids = fields.Many2many('purchase.order', string='Purchase Order', help='PO yang dibuat, bisa lebih dari satu') po_qty = fields.Float(string='PO Qty', help='Totalan dari semua PO Outstanding') received_qty = fields.Float(string='Received Qty', help='Totalan dari barang yang diterima dari PO tsb') diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 49b38e6a..e817a28d 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -145,3 +145,4 @@ access_v_brand_product_category,access.v.brand.product.category,model_v_brand_pr access_web_find_page,access.web.find.page,model_web_find_page,,1,1,1,1 access_v_requisition_match_po,access.v.requisition.match.po,model_v_requisition_match_po,,1,1,1,1 access_approval_retur_picking,access.approval.retur.picking,model_approval_retur_picking,,1,1,1,1 +access_sales_order_fulfillment_v2,access.sales.order.fulfillment.v2,model_sales_order_fulfillment_v2,,1,1,1,1 diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 98001589..676a822d 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -227,6 +227,9 @@ + + + @@ -341,6 +344,23 @@ + + + + + sales.order.fulfillment.v2.tree + sales.order.fulfillment.v2 + + + + + + + + + + + sales.order.fullfillment.tree -- cgit v1.2.3 From d71a8ead26eaf1d44da38b94b1a114f97f407bd8 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 13 Nov 2024 09:50:19 +0700 Subject: add po ids in fulfillment v2 --- indoteknik_custom/views/sale_order.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 676a822d..02531966 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -356,6 +356,7 @@ + -- cgit v1.2.3 From 001002a2c56d241cf2340155683f43a8c62ac7b6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 13 Nov 2024 13:30:27 +0700 Subject: add free product to so line when promotion --- indoteknik_api/controllers/api_v1/sale_order.py | 1 + indoteknik_custom/models/promotion/sale_order.py | 10 ++++++++++ indoteknik_custom/models/sale_order.py | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 905795b0..3e182a2e 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -464,6 +464,7 @@ class SaleOrder(controller.Controller): if len(promotions) > 0: sale_order.apply_promotion_program() + sale_order.add_free_product(promotions) voucher_code = params['value']['voucher'] voucher = request.env['voucher'].search([('code', '=', voucher_code),('apply_type', 'in', ['all', 'brand'])], limit=1) diff --git a/indoteknik_custom/models/promotion/sale_order.py b/indoteknik_custom/models/promotion/sale_order.py index cb9a6f92..be820c6f 100644 --- a/indoteknik_custom/models/promotion/sale_order.py +++ b/indoteknik_custom/models/promotion/sale_order.py @@ -6,6 +6,16 @@ class SaleOrder(models.Model): order_promotion_ids = fields.One2many('sale.order.promotion', 'order_id', 'Promotions') + def add_free_product(self, promotions): + for promotion in promotions: + program_line = self.env['promotion.program.line'].browse(promotion['program_line_id']) + for free_product in program_line.free_product_ids: + self.env['sale.order.line'].create({ + 'order_id': self.id, + 'name': "Free Product " + free_product.product_id.display_name, + 'display_type': 'line_note' + }) + def apply_promotion_program(self): userdata = { 'user_id': self.partner_id.user_id.id, diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index e2399ecc..a0d70059 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -148,7 +148,7 @@ class SaleOrder(models.Model): missing_weight_products = [] for line in self.order_line: - if line.weight: + if line.weight > 0: total_weight += line.weight * line.product_uom_qty self.total_weight = total_weight @@ -161,7 +161,7 @@ class SaleOrder(models.Model): missing_weight_products = [] for line in self.order_line: - if line.weight: + if line.weight > 0: total_weight += line.weight * line.product_uom_qty line.product_id.weight = line.weight else: @@ -186,7 +186,7 @@ class SaleOrder(models.Model): missing_weight_products = [] for line in self.order_line: - if line.weight: + if line.weight > 0: total_weight += line.weight * line.product_uom_qty line.product_id.weight = line.weight else: -- cgit v1.2.3 From 7dd310eed8f726982e3df3934d85e844b14526c3 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 13 Nov 2024 13:35:16 +0700 Subject: update set parent berdasarkan vals company id --- indoteknik_custom/models/user_company_request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index 86e66934..dd9a35c1 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -74,7 +74,7 @@ class UserCompanyRequest(models.Model): if not self.is_approve and is_approve: if is_approve == 'approved': - self.user_id.parent_id = self.user_company_id.id + self.user_id.parent_id = vals.get('user_company_id') if vals.get('user_company_id') else self.user_company_id.id self.user_id.customer_type = self.user_company_id.customer_type self.user_id.npwp = self.user_company_id.npwp self.user_id.sppkp = self.user_company_id.sppkp -- cgit v1.2.3 From 770c6506de7ba5b1a3430695298f1001f6e9d48e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 13 Nov 2024 14:20:07 +0700 Subject: add purchaser in fulfillment v2 --- indoteknik_custom/models/sales_order_fullfillment.py | 1 + indoteknik_custom/views/sale_order.xml | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/sales_order_fullfillment.py b/indoteknik_custom/models/sales_order_fullfillment.py index 42544c15..05a0641c 100644 --- a/indoteknik_custom/models/sales_order_fullfillment.py +++ b/indoteknik_custom/models/sales_order_fullfillment.py @@ -21,6 +21,7 @@ class SalesOrderFullfillmentV2(models.Model): po_ids = fields.Many2many('purchase.order', string='Purchase Order', help='PO yang dibuat, bisa lebih dari satu') po_qty = fields.Float(string='PO Qty', help='Totalan dari semua PO Outstanding') received_qty = fields.Float(string='Received Qty', help='Totalan dari barang yang diterima dari PO tsb') + purchaser = fields.Char(string='Purchaser') class SalesOrderFullfillment(models.Model): diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index ca27c2ed..7b8af971 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -353,12 +353,13 @@ - - + + - - - + + + + -- cgit v1.2.3 From 405da89e61fc9d1278d37fbd9793f5578992f1c1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 13 Nov 2024 15:10:28 +0700 Subject: delivery amt cr --- indoteknik_custom/views/sale_order.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index ca27c2ed..02531966 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -29,7 +29,7 @@ - + -- cgit v1.2.3 From 68998f5a42a0740060d74107d108181b1dfcfb2d Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 13 Nov 2024 15:34:00 +0700 Subject: comment fulfillment v1 --- .../models/report_stock_forecasted.py | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/indoteknik_custom/models/report_stock_forecasted.py b/indoteknik_custom/models/report_stock_forecasted.py index ebdc7d4a..c9d54a15 100644 --- a/indoteknik_custom/models/report_stock_forecasted.py +++ b/indoteknik_custom/models/report_stock_forecasted.py @@ -6,33 +6,33 @@ class ReplenishmentReport(models.AbstractModel): @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, - }) + # 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): -- cgit v1.2.3