Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1565 Vistas

I have added custom selection field in model sale.order and i need to show this field value in invoices report, i didn't found any relation between model sale.order and account.move to add the the custom field value in account.move using related attribute.

any idea how can i do that ?


Avatar
Descartar
Mejor respuesta

Hi,

You can try as follows, while creating invoice from sale order, try passing the custom field values to invoice. To accept this value you can add same field in invoice too.


For passing the value from sale order to invoice model, inherit the function _prepare_invoice_values function in sale.order model.


Thanks & Regards.

Avatar
Descartar
Autor

Hello Niyas,
i did this in python:

def _prepare_invoice(self):
for rec in self:
res = super(saleorder, rec)._prepare_invoice()
res['sales_type'] = rec.sales_type
return res
and then added the field in report like this:

<div t-if="o.sales_type">
<strong>Sales Type:</strong>
<t t-esc="o.sales_type"/>
</div>

but iam getting this error message as below:

Error when render the template
AttributeError: 'account.move' object has no attribute 'sales_type'
Template: account.report_invoice_document
Path: /t/t/div[2]/div[2]/div[5]
Node: <div t-if="o.sales_type"/>

any idea

Seems you haven't added a field named sales_type in the invoice model, can you add the field and try the same again and see

Autor

Thank You it works now

Publicaciones relacionadas Respuestas Vistas Actividad
2
dic 23
2973
1
oct 23
7409
1
feb 23
4402
0
abr 23
1795
1
mar 23
3656