Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Odoo 9: how can i set specific value of a custom many2one filed base on the value of other filed on other module?

By
thanhthuansteel
on 11/22/16, 8:34 AM 79 views

Hello everyone, could you guy please help me to answer: Is is possible to use the value of bom_id(bill of masterial) to automatically set the value of a custom many2one filed in 'sale.order.line'? and how to get the purpose? 

0
thanhthuansteel
On 11/25/16, 10:15 PM
class SaleLine(models.Model):
    _inherit = "sale.order.line"
 width_id = fields.Many2one('sale.order.line.width')
 lng = fields.Float(default=1)
formula = fields.Char(compute='_get_formula', )
 unit_id = fields.Many2one('product.uom')
 quantity_extra = fields.Float(default=1)
 quantity_sum = fields.Float(compute='_compute_quantity', store=True)

Where is the related field define?

Chandni
on 11/28/16, 1:23 AM
0
Chandni
On 11/22/16, 10:25 AM

Hi,

You can make that custom field related to that bom_id field, than it will automatically get id from relation.

Field Definition: custom_id = fields.Char(related="bom_id.custom_id",store=True)

custom field should be there in object where you have to put relation.

Thanks,

where need i put the related field? the at the mrp.bom or my custom model?

thanhthuansteel
on 11/22/16, 10:07 PM

On your custom model.

Chandni
on 11/23/16, 5:50 AM

thank you, i will try it first but i can not forgot to say thank you friends

thanhthuansteel
on 11/23/16, 5:54 AM

i have try but it seem doesn't work, moreover my original purpose is when put a product_id in order line, the system will automatically check it, and if the product_id is set with bom_id then the custom field will be called, if not so the custom field should be ignored

thanhthuansteel
on 11/23/16, 6:04 AM

Need to check your code. How u have configure it and set the field.!!!!

Chandni
on 11/25/16, 1:28 PM

the code is showed as following answer.thank for your help

thanhthuansteel
on 11/25/16, 10:10 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/22/16, 8:34 AM
Seen: 79 times
Last updated: 11/25/16, 10:15 PM