summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-06-13 11:39:00 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-06-13 11:39:00 +0700
commit860abd78b0474279f851378f0b6507fe71fd76be (patch)
tree7bd75d5d9373f215990809865656543e40261653 /indoteknik_custom/models
parent4af22ad4f15865626f0a99fed233cb19d04d9b8c (diff)
<miqdad> PTG document name sequence
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/tukar_guling.py21
2 files changed, 22 insertions, 0 deletions
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