# -*- coding: utf-8 -*-
##############################################################################
#
#    Odoo, Open Source Management Solution
#    Copyright (C) 2016-TODAY Prime Consulting SA, Cape Verde (<http://prime.cv>).
#
##############################################################################

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, _

import odoo.addons.decimal_precision as dp

class EcomEbusiness(models.Model):
    _inherit = 'ecom.ebusiness'

    #JCF - 22-06-2017
    @api.one
    @api.depends('contract_ebusiness_ids')
    def _get_contracts_data(self):
        if not self.contract_ebusiness_ids:
            return {}
        res = {}
        start_date = False
        for ebusiness in self:
            if ebusiness.contract_ebusiness_ids:
                for contract in ebusiness.contract_ebusiness_ids:
                    start_date=contract.start_date
        self.contract_start_date=start_date

    occupancy_rate = fields.Float('Ocuppancy Rate')
    market_share_rate = fields.Float('Market Share Rate')
    goal_rate = fields.Float('Goal Rate')
    contract_start_date = fields.Date('Contract start date', compute='_get_contracts_data', store=True)
