From 48e5f880d0587964c15c88827ba21cf932928a44 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 9 Oct 2023 15:05:17 +0700 Subject: add field date_completed on account_move and sort default_order by date_order asc --- indoteknik_custom/models/account_move.py | 6 +++++- indoteknik_custom/views/account_move.xml | 5 ++++- indoteknik_custom/views/sale_monitoring.xml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index c3cd7ef9..207ccee1 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -1,6 +1,7 @@ from odoo import models, api, fields from odoo.exceptions import AccessError, UserError, ValidationError -from datetime import timedelta, date +from datetime import timedelta, date, datetime +from pytz import timezone, utc import logging import base64 import PyPDF2 @@ -28,6 +29,7 @@ class AccountMove(models.Model): 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') + date_completed = fields.Datetime(string='Date Completed') @api.onchange('efaktur_id') def change_efaktur_id(self): @@ -90,8 +92,10 @@ class AccountMove(models.Model): # raise UserError('Hanya Accounting yang bisa Posting') # if self._name == 'account.move': for entry in self: + entry.date_completed = datetime.utcnow() for line in entry.line_ids: line.date_maturity = entry.date + return res def _compute_invoice_day_to_due(self): diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index c45dab25..2aeffc83 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -13,6 +13,9 @@ + + + @@ -28,7 +31,7 @@ - + diff --git a/indoteknik_custom/views/sale_monitoring.xml b/indoteknik_custom/views/sale_monitoring.xml index 641eb8fb..5824af6a 100755 --- a/indoteknik_custom/views/sale_monitoring.xml +++ b/indoteknik_custom/views/sale_monitoring.xml @@ -4,7 +4,7 @@ sale.monitoring.tree sale.monitoring - +
-- cgit v1.2.3 From 39931e48a1036f857c3399c96397ea44b0009e89 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 10 Oct 2023 17:01:38 +0700 Subject: Add pdf extension on dowload sale order --- indoteknik_api/controllers/api_v1/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 8209c751..cf6eb719 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -202,7 +202,7 @@ class SaleOrder(controller.Controller): return rest_api.response_attachment({ 'content': pdf, 'mimetype': 'application/pdf', - 'filename': sale_order[0]['name'] + 'filename': sale_order[0]['name'] + '.pdf' }) return self.response('Dokumen tidak ditemukan', code=404) -- cgit v1.2.3 From 96ae355ac947ad04ed01d8ef9685b012067fabd2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 10 Oct 2023 17:04:56 +0700 Subject: Add pdf extension on tax invoice download --- indoteknik_api/controllers/api_v1/download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/download.py b/indoteknik_api/controllers/api_v1/download.py index d9353896..d58e84d0 100644 --- a/indoteknik_api/controllers/api_v1/download.py +++ b/indoteknik_api/controllers/api_v1/download.py @@ -47,6 +47,6 @@ class Download(controller.Controller): 'content': attachment['datas'], 'decode_content': True, 'mimetype': attachment['mimetype'], - 'filename': account_move[0]['name'], + 'filename': account_move[0]['name'] + '.pdf', }) return self.response('Dokumen tidak ditemukan', code=404) -- cgit v1.2.3 From 224f1dd2cf63d01c2a1e8cfa8e78521140827353 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 10 Oct 2023 17:08:06 +0700 Subject: Add pdf extension on download file API --- indoteknik_api/controllers/api_v1/download.py | 2 +- indoteknik_api/controllers/api_v1/sale_order.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/download.py b/indoteknik_api/controllers/api_v1/download.py index d58e84d0..54b09372 100644 --- a/indoteknik_api/controllers/api_v1/download.py +++ b/indoteknik_api/controllers/api_v1/download.py @@ -28,7 +28,7 @@ class Download(controller.Controller): return rest_api.response_attachment({ 'content': pdf, 'mimetype': 'application/pdf', - 'filename': account_move[0]['name'] + 'filename': account_move[0]['name'] + '.pdf' }) @http.route(PREFIX + 'download/tax-invoice//', auth='none', method=['GET']) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index cf6eb719..0f236ffb 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -181,7 +181,7 @@ class SaleOrder(controller.Controller): 'content': attachment['datas'], 'decode_content': True, 'mimetype': attachment['mimetype'], - 'filename': sale_order[0]['partner_purchase_order_name'] + 'filename': sale_order[0]['partner_purchase_order_name'] + '.pdf' }) return self.response('Dokumen tidak ditemukan', code=404) -- cgit v1.2.3 From eabf0ceb0fb6900736449fcb0b82125afc955751 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 11 Oct 2023 10:35:52 +0700 Subject: Update discount_amount type int to float on voucher model --- indoteknik_custom/models/voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index a40f8c42..66c50c24 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -12,7 +12,7 @@ class Voucher(models.Model): image = fields.Binary(string='Image') code = fields.Char(string='Code', help='Kode voucher yang akan berlaku untuk pengguna') description = fields.Text(string='Description') - discount_amount = fields.Integer(string='Discount Amount') + discount_amount = fields.Float(string='Discount Amount') discount_type = fields.Selection(string='Discount Type', selection=[ ('percentage', 'Percentage'), -- cgit v1.2.3 From 11d446d513b540184e02f26bca52b2c8e365c608 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 11 Oct 2023 10:47:22 +0700 Subject: Update discount_amount type int to float on voucher line model --- indoteknik_custom/models/voucher_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/voucher_line.py b/indoteknik_custom/models/voucher_line.py index 8b449d1f..890471dc 100644 --- a/indoteknik_custom/models/voucher_line.py +++ b/indoteknik_custom/models/voucher_line.py @@ -7,7 +7,7 @@ class Voucher(models.Model): voucher_id = fields.Many2one('voucher', string='Voucher') manufacture_id = fields.Many2one('x_manufactures', string='Brand') min_purchase_amount = fields.Integer(string='Min. Purchase Amount', help='Nominal minimum untuk dapat menggunakan voucher. Isi 0 jika tidak ada minimum purchase amount') - discount_amount = fields.Integer(string='Discount Amount') + discount_amount = fields.Float(string='Discount Amount') discount_type = fields.Selection(string='Discount Type', selection=[ ('percentage', 'Percentage'), -- cgit v1.2.3 From 53c28a95ef0ba225f83fadcb09aedb14c323b201 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 11 Oct 2023 14:40:56 +0700 Subject: Add get category breadcrumb API on product and category --- indoteknik_api/controllers/api_v1/category.py | 17 ++- indoteknik_api/controllers/api_v1/product.py | 182 ++++++++++++++++---------- 2 files changed, 130 insertions(+), 69 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py index 3c5766e2..efa6b033 100644 --- a/indoteknik_api/controllers/api_v1/category.py +++ b/indoteknik_api/controllers/api_v1/category.py @@ -120,4 +120,19 @@ class Category(controller.Controller): 'name': category.name }) return self.response(data) - \ No newline at end of file + + @http.route(prefix + 'category//category-breadcrumb', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_category_parents_by_id(self, id, **kw): + categories = [] + + category = request.env['product.public.category'].search([('id', '=', int(id))], limit=1) + if not category: + return self.response(code=400, description='Category not found') + + while category: + categories.append({'id': category.id, 'name': category.name}) + category = category.parent_frontend_id + + categories.reverse() + return self.response(categories) \ No newline at end of file diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 2cbdede7..0c8a286b 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -2,7 +2,10 @@ from .. import controller from odoo import http from odoo.http import request from datetime import datetime, timedelta -import ast, logging, math, json +import ast +import logging +import math +import json _logger = logging.getLogger(__name__) @@ -10,20 +13,43 @@ _logger = logging.getLogger(__name__) class Product(controller.Controller): prefix = '/api/v1/' + @http.route(prefix + 'product//category-breadcrumb', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_product_categories_by_id(self, id, **kw): + categories = [] + + product = request.env['product.template'].search( + [('id', '=', int(id))], limit=1) + if not product: + return self.response(code=400, description='Product not found') + + if len(product.public_categ_ids) == 0: + return self.response(categories) + + category = product.public_categ_ids[0] + while category: + categories.append({'id': category.id, 'name': category.name}) + category = category.parent_frontend_id + + categories.reverse() + return self.response(categories) + @http.route(prefix + 'product_variant//stock', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() def get_product_template_stock_by_id(self, **kw): id = int(kw.get('id')) date_7_days_ago = datetime.now() - timedelta(days=7) - product = request.env['product.product'].search([('id', '=', id)], limit=1) - product_sla = request.env['product.sla'].search([('product_variant_id', '=', id)], limit=1) + product = request.env['product.product'].search( + [('id', '=', id)], limit=1) + product_sla = request.env['product.sla'].search( + [('product_variant_id', '=', id)], limit=1) stock_vendor = request.env['stock.vendor'].search([ ('product_variant_id', '=', id), ('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S")) ], limit=1) qty_available = product.qty_onhand_bandengan - + qty = 0 sla_date = '-' @@ -33,22 +59,23 @@ class Product(controller.Controller): qty_vendor = math.ceil(float(qty_vendor)) total_excell = qty_vendor - is_altama_product = product.x_manufacture.id in [10,122,89] + is_altama_product = product.x_manufacture.id in [10, 122, 89] if is_altama_product: try: # Qty Altama - qty_altama = request.env['product.template'].get_stock_altama(product.default_code) + qty_altama = request.env['product.template'].get_stock_altama( + product.default_code) qty_altama -= int(qty_altama * 0.1) qty_altama = math.ceil(float(qty_altama)) - total_adem = qty_altama - + total_adem = qty_altama + if qty_available > 0: qty = qty_available + total_adem + total_excell sla_date = '1 Hari' elif qty_altama > 0 or qty_vendor > 0: qty = total_adem if qty_altama > 0 else total_excell sla_date = '2-4 Hari' - else: + else: sla_date = '3-7 Hari' except: print('error') @@ -56,10 +83,9 @@ class Product(controller.Controller): if qty_available > 0: qty = qty_available sla_date = product_sla.sla or '-' - elif qty_vendor > 0: + elif qty_vendor > 0: qty = total_excell sla_date = '2-4 Hari' - data = { 'qty': qty, @@ -68,14 +94,14 @@ class Product(controller.Controller): return self.response(data, headers=[('Cache-Control', 'max-age=600, private')]) - @http.route(prefix + 'product/template/price/', auth='public', methods=['GET', 'OPTIONS']) def get_product_template_price_by_id(self, **kw): if not self.authenticate(): return self.response(code=401, description='Unauthorized') id = kw.get('id') partner_id = int(kw.get('partner_id', 0)) - product_template = request.env['product.template'].search([('id', '=', id)], limit=1) + product_template = request.env['product.template'].search( + [('id', '=', id)], limit=1) data = { 'price_include': product_template.product_variant_id._get_website_price_include_tax(), @@ -106,14 +132,15 @@ class Product(controller.Controller): data.update(start_from) return self.response(data, headers=[('Cache-Control', 'max-age=180, private')]) - + @http.route(prefix + 'product/product/price/', auth='public', methods=['GET', 'OPTIONS']) def get_product_product_price_by_id(self, **kw): if not self.authenticate(): return self.response(code=401, description='Unauthorized') id = kw.get('id') - partner_id = int(kw.get('partner_id', 0)) - product_product = request.env['product.product'].search([('id', '=', id)], limit=1) + partner_id = int(kw.get('partner_id', 0)) + product_product = request.env['product.product'].search( + [('id', '=', id)], limit=1) data = { 'price_include': product_product._get_website_price_include_tax(), @@ -132,7 +159,8 @@ class Product(controller.Controller): is_brand_only = int(kw.get('is_brand_only', 0)) base_url = request.env['ir.config_parameter'].get_param('web.base.url') - limit_new_products = request.env['ir.config_parameter'].get_param('limit.new.product') + limit_new_products = request.env['ir.config_parameter'].get_param( + 'limit.new.product') limit_new_products = int(limit_new_products) # current_time = datetime.now() # delta_time = current_time - timedelta(days=30) @@ -147,8 +175,9 @@ class Product(controller.Controller): ('x_manufacture', '!=', False), # ('create_date', '>=', delta_time), ] - new_products = request.env['product.template'].search(query_products, order='create_date desc', limit=limit_new_products) - brands = [] + new_products = request.env['product.template'].search( + query_products, order='create_date desc', limit=limit_new_products) + brands = [] for product in new_products: brands.append(product.x_manufacture) brands = list(dict.fromkeys(brands)) @@ -179,11 +208,13 @@ class Product(controller.Controller): ('x_manufacture', '!=', False), # ('create_date', '>=', delta_time), ] - count_products = request.env['product.template'].search_count(query) + count_products = request.env['product.template'].search_count( + query) if count_products < 6: _logger.info('Brand Skipped %s' % brand.x_name) continue - products = request.env['product.template'].search(query, order='create_date desc', limit=12) + products = request.env['product.template'].search( + query, order='create_date desc', limit=12) data.append({ 'manufacture_id': brand.id, 'sequence': brand.sequence if brand.sequence else count, @@ -205,18 +236,19 @@ class Product(controller.Controller): categories = kw.get('categories') promotions = kw.get('promotions') ready_stock = kw.get('ready_stock') - - require_betweens = ['name', 'manufactures', 'categories', 'ready_stock', 'promotions'] - is_fulfill = False + + require_betweens = ['name', 'manufactures', + 'categories', 'ready_stock', 'promotions'] + is_fulfill = False for required in require_betweens: if kw.get(required): is_fulfill = True - + if not is_fulfill: return self.response(code=400, description='name or manufactures or categories or ready_stock or promotions is required') - + query = [('sale_ok', '=', True)] - + if name: name = '%' + name.replace(' ', '%') + '%' query += [ @@ -224,44 +256,49 @@ class Product(controller.Controller): ('default_code', 'ilike', name), ('name', 'ilike', name), ] - + if manufactures: - query.append(('x_manufacture', 'in', [int(x) for x in manufactures.split(',')])) - + query.append(('x_manufacture', 'in', [ + int(x) for x in manufactures.split(',')])) + if categories: - query.append(('public_categ_ids', 'child_of', [int(x) for x in categories.split(',')])) - + query.append(('public_categ_ids', 'child_of', [ + int(x) for x in categories.split(',')])) + if ready_stock == '1': query.append(('virtual_qty', '>', 0)) - + if promotions: - coupon_programs = request.env['coupon.program'].search([('id', 'in', promotions.split(','))]) - promotion_query = [x for coupon_program in coupon_programs for x in ast.literal_eval(coupon_program.rule_products_domain)] + coupon_programs = request.env['coupon.program'].search( + [('id', 'in', promotions.split(','))]) + promotion_query = [x for coupon_program in coupon_programs for x in ast.literal_eval( + coupon_program.rule_products_domain)] query += promotion_query - + price_from = kw.get('price_from') if price_from and int(price_from): query.append(('web_price_sorting', '>=', int(price_from))) - + price_to = kw.get('price_to') if price_to and int(price_to): query.append(('web_price_sorting', '<=', int(price_to))) - + product_variants = request.env['product.product'].search(query) product_variant_ids = [x.id for x in product_variants] - + query = [('product_variant_ids', 'in', product_variant_ids)] limit = int(kw.get('limit', 0)) offset = int(kw.get('offset', 0)) order = self.get_product_default_order(kw.get('order')) - - product_templates = request.env['product.template'].search(query, limit=limit, offset=offset, order=order) + + product_templates = request.env['product.template'].search( + query, limit=limit, offset=offset, order=order) data = { 'product_total': request.env['product.template'].search_count(query), 'products': [request.env['product.template'].api_single_response(x) for x in product_templates] } return self.response(data) - + @http.route(prefix + 'product/solr', auth='public', methods=['GET']) @controller.Controller.must_authorized() def get_product_solr(self, **kw): @@ -269,10 +306,10 @@ class Product(controller.Controller): solr_flag = kw.get('flag') limit = int(kw.get('limit', 0)) offset = int(kw.get('offset', 0)) - + if not solr_flag: return self.response(code=400, description='flag is required') - + query = [ ('sale_ok', '=', True), ('solr_flag', '=', int(solr_flag)) @@ -284,13 +321,14 @@ class Product(controller.Controller): ('default_code', 'ilike', name), ('name', 'ilike', name), ] - product_templates = request.env['product.template'].search(query, limit=limit, offset=offset) + product_templates = request.env['product.template'].search( + query, limit=limit, offset=offset) data = { 'product_total': request.env['product.template'].search_count(query), 'products': [request.env['product.template'].api_single_response(x, with_detail='SOLR') for x in product_templates] } return self.response(data) - + @http.route(prefix + 'product/', auth='public', methods=['GET']) @controller.Controller.must_authorized() def get_product_by_id(self, **kw): @@ -300,53 +338,60 @@ class Product(controller.Controller): data = [] id = [int(x) for x in id.split(',')] - product_templates = request.env['product.template'].search([('id', 'in', id)]) + product_templates = request.env['product.template'].search( + [('id', 'in', id)]) if product_templates: - data = [request.env['product.template'].api_single_response(x, with_detail='DEFAULT') for x in product_templates] - + data = [request.env['product.template'].api_single_response( + x, with_detail='DEFAULT') for x in product_templates] + return self.response(data) - + @http.route(prefix + 'product//similar', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() def get_product_similar_by_id(self, **kw): id = kw.get('id') if not id: return self.response(code=400, description='id is required') - + id = int(id) - product_template = request.env['product.template'].search([('id', '=', id)]) - - if not product_template: return self.response([]) - + product_template = request.env['product.template'].search( + [('id', '=', id)]) + + if not product_template: + return self.response([]) + query = [('id', '!=', id)] if product_template.x_manufacture: - query.append(('x_manufacture', '=', product_template.x_manufacture.id)) + query.append( + ('x_manufacture', '=', product_template.x_manufacture.id)) if product_template.public_categ_ids: - query.append(('public_categ_ids', 'in', [x.id for x in product_template.public_categ_ids])) + query.append(('public_categ_ids', 'in', [ + x.id for x in product_template.public_categ_ids])) if len(query) == 2: query.insert(0, '|') - + limit = int(kw.get('limit', 0)) offset = int(kw.get('offset', 0)) order = self.get_product_default_order(kw.get('order')) - product_templates = request.env['product.template'].search(query, limit=limit, offset=offset, order=order) - + product_templates = request.env['product.template'].search( + query, limit=limit, offset=offset, order=order) + data = { 'product_total': request.env['product.template'].search_count(query), 'products': [request.env['product.template'].api_single_response(x) for x in product_templates] } return self.response(data) - + def get_product_default_order(self, order): orders = ['product_rating desc'] if order != 'price-asc': orders.append('web_price_sorting desc') - if order == 'price-asc': + if order == 'price-asc': orders.append('web_price_sorting asc') - elif order == 'latest': + elif order == 'latest': orders.append('create_date desc') return ','.join(orders) - + @http.route(prefix + 'product/category-homepage', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() def get_product_category_homepage(self, **kw): @@ -356,13 +401,14 @@ class Product(controller.Controller): id = kw.get('id') if id: query = f'id:{id}' - - categories = solr_model.connect('product_category_homepage').search(query, sort='sequence_i asc').docs + + categories = solr_model.connect('product_category_homepage').search( + query, sort='sequence_i asc').docs categories = solr_model.clean_key_docs(categories) for category in categories: product_ids = category.get('product_ids', []) category.pop('product_ids', None) products = request.env['product.template'].browse(product_ids) category['products'] = products.solr_results() - - return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')]) \ No newline at end of file + + return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')]) -- cgit v1.2.3 From ea8b431331628bc300d23d5d3ee43cf1f0f1018a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 13 Oct 2023 10:28:51 +0700 Subject: fix rating product for pricelist --- 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 defcbdd4..fb8561e7 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -401,9 +401,9 @@ class ProductProduct(models.Model): def _compute_web_price(self): for product in self: - pricelist_id = self.env.context.get('pricelist') + pricelist_id = self.env['ir.config_parameter'].sudo().get_param('product.pricelist.default_price_id_v2') - domain = [('pricelist_id', '=', pricelist_id or 1), ('product_id', '=', product.id)] + domain = [('pricelist_id', '=', pricelist_id or 17022), ('product_id', '=', product.id)] product_pricelist_item = self.env['product.pricelist.item'].search(domain, limit=1) if product_pricelist_item.base_pricelist_id: -- cgit v1.2.3 From a00faa739bdbd8d7750728bdfdc3926b9bf446e2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 13 Oct 2023 15:38:18 +0700 Subject: sale monitoring upgrade --- indoteknik_custom/models/sale_monitoring.py | 34 ++++++++++++++++++++++++++++- indoteknik_custom/models/sale_order_line.py | 8 ++++++- indoteknik_custom/views/purchase_order.xml | 2 +- indoteknik_custom/views/sale_monitoring.xml | 8 +++++-- indoteknik_custom/views/sale_order.xml | 1 + 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index ad15e0c2..cac68b7c 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -21,9 +21,41 @@ class SaleMonitoring(models.Model): status = fields.Char(string="Status") po_number = fields.Char(string="PO Number") qty_reserved = fields.Integer(string="Qty Reserved") - note = fields.Char(string="Note", compute='compute_note') + note_so_line = fields.Selection([ + ('eta', 'ETA'), + ('info_sales', 'Info Sales'), + ('info_vendor', 'Info Vendor'), + ('penggabungan', 'Penggabungan'), + ], string="Note", compute='compute_note') + note = fields.Char(string="Note Detail", compute='compute_note_detail') + purchase_representative_id = fields.Many2one('res.users', string="Purchase Representative", readonly=True, compute='compute_purchase_representative') + + def compute_purchase_representative(self): + for sale in self: + po = self.env['purchase.order'].search([ + ('sale_order_id', '=', sale.sale_order_id.id), + ('user_id', '!=', False) + ]) + + user_id = False + + if po: + user_id = po[0].user_id + + sale.purchase_representative_id = user_id def compute_note(self): + for sale in self: + lines = self.env['sale.order.line'].search([ + ('order_id', '=', sale.sale_order_id.id), + ('note', '!=', False) + ]) + + note = ', '.join(lines.mapped('note') or ['']) + + sale.note_so_line = note + + def compute_note_detail(self): for sale in self: lines = self.env['sale.order.line'].search([ ('order_id', '=', sale.sale_order_id.id), diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 69328325..d0985de5 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -18,7 +18,13 @@ class SaleOrderLine(models.Model): delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) line_no = fields.Integer('No', default=0, copy=False) - note_procurement = fields.Char(string='Note', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring") + note = fields.Selection([ + ('eta', 'ETA'), + ('info_sales', 'Info Sales'), + ('info_vendor', 'Info Vendor'), + ('penggabungan', 'Penggabungan'), + ], string='Note', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring") + note_procurement = fields.Char(string='Note Detail', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring") vendor_subtotal = fields.Float(string='Vendor Subtotal', compute="_compute_vendor_subtotal") amount_voucher_disc = fields.Float(string='Voucher Discount') diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index e0ec86f9..adcaaf43 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -37,7 +37,7 @@ - + diff --git a/indoteknik_custom/views/sale_monitoring.xml b/indoteknik_custom/views/sale_monitoring.xml index 5824af6a..207277af 100755 --- a/indoteknik_custom/views/sale_monitoring.xml +++ b/indoteknik_custom/views/sale_monitoring.xml @@ -18,6 +18,7 @@ + - + +
@@ -49,7 +51,8 @@ decoration-info="status == 'Delivered' or status == 'Invoiced'" /> - + + @@ -58,6 +61,7 @@ + diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index e0e9ac54..a260c68a 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -92,6 +92,7 @@ "/> + -- cgit v1.2.3 From 21fdc9e5023924e40159c5c0227bc549b23b5c2f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 16 Oct 2023 08:21:28 +0700 Subject: fix error monitoring --- indoteknik_custom/models/sale_monitoring.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index cac68b7c..e3959da0 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -26,7 +26,7 @@ class SaleMonitoring(models.Model): ('info_sales', 'Info Sales'), ('info_vendor', 'Info Vendor'), ('penggabungan', 'Penggabungan'), - ], string="Note", compute='compute_note') + ], string="Note") note = fields.Char(string="Note Detail", compute='compute_note_detail') purchase_representative_id = fields.Many2one('res.users', string="Purchase Representative", readonly=True, compute='compute_purchase_representative') @@ -44,16 +44,6 @@ class SaleMonitoring(models.Model): sale.purchase_representative_id = user_id - def compute_note(self): - for sale in self: - lines = self.env['sale.order.line'].search([ - ('order_id', '=', sale.sale_order_id.id), - ('note', '!=', False) - ]) - - note = ', '.join(lines.mapped('note') or ['']) - - sale.note_so_line = note def compute_note_detail(self): for sale in self: -- cgit v1.2.3 From eefe129e31b112d80038fc3aecf2aee4c4e10108 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 16 Oct 2023 08:34:02 +0700 Subject: fix sale monitoring --- indoteknik_custom/models/sale_monitoring.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index e3959da0..cfbe6d78 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -26,7 +26,7 @@ class SaleMonitoring(models.Model): ('info_sales', 'Info Sales'), ('info_vendor', 'Info Vendor'), ('penggabungan', 'Penggabungan'), - ], string="Note") + ], string="Note", compute='compute_note') note = fields.Char(string="Note Detail", compute='compute_note_detail') purchase_representative_id = fields.Many2one('res.users', string="Purchase Representative", readonly=True, compute='compute_purchase_representative') @@ -44,6 +44,14 @@ class SaleMonitoring(models.Model): sale.purchase_representative_id = user_id + def compute_note(self): + for sale in self: + lines = self.env['sale.order.line'].search([ + ('order_id', '=', sale.sale_order_id.id), + ('note', '!=', False) + ], limit=1) + + sale.note_so_line = lines.note def compute_note_detail(self): for sale in self: -- cgit v1.2.3 From 34baf6dc9d7031fdfa196446ef4274fff03d0abc Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 16 Oct 2023 11:19:07 +0700 Subject: Fix cart API --- indoteknik_api/controllers/api_v1/cart.py | 7 ++++--- indoteknik_api/controllers/api_v1/category.py | 2 +- indoteknik_api/controllers/api_v1/product.py | 2 +- indoteknik_custom/models/website_user_cart.py | 8 ++++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py index 88fa9f88..8ef2c1c1 100644 --- a/indoteknik_api/controllers/api_v1/cart.py +++ b/indoteknik_api/controllers/api_v1/cart.py @@ -14,8 +14,9 @@ class Cart(controller.Controller): user_id = int(user_id) limit = int(kw.get('limit', 0)) offset = int(kw.get('offset', 0)) - query = [('user_id', '=', user_id), ('source', '=', 'add_to_cart')] + query = [('user_id', '=', user_id)] carts = user_cart.search(query, limit=limit, offset=offset, order='create_date desc') + carts.write({'source': 'add_to_cart'}) data = { 'product_total': user_cart.search_count(query), 'products': carts.with_context(price_for="web").get_products() @@ -26,7 +27,7 @@ class Cart(controller.Controller): @controller.Controller.must_authorized() def get_cart_count_by_user_id(self, user_id, **kw): user_id = int(user_id) - query = [('user_id', '=', user_id), ('source', '=', 'add_to_cart')] + query = [('user_id', '=', user_id)] carts = request.env['website.user.cart'].search_count(query) return self.response(carts) @@ -77,7 +78,7 @@ class Cart(controller.Controller): data_to_update['source'] = source result = {} - if cart and source in (None, 'add_to_cart'): + if cart: # Update existing cart entry cart.write(data_to_update) result['id'] = cart.id diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py index efa6b033..44a60bc9 100644 --- a/indoteknik_api/controllers/api_v1/category.py +++ b/indoteknik_api/controllers/api_v1/category.py @@ -135,4 +135,4 @@ class Category(controller.Controller): category = category.parent_frontend_id categories.reverse() - return self.response(categories) \ No newline at end of file + return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')]) \ No newline at end of file diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 0c8a286b..1b698f26 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -32,7 +32,7 @@ class Product(controller.Controller): category = category.parent_frontend_id categories.reverse() - return self.response(categories) + return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')]) @http.route(prefix + 'product_variant//stock', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 47a695fe..2721d66f 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -55,11 +55,15 @@ class WebsiteUserCart(models.Model): def get_product_by_user(self, user_id, selected=False, source=False): user_id = int(user_id) - source = source if source else 'add_to_cart' + + if source == 'buy': + source = ['buy'] + else: + source = ['add_to_cart', 'buy'] parameters = [ ('user_id', '=', user_id), - ('source', '=', source) + ('source', 'in', source) ] if selected: -- cgit v1.2.3 From f3e37cbd999409929703ebddef5b487a7daf4940 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 16 Oct 2023 13:46:05 +0700 Subject: fix error base pricelist --- indoteknik_custom/models/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index fb8561e7..b1930ada 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -403,7 +403,7 @@ class ProductProduct(models.Model): for product in self: pricelist_id = self.env['ir.config_parameter'].sudo().get_param('product.pricelist.default_price_id_v2') - domain = [('pricelist_id', '=', pricelist_id or 17022), ('product_id', '=', product.id)] + domain = [('pricelist_id.id', '=', pricelist_id or 17022), ('product_id.id', '=', product.id)] product_pricelist_item = self.env['product.pricelist.item'].search(domain, limit=1) if product_pricelist_item.base_pricelist_id: -- cgit v1.2.3 From 6d9ac5debfc7f8809e627900555301aac6ab6083 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 16 Oct 2023 15:24:28 +0700 Subject: Add qty sold field and solr data --- indoteknik_custom/models/product_template.py | 15 ++++++++++++++- indoteknik_custom/models/solr/product_product.py | 1 + indoteknik_custom/models/solr/product_template.py | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index b1930ada..da1a111f 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -52,7 +52,11 @@ 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') - + qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') + + def _get_qty_sold(self): + for rec in self: + rec.qty_sold = sum(x.qty_sold for x in rec.product_variant_ids) def day_product_to_edit(self): day_products = [] @@ -331,6 +335,15 @@ class ProductProduct(models.Model): qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan') sla_version = fields.Integer(string="SLA Version", default=0) is_edited = fields.Boolean(string='Is Edited') + qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') + + def _get_qty_sold(self): + for product in self: + order_line = self.env['sale.order.line'].search([ + ('order_id.state', 'in', ['done', 'sale']), + ('product_id', '=', product.id) + ]) + product.qty_sold = sum(x.product_uom_qty for x in order_line) def day_product_to_edit(self): day_products = [] diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 31a0026d..720be7fa 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -64,6 +64,7 @@ class ProductProduct(models.Model): 'attributes': [x.name for x in variant.product_template_attribute_value_ids], 'has_product_info_b': True, 'publish_b': variant.product_tmpl_id.active and variant.product_tmpl_id.type == 'product', + 'qty_sold_f': variant.qty_sold }) 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 d7439bcb..cc8d4bf2 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -80,7 +80,8 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': template.active and template.type == 'product' + 'publish_b': template.active and template.type == 'product', + "qty_sold_f": template.qty_sold }) self.solr().add(docs=[document], softCommit=True) -- cgit v1.2.3 From db4547a746308fe1498e36208c1821168183a7e2 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 17 Oct 2023 09:48:32 +0700 Subject: add column note and description in purchase order --- indoteknik_custom/models/automatic_purchase.py | 5 +++-- indoteknik_custom/models/purchase_order.py | 1 + indoteknik_custom/views/purchase_order.xml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index e21b411d..990d3cc5 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -30,12 +30,13 @@ class AutomaticPurchase(models.Model): for vendor in vendor_ids: param_header = { 'partner_id': vendor['partner_id'][0], - 'partner_ref': 'Automatic PO', + # 'partner_ref': 'Automatic PO', 'currency_id': 12, 'user_id': self.env.user.id, 'company_id': 1, # indoteknik dotcom gemilang 'picking_type_id': 28, # indoteknik bandengan receipts - 'date_order': current_time + 'date_order': current_time, + 'note_description': 'Automatic PO' } # new_po = self.env['purchase.order'].create([param_header]) products_vendors = self.env['automatic.purchase.line'].search([ diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 8ad25228..5e4617d4 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -47,6 +47,7 @@ class PurchaseOrder(models.Model): count_line_product = fields.Float('Total Item', compute='compute_count_line_product') note_description = fields.Char(string='Note', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice') + description = fields.Char(string='Description', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') def _compute_has_active_invoice(self): for order in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index adcaaf43..a0614a56 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -75,6 +75,7 @@
+ -- cgit v1.2.3 From c136e5d34dfef4ae95c366b5c52197863b967919 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 17 Oct 2023 09:54:42 +0700 Subject: Fix product virtual rating calculation --- indoteknik_custom/models/product_template.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index da1a111f..d8a2aae2 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -188,12 +188,7 @@ class ProductTemplate(models.Model): def _compute_web_price(self): for template in self: - 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 + template.web_price = template.product_variant_id.web_price def _have_promotion_program(self): for template in self: -- cgit v1.2.3 From 464e80d0cb180335dada9878272c62f5db9b9e73 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 17 Oct 2023 11:19:23 +0700 Subject: product monitoring --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 3 +- indoteknik_custom/models/product_monitoring.py | 35 ++++++++++++++++ indoteknik_custom/models/product_template.py | 4 ++ indoteknik_custom/security/ir.model.access.csv | 3 +- indoteknik_custom/views/product_monitoring.xml | 55 ++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/models/product_monitoring.py create mode 100644 indoteknik_custom/views/product_monitoring.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 6ae60345..23abc084 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -98,6 +98,7 @@ 'views/sale_orders_multi_update.xml', 'views/quotation_so_multi_update.xml', 'views/stock_move_line.xml', + 'views/product_monitoring.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 95defed6..1133c3e7 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -88,4 +88,5 @@ from . import account_move_line from . import stock_scheduler_compute from . import promotion from . import sale_orders_multi_update -from . import quotation_so_multi_update \ No newline at end of file +from . import quotation_so_multi_update +from . import product_monitoring \ No newline at end of file diff --git a/indoteknik_custom/models/product_monitoring.py b/indoteknik_custom/models/product_monitoring.py new file mode 100644 index 00000000..df9701ab --- /dev/null +++ b/indoteknik_custom/models/product_monitoring.py @@ -0,0 +1,35 @@ +from odoo import models, fields, tools, api + +class ProductMonitoring(models.Model): + _name = 'product.monitoring' + _auto = False + _rec_name = 'product_id' + + id = fields.Integer() + product_id = fields.Many2one('product.product', string='Product') + outgoing_qty = fields.Float(string="Outgoing", related='product_id.outgoing_qty') + incoming_qty = fields.Float(string="Incoming", related='product_id.incoming_qty') + qty_available = fields.Float(string="On Hand", related='product_id.qty_available') + qty_upcoming = fields.Float(string="Upcoming", related='product_id.qty_upcoming') + status_stock = fields.Selection([ + ('outgoing_gt_stock', 'Outgoing > Stock'), + ('outgoing_lt_stock', 'Outgoing < Stock'), + ], string="Status Stock", compute='_compute_status_stock') + + def _compute_status_stock(self): + for product in self: + product.status_stock = 'outgoing_lt_stock' if product.outgoing_qty <= product.qty_upcoming else 'outgoing_gt_stock' + + def init(self): + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + SELECT + sm.product_id AS id, + sm.product_id AS product_id + FROM stock_move sm + LEFT JOIN stock_picking sp ON sm.picking_id = sp.id + WHERE sp.state NOT IN ('cancel', 'done') AND sm.product_id IS NOT null + GROUP BY sm.product_id + ) + """ % self._table) \ No newline at end of file diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index fb8561e7..e69d6044 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -329,8 +329,12 @@ class ProductProduct(models.Model): material = fields.Char(string='Material') qty_onhand_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_onhand_bandengan') qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan') + qty_upcoming = fields.Float(string='Qty Upcoming', compute='_get_qty_upcoming') sla_version = fields.Integer(string="SLA Version", default=0) is_edited = fields.Boolean(string='Is Edited') + def _get_qty_upcoming(self): + for product in self: + product.qty_upcoming = product.incoming_qty + product.qty_available def day_product_to_edit(self): day_products = [] diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index e362e546..7a074c71 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -77,4 +77,5 @@ access_cost_centre,access.cost.centre,model_cost_centre,,1,1,1,1 access_stock_scheduler_compute,access.stock.scheduler.compute,model_stock_scheduler_compute,,1,1,1,1 access_sale_order_promotion,access.sale.order.promotion,model_sale_order_promotion,,1,1,1,1 access_sale_orders_multi_update,access.sale.orders.multi_update,model_sale_orders_multi_update,,1,1,1,1 -access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1 \ No newline at end of file +access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1 +access_product_monitoring,access.product.monitoring,model_product_monitoring,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/product_monitoring.xml b/indoteknik_custom/views/product_monitoring.xml new file mode 100644 index 00000000..779a7dd7 --- /dev/null +++ b/indoteknik_custom/views/product_monitoring.xml @@ -0,0 +1,55 @@ + + + + product.monitoring.tree + product.monitoring + + + + + + + + + + + + + + product.monitoring.form + product.monitoring + +
+ + + + + + + + + + +
+
+
+ + + Product Monitoring + ir.actions.act_window + product.monitoring + tree,form + + + +
\ No newline at end of file -- cgit v1.2.3 From 955301fbaf26f847c72e7f0f9f4b8ab47708c906 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 17 Oct 2023 15:53:17 +0700 Subject: Add ignore change validation on temporary product --- indoteknik_custom/models/product_template.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 19bcc780..55a9288f 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -333,6 +333,12 @@ class ProductProduct(models.Model): is_edited = fields.Boolean(string='Is Edited') qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') + def write(self, vals): + if self.id in [385544, 224484]: + raise UserError('Tidak dapat mengubah produk sementara') + + return super(ProductProduct, self).write(vals) + def _get_qty_upcoming(self): for product in self: product.qty_upcoming = product.incoming_qty + product.qty_available -- cgit v1.2.3 From ff9f2f59d1042acaea778049333f1db114a431cb Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 17 Oct 2023 16:08:01 +0700 Subject: Update ignore write temporary product validation --- indoteknik_custom/models/product_template.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 55a9288f..10d109fb 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -307,6 +307,12 @@ class ProductTemplate(models.Model): } self.env['token.storage'].create([values]) return values + + def write(self, vals): + if self.id == 224484: + raise UserError('Tidak dapat mengubah produk sementara') + + return super(ProductTemplate, self).write(vals) class ProductProduct(models.Model): _inherit = "product.product" @@ -333,12 +339,6 @@ class ProductProduct(models.Model): is_edited = fields.Boolean(string='Is Edited') qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') - def write(self, vals): - if self.id in [385544, 224484]: - raise UserError('Tidak dapat mengubah produk sementara') - - return super(ProductProduct, self).write(vals) - def _get_qty_upcoming(self): for product in self: product.qty_upcoming = product.incoming_qty + product.qty_available -- cgit v1.2.3 From c9857525dcb6ecf872ce2479eb3d2545c98221c1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 18 Oct 2023 09:46:08 +0700 Subject: add field note in list stock picking --- indoteknik_custom/models/stock_picking.py | 2 +- indoteknik_custom/views/stock_picking.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 418649b1..626e842d 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -69,7 +69,7 @@ class StockPicking(models.Model): ('hold', 'Hold by Sales'), ('not_paid', 'Customer belum bayar'), ('partial', 'Kirim Parsial') - ], string='Note', help='jika field ini diisi maka tidak akan dihitung ke lead time') + ], string='Note Logistic', help='jika field ini diisi maka tidak akan dihitung ke lead time') waybill_id = fields.One2many(comodel_name='airway.bill', inverse_name='do_id', string='Airway Bill') purchase_representative_id = fields.Many2one('res.users', related='move_lines.purchase_line_id.order_id.user_id', string="Purchase Representative", readonly=True) carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method') diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 9f03235d..3702dcf8 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -15,6 +15,7 @@ + -- cgit v1.2.3 From c70cca235282dc01134f105a2c45fc071f09ae9e Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 18 Oct 2023 10:04:57 +0700 Subject: Fix sync active product solr --- indoteknik_custom/models/solr/product_product.py | 10 ++++++++-- indoteknik_custom/models/solr/product_template.py | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 720be7fa..15c910a5 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -1,4 +1,4 @@ -from odoo import models, fields +from odoo import models, fields, api from datetime import datetime @@ -186,4 +186,10 @@ class ProductProduct(models.Model): results.append(result) - return results \ No newline at end of file + return results + + @api.constrains('active') + def constrains_active(self): + for rec in self: + rec.product_tmpl_id._create_solr_queue_sync_product_template() + \ No newline at end of file diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index cc8d4bf2..f178dd5f 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -221,3 +221,8 @@ class ProductTemplate(models.Model): results.append(result) return results + + @api.constrains('active') + def constrains_active(self): + for rec in self: + rec._create_solr_queue_sync_product_template() \ No newline at end of file -- cgit v1.2.3 From a07d76148eb51f4cdb263f915371208cc2f4b05d Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 18 Oct 2023 10:17:39 +0700 Subject: Fix variant publish condition solr --- indoteknik_custom/models/solr/product_product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 15c910a5..567e2a3e 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.active and variant.product_tmpl_id.type == 'product', + 'publish_b': variant.active and variant.type == 'product', 'qty_sold_f': variant.qty_sold }) -- cgit v1.2.3 From 8e8782b2f1aa3fa61e2b326d2728736ed9969394 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 18 Oct 2023 13:18:45 +0700 Subject: add indent column for purchase order line --- indoteknik_custom/models/purchase_order_line.py | 1 + indoteknik_custom/views/purchase_order.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 95e85122..2e91bb69 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -30,6 +30,7 @@ class PurchaseOrderLine(models.Model): suggest = fields.Char(string='Suggest') price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') + indent = fields.Boolean(string='Indent', help='centang ini jika barang indent') def compute_price_vendor(self): for line in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index a0614a56..8688c1fb 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -65,6 +65,7 @@ + -- cgit v1.2.3 From 0fe05527d92a45b38a3670241636b422c1054320 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 18 Oct 2023 16:36:25 +0700 Subject: add tax if exclude tax in purchase pricelist --- indoteknik_custom/models/purchase_order.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 5e4617d4..59d5ac3e 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -56,6 +56,14 @@ class PurchaseOrder(models.Model): def add_product_to_pricelist(self): for line in self.order_line: current_time = datetime.utcnow() + price_unit = line.price_unit + taxes = line.taxes_id + for tax in taxes: + tax_include = tax.price_include + tax_amt = tax.amount + if taxes: + if not tax_include: + price_unit = price_unit + (price_unit * tax_amt / 100) purchase_pricelist = self.env['purchase.pricelist'].search([ ('product_id', '=', line.product_id.id), -- cgit v1.2.3 From 78f8aeafd40befa56c96f2892012a4a822684265 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 18 Oct 2023 16:37:11 +0700 Subject: forgot to change field price unit --- indoteknik_custom/models/purchase_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 59d5ac3e..e8cd86fa 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -75,7 +75,7 @@ class PurchaseOrder(models.Model): 'vendor_id': line.order_id.partner_id.id, 'product_id': line.product_id.id, 'product_price': 0.00, - 'system_price': line.price_unit, + 'system_price': price_unit, 'system_last_update': current_time, }]) return True @@ -83,7 +83,7 @@ class PurchaseOrder(models.Model): for pricelist in purchase_pricelist: pricelist.write({ 'system_last_update': current_time, - 'system_price': line.price_unit + 'system_price': price_unit }) def _compute_date_planned(self): -- cgit v1.2.3 From 91d393eb699188b536c3c44d4460f6fed9596d3b Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 19 Oct 2023 11:34:36 +0700 Subject: Update due date by payment schedule on bill view --- indoteknik_custom/models/account_move.py | 5 +++++ indoteknik_custom/views/account_move.xml | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 207ccee1..a85e8caa 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -14,6 +14,7 @@ _logger = logging.getLogger(__name__) class AccountMove(models.Model): _inherit = 'account.move' invoice_day_to_due = fields.Integer(string="Day to Due", compute="_compute_invoice_day_to_due") + bill_day_to_due = fields.Date(string="Day to Due", compute="_compute_bill_day_to_due") date_send_fp = fields.Datetime(string="Tanggal Kirim Faktur Pajak") last_log_fp = fields.Char(string="Log Terakhir Faktur Pajak") # use for industry business @@ -107,6 +108,10 @@ class AccountMove(models.Model): invoice_day_to_due = invoice.new_due_date - date.today() invoice_day_to_due = invoice_day_to_due.days invoice.invoice_day_to_due = invoice_day_to_due + + def _compute_bill_day_to_due(self): + for rec in self: + rec.bill_day_to_due = rec.payment_schedule or rec.invoice_date_due @api.onchange('date_kirim_tukar_faktur') def change_date_kirim_tukar_faktur(self): diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 2aeffc83..1721abb6 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -73,8 +73,12 @@ account.move - - + + + + + + 1 -- cgit v1.2.3 From 1292cb9fc57d972dec21a13df874099cf6d8bef2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 19 Oct 2023 16:03:34 +0700 Subject: Fix product price calculation for solr --- indoteknik_custom/models/solr/product_product.py | 46 ++++--------- indoteknik_custom/models/solr/product_template.py | 82 +++++++++++------------ 2 files changed, 53 insertions(+), 75 deletions(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 567e2a3e..e1342fc2 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -75,24 +75,12 @@ class ProductProduct(models.Model): def _sync_price_to_solr(self): solr_model = self.env['apache.solr'] + TIER_NUMBERS = ['1_v2', '2_v2', '3_v2', '4_v2', '5_v2'] for variant in self: - price_excl_after_disc = price_excl = discount = tax = 0 - flashsale_data = {} + flashsale_data = variant.with_context(price_for="web")._get_flashsale_price() - if price_excl_after_disc == 0 or variant._get_website_price_after_disc_and_tax() < price_excl_after_disc: - price_excl = variant._get_website_price_exclude_tax() - price_excl_after_disc = variant._get_website_price_after_disc_and_tax() - tax = variant._get_website_tax() - discount = variant._get_website_disc(0) - flashsale_data = variant.with_context(price_for="web")._get_flashsale_price() - - price_excl_v2 = variant._v2_get_website_price_exclude_tax() - price_excl_after_disc_v2 = variant._v2_get_website_price_after_disc_and_tax() - tax_v2 = variant._v2_get_website_tax() - - document = solr_model.get_doc('variants', variant.id) - document.update({ + flashsale_doc = { "id": variant.id, "flashsale_id_i": flashsale_data.get('flashsale_id', 0), "flashsale_tag_s": flashsale_data.get('flashsale_tag', ''), @@ -102,25 +90,19 @@ class ProductProduct(models.Model): "flashsale_base_price_f": flashsale_data.get('flashsale_base_price', 0), "flashsale_discount_f": flashsale_data.get('flashsale_discount', 0), "flashsale_price_f": flashsale_data.get('flashsale_price', 0), - "price_f": price_excl, - "discount_f": discount, - "price_discount_f": price_excl_after_disc, - "tax_f": tax, - "price_v2_f": price_excl_v2, - "price_discount_v2_f": price_excl_after_disc_v2, - "tax_v2_f": tax_v2, - }) - - for tier_number in [1, 2, 3, '1_v2', '2_v2', '3_v2', '4_v2', '5_v2']: + } + + price_doc = {} + + for tier_number in TIER_NUMBERS: tier = variant._get_pricelist_tier(tier_number) - document.update({ - f"discount_tier{tier_number}_f": tier.get(f'discount_tier{tier_number}', 0), - f"price_tier{tier_number}_f": tier.get(f'price_tier{tier_number}', 0), - }) - - # for tier_number in [1, 2, 3, '1_v2', '2_v2', '3_v2', '4_v2', '5_v2']: - # tier = tier_data[tier_number] + price_doc[f"discount_tier{tier_number}_f"] = tier.get(f'discount_tier{tier_number}', 0) + price_doc[f"price_tier{tier_number}_f"] = tier.get(f'price_tier{tier_number}', 0) + document = solr_model.get_doc('variants', variant.id) + document['id'] = variant.id + document.update(flashsale_doc) + document.update(price_doc) document.update({"has_price_info_b": True}) 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 f178dd5f..aa1708cc 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -97,56 +97,52 @@ class ProductTemplate(models.Model): def _sync_price_to_solr(self): solr_model = self.env['apache.solr'] + TIER_NUMBERS = ['1_v2', '2_v2', '3_v2', '4_v2', '5_v2'] for template in self: - flashsale_data = {} - price_excl = price_excl_after_disc = discount = tax = 0 - tier_data = {} + cheapest_flashsale = {} for variant in template.product_variant_ids: variant_flashsale = variant.with_context(price_for="web")._get_flashsale_price() variant_flashsale_price = variant_flashsale.get('flashsale_price', 0) - flashsale_data_price = flashsale_data.get('flashsale_price', 0) - - if flashsale_data_price == 0 or (variant_flashsale_price != 0 and variant_flashsale_price < flashsale_data_price): - flashsale_data = variant_flashsale - - price_excl = variant._get_website_price_exclude_tax() - price_excl_after_disc = variant._get_website_price_after_disc_and_tax() - discount = variant._get_website_disc(0) - tax = variant._get_website_tax() - - price_excl_v2 = variant._v2_get_website_price_exclude_tax() - price_excl_after_disc_v2 = variant._v2_get_website_price_after_disc_and_tax() - tax_v2 = variant._v2_get_website_tax() - + cheapest_flashsale_price = cheapest_flashsale.get('flashsale_price', 0) + + if cheapest_flashsale_price == 0 or (variant_flashsale_price != 0 and variant_flashsale_price < cheapest_flashsale_price): + cheapest_flashsale = variant_flashsale + + flashsale_doc = { + "flashsale_id_i": cheapest_flashsale.get('flashsale_id', 0), + "flashsale_tag_s": cheapest_flashsale.get('flashsale_tag', ''), + "flashsale_name_s": cheapest_flashsale.get('flashsale_name', ''), + "flashsale_start_date_s": cheapest_flashsale.get('flashsale_start_date', ''), + "flashsale_end_date_s": cheapest_flashsale.get('flashsale_end_date', ''), + "flashsale_base_price_f": cheapest_flashsale.get('flashsale_base_price', 0), + "flashsale_discount_f": cheapest_flashsale.get('flashsale_discount', 0), + "flashsale_price_f": cheapest_flashsale.get('flashsale_price', 0) + } + + price_doc = {} + + # Loop tier to get each variant price + for tier_number in TIER_NUMBERS: + for variant in template.product_variant_ids: + tier = variant._get_pricelist_tier(tier_number) + discount_tier_key = f'discount_tier{tier_number}' + price_tier_key = f'price_tier{tier_number}' + + variant_discount = tier.get(discount_tier_key, 0) + variant_price = tier.get(price_tier_key, 0) + + price_tier = price_doc.get(f"{price_tier_key}_f", 0) + # When price tier is 0 or variant_price less than price tier then use variant price + if price_tier == 0 or variant_price < price_tier: + price_doc[f"{discount_tier_key}_f"] = variant_discount + price_doc[f"{price_tier_key}_f"] = variant_price + document = solr_model.get_doc('product', template.id) - document.update({ - "id": template.id, - "flashsale_id_i": flashsale_data.get('flashsale_id', 0), - "flashsale_tag_s": flashsale_data.get('flashsale_tag', ''), - "flashsale_name_s": flashsale_data.get('flashsale_name', ''), - "flashsale_start_date_s": flashsale_data.get('flashsale_start_date', ''), - "flashsale_end_date_s": flashsale_data.get('flashsale_end_date', ''), - "flashsale_base_price_f": flashsale_data.get('flashsale_base_price', 0), - "flashsale_discount_f": flashsale_data.get('flashsale_discount', 0), - "flashsale_price_f": flashsale_data.get('flashsale_price', 0), - "price_f": price_excl, - "discount_f": discount, - "price_discount_f": price_excl_after_disc, - "tax_f": tax, - "price_v2_f": price_excl_v2, - "price_discount_v2_f": price_excl_after_disc_v2, - "tax_v2_f": tax_v2, - }) - - for tier_number in [1, 2, 3, '1_v2', '2_v2', '3_v2', '4_v2', '5_v2']: - tier = variant._get_pricelist_tier(tier_number) - document.update({ - f"discount_tier{tier_number}_f": tier.get(f'discount_tier{tier_number}', 0), - f"price_tier{tier_number}_f": tier.get(f'price_tier{tier_number}', 0), - }) - + document['id'] = template.id + document.update(flashsale_doc) + document.update(price_doc) document.update({"has_price_info_b": True}) self.solr().add(docs=[document], softCommit=True) -- cgit v1.2.3 From 1e08cea66f4b4b3e4664f09986b1e41d0ba57830 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 19 Oct 2023 16:03:57 +0700 Subject: Add rounding total weight on get user checkout --- indoteknik_custom/models/website_user_cart.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 2721d66f..bbc14c88 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -95,6 +95,7 @@ class WebsiteUserCart(models.Model): tax = round(subtotal * 0.11) grand_total = subtotal + tax total_weight = sum(x['weight'] * x['quantity'] for x in products) + total_weight = round(total_weight, 2) result = { 'total_purchase': total_purchase, 'total_discount': total_discount, -- cgit v1.2.3 From 956a77b7ad29af3620ee37e66c3b13de6a562deb Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 20 Oct 2023 10:15:32 +0700 Subject: add scheduled actions for run scheduler --- indoteknik_custom/views/purchase_order.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index a0614a56..1ff14e60 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -150,4 +150,18 @@ + + + Run Scheduler Reserve Stock + 1 + hours + -1 + + + model.procure_calculation() + code + 75 + True + + \ No newline at end of file -- cgit v1.2.3 From 4570401835223c2b613c2739fe9684fbe6c15b94 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 20 Oct 2023 10:25:23 +0700 Subject: add sale_order_id to search box purchase order --- indoteknik_custom/views/purchase_order.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 7bf14899..d564f260 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -140,7 +140,7 @@ - + purchase.order.select.inherit purchase.order -- cgit v1.2.3 From 49d7b473a8cd458ade6a4e703c276b0771707db2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 20 Oct 2023 15:31:03 +0700 Subject: Add unpublished field on product template and variant --- indoteknik_custom/models/solr/product_product.py | 10 +++++++--- indoteknik_custom/models/solr/product_template.py | 5 +++-- indoteknik_custom/views/product_template.xml | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index e1342fc2..85c94741 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -5,6 +5,7 @@ from datetime import datetime class ProductProduct(models.Model): _inherit = 'product.product' + unpublished = fields.Boolean(string='Unpublished') last_update_solr = fields.Datetime(string='Last Update Solr') desc_update_solr = fields.Char(string='Desc Update Solr') @@ -63,7 +64,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.active and variant.type == 'product', + 'publish_b': not variant.unpublished, 'qty_sold_f': variant.qty_sold }) @@ -170,8 +171,11 @@ class ProductProduct(models.Model): return results - @api.constrains('active') - def constrains_active(self): + @api.constrains('unpublished') + def _constrains_unpublished(self): for rec in self: + if rec.product_variant_count == 1: + rec.product_tmpl_id.unpublished = rec.unpublished + rec.product_tmpl_id._create_solr_queue_sync_product_template() \ No newline at end of file diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index aa1708cc..25d7d4b8 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -5,6 +5,7 @@ from datetime import datetime class ProductTemplate(models.Model): _inherit = "product.template" + unpublished = fields.Boolean(string='Unpublished') last_update_solr = fields.Datetime(string='Last Update Solr') desc_update_solr = fields.Char(string='Desc Update Solr') @@ -23,7 +24,7 @@ class ProductTemplate(models.Model): 'function_name': function_name }) - @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'active') + @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'unpublished') def _create_solr_queue_sync_product_template(self): self._create_solr_queue('_sync_product_template_to_solr') @@ -80,7 +81,7 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': template.active and template.type == 'product', + 'publish_b': not template.unpublished, "qty_sold_f": template.qty_sold }) diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index a3a23101..6fdb5e8f 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -13,6 +13,7 @@ + -- cgit v1.2.3 From 2016ebabb250d1fe521d9b00668b7fa4313dff81 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Sat, 21 Oct 2023 10:31:01 +0700 Subject: add field count trx po and vendor --- indoteknik_custom/models/purchase_pricelist.py | 2 ++ indoteknik_custom/views/purchase_pricelist.xml | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 3607defe..b7c3785a 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -14,6 +14,8 @@ class PurchasePricelist(models.Model): system_price = fields.Float(string='System Price', required=True) human_last_update = fields.Datetime(string='Human Update') system_last_update = fields.Datetime(string='System Update') + count_trx_po = fields.Integer(string='Count Trx Product') + count_trx_po_vendor = fields.Integer(string='Count Trx Vendor') @api.depends('product_id', 'vendor_id') def _compute_name(self): diff --git a/indoteknik_custom/views/purchase_pricelist.xml b/indoteknik_custom/views/purchase_pricelist.xml index f9fd52ba..f4cd4e78 100755 --- a/indoteknik_custom/views/purchase_pricelist.xml +++ b/indoteknik_custom/views/purchase_pricelist.xml @@ -11,6 +11,8 @@ + + @@ -27,6 +29,10 @@ + + + + -- cgit v1.2.3 From 7e734333e198e8405ce49ef96f5cb347b0a892d4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 23 Oct 2023 11:23:27 +0700 Subject: fix re calculate po --- indoteknik_custom/models/purchase_order.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index e8cd86fa..d62d7b1e 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -338,12 +338,11 @@ class PurchaseOrder(models.Model): def re_calculate(self): for line in self.order_line: sale_order_line = self.env['sale.order.line'].search([ - ('id', '=', line.so_line_id.id), + ('product_id', 'in', [line.product_id.id]), ('order_id', '=', line.order_id.sale_order_id.id) - ], limit=1, order='price_reduce_taxexcl') + ]) for so_line in sale_order_line: - unit_price = line.price_unit - so_line.purchase_price = unit_price + so_line.purchase_price = line.price_unit def button_cancel(self): res = super(PurchaseOrder, self).button_cancel() -- cgit v1.2.3 From 5ddda2a380e9aeaf63241e8f6b1c35e3005a3468 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 23 Oct 2023 15:36:50 +0700 Subject: Add action on sync by solr flag --- indoteknik_custom/models/solr/product_product.py | 1 + indoteknik_custom/models/solr/product_template.py | 1 + 2 files changed, 2 insertions(+) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 85c94741..03eaaf13 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -25,6 +25,7 @@ class ProductProduct(models.Model): def variant_solr_flag_to_solr(self, limit=500): variant_products = self.search([('solr_flag', '=', 2)], limit=limit) for product in variant_products: + product.product_tmpl_id._create_solr_queue('_sync_product_template_to_solr') product.product_tmpl_id._create_solr_queue('_sync_price_to_solr') product.solr_flag = 1 diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 25d7d4b8..2bbcab9c 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -36,6 +36,7 @@ class ProductTemplate(models.Model): def solr_flag_to_solr(self, limit=500): template_products = self.search([('solr_flag', '=', 2)], limit=limit) for product in template_products: + product._create_solr_queue('_sync_product_template_to_solr') product._create_solr_queue('_sync_price_to_solr') product.solr_flag = 1 -- cgit v1.2.3 From c35137e5a43afeb6a45b7f213f9ab40afb75fb4c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 23 Oct 2023 19:06:32 +0700 Subject: change logic of valid purchase pricelist in sales order --- indoteknik_custom/models/sale_order_line.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index d0985de5..748153ad 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -72,21 +72,33 @@ class SaleOrderLine(models.Model): cost = self.product_id.standard_price self.purchase_price = cost else: + # purchase_price = self.env['purchase.pricelist'].search( + # [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1) purchase_price = self.env['purchase.pricelist'].search( - [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1) - self.purchase_price = purchase_price.product_price + [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], + limit=1, order='count_trx_po desc, count_trx_po_vendor desc') + self.purchase_price = self._get_valid_purchase_price(purchase_price) self.purchase_tax_id = 22 + def _get_valid_purchase_price(self, purchase_price): + p_price = 0 + if purchase_price.system_price > 0 and purchase_price.product_price > 0: + if purchase_price.human_last_update > purchase_price.system_last_update: + p_price = purchase_price.product_price + else: + p_price = purchase_price.system_price + return p_price + @api.onchange('product_id') def product_id_change(self): super(SaleOrderLine, self).product_id_change() for line in self: if line.product_id and line.product_id.type == 'product': purchase_price = self.env['purchase.pricelist'].search( - [('product_id', '=', self.product_id.id)], limit=1, order='product_price ASC') + [('product_id', '=', self.product_id.id)], limit=1, order='count_trx_po desc, count_trx_po_vendor desc') line.vendor_id = purchase_price.vendor_id line.tax_id = line.order_id.sales_tax_id - line.purchase_price = purchase_price.product_price + line.purchase_price = self._get_valid_purchase_price(purchase_price) def compute_delivery_amt_line(self): for line in self: -- cgit v1.2.3 From 8cba1eaa340eb0c6b264672b0a47dc1628c2eb04 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 25 Oct 2023 14:05:01 +0700 Subject: initial commit for split automatic purchase --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 3 ++- indoteknik_custom/models/automatic_purchase.py | 10 ++++++++-- indoteknik_custom/models/stock_warehouse_orderpoint.py | 10 ++++++++++ indoteknik_custom/models/x_manufactures.py | 2 ++ indoteknik_custom/views/automatic_purchase.xml | 2 ++ indoteknik_custom/views/stock_warehouse_orderpoint.xml | 15 +++++++++++++++ indoteknik_custom/views/x_manufactures.xml | 2 ++ 8 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 indoteknik_custom/models/stock_warehouse_orderpoint.py create mode 100644 indoteknik_custom/views/stock_warehouse_orderpoint.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 23abc084..3bc4be60 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -99,6 +99,7 @@ 'views/quotation_so_multi_update.xml', 'views/stock_move_line.xml', 'views/product_monitoring.xml', + 'views/stock_warehouse_orderpoint.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 1133c3e7..6a5eac00 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -89,4 +89,5 @@ from . import stock_scheduler_compute from . import promotion from . import sale_orders_multi_update from . import quotation_so_multi_update -from . import product_monitoring \ No newline at end of file +from . import product_monitoring +from . import stock_warehouse_orderpoint diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 990d3cc5..f81ecdcc 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -17,6 +17,7 @@ class AutomaticPurchase(models.Model): is_po = fields.Boolean(string='Is PO') purchase_match = fields.One2many('automatic.purchase.match', 'automatic_purchase_id', string='Matches', auto_join=True) vendor_id = fields.Many2one('res.partner', string='Vendor', help='boleh kosong, jika diisi, maka hanya keluar data untuk vendor tersebut') + responsible_id = fields.Many2one('res.users', string='Responsible', required=True) def create_po_from_automatic_purchase(self): if not self.purchase_lines: @@ -87,7 +88,8 @@ class AutomaticPurchase(models.Model): raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') query = [ - ('product_min_qty', '>', 0) + ('product_min_qty', '>', 0), + ('product_id.x_manufacture.user_id.id', '=', self.responsible_id.id) ] orderpoints = self.env['stock.warehouse.orderpoint'].search(query) count = 0 @@ -101,10 +103,14 @@ class AutomaticPurchase(models.Model): if self.vendor_id: purchase_price = self.env['purchase.pricelist'].search([ ('product_id', '=', point.product_id.id), + # ('product_id.x_manufacture.user_id.id', '=', self.responsible_id.id), ('vendor_id', '=', self.vendor_id.id) ], order='product_price asc', limit=1) else: - purchase_price = self.env['purchase.pricelist'].search([('product_id', '=', point.product_id.id)], order='product_price asc', limit=1) + purchase_price = self.env['purchase.pricelist'].search([ + ('product_id', '=', point.product_id.id), + # ('product_id.x_manufacture.user_id.id', '=', self.responsible_id.id), + ], order='product_price asc', limit=1) vendor_id = purchase_price.vendor_id.id price = purchase_price.product_price or 0 diff --git a/indoteknik_custom/models/stock_warehouse_orderpoint.py b/indoteknik_custom/models/stock_warehouse_orderpoint.py new file mode 100644 index 00000000..277c8dc3 --- /dev/null +++ b/indoteknik_custom/models/stock_warehouse_orderpoint.py @@ -0,0 +1,10 @@ +from odoo import fields, models, api, _ + +class StockWarehouseOrderpoint(models.Model): + _inherit = 'stock.warehouse.orderpoint' + + responsible_id = fields.Many2one('res.users', string='Responsible', compute='_compute_responsible') + + def _compute_responsible(self): + for stock in self: + stock.responsible_id = stock.product_id.x_manufacture.user_id diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index e48a5367..abedf0cf 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -47,6 +47,8 @@ class XManufactures(models.Model): parent_id = fields.Many2one('x_manufactures', string='Parent', help='Parent Brand tersebut') category_ids = fields.Many2many('product.public.category', string='Category', help='Brand tsb memiliki Category apa saja') vendor_ids = fields.Many2many('res.partner', string='Vendor', compute='_compute_vendor_ids') + # user_id = fields.Many2one('res.users', string='Responsible', domain="['|'('id', '=', 19), ('id', '=', 6)]", help="Siapa yang bertanggung jawab") + user_id = fields.Many2one('res.users', string='Responsible', help="Siapa yang bertanggung jawab") def _compute_vendor_ids(self): for manufacture in self: diff --git a/indoteknik_custom/views/automatic_purchase.xml b/indoteknik_custom/views/automatic_purchase.xml index 49751f4e..0478304e 100644 --- a/indoteknik_custom/views/automatic_purchase.xml +++ b/indoteknik_custom/views/automatic_purchase.xml @@ -10,6 +10,7 @@ + @@ -57,6 +58,7 @@ + diff --git a/indoteknik_custom/views/stock_warehouse_orderpoint.xml b/indoteknik_custom/views/stock_warehouse_orderpoint.xml new file mode 100644 index 00000000..038b09cc --- /dev/null +++ b/indoteknik_custom/views/stock_warehouse_orderpoint.xml @@ -0,0 +1,15 @@ + + + + + stock.warehouse.orderpoint.tree + stock.warehouse.orderpoint + + + + + + + + + \ No newline at end of file diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index f68a0e00..d413be12 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -24,6 +24,7 @@ + @@ -46,6 +47,7 @@ + -- cgit v1.2.3 From 9292b2e0865500077281e2c410d264011b9a65da Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 25 Oct 2023 15:56:56 +0700 Subject: add date if all line in delivery order reserved --- indoteknik_custom/models/sale_order.py | 38 +++++++++++++++++++++++++++++++ indoteknik_custom/models/stock_picking.py | 6 +++++ indoteknik_custom/views/stock_picking.xml | 1 + 3 files changed, 45 insertions(+) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 9324930e..9da6d9fb 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1,5 +1,6 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError +from datetime import datetime import logging, random, string, requests, math, json, re _logger = logging.getLogger(__name__) @@ -81,6 +82,16 @@ class SaleOrder(models.Model): email = fields.Char(string='Email') picking_iu_id = fields.Many2one('stock.picking', 'Picking IU') helper_by_id = fields.Many2one('res.users', 'Helper By') + picking_ids = fields.Many2many('stock.picking', string='Pickings', compute='_get_pickings', readonly=True, copy=False, search="_search_picking_ids") + + def _get_pickings(self): + state = ['assigned'] + for order in self: + pickings = self.env['stock.picking'].search([ + ('sale_id.id', '=', order.id), + ('state', 'in', state) + ]) + order.picking_ids = pickings @api.model def action_multi_update_state(self): @@ -193,8 +204,35 @@ class SaleOrder(models.Model): sale.so_status = 'sebagian' else: sale.so_status = 'menunggu' + + for picking in sale.picking_ids: + sum_qty_pick = sum(move_line.product_uom_qty for move_line in picking.move_ids_without_package) + sum_qty_reserved = sum(move_line.product_uom_qty for move_line in picking.move_line_ids_without_package) + if sum_qty_pick == sum_qty_reserved: + current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + picking.date_reserved = current_time + else: + picking.date_reserved = '' + _logger.info('Calculate SO Status %s' % sale.id) + def _search_picking_ids(self, operator, value): + if operator == 'in' and value: + self.env.cr.execute(""" + SELECT array_agg(so.sale_id) + FROM stock_picking so + WHERE + so.sale_id is not null and so.id = ANY(%s) + """, (list(value),)) + so_ids = self.env.cr.fetchone()[0] or [] + return [('id', 'in', so_ids)] + elif operator == '=' and not value: + order_ids = self._search([ + ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')) + ]) + return [('id', 'not in', order_ids)] + return ['&', ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)] + @api.onchange('partner_shipping_id') def onchange_partner_shipping(self): self.real_shipping_id = self.partner_shipping_id diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 626e842d..a5e533b1 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1,6 +1,7 @@ from odoo import fields, models, api, _ from odoo.exceptions import AccessError, UserError, ValidationError from odoo.tools.float_utils import float_is_zero +from datetime import datetime from itertools import groupby import pytz, datetime @@ -74,6 +75,7 @@ class StockPicking(models.Model): purchase_representative_id = fields.Many2one('res.users', related='move_lines.purchase_line_id.order_id.user_id', string="Purchase Representative", readonly=True) carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method') shipping_status = fields.Char(string='Shipping Status', compute="_compute_shipping_status") + date_reserved = fields.Datetime(string="Date Reserved", help='Tanggal ter-reserved semua barang nya') def _compute_shipping_status(self): for rec in self: @@ -309,6 +311,10 @@ class StockPicking(models.Model): if product: product.product_tmpl_id._create_solr_queue('_sync_product_stock_to_solr') + if not self.date_reserved: + current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + self.date_reserved = current_time + res = super(StockPicking, self).button_validate() self.calculate_line_no() return res diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 3702dcf8..b0932d5a 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -72,6 +72,7 @@ /> + Date: Thu, 26 Oct 2023 11:09:33 +0700 Subject: fix bug in sale order while compute date reserved --- indoteknik_custom/models/sale_order.py | 56 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 9da6d9fb..cc6941a9 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -82,16 +82,16 @@ class SaleOrder(models.Model): email = fields.Char(string='Email') picking_iu_id = fields.Many2one('stock.picking', 'Picking IU') helper_by_id = fields.Many2one('res.users', 'Helper By') - picking_ids = fields.Many2many('stock.picking', string='Pickings', compute='_get_pickings', readonly=True, copy=False, search="_search_picking_ids") + # picking_ids = fields.Many2many('stock.picking', string='Pickings', compute='_get_pickings', readonly=True, copy=False, search="_search_picking_ids") - def _get_pickings(self): - state = ['assigned'] - for order in self: - pickings = self.env['stock.picking'].search([ - ('sale_id.id', '=', order.id), - ('state', 'in', state) - ]) - order.picking_ids = pickings + # def _get_pickings(self): + # state = ['assigned'] + # for order in self: + # pickings = self.env['stock.picking'].search([ + # ('sale_id.id', '=', order.id), + # ('state', 'in', state) + # ]) + # order.picking_ids = pickings @api.model def action_multi_update_state(self): @@ -208,30 +208,34 @@ class SaleOrder(models.Model): for picking in sale.picking_ids: sum_qty_pick = sum(move_line.product_uom_qty for move_line in picking.move_ids_without_package) sum_qty_reserved = sum(move_line.product_uom_qty for move_line in picking.move_line_ids_without_package) - if sum_qty_pick == sum_qty_reserved: + if picking.state == 'done': + continue + elif sum_qty_pick == sum_qty_reserved and not picking.date_reserved:# baru ke reserved current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') picking.date_reserved = current_time + elif sum_qty_pick == sum_qty_reserved:# sudah ada data reserved + picking.date_reserved = picking.date_reserved else: picking.date_reserved = '' _logger.info('Calculate SO Status %s' % sale.id) - def _search_picking_ids(self, operator, value): - if operator == 'in' and value: - self.env.cr.execute(""" - SELECT array_agg(so.sale_id) - FROM stock_picking so - WHERE - so.sale_id is not null and so.id = ANY(%s) - """, (list(value),)) - so_ids = self.env.cr.fetchone()[0] or [] - return [('id', 'in', so_ids)] - elif operator == '=' and not value: - order_ids = self._search([ - ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')) - ]) - return [('id', 'not in', order_ids)] - return ['&', ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)] + # def _search_picking_ids(self, operator, value): + # if operator == 'in' and value: + # self.env.cr.execute(""" + # SELECT array_agg(so.sale_id) + # FROM stock_picking so + # WHERE + # so.sale_id is not null and so.id = ANY(%s) + # """, (list(value),)) + # so_ids = self.env.cr.fetchone()[0] or [] + # return [('id', 'in', so_ids)] + # elif operator == '=' and not value: + # order_ids = self._search([ + # ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')) + # ]) + # return [('id', 'not in', order_ids)] + # return ['&', ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)] @api.onchange('partner_shipping_id') def onchange_partner_shipping(self): -- cgit v1.2.3 From 0037ab8019daad5c1cfccd0007284c54b5c22253 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 26 Oct 2023 11:56:16 +0700 Subject: add indent tab in purchase order --- indoteknik_custom/models/purchase_order.py | 1 + indoteknik_custom/views/purchase_order.xml | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index d62d7b1e..f9cd7f5b 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -48,6 +48,7 @@ class PurchaseOrder(models.Model): note_description = fields.Char(string='Note', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice') 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) def _compute_has_active_invoice(self): for order in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index d564f260..8f7ea6df 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -79,6 +79,7 @@ + @@ -96,6 +97,12 @@ {'readonly': [], 'required': True} + + + + + + @@ -165,4 +172,16 @@ True + + + purchase.order.line.indent.tree + purchase.order.line + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 6777edb758fb29981a0baac663b1388a820cded8 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 26 Oct 2023 15:54:47 +0700 Subject: bug fix get purchase price in sales order --- indoteknik_custom/models/sale_order_line.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 748153ad..eda003c7 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -87,6 +87,10 @@ class SaleOrderLine(models.Model): p_price = purchase_price.product_price else: p_price = purchase_price.system_price + elif purchase_price.system_price > 0 and purchase_price.product_price == 0: + p_price = purchase_price.system_price + elif purchase_price.system_price == 0 and purchase_price.product_price > 0: + p_price = purchase_price.product_price return p_price @api.onchange('product_id') -- cgit v1.2.3 From 5bb681f2975a3fb38fcd87c89f72d18c6e794170 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 28 Oct 2023 10:07:00 +0700 Subject: Bug fix condition sync product price to solr --- indoteknik_custom/models/solr/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 2bbcab9c..648a0625 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -137,7 +137,7 @@ class ProductTemplate(models.Model): price_tier = price_doc.get(f"{price_tier_key}_f", 0) # When price tier is 0 or variant_price less than price tier then use variant price - if price_tier == 0 or variant_price < price_tier: + if price_tier == 0 or (variant_price < price_tier and variant_price > 0): price_doc[f"{discount_tier_key}_f"] = variant_discount price_doc[f"{price_tier_key}_f"] = variant_price -- cgit v1.2.3 From c114fc17c7502174415c4e4bf1e7f8e24a46998c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 30 Oct 2023 08:59:11 +0700 Subject: Change name manufacture on solr to lowercase --- indoteknik_custom/models/solr/x_manufactures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/x_manufactures.py b/indoteknik_custom/models/solr/x_manufactures.py index 375b7708..98b1d01d 100644 --- a/indoteknik_custom/models/solr/x_manufactures.py +++ b/indoteknik_custom/models/solr/x_manufactures.py @@ -40,7 +40,7 @@ class XManufactures(models.Model): document.update({ 'id': brands.id, 'display_name_s': brands.display_name, - 'name_s': brands.x_name, + 'name_s': brands.x_name.lower(), 'sequence_i': brands.sequence or '', 'negara_asal_s': brands.x_negara_asal or '', 'short_desc_s': brands.x_short_desc or '', -- cgit v1.2.3 From 9530cc0c2ba6a15300799cf7e14b6dc1b04daa37 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 30 Oct 2023 11:37:11 +0700 Subject: move status invoice to bottom in sales monitoring detail --- indoteknik_custom/models/sale_monitoring_detail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index dc4caa14..43b0b063 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -31,12 +31,12 @@ class SaleMonitoringDetail(models.Model): SELECT *, CASE - when qty_so_invoiced = qty_so then 'Invoiced' when qty_so_delivered = qty_so then 'Delivered' when qty_reserved >= qty_so then 'Siap kirim' when qty_po + qty_reserved - qty_po_received < qty_so then 'Belum/Kurang PO' when qty_po_received = 0 then 'Belum terima' when qty_po_received < qty_po then 'Terima sebagian' + when qty_so_invoiced = qty_so then 'Invoiced' END AS status FROM ( -- cgit v1.2.3 From d426ff142df8b5778398e3b460ff03d02d9e368a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 30 Oct 2023 11:38:13 +0700 Subject: move status invoiced to bottom in sale monitoring header only --- indoteknik_custom/models/sale_monitoring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index cfbe6d78..107d5296 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -81,12 +81,12 @@ class SaleMonitoring(models.Model): SUM(smd.qty_so_invoiced) AS qty_so_invoiced, sum(smd.qty_reserved) as qty_reserved, CASE - when sum(qty_so_invoiced) = sum(qty_so) then 'Invoiced' when sum(qty_so_delivered) = sum(qty_so) then 'Delivered' when sum(qty_reserved) >= sum(qty_so) then 'Siap kirim' when sum(qty_po) + sum(qty_reserved) - sum(qty_po_received) < sum(qty_so) then 'Belum/Kurang PO' when sum(qty_po_received) = 0 then 'Belum terima' when sum(qty_po_received) < sum(qty_po) then 'Terima sebagian' + when sum(qty_so_invoiced) = sum(qty_so) then 'Invoiced' END AS status, get_po_number(smd.sale_order_id) as po_number FROM sale_monitoring_detail smd -- cgit v1.2.3 From f8fc4ac3557bf5a74f49ea79b178b29ff5684815 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 1 Nov 2023 11:00:34 +0700 Subject: Add digital invoice tax field on partner --- indoteknik_custom/models/res_partner.py | 1 + indoteknik_custom/views/res_partner.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index bc2a24b1..2983ca45 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -19,6 +19,7 @@ class ResPartner(models.Model): ]) sppkp = fields.Char(string="SPPKP") counter = fields.Integer(string="Counter", default=0) + digital_invoice_tax = fields.Boolean(string="Digital Invoice & Faktur Pajak") def get_child_ids(self): partner = self.env['res.partner'].search([('id', '=', self.id)], limit=1) diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index d609fdd5..ef4898d0 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -14,6 +14,7 @@ + -- cgit v1.2.3 From 6b49797aca36574497f93a06f8e1c0622e5ad009 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 2 Nov 2023 15:40:43 +0700 Subject: add field kind of sparepart and accesories in product template --- indoteknik_custom/models/product_template.py | 4 ++++ indoteknik_custom/views/product_template.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 10d109fb..d1de2221 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -53,6 +53,10 @@ class ProductTemplate(models.Model): seq_new_product = fields.Integer(string='Seq New Product', help='Urutan Sequence New Product') is_edited = fields.Boolean(string='Is Edited') qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') + kind_of = fields.Selection([ + ('sp', 'Spare Part'), + ('acc', 'Accessories') + ], string='Kind of', copy=False) def _get_qty_sold(self): for rec in self: diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index 6fdb5e8f..92d2191e 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -10,6 +10,7 @@ + -- cgit v1.2.3 From a4cd5ce9cd8d5ef38062732a16a61d6d5c094e30 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 3 Nov 2023 10:46:02 +0700 Subject: initial commit for new window of customer commision --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/commision.py | 41 +++++++++++++ indoteknik_custom/security/ir.model.access.csv | 4 +- indoteknik_custom/views/customer_commision.xml | 82 ++++++++++++++++++++++++++ indoteknik_custom/views/ir_sequence.xml | 10 ++++ 6 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/commision.py create mode 100644 indoteknik_custom/views/customer_commision.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 3bc4be60..a758d636 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -100,6 +100,7 @@ 'views/stock_move_line.xml', 'views/product_monitoring.xml', 'views/stock_warehouse_orderpoint.xml', + 'views/customer_commision.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 6a5eac00..e842b511 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -91,3 +91,4 @@ from . import sale_orders_multi_update from . import quotation_so_multi_update from . import product_monitoring from . import stock_warehouse_orderpoint +from . import commision diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py new file mode 100644 index 00000000..e39deb63 --- /dev/null +++ b/indoteknik_custom/models/commision.py @@ -0,0 +1,41 @@ +from odoo import models, api, fields +from odoo.exceptions import UserError +from datetime import datetime +import logging + +_logger = logging.getLogger(__name__) + + +class CustomerCommision(models.Model): + _name = 'customer.commision' + _order = 'id desc' + + number = fields.Char(string='Document No', index=True, copy=False, readonly=True) + date_from = fields.Date(string='Date From', required=True) + date_to = fields.Date(string='Date To', required=True) + partner_id = fields.Many2one('res.partner', String='Customer', required=True) + description = fields.Char(string='Description') + notification = fields.Char(string='Notification') + commision_lines = fields.One2many('customer.commision.line', 'customer_commision_id', string='Lines', auto_join=True) + + @api.model + def create(self, vals): + vals['number'] = self.env['ir.sequence'].next_by_code('customer.commision') or '0' + result = super(CustomerCommision, self).create(vals) + return result + + def generate_customer_commision(self): + print("masuk") + return + +class CustomerCommisionLine(models.Model): + _name = 'customer.commision.line' + _order = 'id' + + customer_commision_id = fields.Many2one('customer.commision', string='Ref', required=True, ondelete='cascade', copy=False) + invoice_id = fields.Many2one('account.move', string='Invoice') + partner_id = fields.Many2one('res.partner', string='Customer') + state = fields.Char(string='InvStatus') + dpp = fields.Float(string='DPP') + tax = fields.Float(string='TaxAmt') + total = fields.Float(string='Total') diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 7a074c71..ed8d4725 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -78,4 +78,6 @@ access_stock_scheduler_compute,access.stock.scheduler.compute,model_stock_schedu access_sale_order_promotion,access.sale.order.promotion,model_sale_order_promotion,,1,1,1,1 access_sale_orders_multi_update,access.sale.orders.multi_update,model_sale_orders_multi_update,,1,1,1,1 access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1 -access_product_monitoring,access.product.monitoring,model_product_monitoring,,1,1,1,1 \ No newline at end of file +access_product_monitoring,access.product.monitoring,model_product_monitoring,,1,1,1,1 +access_customer_commision,access.customer.commision,model_customer_commision,,1,1,1,1 +access_customer_commision_line,access.customer.commision.line,model_customer_commision_line,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml new file mode 100644 index 00000000..a714cb80 --- /dev/null +++ b/indoteknik_custom/views/customer_commision.xml @@ -0,0 +1,82 @@ + + + + customer.commision.tree + customer.commision + + + + + + + + + + + + + + customer.commision.line.tree + customer.commision.line + + + + + + + + + + + + + + customer_commision_form + customer.commision + +
+ +
+ + + + + + + + + + +
+
+
+
+ + + + + + + + + + + + Customer Commision + ir.actions.act_window + customer.commision + tree,form + + + + \ No newline at end of file diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index 6798e5b4..86259b12 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -60,5 +60,15 @@ 1 1 + + + Customer Commision + customer.commision + TRUE + CC/%(year)s/ + 5 + 1 + 1 + \ No newline at end of file -- cgit v1.2.3 From e12706c91da229ee1f556635968f8d9c42555af1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 3 Nov 2023 11:30:41 +0700 Subject: add button confirm --- indoteknik_custom/models/commision.py | 28 +++++++++++++++++++++++++- indoteknik_custom/views/customer_commision.xml | 5 +++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index e39deb63..d6c0b0a5 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -24,8 +24,34 @@ class CustomerCommision(models.Model): result = super(CustomerCommision, self).create(vals) return result + def action_confirm_customer_commision(self): + print("a") + return + def generate_customer_commision(self): - print("masuk") + partners = [] + partners += self.partner_id.child_ids + partners.append(self.partner_id) + + for partner in partners: + where = [ + ('move_type', '=', 'out_invoice'), + ('state', '=', 'posted'), + ('partner_id.id', '=', partner.id), + ('invoice_date', '>=', self.date_from), + ('invoice_date', '<=', self.date_to), + ] + invoices = self.env['account.move'].search(where, order='id') + for invoice in invoices: + self.env['customer.commision.line'].create([{ + 'customer_commision_id': self.id, + 'partner_id': invoice.partner_id.id, + 'invoice_id': invoice.id, + 'state': invoice.state, + 'dpp': invoice.amount_untaxed_signed, + 'tax': invoice.amount_tax_signed, + 'total': invoice.amount_total_signed + }]) return class CustomerCommisionLine(models.Model): diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml index a714cb80..b60cc1d9 100644 --- a/indoteknik_custom/views/customer_commision.xml +++ b/indoteknik_custom/views/customer_commision.xml @@ -35,6 +35,11 @@ customer.commision
+
+
-- cgit v1.2.3 From 566a20db595a2b0a1959a12d289361b16e1ef172 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 3 Nov 2023 13:42:51 +0700 Subject: add approval in editing reconcile & journal entries --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 3 ++- indoteknik_custom/models/account_bank_statement.py | 19 +++++++++++++ indoteknik_custom/models/account_move.py | 12 ++++++++- indoteknik_custom/models/users.py | 1 + indoteknik_custom/views/account_bank_statement.xml | 31 ++++++++++++++++++++++ indoteknik_custom/views/users.xml | 1 + 7 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/models/account_bank_statement.py create mode 100644 indoteknik_custom/views/account_bank_statement.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 23abc084..b054d594 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -99,6 +99,7 @@ 'views/quotation_so_multi_update.xml', 'views/stock_move_line.xml', 'views/product_monitoring.xml', + 'views/account_bank_statement.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 1133c3e7..23a7331c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -89,4 +89,5 @@ from . import stock_scheduler_compute from . import promotion from . import sale_orders_multi_update from . import quotation_so_multi_update -from . import product_monitoring \ No newline at end of file +from . import product_monitoring +from . import account_bank_statement \ No newline at end of file diff --git a/indoteknik_custom/models/account_bank_statement.py b/indoteknik_custom/models/account_bank_statement.py new file mode 100644 index 00000000..495367e8 --- /dev/null +++ b/indoteknik_custom/models/account_bank_statement.py @@ -0,0 +1,19 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import AccessError, UserError, ValidationError + +class AccountBankStatement(models.Model): + _inherit = "account.bank.statement" + + is_edit = fields.Boolean(string='Edit', default=False) + + def is_edited(self): + if not self.env.user.is_admin_reconcile: + raise UserError('Yang berhak hanya Mba Tania') + + self.is_edit = True + + def not_edited(self): + if not self.env.user.is_admin_reconcile: + raise UserError('Yang berhak hanya Mba Tania') + + self.is_edit = False \ No newline at end of file diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index a85e8caa..c55e2e1b 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -62,6 +62,10 @@ class AccountMove(models.Model): res = super(AccountMove, self).button_draft() if not self.env.user.is_accounting: raise UserError('Hanya Accounting yang bisa Reset to Draft') + + if self.write_date != self.create_date: + if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') return res def action_post(self): @@ -145,4 +149,10 @@ class AccountMove(models.Model): 'move_ids': [x.id for x in self] } return action - \ No newline at end of file + + def write(self, vals): + res = super(AccountMove, self).write(vals) + if self.write_date != self.create_date: + if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + return res diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index b90c0097..2ff9933e 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -11,6 +11,7 @@ class Users(models.Model): is_accounting = fields.Boolean(string='Accounting', help='Berhak Approval Internal Use') 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') def notify_internal_users(self, message, title): users = self.search([('share', '=', False)]) diff --git a/indoteknik_custom/views/account_bank_statement.xml b/indoteknik_custom/views/account_bank_statement.xml new file mode 100644 index 00000000..a4e4f7e5 --- /dev/null +++ b/indoteknik_custom/views/account_bank_statement.xml @@ -0,0 +1,31 @@ + + + + + account.bank.statement.tree + account.bank.statement + + + + + + + + + + account.bank.statement.form + account.bank.statement + + + + + + + + + + \ No newline at end of file diff --git a/indoteknik_custom/views/users.xml b/indoteknik_custom/views/users.xml index d67b4474..020d8ddc 100644 --- a/indoteknik_custom/views/users.xml +++ b/indoteknik_custom/views/users.xml @@ -13,6 +13,7 @@ + -- cgit v1.2.3 From d05d1f609441ff0ead57d447c0ece63a968410de Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 4 Nov 2023 09:19:07 +0700 Subject: invisible field edit on reconcile --- indoteknik_custom/models/account_bank_statement.py | 6 +++--- indoteknik_custom/views/account_bank_statement.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/account_bank_statement.py b/indoteknik_custom/models/account_bank_statement.py index 495367e8..23008f13 100644 --- a/indoteknik_custom/models/account_bank_statement.py +++ b/indoteknik_custom/models/account_bank_statement.py @@ -4,16 +4,16 @@ from odoo.exceptions import AccessError, UserError, ValidationError class AccountBankStatement(models.Model): _inherit = "account.bank.statement" - is_edit = fields.Boolean(string='Edit', default=False) + is_edit = fields.Boolean(string='Unlock', default=False) def is_edited(self): if not self.env.user.is_admin_reconcile: - raise UserError('Yang berhak hanya Mba Tania') + raise UserError('Yang berhak hanya Mba Tania dan Iqmal Saputra') self.is_edit = True def not_edited(self): if not self.env.user.is_admin_reconcile: - raise UserError('Yang berhak hanya Mba Tania') + raise UserError('Yang berhak hanya Mba Tania dan Iqmal Saputra') self.is_edit = False \ No newline at end of file diff --git a/indoteknik_custom/views/account_bank_statement.xml b/indoteknik_custom/views/account_bank_statement.xml index a4e4f7e5..db380f37 100644 --- a/indoteknik_custom/views/account_bank_statement.xml +++ b/indoteknik_custom/views/account_bank_statement.xml @@ -23,7 +23,7 @@ - + -- cgit v1.2.3 From f8fcf079afbe107ed8bda3e6e832b58786d2a42a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 4 Nov 2023 11:53:45 +0700 Subject: fix error account move --- indoteknik_custom/models/account_move.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index c55e2e1b..ee4279b2 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -63,9 +63,10 @@ class AccountMove(models.Model): if not self.env.user.is_accounting: raise UserError('Hanya Accounting yang bisa Reset to Draft') - if self.write_date != self.create_date: - if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': - raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + for rec in self: + if rec.write_date != rec.create_date: + if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') return res def action_post(self): @@ -152,7 +153,8 @@ class AccountMove(models.Model): def write(self, vals): res = super(AccountMove, self).write(vals) - if self.write_date != self.create_date: - if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': - raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + for rec in self: + if rec.write_date != rec.create_date: + if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') return res -- cgit v1.2.3 From d445d93ab8688cd63a49ac6c128dca8eccb30fde Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Sat, 4 Nov 2023 11:56:57 +0700 Subject: change to dpp --- indoteknik_custom/models/commision.py | 43 +++++++++++++++++++++++++- indoteknik_custom/views/customer_commision.xml | 22 +++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index d6c0b0a5..315e47f6 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -9,6 +9,8 @@ _logger = logging.getLogger(__name__) class CustomerCommision(models.Model): _name = 'customer.commision' _order = 'id desc' + _inherit = ['mail.thread'] + _rec_name = 'number' number = fields.Char(string='Document No', index=True, copy=False, readonly=True) date_from = fields.Date(string='Date From', required=True) @@ -17,6 +19,30 @@ class CustomerCommision(models.Model): description = fields.Char(string='Description') notification = fields.Char(string='Notification') commision_lines = fields.One2many('customer.commision.line', 'customer_commision_id', string='Lines', auto_join=True) + status = fields.Selection([ + ('pengajuan', 'Menunggu Approval'), + ('approved', 'Approved') + ], string='Status', copy=False, readonly=True, tracking=3) + commision_percent = fields.Float(string='Commision %', tracking=3) + commision_amt = fields.Float(string='Commision Amount', tracking=3) + total_dpp = fields.Float(string='Total DPP', compute='_compute_total_dpp') + + @api.constrains('commision_percent') + def _onchange_commision_percent(self): + print('masuk onchange commision percent') + self.commision_amt = self.commision_percent * self.total_dpp // 100 + + # @api.constrains('commision_amt') + # def _onchange_commision_amt(self): + # print('masuk onchange commision amt') + # self.commision_percent = (self.commision_amt / self.grand_total * 100) + + def _compute_total_dpp(self): + for data in self: + total_dpp = 0 + for line in data.commision_lines: + total_dpp = total_dpp + line.dpp + data.total_dpp = total_dpp @api.model def create(self, vals): @@ -25,10 +51,20 @@ class CustomerCommision(models.Model): return result def action_confirm_customer_commision(self): - print("a") + if not self.status: + self.status = 'pengajuan' + elif self.status == 'pengajuan' and self.env.user.is_leader: + for line in self.commision_lines: + line.invoice_id.is_customer_commision = True + self.status = 'approved' + else: + raise UserError('Harus di approved oleh Pimpinan') return def generate_customer_commision(self): + if self.commision_lines: + raise UserError('Line sudah ada, tidak bisa di generate ulang') + partners = [] partners += self.partner_id.child_ids partners.append(self.partner_id) @@ -37,6 +73,7 @@ class CustomerCommision(models.Model): where = [ ('move_type', '=', 'out_invoice'), ('state', '=', 'posted'), + ('is_customer_commision', '=', False), ('partner_id.id', '=', partner.id), ('invoice_date', '>=', self.date_from), ('invoice_date', '<=', self.date_to), @@ -65,3 +102,7 @@ class CustomerCommisionLine(models.Model): dpp = fields.Float(string='DPP') tax = fields.Float(string='TaxAmt') total = fields.Float(string='Total') + +class AccountMove(models.Model): + _inherit = 'account.move' + is_customer_commision = fields.Boolean(string='Customer Commision Used') diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml index b60cc1d9..ccaa0727 100644 --- a/indoteknik_custom/views/customer_commision.xml +++ b/indoteknik_custom/views/customer_commision.xml @@ -11,6 +11,7 @@ + @@ -46,10 +47,10 @@ - - + +
@@ -59,6 +60,10 @@ class="mr-2 oe_highlight" />
+ + + +
@@ -67,6 +72,10 @@ +
+ + +
@@ -78,10 +87,17 @@ tree,form - + + \ No newline at end of file -- cgit v1.2.3 From efa51f6b1c5254996db90a90468241da303a7e21 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 6 Nov 2023 08:40:38 +0700 Subject: new table of partner commision --- indoteknik_custom/models/commision.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 315e47f6..6d61de4c 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -6,6 +6,17 @@ import logging _logger = logging.getLogger(__name__) +class CustomerRebate(models.Model): + _name = 'customer.rebate' + _order = 'id desc' + _inherit = ['mail.thread'] + + partner_id = fields.Many2one('res.partner', string='Customer') + date_from = fields.Date(string='Date From', required=True) + date_to = fields.Date(string='Date To', required=True) + target_quarter = fields.Float(string='Target/Quarter') + + class CustomerCommision(models.Model): _name = 'customer.commision' _order = 'id desc' @@ -26,6 +37,14 @@ class CustomerCommision(models.Model): commision_percent = fields.Float(string='Commision %', tracking=3) commision_amt = fields.Float(string='Commision Amount', tracking=3) total_dpp = fields.Float(string='Total DPP', compute='_compute_total_dpp') + commision_type = fields.Selection([ + ('fee', 'Fee'), + ('cashback', 'Cashback'), + ('rebate', 'Rebate'), + ], string='Commision Type') + + # add status for type of commision, fee, rebate / cashback + # include child or not? @api.constrains('commision_percent') def _onchange_commision_percent(self): -- cgit v1.2.3 From 7fccc21783e9c3b61c62757b202bccf3b40aba31 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 6 Nov 2023 13:11:47 +0700 Subject: get valid purchase price while create po from automatic purchase --- indoteknik_custom/models/automatic_purchase.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index f81ecdcc..502761e0 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -105,15 +105,18 @@ class AutomaticPurchase(models.Model): ('product_id', '=', point.product_id.id), # ('product_id.x_manufacture.user_id.id', '=', self.responsible_id.id), ('vendor_id', '=', self.vendor_id.id) - ], order='product_price asc', limit=1) + ], order='count_trx_po desc, count_trx_po_vendor desc', limit=1) else: purchase_price = self.env['purchase.pricelist'].search([ ('product_id', '=', point.product_id.id), # ('product_id.x_manufacture.user_id.id', '=', self.responsible_id.id), - ], order='product_price asc', limit=1) + ], order='count_trx_po desc, count_trx_po_vendor desc', limit=1) vendor_id = purchase_price.vendor_id.id - price = purchase_price.product_price or 0 + price = self._get_valid_purchase_price(purchase_price) + + if self.vendor_id and self.vendor_id.id != vendor_id: + continue self.env['automatic.purchase.line'].create([{ 'automatic_purchase_id': self.id, @@ -135,6 +138,19 @@ class AutomaticPurchase(models.Model): _logger.info('Create Automatic Purchase Line %s' % point.product_id.name) self.notification = "Automatic PO Created %s Lines" % count + def _get_valid_purchase_price(self, purchase_price): + p_price = 0 + if purchase_price.system_price > 0 and purchase_price.product_price > 0: + if purchase_price.human_last_update > purchase_price.system_last_update: + p_price = purchase_price.product_price + else: + p_price = purchase_price.system_price + elif purchase_price.system_price > 0 and purchase_price.product_price == 0: + p_price = purchase_price.system_price + elif purchase_price.system_price == 0 and purchase_price.product_price > 0: + p_price = purchase_price.product_price + return p_price + class AutomaticPurchaseLine(models.Model): _name = 'automatic.purchase.line' -- cgit v1.2.3 From 12492662cac198463233dec43952e43038611ada Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 8 Nov 2023 08:59:13 +0700 Subject: add list customer rebate --- indoteknik_custom/models/commision.py | 104 ++++++++++++++++++++++++- indoteknik_custom/security/ir.model.access.csv | 3 +- indoteknik_custom/views/customer_commision.xml | 84 ++++++++++++++++++++ 3 files changed, 186 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 6d61de4c..0dbbce52 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -11,10 +11,106 @@ class CustomerRebate(models.Model): _order = 'id desc' _inherit = ['mail.thread'] - partner_id = fields.Many2one('res.partner', string='Customer') - date_from = fields.Date(string='Date From', required=True) - date_to = fields.Date(string='Date To', required=True) - target_quarter = fields.Float(string='Target/Quarter') + partner_id = fields.Many2one('res.partner', string='Customer', required=True) + date_from = fields.Date(string='Date From', required=True, help="Pastikan tanggal 1 januari, jika tidak, code akan break") + date_to = fields.Date(string='Date To', required=True, help="Pastikan tanggal 31 desember, jika tidak, code akan break") + description = fields.Char(string='Description') + target_1st = fields.Float(string='Target/Quarter 1st') + target_2nd = fields.Float(string='Target/Quarter 2nd') + achieve_1 = fields.Float(string='Achieve 1 %') + achieve_2 = fields.Float(string='Achieve 2 %') + dpp_q1 = fields.Float(string='DPP Q1', compute='_compute_current_dpp') + dpp_q2 = fields.Float(string='DPP Q2', compute='_compute_current_dpp') + dpp_q3 = fields.Float(string='DPP Q3', compute='_compute_current_dpp') + dpp_q4 = fields.Float(string='DPP Q4', compute='_compute_current_dpp') + status_q1 = fields.Char(string='Status Q1', compute='_compute_achievement') + status_q2 = fields.Char(string='Status Q2', compute='_compute_achievement') + status_q3 = fields.Char(string='Status Q3', compute='_compute_achievement') + status_q4 = fields.Char(string='Status Q4', compute='_compute_achievement') + + def _compute_current_dpp(self): + for line in self: + line.dpp_q1 = line._get_current_dpp_q1(line) + line.dpp_q2 = line._get_current_dpp_q2(line) + line.dpp_q3 = line._get_current_dpp_q3(line) + line.dpp_q4 = line._get_current_dpp_q4(line) + + def _compute_achievement(self): + for line in self: + line.status_q1 = line._check_achievement(line.target_1st, line.target_2nd, line.dpp_q1) + line.status_q2 = line._check_achievement(line.target_1st, line.target_2nd, line.dpp_q2) + line.status_q3 = line._check_achievement(line.target_1st, line.target_2nd, line.dpp_q3) + line.status_q4 = line._check_achievement(line.target_1st, line.target_2nd, line.dpp_q4) + + def _check_achievement(self, target_1st, target_2nd, dpp): + status = 'not achieve' + if dpp >= target_1st: + status = '1st' + elif dpp >= target_2nd: + status = '2nd' + else: + status = 'not achieve' + return status + + def _get_current_dpp_q1(self, line): + sum_dpp = 0 + where = [ + ('move_type', '=', 'out_invoice'), + ('state', '=', 'posted'), + ('is_customer_commision', '=', False), + ('partner_id.id', '=', line.partner_id.id), + ('invoice_date', '>=', line.date_from), + ('invoice_date', '<=', '2023-03-31'), + ] + invoices = self.env['account.move'].search(where, order='id') + for invoice in invoices: + sum_dpp += invoice.amount_untaxed_signed + return sum_dpp + + def _get_current_dpp_q2(self, line): + sum_dpp = 0 + where = [ + ('move_type', '=', 'out_invoice'), + ('state', '=', 'posted'), + ('is_customer_commision', '=', False), + ('partner_id.id', '=', line.partner_id.id), + ('invoice_date', '>=', '2023-04-01'), + ('invoice_date', '<=', '2023-06-30'), + ] + invoices = self.env['account.move'].search(where, order='id') + for invoice in invoices: + sum_dpp += invoice.amount_untaxed_signed + return sum_dpp + + def _get_current_dpp_q3(self, line): + sum_dpp = 0 + where = [ + ('move_type', '=', 'out_invoice'), + ('state', '=', 'posted'), + ('is_customer_commision', '=', False), + ('partner_id.id', '=', line.partner_id.id), + ('invoice_date', '>=', '2023-07-01'), + ('invoice_date', '<=', '2023-09-30'), + ] + invoices = self.env['account.move'].search(where, order='id') + for invoice in invoices: + sum_dpp += invoice.amount_untaxed_signed + return sum_dpp + + def _get_current_dpp_q4(self, line): + sum_dpp = 0 + where = [ + ('move_type', '=', 'out_invoice'), + ('state', '=', 'posted'), + ('is_customer_commision', '=', False), + ('partner_id.id', '=', line.partner_id.id), + ('invoice_date', '>=', '2023-10-01'), + ('invoice_date', '<=', line.date_to), + ] + invoices = self.env['account.move'].search(where, order='id') + for invoice in invoices: + sum_dpp += invoice.amount_untaxed_signed + return sum_dpp class CustomerCommision(models.Model): diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index ed8d4725..ff467204 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -80,4 +80,5 @@ access_sale_orders_multi_update,access.sale.orders.multi_update,model_sale_order access_quotation_so_multi_update,access.quotation.so.multi_update,model_quotation_so_multi_update,,1,1,1,1 access_product_monitoring,access.product.monitoring,model_product_monitoring,,1,1,1,1 access_customer_commision,access.customer.commision,model_customer_commision,,1,1,1,1 -access_customer_commision_line,access.customer.commision.line,model_customer_commision_line,,1,1,1,1 \ No newline at end of file +access_customer_commision_line,access.customer.commision.line,model_customer_commision_line,,1,1,1,1 +access_customer_rebate,access.customer.rebate,model_customer_rebate,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml index ccaa0727..f067093b 100644 --- a/indoteknik_custom/views/customer_commision.xml +++ b/indoteknik_custom/views/customer_commision.xml @@ -100,4 +100,88 @@ parent="sale.product_menu_catalog" sequence="101" /> + + + customer.rebate.tree + customer.rebate + + + + + + + + + + + + + + + + + + + + + + + + customer_rebate_form + customer.rebate + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + Customer Rebate + ir.actions.act_window + customer.rebate + tree,form + + + + + \ No newline at end of file -- cgit v1.2.3 From 23c357465171e83e716c7a2619d4aa03041705b8 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 8 Nov 2023 09:04:12 +0700 Subject: potential customer flag --- indoteknik_custom/models/res_partner.py | 1 + indoteknik_custom/views/res_partner.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 2983ca45..a1b57147 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -20,6 +20,7 @@ class ResPartner(models.Model): sppkp = fields.Char(string="SPPKP") counter = fields.Integer(string="Counter", default=0) digital_invoice_tax = fields.Boolean(string="Digital Invoice & Faktur Pajak") + is_potential = fields.Boolean(string='Potential') def get_child_ids(self): partner = self.env['res.partner'].search([('id', '=', self.id)], limit=1) diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index ef4898d0..c1ae3ed3 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -14,6 +14,7 @@ + -- cgit v1.2.3 From bdb068f9ac374b97504890c69308e6afd2c22527 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 8 Nov 2023 10:41:35 +0700 Subject: fix bug entries can edit after unlock reconcile --- indoteknik_custom/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index ee4279b2..2c9b9816 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -153,7 +153,7 @@ class AccountMove(models.Model): def write(self, vals): res = super(AccountMove, self).write(vals) - for rec in self: + for rec in self.line_ids: if rec.write_date != rec.create_date: if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') -- cgit v1.2.3 From f64c15810e963555e88511becee56f4ee8efb21b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 8 Nov 2023 10:54:51 +0700 Subject: update commision for rebate --- indoteknik_custom/models/commision.py | 130 +++++++++++++++++-------- indoteknik_custom/views/customer_commision.xml | 6 +- 2 files changed, 95 insertions(+), 41 deletions(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 0dbbce52..f9edf2ad 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -28,6 +28,7 @@ class CustomerRebate(models.Model): status_q3 = fields.Char(string='Status Q3', compute='_compute_achievement') status_q4 = fields.Char(string='Status Q4', compute='_compute_achievement') + # all code class CustomerRebate deprecated, cause lack of performance def _compute_current_dpp(self): for line in self: line.dpp_q1 = line._get_current_dpp_q1(line) @@ -54,62 +55,70 @@ class CustomerRebate(models.Model): def _get_current_dpp_q1(self, line): sum_dpp = 0 + brand = [10, 89, 122] where = [ - ('move_type', '=', 'out_invoice'), - ('state', '=', 'posted'), - ('is_customer_commision', '=', False), - ('partner_id.id', '=', line.partner_id.id), - ('invoice_date', '>=', line.date_from), - ('invoice_date', '<=', '2023-03-31'), + ('move_id.move_type', '=', 'out_invoice'), + ('move_id.state', '=', 'posted'), + ('move_id.is_customer_commision', '=', False), + ('move_id.partner_id.id', '=', line.partner_id.id), + ('move_id.invoice_date', '>=', line.date_from), + ('move_id.invoice_date', '<=', '2023-03-31'), + ('product_id.x_manufacture', 'in', brand), ] - invoices = self.env['account.move'].search(where, order='id') - for invoice in invoices: - sum_dpp += invoice.amount_untaxed_signed + invoice_lines = self.env['account.move.line'].search(where, order='id') + for invoice_line in invoice_lines: + sum_dpp += invoice_line.price_subtotal return sum_dpp def _get_current_dpp_q2(self, line): sum_dpp = 0 + brand = [10, 89, 122] where = [ - ('move_type', '=', 'out_invoice'), - ('state', '=', 'posted'), - ('is_customer_commision', '=', False), - ('partner_id.id', '=', line.partner_id.id), - ('invoice_date', '>=', '2023-04-01'), - ('invoice_date', '<=', '2023-06-30'), + ('move_id.move_type', '=', 'out_invoice'), + ('move_id.state', '=', 'posted'), + ('move_id.is_customer_commision', '=', False), + ('move_id.partner_id.id', '=', line.partner_id.id), + ('move_id.invoice_date', '>=', '2023-04-01'), + ('move_id.invoice_date', '<=', '2023-06-30'), + ('product_id.x_manufacture', 'in', brand), ] - invoices = self.env['account.move'].search(where, order='id') + invoices = self.env['account.move.line'].search(where, order='id') for invoice in invoices: - sum_dpp += invoice.amount_untaxed_signed + sum_dpp += invoice.price_subtotal return sum_dpp def _get_current_dpp_q3(self, line): sum_dpp = 0 + brand = [10, 89, 122] where = [ - ('move_type', '=', 'out_invoice'), - ('state', '=', 'posted'), - ('is_customer_commision', '=', False), - ('partner_id.id', '=', line.partner_id.id), - ('invoice_date', '>=', '2023-07-01'), - ('invoice_date', '<=', '2023-09-30'), + ('move_id.move_type', '=', 'out_invoice'), + ('move_id.state', '=', 'posted'), + ('move_id.is_customer_commision', '=', False), + ('move_id.partner_id.id', '=', line.partner_id.id), + ('move_id.invoice_date', '>=', '2023-07-01'), + ('move_id.invoice_date', '<=', '2023-09-30'), + ('product_id.x_manufacture', 'in', brand), ] - invoices = self.env['account.move'].search(where, order='id') + invoices = self.env['account.move.line'].search(where, order='id') for invoice in invoices: - sum_dpp += invoice.amount_untaxed_signed + sum_dpp += invoice.price_subtotal return sum_dpp def _get_current_dpp_q4(self, line): sum_dpp = 0 + brand = [10, 89, 122] where = [ - ('move_type', '=', 'out_invoice'), - ('state', '=', 'posted'), - ('is_customer_commision', '=', False), - ('partner_id.id', '=', line.partner_id.id), - ('invoice_date', '>=', '2023-10-01'), - ('invoice_date', '<=', line.date_to), + ('move_id.move_type', '=', 'out_invoice'), + ('move_id.state', '=', 'posted'), + ('move_id.is_customer_commision', '=', False), + ('move_id.partner_id.id', '=', line.partner_id.id), + ('move_id.invoice_date', '>=', '2023-10-01'), + ('move_id.invoice_date', '<=', line.date_to), + ('product_id.x_manufacture', 'in', brand), ] - invoices = self.env['account.move'].search(where, order='id') + invoices = self.env['account.move.line'].search(where, order='id') for invoice in invoices: - sum_dpp += invoice.amount_untaxed_signed + sum_dpp += invoice.price_subtotal return sum_dpp @@ -127,7 +136,8 @@ class CustomerCommision(models.Model): notification = fields.Char(string='Notification') commision_lines = fields.One2many('customer.commision.line', 'customer_commision_id', string='Lines', auto_join=True) status = fields.Selection([ - ('pengajuan', 'Menunggu Approval'), + ('pengajuan1', 'Menunggu Approval Marketing'), + ('pengajuan2', 'Menunggu Approval Pimpinan'), ('approved', 'Approved') ], string='Status', copy=False, readonly=True, tracking=3) commision_percent = fields.Float(string='Commision %', tracking=3) @@ -137,7 +147,7 @@ class CustomerCommision(models.Model): ('fee', 'Fee'), ('cashback', 'Cashback'), ('rebate', 'Rebate'), - ], string='Commision Type') + ], string='Commision Type', required=True) # add status for type of commision, fee, rebate / cashback # include child or not? @@ -165,21 +175,61 @@ class CustomerCommision(models.Model): result = super(CustomerCommision, self).create(vals) return result - def action_confirm_customer_commision(self): + def action_confirm_customer_commision(self):#add 2 step approval if not self.status: - self.status = 'pengajuan' - elif self.status == 'pengajuan' and self.env.user.is_leader: + self.status = 'pengajuan1' + elif self.status == 'pengajuan1' and self.env.user.id == 19: + self.status = 'pengajuan2' + elif self.status == 'pengajuan2' and self.env.user.is_leader: for line in self.commision_lines: line.invoice_id.is_customer_commision = True self.status = 'approved' else: - raise UserError('Harus di approved oleh Pimpinan') + raise UserError('Harus di approved oleh yang bersangkutan') return def generate_customer_commision(self): if self.commision_lines: raise UserError('Line sudah ada, tidak bisa di generate ulang') + if self.commision_type == 'fee': + self._generate_customer_commision_fee() + else: + self._generate_customer_commision_rebate() + + def _generate_customer_commision_rebate(self): + partners = [] + partners += self.partner_id.child_ids + partners.append(self.partner_id) + + for partner in partners: + brand = [10, 89, 122] + where = [ + ('move_id.move_type', '=', 'out_invoice'), + ('move_id.state', '=', 'posted'), + ('move_id.is_customer_commision', '=', False), + ('move_id.amount_residual_signed', '=', 0), + ('move_id.partner_id.id', '=', partner.id), + ('move_id.invoice_date', '>=', self.date_from), + ('move_id.invoice_date', '<=', self.date_to), + ('product_id.x_manufacture', 'in', brand), + ] + invoice_lines = self.env['account.move.line'].search(where, order='id') + for invoice_line in invoice_lines: + tax = invoice_line.price_total - invoice_line.price_subtotal + self.env['customer.commision.line'].create([{ + 'customer_commision_id': self.id, + 'partner_id': invoice_line.move_id.partner_id.id, + 'invoice_id': invoice_line.move_id.id, + 'state': invoice_line.move_id.state, + 'product_id': invoice_line.product_id.id, + 'dpp': invoice_line.price_subtotal, + 'tax': tax, + 'total': invoice_line.price_total + }]) + return + + def _generate_customer_commision_fee(self): partners = [] partners += self.partner_id.child_ids partners.append(self.partner_id) @@ -189,6 +239,7 @@ class CustomerCommision(models.Model): ('move_type', '=', 'out_invoice'), ('state', '=', 'posted'), ('is_customer_commision', '=', False), + ('amount_residual_signed', '=', 0), ('partner_id.id', '=', partner.id), ('invoice_date', '>=', self.date_from), ('invoice_date', '<=', self.date_to), @@ -217,6 +268,7 @@ class CustomerCommisionLine(models.Model): dpp = fields.Float(string='DPP') tax = fields.Float(string='TaxAmt') total = fields.Float(string='Total') + product_id = fields.Many2one('product.product', string='Product') class AccountMove(models.Model): _inherit = 'account.move' diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml index f067093b..e299d37e 100644 --- a/indoteknik_custom/views/customer_commision.xml +++ b/indoteknik_custom/views/customer_commision.xml @@ -24,9 +24,10 @@ + - - + + @@ -61,6 +62,7 @@ />
+ -- cgit v1.2.3 From 019493c8e0e6cc5aff4c612eb332f1c882b0519d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 8 Nov 2023 11:03:23 +0700 Subject: button reset to draft entries --- indoteknik_custom/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 2c9b9816..4e1beb3a 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -63,7 +63,7 @@ class AccountMove(models.Model): if not self.env.user.is_accounting: raise UserError('Hanya Accounting yang bisa Reset to Draft') - for rec in self: + for rec in self.line_ids: if rec.write_date != rec.create_date: if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') -- cgit v1.2.3 From db561aabfa404edfff9462c812d15a200223b978 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 8 Nov 2023 11:19:54 +0700 Subject: add responsible in po base on manufacture responsible --- indoteknik_custom/models/purchase_order.py | 9 +++++++++ indoteknik_custom/views/purchase_order.xml | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index f9cd7f5b..b0f1a569 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -49,6 +49,15 @@ class PurchaseOrder(models.Model): has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice') 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') + + def _compute_responsibles(self): + for purchase in self: + resposible_ids = [] + for line in purchase.order_line: + resposible_ids.append(line.product_id.x_manufacture.user_id.id) + resposible_ids = list(set(resposible_ids)) + purchase.responsible_ids = resposible_ids def _compute_has_active_invoice(self): for order in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 8f7ea6df..bc84bcd1 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -79,7 +79,7 @@ - + @@ -115,6 +115,7 @@ +
@@ -130,6 +131,7 @@ + -- cgit v1.2.3 From 27b2145a60fde081f7dd5555126e169d426904e9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 9 Nov 2023 09:21:45 +0700 Subject: mandatory source in sale order --- indoteknik_custom/models/sale_order.py | 2 +- indoteknik_custom/views/sale_order.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index cc6941a9..dbc4e863 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -77,7 +77,7 @@ class SaleOrder(models.Model): voucher_id = fields.Many2one(comodel_name='voucher', string='Voucher', copy=False) applied_voucher_id = fields.Many2one(comodel_name='voucher', string='Applied Voucher', copy=False) amount_voucher_disc = fields.Float(string='Voucher Discount') - source_id = fields.Many2one('utm.source', 'Source', domain="[('id', 'in', [32, 59, 60, 61])]") + source_id = fields.Many2one('utm.source', 'Source', domain="[('id', 'in', [32, 59, 60, 61])]", required=True) estimated_arrival_days = fields.Integer('Estimated Arrival Days', default=0) email = fields.Char(string='Email') picking_iu_id = fields.Many2one('stock.picking', 'Picking IU') diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index a260c68a..c6187f60 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -50,7 +50,7 @@ - + -- cgit v1.2.3 From 14156f7d6f55eaa4e74310ee1aa4e5128aa17fff Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 9 Nov 2023 09:55:34 +0700 Subject: mandatory static npwp,sppkp,customer_type in sale order and fix log note journal entries --- indoteknik_custom/models/account_move.py | 18 ++++++++++++------ indoteknik_custom/models/sale_order.py | 6 +++--- indoteknik_custom/views/sale_order.xml | 6 +++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 4e1beb3a..fe9db583 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -151,10 +151,16 @@ class AccountMove(models.Model): } return action - def write(self, vals): - res = super(AccountMove, self).write(vals) + @api.constrains('efaktur_id', 'ref', 'date', 'journal_id', 'name') + def constrains_edit(self): for rec in self.line_ids: - if rec.write_date != rec.create_date: - if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': - raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') - return res + if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + + # def write(self, vals): + # res = super(AccountMove, self).write(vals) + # for rec in self.line_ids: + # if rec.write_date != rec.create_date: + # if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': + # raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + # return res diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index dbc4e863..f9229bca 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -70,9 +70,9 @@ class SaleOrder(models.Model): customer_type = fields.Selection([ ('pkp', 'PKP'), ('nonpkp', 'Non PKP') - ]) - sppkp = fields.Char(string="SPPKP") - npwp = fields.Char(string="NPWP") + ], required=True) + sppkp = fields.Char(string="SPPKP", required=True) + npwp = fields.Char(string="NPWP", required=True) purchase_total = fields.Monetary(string='Purchase Total', compute='_compute_purchase_total') voucher_id = fields.Many2one(comodel_name='voucher', string='Voucher', copy=False) applied_voucher_id = fields.Many2one(comodel_name='voucher', string='Applied Voucher', copy=False) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index c6187f60..5596c271 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -45,9 +45,9 @@ - - - + + + -- cgit v1.2.3 From a98d7f339c2bb15974f941b450cbaeb0de64283e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 10 Nov 2023 08:03:29 +0700 Subject: minor change requisition --- indoteknik_custom/models/requisition.py | 223 +++++++++++++++++--------------- indoteknik_custom/views/requisition.xml | 25 ++-- 2 files changed, 131 insertions(+), 117 deletions(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 19f0ba7e..6408c4fd 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -9,6 +9,8 @@ _logger = logging.getLogger(__name__) class Requisition(models.Model): _name = 'requisition' _order = 'id desc' + _inherit = ['mail.thread'] + _rec_name = 'number' number = fields.Char(string='Document No', index=True, copy=False, readonly=True) date_doc = fields.Date(string='Date', help='isi tanggal hari ini') @@ -26,108 +28,108 @@ class Requisition(models.Model): result = super(Requisition, self).create(vals) return result - def create_requisition_from_sales_with_price(self): - if self.requisition_lines: - raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') - if not self.sale_order_id: - raise UserError('Sale Order harus diisi') - if self.is_po: - raise UserError('Sudah jadi PO, tidak bisa di create ulang PO nya') - - count = 0 - for order_line in self.sale_order_id.order_line: - # get purchase price altama, if nothing, then get other cheaper, if nothing then last po - purchase_price = order_line.purchase_price - vendor_id = order_line.vendor_id.id - - # get qty available bandengan - qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty - suggest = 'harus beli' - if qty_available > order_line.product_qty: - suggest = 'masih cukup' - - self.env['requisition.line'].create([{ - 'requisition_id': self.id, - 'partner_id': vendor_id, - 'brand_id': order_line.product_id.product_tmpl_id.x_manufacture.id, - 'product_id': order_line.product_id.id, - 'qty_purchase': order_line.product_uom_qty, - 'tax_id': order_line.purchase_tax_id.id, - 'price_unit': purchase_price, - 'subtotal': purchase_price * order_line.product_uom_qty, - 'source': 'sales', - 'qty_available_store': qty_available, - 'suggest': suggest, - }]) - count+=1 - _logger.info('Create Requisition %s' % order_line.product_id.name) - self.notification = "Requisition Created %s lines" % count - - def create_requisition_from_sales(self): - if self.requisition_lines: - raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') - if not self.sale_order_id: - raise UserError('Sale Order harus diisi') - if self.is_po: - raise UserError('Sudah jadi PO, tidak bisa di create ulang PO nya') + # def create_requisition_from_sales_with_price(self): + # if self.requisition_lines: + # raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') + # if not self.sale_order_id: + # raise UserError('Sale Order harus diisi') + # if self.is_po: + # raise UserError('Sudah jadi PO, tidak bisa di create ulang PO nya') + + # count = 0 + # for order_line in self.sale_order_id.order_line: + # # get purchase price altama, if nothing, then get other cheaper, if nothing then last po + # purchase_price = order_line.purchase_price + # vendor_id = order_line.vendor_id.id + + # # get qty available bandengan + # qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty + # suggest = 'harus beli' + # if qty_available > order_line.product_qty: + # suggest = 'masih cukup' + + # self.env['requisition.line'].create([{ + # 'requisition_id': self.id, + # 'partner_id': vendor_id, + # 'brand_id': order_line.product_id.product_tmpl_id.x_manufacture.id, + # 'product_id': order_line.product_id.id, + # 'qty_purchase': order_line.product_uom_qty, + # 'tax_id': order_line.purchase_tax_id.id, + # 'price_unit': purchase_price, + # 'subtotal': purchase_price * order_line.product_uom_qty, + # 'source': 'sales', + # 'qty_available_store': qty_available, + # 'suggest': suggest, + # }]) + # count+=1 + # _logger.info('Create Requisition %s' % order_line.product_id.name) + # self.notification = "Requisition Created %s lines" % count + + # def create_requisition_from_sales(self): + # if self.requisition_lines: + # raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') + # if not self.sale_order_id: + # raise UserError('Sale Order harus diisi') + # if self.is_po: + # raise UserError('Sudah jadi PO, tidak bisa di create ulang PO nya') - # old_requisition = self.env['requisition'].search([('sale_order_id', '=', self.sale_order_id.id)], limit=1) - # if old_requisition: - # raise UserError('Sudah pernah jadi Requisition') - - count = 0 - for order_line in self.sale_order_id.order_line: - # get purchase price altama, if nothing, then get other cheaper, if nothing then last po - purchase_price = 0 - vendor_id = 0 - - # get qty available bandengan - qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty - suggest = 'harus beli' - if qty_available > order_line.product_qty: - suggest = 'masih cukup' - - purchase_pricelist = self.env['purchase.pricelist'].search([ - ('product_id.id', '=', order_line.product_id.id), - ('vendor_id.id', '=', 5571) - ], order='product_price asc', limit=1) - purchase_price = purchase_pricelist.product_price - vendor_id = purchase_pricelist.vendor_id.id - source = 'PriceList' + # # old_requisition = self.env['requisition'].search([('sale_order_id', '=', self.sale_order_id.id)], limit=1) + # # if old_requisition: + # # raise UserError('Sudah pernah jadi Requisition') + + # count = 0 + # for order_line in self.sale_order_id.order_line: + # # get purchase price altama, if nothing, then get other cheaper, if nothing then last po + # purchase_price = 0 + # vendor_id = 0 + + # # get qty available bandengan + # qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty + # suggest = 'harus beli' + # if qty_available > order_line.product_qty: + # suggest = 'masih cukup' + + # purchase_pricelist = self.env['purchase.pricelist'].search([ + # ('product_id.id', '=', order_line.product_id.id), + # ('vendor_id.id', '=', 5571) + # ], order='product_price asc', limit=1) + # purchase_price = purchase_pricelist.product_price + # vendor_id = purchase_pricelist.vendor_id.id + # source = 'PriceList' - if not purchase_price or purchase_price <= 0: - purchase_pricelist = self.env['purchase.pricelist'].search([('product_id', '=', order_line.product_id.id)], order='product_price asc', limit=1) - purchase_price = purchase_pricelist.product_price - vendor_id = purchase_pricelist.vendor_id.id - source = 'PriceList' + # if not purchase_price or purchase_price <= 0: + # purchase_pricelist = self.env['purchase.pricelist'].search([('product_id', '=', order_line.product_id.id)], order='product_price asc', limit=1) + # purchase_price = purchase_pricelist.product_price + # vendor_id = purchase_pricelist.vendor_id.id + # source = 'PriceList' - if not purchase_price or purchase_price <= 0: - last_po_line = self.env['purchase.order.line'].search([('product_id', '=', order_line.product_id.id), ('order_id.state', '=', 'done')], order='id desc', limit=1) - purchase_price = last_po_line.price_unit - vendor_id = last_po_line.order_id.partner_id.id - source = 'LastPO' + # if not purchase_price or purchase_price <= 0: + # last_po_line = self.env['purchase.order.line'].search([('product_id', '=', order_line.product_id.id), ('order_id.state', '=', 'done')], order='id desc', limit=1) + # purchase_price = last_po_line.price_unit + # vendor_id = last_po_line.order_id.partner_id.id + # source = 'LastPO' - if not purchase_price or purchase_price <= 0: - purchase_price = 0 - vendor_id = 5571 - source = 'Nothing' - - self.env['requisition.line'].create([{ - 'requisition_id': self.id, - 'partner_id': vendor_id, - 'brand_id': order_line.product_id.product_tmpl_id.x_manufacture.id, - 'product_id': order_line.product_id.id, - 'qty_purchase': order_line.product_uom_qty, - 'tax_id': order_line.purchase_tax_id.id, - 'price_unit': purchase_price, - 'subtotal': purchase_price * order_line.product_uom_qty, - 'source': source, - 'qty_available_store': qty_available, - 'suggest': suggest, - }]) - count+=1 - _logger.info('Create Requisition %s' % order_line.product_id.name) - self.notification = "Requisition Created %s lines" % count + # if not purchase_price or purchase_price <= 0: + # purchase_price = 0 + # vendor_id = 5571 + # source = 'Nothing' + + # self.env['requisition.line'].create([{ + # 'requisition_id': self.id, + # 'partner_id': vendor_id, + # 'brand_id': order_line.product_id.product_tmpl_id.x_manufacture.id, + # 'product_id': order_line.product_id.id, + # 'qty_purchase': order_line.product_uom_qty, + # 'tax_id': order_line.purchase_tax_id.id, + # 'price_unit': purchase_price, + # 'subtotal': purchase_price * order_line.product_uom_qty, + # 'source': source, + # 'qty_available_store': qty_available, + # 'suggest': suggest, + # }]) + # count+=1 + # _logger.info('Create Requisition %s' % order_line.product_id.name) + # self.notification = "Requisition Created %s lines" % count def create_po_from_requisition(self): if not self.requisition_lines: @@ -141,13 +143,14 @@ class Requisition(models.Model): for vendor in vendor_ids: param_header = { 'partner_id': vendor['partner_id'][0], - 'partner_ref': self.sale_order_id.name, + # 'partner_ref': self.sale_order_id.name, 'currency_id': 12, 'user_id': self.env.user.id, 'company_id': 1, # indoteknik dotcom gemilang 'picking_type_id': 28, # indoteknik bandengan receipts 'date_order': current_time, - 'sale_order_id': self.sale_order_id.id + 'sale_order_id': self.sale_order_id.id, + 'note_description': 'from Purchase Requisition' } # new_po = self.env['purchase.order'].create([param_header]) products_vendors = self.env['requisition.line'].search([ @@ -156,9 +159,9 @@ class Requisition(models.Model): ('qty_purchase', '>', 0) ], order='brand_id') count = brand_id = 0 - new_po = '' + for product in products_vendors: - if not new_po or ((count == 200 or brand_id != product.brand_id.id) and vendor['partner_id'][0] == 5571): + if count == 200 or brand_id != product.brand_id.id: count = 0 counter_po_number += 1 new_po = self.env['purchase.order'].create([param_header]) @@ -178,14 +181,16 @@ class Requisition(models.Model): if qty_available > product.qty_purchase: suggest = 'masih cukup' + tax = [22] + param_line = { 'order_id': new_po.id, 'sequence': count, 'product_id': product.product_id.id, 'product_qty': product.qty_purchase, 'product_uom_qty': product.qty_purchase, - 'price_unit': product.last_price, - 'taxes_id': product.tax_id, + 'price_unit': product.price_unit, + 'taxes_id': tax, 'qty_available_store': qty_available, 'suggest': suggest, } @@ -193,7 +198,7 @@ class Requisition(models.Model): product.current_po_id = new_po.id product.current_po_line_id = new_line.id _logger.info('Create PO Line %s' % product.product_id.name) - self.notification = self.notification + ' %s' % new_po.name + # self.notification = self.notification + ' %s' % new_po.name self.is_po = True class RequisitionLine(models.Model): @@ -221,7 +226,13 @@ class RequisitionLine(models.Model): @api.onchange('price_unit') def _onchange_price_unit(self): - self.subtotal = self.price_unit * self.qty_purchase + for line in self: + line.subtotal = line.price_unit * line.qty_purchase + + @api.onchange('product_id') + def _onchange_product(self): + for line in self: + line.brand_id = line.product_id.product_tmpl_id.x_manufacture.id class RequisitionPurchaseMatch(models.Model): _name = 'requisition.purchase.match' diff --git a/indoteknik_custom/views/requisition.xml b/indoteknik_custom/views/requisition.xml index e7335a57..e9c3b4e0 100644 --- a/indoteknik_custom/views/requisition.xml +++ b/indoteknik_custom/views/requisition.xml @@ -62,16 +62,6 @@
-