Delete Class Attributes

12 views
Skip to first unread message

Francisco Maria Moyano Casco

unread,
Mar 25, 2018, 10:37:42 AM3/25/18
to tryton
Hi,
I'm working on Tryton 4-2. I'm trying to delete some class attributes, due to a migration, but I had no success.

The code I use is the next one:
......
if table.column_exist('water'):
table.drop_column('water')
if hasattr(cls,'water'):
del cls.water
.......

Any clue why this doesn't work?

Thanks
Francisco

Cédric Krier

unread,
Mar 25, 2018, 10:55:03 AM3/25/18
to tryton
Why are you deleting it? Just remove the definition from the class.

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

Francisco Maria Moyano Casco

unread,
Mar 25, 2018, 4:11:38 PM3/25/18
to tryton
El domingo, 25 de marzo de 2018, 11:55:03 (UTC-3), Cédric Krier escribió:
> On 2018-03-25 07:37, Francisco Maria Moyano Casco wrote:
> > Hi,
> > I'm working on Tryton 4-2. I'm trying to delete some class attributes, due to a migration, but I had no success.
> >
> > The code I use is the next one:
> > ......
> > if table.column_exist('water'):
> > table.drop_column('water')
> > if hasattr(cls,'water'):
> > del cls.water
> > .......
> >
> > Any clue why this doesn't work?
>
> Why are you deleting it? Just remove the definition from the class.

Because, the attributes I want to remove are part of a module base class. So, if I remove the definifinition from it, next time the module would be update to a newer version, I will have to remove again.

Cédric Krier

unread,
Mar 25, 2018, 5:30:04 PM3/25/18
to tryton
You can not remove field from other modules. This will break the other
module.

Nicolas Évrard

unread,
Mar 25, 2018, 5:44:19 PM3/25/18
to tryton
* Francisco Maria Moyano Casco [2018-03-25 22:11 +0200]:
Why do you want to remove a field from a base module?

--
Nicolas Évrard - B2CK SPRL
E-mail/Jabber: nicolas...@b2ck.com

Francisco Maria Moyano Casco

unread,
Mar 25, 2018, 5:51:13 PM3/25/18
to tryton


El domingo, 25 de marzo de 2018, 18:30:04 (UTC-3), Cédric Krier escribió:
> On 2018-03-25 13:11, Francisco Maria Moyano Casco wrote:
> > El domingo, 25 de marzo de 2018, 11:55:03 (UTC-3), Cédric Krier escribió:
> > > Why are you deleting it? Just remove the definition from the class.
> >
> > Because, the attributes I want to remove are part of a module base
> > class. So, if I remove the definifinition from it, next time the
> > module would be update to a newer version, I will have to remove
> > again.
>
> You can not remove field from other modules. This will break the other
> module.

Ok!

I'm sorry, but why it would break the other modules? Those fields that I want to remove, are not pointed or use by anyother module or report.

Cédric Krier

unread,
Mar 25, 2018, 6:30:06 PM3/25/18
to tryton
On 2018-03-25 14:51, Francisco Maria Moyano Casco wrote:
> I'm sorry, but why it would break the other modules? Those fields that
> I want to remove, are not pointed or use by anyother module or report.

I guess if the module adds such field, it is because it is used.
If it is not really used, you should request to remove it.
Reply all
Reply to author
Forward
0 new messages