can you help me please to add a new field inside documents inspector
(add field inside black side of document information "that shown in below image")
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
This question has been flagged
Hi,
To add a field in document inspector, You need to push the field to inspectorFields. /** @odoo-module */
import { inspectorFields} from "@documents/views/inspector/documents_inspector";
inspectorFields.push("accessed_user_ids");
After that you can call the field in the XML using Xpath. The template name is documents.DocumentsInspector.documentsInfo.
Hope it helps
could you be a bit more specific on how to do that please? Right now I have the field as x_studio_document_name. When you say push the field what does that mean?
How work in odoo 17?
To add a new field inside the Documents Inspector panel in Odoo, as shown in the provided image, you can achieve this by customizing the documents.document model and the corresponding inspector view. Here’s how you can add a field step-by-step:
1. Enable Developer Mode
- Go to Settings > General Settings.
- Activate Developer Mode (find the option in the settings menu or from your user menu dropdown).
2. Add a Custom Field to the documents.document Model
You need to add a custom field to the model that powers the Documents module.
Option 1: Using Studio (Enterprise Only)
- Navigate to Documents > Configuration > Documents.
- Open Odoo Studio (if available).
- Drag and drop a new field into the form view for documents.
- Save the changes.
Option 2: Using a Custom Module (Community or Enterprise)
If you're using Odoo Community or prefer to work with code:
- Create a custom module or use an existing one.
-
Add the following code to extend the documents.document model:
from odoo import models, fields class DocumentsDocument(models.Model): _inherit = 'documents.document' custom_field = fields.Char(string="Custom Field")
-
Update your module by running:
odoo-bin -u your_module_name
3. Add the Field to the Documents Inspector View
The Documents Inspector panel is a special view tied to the documents.document model. You need to extend this view to include your custom field.
- Create a new XML file in your custom module, e.g., views/documents_inspector_view.xml.
-
Add the following code to include the custom field:
<odoo> <record id="view_document_inspector_inherit" model="ir.ui.view"> <field name="name">documents.inspector.inherit</field> <field name="model">documents.document</field> <field name="inherit_id" ref="documents.documents_inspector_sidebar_view"/> <field name="arch" type="xml"> <xpath expr="//div[@class='o_inspector_body']" position="inside"> <div> <field name="custom_field" placeholder="Enter custom value here"/> </div> </xpath> </field> </record> </odoo>
-
Update your module to apply the changes:
odoo-bin -u your_module_name
4. Verify the Changes
- Navigate to the Documents app.
- Select a document and open the Inspector Panel (the right-hand side panel).
- You should now see your custom field displayed in the panel.
5. Optional: Make the Field Editable or Dynamic
- To make the field editable directly in the Inspector panel, ensure the field is not readonly.
- If you need additional logic, such as dynamically setting the field value or adding validation, you can use Python methods or JavaScript.
6. Troubleshooting
- If the changes do not appear:
- Clear the Odoo cache by restarting the server.
- Refresh your browser or clear the browser cache.
- Check the Odoo logs for errors if the inspector panel does not load.
Let me know if you encounter any issues or need further assistance!
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye OlRelated Posts | Cevaplar | Görünümler | Aktivite | |
---|---|---|---|---|
|
0
Mar 24
|
885 | ||
|
3
Eki 24
|
2522 | ||
|
0
Ağu 23
|
681 | ||
|
0
Mar 23
|
1052 | ||
|
0
Oca 23
|
1017 |