I am trying to create a functional field by inheriting the account.invoice.line
table, but I cant seem to get it working. Here is the python code
class account_invoice_line(orm.Model):
_name = 'account.invoice.line'
_inherit = 'account.invoice.line'
_columns = {
'calc_qty': fields.function(_get_calc_qty, type="float", string="Quantity", store=False),
}
def _get_calc_qty(self, cr, uid, ids, field_name, arg, context=None):
calc_qty = {'qty': 0.0}
return calc_qty
and here is the xml view code
<record id="view_account_invoice_custom_form_inherit" model="ir.ui.view">
<field name="name">Account Invoice Form Inherited</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page[@string='Invoice Lines']/field[@name='invoice_line']/tree/field[@name='quantity']" position="replace">
<field name="calc_qty" />
</xpath>
</field>
</record>
Now I dont want to store this value in the table, but I would like to show the calculated number in the view. I know this is possible, but after I install the module and then check the invoices form then I get this message
View error
Can't find field 'calc_qty' in the following view parts composing the view of object model 'account.invoice':
* Account Invoice Form InheritedEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model