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

Hi everyone.


I'm trying to do a server action that call another server action but with different model.


The model of my first action is purchase.order, which contains the lines of code 


    stock_landed_cost_line = record.env['stock.landed.cost.lines'].create(
    {
    'cost_id': stock_landed_cost_id.id,
    'product_id': 7,
    'account_id': 366,
    'split_method': 'by_current_cost_price',
    'price_unit': abs(price_landed_cost)
    })

    action = { "type": "ir.actions.server", "id": 640, "model_id": 426, }


My second server action has the id = 640 and the model of this one is stock.landed.cost, it's simple and the line of code is


record.compute_landed_cost()


At the moment that I trigger the first action, the next error appears:


AttributeError: 'NoneType' object has no attribute 'compute_landed_cost'


Am I doing something wrong? What is the appropriate way to trigger one server action from another server action?


Thanks for your help!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Instead of calling another server action, if it has only single line of code, can you directly call it here.

Instead of this line:   action = { "type": "ir.actions.server", "id": 640, "model_id": 426, }  , you can make a call like this:   stock_landed_cost_id.compute_landed_cost()


Thanks

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

It works! Thank you!

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 24
1379
0
thg 5 24
26
1
thg 4 24
4764
0
thg 3 24
1685
0
thg 3 24
1710