This question has been flagged
2 Replies
1802 Views

Hi

I have a difficulty for product translation .As i understood when you translate the product in the sales order will not show it unless customer language is set to that language up to here everything if fine but some time our customer will ask for Arabic SO and some time English so before creatie any SO if you change the language it is fine but after creation there isn't any way to update it to any other language. i want to create an automated action to update the sales order line when its triggered i was wondering if someone can help me to solve this problem.

Avatar
Discard
Best Answer

Hello Kamran Lalehparvar

I have reproduced your issue and found solution as below.

Actually when you select product on sale order line, description field is filled with product's description as per customer's langauge. then after if you change langauge that field's value will not update unless you trigger onchange of product on sale order line.

i have created server action to update order line's description as per customer langauge. please have a look below server action.



for rec in records.mapped('order_line'):
rec.product_id_change()

Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat


Avatar
Discard
Author

Hi
Its working i really appreciate it.

Author

Hello Again
By the way i have tried to make it for invoice as well with following code:

for rec in records.mapped('invoice_line_ids'):
rec.product_id_change()
but it seems there is a problem i was wondering if you can help me . thanks in advance

please try following python code as account.move object has o2m field "invoice_line_ids" of accout.move.line and that module has _onchange_product_id() onchange method.

for rec in records.mapped('invoice_line_ids'):
rec._onchange_product_id()

Author

Hi
Good Morning
Thank you for your time. i have tried the code but there is problem. when i trying to change the language there is an error
You cannot add/modify entries prior to and inclusive of the lock date 31/12/2021.
but the current date is not before 31/12/2021
i was wondering if might be able to check.

Hello CandidRoot,

I tried adding this server action in odoo 16.0 from february 2024 but it's giving me this error:

AttributeError: 'sale.order.line' object has no attribute 'product_id_change'

I've checked the SaleOrderLine class (model) and indeed there's no such method anywhere.

What could be wrong? Is this in an old version of odoo?

Author Best Answer

Hi Peter

For V16 you can use this code
for order in records:

    partner_lang = order.partner_id.lang

    for line in order.order_line:

        display_name = line.product_id.with_context(lang=partner_lang).display_name

        sales_description = line.product_id.with_context(lang=partner_lang).description_sale


        line.update({'name': display_name + '\n' + sales_description})

Avatar
Discard