From dbf09bbf792809e84d2d0330a992e42b3a5c6994 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 23 May 2025 09:38:02 +0700 Subject: Revert "Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup" This reverts commit 43313db30da73b87843425c01c723f66ee982886, reversing changes made to f6f59e660af6c4229ada54f7313d68867df1ba15. --- indoteknik_custom/models/automatic_purchase.py | 45 ++++++--------------- indoteknik_custom/models/product_template.py | 6 +-- .../models/sale_advance_payment_inv.py | 1 - indoteknik_custom/models/sale_order.py | 46 +++++----------------- indoteknik_custom/models/stock_picking.py | 3 +- indoteknik_custom/views/sale_order.xml | 15 ++++--- indoteknik_custom/views/stock_picking.xml | 1 - .../views/user_pengajuan_tempo_request.xml | 2 +- 8 files changed, 34 insertions(+), 85 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index ff10b814..b66121e1 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -696,42 +696,21 @@ class SaleNotInMatchPO(models.Model): purchase_tax_id = fields.Many2one('account.tax', string='Purchase Tax') note_procurement = fields.Many2one(string='Note Procurement') - # 1. yang bug - # def init(self): - # tools.drop_view_if_exists(self.env.cr, self._table) - # self.env.cr.execute(""" - # CREATE OR REPLACE VIEW %s AS( - # select apsm.id, apsm.automatic_purchase_id, apsm.automatic_purchase_line_id, apsm.sale_id, apsm.sale_line_id, - # apsm.picking_id, apsm.move_id, apsm.partner_id, - # apsm.partner_invoice_id, apsm.salesperson_id, apsm.product_id, apsm.qty_so, apsm.qty_po, apsm.create_uid, - # apsm.create_date, apsm.write_uid, apsm.write_date, apsm.purchase_price, - # apsm.purchase_tax_id, apsm.note_procurement - # from automatic_purchase_sales_match apsm - # where apsm.sale_line_id not in ( - # select distinct coalesce(posm.sale_line_id,0) - # from purchase_order_sales_match posm - # join purchase_order po on po.id = posm.purchase_order_id - # where po.state not in ('cancel') - # ) - # ) - # """ % self._table) - def init(self): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" CREATE OR REPLACE VIEW %s AS( - SELECT apsm.id, apsm.automatic_purchase_id, apsm.automatic_purchase_line_id, - apsm.sale_id, apsm.sale_line_id, apsm.picking_id, apsm.move_id, - apsm.partner_id, apsm.partner_invoice_id, apsm.salesperson_id, - apsm.product_id, apsm.qty_so, apsm.qty_po, apsm.create_uid, - apsm.create_date, apsm.write_uid, apsm.write_date, apsm.purchase_price, - apsm.purchase_tax_id, apsm.note_procurement - FROM automatic_purchase_sales_match apsm - WHERE apsm.sale_line_id NOT IN ( - SELECT posm.sale_line_id - FROM purchase_order_sales_match posm - JOIN purchase_order po ON po.id = posm.purchase_order_id - WHERE po.state NOT IN ('cancel') + select apsm.id, apsm.automatic_purchase_id, apsm.automatic_purchase_line_id, apsm.sale_id, apsm.sale_line_id, + apsm.picking_id, apsm.move_id, apsm.partner_id, + apsm.partner_invoice_id, apsm.salesperson_id, apsm.product_id, apsm.qty_so, apsm.qty_po, apsm.create_uid, + apsm.create_date, apsm.write_uid, apsm.write_date, apsm.purchase_price, + apsm.purchase_tax_id, apsm.note_procurement + from automatic_purchase_sales_match apsm + where apsm.sale_line_id not in ( + select distinct coalesce(posm.sale_line_id,0) + from purchase_order_sales_match posm + join purchase_order po on po.id = posm.purchase_order_id + where po.state not in ('cancel') ) ) - """ % self._table) \ No newline at end of file + """ % self._table) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 89392033..17805c6c 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -870,9 +870,9 @@ class ProductTemplate(models.Model): record.message_post(body=f"Updated:") # log changes to product variants - # variant_message = f"Updated:" - # for variant in record.product_variant_ids: - # variant.message_post(body=variant_message) + variant_message = f"Updated:" + for variant in record.product_variant_ids: + variant.message_post(body=variant_message) # simpan data lama dan log perubahan field def write(self, vals): diff --git a/indoteknik_custom/models/sale_advance_payment_inv.py b/indoteknik_custom/models/sale_advance_payment_inv.py index 48b753cc..bea9a900 100644 --- a/indoteknik_custom/models/sale_advance_payment_inv.py +++ b/indoteknik_custom/models/sale_advance_payment_inv.py @@ -197,7 +197,6 @@ class SaleAdvancePaymentInv(models.TransientModel): # if final: # moves.sudo().filtered(lambda m: m.amount_total < 0).action_switch_invoice_into_refund_credit_note() # for move in moves: - # move.message_post_with_view('mail.message_origin_link', # values={'self': move, 'origin': move.line_ids.mapped('sale_line_ids.order_id')}, # subtype_id=self.env.ref('mail.mt_note').id diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index db0e1227..6028a1d0 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -332,9 +332,9 @@ class SaleOrder(models.Model): ('approve', 'Approve') ], tracking=True, string='State Cancel', copy=False) date_hold = fields.Datetime(string='Date Hold', tracking=True, readonly=True, help='Waktu ketika SO di Hold' - ) + ) date_unhold = fields.Datetime(string='Date Unhold', tracking=True, readonly=True, help='Waktu ketika SO di Unhold' - ) + ) ready_to_ship_status_detail = fields.Char( string='Status Shipping Detail', @@ -379,7 +379,7 @@ class SaleOrder(models.Model): } } - def hold_unhold_qty_outgoing_so(self): + def hold_unhold_qty_outgoing_so(self): if self.hold_outgoing == True: self.hold_outgoing = False self.date_unhold = fields.Datetime.now() @@ -393,6 +393,7 @@ class SaleOrder(models.Model): picking.do_unreserve() self.hold_outgoing = True self.date_hold = fields.Datetime.now() + def _validate_uniform_taxes(self): for order in self: @@ -410,8 +411,8 @@ class SaleOrder(models.Model): # if rec.fee_third_party == 0 and rec.total_margin_excl_third_party != rec.total_percent_margin: # # Gunakan direct SQL atau flag context untuk menghindari rekursi # self.env.cr.execute(""" - # UPDATE sale_order - # SET total_margin_excl_third_party = %s + # UPDATE sale_order + # SET total_margin_excl_third_party = %s # WHERE id = %s # """, (rec.total_percent_margin, rec.id)) # self.invalidate_cache() @@ -1231,12 +1232,10 @@ class SaleOrder(models.Model): for order in self: for line in order.order_line: if 'bom-it' in line.name.lower() or 'bom' in line.product_id.default_code.lower() if line.product_id.default_code else False: - search_bom = self.env['mrp.production'].search( - [('product_id', '=', line.product_id.id), ('sale_order', '=', order.id), - ('state', '!=', 'cancel')], - order='name desc') + search_bom = self.env['mrp.production'].search([('product_id', '=', line.product_id.id), ('sale_order', '=', order.id), ('state', '!=', 'cancel')], + order='name desc') if search_bom: - confirmed_bom = search_bom.filtered(lambda x: x.state == 'confirmed' or x.state == 'done') + confirmed_bom = search_bom.filtered(lambda x: x.state == 'confirmed' or x.state == 'done') if not confirmed_bom: raise UserError( "Product BOM belum dikonfirmasi di Manufacturing Orders. Silakan hubungi MD.") @@ -1534,7 +1533,7 @@ class SaleOrder(models.Model): if not order.real_shipping_id: UserError('Real Delivery Address harus di isi') - + if not self.env.context.get('due_approve', []): if order.validate_partner_invoice_due(): return self._create_notification_action('Notification', @@ -2016,7 +2015,6 @@ class SaleOrder(models.Model): <<<<<<< HEAD self._calculate_etrts_date() return res -<<<<<<< HEAD ======= self._calculate_etrts_date() return res @@ -2056,27 +2054,3 @@ class SaleOrder(models.Model): else: order.ready_to_ship_status_detail = 'On Track' >>>>>>> CR/form-merchant -======= - - def write(self, vals): - # Cek apakah payment_term_id diubah dan SO sedang dalam approval - if 'payment_term_id' in vals and any( - order.approval_status in ['pengajuan1', 'pengajuan2', 'approved'] for order in self): - raise UserError( - "Payment Term tidak dapat diubah karena Sales Order sedang dalam proses approval atau sudah diapprove.") - - if 'payment_term_id' in vals: - for order in self: - partner = order.partner_id.parent_id or order.partner_id - customer_payment_term = partner.property_payment_term_id - - # Jika payment term yang diinput berbeda dengan payment term customer - if vals['payment_term_id'] != customer_payment_term.id: - raise UserError( - f"Payment Term berbeda pada Master Data Customer. " - f"Harap ganti ke '{customer_payment_term.name}' " - f"sesuai dengan payment term yang terdaftar pada customer." - ) - - return super(SaleOrder, self).write(vals) ->>>>>>> 46e4c80e1b530274c01cca5603f3e1be873820f6 diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 3135f41c..0071bb1a 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -288,7 +288,7 @@ class StockPicking(models.Model): self.ensure_one() if not self.name or not self.origin: return False - return f"{self.name}, {self.origin}" + return f"{self.name} {self.origin}" def _download_pod_photo(self, url): """Mengunduh foto POD dari URL""" @@ -584,7 +584,6 @@ class StockPicking(models.Model): self.lalamove_phone = phone self.lalamove_status = pod.get("status") self.lalamove_delivered_at = delivered_at_dt - self.driver_arrival_date = delivered_at_dt return data raise UserError("No delivered data found in Lalamove response.") diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 2191acf4..92d13fa7 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -96,11 +96,11 @@ 1 - - - - - + + + + + <<<<<<< HEAD @@ -316,9 +316,8 @@ - {'readonly': ['|', ('approval_status', 'in', ['pengajuan1', 'pengajuan2', 'approved']), - ('state', 'not in', - ['cancel', 'draft'])]} + {'readonly': [('approval_status', '=', 'approved'), ('state', 'not in', + ['cancel', 'draft'])]} diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 02959d69..ae77ab9a 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -19,7 +19,6 @@ - diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 898d5b2a..339ce8db 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -426,7 +426,7 @@ -- cgit v1.2.3