Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to compare dates before validation

By
Tarik Tourougui
on 2/13/16, 3:25 PM 714 views

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

1

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2993
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 2/13/16, 3:59 PM
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 ...

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

Tarik Tourougui
on 2/14/16, 1:49 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/13/16, 3:25 PM
Seen: 714 times
Last updated: 2/14/16, 1:46 PM