Skip to content

Commit 6207c00

Browse files
authored
Merge pull request #13 from gpbonillas/master
Add method for returns the map with content of fields that the new row was filled * more doc * change the write command return as an object in session to be more generic * handle the trypage in the objectadapter to better deal with versions
2 parents 05bc66f + 9c34673 commit 6207c00

File tree

7 files changed

+212
-153
lines changed

7 files changed

+212
-153
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,28 @@ openERPSession.executeCommandWithContext("account.move.reversal", "reverse_moves
8989
);
9090
```
9191

92+
## Getting fields for audit / tracking purposes
93+
94+
```
95+
// authenticate
96+
97+
ObjectAdapter partnerAdapter = session.getObjectAdapter("res.partner");
98+
99+
Row newPartner = partnerAdapter.getNewRow(new String[]{"name", "ref", "email", "field1", "field2"});
100+
newPartner.put("name", "Jhon Doe");
101+
newPartner.put("ref", "Reference value");
102+
newPartner.put("email", "personalemail@mail.com");
103+
newPartner.put("field1", "1");
104+
newPartner.put("field2", "2");
105+
106+
partnerAdapter.createObject(newPartner);
107+
108+
// Getting fields for tracking/audit purposes
109+
HashMap<String, Object> rowSaved = newPartner.getFieldsOdoo().toString();
110+
111+
saveToDatabaseForTrackingPurpose(rowSaved);
112+
saveToDatabaseForTrackingPurpose(newPartner.getID());
113+
```
92114

93115
# Other ressources [legacy]
94116

pom.xml

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
55

6-
<groupId>com.odoojava</groupId>
7-
<artifactId>odoo-java-api</artifactId>
8-
<version>3.1.6</version>
9-
<packaging>jar</packaging>
6+
<groupId>com.odoojava</groupId>
7+
<artifactId>odoo-java-api</artifactId>
8+
<version>3.1.7</version>
9+
<packaging>jar</packaging>
1010

11-
<name>odoo-java-api</name>
12-
<url>http://maven.apache.org</url>
11+
<name>odoo-java-api</name>
12+
<url>http://maven.apache.org</url>
1313

14-
<properties>
15-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<maven.compiler.source>1.8</maven.compiler.source>
17-
<maven.compiler.target>1.8</maven.compiler.target>
18-
</properties>
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
18+
</properties>
1919

20-
<dependencies>
21-
<dependency>
22-
<groupId>junit</groupId>
23-
<artifactId>junit</artifactId>
24-
<version>4.12</version>
25-
<scope>test</scope>
26-
</dependency>
27-
<dependency>
28-
<groupId>org.apache.xmlrpc</groupId>
29-
<artifactId>xmlrpc-client</artifactId>
30-
<version>3.1.3</version>
31-
</dependency>
32-
<dependency>
33-
<groupId>org.assertj</groupId>
34-
<artifactId>assertj-core</artifactId>
35-
<version>3.3.0</version>
36-
<scope>test</scope>
37-
</dependency>
38-
<dependency>
39-
<groupId>org.mock-server</groupId>
40-
<artifactId>mockserver-netty</artifactId>
41-
<version>3.10.2</version>
42-
<scope>test</scope>
43-
</dependency>
44-
<dependency>
45-
<groupId>javax.xml.bind</groupId>
46-
<artifactId>jaxb-api</artifactId>
47-
<version>2.4.0-b180830.0359</version>
48-
</dependency>
49-
<dependency>
50-
<groupId>org.eclipse.lsp4j</groupId>
51-
<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId>
52-
<version>0.9.0</version>
53-
</dependency>
54-
<dependency>
55-
<groupId>com.github.briandilley.jsonrpc4j</groupId>
56-
<artifactId>jsonrpc4j</artifactId>
57-
<version>1.5.1</version>
58-
</dependency>
59-
</dependencies>
60-
<organization>
61-
<name>odoo-java</name>
62-
<url>http://odoo-java.com</url>
63-
</organization>
64-
<scm>
65-
<url>https://github.com/odoo-java/odoo-java-api</url>
66-
</scm>
67-
<issueManagement>
68-
<url>https://github.com/odoo-java/odoo-java-api/issues</url>
69-
</issueManagement>
20+
<dependencies>
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<version>4.12</version>
25+
<scope>test</scope>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.apache.xmlrpc</groupId>
29+
<artifactId>xmlrpc-client</artifactId>
30+
<version>3.1.3</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.assertj</groupId>
34+
<artifactId>assertj-core</artifactId>
35+
<version>3.3.0</version>
36+
<scope>test</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.mock-server</groupId>
40+
<artifactId>mockserver-netty</artifactId>
41+
<version>3.10.2</version>
42+
<scope>test</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>javax.xml.bind</groupId>
46+
<artifactId>jaxb-api</artifactId>
47+
<version>2.4.0-b180830.0359</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.eclipse.lsp4j</groupId>
51+
<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId>
52+
<version>0.9.0</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>com.github.briandilley.jsonrpc4j</groupId>
56+
<artifactId>jsonrpc4j</artifactId>
57+
<version>1.5.1</version>
58+
</dependency>
59+
</dependencies>
60+
<organization>
61+
<name>odoo-java</name>
62+
<url>http://odoo-java.com</url>
63+
</organization>
64+
<scm>
65+
<url>https://github.com/odoo-java/odoo-java-api</url>
66+
</scm>
67+
<issueManagement>
68+
<url>https://github.com/odoo-java/odoo-java-api/issues</url>
69+
</issueManagement>
7070
</project>
Lines changed: 84 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright 2011, 2013-2014 De Bortoli Wines Pty Limited (Australia)
3-
*
3+
*
44
* This file is part of OpenERPJavaAPI.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,83 +24,89 @@
2424

2525
/**
2626
* Provides the session context object that is used in calls to the server.
27-
* @author Pieter van der Merwe
2827
*
28+
* @author Pieter van der Merwe
2929
*/
30-
public class Context extends HashMap<String, Object>{
31-
32-
private static final long serialVersionUID = 1L;
33-
final static String ActiveTestTag = "active_test";
34-
final static String LangTag = "lang";
35-
final static String TimezoneTag = "tz";
36-
37-
38-
@Override
39-
public void putAll(Map<? extends String, ? extends Object> m) {
40-
// TODO Auto-generated method stub
41-
super.putAll(m);
42-
}
43-
44-
/**
45-
* Gets the active_test context property.
46-
* @return The active_test value or null if the property doesn't exist.
47-
*/
48-
public Boolean getActiveTest(){
49-
if (!this.containsKey(ActiveTestTag))
50-
return null;
51-
52-
return Boolean.parseBoolean(this.get(ActiveTestTag).toString());
53-
}
54-
55-
/**
56-
* Sets the active_test context value. If true, only active items are returned by default when calling the ReadObject item.
57-
* @param active_test
58-
*/
59-
public void setActiveTest(boolean active_test){
60-
this.remove(ActiveTestTag);
61-
this.put(ActiveTestTag, active_test);
62-
}
63-
64-
/**
65-
* Gets the 'lang' context value.
66-
* @return Language or null if the property doesn't exist.
67-
*/
68-
public String getLanguage() {
69-
if (!this.containsKey(LangTag))
70-
return null;
71-
72-
return this.get(LangTag).toString();
73-
}
74-
75-
/**
76-
* Sets the 'lang' context value.
77-
* @param lang Examples "en_US", "nl_NL"
78-
*/
79-
public void setLanguage(String lang) {
80-
this.remove(LangTag);
81-
this.put(LangTag, lang);
82-
}
83-
84-
/**
85-
* Gets the 'tz' context value.
86-
* @return Time zone string or null if the property doesn't exist
87-
*/
88-
public String getTimeZone() {
89-
if (!this.containsKey(TimezoneTag))
90-
return null;
91-
92-
if (this.get(TimezoneTag) instanceof Boolean && Boolean.getBoolean(this.get(TimezoneTag).toString()) == false)
93-
return null;
94-
95-
return this.get(TimezoneTag).toString();
96-
}
97-
98-
/**
99-
* Sets the 'tz' context flag.
100-
* @param tz Examples "Australia/Sydney", "Europe/Brussels"
101-
*/
102-
public void setTimeZone(String tz) {
103-
this.remove(TimezoneTag);
104-
this.put(TimezoneTag, tz);
105-
}
30+
public class Context extends HashMap<String, Object> {
31+
32+
private static final long serialVersionUID = 1L;
33+
final static String ActiveTestTag = "active_test";
34+
final static String LangTag = "lang";
35+
final static String TimezoneTag = "tz";
36+
37+
38+
@Override
39+
public void putAll(Map<? extends String, ? extends Object> m) {
40+
// TODO Auto-generated method stub
41+
super.putAll(m);
42+
}
43+
44+
/**
45+
* Gets the active_test context property.
46+
*
47+
* @return The active_test value or null if the property doesn't exist.
48+
*/
49+
public Boolean getActiveTest() {
50+
if (!this.containsKey(ActiveTestTag))
51+
return null;
52+
53+
return Boolean.parseBoolean(this.get(ActiveTestTag).toString());
54+
}
55+
56+
/**
57+
* Sets the active_test context value. If true, only active items are returned by default when calling the ReadObject item.
58+
*
59+
* @param active_test
60+
*/
61+
public void setActiveTest(boolean active_test) {
62+
this.remove(ActiveTestTag);
63+
this.put(ActiveTestTag, active_test);
64+
}
65+
66+
/**
67+
* Gets the 'lang' context value.
68+
*
69+
* @return Language or null if the property doesn't exist.
70+
*/
71+
public String getLanguage() {
72+
if (!this.containsKey(LangTag))
73+
return null;
74+
75+
return this.get(LangTag).toString();
76+
}
77+
78+
/**
79+
* Sets the 'lang' context value.
80+
*
81+
* @param lang Examples "en_US", "nl_NL"
82+
*/
83+
public void setLanguage(String lang) {
84+
this.remove(LangTag);
85+
this.put(LangTag, lang);
86+
}
87+
88+
/**
89+
* Gets the 'tz' context value.
90+
*
91+
* @return Time zone string or null if the property doesn't exist
92+
*/
93+
public String getTimeZone() {
94+
if (!this.containsKey(TimezoneTag))
95+
return null;
96+
97+
if (this.get(TimezoneTag) instanceof Boolean && Boolean.getBoolean(this.get(TimezoneTag).toString()) == false)
98+
return null;
99+
100+
return this.get(TimezoneTag).toString();
101+
}
102+
103+
/**
104+
* Sets the 'tz' context flag.
105+
*
106+
* @param tz Examples "Australia/Sydney", "Europe/Brussels"
107+
*/
108+
public void setTimeZone(String tz) {
109+
this.remove(TimezoneTag);
110+
this.put(TimezoneTag, tz);
111+
}
106112
}

0 commit comments

Comments
 (0)