Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

manual invoice numbering

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
invoicesequence
1 Rispondi
12145 Visualizzazioni
Avatar
Ayhan KIZILTAN

How do I enter Invoice Numbers manually?

1
Avatar
Abbandona
Avatar
patrick
Risposta migliore

By default the invoice number is generated. If you want to ad it manually, you have to create a new module, which extends account_invoice, and you override the methods create and/or save.

But it is dangerous to type the invoice numbers manually, because you can forget it, you can skip numbers or use numbers multiple times.

Depending on the reason you want to type the numbers manually, it can already be done, or changed easily. If you can tell us the reason(s), we might be able to help you with it.

Example script:

# -*- coding: UTF-8 -*-
import openerplib
import datetime
import psycopg2

h = "localhost"
db= 'database'
u = "admin"
p = 'password'

h_sql = h
db_sql = db
u_sql = "openerp"
p_sql = "openerp"

line = '-' *45 + '\n'
file_dbo_factuur = 'dbo_Factuur.csv'
file_dbo_factuurregel = 'dbo_Factuurregels.csv'
f_result = 'factuur_Result.txt'
f_error = 'factuur_Error.csv'
file_finance = 'factuur_finance.csv'

invoiceAdded = 0
invoiceRejected = 0

################################################################################
## VARIOUS ROUTINES
################################################################################
def printHeading():
  f_res.write(line)
  dateX = str(datetime.datetime.now())
  f_res.write('-' * 10 + dateX+'\n')

def initConnection(h, db, u, p):
  printHeading()
  f_res.write('Connecting to %s \nuser: %s\ndatabase: %s\n' %(h, u, db))
  return openerplib.get_connection(
    hostname=h, database=db, login=u, password=p)

def addValsToDB(c, m, vals):
  printHeading()
  f_res.write('Adding data to %s\n' %(m))
  print 'Adding data to', m
  model = c.get_model(m)
  result = []
  i = 0
  for v in vals:
    result.append(model.create(v))
    i += 1
    x, y = divmod(i, 100)
    if y == 0:
      f_res.write('Added already %d records to %s\n' %(x*100, m))

  f_res.write('Number of records added: %d\n' %(len(result)))
  return result

def writeData(c, m, ids, vals):
  printHeading()
  f_res.write('Modifying data of model %s with id(s) = %s\n' %(m, ids))
  print 'Modifying data of model', m, 'with id =', ids
  model = c.get_model(m)
  return model.write(ids, vals)
################################################################################
## SCRIPT SPECIFIC ROUTINE(S)
################################################################################
def addInvoice(c, factuur, lines):
  global invoiceAdded
  global invoiceRejected

  #check invoice itself
  factuur_split = factuur.split(';')
  m = 'account.invoice'
  vals = []

# do your checks

  if sjoemel: #so old order
    resOrder = order_obj.onchange_partner_id(0, partner)['value']

    origin = 'Factuur %s, van order voor 2013' %(factuur_split[2])
    currency = factuur_split[9]
    if currency == '1': # Euro
      pass
    elif currency == '6': # USD
      currency = '3'
    elif currency == '7': # GBP
      currency = '152'

    fiscal = resOrder['fiscal_position']
    reference = factuur_split[30]
    user = 1 #fixed to admin
    payment = resOrder['payment_term']
    comment = factuur_split[13]

  else: #order uit 2013
    origin = order['name']
    currency = order['currency_id'][0]
    partner = order['partner_id'][0]
    if order['fiscal_position'] == False:
      fiscal = False
    else:
      fiscal = order['fiscal_position'][0]
    reference = order['client_order_ref']
    user = order['user_id'][0]
    payment = order['payment_term'][0]
    comment = order['note']

  agent = klant_agent.get(partner, False)
  agent_code = agent_id_code.get(agent, '')

  klant = partner_obj.read(partner)
  hb_inkoop_org = klant['hb_inkoop_org']

  vals.append({
    'origin': origin,
    'date_due': factuur_split[30],
    'check_total': 0.0,
    'partner_bank_id': False,
    'supplier_invoice_number': False,
    'paypal_url': False,
    'company_id': 1,
    'currency_id': currency,
    'partner_id': partner,
    'fiscal_position': fiscal,
    'user_id': user,
    'reference': reference,
    'message_is_follower': False,
    'payment_term': payment,
    'reference_type': 'none',
    'journal_id': 11,
    'account_id': 166,
    'type': 'out_invoice',
    'internal_number': 'Q:%s' %(factuur_split[2]),
    'reconciled': False,
    'move_name': '/',
    'section_id': False,
    'date_invoice': factuur_split[3],
    'name': factuur_split[29], #? 
    'comment': comment,
    'sent': False,
    'agent_id': agent,
    'agent_code': agent_code,
    'message_unread': False,
  })

  invoiceID = addValsToDB(connection, m, vals)[0]

  # add the various lines to the invoice.
  vals = []
  m = 'account.invoice.line'

  invoice_line_tax_id = []
  if fiscal == 1: #NL
    invoice_line_tax_id = [2]
