From d8750844beed392c0dd3e588ea242be3c86f2be9 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 20 Mar 2023 11:43:50 +0700 Subject: process semi automatic for generate uang muka pembelian --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/uangmuka_pembelian.py | 65 ++++++++++++++++++++++++++ indoteknik_custom/security/ir.model.access.csv | 3 +- indoteknik_custom/views/purchase_order.xml | 2 + indoteknik_custom/views/uangmuka_pembelian.xml | 30 ++++++++++++ 6 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/uangmuka_pembelian.py create mode 100644 indoteknik_custom/views/uangmuka_pembelian.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 288927a9..c4f0cce0 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -21,6 +21,7 @@ 'views/product_pricelist_item.xml', 'views/product_public_category.xml', 'views/product_template.xml', + 'views/uangmuka_pembelian.xml', 'views/purchase_order.xml', 'views/purchase_pricelist.xml', 'views/sale_monitoring.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 432b0641..d86b1225 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -52,3 +52,4 @@ from . import midtrans from . import ip_lookup from . import wati from . import uangmuka_penjualan +from . import uangmuka_pembelian diff --git a/indoteknik_custom/models/uangmuka_pembelian.py b/indoteknik_custom/models/uangmuka_pembelian.py new file mode 100644 index 00000000..29d188d3 --- /dev/null +++ b/indoteknik_custom/models/uangmuka_pembelian.py @@ -0,0 +1,65 @@ +from odoo import fields, models, _ +from odoo.exceptions import UserError +from datetime import datetime +from odoo.http import request + +import logging + +_logger = logging.getLogger(__name__) + + +class UangmukaPembelian(models.TransientModel): + _name = 'uangmuka.pembelian' + _description = 'digunakan untuk membuat Uang Muka Pembelian' + + pay_amt = fields.Float(string='Payment', help='berapa nilai yang terbentuk untuk COA Uang Muka Pembelian') + account_id = fields.Many2one('account.account', string='Bank Intransit', default=389, help='pilih COA intransit bank') + + 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: + raise UserError('Hanya Finance yang dapat membuat Uang Muka Pembelian') + + orders = self.env['purchase.order'].browse(self._context.get('active_ids',[])) + current_time = datetime.now() + + for order in orders: + param_header = { + 'ref': 'UANG MUKA PEMBELIAN '+order.name+' '+order.partner_id.name, + 'date': current_time, + 'journal_id': 11 + } + + account_move = request.env['account.move'].create([param_header]) + _logger.info('Success Create Uang Muka Pembelian %s' % account_move.name) + + param_debit = { + 'move_id': account_move.id, + 'account_id': 401, # uang muka persediaan barang dagang + 'partner_id': order.partner_id.id, + 'currency_id': 12, + 'debit': self.pay_amt, + 'credit': 0, + } + + param_credit = { + 'move_id': account_move.id, + 'account_id': self.account_id.id, # bank in transit + 'partner_id': order.partner_id.id, + 'currency_id': 12, + 'debit': 0, + 'credit': self.pay_amt, + } + request.env['account.move.line'].create([param_debit, param_credit]) + return { + 'name': _('Journal Entries'), + 'view_mode': 'form', + 'res_model': 'account.move', + 'target': 'current', + 'view_id': False, + 'type': 'ir.actions.act_window', + 'res_id': account_move.id + } diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index bbb73e7d..4bfbd705 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -36,4 +36,5 @@ access_ip_lookup_line,access.ip.lookup.line,model_ip_lookup_line,,1,1,1,1 access_wati_notification,access.wati.notification,model_wati_notification,,1,1,1,1 access_user_company_request,access.user.company.request,model_user_company_request,,1,1,1,1 access_res_partner_company_type,access.res.partner.company_type,model_res_partner_company_type,,1,1,1,1 -access_uangmuka_penjualan,access.uangmuka.penjualan,model_uangmuka_penjualan,,1,1,1,1 \ No newline at end of file +access_uangmuka_penjualan,access.uangmuka.penjualan,model_uangmuka_penjualan,,1,1,1,1 +access_uangmuka_pembelian,access.uangmuka.pembelian,model_uangmuka_pembelian,,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 3220c1da..fb85f4c1 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -25,6 +25,8 @@ string="Ask Approval" type="object" /> + diff --git a/indoteknik_custom/views/uangmuka_pembelian.xml b/indoteknik_custom/views/uangmuka_pembelian.xml new file mode 100644 index 00000000..6cd0bec5 --- /dev/null +++ b/indoteknik_custom/views/uangmuka_pembelian.xml @@ -0,0 +1,30 @@ + + + + Uangmuka Pembelian + uangmuka.pembelian + +
+

+ Pembuatan semi otomatis Uang Muka Pembelian, mohon dicek kembali +

+ + + + +
+
+
+
+
+ + + Create Uang Muka Pembelian + ir.actions.act_window + uangmuka.pembelian + form + new + + +
-- cgit v1.2.3