İçereği Atla
Menü
This question has been flagged
3 Cevaplar
1691 Görünümler

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")  



Avatar
Vazgeç
Best Answer

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

Avatar
Vazgeç

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?

Best Answer

How work in odoo 17?

Avatar
Vazgeç
Best Answer

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

  1. Go to Settings > General Settings.
  2. 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)

  1. Navigate to Documents > Configuration > Documents.
  2. Open Odoo Studio (if available).
  3. Drag and drop a new field into the form view for documents.
  4. Save the changes.

Option 2: Using a Custom Module (Community or Enterprise)

If you're using Odoo Community or prefer to work with code:

  1. Create a custom module or use an existing one.
  2. 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")
    
  3. 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.

  1. Create a new XML file in your custom module, e.g., views/documents_inspector_view.xml.
  2. 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>
    
  3. Update your module to apply the changes:
    odoo-bin -u your_module_name
    

4. Verify the Changes

  1. Navigate to the Documents app.
  2. Select a document and open the Inspector Panel (the right-hand side panel).
  3. 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!

Avatar
Vazgeç
Related 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