From 9365e1bb72a34eb17cbb25536d9e2dbb843e7fe8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 14 Nov 2024 10:05:08 +0700 Subject: note so line on stock picking --- indoteknik_custom/models/sale_order.py | 28 ++++++++++++---------------- indoteknik_custom/models/sale_order_line.py | 2 +- indoteknik_custom/models/stock_picking.py | 1 + indoteknik_custom/views/stock_picking.xml | 1 + 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 75332996..e90ca995 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -491,8 +491,8 @@ class SaleOrder(models.Model): 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 @@ -626,20 +626,6 @@ 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') - @api.onchange('partner_id') def onchange_partner_contact(self): parent_id = self.partner_id.parent_id @@ -980,6 +966,16 @@ class SaleOrder(models.Model): # order.order_line.get_reserved_from() res = super(SaleOrder, self).action_confirm() + for order in self: + note = [] + for line in order.order_line: + if line.display_type == 'line_note': + note.append(line.name) + + if order.picking_ids: + # Sort picking_ids by date and get the most recent one + latest_picking = order.picking_ids.sorted(key=lambda p: p.scheduled_date, reverse=True)[0] + latest_picking.notee = '\n'.join(note) return res def action_cancel(self): diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 5a6640ec..f4469117 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -372,5 +372,5 @@ class SaleOrderLine(models.Model): continue if not line.product_id.product_tmpl_id.sale_ok: raise UserError('Product %s belum bisa dijual, harap hubungi finance' % line.product_id.display_name) - if not line.vendor_id or not line.purchase_price: + if not line.vendor_id or not line.purchase_price and not line.display_type == 'line_note': raise UserError(_('Isi Vendor dan Harga Beli sebelum Request Approval')) \ No newline at end of file diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 50e9304b..ee1dd68c 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -112,6 +112,7 @@ class StockPicking(models.Model): ('done', 'Done'), ('cancel', 'Cancelled'), ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.") + notee = fields.Text(string="Note") def action_send_to_biteship(self): url = "https://api.biteship.com/v1/orders" diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index c230bc7b..1893fcaf 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -129,6 +129,7 @@ + -- cgit v1.2.3 From f6df2ccfde5b45d018c8d7b11203429b5f39ebfc Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 14 Nov 2024 10:39:36 +0700 Subject: make default AR AP in contact --- indoteknik_custom/models/res_partner.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index b01c7984..9108707d 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -10,6 +10,16 @@ class GroupPartner(models.Model): class ResPartner(models.Model): _inherit = 'res.partner' + property_account_payable_id = fields.Many2one('account.account', company_dependent=True, + string="Account Payable", + domain="[('internal_type', '=', 'payable'), ('deprecated', '=', False), ('company_id', '=', current_company_id)]", + help="This account will be used instead of the default one as the payable account for the current partner", + default=438) + property_account_receivable_id = fields.Many2one('account.account', company_dependent=True, + string="Account Receivable", + domain="[('internal_type', '=', 'receivable'), ('deprecated', '=', False), ('company_id', '=', current_company_id)]", + help="This account will be used instead of the default one as the receivable account for the current partner", + default=395) reference_number = fields.Char(string="Reference Number") company_type_id = fields.Many2one('res.partner.company_type', string='Company Type') custom_pricelist_id = fields.Many2one('product.pricelist', string='Price Matrix') -- cgit v1.2.3 From 3f5eec5331b216911d911c230ea64538588b65c0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 14 Nov 2024 11:16:07 +0700 Subject: add free bu --- indoteknik_custom/models/sale_order_line.py | 5 +++++ indoteknik_custom/views/sale_order.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index f4469117..04fafa69 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -37,6 +37,11 @@ class SaleOrderLine(models.Model): weight = fields.Float(string='Weight') md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) margin_md = fields.Float(string='Margin MD') + qty_free_bu = fields.Float(string='Free BU', compute='_get_qty_free_bandengan') + + def _get_qty_free_bandengan(self): + for line in self: + line.qty_free_bu = line.product_id.qty_free_bandengan @api.constrains('note_procurement') def note_procurement_to_apo(self): diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index b8f2d08d..53dac424 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -119,6 +119,7 @@ + Date: Thu, 14 Nov 2024 13:19:42 +0700 Subject: readonly credit limit on contact --- indoteknik_custom/views/partner_payment_term.xml | 3 +++ indoteknik_custom/views/res_partner.xml | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/indoteknik_custom/views/partner_payment_term.xml b/indoteknik_custom/views/partner_payment_term.xml index 433cac3e..e0f2fe39 100644 --- a/indoteknik_custom/views/partner_payment_term.xml +++ b/indoteknik_custom/views/partner_payment_term.xml @@ -24,6 +24,9 @@ + + + diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 6d02a86b..e8d3bf1a 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -6,6 +6,15 @@ res.partner + + 1 + + + 1 + + + 1 + -- cgit v1.2.3 From 7b60204cb96af3d180fa21570c7540722184ab4e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 14 Nov 2024 16:08:42 +0700 Subject: fix bug wati --- indoteknik_custom/models/sale_order.py | 4 +-- indoteknik_custom/models/wati.py | 57 +++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index e90ca995..80e111a8 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -973,8 +973,8 @@ class SaleOrder(models.Model): note.append(line.name) if order.picking_ids: - # Sort picking_ids by date and get the most recent one - latest_picking = order.picking_ids.sorted(key=lambda p: p.scheduled_date, reverse=True)[0] + # Sort picking_ids by creation date to get the most recent one + latest_picking = order.picking_ids.sorted(key=lambda p: p.create_date, reverse=True)[0] latest_picking.notee = '\n'.join(note) return res diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index eed5413e..f3632334 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -58,41 +58,56 @@ class WatiNotification(models.Model): return def _create_wati_history_header(self, ticket_id, sender_name, notification_json, date_wati): + # Helper function to remove NUL characters + def remove_null_characters(value): + if isinstance(value, str): + return value.replace('\0', '') + return value + + # Sanitize the input data param_header = { 'ticket_id': ticket_id, - 'conversation_id': notification_json['conversationId'], - 'sender_name': sender_name, - 'wa_id': notification_json['waId'], - 'text': notification_json['text'], - 'date_wati': date_wati or '', + 'conversation_id': remove_null_characters(notification_json.get('conversationId', '')), + 'sender_name': remove_null_characters(sender_name), + 'wa_id': remove_null_characters(notification_json.get('waId', '')), + 'text': remove_null_characters(notification_json.get('text', '')), + 'date_wati': remove_null_characters(date_wati or ''), } + + # Create the record new_header = self.env['wati.history'].create([param_header]) return new_header def _create_wati_history_line(self, new_header, ticket_id, sender_name, notification_json, date_wati): - text_body = notification_json['text'] or '' + # Helper function to remove NUL characters + def remove_null_characters(value): + if isinstance(value, str): + return value.replace('\0', '') + return value + + # Sanitize the input data param_line = { "wati_history_id": new_header.id, - "conversation_id": notification_json['conversationId'], - "data": notification_json['data'] or '', - "event_type": notification_json['eventType'] or '', - # "list_reply": notification_json['listReply'] or '', - # "message_contact": notification_json['messageContact'] or '', - "operator_email": notification_json['operatorEmail'] or '', - "operator_name": notification_json['operatorName'] or '', - "sender_name": sender_name or '', - # "source_url": notification_json['sourceUrl'] or '', - "status_string": notification_json['statusString'] or '', - "text": text_body, + "conversation_id": remove_null_characters(notification_json.get('conversationId', '')), + "data": remove_null_characters(notification_json.get('data', '')), + "event_type": remove_null_characters(notification_json.get('eventType', '')), + "operator_email": remove_null_characters(notification_json.get('operatorEmail', '')), + "operator_name": remove_null_characters(notification_json.get('operatorName', '')), + "sender_name": remove_null_characters(sender_name or ''), + "status_string": remove_null_characters(notification_json.get('statusString', '')), + "text": remove_null_characters(notification_json.get('text', '')), "ticket_id": ticket_id, - "type": notification_json['type'] or '', - "wa_id": notification_json['waId'] or '', - "date_wati": date_wati or '', + "type": remove_null_characters(notification_json.get('type', '')), + "wa_id": remove_null_characters(notification_json.get('waId', '')), + "date_wati": remove_null_characters(date_wati or ''), } + + # Create the record safely without NUL characters self.env['wati.history.line'].create([param_line]) - self._update_header_after_create_line(new_header, sender_name, date_wati, text_body) + self._update_header_after_create_line(new_header, sender_name, date_wati, param_line['text']) return + def _update_header_after_create_line(self, new_header, sender_name, date_wati, text_body): new_header.last_reply_by = sender_name new_header.last_reply_date = date_wati -- cgit v1.2.3 From 0c0cf00f50f78bc74aeedd8096eb161673a4ada7 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 15 Nov 2024 09:57:49 +0700 Subject: bf matches so in purchase order --- indoteknik_custom/models/automatic_purchase.py | 60 ++++++++++++++------------ 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 548115e6..46cc9fa5 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -401,36 +401,40 @@ class AutomaticPurchase(models.Model): domain = [ ('product_id', '=', line.product_id.id) ] - sale = self.env['v.sales.outstanding'].search(domain, order='sale_order_create_date desc', limit=1) - - existing_match = self.env['automatic.purchase.sales.match'].search([ - ('automatic_purchase_id', '=', self.id), - ('sale_id', '=', sale.sale_id.id), - ('product_id', '=', sale.product_id.id), - ]) + sales = self.env['v.sales.outstanding'].search(domain, order='sale_order_create_date desc') - price_so = self.env['sale.order.line'].search([ - ('id', '=', sale.sale_line_id.id), - ]) - - if existing_match: - continue + for sale in sales: + existing_match = self.env['automatic.purchase.sales.match'].search([ + ('automatic_purchase_id', '=', self.id), + ('sale_id', '=', sale.sale_id.id), + ('sale_line_id', '=', sale.sale_line_id.id), + ('product_id', '=', sale.product_id.id), + ]) - self.env['automatic.purchase.sales.match'].create([{ - 'automatic_purchase_id': self.id, - 'sale_id': sale.sale_id.id, - 'sale_line_id': sale.sale_line_id.id, - 'picking_id': sale.picking_id.id, - 'move_id': sale.move_id.id, - 'partner_id': sale.partner_id.id, - 'partner_invoice_id': sale.partner_invoice_id.id, - 'salesperson_id': sale.salesperson_id.id, - 'product_id': sale.product_id.id, - 'qty_so': sale.outgoing, - 'qty_po': line.qty_purchase, - 'purchase_price': price_so.purchase_price, - 'purchase_tax_id': price_so.purchase_tax_id.id if price_so.purchase_tax_id.id else None, - }]) + # price_so = self.env['sale.order.line'].search([ + # ('id', '=', sale.sale_line_id.id), + # ]) + + if existing_match: + continue + + self.env['automatic.purchase.sales.match'].create([{ + 'automatic_purchase_id': self.id, + 'sale_id': sale.sale_id.id, + 'sale_line_id': sale.sale_line_id.id, + 'picking_id': sale.picking_id.id, + 'move_id': sale.move_id.id, + 'partner_id': sale.partner_id.id, + 'partner_invoice_id': sale.partner_invoice_id.id, + 'salesperson_id': sale.salesperson_id.id, + 'product_id': sale.product_id.id, + 'qty_so': sale.outgoing, + 'qty_po': line.qty_purchase, + 'purchase_price': sale.sale_line_id.purchase_price, + 'purchase_tax_id': sale.sale_line_id.purchase_tax_id.id if sale.sale_line_id.purchase_tax_id.id else None, + # 'purchase_price': price_so.purchase_price, + # 'purchase_tax_id': price_so.purchase_tax_id.id if price_so.purchase_tax_id.id else None, + }]) def _create_sync_purchasing_job(self, jobs): date = datetime.utcnow() -- cgit v1.2.3 From 513e38bb38e712a37f2d2b8427212f4e83950f5a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 15 Nov 2024 10:11:55 +0700 Subject: cr qty available to available bandengan in generate reordering rule --- indoteknik_custom/models/automatic_purchase.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 46cc9fa5..4e96e6d4 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -466,9 +466,9 @@ class AutomaticPurchase(models.Model): count = 0 for point in orderpoints: # _logger.info('test %s' % point.product_id.name) - if point.product_id.virtual_available > point.product_min_qty: + if point.product_id.qty_available_bandengan > point.product_min_qty: continue - qty_purchase = point.product_max_qty - point.product_id.virtual_available + qty_purchase = point.product_max_qty - point.product_id.qty_available_bandengan po_line = self.env['purchase.order.line'].search([('product_id', '=', point.product_id.id), ('order_id.state', '=', 'done')], order='id desc', limit=1) if self.vendor_id: @@ -495,7 +495,7 @@ class AutomaticPurchase(models.Model): 'qty_purchase': qty_purchase, 'qty_min': point.product_min_qty, 'qty_max': point.product_max_qty, - 'qty_available': point.product_id.virtual_available, + 'qty_available': point.product_id.qty_available_bandengan, # 'partner_id': po_line.order_id.partner_id.id, # 'last_price': po_line.price_unit, 'partner_id': vendor_id, -- cgit v1.2.3 From afc8a108c9b1c52656bb3bbac9111dfa6e590bcb Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 15 Nov 2024 13:38:26 +0700 Subject: comment code check state reserve on approval unreserve --- indoteknik_custom/models/approval_unreserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/approval_unreserve.py b/indoteknik_custom/models/approval_unreserve.py index ba8b8da7..d847ea37 100644 --- a/indoteknik_custom/models/approval_unreserve.py +++ b/indoteknik_custom/models/approval_unreserve.py @@ -86,7 +86,7 @@ class ApprovalUnreserve(models.Model): }) # Trigger the unreserve function self._trigger_unreserve() - self.picking_id.check_state_reserve() + # self.picking_id.check_state_reserve() def action_reject(self, reason): if self.env.user.id != self.user_id.id: -- cgit v1.2.3 From 0731e9433b959f3aee8bff0488272f54a32546fe Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 16 Nov 2024 09:16:25 +0700 Subject: deactivate kelurahan validation --- 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 80e111a8..21f83521 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -491,8 +491,8 @@ class SaleOrder(models.Model): 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 5fda2edbacb79e31f26e0ba332a76244354ec337 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 16 Nov 2024 09:47:49 +0700 Subject: activate function constrains departure date --- 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 ee1dd68c..68e94ef7 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -194,9 +194,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 b57a1313743121f4a6a089fd175bb1594e042afb Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 18 Nov 2024 09:58:20 +0700 Subject: cr stock_picking --- indoteknik_custom/models/stock_picking.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 68e94ef7..430c54f3 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -196,7 +196,8 @@ class StockPicking(models.Model): @api.constrains('driver_departure_date') def constrains_driver_departure_date(self): - self.date_doc_kirim = self.driver_departure_date + if not self.date_doc_kirim: + self.date_doc_kirim = self.driver_departure_date @api.constrains('arrival_time') def constrains_arrival_time(self): @@ -450,6 +451,8 @@ class StockPicking(models.Model): 'picking_ids': [x.id for x in self] } return action + elif not self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin: + raise UserError('Harus Purchasing yang Ask Return') else: raise UserError('Harus Sales Admin yang Ask Return') elif self.picking_type_code == 'incoming': @@ -459,6 +462,8 @@ class StockPicking(models.Model): 'picking_ids': [x.id for x in self] } return action + elif not self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin: + raise UserError('Harus Sales Admin yang Ask Return') else: raise UserError('Harus Purchasing yang Ask Return') -- cgit v1.2.3 From d5cef4f36b8f6e74d536d26fa01a3b68b5e57ba8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 18 Nov 2024 10:05:29 +0700 Subject: fix bug vendor approval --- indoteknik_custom/models/vendor_approval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/vendor_approval.py b/indoteknik_custom/models/vendor_approval.py index bcc5d3ea..56b81a37 100644 --- a/indoteknik_custom/models/vendor_approval.py +++ b/indoteknik_custom/models/vendor_approval.py @@ -32,7 +32,7 @@ class VendorApproval(models.Model): self.order_id.vendor_approval = True message = "Vendor Approval approved by %s" % (self.env.user.name) self.order_id.message_post(body=message) - if not self.order_id.due_id: + if not self.order_id.due_id and self.order_id.state == 'draft': self.order_id.action_confirm() def action_reject(self): -- cgit v1.2.3 From 34c6611b059cf6ea79bb78e359b973719848f09b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 18 Nov 2024 10:57:21 +0700 Subject: fix bug vendor approval --- 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 21f83521..3d91ba91 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -748,7 +748,7 @@ class SaleOrder(models.Model): raise UserError("Salesperson sudah tidak aktif, mohon diisi yang benar pada data SO dan Contact") def sale_order_approve(self): - if self.validate_different_vendor() and not self.vendor_approval and not self.vendor_approval_id: + if self.validate_different_vendor() and not self.vendor_approval: return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor') self.check_due() @@ -925,7 +925,7 @@ class SaleOrder(models.Model): def action_confirm(self): for order in self: - if self.validate_different_vendor() and not self.vendor_approval and not self.vendor_approval_id: + if self.validate_different_vendor() and not self.vendor_approval: return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor') order.check_data_real_delivery_address() -- cgit v1.2.3 From 862e7b97028104e69ab500bf354a7c1b85854e4a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 18 Nov 2024 15:41:41 +0700 Subject: update code avoid error --- indoteknik_api/models/product_product.py | 5 +++-- indoteknik_custom/models/website_user_cart.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 386ddb6a..f8869c7d 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -61,8 +61,9 @@ class ProductProduct(models.Model): price_for = self.env.context.get('price_for', 'odoo') pricelist = pricelist or self.env.context.get('user_pricelist') default_price_tier = '1_v2' - - price_tier = pricelist.get_tier_level() + price_tier = [] + if pricelist: + price_tier = pricelist.get_tier_level() price_tier = price_tier if price_tier else default_price_tier pricelist = self._get_pricelist_tier(price_tier) diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 494f32f3..44393cf1 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -65,7 +65,7 @@ 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 + res['available_quantity'] = sum(stock_quant.mapped('available_quantity')) else: res['is_in_bu'] = False res['on_hand_qty'] = 0 -- cgit v1.2.3 From c4d1b5f203e0e860ed6ddcb3f33880476f0fa43c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 19 Nov 2024 11:42:54 +0700 Subject: add field to responsive view and change field potential to is not potential --- indoteknik_custom/models/res_partner.py | 2 +- indoteknik_custom/views/res_partner.xml | 2 +- indoteknik_custom/views/sale_order.xml | 40 ++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 2f0baab0..4297012c 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -33,7 +33,7 @@ class ResPartner(models.Model): counter = fields.Integer(string="Counter", default=0) leadtime = fields.Integer(string="Leadtime", default=0) digital_invoice_tax = fields.Boolean(string="Digital Invoice & Faktur Pajak") - is_potential = fields.Boolean(string='Potential') + is_not_potential = fields.Boolean(string='Not Potential') pakta_integritas = fields.Boolean(string='Pakta Integritas') use_so_approval = fields.Boolean(string='Use SO Approval') diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index e8d3bf1a..1b164161 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -31,7 +31,7 @@ - + diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 53dac424..3a3b1c81 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -118,9 +118,47 @@ } +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- + Date: Thu, 21 Nov 2024 09:24:56 +0700 Subject: cr stock_picking --- indoteknik_custom/models/stock_picking.py | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 071e3dfe..f17e12b7 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -442,29 +442,31 @@ class StockPicking(models.Model): for pick in self: if self.env.user.is_accounting: pick.approval_return_status = 'approved' - else: - 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 - elif not self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin: - raise UserError('Harus Purchasing yang Ask Return') - 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 - elif not self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin: - raise UserError('Harus Sales Admin yang Ask Return') - else: - raise UserError('Harus Purchasing yang Ask Return') + continue + + action_context = { + 'picking_ids': [x.id for x in self] + } + + if self.picking_type_code == 'outgoing': + if self.env.user.id in [3988, 3401, 20] or ( + self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin + ): + return self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard', context=action_context) + elif not self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin: + raise UserError('Harus Purchasing yang Ask Return') + 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') or ( + self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin + ): + return self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard', context=action_context) + elif not self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin: + raise UserError('Harus Sales Admin yang Ask Return') + else: + raise UserError('Harus Purchasing yang Ask Return') def calculate_line_no(self): -- cgit v1.2.3 From ffa3c65f93c3b042fb2cb813c17483e7b8ccc4cf Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 21 Nov 2024 09:46:54 +0700 Subject: cr stock picking --- indoteknik_custom/models/stock_picking.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index f17e12b7..16805197 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -444,15 +444,15 @@ class StockPicking(models.Model): pick.approval_return_status = 'approved' continue - action_context = { - 'picking_ids': [x.id for x in self] - } - if self.picking_type_code == 'outgoing': if self.env.user.id in [3988, 3401, 20] or ( self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin ): - return self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard', context=action_context) + 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 elif not self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin: raise UserError('Harus Purchasing yang Ask Return') else: @@ -462,7 +462,11 @@ class StockPicking(models.Model): if self.env.user.has_group('indoteknik_custom.group_role_purchasing') or ( self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin ): - return self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard', context=action_context) + 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 elif not self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin: raise UserError('Harus Sales Admin yang Ask Return') else: -- cgit v1.2.3 From b9bdfb05f96affaeec8e197b6585df140d4cd11c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 21 Nov 2024 09:48:11 +0700 Subject: cr stock_picking --- indoteknik_custom/models/stock_picking.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 16805197..10b26711 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -444,14 +444,13 @@ class StockPicking(models.Model): pick.approval_return_status = 'approved' continue + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + if self.picking_type_code == 'outgoing': if self.env.user.id in [3988, 3401, 20] or ( self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin ): - 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] - } + action['context'] = {'picking_ids': [x.id for x in self]} return action elif not self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin: raise UserError('Harus Purchasing yang Ask Return') @@ -462,17 +461,13 @@ class StockPicking(models.Model): if self.env.user.has_group('indoteknik_custom.group_role_purchasing') or ( self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin ): - 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] - } + action['context'] = {'picking_ids': [x.id for x in self]} return action elif not self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin: raise UserError('Harus Sales Admin yang Ask Return') else: raise UserError('Harus Purchasing yang Ask Return') - def calculate_line_no(self): for picking in self: -- cgit v1.2.3 From 4e84a3c939f50315c5eba4a9ae350f17383b5543 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 21 Nov 2024 16:29:05 +0700 Subject: perbaiki code is_in_bu logic --- indoteknik_custom/models/solr/product_product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index dd1d40f6..667511b2 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -54,7 +54,7 @@ class ProductProduct(models.Model): ('location_id', 'in', target_locations), ]) - is_in_bu = any(quant.available_quantity > 0 for quant in stock_quant) + is_in_bu = True if variant.qty_free_bandengan > 0 else False document = solr_model.get_doc('variants', variant.id) -- cgit v1.2.3