Merge lp:~lmi/openerp-connector/7.0-pass-vals-to-events into lp:~openerp-connector-core-editors/openerp-connector/7.0

Proposed by Laurent Mignon (Acsone)
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp
Approved revision: 589
Merged at revision: 603
Proposed branch: lp:~lmi/openerp-connector/7.0-pass-vals-to-events
Merge into: lp:~openerp-connector-core-editors/openerp-connector/7.0
Diff against target: 93 lines (+14/-9)
4 files modified
connector/CHANGES.rst (+3/-0)
connector/event.py (+2/-1)
connector/producer.py (+2/-2)
connector/tests/test_producer.py (+7/-6)
To merge this branch: bzr merge lp:~lmi/openerp-connector/7.0-pass-vals-to-events
Reviewer Review Type Date Requested Status
Laurent Mignon (Acsone) (community) Abstain
Sébastien BEAU - http://www.akretion.com Approve
Guewen Baconnier @ Camptocamp code review, test Approve
Review via email: mp+189234@code.launchpad.net

Description of the change

* Pass a new parameter to listeners of 'on_recrod_write' ( vals: field values of the new record, e.g {'field_name': field_value, ...})
* Replace the list of updated fields passed to listeners of 'on_record_write' by a dictionary of updated field values e.g {'field_name': field_value, ...}

To post a comment you must log in.
Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

sorry.. resubmitted

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks!

2 little things:
l.8 The new arg is on 'on_record_create', not 'on_recrod_write'
l.81 Can you align 'city' with 'name' ?

I'll make the changes for the Magento Connector, if someone want to do it for the Prestashop one, let us know here.

The changes to do are:
 * change the name of the argument and to use vals.keys() in all the consumers of on_record_write
 * add the argument vals in all the consumers of on_record_create

This change needs to be done in others connectors I'm not aware of, but it has been discussed on the mailing list and here so I hope the developers follow theses channels.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Forgot to set the review tag

review: Needs Fixing
588. By Laurent Mignon (Acsone)

The new arg is on 'on_record_create', not 'on_recrod_write'

589. By Laurent Mignon (Acsone)

pep8

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Thanks for the review!

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Here is the MP for the Magento Connector: https://code.launchpad.net/~openerp-connector-community/openerp-connector/7.0-magentoerpconnect-pass-vals-to-events/+merge/189295

I approve your MP and thank you again for taking the time to propose the change and develop it.

We will need to merge all the MPs (connector + Magento + Prestashop) at the same time.

review: Approve (code review, test)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Good work and thanks Guewen for the merge proposal on Magento and Prestashop
LGTM

review: Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :
Revision history for this message
Laurent Mignon (Acsone) (lmi) :
review: Abstain
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Just to say I did not forget this MP. I want to merge all the proposals breaking the API backward compatibility at the same time.

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Ok,
Thank you for the information

On Mon, Dec 9, 2013 at 1:34 PM, Guewen Baconnier @ Camptocamp <
<email address hidden>> wrote:

> Just to say I did not forget this MP. I want to merge all the proposals
> breaking the API backward compatibility at the same time.
> --
>
> https://code.launchpad.net/~lmi/openerp-connector/7.0-pass-vals-to-events/+merge/189234
> You are the owner of lp:~lmi/openerp-connector/7.0-pass-vals-to-events.
>

--
*Laurent Mignon*
*Senior Software Engineer*

*Tel : +352 20 21 10 20 32*
*Fax : +352 20 21 10 21*
*Gsm : +352 691 506 009*
*Email: <email address hidden> <email address hidden>*

*Acsone SA, Succursale de Luxembourg*
*22, Zone industrielle*
*L-8287 Kehlen, Luxembourg*
*www.acsone.eu <http://www.acsone.eu>*

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'connector/CHANGES.rst'
2--- connector/CHANGES.rst 2013-09-12 15:00:20 +0000
3+++ connector/CHANGES.rst 2013-10-04 09:36:28 +0000
4@@ -4,6 +4,9 @@
5 2.0.1.dev0
6 ~~~~~~~~~~
7
8+* Pass a new parameter to listeners of 'on_recrod_create' ( vals: field values of the new record, e.g {'field_name': field_value, ...})
9+* Replace the list of updated fields passed to listeners of 'on_record_write' by a dictionary of updated field values e.g {'field_name': field_value, ...}
10+
11 2.0.1 (2013-09-12)
12 ~~~~~~~~~~~~~~~~~~
13
14
15=== modified file 'connector/event.py'
16--- connector/event.py 2013-06-28 13:45:31 +0000
17+++ connector/event.py 2013-10-04 09:36:28 +0000
18@@ -188,7 +188,7 @@
19 * session: :py:class:`~connector.session.ConnectorSession` object
20 * model_name: name of the model
21 * record_id: id of the record
22- * fields: list with names of the fields which have been written
23+ * vals: field values of the new record, e.g {'field_name': field_value, ...}
24
25 """
26
27@@ -201,6 +201,7 @@
28 * session: :py:class:`~connector.session.ConnectorSession` object
29 * model_name: name of the model
30 * record_id: id of the created record
31+ * vals: field values updated, e.g {'field_name': field_value, ...}
32
33 """
34
35
36=== modified file 'connector/producer.py'
37--- connector/producer.py 2013-04-23 13:27:22 +0000
38+++ connector/producer.py 2013-10-04 09:36:28 +0000
39@@ -42,7 +42,7 @@
40 record_id = create_original(self, cr, uid, vals, context=context)
41 if self.pool.get('connector.installed') is not None:
42 session = ConnectorSession(cr, uid, context=context)
43- on_record_create.fire(session, self._name, record_id)
44+ on_record_create.fire(session, self._name, record_id, vals)
45 return record_id
46 orm.Model.create = create
47
48@@ -57,7 +57,7 @@
49 if on_record_write.has_consumer_for(session, self._name):
50 for record_id in ids:
51 on_record_write.fire(session, self._name,
52- record_id, vals.keys())
53+ record_id, vals)
54 return result
55 orm.Model.write = write
56
57
58=== modified file 'connector/tests/test_producer.py'
59--- connector/tests/test_producer.py 2013-04-23 11:58:21 +0000
60+++ connector/tests/test_producer.py 2013-10-04 09:36:28 +0000
61@@ -32,7 +32,7 @@
62 Create a record and check if the event is called
63 """
64 @on_record_create
65- def event(session, model_name, record_id):
66+ def event(session, model_name, record_id, vals):
67 self.recipient.record_id = record_id
68
69 record_id = self.model.create(self.cr,
70@@ -46,17 +46,18 @@
71 Write on a record and check if the event is called
72 """
73 @on_record_write
74- def event(session, model_name, record_id, fields=None):
75+ def event(session, model_name, record_id, vals=None):
76 self.recipient.record_id = record_id
77- self.recipient.fields = fields
78+ self.recipient.vals = vals
79
80+ vals = {'name': 'Lrrr',
81+ 'city': 'Omicron Persei 8'}
82 self.model.write(self.cr,
83 self.uid,
84 self.partner_id,
85- {'name': 'Lrrr',
86- 'city': 'Omicron Persei 8'})
87+ vals)
88 self.assertEqual(self.recipient.record_id, self.partner_id)
89- self.assertItemsEqual(self.recipient.fields, ['name', 'city'])
90+ self.assertDictEqual(self.recipient.vals, vals)
91 on_record_write.unsubscribe(event)
92
93 def test_on_record_unlink(self):