Skip to Content
Menu
This question has been flagged
6 Replies
4147 Views

Hello guys,

Sorry for the amateur question. I know that for you this is very simple, but since I am not a developer, I have a great difficulty.

I have created a custom field called  x_cnpj . I need to include this field when I generate the sale quotation report.
I try edit report_saleorder_document  and add this line:
<span t-field="doc.partner_id.x_cnpj"/>

But when generate report, value does not appear, it is as if it did not exist.

I know I'm doing something wrong, can someone help me with a step by step?

thank you very much !

Avatar
Discard
Best Answer

Hi,

Did you include the new field named x_cnpj inside the customer model(res.partner) ? If so, what you did seems to be right. If the new field is introduced in the sale order model(sale.order) , then use

<span t-field="doc.x_cnpj"/>

instead of <span t-field="doc.partner_id.x_cnpj"/>


Thanks

Avatar
Discard
Best Answer

Hello,
Please verify once value set in x_cnpj of customer of sale order for which you are generating report.

Avatar
Discard
Best Answer

Hi,

   If you put the  x_cnpj in sale order just use the same as said by Niyas .if it is in Partner form use doc.partner_id.x_cnpj 

<template id="view_id" inherit_id="sale.report_saleorder_document">
<xpath expr="//path" position="after">
<t t-if="doc.x_cnpj">
<strong>x_cnpj :</strong>
<p t-field="doc.x_cnpj"/>
</t>
</xpath>
</template>

   

Avatar
Discard
Author Best Answer

Hi Niyas,

i dont know what i´m doing wrong, but i get this error when generate PDF:


Error to render compiling AST
KeyError: 'x_cnpj'
Template: sale.report_saleorder_document
Path: /templates/t/t/div/div[1]/div[2]/div[1]/span
Node: <span t-field="doc.x_cnpj"/> 
Any ideas ?
Avatar
Discard

Can you specify where you have added this field ? from the user interface or by custom module

Author

Hi Niyas

I´m a IT Pro, but have no experience with development.

I create the custom field in called x_cnpj in "Models" - "res.partner"

Then, i edit res.partner.form and add <field name="x_cnpj" placeholder="CNPJ - Sem pontos ou traços" attrs="{'invisible': [('is_company','=', False)]}"/>

Until here, is working, because i can add information to this field in customer information.

But i need this information appears in my quotation when i generate this from sales

I don´t know what do to in report_saleorder_document to make the field x_cnpj create in res.partner.form appears in this report.

Any ideas ?