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
- Бухгалтерия
- Склад
- PoS
- Project
- MRP
Этот вопрос был отмечен
            
                3977
                
                    Представления
                
            
        
    Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Регистрация| Related Posts | Ответы | Просмотры | Активность | |
|---|---|---|---|---|
|  | 1 июн. 24  | 443 | ||
|  | 1 февр. 16  | 5609 | ||
|  | 1 сент. 23  | 2754 | ||
|  | 2 сент. 24  | 14050 | ||
|  | 2 окт. 22  | 22394 | 
