'Creates xml that is to be exported and sent to estate for partner vat intra.
:return: Value for next action.
:rtype: dict'

@api.multi
def create_xml(self):

    self.ensure_one()
    company = self.company_id
    if (not (company.partner_id and company.partner_id.country_id and company.partner_id.country_id.id)):
        self._company_warning(_('The    country    of    your    company    is    not    set,    please    make    sure    to    configure    it    first.'))
    if (not company.company_registry):
        self._company_warning(_('The    registry    number    of    your    company    is    not    set,    please    make    sure    to    configure    it    first.'))
    if (len(self.year) != 4):
        raise exceptions.Warning(_('Year    must    be    4    digits    number    (YYYY)'))
    decl = ET.Element('DeclarationReport')
    decl.set('xmlns', INTRASTAT_XMLNS)
    admin = ET.SubElement(decl, 'Administration')
    fromtag = ET.SubElement(admin, 'From')
    fromtag.text = company.company_registry
    fromtag.set('declarerType', 'KBO')
    ET.SubElement(admin, 'To').text = 'NBB'
    ET.SubElement(admin, 'Domain').text = 'SXX'
    if (self.arrivals == 'be-standard'):
        decl.append(self.sudo()._get_lines(dispatchmode=False, extendedmode=False))
    elif (self.arrivals == 'be-extended'):
        decl.append(self.sudo()._get_lines(dispatchmode=False, extendedmode=True))
    if (self.dispatches == 'be-standard'):
        decl.append(self.sudo()._get_lines(dispatchmode=True, extendedmode=False))
    elif (self.dispatches == 'be-extended'):
        decl.append(self.sudo()._get_lines(dispatchmode=True, extendedmode=True))
    data_file = ET.tostring(decl, encoding='UTF-8', method='xml')
    self.write({'name': ('intrastat_%s%s.xml' % (self.year, self.month)), 'file_save': base64.encodestring(data_file), 'state': 'download'})
    return {'name': _('Save'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'l10n_be_intrastat_xml.xml_decl', 'type': 'ir.actions.act_window', 'target': 'new', 'res_id': self.id}
