I would like to add fields from my product.product to my newly created Expense form (legacy_expense) which inherits hr.expense.expense. I created this module to edit the workflow of the Expense Management module - this I managed to do fine.
I'm new to OpenERP and am having trouble getting this to work. I tried inheriting the many2one product_id field in the form through my .py field and then get it to show in the xml but it always comes up with the error "XMLSyntaxError: attributes construct error, line 25, column 13"
I'm guessing my inheritance ins't correct and I have no idea how to relate the two objects. If someone could help me out with this it'll be great!
This is my customised legacy_expense.py file:
from openerp.osv import fields, osv
class legacy_expense(osv.osv):
_inherit = 'hr.expense.expense'
_columns = {
'state': fields.selection([
('draft', 'New'),
('cancelled', 'Refused'),
('confirm', 'Waiting Approval'),
('done', 'Paid'),
], 'Order State', readonly= False, select=True),
'product_id': fields.many2one('product.product','Product',required=True),
}
legacy_expense()
This is the legacy_expense.xml file:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id = "view_expenses_form_custom" model="ir.ui.view">
<field name="name">view.expenses.form.custom</field>
<field name="model">hr.expense.expense</field>
<field name="type">form</field>
<field name="inherit_id" ref="hr_expense.view_expenses_form" />
<field name="arch" type="xml">
<data>
<header>
<button name="signal_draft_to_confirm" states="draft" string="Submit" type="workflow" groups="base.group_hr_user" />
</header>
<header>
<button name="signal_confirm_to_done" states="confirm" string="Approve Expense" type="workflow" groups="base.group_hr_user" />
</header>
<header>
<button name="signal_confirm_to_refused" states="confirm" string="Reject Expense" type="workflow" groups="base.group_hr_user" />
</header>
</data>
<xpath expr = "/form/sheet/group/group[2]/field[@name='user_valid']"position="after">
<field name="product_id"/>
</xpath>
</field>
</record>
</data>
</openerp>
Again, thanks in advance to anyone who can help!