#  elif fiscal == 2: # EU
  elif fiscal == 3: # EU
    invoice_line_tax_id = [15]
#  elif fiscal == 3: # Non EU
  elif fiscal == 4: # Non EU
    invoice_line_tax_id = [12]
  else:
    invoice_line_tax_id = [2]

  for line_split in resFactLines:
    orderlineOld = line_split[13]
    if orderlineOld:
      orderlineID = old_orderline_obj.search([('orderline_id', '=', line_split[3])])
      orderline = old_orderline_obj.read(orderlineID)[0]
      product = prod_obj.read(int(orderline['product_id']))
    else:
      orderlineID = orderline_obj.search([('hb_id_q', '=', line_split[3])])
      orderLine = orderline_obj.read(orderlineID)[0]
      product = prod_obj.read(orderLine['product_id'][0])

    priceArticle = float(line_split[6])

    vals.append({
    'origin': origin,
    'uos_id': 1,
    'asset_category_id': False,
    'account_id': 458,
    'name': product['name'],
    'sequence': 5,
    'invoice_id': invoiceID,
    'price_unit': priceArticle, 
     'company_id': 1,
    'invoice_line_tax_id': [[6, 0, invoice_line_tax_id]],
    'discount': line_split[4],
    'account_analytic_id': False,
    'quantity': line_split[5],
    'partner_id': partner,
    'product_id': product['id'],
  })

  factuurLineIDs = addValsToDB(connection, m, vals)

  # Validate invoice
  context = {}
  context['active_ids'] = [invoiceID]
  x = factuur_confirm_obj.invoice_confirm([invoiceID], context)

#start of script
f_factuur = open(file_dbo_factuur, 'r')
f_fout = open(f_error, 'a')
f_res = open(f_result, 'a')
startTime = str(datetime.datetime.now())
print startTime
f_fout.write('error code;Omschrijving;factuur;factuurID;order;orderregel\n')

#finance
f_fin = open(file_finance, 'w+')
f_fin.write('Factuur Q;bedrag Q;Factuur openERP;bedrag openERP;verschil (Q - OpenERP)\n')

connection = initConnection(h, db, u, p)
f_res.write('Connecting with SQL:\nuser: %s\ndatabase: %s\n' %(u_sql, db_sql))
conn_string = "dbname='%s' user='%s' password='%s'" %(db_sql, u_sql, p_sql)
conn_sql = psycopg2.connect(conn_string)
cursor = conn_sql.cursor()

# search partners with agent
statement = "select partner_id, agent_id from res_partner_agent"
klant_agent = {}
cursor.execute(statement)
result = cursor.fetchall()
for r in result:
    klant_agent[r[0]] = r[1]

statement = "select hb_id_q, id from res_partner"
partner_Q_id = {}
cursor.execute(statement)
result = cursor.fetchall()
for r in result:
    partner_Q_id[r[0]] = r[1]

f_factuur = open(file_dbo_factuur_nw, 'r')
f_factuurline = open(file_dbo_factuurregel, 'r')
# get rid of the headings
header_f = f_factuur.readline()
header_l = f_factuurline.readline()
# get the first entry of the factuurline
line_factuur = f_factuurline.readline()
numberOfLines = 1 #because of line above

factuur_obj = connection.get_model('account.invoice')
factuurline_obj = connection.get_model('account.invoice.line')
order_obj = connection.get_model('sale.order')
orderline_obj = connection.get_model('sale.order.line')
prod_obj = connection.get_model('product.product')
old_order_obj = connection.get_model('hb.order')
old_orderline_obj = connection.get_model('hb.order.line')
partner_obj = connection.get_model('res.partner')
#nodig om facturen te bevestigen....
factuur_confirm_obj = connection.get_model('account.invoice.confirm')

partner_q_id = {}
statement = "select hb_id_q, id from res_partner where customer = True"
cursor.execute(statement)
result = cursor.fetchall()
for r in result:
  partner_q_id[r[0]] = r[1]

partner_id_obj = {}

s = ''
numberOfRecords = 0

