Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1567 มุมมอง

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 ?


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
ผู้เขียน

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

ผู้เขียน

Thank You it works now

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ธ.ค. 23
2974
1
ต.ค. 23
7410
1
ก.พ. 23
4402
0
เม.ย. 23
1795
Override report_invoice_document แก้ไขแล้ว
1
มี.ค. 23
3656