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

Hi,

I am newbie to Odoo and I am working on fleet module.

In that module there are 2 forms Vehicle and Vehicle Contract. There is a lookup of vehicle in vehicle contract form.

Task is: I have to print a list of all contracts made for a vehicle on a Vehicle form.


Thanks in advance

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

Hello Gaurav,

There is already contract state button in the vehicle form view and you can also see all the related contract with particular vehicles.

Thanks,

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

Thanks Jignesh,

Your solution solved my issue. I found one more solution.


def _get_vehicles(self, cr, uid, ids, fields, arg, context=None):

res = {}

#vehicle = self.env['fleet.vehicle']

for _obj in self.browse(cr, uid, ids, context=context):

#('vehicle_id','=', self.vehicle_id)

_orders = self.pool.get('fleet.vehicle.log.contract').search(cr, uid, [('vehicle_id','=',context.get('active_id', False))], context=context)

res[_obj.id] =_orders

return res


'vehicle_ids' : fields.function(_get_vehicles, string="Vehicles", type="many2many", relation='fleet.vehicle'),


<field name="vehicle_ids" nolabel="1" >


But loop is getting all the contracts not for a particular vehicle. Can you tell me, what I am missing?

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

Hello, See method return_action_to_open method in fleet.py of fleet module. you can get more idea. Thanks,

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 12 19
8786
1
thg 2 23
3838
1
thg 10 19
13258
2
thg 8 25
2854
1
thg 7 25
1159