Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Invoice Numbers not be created?

By
Nicholas Coad
on 5/29/13, 8:09 PM 4,336 views

I have a multi-company environment. For whatever reason, invoice sequence numbers are not be created. I have no idea why. It worked for my first 2 trials, but now I'm getting an error on validating invoices "Constraint Error Invoice Number must be unique per Company!"

The reason why it's not unique is because the invoice number its trying to use is just a slash "/".

I am using a user that is specific to that company. All my Warehouses, Locations, Accounts and Journals are specific to that company as well.

For images please see: imgur.com/a/FZtiN

Log:

    2013-05-29 22:05:16,888 436 ERROR mydb openerp.sql_db: bad query: update "account_invoice" set "number"='/' where id = 17
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\sql_db.py", line 226, in execute
IntegrityError: duplicate key value violates unique constraint "account_invoice_number_uniq"
DETAIL:  Key (number, company_id, journal_id, type)=(/, 5, 27, out_invoice) already exists.

2013-05-29 22:05:16,888 436 ERROR mydb openerp.tools.safe_eval: Cannot eval u'action_move_create()'
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\tools\safe_eval.py", line 241, in safe_eval
  File "", line 1, in <module>
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\osv\orm.py", line 374, in function_proxy
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\openerp\addons\account\account_invoice.py", line 1012, in action_move_create
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\openerp\addons\mail\mail_thread.py", line 264, in write
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\osv\orm.py", line 4270, in write
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\osv\orm.py", line 4640, in _store_set_values
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\sql_db.py", line 161, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\sql_db.py", line 226, in execute
IntegrityError: duplicate key value violates unique constraint "account_invoice_number_uniq"
DETAIL:  Key (number, company_id, journal_id, type)=(/, 5, 27, out_invoice) already exists.

2013-05-29 22:05:16,888 436 ERROR mydb openerp.netsvc: Constraint Error
Invoice Number must be unique per Company!
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\netsvc.py", line 293, in dispatch_rpc
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\osv\osv.py", line 152, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0-20130413-232416\Server\server\.\openerp\netsvc.py", line 72, in abort_response
except_osv: ('Constraint Error', 'Invoice Number must be unique per Company!')
2013-05-29 22:05:16,904 436 INFO mydb werkzeug: 10.0.4.17 - - [29/May/2013 22:05:16] "POST /web/dataset/exec_workflow HTTP/1.1" 200 -
2013-05-29 22:05:16,921 436 INFO ? werkzeug: 10.0.4.17 - - [29/May/2013 22:05:16] "GET /web/static/src/img/warning.png HTTP/1.1" 200 -

I have the same problem. I am using Versión 7.0-20130510-231240. I tried to cancel and re-validate an invoice which had a mistake and when revalidating I got the "Constraint Error Invoice Number must be unique per Company!" error. After that I am unable to make even a new invoice without getting the error. The next sequence number is ok and I have even tried with a far ahead number so I am sure there is no invoice with that number.

Luis Leiva
on 7/4/13, 4:47 PM

My solution was to review every single accounting type setting by comparing it to a functional company. Fix any errors and then go into the database and manually delete the records without proper invoice numbers. It started working at that point.

Nicholas Coad
on 7/4/13, 4:50 PM
0
Yogesh
On 11/19/15, 12:35 PM



Hi, that error says combination of (number, company_id, journal_id, type) should be unique.
Odoo automatically creates sequence for each new journal, later on posting entries in journal this sequence is read from this field, select correct sequence on journal of invoice should fix this. Probably would require to delete or edit name of move_id(Journal Entry) to get it working.



0
explanar
On 4/11/15, 7:37 AM

For me in Odoo V8 the error occured after having accidentially typed in "0" at the tax field of an invoice row and confirmed it by [Enter].

This made the system generate a VAT-Type named "0" without further configuration.

After this accidential happening, the error occurs at every invoice-confirmation.
Even after deleting the wrong VAT-Type "0" the error is still alive.

After a reboot of the Odoo-hosting machine / ubuntu 14.04-64 still no change:

 Odoo Server Error

