Skip to Content
Menu
This question has been flagged
1 Reply
1204 Views

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
Discard
Best Answer

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
Discard
Author

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

Author

Thank You it works now

Related Posts Replies Views Activity
2
Dec 23
1325
1
Oct 23
5569
1
Feb 23
3018
0
Apr 23
1045
1
Mar 23
2020