Trying to implement this feature where failed invoices should have a "Warning Icon" prefix

I’m providing the code and description: If the Customer Invoices fail to validate then in the tree view that entry should show a warning :warning: prefix icon for the “number” field.

warning_icon = fields.Function(fields.Char('Warning Icon'), 'get_warning_icon')

def get_warning_icon(self, name=None):
    if not self.e_invoice_complete:
        return 'warning_icon'
    return None


<record model="ir.ui.icon" id="warning_icon">
     <field name="name">warning</field>
     <field name="path">icons/warning_icon.svg</field>


   <field name="number">
       <prefix icon="warning_icon"/>

Description: All I want to do is that I am inheriting ‘account_invoice\invoice_tree.xml’ and in my file “e_invoice_pa\invoice_tree.xml” I want to put a prefix for example in case of Customer Invoices fail to validate in the tree view it should have a prefix warning_icon to number field

This is not the proper XML content for extending an existing view, see Extend model — trytond latest documentation
You must have an xpath expression like

    <xpath expr="//field[@name='number']" position="inside">
        <prefix icon="warning_icon"/>
1 Like

Thank you so much for your help! At least for now the error has been resolved, but still, I cannot see the icon yet.

You must return the name of the icon which you set it to warning.

PS: maybe it is better to add some prefix to avoid collision with icons from other modules.

1 Like

I really appreciate your help. You solved my problem <3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.