Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1587 Widoki

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 ?


Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
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

Powiązane posty Odpowiedzi Widoki Czynność
2
gru 23
3001
1
paź 23
7446
1
lut 23
4421
0
kwi 23
1823
1
mar 23
3696