From 860abd78b0474279f851378f0b6507fe71fd76be Mon Sep 17 00:00:00 2001 From: Miqdad Date: Fri, 13 Jun 2025 11:39:00 +0700 Subject: PTG document name sequence --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/tukar_guling.py | 21 +++++++++++ indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/tukar_guling.xml | 50 ++++++++++++++++++++++++++ 4 files changed, 73 insertions(+) diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 08fa9803..72bd7cee 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -150,3 +150,4 @@ from . import stock_backorder_confirmation from . import account_payment_register from . import stock_inventory from . import approval_invoice_date +from . import tukar_guling diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index e69de29b..ca246c7f 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -0,0 +1,21 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError, ValidationError + + +class TukarGuling(models.Model): + _name = 'tukar.guling' + _description = 'Tukar Guling' + _order = 'date desc, id desc' + _rec_name = 'name' + + # Hanya 2 field seperti yang Anda inginkan + name = fields.Char('Reference', required=True, copy=False, readonly=True, default='New') + date = fields.Datetime('Date', default=fields.Datetime.now, required=True) + + # Sequence generator + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get('name', 'New') == 'New': + vals['name'] = self.env['ir.sequence'].next_by_code('tukar.guling') or '0' + return super(TukarGuling, self).create(vals_list) \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 601f04c5..5b60f3ac 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -181,3 +181,4 @@ access_shipping_option,shipping.option,model_shipping_option,,1,1,1,1 access_production_purchase_match,access.production.purchase.match,model_production_purchase_match,,1,1,1,1 access_image_carousel,access.image.carousel,model_image_carousel,,1,1,1,1 access_v_sale_notin_matchpo,access.v.sale.notin.matchpo,model_v_sale_notin_matchpo,,1,1,1,1 +access_tukar_guling_all_users,tukar.guling.all.users,model_tukar_guling,base.group_user,1,1,1,0 diff --git a/indoteknik_custom/views/tukar_guling.xml b/indoteknik_custom/views/tukar_guling.xml index e69de29b..34f2fa48 100644 --- a/indoteknik_custom/views/tukar_guling.xml +++ b/indoteknik_custom/views/tukar_guling.xml @@ -0,0 +1,50 @@ + + + + Pengajuan Tukar Guling + ir.actions.act_window + tukar.guling + tree,form + + + + + + Pengajuan Tukar Guling + tukar.guling + PTG/ + 5 + 1 + 1 + + + + + pengajuan.tukar.guling.tree + tukar.guling + + + + + + + + + + pengajuan.tukar.guling.form + tukar.guling + +
+ + + +
+
+
+
\ No newline at end of file -- cgit v1.2.3