I want to execute a function after some record is saved in the database (something like Signals in Django).
I have tried using Odoo Connector but with no success. connector module is not present in openerp.addons package by default and I could not find a good resource to understand how to install it.
How can I execute a function every time a new record is saved?
I solved it myself.
I manually copied connector module from github to /usr/lib/python2.7/dist-packages/openerp/addons (to make sure it's in my IDE's libraries' path).
Installed the connector from Settings -> Local Modules.
Used the following code (can be anywhere, even in __init__.py of your module)
#on_record_create(model_names=['res.users', 'res.partner'])
#on_record_write(model_names=['res.users', 'res.partner'])
def delay_export(session, model_name, record_id, vals):
"""
Do some real work here.
"""
import ipdb; ipdb.set_trace()
The above code is based on odoo-connector.
Related
I'm working on my first query module for Memgraph. I'm trying to find the best approach.
I have a query module that depends on a local submodule (firstone):
import firstone
import mgp
import importlib
#mgp.read_proc
def procedure(context...):
importlib.reload(firstone)
firstone.call()
If I get it correctly, if firstone module changes, the procedure is still using the previous code. How can I reload the Python query module during development?
You can use the use mg.load to load or reload the given module. The correct syntax is CALL mg.load("py_example");. After loading the module, all dependent Python's submodules that are imported will also be reloaded. The official documentation can be found on Memgraph site.
Just started learning how to use AWS Lambda to put my Python codes up and I've come across an issue that is making me question my sanity. In all videos, tutorials, and forums on the subject, people seem to have an entry field to modify the name of the lambda handler. This option appears nowhere on my lambda configuration page. My code does run if I use the default naming of a "lambda_function" file and a "lambda_handler" main function inside it, but nowhere do I see an option to specify my own names.
The reason I want to specify my own names is that I am trying to be able to import user-created modules and it seems the only way to do that is to modify the handler to specify a subfolder as documented here (just putting from modulename import function, class or whatever in the main handler_function file does not appear to work.
Thanks all for all the help !!
You can change your lambda handler name.
Configuration -> Basic setting -> Handler info
You can find below Tags
See this screenshot :
For latest update remove basic setting of lambda so follow this :
Click on layer as show below in image
Check Run time setting and edit it.
To get error log details in the xamarin project i installed serilog.sinks.xamarin nuget package in my project. In android, I tried serilog.sinks.rollingfile to store the log details in the documents folder. This is my code
Log.Logger=new LoggerConfiguration().WriteTo.RollingFile(Path.Combine(Environment.DirectoryDocuments,"AndroidErrorLog.txt"))
.WriteTo.AndroidLog().CreateLogger();
After executing the project, if I check the documents folder no file are created and no logs details are found. Can any one tell what mistake I have done and how to fix this issue?.
Log.Logger = new LoggerConfiguration()
.WriteTo.File(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "JCA_log-{Date}.txt")
, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] [{SourceContext}] {Message}{NewLine}{Exception}")
.WriteTo.AndroidLog()
.CreateLogger();
Taken from PhillipOGorman from the following sources:
Example #1
Example #2
I had this exact issue. I think it was something in the constructor that seemed to stop Serilog from creating a file.
Note #1: The Serilog code provided relies on the Sinks.File and Sinks.Xamarin.Droid Serilog libraries.
Note #2: He used:
Android.OS.Environment.ExternalStorageDirectory.AbsolutePath
when referencing where the file would write to but,
Environment.GetFolderPath(Environment.SpecialFolder.Personal)
works fine (plus it packages it within your apps sandbox.)
I have used the latest connector from Rally and set it up with Task Scheduler to run periodically. It works well, however I have encountered problems when trying to extend it.
Within the config.yml file used, there is an UpdateArtifactState flag that I believe, when set to True, will make use of the statex.rb file. This file handles how the commit message from SVN is parsed. It is here that I find my problem;
I want to extend the connector to allow for the # symbol to be included in the Rally task identifier (DE55555 -> #DE5555 for example). However, upon testing this file does not seem to be used.
Question: if my assumption is correct, and the statex.rb file is merely an example and not used in execution, how can I extend the Rally Connector to pick up tags the way I see fit?
You may try the following:
make a new Ruby class and put it in to the extension subdirectory.
Example: extension/my_state_extractor.rb
in this file he has a class defined as 'MyStateExtractor'
Pattern your file from the statex.rb file.
Then, in your config in the Rally section, you'll need an entry of
StateExtractorClass : MyStateExtractor(message)
Customarily this entry will follow the entry for UpdateArtifactState : True
I am looking at zfmodules to get a datatable module, and have found the perfect one :
https://github.com/dudapiotr/ZfTable
..however there is very little explanation of how to configure it into an existing project, change the data source etc.
Does anyone have any experience of this module, or is successfully using it in production?
The thing that i understood from Question is " You want to inject this
Module in your current Application ", well i have checked the link [https://github.com/dudapiotr/ZfTable][1] and the module seems perfect to inject to your Application. *The only thing which seems unfitting is the 'data' folder, you should compile
'customer.sql' onto your database, and then remove the folder 'data', since it does not matches to the framework structure
**Try these steps **
*
create your sql database exactly as mentioned in customer.sql
copy this module to your application, with other residing modules (if any).
Add the module name to application.config.php in Application/config/autoload directory ( since you are adding module manually, you must add your module name there by yourself)
And last, Routing configuration of your module in Application/config/module.config.php
if you need any help in routing of step 4, go here [Zend framework not able to route the translated child routes
*