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

from Approval Request when a Purchase related request like: Create RFQ's is approved i want to create record(s) in Internal Transfer (stock.picking -parent- and stock.move -child-) with all approval product line records using Automation Rules. i don't know how to create records using python code and if there is something to override Create method here for stock.picking and stock.move?

please help.

Note: see my working in below comment.

regards


아바타
취소
작성자

i have tried below code to achieve:

Python Code Block in Automation Rule Action

if record.request_status=='new':
#raise UserError(record.create_date)

# if not record.create_date:
sequncecode = 'appr.sequence.'+record.x_abbreviation
# print(sequncecode)
seq = env['ir.sequence'].next_by_code(sequncecode)
# name_length = len(seq)
record.write({'name': seq})

# Create stock.picking record
picking_data = {
'picking_type_id': 1,
'company_id': 1,
# Add other required fields
}
stock_picking = env['stock.picking'].create(picking_data)

above code is for:

1) in Approval Request have separate sequences by departments which working fine

2) create record in stock.picking, it creates records in stock.picking but creates 2 records instead of 1

when adding code below for stock.move after stock.picking code it is throwing error as below.

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

error for stock.move:

ValueError: <class 'AttributeError'>: "'approval.request' object has no attribute 'approval_product_line'" while evaluating

please help.

regards

베스트 답변

Hi Smith,

If you are using the Enterprise edition of Odoo, you can utilize the Studio module to set up automated actions for creating records in the stock.picking or stock.move models when a purchase order (PO) is created. For guidance on setting up automated action workflows, you can refer to the following documentation:

Automated Actions - Odoo Documentation


Hope it helps

아바타
취소
작성자

thank you to consider for help. it has already been resolved before at least 20 days ago.

관련 게시물 답글 화면 활동
2
8월 24
953
2
7월 24
1516
1
1월 24
1388
2
12월 23
2084
1
5월 24
1538