# -*- coding: utf-8 -*- ############################################################################### # # Tech-Receptives Solutions Pvt. Ltd. # Copyright (C) 2009-TODAY Tech-Receptives(). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # ############################################################################### from odoo.osv import expression from odoo.tools.float_utils import float_round as round from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT from odoo.exceptions import UserError, ValidationError from odoo import api, fields, models, _ class EtourismBookingCondition(models.Model): _name = 'etourism.booking.condition' _description = "Booking Conditions" name = fields.Char(string='Name', required=True) description = fields.Text(string='Description') enterprise_id = fields.Many2one('etourism.enterprise', string='Enterprise', required=True) has_default_enterprise = fields.Boolean('Has Default Enterprise', help="True, if User creating Booking group has related Enterprise.") type_code = fields.Char(related="enterprise_id.type_id.code", string='Ebusiness Type', store=True) @api.model def default_get(self, fields): res = super(EtourismBookingCondition, self).default_get(fields) if self.env.uid: enterprise_id = self.env['res.users'].browse([self.env.uid])[0].enterprise_id if enterprise_id: res.update({'enterprise_id': enterprise_id.id, 'has_default_enterprise': True}) return res # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: