Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
1420 Переглядів

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


Аватар
Відмінити
Автор

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

Автор

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

Автор

it SEEMS no one can help for this requirement ??

Найкраща відповідь

Hi


Hope everything  is well


Default  code open the tree view right?


But you want to open form view is this correct? 

Аватар
Відмінити
Автор

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

Автор

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

Автор

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

Автор

@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 Відповіді Переглядів Дія
4
трав. 25
2338
2
трав. 25
5678
1
бер. 25
1541
4
бер. 25
4325
3
лют. 25
5306