ODOO How to run automated actions at a specific time everyday - cron

I am trying to add a cron job that should run every day at 12 pm. I am facing a few issue and have a few doubts.
I was able to run it every minute but couldn't run it at a specific time.
How to know which timezone is expected and which timezone is set in the "nextcall" field
It doesnt run until I open console in the browser. How can it be done so that it runs at the server and no additional action is needed?
<record id="ir_cron_module_get_active_sr" model="ir.cron">
<field name="name">Get Active Srs</field>
<field name="user_id" ref="base.user_root" />
//<field name="interval_number">2</field>
//<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="nextcall" eval="(datetime.utcnow() + timedelta(days=0)).strftime('%Y-%m-%d 12:22:00')" />
<field name="doall" eval="True" />
<field name="model" eval="'sd.cron'" />
<field name="function" eval="'get_active_srs'" />
<field name="args" eval="'(None,)'" />
<field name="priority">1</field>
</record>

Maybe you are omitting this line:
<field name="active">True</field>
Functionally you can check it under Settings --> Automation --> Scheduled Actions with the debut mode activated.
What I can see on your code is that this 2 lines aren't well commented (you wanted to comment them or it was a copy pasta mistake?)
//<field name="interval_number">2</field>
//<field name="interval_type">minutes</field>
Check if that's the right time you want to run the next test, it is in UCT time, you can check the UTC time in linux with timedatectl on a terminal (in ubuntu at least)
<field name="nextcall" eval="(datetime.utcnow() + timedelta(days=0)).strftime('%Y-%m-%d 12:22:00')" />
I don't know in what context are you using this cron, but remember that the model must be the one that contains the function that you are calling. So, be sure that sd.cron has the method get_active_srs
<field name="model" eval="'sd.cron'" />
At the end, if you are not passing any arguments you can omit this line
<field name="args" eval="'(None,)'" />

Related

Odoo search Control panel model extension failed to evaluate domain

Im doing the odoo getting started tutorial and I get an error that I dont understand and dont know how to debug it. Im adding the search record, and have the following now.
<record id="estate_property_search" model="ir.ui.view">
<field name="name">estate.property.view.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search string="Search Opportunities">
<field name="name"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<filter string="Available" name="available" domain="[('date_availability', '=', context_today() )]"/>
<filter string="Archived" name="inactive" domain=" [('active', '=', False )]"/>
</search>
</field>
</record>
The archived filter is working correctly, the available filter is giving me the error:
Error: Control panel model extension failed to evaluate domain:/n{}
I'm pretty sure that this error is the result of code that is not correct because if I replace it False, then it works, and if I replace it with something random like toooday() then i get the same error. However, I see many examples on the internet using this code so I think it should work. I also tried odoo.fields.Date.context_today() and that doesnt work either.
It could be that Odoo is evaluating the domain on module update to get a safe domain for later use.
So context_today() alone is not working when evaluating because you can't use a pure date object in a domain. Just add .strftime('%Y-%m-%d') to it, and it should evaluate without an error.

PowerSchool Python API Plugin

I am attempting to connect to the PowerSchool SIS API via the Python PowerSchool library.
From the installation instructions here, I am stuck on the part where I need to create an XML file (including Oauth) for uploading as a plugin (via System > System Settings > Plugin Management Dashboard > {Your Plugin}). I am looking for an example showing how to do this in detail. I have tried looking at the information available in PowerSource here but this documentation does not show exactly what to do.
Thanks in advance for any help you can provide.
I think you must log in to the Powerschool system to install the plugin before you can connect to the API.
The plugin should look something like this...
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://plugin.powerschool.pearson.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation='http://plugin.powerschool.pearson.com plugin.xsd'
name="(Your Product Name)"
version="(Your Product Version)"
description="The plugin for PowerSchool integration with (Your Product Name)">
<oauth></oauth>
<publisher name="(Your Company Name)">
<contact email="(Your Email Address)" />
</publisher>
<access_request>
<field table="CodeSet" field="description" access="ViewOnly" />
<field table="CodeSet" field="codetype" access="ViewOnly" />
<field table="CodeSet" field="codesetid" access="ViewOnly" />
<field table="CodeSet" field="code" access="ViewOnly" />
<field table="STUDENTS" field="DCID" access="ViewOnly" />
<field table="STUDENTS" field="ID" access="ViewOnly" />
<field table="STUDENTS" field="first_name" access="ViewOnly" />
<field table="STUDENTS" field="last_name" access="ViewOnly" />
<field table="STUDENTS" field="grade_level" access="ViewOnly" />
<field table="TRANSPORTATION" field="DCID" access="FullAccess" />
<field table="TRANSPORTATION" field="ID" access="FullAccess" />
<field table="TRANSPORTATION" field="StudentId" access="FullAccess" />
<field table="TRANSPORTATION" field="Description" access="FullAccess" />
</access_request>
</plugin>
There are various places where you need to put your own information, like company name, product name, etc...
Then, you will need to put the tables and columns you want/need access to in the access_request node. Note, you must specify the type of access you require, such as ViewOnly or FullAccess.
This is a security measure. The Powerschool administrator for the school you are dealing with can then decide whether to allow the plugin or not. Once the plugin is installed, the Powerschool administrator should tell you the ClientId and the client secret to use for OAuth authentication.

Odoo 12 - Model not found even though it exists

