From f0caad5740ae914391dbe7650977c00df2379f52 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 16 Jan 2023 13:08:22 +0700 Subject: change limit to 100 --- indoteknik_custom/models/product_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index ef0ead1b..caf7ea3a 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -146,7 +146,7 @@ class ProductTemplate(models.Model): ('active', '=', True), ('last_calculate_rating', '=', False), # ('id', '=', 22798), - ], limit=10000) + ], limit=100) for product in products: # print("Calculate Rating Product ", product) @@ -171,7 +171,7 @@ class ProductTemplate(models.Model): ('type', '=', 'product'), ('active', '=', True), ('last_calculate_rating', '<', delta_time), - ], limit=10000) + ], limit=100) for product in products: print("Calculate Rating Product OutOfDate", product) -- cgit v1.2.3 From 09cfa10a6ac0335b4342665707269cc5aa7bbcf8 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 16 Jan 2023 13:22:47 +0700 Subject: revert --- indoteknik_custom/models/stock_picking.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index d19214d2..84a374c5 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -145,10 +145,8 @@ class StockPicking(models.Model): continue raise UserError('Sudah pernah dikirim kalender') - is_delivered_validation = self.env['ir.config_parameter'].get_param( - 'stock_picking.qty_delivered_validation') for line in self.move_line_ids_without_package: - if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing' and is_delivered_validation == 'Y': + if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing': if line.move_id.sale_line_id.qty_delivered + line.qty_done > line.move_id.sale_line_id.product_uom_qty: raise UserError("Qty Delivered akan lebih dari Qty SO") -- cgit v1.2.3 From 83ead9edac739720168d615f6282e3978634e461 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 16 Jan 2023 15:44:51 +0700 Subject: fix generate dunning run --- indoteknik_custom/models/dunning_run.py | 75 ++++++++++++++++++--------------- indoteknik_custom/views/dunning_run.xml | 31 ++++++++++++-- 2 files changed, 68 insertions(+), 38 deletions(-) diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index ed9aa7c0..56a33578 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -17,8 +17,37 @@ class DunningRun(models.Model): 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') + 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') + is_validated = fields.Boolean(string='Validated') + + def copy_date_faktur(self): + if not self.is_validated: + raise UserError('Harus di validate dulu') + for line in self.dunning_line: + invoice = line.invoice_id + if not invoice.date_kirim_tukar_faktur: + invoice.date_kirim_tukar_faktur = self.date_kirim_tukar_faktur + if not invoice.resi_tukar_faktur: + invoice.resi_tukar_faktur = self.resi_tukar_faktur + if not invoice.date_terima_tukar_faktur: + invoice.date_terima_tukar_faktur = self.date_terima_tukar_faktur + if not invoice.shipper_faktur_id: + invoice.shipper_faktur_id = self.shipper_faktur_id + + def validate_dunning(self): + if not self.dunning_line: + raise UserError('Dunning Line masih kosong, generate dulu') + else: + self.is_validated = True def generate_dunning_line(self): + if self.is_validated: + raise UserError('Sudah di validate, tidak bisa digenerate ulang') + if self.dunning_line: + raise UserError('Harus hapus semua line jika ingin generate ulang') if self.partner_id.parent_id: raise UserError('Harus pilih parent company') @@ -29,21 +58,26 @@ class DunningRun(models.Model): for partner in partners: query = [ ('move_type', '=', 'out_invoice'), + ('state', '=', 'posted'), ('partner_id', '=', partner.id), - ('outstanding_amount', '>', 0), + ('amount_residual_signed', '>', 0), ] invoices = self.env['account.move'].search(query, order='invoice_date') + count = 0 for invoice in invoices: - parameter_line = { + self.env['dunning.run.line'].create([{ 'dunning_id': self.id, - 'partner_id': invoice.partner_id, + 'partner_id': invoice.partner_id.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.outstanding_amount - } - self.env['dunning.run.line'].create([parameter_line]) + '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) @api.model def create(self, vals): @@ -51,33 +85,6 @@ class DunningRun(models.Model): result = super(DunningRun, self).create(vals) return result - def generate_dunning_line(self): - # validation - if not self.partner_id: - raise UserError('Customer harus diisi') - - invoices = self.env['account.move'].search([ - ('amount_residual_signed', '>', 0), - ('partner_id', '=', self.partner_id.id), - ('move_type', '=', 'out_invoice'), - ('state', '=', 'posted'), - ]) - count = 0 - for invoice in invoices: - self.env['dunning.run.line'].create([{ - 'dunning_id': self.id, - 'partner_id': invoice.partner_id.id, - 'invoice_id': invoice.id, - 'date_invoice': invoice.invoice_date, - 'efaktur_id': invoice.efaktur_id.id, - 'reference': invoice.ref, - '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) - 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 ab01d476..c251b206 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -5,10 +5,14 @@ dunning.run - + + + + + @@ -39,14 +43,33 @@
- - - +
+ + + +
+ + + + + +
-- cgit v1.2.3 From f960f1c092cdb7669152f8caca7afad314a59877 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 16 Jan 2023 17:00:16 +0700 Subject: change logic api new product --- indoteknik_api/controllers/api_v1/product.py | 39 +++++++++++++++++++++++----- indoteknik_custom/models/product_template.py | 3 +-- indoteknik_custom/views/x_manufactures.xml | 3 --- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 28a63ed5..2e8e0226 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -1,6 +1,7 @@ from .. import controller from odoo import http from odoo.http import request +from datetime import datetime, timedelta import ast @@ -12,20 +13,44 @@ class Product(controller.Controller): if not self.authenticate(): return self.response(code=401, description='Unauthorized') base_url = request.env['ir.config_parameter'].get_param('web.base.url') - query = [('show_as_new_product', '=', True)] - brands = request.env['x_manufactures'].search(query, order='sequence') + current_time = datetime.now() + delta_time = current_time - timedelta(days=30) + + delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') + query_products = [ + ('type', '=', 'product'), + ('active', '=', True), + ('image_128', '!=', False), + ('website_description', '!=', False), + ('create_date', '>=', delta_time), + ] + new_products = request.env['product.template'].search(query_products, order='name', limit=500) + brands = [] + for product in new_products: + brands.append(product.x_manufacture) + brands = list(dict.fromkeys(brands)) + data = [] + count = 0 for brand in brands: - query_products = [ - ('is_new_product', '=', True), + count += 1 + if count == 11: + break + query = [ + ('type', '=', 'product'), + ('active', '=', True), ('x_manufacture', '=', brand.id), + ('image_128', '!=', False), + ('website_description', '!=', False), + ('create_date', '>=', delta_time), ] - products = request.env['product.template'].search(query_products, order='name') + products = request.env['product.template'].search(query, order='name', limit=36) data.append({ 'manufacture_id': brand.id, - 'sequence': brand.sequence, + 'sequence': brand.sequence if brand.sequence else count, 'name': brand.x_name, - 'image': base_url + 'api/image/x_manufactures/x_logo_manufacture/' + str(brand.id) if brand.x_logo_manufacture else '', + 'image': base_url + 'api/image/x_manufactures/x_logo_manufacture/' + str( + brand.id) if brand.x_logo_manufacture else '', 'products': [request.env['product.template'].api_single_response(x) for x in products] }) return self.response(data) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index caf7ea3a..74b4edb1 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -57,7 +57,6 @@ class ProductTemplate(models.Model): current_time = datetime.now() delta_time = current_time - timedelta(days=30) - #current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') products = self.env['product.template'].search([ @@ -65,7 +64,7 @@ class ProductTemplate(models.Model): ('active', '=', True), ('product_rating', '>', 3), ('create_date', '>=', delta_time), - ], limit=1000) + ], limit=100) seq = 0 for product in products: diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index cc8fd10c..e51cb6a7 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -43,7 +43,6 @@ - @@ -64,8 +63,6 @@ - - -- cgit v1.2.3