rodoo 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03ac273092ec11431199a18290e4d411f7a900e8236b2762817182b8906bd27a
4
- data.tar.gz: 8160dffa4ffd00dea1654be504b9900dfff1f8980083037abda70a5bd3751eee
3
+ metadata.gz: 6296d9a68fe77f42b8a9077cceffbb4f444a72cd2e483e39f5c8e5c2b8e544d7
4
+ data.tar.gz: ae9f0cd4ec90a8b199750929c46ca59e93582b03b77be7cf97b72475f45b99a5
5
5
  SHA512:
6
- metadata.gz: 830a2ccb8769ae5731f349d59c04f52d48dc2645bcce94e85dd74e9e512b8aaa3ff12b772dff5b89d9e7ecfd56015b68b2cf27b98caeb7105d22f3cd634094b3
7
- data.tar.gz: 4d40594ee7327b47ae32cca4ec5c31805ea081ff380ddf6d1234d056ab32dff29b2c5210daf79f035887bd89827a8126fdd6d2ed28da25afc2b74cf86d2d5716
6
+ metadata.gz: 3b66d9c307b38d5eb0f9a3de01917dca2d2469a4019193b56806b3e7a41e8957a136a2f354c9a95eaae3f3e9da093cbcffb053f9bedc5bcff644897d1b7715d5
7
+ data.tar.gz: 324854d54a34edf6c2a91ad6f4523db61017ca83dd7a77c6c1f69ba72d452273d93d46ecb0627ccf53bcd3a92866ad8b1c03c7ad20fef6789b38634823581e4a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2026-01-26
4
+
5
+ ### Added
6
+
7
+ - Add `message_post` instance method for posting messages to Odoo records
8
+
3
9
  ## [0.3.0] - 2026-01-22
4
10
 
5
11
  ### Added
data/README.md CHANGED
@@ -107,6 +107,30 @@ all_contacts = Rodoo::Contact.all(limit: 100)
107
107
 
108
108
  Supported operators in string conditions: `=`, `!=`, `<>`, `<`, `>`, `<=`, `>=`, `like`, `ilike`, `=like`, `=ilike`
109
109
 
110
+ ### Language-specific responses
111
+
112
+ Use the `lang:` parameter to retrieve translatable fields (like `name`, `description`) in a specific language:
113
+
114
+ ```ruby
115
+ # Find with language
116
+ contact = Rodoo::Contact.find(42, lang: "fr_FR")
117
+ contact.name # => "Société Acme" (French translation)
118
+
119
+ # Query with language
120
+ products = Rodoo::Product.where(type: "consu", lang: "es_ES")
121
+
122
+ # All records with language
123
+ contacts = Rodoo::Contact.all(limit: 100, lang: "de_DE")
124
+
125
+ # Find by with language
126
+ contact = Rodoo::Contact.find_by(email: "john@example.com", lang: "it_IT")
127
+
128
+ # Create with language (for translatable field values)
129
+ contact = Rodoo::Contact.create({ name: "Nouveau Contact" }, lang: "fr_FR")
130
+ ```
131
+
132
+ The language code should match one of the languages installed in your Odoo instance (e.g., `en_US`, `fr_FR`, `es_ES`, `de_DE`).
133
+
110
134
  ### Creating records
111
135
 
112
136
  ```ruby
@@ -149,6 +173,35 @@ contact.destroy
149
173
  contact.destroyed? # => true
150
174
  ```
151
175
 
176
+ ### Posting messages (chatter)
177
+
178
+ Post internal notes or messages to a record's chatter using Odoo's mail thread functionality:
179
+
180
+ ```ruby
181
+ invoice = Rodoo::CustomerInvoice.find(42)
182
+
183
+ # Post an internal note
184
+ invoice.message_post(
185
+ body: "<p>This is an internal note</p>",
186
+ message_type: "comment",
187
+ subtype_xmlid: "mail.mt_note"
188
+ )
189
+
190
+ # Post with additional parameters (e.g., notify specific partners)
191
+ invoice.message_post(
192
+ body: "<p>Please review this invoice</p>",
193
+ message_type: "comment",
194
+ subtype_xmlid: "mail.mt_comment",
195
+ partner_ids: [10, 20]
196
+ )
197
+ ```
198
+
199
+ **Parameters:**
200
+ - `body:` (required) - HTML content of the message
201
+ - `message_type:` - Type of message: `"comment"` (default), `"notification"`, `"email"`, `"user_notification"`
202
+ - `subtype_xmlid:` - XML ID for subtype (e.g., `"mail.mt_note"` for internal notes, `"mail.mt_comment"` for comments)
203
+ - Additional kwargs are passed directly to Odoo's `message_post` method
204
+
152
205
  ### Attachments
153
206
 
154
207
  Attach PDF files to accounting entries (invoices, credit notes, journal entries):
data/lib/rodoo/model.rb CHANGED
@@ -275,6 +275,37 @@ module Rodoo
275
275
  @destroyed == true
276
276
  end
277
277
 
278
+ # Posts a message to the record's chatter (mail thread).
279
+ # This is used for internal notes, comments, and notifications in Odoo.
280
+ #
281
+ # @param body [String] HTML content of the message
282
+ # @param message_type [String] Type: "comment", "notification", "email", "user_notification"
283
+ # @param subtype_xmlid [String, nil] XML ID for subtype (e.g., "mail.mt_note" for internal notes)
284
+ # @param kwargs [Hash] Additional parameters to pass to message_post
285
+ # @return [Integer] The ID of the created mail.message record
286
+ # @raise [Rodoo::Error] If the record hasn't been persisted
287
+ #
288
+ # @example Post an internal note
289
+ # invoice.message_post(
290
+ # body: "<p>This is an internal note</p>",
291
+ # message_type: "comment",
292
+ # subtype_xmlid: "mail.mt_note"
293
+ # )
294
+ #
295
+ def message_post(body:, message_type: "comment", subtype_xmlid: nil, **kwargs)
296
+ raise Error, "Cannot post message to a record that hasn't been persisted" unless persisted?
297
+
298
+ params = {
299
+ ids: [id],
300
+ body: body,
301
+ message_type: message_type,
302
+ subtype_xmlid: subtype_xmlid,
303
+ **kwargs
304
+ }.compact
305
+
306
+ self.class.execute("message_post", params)
307
+ end
308
+
278
309
  def inspect
279
310
  "#<#{self.class.name} id=#{id.inspect} #{inspectable_attributes}>"
280
311
  end
data/lib/rodoo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rodoo
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serrano