I wonder if there is some way to show in one field, a concatenation of 3 other fields, already in the same form.
Like for example:
'field_1' : fields.integer('Campo 1'),
field_2' : fields.integer('Campo 2'),
field_3' : fields.integer('Campo 3'),
Then show the inputs of these 3 fields concatenated in one single field:
field_concatenated : fields.related(?)('field_1', 'field_2', 'field_3', 'Name of the field'),
I put an '?' sign cause i actually don't know how to achieve this, maybe using a related
type one? By the way the 3 fields are on the same class-form.
The resulting field could be readonly
, and show up after the form has been saved.
I hope i've explained myself.
Thanks in advance
EDIT
The fields can be of the type integer
and char
2nd EDIT
Actual Example:
'empresa' : fields.integer('Empresa'),
'provee' : fields.integer('Proveedor'),
'soli_cant' : fields.integer('Cantidad de Solicitudes'),
'dest' : fields.char('Destino'),
'anho' : fields.integer('Año'),
So, after these fields are filled manually, the resulting field have to show me a concatenation of these 4 fields, in a format like empresa-proveesoli_cant-dest-anho
Being provee
and soli_cant
one after the another, (without the '-') if it can't be possible then that show me the concatenation without separator
Maybe it isn't necessarily declared on the python code, maybe there is some shortcut in the xml view?
Something like <field name="empresa" "provee" "soli_cant" "dest" "anho" />
idk...
3rd EDIT
The actual code i'm using right now (Thanks to Ethan Furman):
The columns:
'empresa' : fields.integer('Empresa'),
'provee' : fields.integer('Proveedor'),
'soli_cant' : fields.integer('Cantidad de Solicitudes'),
'dest' : fields.char('Destino'),
'anho' : fields.integer('Año'),
The function with it's column:
def _combinalos(self, cr, uid, ids, field_name, args, context=None):
values = {}
for id in ids:
rec = self.browse(cr, uid, [id], context=context)[0]
values[id] = {}
values[id][field_name] = '%s %s %s %s %s' %(rec.empresa, rec.provee, rec.soli_cant, rec.dest, rec.anho)
return values
columns = {
'nombre' : fields.function(_combinalos, string='Referencia de Pedido', type='char', arg=('empresa','provee','soli_cant', 'dest', 'anho'), method=True),
All this on the same class
of course.
Then i call it from my xml view
like this:
<h1>
<label string="Request for Quotation " attrs="{'invisible': [('state','not in',('draft','sent'))]}"/>
<label string="Purchase Order " attrs="{'invisible': [('state','in',('draft','sent'))]}"/>
<field name="nombre" class="oe_inline" readonly="1" />
</h1>
The label string
is to filter if this is a Request for Quotation
or a Purchase Order
After all this, i do fill the 5 fields of integer
and char
type, but still don't get these fields 'concatenated' in one string, or title, just a label saying [object Object], it could be a label
issue? String name of function in the column maybe?