콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
1553 화면

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

관련 게시물 답글 화면 활동
4
5월 25
2706
2
5월 25
6137
1
3월 25
1811
4
3월 25
4703
3
2월 25
5776