İçereği Atla
Menü
Bu soru işaretlendi
8 Cevaplar
28786 Görünümler

Hello,

I have 2 fields, Name and Lastname, but in the view I want them to appear together inside just one field, so instead of having:

<field name="Name" string="Name" />

<field name="Last Name" string="Last Name" />

I want 1 field which would have Name+Last Name

Any tip on how to do this will be appreciated,

Thanks!

Avatar
Vazgeç

@Yakito, if answer is good, you vote and/or accept this answer!

Üretici

Yes yes, sure I will, I have to test it first. That will happen tonight!

En İyi Yanıt

You could try something like:

<label for="Name and Lastname"/>
<div>
     <field name="Name" class="oe_inline"/><field name="Last Name" class="oe_inline" />
 </div>

The "label" should be the "string" that you wish to show.

Avatar
Vazgeç
Üretici

Oh, perfect, I thought I had to do it on python, this is much simpler. thanks!

You can define a field and user a python code to concatenate what you want, but i thought that you only needed a "visual thing". If you need to store it for some reason i have a very basic example i had to make :P (i am a newbie myself :P)

tienes el ejemplo de contactenar un campo?
quiero concatenar tres campos: nombre+apellido1+apellido2
y sustituir con eso el nombre del partner

En İyi Yanıt

Oi Federico,

Tray the code below. You may iterate the variables if there are a list in place of object's fields.

<t t-set="finaltext" t-value="obj.yourvariable1+' #'+obj.yourvariable2+', #'+obj.yourvariable3 "/>
<span t-esc="finaltext"/>
Avatar
Vazgeç
En İyi Yanıt

 @api.model

def create(self, vals):

if vals['fname']:

fname = vals['fname'].title()

else:

fname = ''

if vals['lname']:

lname = vals['lname'].title()

else:

lname = ''

name = "{}, {}".format(lname, fname,)

print 'name', name

vals['name'] = name

vals['fname'] = fname

vals['lname'] = lname

if 'address_id' in vals:

res_id = super(HrEmployee, self).create(vals)

return res_id


fname is your firstname and lname is your lastname, Try this on your python file

Avatar
Vazgeç
En İyi Yanıt

Is possible to do the same thing with strings from a a single field (in my case product.id from pos.order)? 

I would like to concatenate every code starting with '#' between the codes starting with [internal reference].

Normal view:

[0001] product1
# product instructions 1
# product instructions 2

[0002] product2
# product instructions 1
# product instructions 2

Should appear as :

[0001] product1    # product instructions 1 , # product instructions 2

[0002] product2    # product instructions 1 , # product instructions 2

Is it possible with the same principle directly on xml? I don't need to store information (for now) is just another rappresentation.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eyl 24
2935
1
Mar 22
2432
3
May 25
1577
1
Nis 25
1179
3
Eyl 24
14021