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

from odoo import models, api

class AccountMove(models.Model):
    _inherit = "account.move"

    @api.model
    def create(self, vals):
        """Set Journal Entry number (consequently related Invoice no) generated using Enterprise sequence code for Invoices with Enterprise & Booking Group.
        """
        if not vals:
            vals = dict()
        context = self._context or {}
        if context.get('invoice', ''):
            invoice = context['invoice']
            if invoice.enterprise_id:
                vals['name'] = self.create_uid.etourism_get_next_sequence('INV', 'account.move', 'name', invoice.enterprise_id.id)
        return super(AccountMove, self).create(vals)