From 6a87a12ca305d22db5532d1c645b67e9c5bf9747 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 28 Oct 2023 09:05:59 +0700 Subject: Update auth function --- indoteknik_custom/models/res_users.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 7f94771f..02433deb 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -1,4 +1,7 @@ from odoo import models, fields +from datetime import datetime +from pytz import UTC +import random, string class ResUsers(models.Model): @@ -6,3 +9,22 @@ class ResUsers(models.Model): reset_password_token = fields.Char(string="Reset Password Token") activation_token = fields.Char(string="Activation Token") + otp_code = fields.Char(string='OTP Code') + otp_create_date = fields.Datetime(string='OTP Create Date') + + def _generate_otp(self): + for user in self: + user.otp_code = '{:04d}'.format(random.randint(0, 9999)) + user.otp_create_date = fields.Datetime.now() + + def _generate_activation_token(self): + for user in self: + token_source = string.ascii_letters + string.digits + user.activation_token = ''.join(random.choice(token_source) for i in range(21)) + + def send_activation_mail(self): + template = self.env.ref('indoteknik_custom.mail_template_res_user_activation_request') + for user in self: + user._generate_otp() + user._generate_activation_token() + template.send_mail(user.id, force_send=True) \ No newline at end of file -- cgit v1.2.3 From 0831511787b1cd2171d6dd1dd6c2c9da46b64d2e Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 30 Oct 2023 09:53:05 +0700 Subject: Add get activation token url on activation mail template --- indoteknik_custom/models/res_users.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 02433deb..1e729550 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -27,4 +27,8 @@ class ResUsers(models.Model): for user in self: user._generate_otp() user._generate_activation_token() - template.send_mail(user.id, force_send=True) \ No newline at end of file + template.send_mail(user.id, force_send=True) + + def get_activation_token_url(self): + base_url = self.env['ir.config_parameter'].get_param('site.base.url') + return f'{base_url}/register?activation=token&token={self.activation_token}' -- cgit v1.2.3 From 9a6918c3ee15cbed74af9fcf838a667dac166b32 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 10 Nov 2023 13:52:18 +0700 Subject: add other info in commision and add name in dunning run --- indoteknik_custom/models/commision.py | 4 ++++ indoteknik_custom/models/dunning_run.py | 1 + 2 files changed, 5 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index d4942a0d..a11d85c7 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -148,6 +148,10 @@ class CustomerCommision(models.Model): ('cashback', 'Cashback'), ('rebate', 'Rebate'), ], string='Commision Type', required=True) + bank_name = fields.Char(string='Bank', tracking=3) + account_name = fields.Char(string='Account Name', tracking=3) + bank_account = fields.Char(string='Account No', tracking=3) + note_transfer = fields.Char(string='Keterangan') # add status for type of commision, fee, rebate / cashback # include child or not? diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index 8e5b2c19..abfd68be 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -10,6 +10,7 @@ class DunningRun(models.Model): _name = 'dunning.run' _description = 'Dunning Run' _order = 'dunning_date desc, id desc' + _rec_name = 'number' number = fields.Char(string='Document No', index=True, copy=False, readonly=True) dunning_date = fields.Date(string='Dunning Date', required=True) -- cgit v1.2.3 From e7dc713b08b356100960e93d552b3a3a2a31727c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 10 Nov 2023 16:28:06 +0700 Subject: Fix bug voucher --- indoteknik_custom/models/voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 66c50c24..2eedc861 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -219,7 +219,7 @@ class Voucher(models.Model): tnc.append(f'
  • Voucher berlaku {self._res_remaining_time()} lagi
  • ') tnc.append(f'
  • Voucher tidak bisa digunakan apabila terdapat produk flash sale
  • ') if len(self.voucher_line) > 0: - brand_names = ', '.join([x.manufacture_id.x_name for x in self.voucher_line]) + brand_names = ', '.join([x.manufacture_id.x_name or '' for x in self.voucher_line]) tnc.append(f'
  • Voucher berlaku untuk produk dari brand {brand_names}
  • ') tnc.append(self.generate_detail_tnc()) tnc.append('') -- cgit v1.2.3 From 132d4b80f3d5dad792468bd14961f6a9540122e2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 15 Nov 2023 10:32:25 +0700 Subject: add new role for wms and fix bug delete reconcile --- indoteknik_custom/models/account_move.py | 5 +++-- indoteknik_custom/models/users.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index fe9db583..d55cca38 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -48,8 +48,9 @@ class AccountMove(models.Model): def unlink(self): res = super(AccountMove, self).unlink() - if self.state == 'posted': - raise UserError('Data Hanya Bisa Di Cancel') + for rec in self: + if rec.state == 'posted': + raise UserError('Data Hanya Bisa Di Cancel') return res def button_cancel(self): diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index 2ff9933e..d95b56e7 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -12,6 +12,8 @@ class Users(models.Model): is_logistic_approver = fields.Boolean(string='Logistic Approver', help='Berhak Approval Penerimaan Barang') is_editor_product = fields.Boolean(string='Editor Product', help='Berhak Mengedit Data Product') is_admin_reconcile = fields.Boolean(string='Admin Reconcile', help='Berhak Mengedit Journal Reconcile') + is_inbound = fields.Boolean(string='Operator Inbound') + is_outbound = fields.Boolean(string='Operator Outbound') def notify_internal_users(self, message, title): users = self.search([('share', '=', False)]) -- cgit v1.2.3 From cc9c34431ec16a493808a307405b772d83f4edc8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Nov 2023 09:11:39 +0700 Subject: Add voucher on activation mail feature --- indoteknik_custom/models/res_users.py | 7 +++++++ indoteknik_custom/models/voucher.py | 3 +++ 2 files changed, 10 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 1e729550..09321fc6 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -32,3 +32,10 @@ class ResUsers(models.Model): def get_activation_token_url(self): base_url = self.env['ir.config_parameter'].get_param('site.base.url') return f'{base_url}/register?activation=token&token={self.activation_token}' + + def get_voucher_code(self, type): + if type == 'activation': + vouchers = self.env['voucher'].get_active_voucher([('show_on_email', '=', 'user_activation')]) + if not vouchers: return None + return ', '.join(x.code for x in vouchers) + return None diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 2eedc861..588e9ac5 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -55,6 +55,9 @@ class Voucher(models.Model): ('brand', "Selected product brand"), ]) count_order = fields.Integer(string='Count Order', compute='_compute_count_order') + show_on_email = fields.Selection([ + ('user_activation', 'User Activation') + ], 'Show on Email') @api.constrains('description') def _check_description_length(self): -- cgit v1.2.3 From a155ccce0c0c59f1e41c11012cf81ea16812642d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 21 Nov 2023 13:42:52 +0700 Subject: add new field pakta_integritas on res partner --- indoteknik_custom/models/res_partner.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index a1b57147..fcde9369 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -21,6 +21,7 @@ class ResPartner(models.Model): counter = fields.Integer(string="Counter", default=0) digital_invoice_tax = fields.Boolean(string="Digital Invoice & Faktur Pajak") is_potential = fields.Boolean(string='Potential') + pakta_integritas = fields.Boolean(string='Pakta Integritas') def get_child_ids(self): partner = self.env['res.partner'].search([('id', '=', self.id)], limit=1) -- cgit v1.2.3 From 02746d8bb34a64fa5a1595925007e554fd2fcef7 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 22 Nov 2023 10:07:50 +0700 Subject: add field paid status in purchase order --- indoteknik_custom/models/purchase_order.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index b0f1a569..e00a671c 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -50,6 +50,7 @@ class PurchaseOrder(models.Model): description = fields.Char(string='Description', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') purchase_order_lines = fields.One2many('purchase.order.line', 'order_id', string='Indent', auto_join=True) responsible_ids = fields.Many2many('res.users', string='Responsibles', compute='_compute_responsibles') + status_paid_cbd = fields.Boolean(string='Paid Status', tracking=3, help='Field ini diisi secara manual oleh Finance AP dan hanya untuk status PO CBD') def _compute_responsibles(self): for purchase in self: -- cgit v1.2.3 From 395cb850ae364b36764e9d5e0ee0ff8226916696 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 22 Nov 2023 10:37:22 +0700 Subject: Add product rating from sold amount --- indoteknik_custom/models/product_template.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index d1de2221..264d0bbb 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -120,6 +120,8 @@ class ProductTemplate(models.Model): rate = 0 if product.web_price: rate += 4 + if product.qty_sold > 0: + rate += 3 if product.have_promotion_program: #have discount from pricelist rate += 5 if product.image_128: -- cgit v1.2.3 From 3e6c8343e93d7126f4002a23e396f22db7667774 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Nov 2023 15:44:31 +0700 Subject: fix archive product --- indoteknik_custom/models/product_template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 264d0bbb..90e8a144 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -315,8 +315,9 @@ class ProductTemplate(models.Model): return values def write(self, vals): - if self.id == 224484: - raise UserError('Tidak dapat mengubah produk sementara') + for rec in self: + if rec.id == 224484: + raise UserError('Tidak dapat mengubah produk sementara') return super(ProductTemplate, self).write(vals) -- cgit v1.2.3 From 1a27ae4f9ec137d7af69175afb67a094873738b9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Nov 2023 16:51:02 +0700 Subject: add new condition on publish_b solr --- indoteknik_custom/models/solr/product_product.py | 2 +- indoteknik_custom/models/solr/product_template.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 03eaaf13..ebfa8e65 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -65,7 +65,7 @@ class ProductProduct(models.Model): 'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly, 'attributes': [x.name for x in variant.product_template_attribute_value_ids], 'has_product_info_b': True, - 'publish_b': not variant.unpublished, + 'publish_b': not variant.unpublished or not variant.active, 'qty_sold_f': variant.qty_sold }) diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 648a0625..123a95ac 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -82,7 +82,7 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': not template.unpublished, + 'publish_b': not template.unpublished or not template.active, "qty_sold_f": template.qty_sold }) -- cgit v1.2.3 From 1941896aebea3908b1763a4bd4244e5ac7e78bc6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Nov 2023 17:07:53 +0700 Subject: add constrains active on template and variant --- indoteknik_custom/models/solr/product_product.py | 8 +++++++- indoteknik_custom/models/solr/product_template.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index ebfa8e65..fe2a08dc 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -29,6 +29,12 @@ class ProductProduct(models.Model): product.product_tmpl_id._create_solr_queue('_sync_price_to_solr') product.solr_flag = 1 + @api.constrains('active') + def _constrains_active(self): + for rec in self: + if not rec.active: + rec.unpublished = True + def _sync_variants_to_solr(self): solr_model = self.env['apache.solr'] @@ -65,7 +71,7 @@ class ProductProduct(models.Model): 'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly, 'attributes': [x.name for x in variant.product_template_attribute_value_ids], 'has_product_info_b': True, - 'publish_b': not variant.unpublished or not variant.active, + 'publish_b': not variant.unpublished, 'qty_sold_f': variant.qty_sold }) diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 123a95ac..fd3357fd 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -28,6 +28,12 @@ class ProductTemplate(models.Model): def _create_solr_queue_sync_product_template(self): self._create_solr_queue('_sync_product_template_to_solr') + @api.constrains('active') + def _constrains_active(self): + for rec in self: + if not rec.active: + rec.unpublished = True + def action_sync_to_solr(self): template_ids = self.env.context.get('active_ids', []) templates = self.search([('id', 'in', template_ids)]) @@ -82,7 +88,7 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': not template.unpublished or not template.active, + 'publish_b': not template.unpublished, "qty_sold_f": template.qty_sold }) -- cgit v1.2.3 From e9dec832ab749b1c72dc358603d00ad7a35d4bb6 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 25 Nov 2023 09:21:30 +0700 Subject: Update domain filter solr_flag in product template to solr_queue --- indoteknik_custom/models/solr/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 648a0625..c09a6e5a 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -34,7 +34,7 @@ class ProductTemplate(models.Model): templates._create_solr_queue('_sync_product_template_to_solr') def solr_flag_to_solr(self, limit=500): - template_products = self.search([('solr_flag', '=', 2)], limit=limit) + template_products = self.search([('solr_flag', '=', 2), ('active', 'in', [True, False])], limit=limit) for product in template_products: product._create_solr_queue('_sync_product_template_to_solr') product._create_solr_queue('_sync_price_to_solr') -- cgit v1.2.3