Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
8 Răspunsuri
28780 Vizualizări

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!

Imagine profil
Abandonează

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

Autor

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

Cel mai bun răspuns

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.

Imagine profil
Abandonează
Autor

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

Cel mai bun răspuns

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"/>
Imagine profil
Abandonează
Cel mai bun răspuns

 @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

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
sept. 24
2933
1
mar. 22
2430
3
mai 25
1576
1
apr. 25
1175
3
sept. 24
14016