This question has been flagged
2812 Views

Hiya,

I have a dropdown that I require to be populated based upon the input from another dropdown. The logic side of this should be fine, my problem comes with actually using the function that I have defined within my view where I am filtering the dropdown.

I get this error: "Validate Error Error occurred while validating the field(s) arch: Invalid XML for View Architecture!" and if I look back into the logs it seems that it's because it can't find the place where I have referenced my function. I have tried putting <field name="get_parent_id" /> and many variants of this in different locations throughout the view but I seem to always end back with the problem of my code not being able to find the function. Help here would be greatly appreciated!

The function in account_invoice.py (overridden) is:

    def get_parent_id(self, cr, uid, ids, field_name, arg, context=None):
        """Returns the parent id to supply the dropdown with relevant 'attention' details"""
        result = {}
        if not ids:
            return result
        for record in self.browse(cr, uid, ids, context=context):
            result[record.id] = record.partner_id.id
        return result

My view account_invoice_view.xml is:

        <record id="invoice_form" model="ir.ui.view">
            <field name="get_parent_id" />
            <field name="name">account.invoice.form</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="catalyst_setup.invoice_form" />
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='po_number']" position="before">
                        <field name="attn" domain="[('parent_id','=',get_parent_id)]" on_change="onchange_attn(attn)" widget="many2many_tags"/>
                    </xpath>
                </data>
            </field>
        </record>

(I hope those put themselves in blocks, I haven't been able to see how to do that in the wysiwyg)

Avatar
Discard