diff options
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/uangmuka_pembelian.py | 65 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/uangmuka_pembelian.xml | 30 |
6 files changed, 101 insertions, 1 deletions
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" /> + <button name="indoteknik_custom.action_view_uangmuka_pembelian" string="UangMuka" + type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/> </button> <field name="date_order" position="before"> <field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <record id="view_uangmuka_pembelian" model="ir.ui.view"> + <field name="name">Uangmuka Pembelian</field> + <field name="model">uangmuka.pembelian</field> + <field name="arch" type="xml"> + <form string="Invoice Sales Order"> + <p class="oe_grey"> + Pembuatan semi otomatis Uang Muka Pembelian, mohon dicek kembali + </p> + <group> + <field name="pay_amt"/> + <field name="account_id" domain="[('name', 'ilike', 'intransit')]"/> + </group> + <footer> + <button name="create_uangmukapembelian" id="create_uangmukapembelian" string="Create" type="object" required="1"/> + </footer> + </form> + </field> + </record> + + <record id="action_view_uangmuka_pembelian" model="ir.actions.act_window"> + <field name="name">Create Uang Muka Pembelian</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">uangmuka.pembelian</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + +</odoo> |
