تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
8 الردود
28773 أدوات العرض

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 24
2933
1
مارس 22
2429
3
مايو 25
1572
1
أبريل 25
1174
3
سبتمبر 24
14015