Skip to content

Commit 6250553

Browse files
committed
Constants added for relationship actions.
1 parent cd1b98f commit 6250553

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ fail to make the OpenERP/Odoo version number clear.
123123

124124
# TODO
125125

126-
* Docs on config (this package supports multiple clients, so can connect
127-
to multiple Odoo instances or as multiple users at the same time).
128-
* Docs on installation (has a auto discovered provider and facade).
129-
Includes details on how to publish the config file.
130126
* The write functions are not written yet (create, write and unlink).
131-
* The search_read method is not supported yet.
132-
* The setting of the configuration could be done in a more fluent
133-
way, as tends to be the Laravel way. But it's no biggie.
127+
* Examples on how relationships are managed are needed, since they are
128+
one of the areas that cause the most confusion.

src/OdooClient.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,53 @@ class OdooClient
2828

2929
const DEFAULT_LIMIT = 100;
3030

31+
/**
32+
* The action to perform when updating a one-to-many relation.
33+
* Note: a many-to-many relation is treated like a one-to-many
34+
* relation from each side.
35+
* - Actions 0 to 2 manage CRUD operations on the models being
36+
* linked to.
37+
* - Actions 3 to 6 manage just the relationship between existing
38+
* models.
39+
*/
40+
// Adds a new record created from the provided value dict.
41+
// (0, _, values)
42+
const RELATION_CREATE = 0;
43+
//
44+
// Updates an existing record of id `id` with the values in values.
45+
// Can not be used in create().
46+
// (1, id, values)
47+
const RELATION_UPDATE = 1;
48+
//
49+
// Removes the record of id `id` from the set, then deletes it
50+
// (from the database).
51+
// Can not be used in create().
52+
// (2, id, _)
53+
const RELATION_DELETE = 2;
54+
//
55+
// Removes the record of id `id` from the set, but does not delete it.
56+
// Can not be used on One2many. Can not be used in create().
57+
// (3, id, _)
58+
const RELATION_REMOVE_LINK = 3;
59+
//
60+
// Adds an existing record of id `id` to the set. Can not be used on One2many.
61+
// (4, id, _)
62+
const RELATION_ADD_LINK = 4;
63+
//
64+
// Removes all records from the set, equivalent to using the
65+
// command 3 on every record explicitly.
66+
// Can not be used on One2many.
67+
// Can not be used in create().
68+
// (5, _, _)
69+
const RELATION_REMOVE_ALL_LINKs = 5;
70+
//
71+
// Replaces all existing records in the set by the ids list,
72+
// equivalent to using the command 5 followed by a command 4
73+
// for each id in ids.
74+
// Can not be used on One2many.
75+
// (6, _, ids)
76+
const RELATION_REPLACE_ALL_LINKS = 6;
77+
3178
/**
3279
* Later versions of the API include a version number e.g. /xmlrpc/2/
3380
*/

0 commit comments

Comments
 (0)