I have a situation that whenever I tried to open the wizard i want my data back in the one2many fields since for the parent is working fine it is loading the data by using _default as a prefix over every fields but what if i want to load the data in the grid(One2many) also
# Here is the Main class
class batch_wise_allocation(models.TransientModel):
_name = 'batch.wise_allocation'
_table = 'batch_wise_allocation'
_description = 'Batch Wise Allocation'
product_id= fields.Many2one('product.product', string="Product")
dispatch_line_id = fields.Integer(string= 'Dispatch Line ID')
main_id= fields.One2many('batch.wise_allocation_line','batch_allocation_line_id',string= 'Allocation Line ID')
#Here is the child class
class batch_wise_allocation_line(models.TransientModel):
_name = 'batch.wise_allocation_line'
_table = 'batch_wise_allocation_line'
_description = 'Batch Wise Allocation Line'
batch_allocation_line_id= fields.Many2one('batch.wise_allocation', string="Batch Allocation ID")
batch_id= fields.Many2one('pra.batch_master',string= 'Batch No')
batch_name=fields.Char('Batch Name')
batch_size= fields.Float('Batch Size')
batch_qty=fields.Float('Batch Qty')
dispatch_qty= fields.Float('Dispatch Qty')
packing_details= fields.Char('Packing Details')
#########
And this is the class from where I want to load the batch_list and the batch_wise_dispatch automatically if it is entered before while opening the wizard
class DispatchLine(models.Model):
_name = 'pra.dispatch_line'
_table = 'pra_dispatch_line'
_description = 'Sales Dispatch Line'
def action_dispatch_qty_transfer(self, cr, uid, ids, context=None):
pra_dispatch_line = self.browse(cr, uid, ids[0], context=context)
return {
'name': ('Batch Allocation'),
'view_type':'form',
'view_mode':'form',
'res_model': 'batch.wise_allocation',
'view_id':False,
'type':'ir.actions.act_window',
'target':'new',
'context': {'default_dispatch_line_id':pra_dispatch_line.id,
'default_product_id':pra_dispatch_line.product_id.id,
#How can I add here the default for the One2many fields------????
},
}
batch_list = fields.Text(string= 'Batches',readonly=1)
batch_wise_dispatch = fields.Text(string= 'Batch Wise Dispatch',readonly=1)
#############################################
'''Very thanks to Dan Čermák for the last 2 answer it was really very wonderful'''
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ờ
3477
Lượt xem
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 6 24
|
442 | ||
|
1
thg 2 16
|
4953 | ||
|
1
thg 9 23
|
2264 | ||
|
2
thg 9 24
|
13379 | ||
|
2
thg 10 22
|
21498 |