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/models/account_move.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indoteknik_custom/models') 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') -- 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(+) (limited to 'indoteknik_custom/models') 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(+) (limited to 'indoteknik_custom/models') 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/models/__init__.py | 1 + indoteknik_custom/models/dunning_run.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 indoteknik_custom/models/dunning_run.py (limited to 'indoteknik_custom/models') 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') + -- 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 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'indoteknik_custom/models') 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') -- 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 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'indoteknik_custom/models') 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' -- cgit v1.2.3 From d5e783d3a91b9ba782f4aebb21e558779a83f8b6 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 1 Nov 2022 11:00:23 +0700 Subject: add shipper faktur --- indoteknik_custom/models/account_move.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index fd9ed758..aa4b0b1e 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -7,9 +7,10 @@ class AccountMove(models.Model): 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') + date_kirim_tukar_faktur = fields.Date(string='Kirim Faktur') + resi_tukar_faktur = fields.Char(string='Resi Faktur') + date_terima_tukar_faktur = fields.Date(string='Terima Faktur') + shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur') @api.onchange('date_kirim_tukar_faktur') def change_date_kirim_tukar_faktur(self): -- cgit v1.2.3