From bfaee558997160c891a394a9862ad338a494337f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 29 Sep 2023 16:54:54 +0700 Subject: delete weekly solr & Helper by di Quotation / SO --- indoteknik_custom/models/sale_order.py | 9 ++++++++- indoteknik_custom/models/solr/apache_solr_queue.py | 11 ++++++++++- indoteknik_custom/views/apache_solr_queue.xml | 15 +++++++++++++++ indoteknik_custom/views/sale_order.xml | 3 +++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 71163fa4..e201496a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1,6 +1,6 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError -import logging, random, string, requests, math, json, re +import logging, random, string, requests, math, json, re _logger = logging.getLogger(__name__) @@ -80,6 +80,7 @@ class SaleOrder(models.Model): estimated_arrival_days = fields.Integer('Estimated Arrival Days', default=0) email = fields.Char(string='Email') picking_iu_id = fields.Many2one('stock.picking', 'Picking IU') + helper_by_id = fields.Many2one('res.users', 'Helper By') @api.model def action_multi_update_state(self): @@ -246,6 +247,12 @@ class SaleOrder(models.Model): minimum_amount = 20000000 for order in self: order.have_visit_service = self.amount_total > minimum_amount + + def write(self, values): + if self.env.user.id in [991, 20, 1180]: + values['helper_by_id'] = self.env.user.id + + return super(SaleOrder, self).write(values) def check_due(self): """To show the due amount and warning stage""" diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 6a5b480f..8dd7c273 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -1,5 +1,5 @@ from odoo import models, fields -from datetime import datetime +from datetime import datetime, timedelta import logging, time @@ -72,3 +72,12 @@ class ApacheSolrQueue(models.Model): if count == 0: self.create(payload) + def delete_weekly_solr(self, limit=500): + solr = self.search([ + ('execute_status', '=', 'success'), + ('execute_date', '>=', (datetime.utcnow() - timedelta(days=7))), + ], limit=limit) + for rec in solr: + rec.unlink() + + diff --git a/indoteknik_custom/views/apache_solr_queue.xml b/indoteknik_custom/views/apache_solr_queue.xml index 3861fd20..9685ef06 100644 --- a/indoteknik_custom/views/apache_solr_queue.xml +++ b/indoteknik_custom/views/apache_solr_queue.xml @@ -57,6 +57,21 @@ records.execute_queue() + + + Solr Queue: Delete Weekly + 14 + minutes + -1 + + + model.delete_weekly_solr() + code + 65 + True + + + Solr Queue: Process diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index bc098f18..0d972ec1 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -41,6 +41,9 @@ 1 + + + -- cgit v1.2.3 From b0b5d0a094a1a87810b45bfcc52c17a82b73d3eb Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 2 Oct 2023 10:52:31 +0700 Subject: Fix get pricelist on product product --- indoteknik_api/models/product_product.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 78e32762..fdc90533 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -64,9 +64,9 @@ class ProductProduct(models.Model): price_discount = self._get_website_price_after_disc_and_tax() pricelists = { - 'tier1': self._get_pricelist_tier(1), - 'tier2': self._get_pricelist_tier(2), - 'tier3': self._get_pricelist_tier(3), + 'tier1': self._get_pricelist_tier1, + 'tier2': self._get_pricelist_tier2, + 'tier3': self._get_pricelist_tier3, } price_tier = pricelist.get_tier_name() @@ -214,6 +214,15 @@ class ProductProduct(models.Model): retValue = pl_item2.price_discount return retValue + def _get_pricelist_tier1(self): + return self._get_pricelist_tier(1) + + def _get_pricelist_tier2(self): + return self._get_pricelist_tier(2) + + def _get_pricelist_tier3(self): + return self._get_pricelist_tier(3) + def _get_pricelist_tier(self, tier_number): config_param_name = f'product.pricelist.tier{tier_number}' product_pricelist_tier = int(self.env['ir.config_parameter'].get_param(config_param_name)) -- cgit v1.2.3 From 9fe4b646f1b1cda3d704a66dfbca3e935e38d96b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 2 Oct 2023 16:45:07 +0700 Subject: Group by brand, sync to solr when validate stock picking, add new name function solr queue --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/product_template.py | 16 ++++++--------- indoteknik_custom/models/solr/apache_solr_queue.py | 2 +- indoteknik_custom/models/solr/product_product.py | 2 +- indoteknik_custom/models/solr/product_template.py | 23 +++++---------------- indoteknik_custom/models/stock_move.py | 3 ++- indoteknik_custom/models/stock_picking.py | 2 +- indoteknik_custom/views/apache_solr_queue.xml | 1 + indoteknik_custom/views/product_template.xml | 1 - indoteknik_custom/views/stock_move_line.xml | 24 ++++++++++++++++++++++ 10 files changed, 42 insertions(+), 33 deletions(-) create mode 100644 indoteknik_custom/views/stock_move_line.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 48434845..6ae60345 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -97,6 +97,7 @@ 'views/account_move_line.xml', 'views/sale_orders_multi_update.xml', 'views/quotation_so_multi_update.xml', + 'views/stock_move_line.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index d35188b4..defcbdd4 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -52,16 +52,7 @@ class ProductTemplate(models.Model): help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru') seq_new_product = fields.Integer(string='Seq New Product', help='Urutan Sequence New Product') is_edited = fields.Boolean(string='Is Edited') - publish = fields.Boolean(string='Publish', default=True) - @api.constrains('active') - def constrains_active_publish(self): - if not self.active or self.type != 'product': - self.publish = False - else: - self.publish = True - - self._create_solr_queue('_sync_product_template_to_solr') def day_product_to_edit(self): day_products = [] @@ -193,7 +184,12 @@ class ProductTemplate(models.Model): def _compute_web_price(self): for template in self: - template.web_price = template.product_variant_ids[0].web_price + products = self.env['product.product'].search([ + ('product_tmpl_id', '=', template.id), + ('active', 'in', [True, False]) + ]) + for variants in products: + template.web_price = variants[0].web_price def _have_promotion_program(self): for template in self: diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 8dd7c273..f66d356d 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__) class ApacheSolrQueue(models.Model): _name = 'apache.solr.queue' - display_name = fields.Char('Display Name', compute="_compute_display_name") + display_name = fields.Char('Display Name', compute="_compute_display_name", store=True) res_model = fields.Char('Resource Model') res_id = fields.Integer('Resource ID') function_name = fields.Char('Function Name') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 41af2d0e..16135e5e 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -63,7 +63,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': variant.product_tmpl_id.publish, + 'publish_b': variant.product_tmpl_id.active and variant.product_tmpl_id.type == 'product', }) self.solr().add(docs=[document], softCommit=True) diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index b4782d1c..e39530a7 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -23,23 +23,7 @@ class ProductTemplate(models.Model): 'function_name': function_name }) - @api.constrains('active', 'type') - def constrains_active(self): - for template in self: - template.publish = template.active and template.type == 'product' - self._create_solr_queue('_sync_product_template_to_solr') - - @api.constrains('publish') - def constrains_publish(self): - for template in self: - if template.active and template.type == 'product': - continue - template.product_variant_ids.publish = template.publish - self._create_solr_queue('_sync_product_template_to_solr') - - constrains_active._priority = 1 - - @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920') + @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'active') def _create_solr_queue_sync_product_template(self): self._create_solr_queue('_sync_product_template_to_solr') @@ -54,6 +38,9 @@ class ProductTemplate(models.Model): product._create_solr_queue('_sync_price_to_solr') product.solr_flag = 1 + def _sync_product_stock_to_solr(self): + self._sync_product_template_to_solr() + def _sync_product_template_to_solr(self): solr_model = self.env['apache.solr'] @@ -93,7 +80,7 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': template.publish + 'publish_b': template.active and template.type == 'product' }) self.solr().add(docs=[document], softCommit=True) diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index bdbb0227..dade9a04 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import fields, models, api class StockMove(models.Model): @@ -72,3 +72,4 @@ class StockMoveLine(models.Model): _inherit = 'stock.move.line' line_no = fields.Integer('No', default=0) + manufacture = fields.Many2one('x_manufactures', string="Brands", related="product_id.x_manufacture", store=True) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 181f2a59..418649b1 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -307,7 +307,7 @@ class StockPicking(models.Model): for product in self.move_line_ids_without_package.product_id: if product: - product.product_tmpl_id._create_solr_queue('_sync_product_template_to_solr') + product.product_tmpl_id._create_solr_queue('_sync_product_stock_to_solr') res = super(StockPicking, self).button_validate() self.calculate_line_no() diff --git a/indoteknik_custom/views/apache_solr_queue.xml b/indoteknik_custom/views/apache_solr_queue.xml index 9685ef06..13869b4c 100644 --- a/indoteknik_custom/views/apache_solr_queue.xml +++ b/indoteknik_custom/views/apache_solr_queue.xml @@ -28,6 +28,7 @@ + diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index e09fee77..a3a23101 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -15,7 +15,6 @@ - diff --git a/indoteknik_custom/views/stock_move_line.xml b/indoteknik_custom/views/stock_move_line.xml new file mode 100644 index 00000000..757d2522 --- /dev/null +++ b/indoteknik_custom/views/stock_move_line.xml @@ -0,0 +1,24 @@ + + + + Stock Move Line + stock.move.line + + + + + + + + + + Stock Move Line + stock.move.line + + + + + + + + -- cgit v1.2.3 From 091038b12f8e1cf9b0668110405c385e90a97ad7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 3 Oct 2023 12:44:54 +0700 Subject: nomor faktur pajak di invoice --- indoteknik_custom/models/account_move.py | 12 ++++++++++++ indoteknik_custom/views/account_move.xml | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 18025b32..c3cd7ef9 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -2,6 +2,10 @@ from odoo import models, api, fields from odoo.exceptions import AccessError, UserError, ValidationError from datetime import timedelta, date import logging +import base64 +import PyPDF2 +import os +import re _logger = logging.getLogger(__name__) @@ -23,6 +27,14 @@ class AccountMove(models.Model): cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre') analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') due_line = fields.One2many('due.extension.line', 'invoice_id', compute='_compute_due_line', string='Due Extension Lines') + no_faktur_pajak = fields.Char(string='No Faktur Pajak') + + @api.onchange('efaktur_id') + def change_efaktur_id(self): + for invoice in self: + if not invoice.efaktur_id: + return + invoice.no_faktur_pajak = invoice.efaktur_id.name def _compute_due_line(self): for invoice in self: diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 11558bf4..c45dab25 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -13,6 +13,12 @@ + + + + + pdf_viewer + -- cgit v1.2.3 From d238f43442cc27db0d0c05bba99b42b41eaadf54 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 3 Oct 2023 13:48:03 +0700 Subject: fix compute display name --- indoteknik_custom/models/solr/apache_solr_queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index f66d356d..8dd7c273 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__) class ApacheSolrQueue(models.Model): _name = 'apache.solr.queue' - display_name = fields.Char('Display Name', compute="_compute_display_name", store=True) + display_name = fields.Char('Display Name', compute="_compute_display_name") res_model = fields.Char('Resource Model') res_id = fields.Integer('Resource ID') function_name = fields.Char('Function Name') -- cgit v1.2.3