İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1566 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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

Üretici

Thank You it works now

İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Ara 23
2973
1
Eki 23
7409
1
Şub 23
4402
0
Nis 23
1795
1
Mar 23
3656