Help

2

How to change Many2one Field(Master Data) language according to customer language ?

Avatar
Manish Kumar Bohra

Hello Everyone,


I am facing a problem related to translated value updated in many2one field in wizard.

Basically My custom wizard language based on customer language in Customer Form. My all Field Value is updated but i am facing a problem related to Many2one.

My Master Table data:

English (Source Term)
Chinese (Converted Term)Translated Value

In many2one field value language  output on terminal is "Chinese" But In Field value it's show "ENGLISH" so any one suggest me how to solve this problem.

My Code Below :

form_name = fields.Many2one('consent.form', required=True,
default=lambda self: self.env['consent.form'].search([], limit=1))

and Wizard Action code Below(Py) :

def action_view_consent_form_wizard(self):
ir_model_data = self.env['ir.model.data']
try:
view_id = ir_model_data.get_object_reference('OPMG', 'view_consent_form_wizard')[1]
except ValueError:
view_id = False
res = {
'name': 'Consent Form',
'view_type': 'form',
'view_mode': 'form',
'views': [(view_id, 'form')],
'res_model': 'consent.customer.wizard',
'view_id': view_id,
'type': 'ir.actions.act_window',
# 'res_id': record,
'target': 'new',
'context': ctx,
}
return res

XML :

<record id="action_customer_consent_form_wizard" model="ir.actions.act_window">
<field name="name">Consent Form</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">consent.customer.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>

Thanks.



Avatar
Discard