Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
3113 Vistas

i have a table coa_ledgers (id, name, ledger_acc etc.)

for my banks i want to have a field ledger_acc which should type of Many2one to select from coa_ledgers and return the value of field ledger_acc instead of id

how i can achieve this, can i mention field name to be return then How To or something else?

please help.

 ledger_acc = fields.Many2one('coa_ledgers', string='Ledger A/c')

regards 

Avatar
Descartar
Mejor respuesta

Hi,

To achieve the desired functionality where the Many2one field 'ledger_acc' in your Odoo model returns the value of the 'ledger_acc' field instead of the ID of the selected record from the 'coa_ledgers', you can use the 'name_get' method:

class CoaLedgers(models.Model):
_name = 'coa_ledgers'

name = fields.Char(string='Name')
ledger_acc = fields.Char(string='Ledger A/c')

def name_get(self):
result = []
for record in self:
name = record.ledger_acc
result.append((record.id, name))
return result

Regards

Avatar
Descartar
Autor

thanks, but may be i failed to convery the problem OR may be i failed to understand what solution you have posted here.
anyway there are 2 things when it populates dropdown list (Many2one), (1) a display value and (2) a return value
i am asking about Return Value which will save in current Many2one field to make relation / reference to its parent model.
hope that clear.
very sorry for any inconvenience.
regards

Autor

@Cybrosys Techno Solution
waiting for your response on my comment posted yesterday.
regards

Autor Mejor respuesta

@Admin @Moderator 

what is problem with this forum? i can't get Answer to my problems then How I Can recommend Odoo 

nobody even trying to inform how i can get Answer or at least like: this is not possible yet in Odoo 

on of my previous topic regarding Parent-Child (Master-Detail) not yet Answered by seniors here, nobody is able to say "no, this is not possible" etc. can anyone please guide that from where i can get help and resolve my problems? 

i think simple Comment is not able to inform someone here that this thread/toipic is updated. and also i faced posting the Error text and my code, i request to Delete a post due to this problem and ask to guide me for How To's but simply post Deleted silently, because this is simple and nobody helped for How To's because this was not possible for him.


regards

Avatar
Descartar

Hi,
This is a public forum, where it is not ensured to answer and all solve your all issues. As all forums, people may help if they feel it is easy for them, there are lot of questions which is answered and answered.

If the question is easy and straightforward, the chance of getting answered is high, else people wont spend much time to resolve your issues.

Incase if you feel the forum is not helpful much and need more support, you may seek dedicated support from any sort of support channels.

Publicaciones relacionadas Respuestas Vistas Actividad
1
may 23
3382
1
abr 24
1432
2
feb 24
2046
3
dic 23
5645
1
ago 23
2743