for factuur in f_factuur:
  lines = []

  numberOfRecords += 1
  factuur_result = factuur.split(';')
  if len(factuur_result) != lengte_f:
    print 'Factuur niet goede lengte. %s' %(factuur)
    continue
  s = factuur

  while s:
      if line_factuur == '\n': # end of file
        if len(lines) > 0:
          result = addInvoice(connection, s, lines)
        print 'Einde, wegens alleen \\n'
        break

      if line_factuur == '': # end of file?!
        if len(lines) > 0:
          result = addInvoice(connection, s, lines)
        print 'Einde, wegens lege regel'
        break

      if line_factuur == '\r\n': # zou niet mogen!
        print line_factuur
        print line_result

      line_result = line_factuur.replace('\n','').split(';')

      if factuur_result[0] < line_result[2]: #order lines later than order
        if len(lines) > 0:
          result = addInvoice(connection, s, lines)
        else:
          f_fout.write('06;Factuur %s zonder regels\n' %(factuur_result[0]))
        break

      if factuur_result[0] == line_result[2]: # order line part of order
        lines.append(line_factuur)

      line_factuur = f_factuurline.readline()
      numberOfLines += 1

  s = ''

print line
print 'Records:', numberOfRecords
print 'Lines  :', numberOfLines
print 'Invoices made in openERP:', invoiceAdded
print 'Invoices rejected by openERP:', invoiceRejected
print line

f_res.write(line+'\n')
f_res.write('Invoices read: %d\n' %(numberOfRecords))
f_res.write('Invoicelines read: %d\n' %(numberOfLines))
f_res.write('Invoices made in openERP: %d\n' %(invoiceAdded))
f_res.write('Invoices rejected by openERP: %d\n' %(invoiceRejected))
f_res.write(line+'\n')

eindTime = str(datetime.datetime.now())
f_fout.write(eindTime+'\n')
f_res.write(eindTime+'\n')
f_fin.write(eindTime+'\n')

f_fin.close()
f_fout.close()
f_res.close()

print eindTime
print 'einde'
print line
1
Avatar
Abbandona
Ayhan KIZILTAN
Autore

I want to enter the invoice numbers manually because I have to enter the invoices which I already created manually before I began to use OpenERP. So each invoice has its own sequences. After I complete all the previous invoice entries I will begin to use the invoice numbers generated by the software.

patrick

If needed, I can show a small script to do the import for you. Just let me know if you are interested. You want to place your own invoice number as account_invoice.internal_number. This field will be used to generate/display the invoice number

Ayhan KIZILTAN
Autore

Yes I am interested.

AJ Schrafel Paper Corp

i agree with patrick, importing the invoices is a much better idea than manually keying data.

Nagah El-Msiry

Dear I'm facing the same problem and i want to import invoices with pregenerated numbers as beginign balances, (will that affect accounting side also or i have to make entry with total balance ?)

SYNAP SYSTEM

The first thing I tried with OpenERP was editing old invoices (and still don't know how to do it). It seems that I may not be the only one...

AJ Schrafel Paper Corp

once an invoice is out of draft state, you cannot edit it. You need to either have your customer pay the invoice short and issue a credit memo to zero out the balance OR you need to issue a credit for the entire invoice and re-invoice at the correct amount. This is a basic principle of accounting that openERP must follow otherwise it would not be taken seriously as an accounting package.

SYNAP SYSTEM

By "old invoices" I doesn't mean "paid invoices". I mean "invoices which was edited out of OpenERP". Fact is that if we had already issued paper wrote invoices with manually-attributed reference numbers, it's not possible to create the same invoice in OpenERP with the same reference number, as it's automatically generated and not editable.

AJ Schrafel Paper Corp

You can load them directly into the database using pgadmin or custom scripting to put the information into the database. But this method might lead to unforeseen issues.

SYNAP SYSTEM

Of course! We can do anything this way... But the purpose of a framework is not to make us choose between "not doing something" and "doing it the bad way". OpenERP is quite well designed. But it's very difficult to convince a customer when we are not even able to import it's own data for a demo.

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to change Invoice sequence via xml in Odoo 15 or newer?
invoice sequence
Avatar
0
set 24
2062
Odoo 17.1 - How to never reset invoice number
invoice sequence
Avatar
Avatar
2
mar 24
3934
How to select manually a sequence for an invoice? Risolto
invoice sequence
Avatar
Avatar
2
feb 23
4592
Manually set invoice number Risolto
invoice sequence
Avatar
Avatar
Avatar
Avatar
Avatar
6
ott 20
39343
Error in Sequence when creating and editing invoice
invoice sequence
Avatar
Avatar
1
set 20
5107
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now