# -*- coding: utf-8 -*-
###############################################################################
#
#    Tech-Receptives Solutions Pvt. Ltd.
#    Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
#    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 <http://www.gnu.org/licenses/>.
#
###############################################################################

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 EcomEbusinessType(models.Model):

    @api.multi
    @api.depends('name', 'parent_id')
    def name_get(self):
        result = []
        for location in self:
            name = location.name
            if location.parent_id:
                name = location.parent_id.name+' / '+name
            result.append((location.id, name))
        return result

    def _ebusiness_type_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
        res = self.name_get(cr, uid, ids, context=context)
        return dict(res)

    _name = 'ecom.ebusiness.type'
    _order="name asc"

    name = fields.Char(string='Name', required=True, translate=True)
    complete_name = fields.Char(string='Complete Name', store=True, compute='_ebusiness_type_name_get_fnc')
    parent_id = fields.Many2one('ecom.ebusiness.type', string='Belongs To', required=False)
    ordering = fields.Integer(string='Order')
    code = fields.Char(string='Code', size=16)
    image = fields.Binary(string='Image')

