From 8b3d929a7cae089ac12d9752d3f97793dbe084d5 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 11:02:57 +0700 Subject: add new product rest api --- indoteknik_custom/models/x_manufactures.py | 2 ++ indoteknik_custom/views/x_manufactures.xml | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index 1d215cf8..e6842797 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -42,6 +42,8 @@ class XManufactures(models.Model): ('reset', 'Reset'), ('done', 'Done') ], string="Cache Reset") + sequence = fields.Integer(string='Sequence', help='Urutan tampil di homepage jika show as new product') + show_as_new_product = fields.Boolean(string='Show as New Product', help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru') def cache_reset(self): manufactures = self.env['x_manufactures'].search([ diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index d122c6c1..c7cedd9c 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -16,13 +16,14 @@ x_manufactures - + + @@ -42,6 +43,8 @@ + + @@ -54,7 +57,16 @@ - + + + + + + + + + + -- cgit v1.2.3 From e74ac27eb94a05c569f9789b1f875f7c85b6dc02 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 11:22:05 +0700 Subject: add is new product field --- indoteknik_custom/models/product_template.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index dbbd4ad4..9f0410f4 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -44,6 +44,8 @@ class ProductTemplate(models.Model): usage = fields.Char(string='Usage') specification = fields.Char(string='Specification') material = fields.Char(string='Material') + is_new_product = fields.Boolean(string='Produk Baru', + help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru') # def write(self, vals): # if 'solr_flag' not in vals and self.solr_flag == 1: -- cgit v1.2.3 From 985f2175d80b7d2fce25813512ad6f1df28dd1b9 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 15:45:03 +0700 Subject: custom invoice print --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/report/report_invoice.xml | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 indoteknik_custom/report/report_invoice.xml (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 421b7cb2..92fa895c 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -60,6 +60,7 @@ 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', 'report/purchase_order.xml', + 'report/report_invoice.xml' ], 'demo': [], 'css': [], diff --git a/indoteknik_custom/report/report_invoice.xml b/indoteknik_custom/report/report_invoice.xml new file mode 100644 index 00000000..cc9361a4 --- /dev/null +++ b/indoteknik_custom/report/report_invoice.xml @@ -0,0 +1,11 @@ + + + -- cgit v1.2.3 From 80585674bc624a63b137caf643aa5a716c96b117 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 15:50:59 +0700 Subject: empty --- indoteknik_custom/report/report_invoice.xml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/report/report_invoice.xml b/indoteknik_custom/report/report_invoice.xml index cc9361a4..bb81e9e6 100644 --- a/indoteknik_custom/report/report_invoice.xml +++ b/indoteknik_custom/report/report_invoice.xml @@ -1,11 +1,3 @@ - + -- cgit v1.2.3 From b45655a8598d1d841c7cc6c1049e83a6b53a10ef Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 15:53:03 +0700 Subject: manifest --- indoteknik_custom/__manifest__.py | 3 +-- indoteknik_custom/report/report_invoice.xml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 92fa895c..818607c1 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -59,8 +59,7 @@ 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', - 'report/purchase_order.xml', - 'report/report_invoice.xml' + 'report/purchase_order.xml' ], 'demo': [], 'css': [], diff --git a/indoteknik_custom/report/report_invoice.xml b/indoteknik_custom/report/report_invoice.xml index bb81e9e6..56d2f04b 100644 --- a/indoteknik_custom/report/report_invoice.xml +++ b/indoteknik_custom/report/report_invoice.xml @@ -1,3 +1,3 @@ - + -- cgit v1.2.3 From 8204c2e7fa08fda5f4ef88258314f7189213d369 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 15:59:36 +0700 Subject: deleted --- indoteknik_custom/report/report_invoice.xml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 indoteknik_custom/report/report_invoice.xml (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/report/report_invoice.xml b/indoteknik_custom/report/report_invoice.xml deleted file mode 100644 index 56d2f04b..00000000 --- a/indoteknik_custom/report/report_invoice.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - -- cgit v1.2.3 From f1ec58d2bafd95927d75e448b3d4fbc2d0cb2796 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 16:21:39 +0700 Subject: fix --- indoteknik_custom/__manifest__.py | 3 ++- indoteknik_custom/report/report_invoice.xml | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/report/report_invoice.xml (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 818607c1..92fa895c 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -59,7 +59,8 @@ 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', - 'report/purchase_order.xml' + 'report/purchase_order.xml', + 'report/report_invoice.xml' ], 'demo': [], 'css': [], diff --git a/indoteknik_custom/report/report_invoice.xml b/indoteknik_custom/report/report_invoice.xml new file mode 100644 index 00000000..cc9361a4 --- /dev/null +++ b/indoteknik_custom/report/report_invoice.xml @@ -0,0 +1,11 @@ + + + -- cgit v1.2.3 From fcff03f98816bc0c8501206de3e4dfac979622b1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 12 Jan 2023 16:46:39 +0700 Subject: revert --- indoteknik_custom/report/report_invoice.xml | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/report/report_invoice.xml b/indoteknik_custom/report/report_invoice.xml index cc9361a4..996dcf3e 100644 --- a/indoteknik_custom/report/report_invoice.xml +++ b/indoteknik_custom/report/report_invoice.xml @@ -1,11 +1,4 @@ -- cgit v1.2.3 From a560384285965c54d1a6db17e935ebdd829893aa Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 13 Jan 2023 09:45:49 +0700 Subject: add multiple partner if not parent company in dunning run --- indoteknik_custom/models/dunning_run.py | 52 ++++++++++++++++++++++++++++----- indoteknik_custom/views/dunning_run.xml | 5 ++-- indoteknik_custom/views/ir_sequence.xml | 10 +++++++ 3 files changed, 57 insertions(+), 10 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index 5d98bb98..ef6407e8 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -10,24 +10,55 @@ class DunningRun(models.Model): _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') + number = fields.Char(string='Document No', index=True, copy=False, readonly=True) + dunning_date = fields.Date(string='Dunning Date', required=True) partner_id = fields.Many2one( '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') + # dunning_level = fields.Integer(string='Dunning Level', default=30, help='30 hari sebelum jatuh tempo invoice') + + def generate_dunning_line(self): + if self.partner_id.parent_id: + raise UserError('Harus pilih parent company') + + partners = [] + partners += self.partner_id.child_ids + partners.append(self.partner_id) + + for partner in partners: + query = [ + ('move_type', '=', 'out_invoice'), + ('partner_id', '=', partner.id), + ('outstanding_amount', '>', 0), + ] + invoices = self.env['account.move'].search(query, order='invoice_date') + for invoice in invoices: + parameter_line = { + 'dunning_id': self.id, + 'partner_id': invoice.partner_id, + 'invoice_id': invoice.id, + 'date_invoice': invoice.invoice_date, + 'efaktur_id': invoice.efaktur_id, + 'reference': invoice.ref, + 'open_amt': invoice.outstanding_amount + } + self.env['dunning.run.line'].create([parameter_line]) + + @api.model + def create(self, vals): + vals['number'] = self.env['ir.sequence'].next_by_code('dunning.run') or '0' + result = super(DunningRun, self).create(vals) + return result 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), + ('partner_id', '=', self.partner_id.id), ('move_type', '=', 'out_invoice'), ('state', '=', 'posted'), ]) @@ -37,9 +68,11 @@ class DunningRun(models.Model): 'dunning_id': self.id, 'invoice_id': invoice.id, 'date_invoice': invoice.invoice_date, - 'efaktur_id': invoice.efaktur_id, + 'efaktur_id': invoice.efaktur_id.id, 'reference': invoice.ref, - 'open_amt': invoice.amount_residual_signed + 'total_amt': invoice.amount_total, + 'open_amt': invoice.amount_residual_signed, + 'due_date': invoice.invoice_date_due }]) count += 1 _logger.info("Dunning Line generated %s" % count) @@ -51,10 +84,13 @@ class DunningRunLine(models.Model): _order = 'dunning_id, id' dunning_id = fields.Many2one('dunning.run', string='Dunning Ref', required=True, ondelete='cascade', index=True, copy=False) + partner_id = fields.Many2one('res.partner', string='Customer') 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') + total_amt = fields.Float(string='Total Amount') open_amt = fields.Float(string='Open Amount') + due_date = fields.Date(string='Due Date') diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index b18748ea..427653fe 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -9,7 +9,6 @@ - @@ -23,7 +22,9 @@ + + @@ -39,7 +40,7 @@ - +