diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-12-01 10:03:29 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-12-01 10:03:29 +0700 |
| commit | 15377b23022440d88c40c656a513b3397ba43e9a (patch) | |
| tree | b6ae76c8eb15e54a5c3a1eb1ca4106044f9dc11e /fixco_custom/models | |
| parent | 9c3a7bba06bba9db22d84286f96739ef37e49ace (diff) | |
push revisi hari sabtu tanggal 29/11/25
Diffstat (limited to 'fixco_custom/models')
| -rwxr-xr-x | fixco_custom/models/__init__.py | 3 | ||||
| -rw-r--r-- | fixco_custom/models/automatic_purchase.py | 2 | ||||
| -rw-r--r-- | fixco_custom/models/manage_stock.py | 1 | ||||
| -rwxr-xr-x | fixco_custom/models/product_product.py | 14 | ||||
| -rw-r--r-- | fixco_custom/models/purchase_order.py | 2 | ||||
| -rw-r--r-- | fixco_custom/models/purchase_pricelist_wizard.py | 29 | ||||
| -rwxr-xr-x | fixco_custom/models/stock_picking.py | 31 |
7 files changed, 75 insertions, 7 deletions
diff --git a/fixco_custom/models/__init__.py b/fixco_custom/models/__init__.py index c9c2484..8316e53 100755 --- a/fixco_custom/models/__init__.py +++ b/fixco_custom/models/__init__.py @@ -31,4 +31,5 @@ from . import update_depreciation_move_wizard from . import invoice_reklas from . import uangmuka_pembelian from . import coretax_faktur -from . import token_log
\ No newline at end of file +from . import token_log +from . import purchase_pricelist_wizard
\ No newline at end of file diff --git a/fixco_custom/models/automatic_purchase.py b/fixco_custom/models/automatic_purchase.py index 037d65a..e2b132d 100644 --- a/fixco_custom/models/automatic_purchase.py +++ b/fixco_custom/models/automatic_purchase.py @@ -149,7 +149,7 @@ class AutomaticPurchase(models.Model): vendor = self.env['res.partner'].browse(partner_id) - chunk_size = 20 + chunk_size = 10 line_chunks = [lines[i:i + chunk_size] for i in range(0, len(lines), chunk_size)] for index, chunk in enumerate(line_chunks): diff --git a/fixco_custom/models/manage_stock.py b/fixco_custom/models/manage_stock.py index 80aa505..09d9e6a 100644 --- a/fixco_custom/models/manage_stock.py +++ b/fixco_custom/models/manage_stock.py @@ -17,6 +17,7 @@ class ManageStock(models.Model): vendor_id = fields.Many2one('res.partner', string="Vendor", required=True) qty_available = fields.Float(string='Qty Available', compute='_compute_qty_available') qty_onhand = fields.Float(string='Qty Onhand', compute='_compute_qty_available') + qty_incoming = fields.Float(string='Qty Incoming', related='product_id.incoming_qty') _sql_constraints = [ ('product_unique', 'unique (product_id)', 'This product already has a stock management rule!'), diff --git a/fixco_custom/models/product_product.py b/fixco_custom/models/product_product.py index 72e7ecd..59e9443 100755 --- a/fixco_custom/models/product_product.py +++ b/fixco_custom/models/product_product.py @@ -17,10 +17,22 @@ class ProductProduct(models.Model): qty_pcs_box = fields.Float("Pcs Box") barcode_box = fields.Char("Barcode Box") qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant') - qty_multiple = fields.Float('Multiple') + qty_multiple = fields.Float('Minimum Beli') brand_id = fields.Many2one('brands', string='Brand') product_public_category_id = fields.Many2one('product.public.category', string='Public Categories') + def action_open_pricelist_wizard(self): + return { + 'name': 'Create Purchase Pricelist', + 'type': 'ir.actions.act_window', + 'res_model': 'purchase.pricelist.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': { + 'default_product_id': self.id, + } + } + def check_multiple_qty(self, other_qty): if self.qty_multiple > 0 and other_qty > 0: multiple = self.qty_multiple diff --git a/fixco_custom/models/purchase_order.py b/fixco_custom/models/purchase_order.py index 2393618..61c4ef8 100644 --- a/fixco_custom/models/purchase_order.py +++ b/fixco_custom/models/purchase_order.py @@ -287,7 +287,7 @@ class PurchaseOrder(models.Model): desc = l.get("description") or "" # Flag: row error kalau description tidak mulai dengan SOO/ - is_error = not desc.startswith("SOO/") + is_error = desc and not desc.startswith("SOO/") # Style row merah row_style = "color:red; font-weight:bold;" if is_error else "" diff --git a/fixco_custom/models/purchase_pricelist_wizard.py b/fixco_custom/models/purchase_pricelist_wizard.py new file mode 100644 index 0000000..70ac54f --- /dev/null +++ b/fixco_custom/models/purchase_pricelist_wizard.py @@ -0,0 +1,29 @@ +from odoo import models, fields + +class PurchasePricelistWizard(models.TransientModel): + _name = 'purchase.pricelist.wizard' + _description = 'Wizard Create Purchase Pricelist' + + product_id = fields.Many2one('product.product', string="Product", required=True) + vendor_id = fields.Many2one('res.partner', string="Vendor", required=True, domain="[('supplier_rank','>',0)]") + price = fields.Float(string="Price", required=True) + + def action_create_pricelist(self): + self.ensure_one() + + existing = self.env['purchase.pricelist'].search([ + ('product_id', '=', self.product_id.id) + ], limit=1) + + if existing: + existing.vendor_id = self.vendor_id.id + existing.price = self.price + return {'type': 'ir.actions.act_window_close'} + + self.env['purchase.pricelist'].create({ + 'product_id': self.product_id.id, + 'vendor_id': self.vendor_id.id, + 'price': self.price, + }) + + return {'type': 'ir.actions.act_window_close'} diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py index 5c432b0..11e24a6 100755 --- a/fixco_custom/models/stock_picking.py +++ b/fixco_custom/models/stock_picking.py @@ -50,6 +50,25 @@ class StockPicking(models.Model): store=True ) + def button_validate(self): + checked_products = self.mapped('check_product_lines').mapped('product_id') + picking_lines = self.move_line_ids_without_package + + missing_products = [ + line.product_id.display_name + for line in picking_lines + if line.product_id not in checked_products + ] + + if missing_products: + raise UserError(_( + "Product ini belum discan:\n- %s" + % "\n- ".join(missing_products) + )) + + return super(StockPicking, self).button_validate() + + @api.depends('move_lines.origin_returned_move_id') def _compute_is_return(self): for picking in self: @@ -493,12 +512,18 @@ class PickingReportCustom(models.AbstractModel): def _get_report_values(self, docids, data=None): pickings = self.env['stock.picking'].browse(docids) - - # Update flag is_printed jadi True + already_printed = pickings.filtered(lambda p: p.is_printed) + + if already_printed: + names = "\n- ".join(already_printed.mapped("name")) + raise UserError( + "Dokumen berikut sudah pernah di-print sebelumnya:\n\n- %s" % names + ) + pickings.write({'is_printed': True}) return { 'doc_ids': docids, 'doc_model': 'stock.picking', 'docs': pickings, - }
\ No newline at end of file + } |
