[tryton-dev] Remove constrainte
Hello, Is there a way to remove constrainte put by a "required" clause ? In details, I have a field that have a constrainte put by the "required" clause and i want to remove this constainte by overload of the class. it-is possible ? Regards. -- Christophe CRIER Adiczion (www.adiczion.com)
Re: [tryton-dev] Remove constrainte
El 05/12/14 a les 15:41, Christophe ha escrit: Hello, Is there a way to remove constrainte put by a "required" clause ? In details, I have a field that have a constrainte put by the "required" clause and i want to remove this constainte by overload of the class. it-is possible ? Yes, it's possible. You have to do the following things. 1. Update fields definition to set required to false. 2. Drop the not null constraint on the database. BTW: Can you tell us which is the field you want to remove the constraint? This will help us to prevent having to much constraints on base modules. -- Sergi Almacellas Abellana www.koolpi.com Twitter: @pokoli_srk
Re: [tryton-dev] Remove constrainte
On 05/12/14 10:16, Sergi Almacellas Abellana wrote: El 05/12/14 a les 15:41, Christophe ha escrit: Hello, Is there a way to remove constrainte put by a "required" clause ? In details, I have a field that have a constrainte put by the "required" clause and i want to remove this constainte by overload of the class. it-is possible ? Yes, it's possible. You have to do the following things. 1. Update fields definition to set required to false. 2. Drop the not null constraint on the database. BTW: Can you tell us which is the field you want to remove the constraint? This will help us to prevent having to much constraints on base modules. Or better, you can use "register" method (overloading the class) and to apply python-sql commands
Re: [tryton-dev] Remove constrainte
On 05 Dec 15:41, Christophe wrote: > Hello, > > Is there a way to remove constrainte put by a "required" clause ? > > In details, I have a field that have a constrainte put by the "required" > clause and i want to remove this constainte by overload of the class. it-is > possible ? There is method in TableHandler to manage that [1] but it is intended to be used for migration because on the next update Tryton will try first to re-add the constraint. Indeed, it is probably a bad idea to remove a required from a parent module because if it is set it is because it is strictly required for the module to work properly (but maybe the module is buggy and it is not strictly required if so you should ask the author to fix his module). [1] http://hg.tryton.org/trytond/file/569dd5d4d9e1/trytond/backend/table.py#l167 -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ pgpBjCTQLyzqL.pgp Description: PGP signature
Re: [tryton-dev] Remove constrainte
Le 05/12/2014 16:16, Sergi Almacellas Abellana a écrit : El 05/12/14 a les 15:41, Christophe ha escrit: Hello, Is there a way to remove constrainte put by a "required" clause ? In details, I have a field that have a constrainte put by the "required" clause and i want to remove this constainte by overload of the class. it-is possible ? Yes, it's possible. You have to do the following things. 1. Update fields definition to set required to false. 2. Drop the not null constraint on the database. BTW: Can you tell us which is the field you want to remove the constraint? This will help us to prevent having to much constraints on base modules. I have made (1) for (2) i try with __register__ method but it don't work (or i have made a mistake) @classmethod def __register__(cls, module_name): super(Article, cls).__register__(module_name) TableHandler = backend.get('TableHandler') cursor = Transaction().cursor table = TableHandler(cursor, cls, module_name) table.not_null_action('content', action='remove') For BTW : I try to remove constrainte from 'content' field because in my overload this field is not necessary (it is replaced by another). PS : I also view the Cedric response and what I want to do is perhaps not be possible. -- Christophe CRIER Adiczion (www.adiczion.com)