Skip to Content
Menú
This question has been flagged

Hi,

I would like to override "_prepare_invoice_line" method of src/enterprise/sale_subscription/models/sale_order.py  to hide the periode message ininvoice detail lines

I tried to create a new class in my addon module and use inheritance but it seems not to work properly.

Someone could help me?

Avatar
Descartar
Best Answer

WARNING: This is an approach, not necessarily a complete solution. Your Odoo Digital Advisor or Odoo Partner can help you if you don't have the skills to do this yourself.


One option is to create an Automation Rule that overrides the function that Odoo uses to add the period description with the start and end date. This function relies on the recurring_invoice field on the subscription order line.

This approach creates a new sale order line with the same name and since we are not providing a value for the recurring_invoice field, we can recalculate the description on the copy and assign the result (which won't have the period text) back to the original.


for record in records:
    if record.sale_line_ids:
        sol = record.sale_line_ids[0]
        sol_duplicate = sol.new({'order_id': sol.order_id.id,'name': sol.name})._prepare_invoice_line()
        record['name'] = sol_duplicate.get('name', record.name)
Avatar
Descartar
Autor Best Answer

Many Tks

Avatar
Descartar

Hi Richard,
Did you manage to get this working? If so, could you please share how you achieved it if possible?
I've been trying to do something similar, but instead of removing the invoice period, I'm trying to change the period and invoice a month ahead. Just can't seem to get it working.

Many thanks,
Richard A

Best Answer

Hi,

In order to hide or change the period message of invoices of subscriptions, you must inherit and override the _prepare_invoice_data(odoo v14) method of sale.subscription model. The field narration of subscription invoices must be set to null.

Regards 

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de maig 25
2279
0
de març 25
1103
1
d’oct. 24
1821
1
d’oct. 24
12723
2
d’ag. 23
43192