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

Hi,

I have two models.

class HotelFolio(models.Model):

_name = 'hotel.folio'

reservation_id = fields.Many2one('hotel.reservation', string='Reservation Id')

class HotelReservation(models.Model):

_name = "hotel.reservation"

folio_id = fields.Many2many('hotel.folio', 'hotel_folio_reservation_rel', 'order_id', 'invoice_id', string='Folio')

In the xml view file i do this :

<act_window name="Portefolio"          
context="{'default_folio_id': active_id, 'search_default_folio_id': active_id}"
res_model="hotel.folio"
src_model="hotel.reservation"
id="act_folio"/>
<button class="oe_stat_button" name="%(act_folio)d" icon="fa-money" string="Portefolio" type="action">

My need is is to get the hotel.folio instance related to the hotel.reservation instance. But when i click on the button i get all hotel.folio available in the database. May be i write wrong context.

Thanks for your help.













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

I add in my act_window record this domain and every thing run well.

domain="[('reservation_id', '=', active_id)]"
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Dear Koffo,

Try this Domain:

<field name="folio_id" domain="[('id','=',context.get('default_folio_id',False))]" />

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 1 21
2231
0
thg 3 15
4985
3
thg 5 24
7239
0
thg 8 18
32466
5
thg 3 15
9730