Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
503 Vizualizări

Is it possible to move the custom field "Reference" to infront of the subject line to show as

SP-00001116 - BYOD - VC Solution


I would ideally want to do this for every app 


https://ibb.co/ZzxFGYf0

Imagine profil
Abandonează
Cel mai bun răspuns

Hi Jitesh,


There are two approaches depending on whether you want this just in the UI header (form/tree views) or globally everywhere (including chatter, emails, reports, etc.).

Option 1: Update the Header in Form View (UI Only)

In your custom module, you can override the header/<field name="name"> display in the XML view and concatenate the reference + subject.

Example for a form view:

<record id="view_sale_order_form_inherit" model="ir.ui.view">
    <field name="name">sale.order.form.inherit.reference_subject</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <!-- Replace subject field --><xpath expr="//field[@name='name']" position="replace">
            <field name="display_name_custom" readonly="1"/>
        </xpath>
    </field></record>

Then in your model:

from odoo import models, fields
class SaleOrder(models.Model):
    _inherit = "sale.order"
    display_name_custom = fields.Char(
        compute="_compute_display_name_custom",
        store=False    )

    def _compute_display_name_custom(self):
        for rec in self:
            ref = rec.reference or ""            subject = rec.name or ""            rec.display_name_custom = f"{ref} - {subject}" if ref else subject

This way, in the header it shows exactly:

SP-00001116 - BYOD - VC Solution

Option 2: Override name_get (Global Everywhere)

If you want everywhere in Odoo (lists, search dropdowns, chatter, many2one references, reports, etc.), override name_get:

from odoo import models
class SaleOrder(models.Model):
    _inherit = "sale.order"def name_get(self):
        result = []
        for rec in self:
            ref = rec.reference or ""            subject = rec.name or ""            display_name = f"{ref} - {subject}" if ref else subject
            result.append((rec.id, display_name))
        return result

This way Odoo will always display the reference before the subject, no matter where it’s used.


If you have any questions, feel free to reach out to us

Hope this helps!


Thanks & Regards,

Email: odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

Imagine profil
Abandonează
Autor

Thank you.
Is the global option available on Odoo online?

Autor Cel mai bun răspuns

Thank you.

Is the global option available on Odoo online?

Imagine profil
Abandonează

In Odoo Online (Enterprise) you do not have access to source code, so it is not available.

Related Posts Răspunsuri Vizualizări Activitate
0
aug. 25
941
0
apr. 25
3
0
apr. 25
1064
0
oct. 22
1936
2
iul. 16
4161