From d4913c30c804c20024584182d9b70d4c87544340 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 2 Feb 2024 14:07:12 +0700 Subject: Add role permission feature --- indoteknik_api/controllers/__init__.py | 1 + indoteknik_api/controllers/export.py | 46 ++++++++++++++++++++++ indoteknik_custom/__manifest__.py | 2 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/base_import_import.py | 9 +++-- indoteknik_custom/models/res_users.py | 17 ++++++++ .../models/role_permission/__init__.py | 1 + .../models/role_permission/ir_model_access.py | 9 +++++ .../views/role_permission/ir_model_access.xml | 16 ++++++++ .../views/role_permission/res_groups.xml | 45 +++++++++++++++++++++ 10 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 indoteknik_api/controllers/export.py create mode 100644 indoteknik_custom/models/role_permission/__init__.py create mode 100644 indoteknik_custom/models/role_permission/ir_model_access.py create mode 100644 indoteknik_custom/views/role_permission/ir_model_access.xml create mode 100644 indoteknik_custom/views/role_permission/res_groups.xml diff --git a/indoteknik_api/controllers/__init__.py b/indoteknik_api/controllers/__init__.py index 237f4135..34bba89f 100644 --- a/indoteknik_api/controllers/__init__.py +++ b/indoteknik_api/controllers/__init__.py @@ -1,4 +1,5 @@ from . import controller +from . import export from . import api_v1 from . import api_v2 from . import api_v3 \ No newline at end of file diff --git a/indoteknik_api/controllers/export.py b/indoteknik_api/controllers/export.py new file mode 100644 index 00000000..c29c82c7 --- /dev/null +++ b/indoteknik_api/controllers/export.py @@ -0,0 +1,46 @@ +import json + +from odoo.tools import pycompat +from odoo.exceptions import Warning +from odoo import http +from odoo.http import request +from odoo.addons.web.controllers.main import ExportFormat, GroupExportXlsxWriter, ExportXlsxWriter, serialize_exception, clean_action + +class Export(ExportFormat, http.Controller): + @http.route('/web/export/xlsx', type='http', auth="public", csrf=False) + @serialize_exception + def export_xlsx(self, data, token, **kw): + data_obj = json.loads(data) + model = data_obj['model'] + can_export = request.env.user.check_access(model, 'export') + + if not can_export: + raise Warning('You are not allowed to export') + + return self.base(data, token) + + @property + def content_type(self): + return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + + def filename(self, base): + return base + '.xlsx' + + def from_group_data(self, fields, groups): + with GroupExportXlsxWriter(fields, groups.count) as xlsx_writer: + x, y = 1, 0 + for group_name, group in groups.children.items(): + x, y = xlsx_writer.write_group(x, y, group_name, group) + + return xlsx_writer.value + + def from_data(self, fields, rows): + with ExportXlsxWriter(fields, len(rows)) as xlsx_writer: + for row_index, row in enumerate(rows): + for cell_index, cell_value in enumerate(row): + if isinstance(cell_value, (list, tuple)): + cell_value = pycompat.to_text(cell_value) + xlsx_writer.write_cell(row_index + 1, cell_index, cell_value) + + return xlsx_writer.value + \ No newline at end of file diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index c7e65b37..2c0a4ceb 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -107,6 +107,8 @@ 'views/purchase_order_multi_update.xml', 'views/purchase_order_multi_confirm.xml', 'views/invoice_reklas_penjualan.xml', + 'views/role_permission/ir_model_access.xml', + 'views/role_permission/res_groups.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 76387ff8..9588a835 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -98,3 +98,4 @@ from . import purchase_order_multi_update from . import invoice_reklas_penjualan from . import purchase_order_multi_confirm from . import stock_quant +from . import role_permission diff --git a/indoteknik_custom/models/base_import_import.py b/indoteknik_custom/models/base_import_import.py index 6a100cb8..01e02a4a 100644 --- a/indoteknik_custom/models/base_import_import.py +++ b/indoteknik_custom/models/base_import_import.py @@ -56,7 +56,10 @@ class Import(models.TransientModel): raise UserError(message) def do(self, fields, columns, options, dryrun=False): - enable_import = self._check_enable_import() - if not enable_import: - self._unable_import_notif() + model = self.res_model + can_import = self.env.user.check_access(model, 'import') + + if not can_import: + raise UserError('You are not allowed to import') + return super(Import, self).do(fields, columns, options, dryrun) diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 09321fc6..33f64ce3 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -39,3 +39,20 @@ class ResUsers(models.Model): if not vouchers: return None return ', '.join(x.code for x in vouchers) return None + + def check_access(self, model, mode): + assert mode in ('read', 'write', 'create', 'unlink', 'import', 'export'), 'Invalid access mode' + + self._cr.execute(""" + SELECT MAX(CASE WHEN perm_{mode} THEN 1 ELSE 0 END) + FROM ir_model_access a + JOIN ir_model m ON (m.id = a.model_id) + JOIN res_groups_users_rel gu ON (gu.gid = a.group_id) + WHERE m.model = %s + AND gu.uid = %s + AND a.active IS TRUE + """.format(mode=mode), (model, self._uid,)) + r = self._cr.fetchone()[0] + + return bool(r) + diff --git a/indoteknik_custom/models/role_permission/__init__.py b/indoteknik_custom/models/role_permission/__init__.py new file mode 100644 index 00000000..da36bc1e --- /dev/null +++ b/indoteknik_custom/models/role_permission/__init__.py @@ -0,0 +1 @@ +from . import ir_model_access \ No newline at end of file diff --git a/indoteknik_custom/models/role_permission/ir_model_access.py b/indoteknik_custom/models/role_permission/ir_model_access.py new file mode 100644 index 00000000..c77e9b79 --- /dev/null +++ b/indoteknik_custom/models/role_permission/ir_model_access.py @@ -0,0 +1,9 @@ +from odoo import fields, models + + +class IrModelAccess(models.Model): + _inherit = 'ir.model.access' + + perm_import = fields.Boolean(string='Import Access') + perm_export = fields.Boolean(string='Export Access') + \ No newline at end of file diff --git a/indoteknik_custom/views/role_permission/ir_model_access.xml b/indoteknik_custom/views/role_permission/ir_model_access.xml new file mode 100644 index 00000000..0c74d5e2 --- /dev/null +++ b/indoteknik_custom/views/role_permission/ir_model_access.xml @@ -0,0 +1,16 @@ + + + + + Access Rights + ir.model.access + + + + + + + + + + diff --git a/indoteknik_custom/views/role_permission/res_groups.xml b/indoteknik_custom/views/role_permission/res_groups.xml new file mode 100644 index 00000000..ad6af732 --- /dev/null +++ b/indoteknik_custom/views/role_permission/res_groups.xml @@ -0,0 +1,45 @@ + + + + + Roles + 70 + + + + + IT + + + + + Accounting + + + + + Finance + + + + + Sales + + + + + Marketing + + + + + Purchasing + + + + + Logistic + + + + \ No newline at end of file -- cgit v1.2.3 From 953c3e611af5c57a8f7d57b5f2f651314c2a92a3 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 7 Feb 2024 13:53:16 +0700 Subject: Revert image api style --- indoteknik_api/controllers/controller.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py index 50e86b68..fe0f1203 100644 --- a/indoteknik_api/controllers/controller.py +++ b/indoteknik_api/controllers/controller.py @@ -210,7 +210,12 @@ class Controller(http.Controller): def add_watermark_to_image(self, image, ratio, version = '1'): if not image: return '' - logo_path = get_module_resource('indoteknik_api', 'static', 'src', 'images', 'logo-indoteknik-gray.png') + LOGO_FILENAME = { + '1': 'logo-indoteknik-gray.png', + '2': 'logo-indoteknik.png' + } + + logo_path = get_module_resource('indoteknik_api', 'static', 'src', 'images', LOGO_FILENAME.get(version)) logo_img = Image.open(logo_path).convert('RGBA') img_data = io.BytesIO(base64.b64decode(image)) @@ -238,13 +243,15 @@ class Controller(http.Controller): logo_footer_img = Image.open(logo__footer_path).convert('RGBA') logo_footer_img.thumbnail((img_width, img_height // 1)) logo_footer_w, logo_footer_h = logo_footer_img.size - new_img.paste(logo_footer_img, (0, img_height - logo_footer_h - 20), logo_footer_img) + new_img.paste(logo_footer_img, (0, img_height - logo_footer_h), logo_footer_img) + + logo_img_w = img_width // 1.8 + logo_img_h = img_height // 1.8 logo_img.thumbnail((logo_img_w, logo_img_h)) - if version == '1': - # Add watermark - new_img.paste(logo_img, (12, 10), logo_img) + # Add watermark + new_img.paste(logo_img, (12, 10), logo_img) buffered = io.BytesIO() new_img.save(buffered, format="PNG") -- cgit v1.2.3 From 20b1410fc2335f51ab08fdbecb54d6bfc437b6e1 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 7 Feb 2024 14:40:28 +0700 Subject: Update role FAT and add merchandiser --- indoteknik_custom/views/role_permission/res_groups.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/indoteknik_custom/views/role_permission/res_groups.xml b/indoteknik_custom/views/role_permission/res_groups.xml index ad6af732..910469fd 100644 --- a/indoteknik_custom/views/role_permission/res_groups.xml +++ b/indoteknik_custom/views/role_permission/res_groups.xml @@ -11,14 +11,9 @@ IT - - - Accounting - - - - Finance + + FAT @@ -41,5 +36,10 @@ Logistic + + + Merchandiser + + \ No newline at end of file -- cgit v1.2.3 From 1418dbbb581228383df151f1f8df6fc48a0fb9cc Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 9 Feb 2024 13:49:36 +0700 Subject: change request logbook sj --- indoteknik_custom/models/logbook_sj.py | 45 ++++++++++++------------ indoteknik_custom/models/report_logbook_sj.py | 50 +++++++++++++++++++++------ indoteknik_custom/views/ir_sequence.xml | 10 ++++++ indoteknik_custom/views/report_logbook_sj.xml | 28 +++++++++------ 4 files changed, 89 insertions(+), 44 deletions(-) diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py index 567f1ae3..bf4acd14 100644 --- a/indoteknik_custom/models/logbook_sj.py +++ b/indoteknik_custom/models/logbook_sj.py @@ -18,31 +18,27 @@ class LogbookSJ(models.TransientModel): current_time = datetime.utcnow() report_logbook_ids = [] + parameters_header = { + 'date': current_time, + } + + report_logbook = self.env['report.logbook.sj'].create([parameters_header]) for line in logbook_line: - nomor_sj = line.name - picking = self.env['stock.picking'].search([ - ('picking_code', '=', nomor_sj), - ]) - parameters_header = { - 'name': nomor_sj, - 'date': current_time, - 'name_picking': picking.name, - 'partner_id': picking.partner_id.id, + picking = self.env['stock.picking'].search([('picking_code', '=', line.name)], limit=1) + stock = picking + + data = { + 'picking_id': stock.id, + 'name': stock.name, + 'driver_id': stock.driver_id.id, + 'departure_date': stock.driver_departure_date, + 'arrival_date': stock.driver_arrival_date, + 'carrier_id': stock.carrier_id.id, + 'tracking_no': stock.delivery_tracking_no, + 'partner_id': stock.partner_id.id, + 'report_logbook_sj_id': report_logbook.id } - - report_logbook = self.env['report.logbook.sj'].create([parameters_header]) - - - for stock in picking.move_line_ids_without_package: - data = { - 'product_id': stock.product_id.id, - 'location_id': stock.location_id.id, - 'product_uom_qty': stock.product_uom_qty, - 'qty_done': stock.qty_done, - 'product_uom_id': stock.product_uom_id.id, - 'report_logbook_sj_id': report_logbook.id - } - self.env['report.logbook.sj.line'].create([data]) + self.env['report.logbook.sj.line'].create([data]) report_logbook_ids.append(report_logbook.id) line.unlink() @@ -68,6 +64,7 @@ class LogbookSJLine(models.TransientModel): tracking_no = fields.Char(string='Tracking No') logbook_sj_id = fields.Many2one('logbook.sj', string='Logbook SJ') partner_id = fields.Many2one('res.partner', string='Customer') + picking_id = fields.Many2one('res.partner', string='Customer') @api.onchange('name') def onchange_name(self): @@ -94,6 +91,8 @@ class LogbookSJLine(models.TransientModel): self.partner_id = picking.partner_id + self.picking_id = picking.id + delivery_type = self.get_delivery_type(picking.driver_departure_date, picking.driver_arrival_date) if delivery_type != 'departure': self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py index d2008608..5ff56c9a 100644 --- a/indoteknik_custom/models/report_logbook_sj.py +++ b/indoteknik_custom/models/report_logbook_sj.py @@ -6,29 +6,59 @@ from datetime import datetime class ReportLogbookSJ(models.Model): _name = 'report.logbook.sj' - name = fields.Char(string='Nomor SJ', default='Logbook SJ') - date = fields.Datetime(string='Date') - name_picking = fields.Char(string='Picking Name') - partner_id = fields.Many2one('res.partner', string='Customer') + name = fields.Char(string='Name', default='Logbook SJ') + date = fields.Datetime(string='Date Created') + date_approve = fields.Datetime(string='Date Approve') approve_by_finance = fields.Boolean(string='Approve By Finance') + approve_by = fields.Many2one(comodel_name='res.users', string='Approve By') report_logbook_sj_line = fields.One2many( comodel_name='report.logbook.sj.line', inverse_name='report_logbook_sj_id', string='Logbook SJ Line' ) + state = fields.Selection( + [('belum_terima', 'Belum Terima'), + ('terima_sebagian', 'Terima Sebagian'), + ('terima_semua', 'Sudah di terima semua'), + ], + default='terima_semua', + string='Status', + tracking=True + ) + + @api.model + def create(self, vals): + vals['name'] = self.env['ir.sequence'].next_by_code('report.logbook.sj') or '0' + result = super(ReportLogbookSJ, self).create(vals) + return result def approve(self): + current_time = datetime.utcnow() if self.env.user.is_accounting: self.approve_by_finance = True + self.date_approve = current_time + self.approve_by = self.env.user.id + if any(line.not_exist for line in self.report_logbook_sj_line): + if all(line.not_exist for line in self.report_logbook_sj_line): + self.state = 'belum_terima' + else: + self.state = 'terima_sebagian' + else: + self.state = 'terima_semua' else: raise UserError('Hanya Accounting yang bisa Approve') class ReportLogbookSJLine(models.Model): _name = 'report.logbook.sj.line' - product_id = fields.Many2one(comodel_name='product.product', string='Product') - location_id = fields.Many2one(comodel_name='stock.location', string='From') - product_uom_qty = fields.Float(string='Reserved') - qty_done = fields.Float(string='Done') - product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure') - report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ') \ No newline at end of file + name = fields.Char(string='SJ Number') + driver_id = fields.Many2one(comodel_name='res.users', string='Driver') + departure_date = fields.Char(string='Departure Date') + arrival_date = fields.Char(string='Arrival Date') + carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method') + tracking_no = fields.Char(string='Tracking No') + logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ') # Corrected model name + partner_id = fields.Many2one('res.partner', string='Customer') + picking_id = fields.Many2one('stock.picking', string='Picking') + report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ') + not_exist = fields.Boolean(string='Not Exist') diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index 86259b12..56921839 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -10,6 +10,16 @@ 1 1 + + + Logbook SJ + report.logbook.sj + TRUE + LSJ/%(year)s/ + 5 + 1 + 1 + Stock Picking Code diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml index 52e00d17..ea58aefd 100644 --- a/indoteknik_custom/views/report_logbook_sj.xml +++ b/indoteknik_custom/views/report_logbook_sj.xml @@ -6,10 +6,11 @@ + - + - + @@ -18,12 +19,16 @@ report.logbook.sj.line.tree report.logbook.sj.line - - - - - - + + + + + + + + + + @@ -35,7 +40,7 @@
@@ -45,11 +50,12 @@ + - - + + -- cgit v1.2.3 From ba871e1ff11e160823e3c816c707b642eedea200 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 9 Feb 2024 14:58:28 +0700 Subject: Fix check duplicate product function --- indoteknik_custom/models/product_template.py | 67 ++++++++-------------------- 1 file changed, 18 insertions(+), 49 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 30d89356..ba8fac55 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -74,34 +74,27 @@ class ProductTemplate(models.Model): @api.constrains('name', 'default_code') def _check_duplicate_product(self): for product in self: - if self.env.user.is_purchasing_manager or self.env.user.is_editor_product or self.env.user.id in [1, 25]: - continue - - domain = [('default_code', '!=', False)] + variants = product.product_variant_ids + names = [x.name for x in variants] if variants else [product.name] + default_codes = [x.default_code for x in variants] if variants else [product.default_code] - if product.product_variant_ids: - domain.extend([ - '|', - ('name', 'in', [variants.name for variants in product.product_variant_ids]), - ('default_code', 'in', [variants.default_code for variants in product.product_variant_ids]) - ]) - else: - domain.extend([ - '|', - ('name', 'in', [product.name]), - ('default_code', 'in', [product.default_code]) - ]) + domain = [ + ('default_code', '!=', False), + ('id', '!=', product.id), + '|', + ('name', 'in', names), + ('default_code', 'in', default_codes) + ] + + product_exist = self.search(domain, limit=1) + if len(product_exist) > 0: + raise UserError('Name atau Internal Reference sudah digunakan pada produk lain') - domain.append(('id', '!=', product.id)) + if self.env.user.is_purchasing_manager or self.env.user.is_editor_product or self.env.user.id in [1, 25]: + continue - if product.write_date == product.create_date: - message = "SKU atau Name yang Anda gunakan sudah digunakan di produk lain" - elif all(day_product > 0 for day_product in product.day_product_to_edit()): - domain = [('id', '=', product.id)] - message = "Anda tidak berhak merubah data produk ini" - existing_purchase = self.search(domain, limit=1) - if existing_purchase: - raise UserError(message) + if sum(product.day_product_to_edit()) > 0: + raise UserError('Produk ini tidak dapat diubah') @api.constrains('name') def _validate_name(self): @@ -377,30 +370,6 @@ class ProductProduct(models.Model): day_products.append(day_product) return day_products - - @api.constrains('name','default_code') - def _check_duplicate_product(self): - for product in self: - if self.env.user.is_purchasing_manager or self.env.user.is_editor_product or self.env.user.id in [1, 25]: - continue - - if product.write_date == product.create_date: - domain = [ - ('default_code', '!=', False), - '|', - ('name', 'in', [template.name for template in product.product_tmpl_id] or [product.name]), - ('default_code', 'in', [template.default_code for template in product.product_tmpl_id] or [product.default_code])] - - domain.append(('id', '!=', product.id)) - massage="SKU atau Name yang anda pakai sudah digunakan di product lain" - existing_purchase = self.search(domain, limit=1) - if existing_purchase: - raise UserError(massage) - elif all(day_product > 0 for day_product in product.day_product_to_edit()): - domain = [('id', '=', product.id)] - existing_purchase = self.search(domain) - if existing_purchase: - raise UserError('Anda tidak berhak merubah data product ini') @api.constrains('name') def _validate_name(self): -- cgit v1.2.3 From 4e54d00cf34d262ffa477d8267fb33682c98e649 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 9 Feb 2024 15:52:03 +0700 Subject: Fix product variant image --- indoteknik_custom/models/solr/product_product.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index ac41dbff..5a74df8c 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -49,12 +49,6 @@ class ProductProduct(models.Model): document = solr_model.get_doc('variants', variant.id) - image = '' - if variant.image_256: - image = ir_attachment.api_image('product.product', 'image_256', variant.id) - else: - image = ir_attachment.api_image('product.template', 'image_256', variant.product_tmpl_id.id) - document.update({ 'id': variant.id, 'display_name_s': variant.display_name, @@ -63,7 +57,7 @@ class ProductProduct(models.Model): 'product_rating_f': variant.product_tmpl_id.virtual_rating, 'product_id_i': variant.id, 'template_id_i': variant.product_tmpl_id.id, - "image_s": image, + 'image_s': ir_attachment.api_image('product.template', 'image_256', variant.product_tmpl_id.id), 'stock_total_f': variant.qty_stock_vendor, 'weight_f': variant.product_tmpl_id.weight, 'manufacture_id_i': variant.product_tmpl_id.x_manufacture.id or 0, -- cgit v1.2.3 From f300408a52eab119568a331c46c1288f18bd7c8e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 12 Feb 2024 10:48:37 +0700 Subject: bug fix flashsale price, forgot to divide tax --- indoteknik_api/models/product_product.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 1db58d8e..4400ad08 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -278,11 +278,14 @@ class ProductProduct(models.Model): discount = 0 price_flashsale = 0 + default_divide_tax = float(1.11) if item.price_discount > 0: discount = item.price_discount price_flashsale = base_price - (base_price * discount // 100) + price_flashsale = price_flashsale / default_divide_tax elif item.fixed_price > 0: price_flashsale = item.fixed_price # ask darren for include or exclude + # price_flashsale = price_flashsale / default_divide_tax # darren must fill the fixed price with price exclude discount = (base_price - price_flashsale) // base_price * 100 if price_for == 'odoo': -- cgit v1.2.3 From 0060d2789962593280e91d8ea4251a7c18d6115c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 12 Feb 2024 11:14:02 +0700 Subject: bug fix tax in flashsale price if using fixed price --- indoteknik_api/models/product_product.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 4400ad08..bd6f516d 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -279,14 +279,17 @@ class ProductProduct(models.Model): discount = 0 price_flashsale = 0 default_divide_tax = float(1.11) + default_tax = float(11) if item.price_discount > 0: discount = item.price_discount price_flashsale = base_price - (base_price * discount // 100) price_flashsale = price_flashsale / default_divide_tax elif item.fixed_price > 0: price_flashsale = item.fixed_price # ask darren for include or exclude - # price_flashsale = price_flashsale / default_divide_tax # darren must fill the fixed price with price exclude + price_flashsale = price_flashsale + (price_flashsale * default_tax / 100) discount = (base_price - price_flashsale) // base_price * 100 + price_flashsale = item.fixed_price + # price_flashsale = price_flashsale / default_divide_tax # darren must fill the fixed price with price exclude if price_for == 'odoo': base_price = self._v2_get_website_price_exclude_tax() -- cgit v1.2.3 From fb5ef1ffd3a52997044a4bcd1f6bef8cc70861ff Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 12 Feb 2024 16:37:46 +0700 Subject: bug fix discount zero in flash sale --- indoteknik_api/models/product_product.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index bd6f516d..3ecad627 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -287,7 +287,8 @@ class ProductProduct(models.Model): elif item.fixed_price > 0: price_flashsale = item.fixed_price # ask darren for include or exclude price_flashsale = price_flashsale + (price_flashsale * default_tax / 100) - discount = (base_price - price_flashsale) // base_price * 100 + discount = (base_price - price_flashsale) * 100 / base_price + discount = (math.ceil(discount*100)/100) price_flashsale = item.fixed_price # price_flashsale = price_flashsale / default_divide_tax # darren must fill the fixed price with price exclude -- cgit v1.2.3 From 65e92d876e08fb4dd1ade57e88025bcda7d2b901 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 15 Feb 2024 13:39:18 +0700 Subject: mandatory purchase_tax_id --- indoteknik_custom/views/sale_order.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 696cedc4..a8357573 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -97,7 +97,7 @@ ] } "/> - + -- cgit v1.2.3 From 1a669bcdcf31dfa7f394450eb2afa27d20ab3d89 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 15 Feb 2024 13:54:19 +0700 Subject: mandatory tax_Id --- indoteknik_custom/views/sale_order.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index a8357573..4c4ac281 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -97,7 +97,7 @@ ] } "/> - + @@ -114,6 +114,9 @@ {'no_create': True} + + 1 +