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
この質問にフラグが付けられました
3479
ビュー
関連投稿 | 返信 | ビュー | 活動 | |
---|---|---|---|---|
|
1
6月 24
|
442 | ||
|
1
2月 16
|
4953 | ||
|
1
9月 23
|
2264 | ||
|
2
9月 24
|
13379 | ||
|
2
10月 22
|
21498 |