I use customized Workorders in my model but want to keep the base sales orders for retail etc.
So I used _inherits in my model and it looked very promising i.e. in the beginning.
Here what I did...
class YachtService(models.Model):
_name = 'yacht.service'
_description = 'Workorder Data'
_inherits = {'sale.order': 'partner_id'}
partner_id = fields.Many2one( 'sale.order', ondelete='cascade', required='false', string='Customer')
my_field_2 = fields.Boolean(string="Is MyField 2")
My view looks like this:
<record id="work_order_form" model="ir.ui.view">
<field name="name">workorder.form</field>
<field name="model">yacht.service</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="payment_term_id" position="after">
<field name='my_field_2'/>
</field>
</field>
</record>
When opening my work_order_form view it all appears just like I want it to. As desired, the original sale.order.form is not modified, so far so good....
Here the problem:
In my new view, the moment I enter data into the customer field (partner_id) I get the following error.
Error:
Odoo Server Error
Traceback (most recent call last):
>
>
>
raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf)))
ValueError: Invalid field 'customer' in leaf "<osv.ExtendedLeaf: ('customer', '=', True) on sale_order (ctx: )>"
To be honest, I don't even know where to start with this problem. From what I can read, it seemingly has something to do with the validity of the Many2One field (partner_ID).