summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/product_attribute.py13
-rwxr-xr-xindoteknik_custom/models/product_template.py14
-rwxr-xr-xindoteknik_custom/models/sale_order.py2
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv1
5 files changed, 30 insertions, 1 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index bc20e55d..3a5079f6 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -83,3 +83,4 @@ from . import account_report_general_ledger
from . import price_group
from . import po_sync_price
from . import base_import_import
+from . import product_attribute
diff --git a/indoteknik_custom/models/product_attribute.py b/indoteknik_custom/models/product_attribute.py
new file mode 100644
index 00000000..51ef97cf
--- /dev/null
+++ b/indoteknik_custom/models/product_attribute.py
@@ -0,0 +1,13 @@
+from odoo import fields, models, api, _
+from odoo.exceptions import AccessError, UserError, ValidationError
+import re
+
+class ProductAttributeValue(models.Model):
+ _inherit = 'product.attribute.value'
+
+ @api.constrains('name')
+ def _validate_name(self):
+ pattern = r'^[a-zA-Z0-9\[\]\(\)\.\s/]+$'
+ if not re.match(pattern, self.name):
+ raise UserError('Nama hanya bisa menggunakan angka, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring.')
+ \ No newline at end of file
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index bc54b703..a69d6942 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -4,6 +4,7 @@ from odoo.exceptions import AccessError, UserError, ValidationError
import logging
import requests
import json
+import re
_logger = logging.getLogger(__name__)
@@ -50,6 +51,13 @@ class ProductTemplate(models.Model):
is_new_product = fields.Boolean(string='Produk Baru',
help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru')
seq_new_product = fields.Integer(string='Seq New Product', help='Urutan Sequence New Product')
+
+ @api.constrains('name')
+ def _validate_name(self):
+ pattern = r'^[a-zA-Z0-9\[\]\(\)\.\s/]+$'
+ if not re.match(pattern, self.name):
+ raise UserError('Nama hanya bisa menggunakan angka, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring.')
+
# def write(self, vals):
# if 'solr_flag' not in vals and self.solr_flag == 1:
@@ -278,6 +286,12 @@ class ProductProduct(models.Model):
qty_onhand_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_onhand_bandengan')
qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan')
sla_version = fields.Integer(string="SLA Version", default=0)
+
+ @api.constrains('name')
+ def _validate_name(self):
+ pattern = r'^[a-zA-Z0-9\[\]\(\)\.\s/]+$'
+ if not re.match(pattern, self.name):
+ raise UserError('Nama hanya bisa menggunakan angka, huruf kecil, huruf besar, titik, kurung lengkung, kurung siku, garis miring.')
def _get_qty_incoming_bandengan(self):
for product in self:
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index eb07959e..a0bc54b8 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -1,6 +1,6 @@
from odoo import fields, models, api, _
from odoo.exceptions import UserError
-import logging, random, string, requests, math, json, re
+import logging, random, string, requests, math, json, re
_logger = logging.getLogger(__name__)
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index da389854..c5dbdb19 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -68,3 +68,4 @@ access_airway_bill,access.airway.bill,model_airway_bill,,1,1,1,1
access_airway_bill_manifest,access.airway.bill.manifest,model_airway_bill_manifest,,1,1,1,1
access_price_group,access.price.group,model_price_group,,1,1,1,1
access_po_sync_price,access.po.sync.price,model_po_sync_price,,1,1,1,1
+access_product_attribute_value,access.product.attribute.value,model_product_attribute_value,,1,1,1,1