I am porting a localization accountability model from Odoo 8 to Odoo 12, I ported a function that worked flawlessly but then right after that I tried porting some other code that does not interfere with the first on, even though, whenever it is initialized by the init.py Odoo brings up an error telling me that the model cannot be found, even though it is correctly set up.
All I've tried is to ignore the new modules I added right after setting up the one that should be perfectly working right now. Without them (or without any new module at all, because I've tried porting different ones) it works, but this shouldn't be the case at all.
wizard_nro_ctrl.py
class WizNroctrl(models.TransientModel):
_name = 'nroctrl'
_description = "Wizard that changes the invoice control number"
new_nroctrl = fields.Char('Control Number', required=True)
sure = fields.Boolean('Are you sure?')
# Change control number of the invoice
def set_noctrl(self):
if not self.sure:
raise except_orm('Error!', 'Please confirm that you want to do this by checking the option')
current_id = self._context['current_id']
inv_object = self.env['account.invoice'].browse(current_id)
inv_object.nro_ctrl = self.new_nroctrl
return True
wizard_nro_ctrl_view.xml
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<data>
<record model="ir.ui.view" id="wizard_nro_ctrl_form">
<field name="name">wizard.nro.ctrl.form</field>
<field name="model">nroctrl</field>
<field name="arch" type="xml">
<form string="Changing the Control Number">
<field name="new_nroctrl" placeholder="New control number"/>
<separator string="Are you sure you want to do this?" colspan="4"/>
<field name="sure"/>
<footer>
<button name="set_noctrl" string="Confirm" type="object"/>
<button special="cancel" string="Cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_wiz_nroctrl" model="ir.actions.act_window">
<field name="name">Change control number</field>
<field name="type">ir.actions.act_window</field>
<field name="model">wiz.nroctrl</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</odoo>
The init.py has the model initialized and the folder as well.
The model should work just fine, without this error. There's no reason to my knowledge for this issue.
odoo.tools.convert.ParseError: "Error while validating constraint
Model not found: nroctrl
Please make sure that in the model action you have wrote include model name 'nroctrl'. give the below xml code (nroctrl):
<record id="action_wiz_nroctrl" model="ir.actions.act_window">
<field name="name">Change control number</field>
<field name="type">ir.actions.act_window</field>
<field name="model">nroctrl</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
Also please ensure that you have given file name in init.py of wizard folder. also the folder name in ini.py of module.

"Field type <name> is not installed properly"

SharePoint's telling me the following field type is 'not installed properly'
<?xml version="1.0" encoding="utf-8" ?>
<FieldTypes>
<FieldType>
<Field Name="TypeName">InfoClass</Field>
<Field Name="ParentType">Choice</Field>
<Field Name="TypeDisplayName">xyzInfoClass</Field>
<Field Name="TypeShortDescription">xyzDescription</Field>
<Field Name="UserCreatable">FALSE</Field>
<Field Name="Sortable">TRUE</Field>
<Field Name="AllowBaseTypeRendering">FALSE</Field>
<Field Name="Filterable">TRUE</Field>
<Field Name="FieldTypeClass">SharePointProject1.CustomFieldType.InfoClass, SharePointProject1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=16fde6e7376d101b</Field>
<PropertySchema>
<Fields>
</Fields>
</PropertySchema>
<RenderPattern Name="DisplayPattern">
<Column HTMLEncode="TRUE" />
</RenderPattern>
</FieldType>
</FieldTypes>
I cut it down to what I pasted here and I still get the error. The namespace and assembly are correct and the dll is deployed to the GAC. Event receivers in the same project work, so I dont think it's the code. Having removed everything else I dont know what the problem could be
I'd ask in a proper sharepoint forum but I have IE7. so. this is the only site on the internet that works. and that includes the entire microsoft domain

SHAREPOINT: Custom Field type property storage defined for custom field

ok here is a great question. I have a set of generic custom fields that are highly configurable from an end user perspective and the configuration is getting overbearing as there are nearly 100 plus items each custom field allows you to perform in the areas of Server/Client Validation, Server/Client Events/Actions, Server/Client Bindings parent/child, display properties for form/control, etc, etc.
Right now I'm storing most of these values as "Text" in my field xml for my propertyschema. I'm very familiar with the multi column value, but this is not a complex custom type in sense it's an array. I also considered creating serilzable objects and stuffing them into the text field and then pulling out and de-serilizing them when editing through the field editor or acting on the rules through the custom spfield.
So I'm trying to take the following for example
<PropertySchema>
<Fields>
<Field Name="EntityColumnName" Hidden="TRUE" DisplayName="EntityColumnName" MaxLength="500" DisplaySize="200" Type="Text">
<default></default>
</Field>
<Field Name="EntityColumnParentPK" Hidden="TRUE" DisplayName="EntityColumnParentPK" MaxLength="500" DisplaySize="200" Type="Text">
<default></default>
</Field>
<Field Name="EntityColumnValueName" Hidden="TRUE" DisplayName="EntityColumnValueName" MaxLength="500" DisplaySize="200" Type="Text">
<default></default>
</Field>
<Field Name="EntityListName" Hidden="TRUE" DisplayName="EntityListName" MaxLength="500" DisplaySize="200" Type="Text">
<default></default>
</Field>
<Field Name="EntitySiteUrl" Hidden="TRUE" DisplayName="EntitySiteUrl" MaxLength="500" DisplaySize="200" Type="Text">
<default></default>
</Field>
</Fields>
<PropertySchema>
And turn it into this...
<PropertySchema>
<Fields>
<Field Name="ServerValidationRules" Hidden="TRUE" DisplayName="ServerValidationRules" Type="ServerValidationRulesType">
<default></default>
</Field>
</Fields>
<PropertySchema>
Ideas?????
I may have misunderstood the problem but from what I understand, could you create a generic field type property editor control and reference a editor user control in the xml rather than declare each individual piece of the editor interface declaratively?

Resources