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

I am working on a meeting room reservation module on Odoo I am trying to compare the date that I am about the insert with the dates that I have in the database. i tried the search(), the browse() functions i also tried to iterate on the recordset but it always points on the record that i am about to insert. i was thinking about doint it through an SQL query but i can't find the table's name where the data is stored.

Here is the class definition:

class Reservation(models.Model):
    _name = 'module001.reservation'

    name = fields.Char(String="Reservation Number", required=True)
    start_date = fields.Datetime(default=fields.Date.today)
    room_number = fields.Many2one('module001.room', ondelete='cascade', string="Room", required=True)
    reserved_for = fields.Many2one('res.partner', string="Reserved for ")
    end_date = fields.Datetime(string="End Date", store=True)

Thank you in advance

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
def write(self, cr, uid, ids, values, context=None):
    print "NEW DATE:", values.get('start')
    print "OLD DATE:", self.browse(cr, uid, ids[0], context).start

Just tested, and it works !


Else, your table name should be module001_reservation... but it's better to use orm for it ...

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

i got it done using SQL, Thank you for your help !

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 4 23
38644
0
thg 12 21
2635
2
thg 2 19
9909
14
thg 12 17
101669
0
thg 9 17
2757