Reputation: 1
So, I'm pretty new to Odoo... and I'm having trouble with relational fields in 10. This seems like it should be an incredibly simple thing to do, but I can't figure it out...
I'm trying to populate my sale orders with the custom fields that I added to my products page and (obviously) have those fields on the sales order contain the information from the product page. This is all within the same module (sales)
For an example; one of the things my company does is grade the products we assess and repair for our customers. I'd like to be able to have that grade on the sale order.
Here is a screenshot of my product page: https://i.sstatic.net/nW92s.jpg
Thanks!
Upvotes: 0
Views: 607
Reputation: 941
In your module inherit the sale_order
model, and add the related fields.
class sale_order(models.Model):
_inherit = 'sale.order'
# If your grade field is a CharField
grade = fields.CharField(related='product_id.grade', string='Grade')
Inherit the sale_order
view, and insert the grade
field where you like. In the example below we insert it before the state
field.
<openerp>
<data>
<record id="sale_order_form" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='state']" position="before">
<field name="grade"/>
</xpath>
</field>
</record>
<data>
<openerp>
For changes to take effect you might need to upgrade your module.
Upvotes: 0