Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
8 ตอบกลับ
28799 มุมมอง

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!

อวตาร
ละทิ้ง

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

ผู้เขียน

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

คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
ผู้เขียน

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

คำตอบที่ดีที่สุด

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"/>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

 @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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 24
2942
1
มี.ค. 22
2435
3
พ.ค. 25
1583
1
เม.ย. 25
1183
one2one relational field แก้ไขแล้ว
3
ก.ย. 24
14026