Merge lp:~openerp-community/prestashoperpconnect/7.0-pass-vals-to-events into lp:prestashoperpconnect

Proposed by Guewen Baconnier @ Camptocamp
Status: Rejected
Rejected by: Sébastien BEAU - http://www.akretion.com
Proposed branch: lp:~openerp-community/prestashoperpconnect/7.0-pass-vals-to-events
Merge into: lp:prestashoperpconnect
Diff against target: 142 lines (+18/-23)
4 files modified
prestashoperpconnect/product.py (+2/-2)
prestashoperpconnect/sale.py (+3/-8)
prestashoperpconnect_catalog_manager/product.py (+5/-5)
prestashoperpconnect_catalog_manager/product_attribute.py (+8/-8)
To merge this branch: bzr merge lp:~openerp-community/prestashoperpconnect/7.0-pass-vals-to-events
Reviewer Review Type Date Requested Status
Sébastien BEAU - http://www.akretion.com Needs Fixing
Review via email: mp+190227@code.launchpad.net

Commit message

[CHG] adapt the API to the change done in the connector (events on_record_create and on_record_write)

Description of the change

This is the change in the Prestashop Connector to adapt the API change here: https://code.launchpad.net/~lmi/openerp-connector/7.0-pass-vals-to-events/+merge/189234

Will need to be merged at the same time.

The same MP exist for the Magento connector at https://code.launchpad.net/~openerp-connector-community/openerp-connector/7.0-magentoerpconnect-pass-vals-to-events/+merge/189295

To post a comment you must log in.
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Hi Guewen, I ifx some stuff in my local branch, can you change the branch owner so I can directly push in this branch the fix?

Thanks

Here is my diff

=== modified file 'prestashoperpconnect/product.py'
--- prestashoperpconnect/product.py 2013-10-08 13:28:25 +0000
+++ prestashoperpconnect/product.py 2013-10-10 06:48:40 +0000
@@ -432,10 +432,10 @@

 @on_record_write(model_names='prestashop.product.product')
 def prestashop_product_stock_updated(session, model_name, record_id,
- fields=None):
+ vals):
     if session.context.get('connector_no_export'):
         return
- inventory_fields = list(set(fields).intersection(INVENTORY_FIELDS))
+ inventory_fields = list(set(vals).intersection(INVENTORY_FIELDS))
     if inventory_fields:
         export_inventory.delay(session, model_name,
                                record_id, fields=inventory_fields,

=== modified file 'prestashoperpconnect/sale.py'
--- prestashoperpconnect/sale.py 2013-10-09 08:07:30 +0000
+++ prestashoperpconnect/sale.py 2013-10-10 06:52:33 +0000
@@ -262,18 +262,13 @@
 # TODO improve me, make the search on the sale order backend only
 @on_record_write(model_names='sale.order')
 def prestashop_sale_state_modified(session, model_name, record_id,
- fields=None):
- if 'state' in fields:
- sale = session.pool[model_name].browse(
- session.cr,
- session.uid,
- record_id
- )
+ vals):
+ if 'state' in vals:
         state_list_model = 'sale.order.state.list'
         states = session.pool[state_list_model].search(
             session.cr,
             session.uid,
- [('name', '=', sale.state)]
+ [('name', '=', vals['state'])]
         )

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

Seems I should stop working in the evening ;-)

I changed the owner.

Thanks

267. By Sébastien BEAU - http://www.akretion.com

[CHG] complete the API adaptation with the change done in the connector (events on_record_create and on_record_write)

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

I push the fix, now me we will test it and than approve the merge

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

Could you test it?

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

> I push the fix, now me we will test it and than approve the merge

Some news?

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

I will merge the change soon, but I couldn't afford to test the prestashop branch myself.

Unmerged revisions

267. By Sébastien BEAU - http://www.akretion.com

[CHG] complete the API adaptation with the change done in the connector (events on_record_create and on_record_write)

266. By Guewen Baconnier @ Camptocamp

