In odoo every model will be having a write_date column which will store the last edited time and date of the record.I want to take the value of that field to a variable/ field. But when I print this , it is printing False . What to do.?
code
variable = self.write_date
Thanks in Advance..
The problem is that you're getting in self a new recordset (odoo.models.NewId object at 0x7fe0c05717d0). Therefore, you're trying to get the write_date of a record which has not been created yet. If the record has never been updated (even not created), it's not going to have a value in write_date.
Remember that write_date stores the latest date in which the record was updated.
So, first, at least, you must create the record, and then, you will be able to apply this: variable = self.write_date.
But take a look at this:
What's happening with these transient models' IDs?
May be you get the write_date without creating the record, give a try to this: variable = self._origin.write_date.
Even though we can see a field named write_date in the table, First of all, what we have to do is that you have to add a field named write_date into your model and then try the same.
write_date = fields.Datetime(string='Write Date') solved my problem.Thanks everyone for helping.
Related
I have an option value in the wp_options table as such: option_name . twitter_feed . and the value is there in the options value column. But when I run the following in my code, I get false:
$tf = get_option('twitter_feed');
var_dump($tf);
I have access to my DB and I can see that there is an option named twitter_feed and there is a value. The value starts with a format of:
a:20:{i:0;O:8:"stdClass":28:{s:10:"created_at";s:30:"Tue Sep 19 22:16:26 +0000 2017";s:2:"id";i:910266359799525376;s:6:"id_str";s:18:"910266359799525376";s:4:"text";s:70:"We can't wait for the Grand Opening on Oct 19!'
Does the format that is saved in the DB has anything to do with not being able to pull the value? I would assume I would at least get an error and not false.
I also have a facebook_feed value that works. It is also an option in the wp_options table of facebook_feed and that value starts with a format of:
a:25:{i:0;a:6:{s:7:"message";s:412:""Our scientific and research-based training and programs were devised to help
How can I access the value of my twitter_feed value?
This looks like serialized data. See:
http://php.net/manual/en/function.unserialize.php
Let me know if this helps.
I tried this:
$ff = get_option('twitter_feed');
$ff = unserialize($ff);
var_dump($ff);
the same false. Since I have access to the DB, I grabbed the original twitter feed value and save it to a text editor and then copied the facebook feed value and placed it in the twitter_feed options value. Still FALSE. This makes no sense. AS I have a facebook_feed option and a twitter_feed option both with the same value in my wp_options table and only the facebook_feed works. I have deleted all of the transients in wp_options table thinking this might be an issue but no luck.
Any other ideas?
Well after many hours I finally got it working. I inherited this WP site and it seems to have been coded by someone who just learned OOP. Got to give them props for trying but Many issues. So I created a brand new function to consume the Twitter API and save the new feed in my twitter_feed options value and that worked. Not sure if the data was corrupted, but when I would try to pull the original data out I would receive a FALSE value. Now with the new data feed saved, it works.
Thanks Paul for the suggestion.
I am trying to build a PowerApp to log setup times of our machines by our fitters.
This is what my app looks like:
There are buttons named "Uhrzeit". Pressing these will write the current date and time into the Date/Time fields. I am using the following code:
UpdateContext({Total8:(Text( Now(); "[$-de-DE]dd/mm/yyyy hh:mm:ss" ))})
The Date/Time field is named Total8.
The code is working well but after saving the form and opening a new record the old data is still available in the fields. By clicking on the button "Zeiten zurücksetzen" I can "delete" the old data.
UpdateContext({Total8:""})
Problem: When I open one of the older records the old data is not available in the form. There is only the value of the last record. In the Common Data Service where my records are saved the values are correct.
As an example, I am saving this record:
When I open a new record, the values of the record 1 are still available. This should not be the case if my app worked properly.
For your Information:
If I enter the date/time without tapping the button, saving the record and opening a new record I don't have the problem. I think the "UpdateContext" code is not the code I should use here.
Can anyone help me solve the problem?
I don't think there's a problem with using the contexts in this way -- but remember that a context is just a variable. It isn't automatically linked to a datasource in any special way - so if you set it equal to Now(), it's going to keep that value until you do something different.
When you view an old record, you need to get the data from CDS and update your contexts to match the CDS data. Does this make sense?
Yeah thats my problem.
I want the variable to be linked to a datasource. Or is it possible to write the date/time into the fields without using a context variable?
I have datasource on a form created by code.
formBuildDataSource = form.addDataSource("My_table");
than I open a detail which has datasource from same table and dynamic link and same data row. When I change something od detail and than run
getFirstSelection(formCaller.dataSource(1));
I do not get old data but the new modified data. Is there a way how to get old data from base form before this modification? Somehowmake data datasource on old form unchangable (for whole existence of form).
When I set
formBuildDataSource.autoQuery(false);
formBuildDataSource.autoSearch(false);
than I see no data on a first form. So it would be nice to do something like:
formBuildDataSource.getData();
formBuildDataSource.autoQuery(false);
formBuildDataSource.autoSearch(false);
The Args.record(...) is used for something else so it would be nice to do not need to use it.
I am using AX 2012.
It isn't very clear what you are trying to achieve. If, after modifying a record, you want to check what values its fields had before the change ("Is there a way how to get old data from base form before this modification"), you could have made a copy of the original record before making the changes, e.g.
MyTable myTableOrig = myTable.data();
or if you don't need system fields then
MyTable myTableOrig;
buf2Buf(myTable, myTableOrig);
After that you can always compare current myTable field values and original field values copied to myTableOrig.
In apex code I want to enumerate the legal values for a picklist field. To do this I can just call Account.Foobar__c.getDescribe().getPickListValues() and I've got a list of Schema.PickListEntry values.
However it's possible to setup multiple record types for a given sObject. For example Account might have "Manufacturer", "Distributor" and "Retailer" record types. In the Salesforce setup it is possible edit (limit) the picklist entries for each field based on record type. So Retailer type accounts might only use a subset of the picklist values for the Foobar field.
So basically I want Account.Foobar__c.getDescribe().getPickListValues('Retailer') however this is not the syntax. The validFor method looks promising, but it seems like it is only for field dependent picklists - a picklist filtered only by record type returns false for isDependentPicklist.
I know this is an old post, but maybe the info below will help someone who still needs the answer.
I found here that one can actually get a list of record type specific picklist values by making a describeLayout() call.
Using your example (C#):
DescribeLayoutResult result = binding.describeLayout("Account", new string[] { "01230000000xxXxXXX" } );
PicklistEntry[] values = result.recordTypeMappings[0].picklistsForRecordType[12345].picklistValues;
Replace "01230000000xxXxXXX" with a RecordTypeId of your Retailer record type object. Use the query "SELECT Id FROM RecordType WHERE Name = 'Retailer'" to get the value.
Replace 12345 with an index of your picklist object that you would like to get values of.
You can't do it in pure Apex AFAIK, unfortunately. The metadata API does expose it.
Related opinions: http://boards.developerforce.com/t5/Apex-Code-Development/Any-way-to-obtain-picklist-values-by-record-type/td-p/287563
I have a datagrid that uses an array of objects as the data provider. The objects are essentially key/value pairs:
{ foo:"something"}
{ bar:"hello"}
{ caca:"lorem"}
The datagrid has 2 columns. The first column is the key and the second column is the value. Right now my grid looks like:
My dataFormatter function makes sure that depending on the column (i.e. the dataField value) the correct key or value gets printed out. This works fine for displaying. However, as soon as I try and edit the value field it essentially adds a new value into the object with a key of '1'. For example, if I edit the {caca:"lorem"} object it will then contain the value {caca:"lorem",1:"new value"}.
Is there any possible way I can set the DataGridColumn so that when I edit a value it will update the value associated with the key rather than inserting a new value? I've tried using a custom item editor but it still does the insert. It seems like I need to be able to update the 'dataField' with the actual key value but I'm not sure how to do that.
Looks like you need to think about where your data is going to be stored. I would recommend listening for a CollectionEvent.COLLECTION_CHANGE event on your data model. That event object will contain info about what change occurred, and you can make any updates you need to make.