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

Hi, anyone can teach me how to remove/delete value? I need an example.

logging.info('Creating warehouse routes ...')

odoo = get_session()

wh_route_obj = odoo.env['stock.location.route']

config = {}

config['name'] = 'Manufacture'

config['sequence'] = 5

wh_route_obj.create(config)


These are the code I create the value, I need an example to learn how to delete it (Not remove this code) 
Very appreciate if anyone can help me, thanks

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

odoo = get_session()

wh_route_obj = odoo.env['stock.location.route']

config = {}

config['name'] = 'Manufacture'

config['sequence'] = 5

val = wh_route_obj.create(config)

#Delete

try:

  val.unlink()

except:

  val.sudo().unlink() 

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

Thanks Hilar, sorry for my poor coding skill, the python showed me "AttributeError: 'int' object has no attribute 'unlink()

Am I suppose to import some library that support the method unlink()?


logging.info('Creating warehouse routes ...')

odoo = get_session()

wh_route_obj = odoo.env['stock.location.route']

config = {}

config['name'] = 'Manufacture'

config['sequence'] = 5

val = wh_route_obj.create(config)

val.unlink


Another is what if I want to delete the default value that created in unknown module? How I can unlink it without know where the code is? 


Thanks alot for you answer just now, it take a step for me to understand odoo configuration, sorry for cannot do comment in your answer due to not enough karma point. 

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

here val should be a browsable record like stock.location.route(1), hence we can delete using the method val.unlink(), if it is an integer 1, then try odoo.env['stock.location.route'].unlink([1])

Tác giả

Hi Hilar!, the link's example you sent me and the odoo documentation is really helpful, now I can modify them instead deleted them, I will refer the documentation more about it, thanks alot! :)

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 17
6296
1
thg 2 25
1266
12
thg 9 22
45030
15
thg 9 21
41983
2
thg 2 21
3081