[CHG] adapt the API to the change done in the connector (events on_record_create and on_record_write)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'prestashoperpconnect/product.py'
--- prestashoperpconnect/product.py 2013-10-08 13:28:25 +0000
+++ prestashoperpconnect/product.py 2013-10-10 08:59:47 +0000
@@ -432,10 +432,10 @@
432432
433@on_record_write(model_names='prestashop.product.product')433@on_record_write(model_names='prestashop.product.product')
434def prestashop_product_stock_updated(session, model_name, record_id,434def prestashop_product_stock_updated(session, model_name, record_id,
435 fields=None):435 vals):
436 if session.context.get('connector_no_export'):436 if session.context.get('connector_no_export'):
437 return437 return
438 inventory_fields = list(set(fields).intersection(INVENTORY_FIELDS))438 inventory_fields = list(set(vals).intersection(INVENTORY_FIELDS))
439 if inventory_fields:439 if inventory_fields:
440 export_inventory.delay(session, model_name,440 export_inventory.delay(session, model_name,
441 record_id, fields=inventory_fields,441 record_id, fields=inventory_fields,
442442
=== modified file 'prestashoperpconnect/sale.py'
--- prestashoperpconnect/sale.py 2013-10-09 08:07:30 +0000
+++ prestashoperpconnect/sale.py 2013-10-10 08:59:47 +0000
@@ -262,18 +262,13 @@
262# TODO improve me, make the search on the sale order backend only262# TODO improve me, make the search on the sale order backend only
263@on_record_write(model_names='sale.order')263@on_record_write(model_names='sale.order')
264def prestashop_sale_state_modified(session, model_name, record_id,264def prestashop_sale_state_modified(session, model_name, record_id,
265 fields=None):265 vals):
266 if 'state' in fields:266 if 'state' in vals:
267 sale = session.pool[model_name].browse(
268 session.cr,
269 session.uid,
270 record_id
271 )
272 state_list_model = 'sale.order.state.list'267 state_list_model = 'sale.order.state.list'
273 states = session.pool[state_list_model].search(268 states = session.pool[state_list_model].search(
274 session.cr,269 session.cr,
275 session.uid,270 session.uid,
276 [('name', '=', sale.state)]271 [('name', '=', vals['state'])]
277 )272 )
278273
279 if states:274 if states:
280275
=== modified file 'prestashoperpconnect_catalog_manager/product.py'
--- prestashoperpconnect_catalog_manager/product.py 2013-07-11 14:10:26 +0000
+++ prestashoperpconnect_catalog_manager/product.py 2013-10-10 08:59:47 +0000
@@ -36,28 +36,28 @@
36import openerp.addons.decimal_precision as dp36import openerp.addons.decimal_precision as dp
3737
38@on_record_create(model_names='prestashop.product.product')38@on_record_create(model_names='prestashop.product.product')
39def prestashop_product_product_create(session, model_name, record_id):39def prestashop_product_product_create(session, model_name, record_id, vals):
40 if session.context.get('connector_no_export'):40 if session.context.get('connector_no_export'):
41 return41 return
42 export_record.delay(session, model_name, record_id)42 export_record.delay(session, model_name, record_id)
4343
44@on_record_write(model_names='prestashop.product.product')44@on_record_write(model_names='prestashop.product.product')
45def prestashop_product_product_write(session, model_name, record_id, fields):45def prestashop_product_product_write(session, model_name, record_id, vals):
46 if session.context.get('connector_no_export'):46 if session.context.get('connector_no_export'):
47 return47 return
48 fields = list(set(fields).difference(set(INVENTORY_FIELDS)))48 fields = list(set(vals).difference(set(INVENTORY_FIELDS)))
49 if fields:49 if fields:
50 export_record.delay(session, model_name, record_id, fields)50 export_record.delay(session, model_name, record_id, fields)
5151
52@on_record_write(model_names='product.product')52@on_record_write(model_names='product.product')
53def product_product_write(session, model_name, record_id, fields):53def product_product_write(session, model_name, record_id, vals):
54 if session.context.get('connector_no_export'):54 if session.context.get('connector_no_export'):
55 return55 return
56 model = session.pool.get(model_name)56 model = session.pool.get(model_name)
57 record = model.browse(session.cr, session.uid,57 record = model.browse(session.cr, session.uid,
58 record_id, context=session.context)58 record_id, context=session.context)
59 for binding in record.prestashop_bind_ids:59 for binding in record.prestashop_bind_ids:
60 export_record.delay(session, 'prestashop.product.product', binding.id, fields)60 export_record.delay(session, 'prestashop.product.product', binding.id, vals.keys())
6161
6262
63class prestashop_product_product(orm.Model):63class prestashop_product_product(orm.Model):
6464
=== modified file 'prestashoperpconnect_catalog_manager/product_attribute.py'
--- prestashoperpconnect_catalog_manager/product_attribute.py 2013-06-15 21:15:57 +0000
+++ prestashoperpconnect_catalog_manager/product_attribute.py 2013-10-10 08:59:47 +0000
@@ -121,49 +121,49 @@
121121
122122
123@on_record_create(model_names='prestashop.product.attribute')123@on_record_create(model_names='prestashop.product.attribute')
124def prestashop_product_attribute_created(session, model_name, record_id):124def prestashop_product_attribute_created(session, model_name, record_id, vals):
125 if session.context.get('connector_no_export'):125 if session.context.get('connector_no_export'):
126 return126 return
127 export_record.delay(session, model_name, record_id)127 export_record.delay(session, model_name, record_id)
128128
129129
130@on_record_create(model_names='prestashop.attribute.option')130@on_record_create(model_names='prestashop.attribute.option')
131def prestashop_attribute_option_created(session, model_name, record_id):131def prestashop_attribute_option_created(session, model_name, record_id, vals):
132 if session.context.get('connector_no_export'):132 if session.context.get('connector_no_export'):
133 return133 return
134 export_record.delay(session, model_name, record_id)134 export_record.delay(session, model_name, record_id)
135135
136@on_record_write(model_names='prestashop.product.attribute')136@on_record_write(model_names='prestashop.product.attribute')
137def prestashop_product_attribute_written(session, model_name, record_id, fields=None):137def prestashop_product_attribute_written(session, model_name, record_id, vals):
138 if session.context.get('connector_no_export'):138 if session.context.get('connector_no_export'):
139 return139 return
140 export_record.delay(session, model_name, record_id)140 export_record.delay(session, model_name, record_id)
141141
142@on_record_write(model_names='prestashop.attribute.option')142@on_record_write(model_names='prestashop.attribute.option')
143def prestashop_attribute_option_written(session, model_name, record_id, fields=None):143def prestashop_attribute_option_written(session, model_name, record_id, vals):
144 if session.context.get('connector_no_export'):144 if session.context.get('connector_no_export'):
145 return145 return
146 export_record.delay(session, model_name, record_id)146 export_record.delay(session, model_name, record_id)
147147
148@on_record_write(model_names='attribute.attribute')148@on_record_write(model_names='attribute.attribute')
149def product_attribute_written(session, model_name, record_id, fields=None):149def product_attribute_written(session, model_name, record_id, vals):
150 if session.context.get('connector_no_export'):150 if session.context.get('connector_no_export'):
151 return151 return
152 model = session.pool.get(model_name)152 model = session.pool.get(model_name)
153 record = model.browse(session.cr, session.uid,153 record = model.browse(session.cr, session.uid,
154 record_id, context=session.context)154 record_id, context=session.context)
155 for binding in record.prestashop_bind_ids:155 for binding in record.prestashop_bind_ids:
156 export_record.delay(session, 'prestashop.product.attribute', binding.id, fields)156 export_record.delay(session, 'prestashop.product.attribute', binding.id, vals.keys())
157157
158@on_record_write(model_names='attribute.option')158@on_record_write(model_names='attribute.option')
159def attribute_option_written(session, model_name, record_id, fields=None):159def attribute_option_written(session, model_name, record_id, vals):
160 if session.context.get('connector_no_export'):160 if session.context.get('connector_no_export'):
161 return161 return
162 model = session.pool.get(model_name)162 model = session.pool.get(model_name)
163 record = model.browse(session.cr, session.uid,163 record = model.browse(session.cr, session.uid,
164 record_id, context=session.context)164 record_id, context=session.context)
165 for binding in record.prestashop_bind_ids:165 for binding in record.prestashop_bind_ids:
166 export_record.delay(session, 'prestashop.attribute.option', binding.id, fields)166 export_record.delay(session, 'prestashop.attribute.option', binding.id, vals.keys())
167167
168168
169@prestashop169@prestashop