Skip to Content
Menu
This question has been flagged
1 Atsakyti
781 Rodiniai

Hello Odoo Community,

I’m facing an issue with invoice lines where the product description is displayed by default, both in the backend and on PDF invoices. This makes the invoices and the order lines extremely cluttered and hard to read, and it’s not the desired behavior. What I want is for only the product name, internal reference, and variant to be displayed—without the product description.

Currently, in the invoice template, the product name is rendered using:

<td name="account_invoice_line_name"><span t-if="line.name" t-field="line.name" t-options="{'widget': 'text'}">Bacon Burger</span></td>

However, line.name also includes the product description, which is not necessary. I would like to remove the description from the invoice lines but keep the internal reference and variant as part of the product name. Also line.product_id.name just includes the name but not the Variant oder reference.

Is there a way to achieve this globally in Odoo, so that the product description is no longer shown in each line of the invoice (both in the backend and on PDF invoices)? Only in Invocies would be also helpful at first.

Any help or guidance on how to implement this would be greatly appreciated.

Thank you in advance!

Portretas
Atmesti
Best Answer

Hello, Nico


    To show only the product name, internal reference, and variant to be displayed—without the product description once

    user add a product in Invoice.

   

    Please create a custom module and add a below code of snippet

   

        1) Create a Module, after that create a account_move_line.py file and add it in folder called 'models'.


//Code in comment//


2) As you can see in below image that I have cretaed 3 new products, One Product without variants and Internal Reference,

   Second Product with Variants only and third product with Internal Reference.

   

   

3) For the report Please check below image.


 

Hope this helps !

     

If you need any help in customization feel free to contact us.


Thanks & Regards,

Email:    odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

Portretas
Atmesti

# -*- coding: utf-8 -*-

from odoo import api, models, fields

class AccountMoveLine(models.Model):
"""Inherited account move line for customization"""
_inherit = 'account.move.line'

def _get_computed_name(self):
"""
Custom logic to compute the name for invoice lines.
This will include the product name, internal reference, and variant,
but will exclude the description.
"""
self.ensure_one()
name = self.product_id.display_name or ''
if self.product_id.default_code: # Internal Reference
name = name

# If it's a variant, append the variant details
if self.product_id.product_template_attribute_value_ids:
variant = ", ".join(
attr.name for attr in self.product_id.product_template_attribute_value_ids
)
name = name

return name

@api.depends('product_id', 'quantity', 'price_unit')
def _compute_name(self):
"""
Override to customize the behavior of the `name` field.
"""
for line in self:
if line.move_id.is_invoice(): # Only modify for invoices
line.name = line._get_computed_name()
else:
super(AccountMoveLine, line)._compute_name()

Related Posts Replies Rodiniai Veikla
2
spal. 24
1103
1
spal. 18
3214
0
spal. 15
2859
2
lapkr. 24
1373
1
spal. 24
787