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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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?
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?
On your custom model.
thank you, i will try it first but i can not forgot to say thank you friends
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
Need to check your code. How u have configure it and set the field.!!!!
the code is showed as following answer.thank for your help
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
2
thg 12 18
|
2768 | ||
|
3
thg 7 24
|
4403 | ||
|
1
thg 9 23
|
6345 | ||
|
3
thg 3 23
|
6306 | ||
|
1
thg 1 22
|
11959 |