Some data imports are simple and others I am finding impossible!
The ImportFAQ document is OK up to a point but not quite adequate for some imports.
The import-compatible export is not, as far as I can tell, comprehensive in specifying the mandatory fields for an import. Or am I missing something?
Specifically I am trying to import an Inventory Transfer from stock to a specific customer - any suggestions how to find the minimum set of fields needed in the import file?
Eg when I try - despite there being a valid product_id - I get
null value in column "product_id" violates not-null constraint
DETAIL:
Failing row contains (187, Canis Plus Lamb - 500g - Rolle, 10, 1, 2019-02-25
16:29:58.929875, 2019-02-23 17:49:58, 1, 2019-02-23 17:49:21, null, 5.0,
10.000, null, null, 12, 9, null, 103, null, draft, null, null,
make_to_stock, f, null, null, t, null, null, null, null, null, f, null,
null, 2, 2, 2019-02-25 16:29:58.929875, f, null, null, null, null, null). at row 2
Is the data that follows in the error message useful/usable in any way?
Happy to post my import file but at the moment most keen to understand the principles rather than solve one problem. I think others might find that useful too.
Cant ask on the Odoo Forum as I dont have enough karma so any assistance here would be most welcome. Thanks
The import compatible export doesn't specify required fields in any way, the only difference is the import compatible export keeps the header of the exported document (csv/excel) such that, headers are actual technical name of the fields that's getting exported, so same the document can be imported without any need of manually selecting the columns. You don't get the functionality if your column headers are not matching with underlying fields name. The error message specifically mentioned that product_id field is null, even if you added product_id column, that column is not mapped with the required field, for example in case of importing stock.picking (Inventory Transfer) document, every line in stock.picking record is a stock.move record and for a stcok.move record, product_id is having not null constraint. So if you somehow managed to map product_id column with wrong related field, you get this error message.
If you had attach example of your file, it would be much easier.
I have generated a working stock.picking for you to test, just import as it is, but you have to change the value of move_lines/product_id/.id and partner_id/.id fields according to your product and partner database ID.
name,company_id/id,location_dest_id/id,picking_type_id/id,move_type,location_id/id,move_lines/product_id/.id,move_lines/product_uom_qty,move_lines/date_expected,move_lines/location_dest_id/id,move_lines/name,move_lines/date,move_lines/location_id/id,move_lines/procure_method,move_lines/product_uom/id,partner_id/.id
IMPORT0001,base.main_company,stock.stock_location_stock,stock.picking_type_in,As soon as possible,stock.stock_location_suppliers,1000,40,2019-04-05 19:41:54,stock.stock_location_stock,"Digitizer (Black, OEM, Apple iPad)",2019-04-07 08:32:24,stock.stock_location_suppliers,Default: Take From Stock,product.product_uom_unit,705
Related
I'm attempting to use a Banner API Call.
per the documentation the create call looks like this.
PROCEDURE p_create(
p_pidm gorimmu.gorimmu_pidm%TYPE,
p_immu_code gorimmu.gorimmu_immu_code%TYPE,
p_seq_no gorimmu.gorimmu_seq_no%TYPE,
p_user_id gorimmu.gorimmu_user_id%TYPE DEFAULT gb_common.f_sct_user,
p_immu_date gorimmu.gorimmu_immu_date%TYPE DEFAULT NULL,
p_imst_code gorimmu.gorimmu_imst_code%TYPE DEFAULT NULL,
p_comment gorimmu.gorimmu_comment%TYPE DEFAULT NULL,
p_data_origin gorimmu.gorimmu_data_origin%TYPE DEFAULT NULL,
p_seq_no_out OUT gorimmu.gorimmu_seq_no%TYPE,
p_rowid_out OUT gb_common.internal_record_id_type);
I'm not sure how to use the last two fields that have OUT.
I've used other API calls..but none of them used an OUT.
any help is appreciated..banner documentation not helpful
That just means you must provide a parameter for the API call to populate. So define two variables to pass in such as:
l_seq_no_out gorimmu.gorimmu_seq_no%TYPE;
l_rowid_out gb_common.internal_record_id_type;
Then just pass those as the last two parameters to the p_create call.
When trying to fetch the SalesInvoices class from the Exact Online REST API all the relevant document entries stay empty. I'm using the Exact Online Python SDK for fetching these SalesInvoices.
The code used:
return self.api.invoices.filter(
filter="Customer eq guid'{}'".format(self.api.relations.get(relation_code=relation_code)['ID']),
top=10,
orderby='EntryNumber desc')
Which gives the following response:
"Document": null,
"DocumentNumber": null,
"DocumentSubject": null,
While the SalesInvoice does have a generated document:
I have contacted Exact Online support but so far have gotten no reply
See picture. The Document, DocumentNumber and DocumentSubject are available in ExactOnlineREST..SalesInvoices:
But... the evil is in the detail, because documentation reads:
Document that is manually linked to the invoice
And indeed, this field only gets a value when you manually add a document to the invoice such as before printing it.
When you need all documents and files attached to the sales invoice, please use something like:
select dat.url
from salesinvoices sie
join exactonlinerest..documents dct
on dct.salesinvoicenumber = sie.invoicenumber
and dct.type=10 /* Optional to improve performance. */
join ExactOnlineREST.Documents.DocumentAttachments dat
on dat.document = dct.id
Please change this into Python code, but the syntax and join order and arguments are clear.
I'm developing small application.
It is small CMS like application. Admin of this site should have option to change settings in application. Like text in header, message of the day.
Where should I store those values? Table in database? Some kind of file? I want admin to be able to change those values from website without manually editing files on server.
I think the small table in DB with WebSiteSettings would be the best solution as for me.
EDITED
WebSiteSettings table example:
PK Id [int] not null
StrTmplVal_1 [nvarchar(128)] null
StrTmplVal_2 [nvarchar(256)] null
StrTmplVal_3 [nvarchar(512)] null
BoolTmplVal_1 [bit] null
BoolTmplVal_2 [bit] null
BoolTmplVal_3 [bit] null
IntTmplVal_1 [int] null
IntTmplVal_2 [int] null
IntTmplVal_3 [int] null
WebSiteSettings model example for an individual website:
SettingsId -> Id
SiteName -> StrTmplVal_1
PageHeader -> StrTmplVal_2
WelcomeText -> StrTmplVal_3
IsDemoVersion -> BoolTmplVal_1
IsTilesShowed -> BoolTmplVal_2
MaxRowCountOnPage -> IntTmplVal_1
WelcomeAnimationDelay -> IntTmplVal_2
I suppose a table following this structure would be a start:
Table Settings
ID(int, primary key), Name(varchar)
Table SettingValues ID(int, primary key), SettingID(int foreign key), Value(blob)
Please note that I use BLOB (Binary Large Object) type for the actual value of the setting. Therefore, you could save the settings just by serializing them.
Hope I helped!
This is a question that has to do more about performance and implementation. I want to create an app for getting info about tv series and would like to use thetvdb.com api. thetvdb offers an xml api and some guides to get u started. For initialization they say you must download a zip file (according to the id of the series you want to add).
The xml consists of three xml files. One is about the actors, one is about the banners and one that has all the info about the tv show inclucing seasons and episodes and overviews etc. The guide says that you parse the xml and add them to the tables of your db as you like.
My question is the following: Is it better to download the xml parse it and store it in my db and delete the xmls? Or should I use the xmls and parse them every time i want to get the show's info and present them to the user? What is the cost of one implementation and what is the cost of the second one?
No code yet since I am still designing it.
I would definitely parse the xml files and put them in to a database. Parsing xml files has considerable overhead - and relational databases are designed with the intent of querying the data inside them, and are very performant at this (especially if you design your database well , provide useful indexes and logical joins between the tables.
I think the right solution could depend on your application load(how many users will simultaneously use it), the average size and structure of xml files and the need to refresh the data.
The possible solutions are:
If the xml files are not very big and complicated and don't contain a lot of unwanted information you possibly do not need to store this info in your db.
In this case you can add the caching layer to your app that will store the files and repeatedly get them from the thetvdb if the previous request was too long time ago.
If you think that you can send the required information to the clients in more compact or convenient way or it requires additional processing or you are planning to execute some group opperations on your data in the future then the better option is to store the data in db
Also think about refreshing the data in your db (similarly to the 2-nd option).
Also you can store only critical information in your db.
Update: Generally I would not recommend to use local databases as in future it could cause problems with schema migration (when you want to change something in your db schema).
Storing data into a db is definitely the best way if you have to execute particular queries. I'm also using TheTVDB APIs (integrated in Wordpress) and I can give you some PHP code. First you have to create the DB with the following code, then you have the PHP script that insert data from the XML url of a TV show.
SQL query:
CREATE TABLE IF NOT EXISTS `tvshowsinfo` (
`id` int(9) NOT NULL AUTO_INCREMENT,
`showname` varchar(255) CHARACTER SET utf8 NOT NULL,
`lang` varchar(255) CHARACTER SET utf8 NOT NULL,
`episodeid` int(9) NOT NULL,
`episodenumber` int(5) NOT NULL,
`season` int(5) NOT NULL,
`director` varchar(255) CHARACTER SET utf8 NOT NULL,
`episodename` varchar(255) CHARACTER SET utf8 NOT NULL,
`firstaired` varchar(255) CHARACTER SET utf8 NOT NULL,
`gueststars` text CHARACTER SET utf8 NOT NULL,
`overview` text CHARACTER SET utf8 NOT NULL,
`rating` varchar(255) CHARACTER SET utf8 NOT NULL,
`ratingcnt` int(9) NOT NULL,
`writer` varchar(255) CHARACTER SET utf8 NOT NULL,
`episodeimg` varchar(255) CHARACTER SET utf8 NOT NULL,
`seasonid` int(9) NOT NULL,
`seriesid` int(9) NOT NULL,
`thumbht` int(4) NOT NULL,
`thumbwd` int(4) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
PHP/Wordpress script:
<?php
$url = "Your URL";
$xmlstr = file_get_contents($url);
$elements = json_decode(json_encode((array)simplexml_load_string($xmlstr)),1);
global $wpdb;
$mquery = "INSERT INTO tvshowsinfo (showname,lang,episodeid,episodenumber,season,director,episodename,firstaired,gueststars,overview,rating,ratingcnt,writer,episodeimg,seasonid,seriesid,thumbht,thumbwd) VALUES ";
$i = 0;
foreach ($elements['Episode'] as $element) {
if ($i !== 0) { $mquery .= ", "; }
if ($element["Combined_season"] !== "0") {
$mquery .= "('".mysql_real_escape_string($_POST["seriesname"])."', '".$element["Language"]."', '".$element["id"]."', '".$element["Combined_episodenumber"]."', '".$element["Combined_season"]."', '".mysql_real_escape_string($element["Director"])."', '".mysql_real_escape_string($element["EpisodeName"])."', '".$element["FirstAired"]."', '".mysql_real_escape_string($element["GuestStars"])."', '".mysql_real_escape_string($element["Overview"])."', '".$element["Rating"]."', '".$element["RatingCount"]."', '".mysql_real_escape_string($element["Writer"])."', 'http://thetvdb.com/banners/".$element["filename"]."', '".$element["seasonid"]."', '".$element["seriesid"]."', '".$element["thumb_height"]."', '".$element["thumb_width"]."')";
$i++;
}
}
$wpdb->query($mquery);
$wpdb->print_error();
/* DEBUG */
?>
<pre><?php print_r($elements); ?></pre>
Where can I find a database of European countries and related cities to implement country/city dropdown list (dynamic) in the web-page?
UPDATE: I´m interested in some database that I can utilize from the javascript or php source code. This is to avoid manual work.
My answer: I have found one more good free resource: http://www.geodatasource.com/world-cities-database
MaxMind World Cities is a free list that you can download and use in your app (assuming that the license is ok for your purposes). Otherwise they've also got a webservice (though you have to pay for that).
An alternative is GeoNames.
http://en.wikipedia.org/wiki/Europe#Political_geography
Wikipedia always works :)
For some reason I thought about capitals only, but I guess you mean all cities.
Take a look at:
http://download.geonames.org/export/dump/
Check out the readme.txt which has more info.
Perhaps cities1000.zip could be used as a base for you. Maybe you need to create a database with the countries you want, and then perhaps filter the list from the link above by ISO-code or something.
The readme also mentions some continent code, so maybe that can be of use?
http://www.webservicex.net/country.asmx/GetCountries list of countries in xml
http://www.timdavis.com.au/data/
Get an excel for list of country and state.
You need use Jquery for dynamic ajax dropdown list. See here php/ajax script -
http://myip.ms/info/cities_sql_database/
Cities table format will be -
CREATE TABLE `cities` (
`cityID` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`cityName` varchar(50) NOT NULL,
`stateID` smallint(5) unsigned NOT NULL DEFAULT '0',
`countryID` varchar(3) NOT NULL DEFAULT '',
`language` varchar(10) NOT NULL DEFAULT '',
`latitude` double NOT NULL DEFAULT '0',
`longitude` double NOT NULL DEFAULT '0',
PRIMARY KEY (`cityID`),
UNIQUE KEY `unq` (`countryID`,`stateID`,`cityID`),
KEY `cityName` (`cityName`),
KEY `stateID` (`stateID`),
KEY `countryID` (`countryID`),
KEY `latitude` (`latitude`),
KEY `longitude` (`longitude`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;