diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-01-09 06:34:24 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-01-09 06:34:24 +0000 |
| commit | 6f62411bf3965fc27e24d8c997cc2bca771a0b8e (patch) | |
| tree | 3c0dc3837885ddf0e644558b46b598909b06d504 | |
| parent | 5b607722945ac1b64eb3e6f2393a441064783342 (diff) | |
| parent | 7622354cbe00ca428d94469c6bd5ae3de5e73a76 (diff) | |
Merged in multiple-reklas (pull request #134)
Multiple reklas
| -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 | 20 | ||||
| -rw-r--r-- | indoteknik_custom/models/invoice_reklas.py | 48 | ||||
| -rw-r--r-- | indoteknik_custom/models/invoice_reklas_penjualan.py | 80 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_advance_payment_inv.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/uangmuka_penjualan.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 4 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move.xml | 16 | ||||
| -rw-r--r-- | indoteknik_custom/views/invoice_reklas_penjualan.xml | 40 |
11 files changed, 213 insertions, 3 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index d8058bff..d6e69718 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -105,6 +105,7 @@ 'views/customer_commision.xml', 'views/wati_history.xml', 'views/purchase_order_multi_update.xml', + 'views/invoice_reklas_penjualan.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 e7bcd323..509fceef 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -95,3 +95,4 @@ from . import stock_warehouse_orderpoint from . import commision from . import sale_advance_payment_inv from . import purchase_order_multi_update +from . import invoice_reklas_penjualan diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 82a86a39..ae09d0ee 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -35,6 +35,26 @@ class AccountMove(models.Model): ('belum_upload', 'Belum Upload FP'), ('sudah_upload', 'Sudah Upload FP'), ], 'Mark Upload Faktur', compute='_compute_mark_upload_efaktur', default='belum_upload') + sale_id = fields.Many2one('sale.order', string='Sale Order') + reklas_id = fields.Many2one('account.move', string='Nomor CAB', domain="[('partner_id', '=', partner_id)]") + + def open_form_multi_create_reklas_penjualan(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_view_invoice_reklas_penjualan') + invoice = self.env['invoice.reklas.penjualan'].create([{ + 'name': '-', + }]) + for move in self: + sale_id = move.sale_id.id + self.env['invoice.reklas.penjualan.line'].create([{ + 'invoice_reklas_id': invoice.id, + 'name': move.name, + 'partner_id': move.partner_id.id, + 'sale_id': move.sale_id.id, + 'amount_untaxed_signed': move.amount_untaxed_signed, + 'amount_total_signed': move.amount_total_signed, + }]) + action['res_id'] = invoice.id + return action def _compute_mark_upload_efaktur(self): for move in self: diff --git a/indoteknik_custom/models/invoice_reklas.py b/indoteknik_custom/models/invoice_reklas.py index c2ee7e3d..b1ba49e8 100644 --- a/indoteknik_custom/models/invoice_reklas.py +++ b/indoteknik_custom/models/invoice_reklas.py @@ -94,3 +94,51 @@ class InvoiceReklas(models.TransientModel): 'type': 'ir.actions.act_window', 'res_id': account_move.id } + + + def create_reklas_penjualan(self): + if not self.pay_amt: + raise UserError('Yang dibayarkan harus diisi') + + account_ids = self._context['account_ids'] + invoices = self.env['account.move'].browse(account_ids) + current_time = datetime.now() + for invoice in invoices: + ref_name = 'REKLAS '+invoice.reklas_id.name+" UANG MUKA PENJUALAN "+invoice.name+" "+invoice.partner_id.name + parameters_header = { + 'ref': ref_name, + 'date': current_time, + 'journal_id': 13 + } + + account_move = request.env['account.move'].create([parameters_header]) + _logger.info('Success Reklas with %s' % account_move.name) + + parameter_debit = { + 'move_id': account_move.id, + 'account_id': 449, # uang muka penjualan + 'partner_id': invoice.partner_id.id, + 'currency_id': 12, + 'debit': self.pay_amt, + 'credit': 0, + 'name': ref_name + } + parameter_credit = { + 'move_id': account_move.id, + 'account_id': 395, + 'partner_id': invoice.partner_id.id, + 'currency_id': 12, + 'debit': 0, + 'credit': self.pay_amt, + 'name': ref_name + } + request.env['account.move.line'].create([parameter_debit, parameter_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/models/invoice_reklas_penjualan.py b/indoteknik_custom/models/invoice_reklas_penjualan.py new file mode 100644 index 00000000..533270d2 --- /dev/null +++ b/indoteknik_custom/models/invoice_reklas_penjualan.py @@ -0,0 +1,80 @@ +from odoo import api, fields, models, _ +from odoo.exceptions import UserError +from datetime import datetime +from odoo.http import request + +import logging + +_logger = logging.getLogger(__name__) + + +class InvoiceReklasPenjualan(models.TransientModel): + _name = 'invoice.reklas.penjualan' + _description = "digunakan untuk reklas Uang Muka Penjualan" + + name = fields.Char(string='Name') + invoice_reklas_line = fields.One2many('invoice.reklas.penjualan.line', 'invoice_reklas_id', string='Invoice Reklas Line') + + def create_reklas_penjualan(self): + # invoices = self.invoice_reklas_line.mapped('invoice_id') + invoices = self.invoice_reklas_line + + current_time = datetime.now() + account_move_ids = [] + for invoice in invoices: + ref_name = 'REKLAS ' + invoice.reklas_id.name + " UANG MUKA PENJUALAN " + invoice.name + " " + invoice.partner_id.name + parameters_header = { + 'ref': ref_name, + 'date': current_time, + 'journal_id': 13 + } + + account_move = self.env['account.move'].create([parameters_header]) + _logger.info('Success Reklas with %s' % account_move.name) + + parameter_debit = { + 'move_id': account_move.id, + 'account_id': 449, # uang muka penjualan + 'partner_id': invoice.partner_id.id, + 'currency_id': 12, + 'debit': invoice.pay_amt, + 'credit': 0, + 'name': ref_name + } + parameter_credit = { + 'move_id': account_move.id, + 'account_id': 395, + 'partner_id': invoice.partner_id.id, + 'currency_id': 12, + 'debit': 0, + 'credit': invoice.pay_amt, + 'name': ref_name + } + self.env['account.move.line'].create([parameter_debit, parameter_credit]) + account_move_ids.append(account_move.id) + invoice.unlink() + + self.unlink() + return { + 'name': _('Journal Entries'), + 'view_mode': 'tree,form', + 'res_model': 'account.move', + 'target': 'current', + 'type': 'ir.actions.act_window', + 'domain': [('id', 'in', account_move_ids)], + } + +class InvoiceReklasPenjualanLine(models.TransientModel): + _name = 'invoice.reklas.penjualan.line' + _description = "digunakan untuk reklas Uang Muka Penjualan" + + invoice_reklas_id = fields.Many2one('invoice.reklas.penjualan', string='Invoice Reklas') + pay_amt = fields.Float(string='Yang dibayarkan') + reklas_id = fields.Many2one('account.move', string='Nomor CAB', domain="[('sale_id', '=', sale_id)]") + sale_id = fields.Many2one('sale.order', string='Sale Order') + amount_untaxed_signed = fields.Float(string='Tax excluded') + amount_total_signed = fields.Float(string='Total') + name = fields.Char(string='Name') + partner_id = fields.Many2one('res.partner', string='Partner') + + diff --git a/indoteknik_custom/models/sale_advance_payment_inv.py b/indoteknik_custom/models/sale_advance_payment_inv.py index dde7ed74..ebbba6b9 100644 --- a/indoteknik_custom/models/sale_advance_payment_inv.py +++ b/indoteknik_custom/models/sale_advance_payment_inv.py @@ -16,6 +16,7 @@ class SaleAdvancePaymentInv(models.TransientModel): 'invoice_user_id': order.user_id.id, 'narration': order.note, 'partner_id': parent_id, + 'sale_id': order.id, 'fiscal_position_id': (order.fiscal_position_id or order.fiscal_position_id.get_fiscal_position(order.partner_id.id)).id, 'partner_shipping_id': parent_id.id, 'currency_id': order.pricelist_id.currency_id.id, diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index cb963122..95cbf8ce 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -379,7 +379,7 @@ class SaleOrder(models.Model): def _validate_npwp(self): num_digits = sum(c.isdigit() for c in self.npwp) - if num_digits <= 10: + if num_digits < 10: raise UserError("NPWP harus memiliki minimal 10 digit") # pattern = r'^\d{10,}$' diff --git a/indoteknik_custom/models/uangmuka_penjualan.py b/indoteknik_custom/models/uangmuka_penjualan.py index 93a33b52..65f5361b 100644 --- a/indoteknik_custom/models/uangmuka_penjualan.py +++ b/indoteknik_custom/models/uangmuka_penjualan.py @@ -48,7 +48,8 @@ class UangmukaPenjualan(models.TransientModel): param_header = { 'ref': ref_label, 'date': current_time, - 'journal_id': 11 + 'journal_id': 11, + 'sale_id': order.id, } account_move = request.env['account.move'].create([param_header]) diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index dd7605ab..8520961d 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -85,4 +85,6 @@ 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 -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 +access_purchase_order_multi_update,access.purchase.order.multi_update,model_purchase_order_multi_update,,1,1,1,1 +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
\ No newline at end of file diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 7995b83b..ddd266bb 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -15,6 +15,13 @@ </field> <field name="payment_reference" position="after"> <field name="date_completed" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> + <field name="reklas_id" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> + </field> + <field name="invoice_date" position="after"> + <field name="sale_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> + </field> + <field name="ref" position="after"> + <field name="sale_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'entry')]}"/> </field> <field name="efaktur_document" position="before"> <field name="no_faktur_pajak" attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}"/> @@ -23,6 +30,7 @@ <attribute name="widget">pdf_viewer</attribute> </field> <field name="invoice_user_id" position="after"> + <field name="invoice_origin"/> <field name="date_kirim_tukar_faktur"/> <field name="shipper_faktur_id"/> <field name="resi_tukar_faktur"/> @@ -108,5 +116,13 @@ <field name="state">code</field> <field name="code">action = records.open_form_multi_update()</field> </record> + + <record id="account_move_multi_create_reklas_ir_actions_server" model="ir.actions.server"> + <field name="name">Create Reklas Penjualan</field> + <field name="model_id" ref="account.model_account_move"/> + <field name="binding_model_id" ref="account.model_account_move"/> + <field name="state">code</field> + <field name="code">action = records.open_form_multi_create_reklas_penjualan()</field> + </record> </data> </odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/invoice_reklas_penjualan.xml b/indoteknik_custom/views/invoice_reklas_penjualan.xml new file mode 100644 index 00000000..9c875cca --- /dev/null +++ b/indoteknik_custom/views/invoice_reklas_penjualan.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <record id="view_invoice_reklas_penjualan" model="ir.ui.view"> + <field name="name">Invoice Reklas Penjualan</field> + <field name="model">invoice.reklas.penjualan</field> + <field name="arch" type="xml"> + <form> + <sheet> + <field name="name" invisible="1"/> + <field + name="invoice_reklas_line" + mode="tree" + > + <tree create="0" editable="bottom"> + <field name="name" readonly="1"/> + <field name="partner_id" readonly="1"/> + <field name="pay_amt" required="1"/> + <field name="reklas_id" required="1"/> + <field name="amount_untaxed_signed" readonly="1"/> + <field name="sale_id" readonly="1"/> + <field name="amount_total_signed" readonly="1"/> + </tree> + </field> + </sheet> + <footer> + <button name="create_reklas_penjualan" string="Create Reklas" type="object" default_focus="1" class="oe_highlight"/> + <button string="Cancel" class="btn btn-secondary" special="cancel" /> + </footer> + </form> + </field> + </record> + + <record id="action_view_invoice_reklas_penjualan" model="ir.actions.act_window"> + <field name="name">Create Reklas Penjualan</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">invoice.reklas.penjualan</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> +</odoo> |
