İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1433 Görünümler

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
Vazgeç
Üretici

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

Üretici

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

Üretici

it SEEMS no one can help for this requirement ??

En İyi Yanıt

Hi


Hope everything  is well


Default  code open the tree view right?


But you want to open form view is this correct? 

Avatar
Vazgeç
Üretici

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

Üretici

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

Üretici

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

Üretici

@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

İlgili Gönderiler Cevaplar Görünümler Aktivite
4
May 25
2375
2
May 25
5723
1
Mar 25
1573
4
Mar 25
4361
3
Şub 25
5338