diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-03-04 13:30:06 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-03-04 13:30:06 +0700 |
| commit | 98ec81f4442553070ce235d0e96d736c60dcd839 (patch) | |
| tree | 80fa605cd608822f79dfefdd04886dc6aabf5435 | |
| parent | bfb7d3b45bbf780fa77b9abc8a0f1860a50da57c (diff) | |
| parent | 92b6da28414fed56732f86e1f04ea2fac3464d7d (diff) | |
Merge branch 'odoo-production' into CR/repeat-order
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/coretax_fatur.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 17 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchase_order_multi_ask_approval.py | 22 | ||||
| -rw-r--r-- | indoteknik_custom/models/requisition.py | 42 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 9 | ||||
| -rw-r--r-- | indoteknik_custom/views/purchase_order_multi_ask_approval.xml | 31 |
12 files changed, 129 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index ac887547..f66314fa 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -118,6 +118,7 @@ 'views/sale_monitoring_detail_v2.xml', 'views/purchase_order_multi_update.xml', 'views/purchase_order_multi_confirm.xml', + 'views/purchase_order_multi_ask_approval.xml', 'views/invoice_reklas_penjualan.xml', 'views/po_multi_cancel.xml', 'views/logbook_sj.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index f33a7411..3573eddd 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -106,6 +106,7 @@ from . import sale_monitoring_detail_v2 from . import purchase_order_multi_update from . import invoice_reklas_penjualan from . import purchase_order_multi_confirm +from . import purchase_order_multi_ask_approval from . import po_multi_cancel from . import logbook_sj from . import report_logbook_sj diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index b2ac47c2..9aa0743b 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -65,6 +65,7 @@ class AccountMove(models.Model): other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal') other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes') is_hr = fields.Boolean(string="Is HR?", default=False) + purchase_order_id = fields.Many2one('purchase.order', string='Purchase Order') def _update_line_name_from_ref(self): """Update all account.move.line name fields with ref from account.move""" diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 706a4f44..b4bffbd2 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -59,6 +59,7 @@ class CoretaxFaktur(models.Model): ET.SubElement(tax_invoice, 'TrxCode').text = '04' ET.SubElement(tax_invoice, 'AddInfo') ET.SubElement(tax_invoice, 'CustomDoc') + ET.SubElement(tax_invoice, 'CustomDocMonthYear') ET.SubElement(tax_invoice, 'RefDesc').text = invoice.name ET.SubElement(tax_invoice, 'FacilityStamp') ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0742260227086000000000' diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 54d771ba..d90c4a8a 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -155,6 +155,7 @@ class PurchaseOrder(models.Model): 'invoice_date': current_date, 'date': current_date, 'invoice_origin': self.name, + 'purchase_order_id': self.id, 'move_type': 'in_invoice' } @@ -231,6 +232,7 @@ class PurchaseOrder(models.Model): 'invoice_date': current_date, 'date': current_date, 'invoice_origin': self.name, + 'purchase_order_id': self.id, 'move_type': 'in_invoice' } @@ -307,6 +309,7 @@ class PurchaseOrder(models.Model): invoice_vals = { 'ref': self.partner_ref or '', 'move_type': move_type, + 'purchase_order_id': self.id, 'narration': self.notes, 'currency_id': self.currency_id.id, 'invoice_user_id': self.user_id and self.user_id.id or self.env.user.id, @@ -388,6 +391,13 @@ class PurchaseOrder(models.Model): } return action + def open_form_multi_ask_approval_po(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_ask_approval') + action['context'] = { + 'po_ids': [x.id for x in self] + } + return action + def open_form_multi_create_uang_muka(self): action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka') action['context'] = { @@ -415,6 +425,13 @@ class PurchaseOrder(models.Model): purchase.button_confirm() + def action_multi_ask_approval_po(self): + for purchase in self: + if purchase.state != 'draft': + continue + + purchase.po_approve() + def open_form_multi_update_paid_status(self): action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_update') action['context'] = { diff --git a/indoteknik_custom/models/purchase_order_multi_ask_approval.py b/indoteknik_custom/models/purchase_order_multi_ask_approval.py new file mode 100644 index 00000000..69f8e5a8 --- /dev/null +++ b/indoteknik_custom/models/purchase_order_multi_ask_approval.py @@ -0,0 +1,22 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class PurchaseOrderMultiUpdate(models.TransientModel): + _name = 'purchase.order.multi_ask_approval' + + def save_multi_ask_approval_po(self): + po_ids = self._context['po_ids'] + purchase = self.env['purchase.order'].browse(po_ids) + purchase.action_multi_ask_approval_po() + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'PO berhasil di ask_approval', + 'next': {'type': 'ir.actions.act_window_close'}, + } + }
\ No newline at end of file diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index c972b485..1d350929 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -276,10 +276,11 @@ class RequisitionLine(models.Model): _name = 'requisition.line' _description = 'Requisition Line' _order = 'requisition_id, id' + _inherit = ['mail.thread'] requisition_id = fields.Many2one('requisition', string='Ref', required=True, ondelete='cascade', index=True, copy=False) brand_id = fields.Many2one('x_manufactures', string='Brand') - product_id = fields.Many2one('product.product', string='Product') + product_id = fields.Many2one('product.product', string='Product', tracking=3,) partner_id = fields.Many2one('res.partner', string='Vendor') qty_purchase = fields.Float(string='Qty Purchase') price_unit = fields.Float(string='Price') @@ -331,6 +332,45 @@ class RequisitionLine(models.Model): line.taxes_id = taxes line.partner_id = purchase_pricelist.vendor_id.id + @api.model + def create(self, vals): + record = super(RequisitionLine, self).create(vals) + record._track_changes('Tambah') + return record + + def write(self, vals): + for record in self: + old_values = {field: record[field] for field in vals if field in record} + + result = super(RequisitionLine, self).write(vals) + + for record in self: + record._track_changes('Updated', old_values) + + return result + + def unlink(self): + for record in self: + record._track_changes('Hapus') + return super(RequisitionLine, self).unlink() + + def _track_changes(self, action, old_values=None): + message = f"Produk telah di-{action} : <br/>" + if action == 'Tambah': + # message += f"<br/> Product: {self.product_id.name}" + message += f"Product: {self.product_id.name} <br/> Vendor: {self.partner_id.name} <br/> Qty: {self.qty_purchase} <br/> Price: {self.price_unit} <br/> Tax: {self.tax_id.name} <br/> Subtotal: {self.subtotal} <br/> Brand: {self.brand_id.x_name}" + elif action == 'Hapus': + # message += f"<br/> Deleted Product: {self.product_id.name}" + message += f"<br/> Deleted Product: {self.product_id.name} <br/> Vendor: {self.partner_id.name} Qty: {self.qty_purchase} <br/> Price: {self.price_unit} <br/> Tax: {self.tax_id.name} <br/> Subtotal: {self.subtotal} <br/> Brand: {self.brand_id.x_name}" + else: # Updated + for field, old_value in old_values.items(): + new_value = self[field] + if old_value != new_value: + field_label = self._fields[field].string # Ambil nama label field + message += f"{field_label}: {old_value} -> {new_value}<br/>" + + if self.requisition_id: + self.requisition_id.message_post(body=message) class RequisitionPurchaseMatch(models.Model): _name = 'requisition.purchase.match' diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index f53041cb..8a983479 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -25,6 +25,7 @@ class CancelReasonOrder(models.TransientModel): ('dokumen_tidak_support', 'Indoteknik tidak bisa support document yang dibutuhkan (Ex: TKDN, COO, SNI)'), ('ganti_quotation', 'Ganti Quotation'), ('testing_internal', 'Testing Internal'), + ('revisi_data', 'Revisi Data'), ], string='Reason for Cancel', required=True, copy=False, index=True, tracking=3) attachment_bukti = fields.Many2many( 'ir.attachment', @@ -1162,6 +1163,8 @@ class SaleOrder(models.Model): def confirm_cancel_order(self): """Fungsi ini akan dipanggil oleh wizard setelah alasan pembatalan dipilih""" + if self.state != 'cancel': + self.state = 'cancel' return super(SaleOrder, self).action_cancel() def validate_partner_invoice_due(self): diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 75b3bf48..5e0c2221 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -105,6 +105,7 @@ access_purchase_order_multi_update,access.purchase.order.multi_update,model_purc access_invoice_reklas_penjualan,access.invoice.reklas.penjualan,model_invoice_reklas_penjualan,,1,1,1,1 access_invoice_reklas_penjualan_line,access.invoice.reklas.penjualan.line,model_invoice_reklas_penjualan_line,,1,1,1,1 access_purchase_order_multi_confirm,access.purchase.order.multi_confirm,model_purchase_order_multi_confirm,,1,1,1,1 +access_purchase_order_multi_ask_approval,access.purchase.order.multi_ask_approval,model_purchase_order_multi_ask_approval,,1,1,1,1 access_po_multi_cancel,access.po.multi.cancel,model_po_multi_cancel,,1,1,1,1 access_logbook_sj,access.logbook.sj,model_logbook_sj,,1,1,1,1 access_logbook_sj_line,access.logbook.sj.line,model_logbook_sj_line,,1,1,1,1 diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 50a34e11..17263c3a 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -27,6 +27,7 @@ </field> <field name="invoice_date" position="after"> <field name="sale_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> + <field name="purchase_order_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}"/> </field> <field name="ref" position="after"> <field name="sale_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'entry')]}"/> diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index a57bd467..36c0db13 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -331,6 +331,15 @@ </record> </data> <data> + <record id="purchase_order_multi_ask_approval_ir_actions_server" model="ir.actions.server"> + <field name="name">Ask Approval PO</field> + <field name="model_id" ref="purchase.model_purchase_order"/> + <field name="binding_model_id" ref="purchase.model_purchase_order"/> + <field name="state">code</field> + <field name="code">action = records.open_form_multi_ask_approval_po()</field> + </record> + </data> + <data> <record id="purchase_order_multi_create_uangmuka_ir_actions_server" model="ir.actions.server"> <field name="name">Uang Muka</field> <field name="model_id" ref="purchase.model_purchase_order"/> diff --git a/indoteknik_custom/views/purchase_order_multi_ask_approval.xml b/indoteknik_custom/views/purchase_order_multi_ask_approval.xml new file mode 100644 index 00000000..887ac0bd --- /dev/null +++ b/indoteknik_custom/views/purchase_order_multi_ask_approval.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="view_purchase_order_multi_ask_approval_po_form" model="ir.ui.view"> + <field name="name">Purchase Order Multi ask_approval</field> + <field name="model">purchase.order.multi_ask_approval</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <span>Apakah Anda Yakin Ingin Ask Approval PO Tersebut?</span> + </group> + </sheet> + <footer> + <button name="save_multi_ask_approval_po" string="Ask Approval PO" type="object" default_focus="1" class="oe_highlight"/> + <button string="Cancel" class="btn btn-secondary" special="cancel" /> + </footer> + </form> + </field> + </record> + + <record id="action_purchase_order_multi_ask_approval" model="ir.actions.act_window"> + <field name="name">Purchase Order Multi ask_approval</field> + <field name="res_model">purchase.order.multi_ask_approval</field> + <field name="type">ir.actions.act_window</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_purchase_order_multi_ask_approval_po_form"/> + <field name="target">new</field> + </record> + </data> +</odoo>
\ No newline at end of file |
