From a9abc6b63f1bafb1e007da4446636ec2da10d493 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 18 Feb 2025 13:19:43 +0700 Subject: back to original before CR customer commision --- indoteknik_custom/models/commision.py | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 3f035e2f..48f1c7f6 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -153,10 +153,6 @@ class CustomerCommision(models.Model): bank_account = fields.Char(string='Account No', tracking=3) note_transfer = fields.Char(string='Keterangan') brand_ids = fields.Many2many('x_manufactures', string='Brands') - payment_status = fields.Selection([ - ('pending', 'Pending'), - ('payment', 'Payment'), - ], string='Payment Status', copy=False, readonly=True, tracking=3, default='pending') # add status for type of commision, fee, rebate / cashback # include child or not? @@ -232,15 +228,6 @@ class CustomerCommision(models.Model): raise UserError('Harus di approved oleh yang bersangkutan') return - def action_confirm_customer_payment(self): - group_id = self.env.ref('indoteknik_custom.group_role_fat').id - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - if self.env.user.id not in users_in_group.mapped('id'): - raise UserError('Hanya bisa dikonfirmasi oleh FAT') - else: - self.payment_status = 'payment' - return - def generate_customer_commision(self): if self.commision_lines: raise UserError('Line sudah ada, tidak bisa di generate ulang') -- cgit v1.2.3 From 10c0cd096353397ce26ad13b6967a35d13072fb6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:39:25 +0700 Subject: label in move line same with ref in entries --- indoteknik_custom/models/account_move_line.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 37f7c77c..31950f4c 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -23,3 +23,11 @@ class AccountMoveLine(models.Model): else: account.is_required = False + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'move_id' in vals: + move = self.env['account.move'].browse(vals['move_id']) + if move.move_type == 'entry': + vals['name'] = move.ref + return super().create(vals_list) \ No newline at end of file -- cgit v1.2.3 From 45f6f270ae76b5e2d811f4ef04e9b64ba5b7f143 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:41:06 +0700 Subject: fix error --- indoteknik_custom/models/account_move_line.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 31950f4c..6b394da3 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -24,10 +24,10 @@ class AccountMoveLine(models.Model): account.is_required = False @api.model_create_multi - def create(self, vals_list): - for vals in vals_list: - if 'move_id' in vals: - move = self.env['account.move'].browse(vals['move_id']) - if move.move_type == 'entry': - vals['name'] = move.ref - return super().create(vals_list) \ No newline at end of file + def create(self, vals_list): + for vals in vals_list: + if 'move_id' in vals: + move = self.env['account.move'].browse(vals['move_id']) + if move.move_type == 'entry': + vals['name'] = move.ref + return super().create(vals_list) \ No newline at end of file -- cgit v1.2.3 From bf61388fb16a59dcf954cd288c830f00c62efee5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:42:12 +0700 Subject: fix error --- indoteknik_custom/models/account_move_line.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 6b394da3..a4386157 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -21,13 +21,4 @@ class AccountMoveLine(models.Model): if account.account_id.code and account.account_id.code[0] in ['6', '7']: account.is_required = True else: - account.is_required = False - - @api.model_create_multi - def create(self, vals_list): - for vals in vals_list: - if 'move_id' in vals: - move = self.env['account.move'].browse(vals['move_id']) - if move.move_type == 'entry': - vals['name'] = move.ref - return super().create(vals_list) \ No newline at end of file + account.is_required = False \ No newline at end of file -- cgit v1.2.3 From 62636c80dcc2078eed18810e7958f41fd5b13fdc Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:42:39 +0700 Subject: fix error --- indoteknik_custom/models/account_move_line.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index a4386157..6b394da3 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -21,4 +21,13 @@ class AccountMoveLine(models.Model): if account.account_id.code and account.account_id.code[0] in ['6', '7']: account.is_required = True else: - account.is_required = False \ No newline at end of file + account.is_required = False + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'move_id' in vals: + move = self.env['account.move'].browse(vals['move_id']) + if move.move_type == 'entry': + vals['name'] = move.ref + return super().create(vals_list) \ No newline at end of file -- cgit v1.2.3 From 66901cd03a1494e6c84893e14083dcd1fbe737a5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 14:01:44 +0700 Subject: fix bug account move --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/account_move.py | 3 +- indoteknik_custom/models/account_move_line.py | 2 +- .../models/account_payment_register.py | 48 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/models/account_payment_register.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index ddbe16f1..dea3eeea 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -142,3 +142,4 @@ from . import stock_immediate_transfer from . import coretax_fatur from . import ir_actions_report from . import barcoding_product +from . import account_payment_register diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 7760c69d..b2ac47c2 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -64,6 +64,7 @@ class AccountMove(models.Model): nomor_kwitansi = fields.Char(string="Nomor Kwitansi") other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal') other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes') + is_hr = fields.Boolean(string="Is HR?", default=False) def _update_line_name_from_ref(self): """Update all account.move.line name fields with ref from account.move""" @@ -114,7 +115,7 @@ class AccountMove(models.Model): def create(self, vals): vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' result = super(AccountMove, self).create(vals) - result._update_line_name_from_ref() + # result._update_line_name_from_ref() return result def compute_so_shipping_paid_by(self): diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 6b394da3..7c95d4ef 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -28,6 +28,6 @@ class AccountMoveLine(models.Model): for vals in vals_list: if 'move_id' in vals: move = self.env['account.move'].browse(vals['move_id']) - if move.move_type == 'entry': + if move.move_type == 'entry' and move.is_hr == True: vals['name'] = move.ref return super().create(vals_list) \ No newline at end of file diff --git a/indoteknik_custom/models/account_payment_register.py b/indoteknik_custom/models/account_payment_register.py new file mode 100644 index 00000000..4ebb7e4e --- /dev/null +++ b/indoteknik_custom/models/account_payment_register.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + + +class AccountPaymentRegister(models.TransientModel): + _inherit = 'account.payment.register' + def _create_payment_vals_from_wizard(self): + payment_vals = { + 'date': self.payment_date, + 'amount': self.amount, + 'payment_type': self.payment_type, + 'partner_type': self.partner_type, + 'ref': self.communication, + 'journal_id': self.journal_id.id, + 'is_hr': True, + 'currency_id': self.currency_id.id, + 'partner_id': self.partner_id.id, + 'partner_bank_id': self.partner_bank_id.id, + 'payment_method_id': self.payment_method_id.id, + 'destination_account_id': self.line_ids[0].account_id.id + } + + if not self.currency_id.is_zero(self.payment_difference) and self.payment_difference_handling == 'reconcile': + payment_vals['write_off_line_vals'] = { + 'name': self.writeoff_label, + 'amount': self.payment_difference, + 'account_id': self.writeoff_account_id.id, + } + return payment_vals + + def _create_payment_vals_from_batch(self, batch_result): + batch_values = self._get_wizard_values_from_batch(batch_result) + return { + 'date': self.payment_date, + 'amount': batch_values['source_amount_currency'], + 'payment_type': batch_values['payment_type'], + 'partner_type': batch_values['partner_type'], + 'ref': self._get_batch_communication(batch_result), + 'journal_id': self.journal_id.id, + 'is_hr': True, + 'currency_id': batch_values['source_currency_id'], + 'partner_id': batch_values['partner_id'], + 'partner_bank_id': batch_result['key_values']['partner_bank_id'], + 'payment_method_id': self.payment_method_id.id, + 'destination_account_id': batch_result['lines'][0].account_id.id + } -- cgit v1.2.3 From 38f8ddd9aaaad58c8d7ea27235cd109ba288693d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 19 Feb 2025 15:02:35 +0700 Subject: change logic solr is_in_bu from available to qty_free_bandengan --- indoteknik_custom/models/solr/product_template.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 87e8370f..8afff6e3 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -76,8 +76,11 @@ class ProductTemplate(models.Model): ('product_id', 'in', template.product_variant_ids.ids), ('location_id', 'in', target_locations), ]) - - is_in_bu = any(quant.available_quantity > 0 for quant in stock_quant) + is_in_bu = False + for quant in stock_quant: + if quant.product_id.qty_free_bandengan > 0: + is_in_bu = True + break cleaned_desc = BeautifulSoup(template.website_description or '', "html.parser").get_text() website_description = template.website_description if cleaned_desc else '' -- cgit v1.2.3 From 7c1c4def22a72b9a6f6806d70a865594ae14386c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 20 Feb 2025 16:20:25 +0700 Subject: add CR voucher type account --- indoteknik_custom/models/res_users.py | 7 +++++++ indoteknik_custom/models/voucher.py | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 31b84ae3..63942bb5 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -71,6 +71,13 @@ class ResUsers(models.Model): if not vouchers: return None return ', '.join(x.code for x in vouchers) return None + + def get_voucher_code_switch_account(self, type): + if type == 'switch_account': + vouchers = self.env['voucher'].get_active_voucher([('account_type', 'in', ['all','company'])]) + 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' diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 37c97338..101d4bcf 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -59,7 +59,11 @@ class Voucher(models.Model): show_on_email = fields.Selection([ ('user_activation', 'User Activation') ], 'Show on Email') - + account_type = fields.Selection(string='Account Type', default="all", selection=[ + ('all', "All Account"), + ('person', "Account Individu"), + ('company', "Account Company"), + ]) @api.constrains('description') def _check_description_length(self): for record in self: -- cgit v1.2.3 From 093bd33ba36ba123a53853e7407e534f9f23734b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 21 Feb 2025 10:21:34 +0700 Subject: add voucher info in email approve switch account --- indoteknik_custom/models/res_users.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 63942bb5..b0864f2c 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -70,11 +70,8 @@ class ResUsers(models.Model): vouchers = self.env['voucher'].get_active_voucher([('show_on_email', '=', 'user_activation')]) if not vouchers: return None return ', '.join(x.code for x in vouchers) - return None - - def get_voucher_code_switch_account(self, type): if type == 'switch_account': - vouchers = self.env['voucher'].get_active_voucher([('account_type', 'in', ['all','company'])]) + vouchers = self.env['voucher'].get_active_voucher([('excl_pricelist_ids', 'not in', [1]), ('apply_type', 'in', ['all', 'brand']), ('account_type', 'in', ['all', 'company']), ('visibility', 'in', ['public'])]) if not vouchers: return None return ', '.join(x.code for x in vouchers) return None -- cgit v1.2.3 From 8696e202ecf594890a9ad29bc2bd2729321459c5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 24 Feb 2025 14:58:11 +0700 Subject: add copy to field state_reserve and date_reserved --- indoteknik_custom/models/stock_picking.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 49e66786..954a5d52 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -94,7 +94,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") 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') + date_reserved = fields.Datetime(string="Date Reserved", help='Tanggal ter-reserved semua barang nya', copy=False) status_printed = fields.Selection([ ('not_printed', 'Belum Print'), ('printed', 'Printed') @@ -120,7 +120,7 @@ class StockPicking(models.Model): ('ready', 'Ready to Ship'), ('done', 'Done'), ('cancel', 'Cancelled'), - ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.") + ], string='Status Reserve', readonly=True, tracking=True, copy=False, help="The current state of the stock picking.") notee = fields.Text(string="Note") @api.model -- cgit v1.2.3 From b20368190fbf08b87d8a665c4b316786e3d73141 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 24 Feb 2025 15:36:22 +0700 Subject: state reserve --- indoteknik_custom/models/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 954a5d52..36d9f63d 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -120,7 +120,7 @@ class StockPicking(models.Model): ('ready', 'Ready to Ship'), ('done', 'Done'), ('cancel', 'Cancelled'), - ], string='Status Reserve', readonly=True, tracking=True, copy=False, help="The current state of the stock picking.") + ], string='Status Reserve', tracking=True, copy=False, help="The current state of the stock picking.") notee = fields.Text(string="Note") @api.model -- cgit v1.2.3 From 63c712cd38666723a112899d49af3ee82af9bf89 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 24 Feb 2025 16:04:59 +0700 Subject: adjusment number --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/stock_inventory.py | 59 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 indoteknik_custom/models/stock_inventory.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index dea3eeea..f33a7411 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -143,3 +143,4 @@ from . import coretax_fatur from . import ir_actions_report from . import barcoding_product from . import account_payment_register +from . import stock_inventory diff --git a/indoteknik_custom/models/stock_inventory.py b/indoteknik_custom/models/stock_inventory.py new file mode 100644 index 00000000..12a891de --- /dev/null +++ b/indoteknik_custom/models/stock_inventory.py @@ -0,0 +1,59 @@ +from odoo import models, api, fields +from odoo.exceptions import UserError +from datetime import datetime +import logging + +_logger = logging.getLogger(__name__) + + +class StockInventory(models.Model): + _inherit = ['stock.inventory'] + _order = 'id desc' + _rec_name = 'number' + + number = fields.Char(string='Document No', index=True, copy=False, readonly=True) + adjusment_type = fields.Selection([ + ('in', 'Adjusment In'), + ('out', 'Adjusment Out'), + ], string='Adjusments Type', required=True) + + def _generate_number_stock_inventory(self): + """Men-generate nomor untuk semua stock inventory yang belum memiliki number.""" + stock_records = self.env['stock.inventory'].search([('number', '=', False)], order='id asc') + for record in stock_records: + self._assign_number(record) + + _logger.info('Generate Number Done') + + def _assign_number(self, record): + """Menentukan nomor berdasarkan kategori Adjust-In atau Adjust-Out.""" + name_upper = record.name.upper() if record.name else "" + + if self.adjusment_type == 'out' or "ADJUST OUT" in name_upper or "ADJUST-OUT" in name_upper or "OUT" in name_upper: + last_number = self._get_last_sequence("ADJUST/OUT/") + record.number = f"ADJUST/OUT/{last_number}" + elif self.adjusment_type == 'in' or "ADJUST IN" in name_upper or "ADJUST-IN" in name_upper or "IN" in name_upper: + last_number = self._get_last_sequence("ADJUST/IN/") + record.number = f"ADJUST/IN/{last_number}" + else: + record.number = "UNKNOWN" # Jika tidak termasuk kategori + + def _get_last_sequence(self, prefix): + """Mengambil nomor terakhir berdasarkan prefix (ADJUST/OUT/ atau ADJUST/IN/) dengan format 00001, 00002, dst.""" + last_record = self.env['stock.inventory'].search( + [("number", "like", f"{prefix}%")], order="number desc", limit=1 + ) + + if last_record and last_record.number: + try: + last_number = int(last_record.number.split("/")[-1]) # Ambil angka terakhir + return str(last_number + 1).zfill(5) # Format jadi 00001, 00002, dst. + except ValueError: + return "00001" # Jika format tidak valid, mulai dari 00001 + return "00001" # Jika belum ada data, mulai dari 00001 + + @api.model + def create(self, vals): + order = super(StockInventory, self).create(vals) + self._assign_number(order) + return order -- cgit v1.2.3 From 6352ba63a39293b3e260bd7bd933c9de2c023172 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 10:47:35 +0700 Subject: add purchase price po and so on po sales matches --- indoteknik_custom/models/purchase_order_sales_match.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index d1d929d3..d6c2a631 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -24,6 +24,13 @@ class PurchaseOrderSalesMatch(models.Model): margin_item = fields.Float(string='Margin') delivery_amt = fields.Float(string='Delivery Amount', compute='_compute_delivery_amt') margin_deduct = fields.Float(string='After Deduct', compute='_compute_delivery_amt') + purchase_price_so = fields.Float(string='Purchase Price Sale Order', related='sale_line_id.purchase_price') + purchase_price_po = fields.Float('Purchase Price PO', compute='_compute_purchase_price_po') + + def _compute_purchase_price_po(self): + for line in self: + purchase_price = self.env['purchase.order.line'].search([('order_id', '=', line.purchase_order_id.id), ('product_id', '=', line.product_id.id)]) + line.purchase_price_po = purchase_price.purchase_price def _compute_delivery_amt(self): for line in self: -- cgit v1.2.3 From f7a149c71824ba40f9e585d1df287b36853b7213 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 10:49:49 +0700 Subject: fix bug --- indoteknik_custom/models/purchase_order_sales_match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index d6c2a631..4ebe959b 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -30,7 +30,7 @@ class PurchaseOrderSalesMatch(models.Model): def _compute_purchase_price_po(self): for line in self: purchase_price = self.env['purchase.order.line'].search([('order_id', '=', line.purchase_order_id.id), ('product_id', '=', line.product_id.id)]) - line.purchase_price_po = purchase_price.purchase_price + line.purchase_price_po = purchase_price.price_unit def _compute_delivery_amt(self): for line in self: -- cgit v1.2.3 From 787aa90ca730936c93e0afb250285ebc8708ad3a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 25 Feb 2025 11:17:36 +0700 Subject: cr approved margin SO --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 430b4526..e23f39bc 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1122,7 +1122,7 @@ class SaleOrder(models.Model): return self.total_percent_margin < 15 and not self.env.user.is_leader def _requires_approval_margin_manager(self): - return self.total_percent_margin <= 20 and not self.env.user.is_leader and not self.env.user.is_sales_manager + return self.total_percent_margin >= 15 and not self.env.user.is_leader and not self.env.user.is_sales_manager def _create_approval_notification(self, approval_role): title = 'Warning' -- cgit v1.2.3 From 5fc94808e034dac8efeff3367b665dbd6b4f3df2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:26:52 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 70 ++++++++++-------------------- 1 file changed, 24 insertions(+), 46 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 54d771ba..83f86e8e 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -943,63 +943,41 @@ class PurchaseOrder(models.Model): def compute_total_margin_from_apo(self): sum_so_margin = sum_sales_price = sum_margin = 0 - for line in self.order_sales_match_line: - po_line = self.env['purchase.order.line'].search([ - ('product_id', '=', line.product_id.id), - ('order_id', '=', line.purchase_order_id.id) - ], limit=1) - sale_order_line = line.sale_line_id + for line in self.order_line: + sale_order_line = line.so_line_id if not sale_order_line: sale_order_line = self.env['sale.order.line'].search([ ('product_id', '=', line.product_id.id), - ('order_id', '=', line.sale_id.id) + ('order_id', '=', line.so_id.id) ], limit=1, order='price_reduce_taxexcl') - if sale_order_line and po_line: - so_margin = (line.qty_po / line.qty_so) * sale_order_line.item_margin - sum_so_margin += so_margin - - sales_price = sale_order_line.price_reduce_taxexcl * line.qty_po - if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= (sale_order_line.delivery_amt_line / sale_order_line.product_uom_qty) * line.qty_po - if sale_order_line.order_id.fee_third_party > 0: - sales_price -= (sale_order_line.fee_third_party_line / sale_order_line.product_uom_qty) * line.qty_po - sum_sales_price += sales_price - - - purchase_price = po_line.price_subtotal - if po_line.ending_price > 0: - if po_line.taxes_id.id == 22: - ending_price = po_line.ending_price / 1.11 - purchase_price = ending_price - else: - purchase_price = po_line.ending_price - if line.purchase_order_id.delivery_amount > 0: - purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po - if line.purchase_order_id.delivery_amt > 0: - purchase_price += line.purchase_order_id.delivery_amt - real_item_margin = sales_price - purchase_price - sum_margin += real_item_margin - - if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: - self.total_so_margin = sum_so_margin - self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 - self.total_margin = sum_margin - self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 - - else: - self.total_margin = 0 - self.total_percent_margin = 0 - self.total_so_margin = 0 - self.total_so_percent_margin = 0 - + sum_so_margin += sale_order_line.item_margin + sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty + if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': + sales_price -= sale_order_line.delivery_amt_line + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= sale_order_line.fee_third_party_line + sum_sales_price += sales_price + purchase_price = line.price_subtotal + if line.ending_price > 0: + if line.taxes_id.id == 22: + ending_price = line.ending_price / 1.11 + purchase_price = ending_price + else: + purchase_price = line.ending_price + # purchase_price = line.price_subtotal + if line.order_id.delivery_amount > 0: + purchase_price += line.delivery_amt_line + if line.order_id.delivery_amt > 0: + purchase_price += line.order_id.delivery_amt + real_item_margin = sales_price - purchase_price + sum_margin += real_item_margin if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: self.total_so_margin = sum_so_margin self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 self.total_margin = sum_margin self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 - else: self.total_margin = 0 self.total_percent_margin = 0 -- cgit v1.2.3 From ab1ba4b2b482b207a39ae17e43cdac4b1abb72ce Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:38:21 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 83f86e8e..9c05780b 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -959,7 +959,7 @@ class PurchaseOrder(models.Model): sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price purchase_price = line.price_subtotal - if line.ending_price > 0: + if line.order_id.total_delivery_amount > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: ending_price = line.ending_price / 1.11 purchase_price = ending_price -- cgit v1.2.3 From 6eecc5ecd377e6e7b69519294259b8e66cd8e564 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:40:28 +0700 Subject: fix error --- indoteknik_custom/models/purchase_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 9c05780b..faf0955d 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -959,7 +959,7 @@ class PurchaseOrder(models.Model): sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price purchase_price = line.price_subtotal - if line.order_id.total_delivery_amount > 0 and line.order_id.total_cost_service > 0: + if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: ending_price = line.ending_price / 1.11 purchase_price = ending_price -- cgit v1.2.3 From 0f9e8f280cd50ed5af7cbc98253ebf02068d5f24 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:59:08 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index faf0955d..6d02038d 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -944,20 +944,21 @@ class PurchaseOrder(models.Model): def compute_total_margin_from_apo(self): sum_so_margin = sum_sales_price = sum_margin = 0 for line in self.order_line: - sale_order_line = line.so_line_id - if not sale_order_line: - sale_order_line = self.env['sale.order.line'].search([ - ('product_id', '=', line.product_id.id), - ('order_id', '=', line.so_id.id) - ], limit=1, order='price_reduce_taxexcl') - - sum_so_margin += sale_order_line.item_margin - sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty - if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= sale_order_line.delivery_amt_line - if sale_order_line.order_id.fee_third_party > 0: - sales_price -= sale_order_line.fee_third_party_line - sum_sales_price += sales_price + sales_order_line = self.env['purchase.order.sales.match'].search([ + ('product_id', '=', line.product_id.id), + ('order_id', '=', line.so_id.id) + ]) + + for so_line in sales_order_line: + sale_order_line = so_line.sale_line_id + sum_so_margin += sale_order_line.item_margin + sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty + if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': + sales_price -= sale_order_line.delivery_amt_line + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= sale_order_line.fee_third_party_line + sum_sales_price += sales_price + purchase_price = line.price_subtotal if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: -- cgit v1.2.3 From 780a7642c97518a3d7e6cdc5e2516b354f6e9cae Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 12:00:25 +0700 Subject: fix bug --- indoteknik_custom/models/purchase_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 6d02038d..71ee61d3 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -946,7 +946,7 @@ class PurchaseOrder(models.Model): for line in self.order_line: sales_order_line = self.env['purchase.order.sales.match'].search([ ('product_id', '=', line.product_id.id), - ('order_id', '=', line.so_id.id) + ('sale_id', '=', line.so_id.id) ]) for so_line in sales_order_line: @@ -958,7 +958,7 @@ class PurchaseOrder(models.Model): if sale_order_line.order_id.fee_third_party > 0: sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price - + purchase_price = line.price_subtotal if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: -- cgit v1.2.3 From c36d351e79fb2b3487e391e8075bbdefaf41fbab Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 12:03:32 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 71ee61d3..f2401dec 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -946,7 +946,7 @@ class PurchaseOrder(models.Model): for line in self.order_line: sales_order_line = self.env['purchase.order.sales.match'].search([ ('product_id', '=', line.product_id.id), - ('sale_id', '=', line.so_id.id) + ('purchase_order_id', '=', line.order_id.id) ]) for so_line in sales_order_line: -- cgit v1.2.3 From a24d7b2a21ff24e31eef77e2032a861b7eb13e31 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 13:51:45 +0700 Subject: fix bug --- indoteknik_custom/models/purchase_order.py | 71 ++++++++++++++-------- .../models/purchase_order_sales_match.py | 5 ++ 2 files changed, 51 insertions(+), 25 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index f2401dec..54d771ba 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -943,42 +943,63 @@ class PurchaseOrder(models.Model): def compute_total_margin_from_apo(self): sum_so_margin = sum_sales_price = sum_margin = 0 - for line in self.order_line: - sales_order_line = self.env['purchase.order.sales.match'].search([ + for line in self.order_sales_match_line: + po_line = self.env['purchase.order.line'].search([ ('product_id', '=', line.product_id.id), - ('purchase_order_id', '=', line.order_id.id) - ]) - - for so_line in sales_order_line: - sale_order_line = so_line.sale_line_id - sum_so_margin += sale_order_line.item_margin - sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty + ('order_id', '=', line.purchase_order_id.id) + ], limit=1) + sale_order_line = line.sale_line_id + if not sale_order_line: + sale_order_line = self.env['sale.order.line'].search([ + ('product_id', '=', line.product_id.id), + ('order_id', '=', line.sale_id.id) + ], limit=1, order='price_reduce_taxexcl') + + if sale_order_line and po_line: + so_margin = (line.qty_po / line.qty_so) * sale_order_line.item_margin + sum_so_margin += so_margin + + sales_price = sale_order_line.price_reduce_taxexcl * line.qty_po if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= sale_order_line.delivery_amt_line + sales_price -= (sale_order_line.delivery_amt_line / sale_order_line.product_uom_qty) * line.qty_po if sale_order_line.order_id.fee_third_party > 0: - sales_price -= sale_order_line.fee_third_party_line + sales_price -= (sale_order_line.fee_third_party_line / sale_order_line.product_uom_qty) * line.qty_po sum_sales_price += sales_price - purchase_price = line.price_subtotal - if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: - if line.taxes_id.id == 22: - ending_price = line.ending_price / 1.11 - purchase_price = ending_price - else: - purchase_price = line.ending_price - # purchase_price = line.price_subtotal - if line.order_id.delivery_amount > 0: - purchase_price += line.delivery_amt_line - if line.order_id.delivery_amt > 0: - purchase_price += line.order_id.delivery_amt - real_item_margin = sales_price - purchase_price - sum_margin += real_item_margin + + purchase_price = po_line.price_subtotal + if po_line.ending_price > 0: + if po_line.taxes_id.id == 22: + ending_price = po_line.ending_price / 1.11 + purchase_price = ending_price + else: + purchase_price = po_line.ending_price + if line.purchase_order_id.delivery_amount > 0: + purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po + if line.purchase_order_id.delivery_amt > 0: + purchase_price += line.purchase_order_id.delivery_amt + real_item_margin = sales_price - purchase_price + sum_margin += real_item_margin + + if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: + self.total_so_margin = sum_so_margin + self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 + self.total_margin = sum_margin + self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 + + else: + self.total_margin = 0 + self.total_percent_margin = 0 + self.total_so_margin = 0 + self.total_so_percent_margin = 0 + if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: self.total_so_margin = sum_so_margin self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 self.total_margin = sum_margin self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 + else: self.total_margin = 0 self.total_percent_margin = 0 diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index 4ebe959b..ed013dd5 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -26,6 +26,11 @@ class PurchaseOrderSalesMatch(models.Model): margin_deduct = fields.Float(string='After Deduct', compute='_compute_delivery_amt') purchase_price_so = fields.Float(string='Purchase Price Sale Order', related='sale_line_id.purchase_price') purchase_price_po = fields.Float('Purchase Price PO', compute='_compute_purchase_price_po') + purchase_line_id = fields.Many2one('purchase.order.line', string='Purchase Line', compute='_compute_purchase_line_id') + + def _compute_purchase_line_id(self): + for line in self: + line.purchase_line_id = self.env['purchase.order.line'].search([('order_id', '=', line.purchase_order_id.id), ('product_id', '=', line.product_id.id)]) def _compute_purchase_price_po(self): for line in self: -- cgit v1.2.3