diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-15 10:23:20 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-15 10:23:20 +0700 |
| commit | 080bdd7d1283509e55a0af2459c8e12b7519c0eb (patch) | |
| tree | bc0fbe2b27f67e2f1a767a8cac9a94e295a36353 | |
| parent | ac997ef851c9e1ce6d061a68951051f0b916b534 (diff) | |
change request uang muka purchase order
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 8 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchase_order_multi_uangmuka.py | 37 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchase_order_multi_uangmuka2.py | 18 | ||||
| -rw-r--r-- | indoteknik_custom/models/uangmuka_pembelian.py | 11 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 4 | ||||
| -rw-r--r-- | indoteknik_custom/views/purchase_order_multi_uangmuka.xml | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/purchase_order_multi_uangmuka2.xml | 29 |
10 files changed, 98 insertions, 14 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 1d8e3533..6b5bc8bb 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -130,6 +130,7 @@ 'views/def_cargo_city.xml', 'views/def_cargo_district.xml', 'views/purchase_order_multi_uangmuka.xml', + 'views/purchase_order_multi_uangmuka2.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 13d8f0b4..e6fefe2a 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -116,3 +116,4 @@ from . import external_api from . import ged from . import account_move_multi_update_bills from . import def_cargo +from . import purchase_order_multi_uangmuka2 diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 5d28e5a1..16fb7cf8 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -58,6 +58,7 @@ class PurchaseOrder(models.Model): approval_edit_line = fields.Boolean(string='Approval Edit Line', tracking=3) sale_order = fields.Char(string='Sale Order') matches_so = fields.Many2many('sale.order', string='Matches SO', compute='_compute_matches_so') + is_create_uangmuka = fields.Boolean(string='Uang Muka?') def _compute_matches_so(self): for po in self: @@ -132,6 +133,13 @@ class PurchaseOrder(models.Model): } return action + def open_form_multi_create_uang_muka2(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka') + action['context'] = { + 'po_ids': self.id + } + return action + def action_multi_update_paid_status(self): for purchase in self: purchase.update({ diff --git a/indoteknik_custom/models/purchase_order_multi_uangmuka.py b/indoteknik_custom/models/purchase_order_multi_uangmuka.py index feb13cbc..3ab3a050 100644 --- a/indoteknik_custom/models/purchase_order_multi_uangmuka.py +++ b/indoteknik_custom/models/purchase_order_multi_uangmuka.py @@ -23,7 +23,22 @@ class PurchaseOrderMultiUangmuka(models.TransientModel): for o in self: o.total_amt = o.pay_amt + o.ongkir_amt + o.selisih_amt - def create_uangmukapembelian(self, orders): + def create_uangmukapembelianselected(self): + po_ids = self._context['po_ids'] + orders = self.env['purchase.order'].browse(po_ids) + po_is_uangmuka = self.env['purchase.order'].search([ + ('id', 'in', [x.id for x in orders]), + ('is_create_uangmuka', '=', True) + ]) + + for rec in orders: + if rec.is_create_uangmuka: + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka2') + action['context'] = { + 'order_ids': [data.id for data in po_is_uangmuka] + } + return action + if not self.account_id: raise UserError('Bank Intransit harus diisi') if not self.env.user.has_group('account.group_account_manager'): @@ -52,6 +67,7 @@ class PurchaseOrderMultiUangmuka(models.TransientModel): account_move = self.env['account.move'].create([param_header]) debit_entries = [] pay_amt = 0 + for order in orders: _logger.info('Success Create Uang Muka Pembelian %s' % account_move.name) @@ -61,7 +77,7 @@ class PurchaseOrderMultiUangmuka(models.TransientModel): param_debit = { 'move_id': account_move.id, 'account_id': 401, # uang muka persediaan barang dagang - 'partner_id': partner_id, + 'partner_id': partner_id, 'currency_id': 12, 'debit': order.amount_total, 'credit': 0, @@ -96,6 +112,8 @@ class PurchaseOrderMultiUangmuka(models.TransientModel): if is_have_selisih: debit_entries.append(param_debit_selisih) pay_amt += self.selisih_amt + + order.is_create_uangmuka = True param_credit = { 'move_id': account_move.id, @@ -112,12 +130,6 @@ class PurchaseOrderMultiUangmuka(models.TransientModel): # Create all account.move.line entries at once self.env['account.move.line'].create(debit_entries) - return account_move.id - - def save_multi_create_uang_muka(self): - po_ids = self._context['po_ids'] - purchase = self.env['purchase.order'].browse(po_ids) - account_move = self.create_uangmukapembelian(purchase) return { 'name': _('Journal Entries'), 'view_mode': 'form', @@ -125,5 +137,10 @@ class PurchaseOrderMultiUangmuka(models.TransientModel): 'target': 'current', 'view_id': False, 'type': 'ir.actions.act_window', - 'res_id': account_move - }
\ No newline at end of file + 'res_id': account_move.id + } + + # def save_multi_create_uang_muka(self): + + # account_move = self.create_uangmukapembelianselected(purchase, is_create_uangmuka) +
\ No newline at end of file diff --git a/indoteknik_custom/models/purchase_order_multi_uangmuka2.py b/indoteknik_custom/models/purchase_order_multi_uangmuka2.py new file mode 100644 index 00000000..56539c5f --- /dev/null +++ b/indoteknik_custom/models/purchase_order_multi_uangmuka2.py @@ -0,0 +1,18 @@ +from odoo import fields, models, _, api +from odoo.exceptions import UserError +from datetime import datetime +from odoo.http import request + +import logging, math + +_logger = logging.getLogger(__name__) + + +class PurchaseOrderMultiUangmuka2(models.TransientModel): + _name = 'purchase.order.multi_uangmuka2' + + def redirect_to_po(self): + po_ids = self._context['order_ids'] + purchase = self.env['purchase.order'].browse(po_ids) + purchase.is_create_uangmuka = False + return purchase.open_form_multi_create_uang_muka2()
\ No newline at end of file diff --git a/indoteknik_custom/models/uangmuka_pembelian.py b/indoteknik_custom/models/uangmuka_pembelian.py index e3ce4a20..3ae8d3fb 100644 --- a/indoteknik_custom/models/uangmuka_pembelian.py +++ b/indoteknik_custom/models/uangmuka_pembelian.py @@ -24,8 +24,6 @@ class UangmukaPembelian(models.TransientModel): o.total_amt = o.pay_amt + o.ongkir_amt + o.selisih_amt def create_uangmukapembelian(self): - if self.pay_amt <= 0: - raise UserError('Payment Amount harus diisi') if not self.account_id: raise UserError('Bank Intransit harus diisi') if not self.env.user.is_accounting: @@ -41,6 +39,12 @@ class UangmukaPembelian(models.TransientModel): is_have_selisih = True for order in orders: + if order.is_create_uangmuka == True: + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka2') + action['context'] = { + 'order_ids': [x.id for x in order] + } + return action partner_name = order.partner_id.name if order.partner_id.parent_id: partner_name = order.partner_id.parent_id.name @@ -95,7 +99,7 @@ class UangmukaPembelian(models.TransientModel): 'credit': self.pay_amt + self.ongkir_amt + self.selisih_amt, 'name': ref_label, } - if is_have_ongkir and is_have_selisih: + if is_have_ongkir and is_have_selisih: request.env['account.move.line'].create([param_debit, param_debit_ongkir, param_debit_selisih, param_credit]) elif is_have_ongkir: request.env['account.move.line'].create([param_debit, param_debit_ongkir, param_credit]) @@ -103,6 +107,7 @@ class UangmukaPembelian(models.TransientModel): request.env['account.move.line'].create([param_debit, param_debit_selisih, param_credit]) else: request.env['account.move.line'].create([param_debit, param_credit]) + order.is_create_uangmuka = True return { 'name': _('Journal Entries'), 'view_mode': 'form', diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index a5e8d8f9..ae622ba4 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -121,3 +121,4 @@ access_def_cargo_province,access.def.cargo.province,model_def_cargo_province,,1, access_def_cargo_city,access.def.cargo.city,model_def_cargo_city,,1,1,1,1 access_def_cargo_district,access.def.cargo.district,model_def_cargo_district,,1,1,1,1 access_purchase_order_multi_uangmuka,access.purchase.order.multi_uangmuka,model_purchase_order_multi_uangmuka,,1,1,1,1 +access_purchase_order_multi_uangmuka2,access.purchase.order.multi_uangmuka2,model_purchase_order_multi_uangmuka2,,1,1,1,1 diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 09744f5f..08ff7e84 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -29,6 +29,7 @@ <field name="date_order" position="before"> <field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/> <field name="sale_order"/> + <field name="is_create_uangmuka"/> <field name="approval_status"/> <field name="amount_total_without_service"/> </field> @@ -122,6 +123,7 @@ </field> </record> </data> + <data> <record id="rfq_order_tree_view_inherit" model="ir.ui.view"> @@ -133,6 +135,7 @@ <field name="approval_status" /> <field name="responsible_ids" widget="many2many_tags" optional="hide"/> <field name="matches_so" widget="many2many_tags" optional="hide"/> + <field name="is_create_uangmuka" optional="hide"/> </field> </field> </record> @@ -148,6 +151,7 @@ <field name="po_status"/> <field name="note_description" optional="hide"/> <field name="sale_order_id" optional="hide"/> + <field name="is_create_uangmuka" optional="hide"/> <field name="responsible_ids" widget="many2many_tags" optional="hide"/> <field name="matches_so" widget="many2many_tags" optional="hide"/> </field> diff --git a/indoteknik_custom/views/purchase_order_multi_uangmuka.xml b/indoteknik_custom/views/purchase_order_multi_uangmuka.xml index 56711b94..e03c6bea 100644 --- a/indoteknik_custom/views/purchase_order_multi_uangmuka.xml +++ b/indoteknik_custom/views/purchase_order_multi_uangmuka.xml @@ -17,7 +17,7 @@ <field name="total_amt" readonly="1"/> </group> <footer> - <button name="save_multi_create_uang_muka" string="Create Uang Muka" type="object" default_focus="1" class="oe_highlight"/> + <button name="create_uangmukapembelianselected" string="Create Uang Muka" type="object" default_focus="1" class="oe_highlight"/> <button string="Cancel" class="btn btn-secondary" special="cancel" /> </footer> </form> diff --git a/indoteknik_custom/views/purchase_order_multi_uangmuka2.xml b/indoteknik_custom/views/purchase_order_multi_uangmuka2.xml new file mode 100644 index 00000000..6aad88a1 --- /dev/null +++ b/indoteknik_custom/views/purchase_order_multi_uangmuka2.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="view_purchase_order_multi_create_uangmuka2_form" model="ir.ui.view"> + <field name="name">Purchase Order Multi Create Uangmuka</field> + <field name="model">purchase.order.multi_uangmuka2</field> + <field name="arch" type="xml"> + <form string="Invoice Sales Order"> + <p class="oe_grey"> + Ada po yang sudah terbuat uang muka, apakah anda ingin melanjutkan pembayaran? + </p> + <footer> + <button name="redirect_to_po" string="Lanjutkan Pembayaran" 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_uangmuka2" model="ir.actions.act_window"> + <field name="name">Purchase Order Multi Create Uangmuka</field> + <field name="res_model">purchase.order.multi_uangmuka2</field> + <field name="type">ir.actions.act_window</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_purchase_order_multi_create_uangmuka2_form"/> + <field name="target">new</field> + </record> + </data> +</odoo>
\ No newline at end of file |
