Exemple #1
0
 def _send_invoice_to_sii(self):
     for invoice in self.filtered(
             lambda i: i.state in ['open', 'paid'] and i.is_sii_mapped):
         if invoice.type in ['out_invoice', 'out_refund']:
             wsdl = invoice._get_wsdl('l10n_es_aeat_sii.wsdl_out')
             port_name = 'SuministroFactEmitidas'
             operation = 'SuministroLRFacturasEmitidas'
         elif self.type in ['in_invoice', 'in_refund']:
             wsdl = invoice._get_wsdl('l10n_es_aeat_sii.wsdl_in')
             port_name = 'SuministroFactRecibidas'
             operation = 'SuministroLRFacturasRecibidas'
         if not invoice.sii_sent:
             tipo_comunicacion = 'A0'
         else:
             tipo_comunicacion = 'A1'
         header = invoice._get_header(tipo_comunicacion)
         try:
             invoices = invoice._get_invoices()
         except Exception as fault:
             new_cr = RegistryManager.get(self.env.cr.dbname).cursor()
             env = api.Environment(new_cr, self.env.uid, self.env.context)
             self.with_env(env).sii_send_error = fault
             new_cr.commit()
             new_cr.close()
             raise
         try:
             res = invoice._send_soap(wsdl, port_name, operation, header,
                                      invoices)
             # TODO Facturas intracomunitarias 66 RIVA
             # elif invoice.fiscal_position.id == self.env.ref(
             #     'account.fp_intra').id:
             #     res = serv.SuministroLRDetOperacionIntracomunitaria(
             #         header, invoices)
             if res['EstadoEnvio'] in ['Correcto', 'ParcialmenteCorrecto']:
                 self.sii_sent = True
                 self.sii_csv = res['CSV']
                 if 'FechaRegContable' in invoices:
                     if not self.sii_registration_date:
                         self.sii_registration_date = \
                             self._change_date_format(fields.Date.today())
             else:
                 self.sii_sent = False
             self.env['aeat.sii.result'].create_result(
                 invoice, res, 'normal', False, 'account.invoice')
             send_error = False
             res_line = res['RespuestaLinea'][0]
             if res_line['CodigoErrorRegistro']:
                 send_error = u"{} | {}".format(
                     unicode(res_line['CodigoErrorRegistro']),
                     unicode(res_line['DescripcionErrorRegistro'])[:60])
             self.sii_send_error = send_error
         except Exception as fault:
             self.env['aeat.sii.result'].create_result(
                 invoice, False, 'normal', fault, 'account.invoice')
             self.sii_send_error = fault
Exemple #2
0
def migrate(cr, version):
    registry = RegistryManager.get(cr.dbname)
    from flectra.addons.account.models.chart_template import migrate_set_tags_and_taxes_updatable
    migrate_set_tags_and_taxes_updatable(cr, registry, 'l10n_sg')
def migrate(cr, version):
    registry = RegistryManager.get(cr.dbname)
    from flectra.addons.account.models.chart_template import migrate_tags_on_taxes
    migrate_tags_on_taxes(cr, registry)