What I aim to do is to add a new field called category in the sale order line , and when I choose the product the corresponding category (ie, consumable/service/stockable) should come automatically to the field. I have successfully added the field to the order line. What to write in the function to get the product category in the field?
here is my code
.xml
<odoo>
<data>
<record id="product_category_sale_line" model="ir.ui.view">
<field name="name">sale.orderline.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree/field[@name='price_unit']" position="after">
<field name="category"/>
</xpath>
</field>
</record>
</data>
</odoo>
.py
from odoo import models, fields, api
class ProductCategory(models.Model):
_inherit = 'sale.order'
category = fields.Char(string='Category', compute='get_category')
def get_category(self):