diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-03-04 10:00:53 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-03-04 10:00:53 +0700 |
| commit | cc170c5420fd8854303a63dba59065ab0f87c94e (patch) | |
| tree | 6587c0a149cc7c34574666605e05763c66095f69 | |
| parent | 7c675cd5bc9f45d2ebca33a63b7184cbb97f0f2f (diff) | |
multi ask approval po and source document bills
| -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 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 17 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchase_order_multi_ask_approval.py | 22 | ||||
| -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 |
9 files changed, 84 insertions, 0 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/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/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 |
