Move origin issue when in same period

16 views
Skip to first unread message

Richard PALO

unread,
May 8, 2018, 12:48:20 PM5/8/18
to tryto...@googlegroups.com
I came across a difficulty noticed during FEC generation (French plan) where I
get the following exception:
>...
> File "/trytond/modules/account_fr/account.py", line 315, in get_reference
> return line.move.origin.rec_name
> AttributeError: 'str' object has no attribute 'rec_name'

To briefly explain the issue, it concerns a reversal entry having origin set
to the initial entry at the same date (ie:cancel).

As these entries are bulk loaded via an openerp2tryton migration script, Move.save()
is invoked for all the moves in the period, period by period.

What I notice is that the origin saved in the database is "account.move,-272790" so I
presume the error is related to the fact that the referenced move is not yet saved when
the origin was set, even though when really saved, the origin move will have been saved.

Indeed, all the moves where the reversal entry is in a different period have the origin with
a non-negative number, with no problem during FEC generation. It concerns only the moves
generated in the same period for this scenario.

So the question I pose, without resorting to individual saves on the moves which would probably
have disastrous timing repercussions on the import (>35K moves), is there perhaps an outside chance
that something is forgetting to verify the state (.reload()?) of the origin move prior to saving?

Any other suggestion(s)?

If needed, I can probably provide a proteus test script demonstrating the problem.
--
Richard PALO

Cédric Krier

unread,
May 8, 2018, 2:00:06 PM5/8/18
to tryto...@googlegroups.com
The origin must be saved before being assigned if you want to store the
saved id.


I submitted https://bugs.tryton.org/issue7421 to prevent the exception
raising.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Richard PALO

unread,
May 8, 2018, 4:47:01 PM5/8/18
to tryto...@googlegroups.com
Le 08/05/2018 à 19:56, Cédric Krier a écrit :
> The origin must be saved before being assigned if you want to store the
> saved id.
>
>
> I submitted https://bugs.tryton.org/issue7421 to prevent the exception
> raising.
>
Ok, I'm trying the following, based upon what I see e.g. in modelstorage.py:
> if move_origin.id is None or move_origin.id < 0:
> move_origin.save() # work-around for same period origins
> new_move.origin = move_origin
>

This should keep use of save() down to the handful of cases where id is actually < 0

BTW, why does save(), for example on a move, automatically save() its lines?
Is the problem because origin is unidirectional?

--
Richard PALO

Cédric Krier

unread,
May 8, 2018, 4:55:05 PM5/8/18
to tryto...@googlegroups.com
On 2018-05-08 22:46, Richard PALO wrote:
> BTW, why does save(), for example on a move, automatically save() its lines?
> Is the problem because origin is unidirectional?

Because proteus simulate the behavior of other clients.
Reply all
Reply to author
Forward
0 new messages