Odoo Help

0
2 Answers
1
Avatar

Ray Carnes (ray)

--Ray Carnes (ray)--
2154
| 3 2 6
Greater Los Angeles, United States
--Ray Carnes (ray)--

Business Analyst - Custom Projects

https://www.linkedin.com/in/raycarnes

Ray Carnes (ray)
7/13/18, 11:29 PM

This should get you far enough along to make it work.

sale.report_saleorder_document is the report you want to inherit and override for changing the way the Customer (Partner) is shown.


The QWEB directive that prints the Customer information is:

<div t-field="doc.partner_id" 
t-options="{'widget': 'contact', 'fields': ['address', 'name'], 'no_marker': True}"/>


By default Odoo will show Company, Customer with the address - that's how the template for the widget is defined.

There are two changes you will need to make:

1. Remove the name field from the fields key.  This shows the address WITHOUT the name.

<div t-field="doc.partner_id" 
t-options="{'widget': 'contact', 'fields': ['address'], 'no_marker': True}"/>

2. Show the specific name(s) of the Customer.

<div t-field="doc.partner_id.name"/>
<div><span t-field="doc.partner_id.company_name"/>:</div/>

For a final result of:

<div t-field="doc.partner_id.name"/>
<div><span t-field="doc.partner_id.company_name"/>:
<span t-field="doc.partner_id"
t-options="{'widget': 'contact', 'fields': ['address'], 'no_marker': True}"/>


Note that the quote characters have to be escaped - you will see this in the original Odoo XML, with the original QWEB snippet looking like this:

<span t-field="doc.partner_id" 
t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;], &quot;no_marker&quot;: True}"/>


Your finished report would then look like this:



11 Comments
Yenthe Van Ginneken
7/14/18, 3:44 AM

Great answer Ray!

Ahmed Aljeshi
7/14/18, 5:11 AM

Thanks Ray for you detailed answer, I followed your instructions,

as below

[code]

<div class="col-xs-5 col-xs-offset-1">

<div t-field="doc.partner_id.name"/>

<div><span t-field="doc.company_name"/>

<span t-field="doc.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;], &quot;no_marker&quot;: True}"/>

<p t-if="doc.partner_id.vat"><t t-esc="doc.company_id.country_id.vat_label or 'TIN'"/>: <span t-field="doc.partner_id.vat"/></p>

</div>

</div></div>

[/code]

but for some reason I get an error while trying to print the report. your help is appreciated.

Odoo, Ray Carnes (ray)
7/14/18, 10:39 AM

doc.partner_id.company_name - not doc.company_name. This was my fault, I've updated my post. Each time you get an error, look at the bottom of the traceback and you will see what the problem is.

Ahmed Aljeshi
7/15/18, 3:56 AM

Thanks Ray I really appreciate your help..

,, I'm almost there ,, bear with me plz..

so now the end result came

Client Name

*Company name is missing * :

Address

so I believe something wrong with

<div><span t-field="doc.partner_id.company_name"/>:

Thanks a lot

Odoo, Ray Carnes (ray)
7/15/18, 11:46 AM

I just tried again and if the Company Name is blank, it could be because the Customer doesn't belong to a Company (has no parent_id). Is your CLIENT an Individual that shows below the COMPANY when you open the COMPANY Customer record?

Ahmed Aljeshi
7/15/18, 12:05 PM

yes,

when I access the company profile from " Contacts Module" I see the client name in the bottom of the Company with the rest of clients under the same company

Odoo, Ray Carnes (ray)
7/15/18, 12:51 PM

Can you export the COMPANY and CLIENT records and post the values? Choose these fields: Name, Company Name, Display Name, Address Type, Company Type, Related Company, Parent name, Is a Company, Commercial Entity and Company Name Entity.

Ahmed Aljeshi
7/15/18, 1:18 PM

Hello Ray,

please find this picture , contains the details,

https://imgur.com/a/rRA6meW

for some reason, company_name is empty, this is why it doesn't show in the report, although this person is already added under this parent company :/

https://imgur.com/a/rRA6meW

is there a way to fill the company_name from odoo? or I just do it in Excel and re-import them again?

Regards,

Odoo, Ray Carnes (ray)
7/15/18, 1:23 PM

Enter both into Odoo via the UI, then export in the same way so you can see which of these fields Odoo expects to have values. Then, make sure your import sheet matches the export.

Ahmed Aljeshi
7/15/18, 1:29 PM

Thanks a lot Ray, I'm sure fixing this missing cell ( Company_name) will solve the problem.

sorry for all the hassle :)

I'll do the same steps for invoice too ,, much appreciated !

Ahmed Aljeshi
7/15/18, 1:42 PM

Just tried it ! 100% Thanks again Ray!

Ask a Question
Writer
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now