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 | |
| parent | 9c3a7bba06bba9db22d84286f96739ef37e49ace (diff) | |
push revisi hari sabtu tanggal 29/11/25
| -rwxr-xr-x | fixco_custom/__manifest__.py | 1 | ||||
| -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 | ||||
| -rwxr-xr-x | fixco_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | fixco_custom/views/manage_stock.xml | 2 | ||||
| -rwxr-xr-x | fixco_custom/views/product_product.xml | 7 | ||||
| -rw-r--r-- | fixco_custom/views/wizard_purchase_pricelist.xml | 29 |
12 files changed, 114 insertions, 8 deletions
diff --git a/fixco_custom/__manifest__.py b/fixco_custom/__manifest__.py index badd1c6..7a796ad 100755 --- a/fixco_custom/__manifest__.py +++ b/fixco_custom/__manifest__.py @@ -47,6 +47,7 @@ 'views/vit_kecamatan.xml', 'views/vit_kota.xml', 'views/token_log.xml', + 'views/wizard_purchase_pricelist.xml', ], 'demo': [], 'css': [], 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 + } diff --git a/fixco_custom/security/ir.model.access.csv b/fixco_custom/security/ir.model.access.csv index eee7451..4ed6857 100755 --- a/fixco_custom/security/ir.model.access.csv +++ b/fixco_custom/security/ir.model.access.csv @@ -39,3 +39,4 @@ access_uangmuka_pembelian,access.uangmuka.pembelian,model_uangmuka_pembelian,,1, access_coretax_faktur,access.coretax.faktur,model_coretax_faktur,,1,1,1,1 access_report.fixco_custom.report_picking_list_custom,access.report.fixco_custom.report_picking_list_custom,model_report_fixco_custom_report_picking_list_custom,,1,1,1,1 access_token_log,access.token.log,model_token_log,,1,1,1,1 +access_purchase_pricelist_wizard,access.token.log,model_purchase_pricelist_wizard,,1,1,1,1 diff --git a/fixco_custom/views/manage_stock.xml b/fixco_custom/views/manage_stock.xml index c617e11..60b80a1 100644 --- a/fixco_custom/views/manage_stock.xml +++ b/fixco_custom/views/manage_stock.xml @@ -10,6 +10,7 @@ <field name="buffer_stock"/> <field name="qty_available"/> <field name="qty_onhand"/> + <field name="qty_incoming"/> <field name="vendor_id"/> </tree> </field> @@ -28,6 +29,7 @@ <field name="buffer_stock"/> <field name="qty_available"/> <field name="qty_onhand"/> + <field name="qty_incoming"/> <field name="vendor_id"/> </group> </group> diff --git a/fixco_custom/views/product_product.xml b/fixco_custom/views/product_product.xml index 08952b6..a622d36 100755 --- a/fixco_custom/views/product_product.xml +++ b/fixco_custom/views/product_product.xml @@ -6,9 +6,14 @@ <field name="model">product.product</field> <field name="inherit_id" ref="product.product_normal_form_view"/> <field name="arch" type="xml"> + <xpath expr="//header" position="inside"> + <button name="action_open_pricelist_wizard" + type="object" + string="Create/Update Purchase Pricelist" + class="oe_highlight"/> + </xpath> <field name="categ_id" position="after"> <field name="brand_id" /> - <field name="qty_multiple" /> <field name="barcode_box" /> <field name="qty_pcs_box" /> <field name="qr_code_variant" widget="image" readonly="True"/> diff --git a/fixco_custom/views/wizard_purchase_pricelist.xml b/fixco_custom/views/wizard_purchase_pricelist.xml new file mode 100644 index 0000000..85ec528 --- /dev/null +++ b/fixco_custom/views/wizard_purchase_pricelist.xml @@ -0,0 +1,29 @@ +<!-- file: views/purchase_pricelist_wizard_view.xml --> +<odoo> + <record id="purchase_pricelist_wizard_form" model="ir.ui.view"> + <field name="name">purchase.pricelist.wizard.form</field> + <field name="model">purchase.pricelist.wizard</field> + <field name="arch" type="xml"> + + <form string="Create Purchase Pricelist"> + <group> + <field name="product_id" readonly="1"/> + <field name="vendor_id"/> + <field name="price"/> + </group> + + <footer> + <button string="Create" + type="object" + name="action_create_pricelist" + class="btn-primary"/> + + <button string="Cancel" + class="btn-secondary" + special="cancel"/> + </footer> + </form> + + </field> + </record> +</odoo> |
