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

Hi,

trying to upgrade a module from 10 to 14 and got stuck on the new required ondelete.

The module adds a value to a selectlist:

class ProviderConsignor(models.Model):

    _inherit = 'delivery.carrier'


    delivery_type = fields.Selection(selection_add=[('consignor', "Consignor")], ondelete={'consignor': 'set default'})


But when trying to install the module I get: ValueError: delivery.carrier.delivery_type: required selection fields must define an ondelete policy that implements the proper cleanup of the corresponding records upon module uninstallation. Please use one or more of the following policies: 'set default' (if the field has a default defined), 'cascade', or a single-argument callable where the argument is the recordset containing the specified option.

Tried with cascade and set null as well, but get the same message so I guess the syntas is wrong.


Thanks in advance. 

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

Hi,

You have to set the ondelete policy for the selection field. 

See a code sample:

my_selection = fields.Selection(selection_add=[
('pikachu', "Pikachu"),
('eevee', "Eevee"),
], ondelete={'pikachu': 'set default', 'eevee':'set default'})


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

Solved: the debug is mis-leading. The actual error was a view xml file that referred to old (v10) model. So be aware that the error reported during install may not be the root-cause. As always.

Ảnh đại diện
Huỷ bỏ

What did you do in the xml view? as it was referring to the old model? Please help. Running into the same issue as you faced.

What did you do? I'm having the same issue, please help.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 24
2263
1
thg 6 19
6819
3
thg 8 24
2064
1
thg 5 23
2680
4
thg 4 22
15321