Created
April 2, 2015 14:50
-
-
Save converge/ef06ebfcc2fa1624b317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nfe_export_txt(self, cr, uid, ids, nfe_environment='1', context=False): | |
StrFile = '' | |
StrNF = 'NOTA FISCAL|%s|\n' % len(ids) | |
StrFile = StrNF | |
for inv in self.browse(cr, uid, ids, context={'lang': 'pt_BR'}): | |
#Endereço do company | |
company_addr = self.pool.get('res.partner').address_get(cr, uid, [inv.company_id.partner_id.id], ['default']) | |
company_addr_default = self.pool.get('res.partner.address').browse(cr, uid, [company_addr['default']], context={'lang': 'pt_BR'})[0] | |
#nfe_key = unicode(company_addr_default.state_id.ibge_code).strip().rjust(2, u'0') | |
#nfe_key += unicode(datetime.strptime(inv.date_invoice, '%Y-%m-%d').strftime(u'%y%m')).strip().rjust(4, u'0') | |
#nfe_key += re.sub('[%s]' % re.escape(string.punctuation), '', inv.company_id.partner_id.cnpj_cpf or '') | |
#nfe_key += inv.fiscal_document_id.code | |
#nfe_key += unicode(inv.document_serie_id.code).strip().rjust(3, u'0') | |
#nfe_key += unicode(inv.internal_number).strip().rjust(9, u'0') | |
#fe_key += unicode('1').strip().rjust(1, u'0') # Homologação | |
#nfe_key += unicode(inv.internal_number).strip().rjust(8, u'0') | |
#nfe_key += unicode(self.nfe_dv(nfe_key)).strip().rjust(1, u'0') | |
StrA = 'A|%s|%s|\n' % ('3.10', '') | |
StrFile += StrA | |
StrRegB = { | |
'cUF': company_addr_default.state_id.ibge_code, | |
'cNF': '', | |
'NatOp': normalize('NFKD',unicode(inv.cfop_ids[0].small_name or '')).encode('ASCII','ignore'), | |
'intPag': '2', | |
'mod': inv.fiscal_document_id.code, | |
'serie': inv.document_serie_id.code, | |
'nNF': inv.internal_number or '', | |
# jp | |
#'dEmi': inv.date_invoice or '', | |
'dhEmi': inv.date_invoice + 'T' datetime.now() + '-03:00' or '', | |
# jp | |
#'dSaiEnt': inv.date_invoice or '', | |
#'hSaiEnt': '', | |
'tpNF': '', | |
# jp | |
# verificar se pode ser sempre 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment