← Back to team overview

openerp-community team mailing list archive

Re: Print a string for EVERY write

 

that is really tricky thing to do, "Monkey Patch" is not a very good way to
go, you should try to inheriting BaseModel as Leonardo says, also, if you
want to keep track of the prints in the log file you wont be able to audit
them, try logger instead.

On Tue, Oct 14, 2014 at 8:38 AM, Francesco Apruzzese <cescoap@xxxxxxxxx>
wrote:

> Il 14/10/2014 12:24, atchuthantu@xxxxxxxxx ha scritto:
>
> Thank you! This is what i'm searching!
>
>  Hi,
>>
>>     You can use the functionality used at Connector module available at
>> OCA(https://github.com/OCA/connector/blob/7.0/connector/producer.py)
>>
>> from openerp.osv import orm
>> write_original = orm.BaseModel.write
>> def write(self, cr, uid, ids, vals, context=None):
>>     print "Your custom statement"
>>     # Create a logger entry here
>>     result = write_original(self, cr, uid, ids, vals, context=context)
>>     return result
>> orm.BaseModel.write = write
>>
>> Add this python code in your module, then for every WRITE function, your
>> custom string will be printed to your console.
>>
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to     : openerp-community@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openerp-community
> More help   : https://help.launchpad.net/ListHelp
>



-- 




Ing. Oscar Alcalá Rivera
*312-107-1704* · oszckar@xxxxxxxxx <ozckar@xxxxxxxxx>

Vauxoo SA
Tlf: *3123111122*

*Open Source Enthusiast*

*LinuxCounter:**566085*
     [image: twitter] <http://twitter.com/oscarolar> [image: linkedIn]
<http://www.linkedin.com/pub/oscar-alcal%C3%A1/3b/a79/922>   [image:
Google+] <http://plus.google.com/107659954580035981067/posts>

[image: eco] No me imprimas si no es necesario. Protejamos el medio ambiente

References