Skip to Content
Menu
This question has been flagged
1 Reply
2546 Views

Hello everyone!

Give me an advice, please

I have to add product categories inside invoice’s table.

How can I do it?

Screenshot: https://imgur.com/a/YHmpugw

Menu path: Invoicing > Selecting an invoice
odoo version 12.0-20211011

Thanks

Avatar
Discard
Best Answer

Hi  Stanislav , 

To do this you need to Inherit account.invoice.line

In Py

class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
    category_id = fields.Many2one('product.category', 'Product Category')


Avatar
Discard

XML

<record model="ir.ui.view" id="view_invoice_product_category">
<field name="name">account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='name']" position="after">
<field string="Category" name="category_id"/>
</xpath>
</field>
</record>