Odoo Qweb check for contact title - odoo

I am currently working on my first Odoo (v8) template and want to check if a contact person has a specific title.
What currently works is:
Sehr geehrter <span t-field="o.partner_id.title"></span> <span t-field="o.partner_id.name"></span>
This outputs:
Sehr geehrter Herr Klaus Koffer
As you can see I use the german translation of the system.
My question is: How can I check for "Mister" and "Miss"? The following example does not work. Is there a way to get the internav values as they are obviously not "Mister".
<p t-if="o.partner_id.title == 'Mister'">
Thanks in advance.

You can refer our blog to know about qweb.
Just try it in your code.
t-if="o.partner_id.title.name == 'Mister'"
Because o.partner_id.title gives an object of res.partner.title model.
So, you have to user o.partner_id.title.name. that's it.

Just you can check the condition using <t> </t> Tag for add the condition in Qweb View.
Better way u should use the <t> Tag insted of <p> Tag
some thing like this
<t t-if="o.partner_id.title == 'Mister'">
Your login will add hear for Mister title
</t>
I hope this should helpful for you ..)

Related

How to include a checkbox image in a Qweb Report?

Is there way to change checkbox image in qweb report. For example i want to change standard "V" to image like this:
Is it possible?
Solution 0
Add the file to your module, for example store it in the path /module_name/static/src/img/image_name.png
Then now you can add the image to the Qweb Report:
<img t-att-src="'/module_name/static/src/img/image_name.png'" />
Note: respect the order and the type of the quotes
Solution 1
Maybe it is useful to create ul html list with all the elements you want to add:
<style>
.icon_list {
list-style-image: url('/module_name/static/src/img/image_name.png');
}
</style>
<!-- [...] -->
<ul class="icon_list" >
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
(I didn´t try it but it should work as well)
you can simply replace it with the standard Unicode character ☑ by a field that is checking the status
Please use "input type as checkbox". It worked for me.
<input type="checkbox" checked="checked"/>I agree that glasses are selected based on my indications
in odoo11
you can choose this class for checkbox
i class="fa fa-check which opening and closing tags This gives better checkbox than default in odoo

Remove "Social Title" from order form in Prestashop?

I have just downloaded and installed the latest version of Prestashop. And found out there is a Social Title-option in order checkout form.
I want to remove that. I have found how to remove the Mr and Mrs boxes. But the whole row and label "Social Title" remains.
Have tried to search on Google for an answer but can't find. Some answers refer to the addresses.tpl. But I think the templates might been changed since these threads.
In fact, I have tried to search for "social" in the whole template directory and can't find anything related to this.
The nearest I get is in the ../templates/customer/_partials/customer-form.tpl. And I think it's rendered where this is:
<section>
{block "form_fields"}
{foreach from=$formFields item="field"}
{block "form_field"}
{form_field field=$field}
{/block}
{/foreach}
{/block}
</section>
So, maybe the social title isn't able to change from templates anymore?
So, where do I change it nowadays?
In Prestashop 1.7 there is no need to edit any code, you can just go to Shop Parameters -> Customer Settings -> Titles and remove all existing titles.
This will prevent the "Social title" field from being generated.
Shop Parameters -> Customer Settings -> Titles - Delete titles
themes/xxx/templates/_partials/form-fields.tpl 9th line change
{if $field.type !== 'checkbox'}
{$field.label}
{/if}
to
{if $field.type !== 'checkbox' and $field.type !== 'radio-buttons'}
{$field.label}
{/if}
Yeah, it's kind of dummy workaround, but it works.
UPDATE:
More proper way would be to comment the block:
$genderField = (new FormField)
->setName('id_gender')
->setType('radio-buttons')
->setLabel(
$this->translator->trans(
'Social title', [], 'Shop.Forms.Labels'
)
)
;
foreach (Gender::getGenders($this->language->id) as $gender) {
$genderField->addAvailableValue($gender->id, $gender->name);
}
$format[$genderField->getName()] = $genderField;
You can find it in /classes/form/CustomerFormatter.php
You can find the code for Social Titles in file at the following path:
/themes/default-bootstrap/identity.tpl
Note: It is not a good practice to remove the code from a core file, we recommend to apply some CSS to hide the Social Title block.

how can I add one more field "company name" in odoo while signup?

I wanted to put an extra field in odoo while signup procedure. If admin has created multi company then user gets options to choose the company during sign up.
Demo screen
can anyone pls help me how can I achieve this Dropdown menu for company options in signup form?
<option t-esc="nb"/></t>
and
<select></select>
have no idea how it works.
TIA
You need to inherit the module you wish to modify, in your case I think this is the "web" module. If you don't know how to inherit modules, I recommend going through Odoo's developer documentation.
Inherit AuthSignupHome class in auth_signup module to fetch multi company data and inherit auth_signup.signup template to include qweb web design to for dropdow with multi company data:
try below code:
Controller.py:
class AuthSignupHome(openerp.addons.auth_signup.controllers.main.AuthSignupHome):
company_ids = request.env["res.company"].sudo().search([])
print'company_ids',company_ids
qcontext['multi_company'] = company_ids
return request.render('auth_signup.signup', qcontext)
In xml:
<template id="inherit_fields" inherit_id="auth_signup.fields" name="Sign up">
<xpath expr="//div[#class='form-group field-login']" position="before">
<div class="selection">
<select>
<t t-foreach="multi_company" t-as="company">
<option><t t-esc="company.name"/></option>
</t>
</select>
</div>
</xpath>
</template>
I think it will help you..

How can I change the way that VAT number is show using QWeb in Odoo

I have the view report_invoice_document showing the VAT client number, using next code:
<span t-field="o.partner_id.vat"/>
However, the number that appears is CO8000000001 and I need just the number without letters and if it's possible formatted this way 800.000.000-1.
I was trying to find documentation about t-field-options to customize the field but I didn't have luck with that.
Thanks.
Try:
<span t-esc="o.partner_id.vat[2:]"/>
t-esc supports Python code.

Selenium Junit to find element

I am new to selenium.I am creating test script for duplicate registration into a website .When an error is displayed for duplicate registration i want to pass the testcase .
I am getting confused regarding the property of the webelement . I am not sure as to which field should i take or as how to write the findelement for the error image displayed.
Here is the HTML tag for the element image displayed:
<td>
<img src="images/bell.png">
</td>
This is for the text displayed along with error image :
<a onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.forms['navigation'],'navigation:j_id322,navigation:j_id322','');}return false" style="color:#000000;" href="#">Found 1 patient(s) with same Patient Name, Gender and Age. Click here to view details</a>
Please help .Thanks
Based purely on the details provided, the following would work;
findElement(By.css("td>img[src='images/bell.png']")
and
findElement(By.css("a[onclick]")
However, I am sure that there is more context than this. Without the full html it is hard to give better solutions