# Delete invoice, table of accounts etc

**URL:** <https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640>\
**Category:** User\
**Created:** [April 27, 2020, 3:27am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640 "2020-04-27T03:27:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 27, 2020, 3:27am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/1 "2020-04-27T03:27:13Z")

</div>

When doing my first steps, I’m subject to make many mistakes…  
By accident, I created two identical tables of account (“minimaler Kostenplan”), and used both of them randomly.

Now I need to get rid of the surplus one, but it’s already in use by an invoice. Is there any chance to get delete that invoice ? - Or a trick to “force delete” a table of accounts with all its children?

Is there an “experimental” mode for noobs, where the normal data storage rules in accounting are disabled, so noobs can experiment without fatal consequences?

Cheers,  
Wolf

---

<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:** [April 27, 2020, 8:18am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/2 "2020-04-27T08:18:48Z")

</div>

> [@herrdeh](#):
>
> Is there any chance to get delete that invoice ? - Or a trick to “force delete” a table of accounts with all its children?

No because posted invoice can never be deleted.

> [@herrdeh](#):
>
> Is there an “experimental” mode for noobs, where the normal data storage rules in accounting are disabled, so noobs can experiment without fatal consequences?

No because it would be too risky to allow bad practice in production.

You just have to delete your database and restart your experimentation.

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 27, 2020, 9:44am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/3 "2020-04-27T09:44:57Z")

</div>

Thanks for clarification.

I don’t think that’s really realistic. I cannot belive anybody can dive into tryton without making severe mistakes in the very beginning and early stages. A complete startover each time will soon leave noobs frustrated and disappointed. Think only how many tries a noob needs until his invoice template really fits… (for myself I expect several months of parallel usage of tryton and the old system till I really know how to handle tryton.)

I think tryton should have the chance to begin with an “experimental version” where mistakes can be corrected. That could have a red-coloured background and a huge warning “not for productive use - test only” or so. Finest would be if I could at a certain point copy the _testing_ database to _productive_ and keep the testing one for further experiments.

Please let me know your thoughts.

Cheers,  
Wolf

---

<div class="post-metadata">

**Author:** ![SISalp](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sisalp/32/200_2.png) [@SISalp](https://discuss.tryton.org/u/SISalp)\
**Post date:** [April 27, 2020, 10:04am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/4 "2020-04-27T10:04:36Z")

</div>

> [@herrdeh](#):
>
> I don’t think that’s really realistic. I cannot belive anybody can dive into tryton without making severe mistakes in the very beginning and early stages. A complete startover each time will soon leave noobs frustrated and disappointed. Think only how many tries a noob needs until his invoice template really fits… (for myself I expect several months of parallel usage of tryton and the old system till I really know how to handle tryton.)
> 
> I think tryton should have the chance to begin with an “experimental version” where mistakes can be corrected. That could have a red-coloured background and a huge warning “not for productive use - test only” or so. Finest would be if I could at a certain point copy the _testing_ database to _productive_ and keep the testing one for further experiments.
> 
> Please let me know your thoughts.

It is not up to the software to organize your work. Do your homework and don’t blame software.  
You may get inspired by the Tryton hosting I provide, it runs (at least) 3 independent tryton services.  
One for production, one for testing and one for training.  
An additional panel allows to save/restore/clone/move databases between these three services.  
A “tachy-backup” mode with a database backup every hour or every quarter is available to help you restore the state before.  
test and training services must be maintained over time, because test allows to validate new modules and upgrades before they hit the production service and training is always needed to rehearse unusual  
operations and to train a new employee.  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [April 27, 2020, 10:10am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/5 "2020-04-27T10:10:25Z")

</div>

> [@herrdeh](#):
>
> Finest would be if I could at a certain point copy the _testing_ database to _productive_ and keep the testing one for further experiments.

You can backup the database at any time you like, then restore it to go back to that point in time.

This means that you can create a database backup before you start doing an experiment, then if you find that the experiment didn’t work out as expected you can just restore the database and you will be back to the point just before you started your experiment.

Another alternative would be to have a testing system and a production one, you could copy the production database to the testing one, run the tests to see what will happen, then if you are happy perform the same actions on your production system.

---

<div class="post-metadata">

**Author:** ![SISalp](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sisalp/32/200_2.png) [@SISalp](https://discuss.tryton.org/u/SISalp)\
**Post date:** [April 27, 2020, 10:15am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/6 "2020-04-27T10:15:22Z")

</div>

> [@dave](#):
>
> Another alternative would be to have a testing system and a production one

Yes, this is needed in particular if your test is about modifying/complementing Tryton code.

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 27, 2020, 12:15pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/7 "2020-04-27T12:15:04Z")

</div>

> [@dave](#):
>
> You can backup the database at any time you like, then restore it to go back to that point in time.

Thank you very much - this is helpful.  
_(barking “do your homework” is not…)_

Could you please be a little more detailed?

---

<div class="post-metadata">

**Author:** ![SISalp](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sisalp/32/200_2.png) [@SISalp](https://discuss.tryton.org/u/SISalp)\
**Post date:** [April 27, 2020, 12:34pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/8 "2020-04-27T12:34:45Z")

</div>

> [@herrdeh](#):
>
> (barking “do your homework” is not…)

When I bark, I don’t spend time to answer.  
details are:  
save: pg\_dump -O db\_name \> db.sql  
restore: psql -d “db\_name” -f db.sql --username db\_user

take care if you use several copies of a database, only the production one should perform actions to the outside, like sending mails.

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 27, 2020, 4:06pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/9 "2020-04-27T16:06:36Z")

</div>

Thank you.  
As you may have noticed: I’m not at all a pro, just an entrepreneur looking for a tool to do the not-at-all-fun-part of the work. I never worked with docker, and I dont have the time to dig into the details. So could you please let me know how I can access the database and where it lives?

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [April 27, 2020, 8:49pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/10 "2020-04-27T20:49:48Z")

</div>

> [@herrdeh](#):
>
> I never worked with docker

Are you using docker now? If so the database will be stored inside your [postgres container](https://hub.docker.com/_/postgres). You can find the ID for the container by running:

```
sudo docker ps

```

Once you know the ID you can run the commands suggested by @SISalp in the container by doing something like this: (remember to change the _[container\_id]_ for the one you previously found)

```
sudo docker exec [container_id] pg_dump -U tryton -O tryton >backup.sql

```

and

```
sudo docker exec [container_id] psql -U tryton -d tryton <backup.sql

```

More information on postgres backup and restore can be found in [their documentation](https://www.postgresql.org/docs/12/backup-dump.html).

If you are not using docker then you should be able to use the commands above without the “sudo docker exec [container\_id]” part, although the user name and database name may be different.

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 28, 2020, 10:27am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/11 "2020-04-28T10:27:40Z")

</div>

Thank you very much.

This is what I tried:

> $ sudo docker exec ed01cfc74801 pg\_dump -U tryton -O tryton \>Sikop28.04.20.sql  
> pg\_dump: error: connection to database “tryton” failed: FATAL: role “tryton” does not exist

I tried with running or not-running tryton and tryton-postgres - does not matter…

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [April 28, 2020, 12:09pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/12 "2020-04-28T12:09:35Z")

</div>

> [@herrdeh](#):
>
> This is what I tried:
> 
> > $ sudo docker exec ed01cfc74801 pg\_dump -U tryton -O tryton \>Sikop28.04.20.sql  
> > pg\_dump: error: connection to database “tryton” failed: FATAL: role “tryton” does not exist

Sorry, my mistake, if you followed the docker install instructions then it should be `-U postgres` and not `-U tryton`.

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [April 28, 2020, 12:11pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/13 "2020-04-28T12:11:49Z")

</div>

Another thing, you also might want to specify `-c` or `--clean` as one of the options when running pg\_dump as well.

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 28, 2020, 1:54pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/14 "2020-04-28T13:54:05Z")

</div>

I seem to make a mistake. That’s what I tried:

> From a running tryton, I logged out.

> $ sudo docker ps  
> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
> 18ccc2fcd7db tryton/tryton “/entrypoint.sh uwsg…” 4 hours ago Up 41 seconds 0.0.0.0:8000-\>8000/tcp tryton  
> ed01cfc74801 postgres “docker-entrypoint.s…” 4 hours ago Up 7 minutes 5432/tcp tryton-postgres  
> $ sudo docker stop tryton  
> $ sudo docker exec ed01cfc74801 pg\_dump -U postgres -O postgres \>Sikop28.04.20.sql  
> $ sudo docker start tryton

> log into tryton, changed a bit: created a bogus article  
> logged out tryton

> $ sudo docker stop tryton  
> $ sudo docker exec ed01cfc74801 psql -U postgres -d tryton \<Sikop28.04.20.sql  
> $ sudo docker start tryton

> logged into tryton, expected my bogus article inexistant - but it was not.

What’s my mistake?

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [April 28, 2020, 3:21pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/15 "2020-04-28T15:21:37Z")

</div>

> [@herrdeh](#):
>
> What’s my mistake?

This line:

```
sudo docker exec ed01cfc74801 pg_dump -U postgres -O postgres >Sikop28.04.20.sql

```

Needs the `-c` flag mentioned above (plus the `-C` flag to be safe), and the correct database name, so should be this (I think):

```
sudo docker exec ed01cfc74801 pg_dump -C -c -U postgres -O tryton >Sikop28.04.20.sql

```

And this line:

```
sudo docker exec ed01cfc74801 psql -U postgres -d tryton <Sikop28.04.20.sql

```

Needs an additional `-i` flag that I missed (sorry!):

```
sudo docker exec -i ed01cfc74801 psql -U postgres -d tryton <Sikop28.04.20.sql

```

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 28, 2020, 4:07pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/16 "2020-04-28T16:07:29Z")

</div>

No reason to be sorry - good to see that experts make mistakes as well…

When playing back a backup, I get a heep of error messages:  
[https://www.dropbox.com/s/z2dsjuabjc80qso/restore.txt?dl=0](https://www.dropbox.com/s/z2dsjuabjc80qso/restore.txt?dl=0)

The database seems to be the same as before.  
My fault?

---

<div class="post-metadata">

**Author:** ![dave](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://discuss.tryton.org/u/dave)\
**Post date:** [April 28, 2020, 4:26pm UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/17 "2020-04-28T16:26:26Z")

</div>

> [@herrdeh](#):
>
> When playing back a backup, I get a heep of error messages:  
> [https://www.dropbox.com/s/z2dsjuabjc80qso/restore.txt?dl=0](https://www.dropbox.com/s/z2dsjuabjc80qso/restore.txt?dl=0)

These are not error messages, they are just a list of all the things that are getting restored to the database.

> [@herrdeh](#):
>
> The database seems to be the same as before.

If you have a look in the backup file, there should be a line near the top that says something like `DROP DATABASE tryton;`. If the backup file contains this (which it should do if you ran the `pg_dump` command with the `-C` flag) then you can be pretty sure that any changes that you made to the database _will_ have been removed.

So, make sure the tryton server is restarted (which it will be if you do the commands you listed before), _and_ the client as it may be caching some of the data. To restart the web client use the reload button in the toolbar of your browser.

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 29, 2020, 4:11am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/18 "2020-04-29T04:11:23Z")

</div>

Good morning.  
Sorry, still in trouble… ):

Today, I did an entry to “parties” and tried to save the database:

> $ sudo docker stop tryton  
> $ sudo docker ps  
> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
> ed01cfc74801 postgres “docker-entrypoint.s…” 19 hours ago Up 25 minutes 5432/tcp tryton-postgres  
> $ sudo docker exec ed01cfc74801 pg\_dump -U postgres -O postgres \>29.4.20.sql

And I got a tiny database dump, hardly containing anything:  
[https://www.dropbox.com/s/701tgmvdir3j9v0/29.4.20.sql?dl=0](https://www.dropbox.com/s/701tgmvdir3j9v0/29.4.20.sql?dl=0)

Seems to be a bit away from the final goal…

---

<div class="post-metadata">

**Author:** ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)\
**Post date:** [April 29, 2020, 6:47am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/19 "2020-04-29T06:47:48Z")

</div>

> [@herrdeh](#):
>
> $ sudo docker exec ed01cfc74801 pg\_dump -U postgres -O postgres \>29.4.20.sql

Seems you miss to add dbname “tryton” ?  
… pg\_dump -d tryton …

---

<div class="post-metadata">

**Author:** ![herrdeh](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/herrdeh/32/821_2.png) [@herrdeh](https://discuss.tryton.org/u/herrdeh)\
**Post date:** [April 29, 2020, 7:12am UTC](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640/20 "2020-04-29T07:12:30Z")

</div>

I tried again with this line:

> [@dave](#):
>
> sudo docker exec ed01cfc74801 pg\_dump -C -c -U postgres -O tryton \>Sikop28.04.20.sql

and it worked, I could find my input changes in the dump. Probabely my copy/paste error.

[Next page](https://discuss.tryton.org/t/delete-invoice-table-of-accounts-etc/2640.md?page=2)
