Просмотр исходного кода

[IMP] helpdesk_extras: add file upload support, ES translations, un-blacklist attachment_ids

- Add file upload support for binary/one2many fields in form builder
- Un-blacklist attachment_ids via migration script (18.0.1.0.3)
- Change placeholder field to Text for multiline support
- Add es_MX translations for Request Type and Impact
odoo 2 месяцев назад
Родитель
Сommit
58d87f9999

+ 17 - 1
helpdesk_extras/__init__.py

@@ -1,5 +1,21 @@
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
 
 
+from . import controllers
 from . import models
 from . import models
 from . import wizard
 from . import wizard
-from . import controllers
+
+from odoo import api, SUPERUSER_ID
+
+def post_init_hook(env):
+    """
+    Hook to whitelist attachment_ids for helpdesk.ticket in website forms.
+    This runs after module installation/update.
+    """
+    # Use SQL to bypass "Properties of base fields cannot be altered" ORM check
+    env.cr.execute("""
+        UPDATE ir_model_fields 
+        SET website_form_blacklisted = false 
+        WHERE model = 'helpdesk.ticket' AND name = 'attachment_ids'
+    """)
+    # Verify if it was updated (optional, but good for debugging)
+    # env.cr.commit() # Not strictly needed as post_init_hook runs in transaction? Odoo handles commit.

+ 1 - 1
helpdesk_extras/__manifest__.py

@@ -1,6 +1,6 @@
 {
 {
     "name": "Helpdesk Extras",
     "name": "Helpdesk Extras",
-    "version": "18.0.1.0.2",
+    "version": "18.0.1.0.3",
     "category": "Services/Helpdesk",
     "category": "Services/Helpdesk",
     "summary": "Funcionalidades extras para Helpdesk - Compartir equipos y widget de horas",
     "summary": "Funcionalidades extras para Helpdesk - Compartir equipos y widget de horas",
     "description": """
     "description": """

+ 25 - 0
helpdesk_extras/i18n/es_MX.po

@@ -452,3 +452,28 @@ msgstr "ej., Soporte Básico, Soporte Premium"
 msgid "Describe this workflow template..."
 msgid "Describe this workflow template..."
 msgstr "Describe esta plantilla de flujo de trabajo..."
 msgstr "Describe esta plantilla de flujo de trabajo..."
 
 
+
+#. module: helpdesk_extras
+#: model:helpdesk.request.type,name:helpdesk_extras.type_incident
+msgid "Incident"
+msgstr "Incidente"
+
+#. module: helpdesk_extras
+#: model:helpdesk.request.type,name:helpdesk_extras.type_improvement
+msgid "Improvement"
+msgstr "Mejora"
+
+#. module: helpdesk_extras
+#: selection:helpdesk.ticket,business_impact:0
+msgid "Critical"
+msgstr "Crítico"
+
+#. module: helpdesk_extras
+#: selection:helpdesk.ticket,business_impact:1
+msgid "High"
+msgstr "Alto"
+
+#. module: helpdesk_extras
+#: selection:helpdesk.ticket,business_impact:2
+msgid "Normal"
+msgstr "Normal"

+ 12 - 0
helpdesk_extras/migrations/18.0.1.0.3/post-migration.py

@@ -0,0 +1,12 @@
+from odoo import api, SUPERUSER_ID
+
+def migrate(cr, version):
+    env = api.Environment(cr, SUPERUSER_ID, {})
+    # Use SQL to bypass "Properties of base fields cannot be altered" ORM check
+    cr.execute("""
+        UPDATE ir_model_fields 
+        SET website_form_blacklisted = false 
+        WHERE model = 'helpdesk.ticket' AND name = 'attachment_ids'
+    """)
+    # Also for good measure, check if we need to do it for 'helpdesk.ticket' specifically?
+    # The WHERE clause handles it.

+ 21 - 0
helpdesk_extras/models/helpdesk_team.py

@@ -669,6 +669,27 @@ class HelpdeskTeamExtras(models.Model):
             # Set default value as text content
             # Set default value as text content
             if template_field.default_value:
             if template_field.default_value:
                 input_el.text = template_field.default_value
                 input_el.text = template_field.default_value
+        elif field_type == 'binary':
+            # File upload
+            input_el = etree.SubElement(input_div, 'input', {
+                'type': 'file',
+                'class': 'form-control s_website_form_input',
+                'name': field_name,
+                'id': field_id
+            })
+            if required:
+                input_el.set('required', '1')
+        elif field_type == 'one2many' and field.relation == 'ir.attachment':
+            # Multiple file upload for attachment_ids
+            input_el = etree.SubElement(input_div, 'input', {
+                'type': 'file',
+                'class': 'form-control s_website_form_input',
+                'name': field_name,
+                'id': field_id,
+                'multiple': 'true'
+            })
+            if required:
+                input_el.set('required', '1')
         elif field_type == 'selection':
         elif field_type == 'selection':
             # Check if custom selection options are provided (for non-relation selection fields)
             # Check if custom selection options are provided (for non-relation selection fields)
             selection_options = None
             selection_options = None

+ 1 - 1
helpdesk_extras/models/helpdesk_template.py

@@ -258,7 +258,7 @@ class HelpdeskTemplateField(models.Model):
         string='Custom Label',
         string='Custom Label',
         help="Custom label for the field in the form. If empty, uses the field's default label."
         help="Custom label for the field in the form. If empty, uses the field's default label."
     )
     )
-    placeholder = fields.Char(
+    placeholder = fields.Text(
         string='Placeholder',
         string='Placeholder',
         help="Placeholder text shown when field is empty"
         help="Placeholder text shown when field is empty"
     )
     )