# Error when duplicate invoice

**URL:** https://discuss.tryton.org/t/error-when-duplicate-invoice/1207
**Category:** Developer
**Created:** [March 1, 2019, 11:52am UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207 "2019-03-01T11:52:44Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![jcm](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jcm/32/344_2.png) [@jcm](https://discuss.tryton.org/u/jcm)
#### Post date: [March 1, 2019, 11:52am UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/1 "2019-03-01T11:52:44Z")

</div>

Thks for the explainations.

I’m stuck in this process: the original invoice had many lines generated by Stock moves among Customer locations and Client ones. Once credit note is edited, I tried to duplicate the original invoice to be able to change the address. But this is refused with message ‘You cannot create this type of document (account.invoice.line-account.tax)’.  
Do I have another solution than copying manually one by one each product and quantity on a new invoice? (an error prone process I must say)

---

<div class="post-metadata">

### Author: ![jcm](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jcm/32/344_2.png) [@jcm](https://discuss.tryton.org/u/jcm)
#### Post date: [March 1, 2019, 4:39pm UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/2 "2019-03-01T16:39:39Z")

</div>

Seems it’s unrelated. I don’t get this pb on an older db. Something messed up, I don’t know what.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 1, 2019, 6:35pm UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/3 "2019-03-01T18:35:46Z")

</div>

I suspect that you have a custom modules that add a One2Many to `account.invoice.line-account.tax` model which does not inherit from `ModelView` so users are not allowed to write on it.

Now, I’m wondering if the copy operation should really check the access rights on the fields. Maybe it should just check read/write access on the records and do the operations without any other checks to follow the principle of access right on the border.

---

<div class="post-metadata">

### Author: ![jcm](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jcm/32/344_2.png) [@jcm](https://discuss.tryton.org/u/jcm)
#### Post date: [March 2, 2019, 12:52pm UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/4 "2019-03-02T12:52:51Z")

</div>

I’m surprised, I have no One2Many. Nothing found except in account\_invoice:

```
$ grep -R 'account.invoice.line-account.tax' trytond/modules/*/*.py
trytond/modules/account_invoice/invoice.py: taxes = fields.Many2Many('account.invoice.line-account.tax',
trytond/modules/account_invoice/invoice.py: __name__ = 'account.invoice.line-account.tax'

```

More, the same code base works in dev locally (duplicating invoice or creating a new one). Something went wrong in the db.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 2, 2019, 1:02pm UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/5 "2019-03-02T13:02:38Z")

</div>

It may be useful to run the server with debug logging and can the full traceback for this error.

---

<div class="post-metadata">

### Author: ![jcm](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jcm/32/344_2.png) [@jcm](https://discuss.tryton.org/u/jcm)
#### Post date: [March 5, 2019, 9:40am UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/6 "2019-03-05T09:40:08Z")

</div>

Here it is:

```
Traceback (most recent call last):
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/protocols/dispatcher.py", line 176, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/modules/sale/invoice.py", line 77, in copy
    return super(Invoice, cls).copy(invoices, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/modules/purchase/invoice.py", line 83, in copy
    return super(Invoice, cls).copy(invoices, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/modules/account_invoice_history/invoice.py", line 53, in copy
    return super(Invoice, cls).copy(invoices, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/modules/account_invoice/invoice.py", line 1127, in copy
    return super(Invoice, cls).copy(invoices, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/workflow.py", line 57, in copy
    return super().copy(records, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelstorage.py", line 357, in copy
    new_records = cls.create(to_create)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelsql.py", line 147, in wrapper
    return func(cls, *args, **kwargs)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelsql.py", line 643, in create
    field.set(cls, fname, *fargs)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/fields/one2many.py", line 240, in set
    actions[action](ids, *args)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/fields/one2many.py", line 223, in copy
    Target.copy(copies, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/modules/account_invoice_stock/account.py", line 48, in copy
    return super(InvoiceLine, cls).copy(lines, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/modules/account_invoice/invoice.py", line 2030, in copy
    return super(InvoiceLine, cls).copy(lines, default=default)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelstorage.py", line 357, in copy
    new_records = cls.create(to_create)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/modules/account_invoice/invoice.py", line 2021, in create
    return super(InvoiceLine, cls).create(vlist)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelsql.py", line 147, in wrapper
    return func(cls, *args, **kwargs)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelsql.py", line 643, in create
    field.set(cls, fname, *fargs)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/fields/many2many.py", line 269, in set
    Relation.create(relation_to_create)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelsql.py", line 147, in wrapper
    return func(cls, *args, **kwargs)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelsql.py", line 545, in create
    super(ModelSQL, cls).create(vlist)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/model/modelstorage.py", line 104, in create
    ModelAccess.check(cls. __name__ , 'create')
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/ir/model.py", line 522, in check
    cls.raise_user_error(mode, model_name)
  File "/home/tryton/venv/lib/python3.5/site-packages/trytond/error.py", line 74, in raise_user_error
    raise UserError(error)
trytond.exceptions.UserError: ('UserError', ('Vous ne pouvez pas créer ce type de document\xa0! (account.invoice.line-account.tax)', ''))

```

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 5, 2019, 10:00am UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/7 "2019-03-05T10:00:47Z")

</div>

> [@ced](#):
>
> I suspect that you have a custom modules that add a One2Many to `account.invoice.line-account.tax` model which does not inherit from `ModelView` so users are not allowed to write on it.

This is not what is happening.

It seems that you have an access rule defined for the model `account.invoice.line-account.tax` which prevents you to write on it. Tryton by default does not have access rights on this model because it is only for internal usage.

---

<div class="post-metadata">

### Author: ![jcm](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jcm/32/344_2.png) [@jcm](https://discuss.tryton.org/u/jcm)
#### Post date: [March 5, 2019, 10:22am UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/8 "2019-03-05T10:22:14Z")

</div>

Thks, solved. The access group “Invoice Read” I added had a line with “Line-Account Tax” read checkbox. Deleting this line solved the problem.

I miss a guide on how to allow some read access to users: creating this simple group I made two mistakes, this one and the fact that not adding Admin to the new group made some menu entries disappear.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 5, 2019, 10:28am UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/9 "2019-03-05T10:28:46Z")

</div>

The documentation about access rights have been recently rewrote: [Access Rights — Tryton server](http://docs.tryton.org/projects/server/en/latest/topics/access_rights.html#topics-access-rights)

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [April 4, 2019, 10:28am UTC](https://discuss.tryton.org/t/error-when-duplicate-invoice/1207/10 "2019-04-04T10:28:52Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