Traceback (most recent call last):
  File "/opt/odoo/odoo-server/openerp/http.py", line 530, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo-server/openerp/http.py", line 567, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo-server/openerp/http.py", line 303, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/http.py", line 300, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/odoo-server/openerp/http.py", line 796, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo-server/openerp/http.py", line 396, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 960, in exec_workflow
    return request.session.exec_workflow(model, id, signal)
  File "/opt/odoo/odoo-server/openerp/http.py", line 1101, in exec_workflow
    r = self.proxy('object').exec_workflow(self.db, self.uid, self.password, model, signal, id)
  File "/opt/odoo/odoo-server/openerp/http.py", line 872, in proxy_method
    result = dispatch_rpc(self.service_name, method, args)
  File "/opt/odoo/odoo-server/openerp/http.py", line 114, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 37, in dispatch
    res = fn(db, uid, *params)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 183, in exec_workflow
    return exec_workflow_cr(cr, uid, obj, signal, *args)
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 177, in exec_workflow_cr
    return execute_cr(cr, uid, obj, 'signal_workflow', [res_id], signal)[res_id]
  File "/opt/odoo/odoo-server/openerp/service/model.py", line 159, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 3524, in signal_workflow
    result[res_id] = workflow.trg_validate(uid, self._name, res_id, signal, cr)
  File "/opt/odoo/odoo-server/openerp/workflow/__init__.py", line 85, in trg_validate
    return WorkflowService.new(cr, uid, res_type, res_id).validate(signal)
  File "/opt/odoo/odoo-server/openerp/workflow/service.py", line 91, in validate
    res2 = wi.validate(signal)
  File "/opt/odoo/odoo-server/openerp/workflow/instance.py", line 75, in validate
    wi.process(signal=signal, force_running=force_running, stack=stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 120, in process
    ok = self._split_test(activity['split_mode'], signal, stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 248, in _split_test
    self._join_test(t[0], t[1], stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 257, in _join_test
    WorkflowItem.create(self.session, self.record, activity, inst_id, stack=stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 95, in create
    workflow_item.process(stack=stack)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 116, in process
    if not self._execute(activity, stack):
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 162, in _execute
    returned_action = self.wkf_expr_execute(activity)
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 313, in wkf_expr_execute
    return self.wkf_expr_eval_expr(activity['action'])
  File "/opt/odoo/odoo-server/openerp/workflow/workitem.py", line 291, in wkf_expr_eval_expr
    result = eval(line, env, nocopy=True)
  File "/opt/odoo/odoo-server/openerp/tools/safe_eval.py", line 314, in safe_eval
    return eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
  File "/opt/odoo/odoo-server/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 518, in new_api
    result = method(self._model, cr, uid, self.ids, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/ecoservice_financeinterface/account.py", line 272, in action_move_create
    thisreturn = super(account_invoice, self).action_move_create(cr, uid, ids, *args)
  File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 363, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/account/account_invoice.py", line 926, in action_move_create
    move.post()
  File "/opt/odoo/odoo-server/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 546, in new_api
    result = method(self._model, cr, uid, self.ids, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/ecoservice_financeinterface/account.py", line 132, in post
    res = super(account_move, self).post(cr, uid, ids, context=context)
  File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/account/account.py", line 1324, in post
    self.write(cr, uid, [move.id], {'name':new_name})
  File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/account/account.py", line 1365, in write
    result = super(account_move, self).write(cr, uid, ids, vals, c)
  File "/opt/odoo/odoo-server/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 363, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 3741, in write
    self._write(old_vals)
  File "/opt/odoo/odoo-server/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 546, in new_api
    result = method(self._model, cr, uid, self.ids, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 3987, in _write
    recs.recompute()
  File "/opt/odoo/odoo-server/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 5648, in recompute
    rec._write(values)
  File "/opt/odoo/odoo-server/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/api.py", line 546, in new_api
    result = method(self._model, cr, uid, self.ids, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/models.py", line 3852, in _write
    cr.execute(query, params + (sub_ids,))
  File "/opt/odoo/odoo-server/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
ValueError: "duplicate key value violates unique constraint "account_invoice_number_uniq"
DETAIL:  Key (number, company_id, journal_id, type)=(VK/2015/0011, 1, 1, out_invoice) already exists.
" while evaluating
u'action_move_create()'
0
Nicholas Coad
On 5/31/13, 5:57 PM

Any help would be greatly appreciated.

0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 5/31/13, 6:23 PM

No real help, but does this same behaviour occur for another user with the same company?

If somehow the user does not have access to ir.sequence, this issue might occur.

Do you have any custom modules installed, that is, either own made or downloaded from internet?

Hello, I do have a few custom modules, but none have anything to do with the invoicing system which is stock. My modules are separate and self-contained with an exception to an addition to the Product module (additional attributes, nothing fancy).

Nicholas Coad
on 5/31/13, 6:25 PM

The weird thing is that it used to work, so its something that I managed to break in the configuration, probably something in the accounting, but I cannot find it...

Nicholas Coad
on 5/31/13, 6:26 PM

Was the setup originally multi company? Maybe if you specify the starting number for the invoices, it might work (Settings -> Sequences -> Sequences -> Debiteuren (or Debtors??) -> Edit -> change the value behind 'Next Number'

patrick
on 6/2/13, 7:19 PM

Thank you for the suggestion, but I'm still stuck. Please take a look at the following images. Yes, it was originally set up as multicompany from day one.

Nicholas Coad
on 6/2/13, 10:45 PM

imgur.com/a/3J5mq

Nicholas Coad
on 6/2/13, 10:51 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/29/13, 8:09 PM
Seen: 4336 times
Last updated: 11/19/15, 12:36 PM