Skip to Content
Menu
This question has been flagged
1 Reply
1367 Views

i have created an Automation Rule which works fine to generate Internal Transfer records, please refer to my topic below:

https://www.odoo.com/forum/help-1/v17-create-parent-child-record-in-another-table-on-save-242128

now i want to call or redirect to Internal Transfer view for this created record after creating the record which open form with it, kindly help how it can be done?

regards


Avatar
Discard
Author

don't know why my most of the Questions are unAnswered during last one month... please if i have asked wrong question or trying to do in wrong direction, at least inform me for how to.
regards

Author

i have tried this code to open Internal Transfer form view and admitting that this is wrong or wrong way to do this. please check and correct me.

i have copied the code from existing one to Create RFQ's and it also needs to correct.

# below code to open the form i copied from existing code
# which opens Purchase Order form view
# --------------------------------------------
def show_form():
purchase_ids = record.product_line_ids.purchase_order_line_id.order_id.ids
domain = [('id', 'in', purchase_ids)]
return {
'name': _('Internal Transfer Entries'),
'view_type': 'tree',
'view_mode': 'list,form',
'res_model': 'stock.picking',
'type': 'ir.actions.act_window',
'context': self.env.context,
'domain': domain,
}

regards

Author

it SEEMS no one can help for this requirement ??

Best Answer

Hi


Hope everything  is well


Default  code open the tree view right?


But you want to open form view is this correct? 

Avatar
Discard
Author

yes, to open / show newly created record.

you can right like below
return {
'name': _('Internal Transfer Entries'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.picking',
'type': 'ir.actions.act_window',
'context': self.env.context,
'res_id': record_id.id,
}
you can try this this will direct open form view of any record and you need to pass record_id in record_id.id
thanks

Author

thanks a bunch @Sachin, add this with my code and confirm.

Author

hi @Sachin
i have modified function with what you posted here as below but its not working... please all my code is in previous thread as mentioned link in my opening post, please check , i think i am being confusing. is there any need to call this function or i am missing something?

def show_form():
purchase_ids = record.product_line_ids.purchase_order_line_id.order_id.ids
domain = [('id', 'in', purchase_ids)]
return {
'name': _('Internal Transfer Entries'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.picking',
'type': 'ir.actions.act_window',
'context': self.env.context,
'res_id': record_id.id,
}

Record_Id is the transfer id that you want to open please assign correct transfer record to record_id

Author

@Sachin thank you for your passion to help me. here is my complete code for Automation Rules, please check still its not working.

if record.request_status=='approved' and record.category_id.id in [11, 13]:
new_stock_picking = env['stock.picking'].create({
'picking_type_id': 5,
'company_id': 1,
'origin': record.name,
})

for approval_line in record.product_line_ids: # Assuming there's a related field linking approval request to lines
# Create stock.move record
move_data = {
'picking_id': int(new_stock_picking.id),
'picking_type_id': int(5),
'product_id': int(approval_line.product_id.id),
'product_uom_qty': int(approval_line.quantity),
'name': str(approval_line.product_id.name),
'company_id': int(1),
# 'product_uom': int(1),
'location_id': int(1),
'location_dest_id': int(1),
# Add other required fields
}
stock_move = env['stock.move'].create(move_data)

def show_form():
# purchase_ids = record.product_line_ids.purchase_order_line_id.order_id.ids
# domain = [('id', 'in', purchase_ids)]
return {
'name': _('Internal Transfer Entries'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.picking',
'type': 'ir.actions.act_window',
'context': self.env.context,
'res_id': new_stock_picking.id,
# 'domain': domain,
}

regards

Related Posts Replies Views Activity
4
May 25
2099
2
May 25
5419
1
Mar 25
1339
4
Mar 25
4115
3
Feb 25
5060