Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3444 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 24
917
2
thg 7 24
1479
1
thg 1 24
1350
2
thg 12 23
2045
1
thg 5 24
1498