diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-13 11:39:00 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-13 11:39:00 +0700 |
| commit | 860abd78b0474279f851378f0b6507fe71fd76be (patch) | |
| tree | 7bd75d5d9373f215990809865656543e40261653 | |
| parent | 4af22ad4f15865626f0a99fed233cb19d04d9b8c (diff) | |
<miqdad> PTG document name sequence
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/tukar_guling.py | 21 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/tukar_guling.xml | 50 |
4 files changed, 73 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 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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="action_pengajuan_tukar_guling" model="ir.actions.act_window"> + <field name="name">Pengajuan Tukar Guling</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">tukar.guling</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem + id="menu_pengajuan_tukar_guling" + name="Pengajuan Tukar Guling" + parent="stock.menu_warehouse_report" + sequence="3" + action="action_pengajuan_tukar_guling" + /> + + <record id="seq_tukar_guling" model="ir.sequence"> + <field name="name">Pengajuan Tukar Guling</field> + <field name="code">tukar.guling</field> + <field name="prefix">PTG/</field> + <field name="padding">5</field> + <field name="number_next">1</field> + <field name="number_increment">1</field> + <field name="company_id" eval="False"/> + </record> + + <record id="pengajuan_tukar_guling_tree" model="ir.ui.view"> + <field name="name">pengajuan.tukar.guling.tree</field> + <field name="model">tukar.guling</field> + <field name="arch" type="xml"> + <tree create="1" default_order="create_date desc"> + <field name="name"/> + <field name="date"/> + </tree> + </field> + </record> + + <record id="pengajuan_tukar_guling_form" model="ir.ui.view"> + <field name="name">pengajuan.tukar.guling.form</field> + <field name="model">tukar.guling</field> + <field name="arch" type="xml"> + <form> + <group> + <field name="name" widget="text"/> + </group> + </form> + </field> + </record> +</odoo>
\ No newline at end of file |
