summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-12-29 13:44:00 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-12-29 13:44:00 +0700
commit5446eefa619906ba785d1f867fd828cce0d0748c (patch)
treeaaaed54b3a366dd61c82f3ceece2f0650d4ab5cf
parent08724b92174a216a64b382012e83e45c16b326e7 (diff)
multi update paid status on po
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rwxr-xr-xindoteknik_custom/models/purchase_order.py13
-rw-r--r--indoteknik_custom/models/purchase_order_multi_update.py22
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml9
-rw-r--r--indoteknik_custom/views/purchase_order_multi_update.xml31
7 files changed, 79 insertions, 1 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 39e5cdd9..d8058bff 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -104,6 +104,7 @@
'views/stock_warehouse_orderpoint.xml',
'views/customer_commision.xml',
'views/wati_history.xml',
+ 'views/purchase_order_multi_update.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 50885f56..c6f61ffa 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -94,3 +94,4 @@ from . import account_bank_statement
from . import stock_warehouse_orderpoint
from . import commision
from . import sale_advance_payment_inv
+from . import purchase_order_multi_update
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 285c5a95..6641e204 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -52,6 +52,19 @@ class PurchaseOrder(models.Model):
responsible_ids = fields.Many2many('res.users', string='Responsibles', compute='_compute_responsibles')
status_paid_cbd = fields.Boolean(string='Paid Status', tracking=3, help='Field ini diisi secara manual oleh Finance AP dan hanya untuk status PO CBD')
+ def action_multi_update_paid_status(self):
+ for purchase in self:
+ purchase.update({
+ 'status_paid_cbd': True,
+ })
+
+ 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'] = {
+ 'purchase_ids': [x.id for x in self]
+ }
+ return action
+
def _compute_responsibles(self):
for purchase in self:
resposible_ids = []
diff --git a/indoteknik_custom/models/purchase_order_multi_update.py b/indoteknik_custom/models/purchase_order_multi_update.py
new file mode 100644
index 00000000..aab46de8
--- /dev/null
+++ b/indoteknik_custom/models/purchase_order_multi_update.py
@@ -0,0 +1,22 @@
+from odoo import models, fields
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class PurchaseOrderMultiUpdate(models.TransientModel):
+ _name = 'purchase.order.multi_update'
+
+ def save_multi_update_paid_status(self):
+ purchase_ids = self._context['purchase_ids']
+ purchase = self.env['purchase.order'].browse(purchase_ids)
+ purchase.action_multi_update_paid_status()
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': {
+ 'title': 'Notification',
+ 'message': 'Paid Status berhasil diubah',
+ '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 444a1b42..dd7605ab 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -84,4 +84,5 @@ access_customer_commision_line,access.customer.commision.line,model_customer_com
access_customer_rebate,access.customer.rebate,model_customer_rebate,,1,1,1,1
access_wati_history,access.wati.history,model_wati_history,,1,1,1,1
access_wati_history_line,access.wati.history.line,model_wati_history_line,,1,1,1,1
-access_sale_advance_payment_inv,access.sale.advance.payment.inv,model_sale_advance_payment_inv,,1,1,1,1 \ No newline at end of file
+access_sale_advance_payment_inv,access.sale.advance.payment.inv,model_sale_advance_payment_inv,,1,1,1,1
+access_purchase_order_multi_update,access.purchase.order.multi_update,model_purchase_order_multi_update,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 21e8c328..3a95393e 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -188,4 +188,13 @@
</field>
</record>
</data>
+ <data>
+ <record id="purchase_order_multi_update_ir_actions_server" model="ir.actions.server">
+ <field name="name">Update Paid Status</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_update_paid_status()</field>
+ </record>
+ </data>
</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/purchase_order_multi_update.xml b/indoteknik_custom/views/purchase_order_multi_update.xml
new file mode 100644
index 00000000..7cfcd64d
--- /dev/null
+++ b/indoteknik_custom/views/purchase_order_multi_update.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="view_purchase_order_multi_update_paid_form" model="ir.ui.view">
+ <field name="name">Purchase Order Multi Update Paid Status</field>
+ <field name="model">purchase.order.multi_update</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <span>Apakah Anda Yakin Ingin Mengubah Paid Status?</span>
+ </group>
+ </sheet>
+ <footer>
+ <button name="save_multi_update_paid_status" string="Update Paid Status" 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_update" model="ir.actions.act_window">
+ <field name="name">Purchase Order Multi Update Paid Status</field>
+ <field name="res_model">purchase.order.multi_update</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="view_purchase_order_multi_update_paid_form"/>
+ <field name="target">new</field>
+ </record>
+ </data>
+</odoo> \ No newline at end of file