diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-02-25 14:01:15 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-02-25 14:01:15 +0700 |
| commit | 6a5a2a2666c33ffafd610df882491d86918468bb (patch) | |
| tree | b61d4672169aa78a0bee9aae319af68768a2b6ee /indoteknik_custom/models | |
| parent | 141bfb3a32e73d5b8557a70867d957d5ed3d485b (diff) | |
| parent | a24d7b2a21ff24e31eef77e2032a861b7eb13e31 (diff) | |
Merge branch 'odoo-production' into CR/renca-commision
# Conflicts:
# indoteknik_custom/models/commision.py
# indoteknik_custom/views/customer_commision.xml
Diffstat (limited to 'indoteknik_custom/models')
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move_line.py | 8 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_payment_register.py | 48 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchase_order_sales_match.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/models/res_users.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_inventory.py | 59 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 6 |
11 files changed, 148 insertions, 7 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index ddbe16f1..f33a7411 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -142,3 +142,5 @@ from . import stock_immediate_transfer 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/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 37f7c77c..7c95d4ef 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' 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 + } diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index d1d929d3..ed013dd5 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -24,6 +24,18 @@ 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') + 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: + 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.price_unit def _compute_delivery_amt(self): for line in self: diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 31b84ae3..b0864f2c 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -70,6 +70,10 @@ 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) + if type == 'switch_account': + 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 def check_access(self, model, mode): 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' 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 '' 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 diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 49e66786..36d9f63d 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', tracking=True, copy=False, help="The current state of the stock picking.") notee = fields.Text(string="Note") @api.model 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: |
