Tryton - Issues

 

Issue5502

Title Crash when journal has no sequence defined for the company
Priority bug Status resolved
Superseder Nosy List ced, pokoli, reviewbot, roundup-bot
Type crash Components account
Assigned To pokoli Keywords review
Reviews 45121002
View: 45121002

Created on 2016-04-20.13:23:24 by pokoli, last changed by roundup-bot.

Messages
New changeset 4a5298bbbb43 by Sergi Almacellas Abellana in branch 'default':
Test if journal has a sequence before getting a number from it
https://hg.tryton.org/modules/account/rev/4a5298bbbb43
review45121002 updated at https://codereview.tryton.org/45121002/#ps10002
review45121002 updated at https://codereview.tryton.org/45121002/#ps1
msg40721 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2018-05-17.15:51:25
Here is review45121002 which implements msg40681

P.S: I raised it as a crash as we are not introducing any new feature now.
msg40681 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2018-05-14.12:56:55
Indeed contextual required is not reliable. But I do not think we should create new error message. It is better to just avoid the AttributeError.
msg40680 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2018-05-14.12:48:45
We are still facing this issue without property fields. The problem is that the value depends on the company and a journal may have no value for a newly created company.

I think having an explanatory message is the best that we can do to prevent this issue.
msg25574 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2016-04-21.11:32:15
I don't agree with the review18031002 because it doesn't solve the problem at all.
Also I think it is wrong design to have to test for something that is required.
Indeed the problem is the Property field that should be fixed with issue2349
msg25571 (view) Author: [hidden] (pokoli) (Tryton committer) (Tryton translator) Date: 2016-04-20.13:23:22
Although the sequence on journal is required, it may not have a value. Here are the steps to get a journal without sequence: 

1. Create a new journal named test and set it's sequences.
2. Create a new company and a chart of accounts for it. 

Then the "Test" journal does not have any sequence defined for the current company, so when creating a move on the journal the following exception is raised: 

Traceback (most recent call last):
  File "/home/sergi/nan/projectes/virtualenv/nclone/trytond/trytond/protocols/dispatcher.py", line 199, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/home/sergi/nan/projectes/virtualenv/nclone/trytond/trytond/modules/account/move.py", line 278, in create
    vals['number'] = Sequence.get_id(journal.sequence.id)
AttributeError: 'NoneType' object has no attribute 'id'


The attached review adds a test for the sequences and a explanatory error message.
History
Date User Action Args
2018-05-21 10:31:12roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg40791
2018-05-17 17:12:18reviewbotsetmessages: + msg40733
2018-05-17 16:14:13reviewbotsetnosy: + reviewbot
messages: + msg40723
2018-05-17 15:51:39pokolisettitle: Improve error message when journal has no sequence defined -> Crash when journal has no sequence defined for the company
2018-05-17 15:51:25pokolisetreviews: 18031002 -> 45121002
priority: feature -> bug
type: feature request -> crash
messages: + msg40721
2018-05-14 12:56:55cedsetmessages: + msg40681
2018-05-14 12:48:45pokolisetmessages: + msg40680
2016-04-21 11:32:15cedsetnosy: + ced
messages: + msg25574
2016-04-20 13:23:24pokolicreate

Showing 10 items. Show all history (warning: this could be VERY long)