From 832fa66dd923d06b054efc33bce05ceb3ad52a74 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 26 Oct 2022 10:09:31 +0700 Subject: Update __manifest__.py, account_move.py, and account_move.xml --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/account_move.py | 4 ++++ indoteknik_custom/views/account_move.xml | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 indoteknik_custom/views/account_move.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 96988258..ad3f8af8 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -42,6 +42,7 @@ 'views/stock_picking_type.xml', 'views/users.xml', 'views/delivery_carrier.xml', + 'views/account_move.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 224e22ec..59b9ef2c 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -5,3 +5,7 @@ class AccountMove(models.Model): _inherit = 'account.move' date_send_fp = fields.Datetime(string="Tanggal Kirim Faktur Pajak") last_log_fp = fields.Char(string="Log Terakhir Faktur Pajak") + # use for industry business + date_kirim_tukar_faktur = fields.Date(string='Tanggal Kirim Tukar Faktur') + resi_tukar_faktur = fields.Char(string='Resi Tukar Faktur') + date_terima_tukar_faktur = fields.Date(string='Tanggal Terima Tukar Faktur') diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml new file mode 100644 index 00000000..01c4e8b3 --- /dev/null +++ b/indoteknik_custom/views/account_move.xml @@ -0,0 +1,17 @@ + + + + + Account Move + account.move + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 9c167425c8f5db32b1361b47570fc1fa5475e4e4 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 26 Oct 2022 10:41:32 +0700 Subject: Update account_move.py --- indoteknik_custom/models/account_move.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 59b9ef2c..126ff4c3 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -1,4 +1,5 @@ from odoo import models, api, fields +from datetime import timedelta class AccountMove(models.Model): @@ -9,3 +10,14 @@ class AccountMove(models.Model): date_kirim_tukar_faktur = fields.Date(string='Tanggal Kirim Tukar Faktur') resi_tukar_faktur = fields.Char(string='Resi Tukar Faktur') date_terima_tukar_faktur = fields.Date(string='Tanggal Terima Tukar Faktur') + + @api.onchange('date_kirim_tukar_faktur') + def change_date_kirim_tukar_faktur(self): + for invoice in self: + tukar_date = invoice.date_kirim_tukar_faktur + term = invoice.invoice_payment_term_id + add_days = 0 + for line in term.line_ids: + add_days += line.days + due_date = tukar_date + timedelta(days=add_days) + invoice.invoice_date_due = due_date -- cgit v1.2.3 From 28c6731e8ee1394f61ff88f2750f81d14eb5fb4e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 26 Oct 2022 10:45:28 +0700 Subject: change due date if tukar faktur --- indoteknik_custom/models/account_move.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 126ff4c3..fd9ed758 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -21,3 +21,14 @@ class AccountMove(models.Model): add_days += line.days due_date = tukar_date + timedelta(days=add_days) invoice.invoice_date_due = due_date + + @api.onchange('date_terima_tukar_faktur') + def change_date_terima_tukar_faktur(self): + for invoice in self: + tukar_date = invoice.date_terima_tukar_faktur + term = invoice.invoice_payment_term_id + add_days = 0 + for line in term.line_ids: + add_days += line.days + due_date = tukar_date + timedelta(days=add_days) + invoice.invoice_date_due = due_date -- cgit v1.2.3 From 259497e322a2d7f482e3e345725a19ecc42ef96c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 26 Oct 2022 12:02:31 +0700 Subject: window dunning run, still error, need fix --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/dunning_run.py | 33 +++++++++++++++++++++++++++++++++ indoteknik_custom/views/dunning_run.xml | 21 +++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 indoteknik_custom/models/dunning_run.py create mode 100644 indoteknik_custom/views/dunning_run.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index ad3f8af8..a703bcef 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -43,6 +43,7 @@ 'views/users.xml', 'views/delivery_carrier.xml', 'views/account_move.xml', + 'views/dunning_run.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 37a8d31f..94fe56fe 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -28,3 +28,4 @@ from . import product_pricelist from . import users from . import ir_attachment from . import delivery_carrier +from . import dunning_run diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py new file mode 100644 index 00000000..dc943c23 --- /dev/null +++ b/indoteknik_custom/models/dunning_run.py @@ -0,0 +1,33 @@ +from odoo import models, api, fields + + +class DunningRun(models.Model): + _name = 'dunning.run' + _description = 'Dunning Run' + _order = 'dunning_date desc, id desc' + + number = fields.Char(string='Document No', index=True, required=True, copy=False, readonly=True) + dunning_date = fields.Date(string='Dunning Date') + partner_id = fields.Many2one( + 'res.partner', string='Customer', readonly=True, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, + required=True, change_default=True, index=True, tracking=1, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", ) + order_line = fields.One2many('dunning.run.line', 'dunning_id', string='Dunning Lines', + auto_join=True) + dunning_level = fields.Integer(string='Dunning Level', default=30, help='30 hari sebelum jatuh tempo invoice') + + +class DunningRunLine(models.Model): + _name = 'dunning.run.line' + _description = 'Dunning Run Line' + _order = 'dunning_id, id' + + dunning_id = fields.Many2one('dunning.run', string='Dunning Ref', required=True, ondelete='cascade', index=True, copy=False) + invoice_id = fields.Many2one('account.move', string='Invoice') + date_invoice = fields.Date(string='Invoice Date') + # due_date = fields.Date(string='Due Date') + efaktur_id = fields.Many2one('vit.efaktur', string='Faktur Pajak') + reference = fields.Char(string='Reference') + open_amt = fields.Float(string='Open Amount') + diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml new file mode 100644 index 00000000..5036b1cd --- /dev/null +++ b/indoteknik_custom/views/dunning_run.xml @@ -0,0 +1,21 @@ + + + + dunning.run.tree + dunning.run + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 780b7ce9643644bd3ea020c02d66257d85d53778 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 26 Oct 2022 15:56:00 +0700 Subject: Update dunning_run.py, ir.model.access.csv, and dunning_run.xml --- indoteknik_custom/models/dunning_run.py | 9 ++--- indoteknik_custom/security/ir.model.access.csv | 4 ++- indoteknik_custom/views/dunning_run.xml | 50 ++++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index dc943c23..b6531c5c 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -9,12 +9,9 @@ class DunningRun(models.Model): number = fields.Char(string='Document No', index=True, required=True, copy=False, readonly=True) dunning_date = fields.Date(string='Dunning Date') partner_id = fields.Many2one( - 'res.partner', string='Customer', readonly=True, - states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, - required=True, change_default=True, index=True, tracking=1, - domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", ) - order_line = fields.One2many('dunning.run.line', 'dunning_id', string='Dunning Lines', - auto_join=True) + 'res.partner', string='Customer', + required=True, change_default=True, index=True, tracking=1) + dunning_line = fields.One2many('dunning.run.line', 'dunning_id', string='Dunning Lines', auto_join=True) dunning_level = fields.Integer(string='Dunning Level', default=30, help='30 hari sebelum jatuh tempo invoice') diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 78e56b30..9d2137f6 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -11,4 +11,6 @@ access_purchase_pricelist,access.purchase.pricelist,model_purchase_pricelist,,1, access_sale_monitoring,access.sale.monitoring,model_sale_monitoring,,1,1,1,1 access_sale_monitoring_detail,access.sale.monitoring.detail,model_sale_monitoring_detail,,1,1,1,1 access_delivery_order,access.delivery.order,model_delivery_order,,1,1,1,1 -access_delivery_order_line,access.delivery.order.line,model_delivery_order_line,,1,1,1,1 \ No newline at end of file +access_delivery_order_line,access.delivery.order.line,model_delivery_order_line,,1,1,1,1 +access_dunning_run,access.dunning.run,model_dunning_run,,1,1,1,1 +access_dunning_run_line,access.dunning.run.line,model_dunning_run_line,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index 5036b1cd..b0bf8654 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -14,8 +14,54 @@ + + dunning.run.line.tree + dunning.run.line + + + + + + + + + + + + + dunning.run.form + dunning.run + +
+ +
+ + + + + + + + + + + + + + + + + + + Dunning Run + ir.actions.act_window + dunning.run + tree,form + + + action="dunning_run_action" + parent="account.menu_finance_reports" + sequence="200"/> \ No newline at end of file -- cgit v1.2.3 From ca21d92d64d9d8574cbfa4c227989f05d6ca9f0b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 27 Oct 2022 09:44:32 +0700 Subject: Update dunning_run.py and dunning_run.xml --- indoteknik_custom/models/dunning_run.py | 30 ++++++++++++++++++++++++++++++ indoteknik_custom/views/dunning_run.xml | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index b6531c5c..5d98bb98 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -1,4 +1,8 @@ from odoo import models, api, fields +from odoo.exceptions import AccessError, UserError, ValidationError +import logging + +_logger = logging.getLogger(__name__) class DunningRun(models.Model): @@ -14,6 +18,32 @@ class DunningRun(models.Model): dunning_line = fields.One2many('dunning.run.line', 'dunning_id', string='Dunning Lines', auto_join=True) dunning_level = fields.Integer(string='Dunning Level', default=30, help='30 hari sebelum jatuh tempo invoice') + def generate_dunning_line(self): + # validation + if not self.partner_id: + raise UserError('Customer harus diisi') + if self.dunning_level <= 0: + raise UserError('Dunning Level harus diisi lebih dari 0') + + invoices = self.env['account.move'].search([ + ('amount_residual_signed', '>', 0), + ('partner_id', '=', self.partner_id), + ('move_type', '=', 'out_invoice'), + ('state', '=', 'posted'), + ]) + count = 0 + for invoice in invoices: + self.env['dunning.run.line'].create([{ + 'dunning_id': self.id, + 'invoice_id': invoice.id, + 'date_invoice': invoice.invoice_date, + 'efaktur_id': invoice.efaktur_id, + 'reference': invoice.ref, + 'open_amt': invoice.amount_residual_signed + }]) + count += 1 + _logger.info("Dunning Line generated %s" % count) + class DunningRunLine(models.Model): _name = 'dunning.run.line' diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index b0bf8654..b18748ea 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -33,13 +33,18 @@ dunning.run
- +
+