vendor = fields.Many2one('product.supplierinfo', 'Vendors', domain="[('product_tmpl_id', '=', product_id.id)]")
@api.onchange('product_id')
def onchange_product(self):
if self.product_id:
self.product_desc = self.product_id.name
# self.vendor_ids = [(6, 0, [seller.name.id for seller in self.product_id.seller_ids])]
self.vendor_ids = [(6, 0, self.product_id.seller_ids.ids)]
print('self.vendor_ids',self.vendor_ids)
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ờ
Hi,
Please try this code:vendor_ids = fields.Many2many('product.supplierinfo', 'Vendors', compute='_compute_vendor_ids')
vendor = fields.Many2one('product.supplierinfo', 'Vendors', domain="[('id', 'in', vendor_ids)]")
@api.depends('product_id')
def _compute_vendor_ids(self):
for record in self:
if record.product_id:
record.product_desc = record.product_id.name
value = [data.id for data in record.product_id.seller_ids if data]
if value:
record.vendor_ids = value
Hope it helps
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 | |
---|---|---|---|---|
|
1
thg 9 25
|
2009 | ||
|
1
thg 6 25
|
2031 | ||
|
3
thg 7 25
|
3616 | ||
|
1
thg 5 25
|
1744 | ||
|
4
thg 5 25
|
3072 |