Gautam Bothra
Gautam Bothra

Reputation: 587

How to cancatenate multiple Character fields in one many2one field?

I want to concatenate multiple character fields in a single many2one field and access this in other module. How can we do this?

For example:- I have 5 character fields with different classes in a module and want to concatenate these 5 character fields in a single many2one field. Also I want access this many2one field in another module.

Can anyone help me out here?

Upvotes: 2

Views: 208

Answers (1)

KbiR
KbiR

Reputation: 4174

Use name_get function.

Ex:

@api.multi
@api.depends('name', 'state')
def name_get(self):
    result = []
    for move in self:
        if move.state == 'draft':
            name = '* ' + str(move.id)
        else:
            name = move.name
        result.append((move.id, name))
    return result

Hope it will help you.

Upvotes: 3

Related Questions