This question has been flagged
2 Replies
8811 Views

I need the show a list of Language name in model language.language in Report of product.

and here is my many2many field.

'product_marketing_languages_ids' : fields.many2many('languages.languages', 'product_marketing_languages', 'product_id', 'language_id', 'Marketing Languages'),

and this is the model of product_marketing_languages:

class product_marketing_languages(osv.osv):
    _name = 'product.marketing.languages'
    _columns = {
        'product_id' : fields.many2one('product.product', 'Product Marketing'),
        'language_id' : fields.many2one('languages.languages', 'Language', required = True),
    }

I have try this

[[repeatIn(objects,'o')]]
[[ o.product_marketing_languages_ids,'line' ]]

and it's show : ([browse_record(languages.languages, 145), browse_record(languages.languages, 146)])

and could you tell me how to get the name field in languages.languages using lambda? could anyone help me please?

Avatar
Discard

[[repeatln(objects,'o')]], [[repeatln(o.product_marketing_languages_ids,'line')]], [[line.name]], After all these commands given in your rml report you will get your answer

Best Answer

Hello,

As it shows you, it shows a list of browse records from the language.language ...

so it is two steps to achieve the names ....

[[ repeatIn(objects, 'o') ]]
    [[ repeatIn(o.product_marketing_languages_ids,'line') ]]

now the 'line' contains the language.language attributes, so if language.language contains field called [name], you can access it via:

[[ line.name ]]

personal notice:

on m2m relation the OpenERP will automatically create the third table for you... so you don't need to write the product_marketing_languages model by your self, and usually the table name ended with _rel so it could be :

'product_marketing_languages_ids' : fields.many2many('languages.languages', 'product_marketing_languages_rel', 'product_id', 'language_id', 'Marketing Languages'),

I hope this could helps you ...

Regards...

Avatar
Discard
Best Answer

hello, This are code, i hope it will help you.

<para style="terp_default_Right_9">[[ formatLang(product_marketing_languages_ids.name) ]]</para>

Thanks.

Avatar
Discard
Author

Thank you Ali, but this doesn't show anything.