Merge lp:~camptocamp/openerp-connector-magento/7.0-next-release-related-actions into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0-next-release

Proposed by Guewen Baconnier @ Camptocamp
Status: Merged
Merged at revision: 989
Proposed branch: lp:~camptocamp/openerp-connector-magento/7.0-next-release-related-actions
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0-next-release
Diff against target: 630 lines (+260/-10)
20 files modified
magentoerpconnect/CHANGES.rst (+2/-0)
magentoerpconnect/invoice.py (+5/-1)
magentoerpconnect/magento_model.py (+4/-0)
magentoerpconnect/magento_model_view.xml (+1/-0)
magentoerpconnect/partner.py (+1/-0)
magentoerpconnect/partner_category.py (+1/-0)
magentoerpconnect/product.py (+4/-1)
magentoerpconnect/product_category.py (+1/-0)
magentoerpconnect/related_action.py (+65/-0)
magentoerpconnect/sale.py (+1/-0)
magentoerpconnect/stock_picking.py (+4/-1)
magentoerpconnect/stock_tracking.py (+3/-1)
magentoerpconnect/tests/__init__.py (+4/-0)
magentoerpconnect/tests/test_related_action.py (+98/-0)
magentoerpconnect/unit/backend_adapter.py (+16/-0)
magentoerpconnect/unit/binder.py (+33/-0)
magentoerpconnect/unit/delete_synchronizer.py (+3/-1)
magentoerpconnect/unit/export_synchronizer.py (+3/-1)
magentoerpconnect/unit/import_synchronizer.py (+3/-1)
magentoerpconnect_pricing/product.py (+8/-3)
To merge this branch: bzr merge lp:~camptocamp/openerp-connector-magento/7.0-next-release-related-actions
Reviewer Review Type Date Requested Status
OpenERP Connector Core Editors Pending
Review via email: mp+218945@code.launchpad.net

Commit message

Implements Related Actions

A related action can be attached to a job. It is shown to the user as a button on the form view of the jobs.
When the button is used, the related action is called and must return an OpenERP "client action".

Related action in this connector:
* Open the form view of the record that is concerned by the job on export jobs
* Open a browser on Magento's admin page in order to view/edit the record on import jobs

Description of the change

Implements Related Actions
==========================

Based on the new connector's feature: https://code.launchpad.net/~camptocamp/openerp-connector/7.0-next-release-related-action

A related action can be attached to a job. It is shown to the user as a button on the form view of the jobs.
When the button is used, the related action is called and must return an OpenERP "client action".

Related action in this connector:
* Open the form view of the record that is concerned by the job on export jobs
* Open a browser on Magento's admin page in order to view/edit the record on import jobs

I would like to include this branch in the upcoming release, please test and give me your feedback!

To post a comment you must log in.
985. By Guewen Baconnier @ Camptocamp on 2014-05-12

test method name duplicated

986. By Guewen Baconnier @ Camptocamp on 2014-05-19

rename unwrap_record to unwrap_binding

Revision history for this message
David BEAL (ak) (davidbeal) wrote :

Really, really usefull feature

Nice Guewen

Thank you

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/CHANGES.rst'
2--- magentoerpconnect/CHANGES.rst 2014-05-06 15:46:57 +0000
3+++ magentoerpconnect/CHANGES.rst 2014-05-19 11:42:35 +0000
4@@ -16,6 +16,8 @@
5 * Fix: calculate correctly the discount ratio on sales order lines (lp:1201590)
6 * Possibility to exclude products from stock synchronizations
7 * Products disabled on Magento are imported disabled on OpenERP. An additional module allows more options.
8+* Related Actions: open the form view on the record concerned by an export job, or open the Magento's admin page
9+ on importing jobs
10
11
12 2.3.1 (2014-01-23)
13
14=== modified file 'magentoerpconnect/invoice.py'
15--- magentoerpconnect/invoice.py 2014-04-29 14:11:59 +0000
16+++ magentoerpconnect/invoice.py 2014-05-19 11:42:35 +0000
17@@ -23,7 +23,7 @@
18 import xmlrpclib
19 from openerp.osv import fields, orm
20 from openerp.tools.translate import _
21-from openerp.addons.connector.queue.job import job
22+from openerp.addons.connector.queue.job import job, related_action
23 from openerp.addons.connector.unit.synchronizer import ExportSynchronizer
24 from openerp.addons.connector.event import on_record_create
25 from openerp.addons.connector_ecommerce.event import (on_invoice_paid,
26@@ -32,6 +32,7 @@
27 from .unit.backend_adapter import GenericAdapter
28 from .connector import get_environment
29 from .backend import magento
30+from .related_action import unwrap_binding
31
32 _logger = logging.getLogger(__name__)
33
34@@ -84,6 +85,7 @@
35 """ Backend Adapter for the Magento Invoice """
36 _model_name = 'magento.account.invoice'
37 _magento_model = 'sales_order_invoice'
38+ _admin_path = 'sales_invoice/view/invoice_id/{id}'
39
40 def _call(self, method, arguments):
41 try:
42@@ -248,6 +250,7 @@
43
44
45 @job
46+@related_action(action=unwrap_binding)
47 def export_invoice_paid(session, model_name, record_id):
48 """ Deprecated in 2.1.0.dev0. """
49 _logger.warning('Deprecated: the export_invoice_paid() job is deprecated '
50@@ -256,6 +259,7 @@
51
52
53 @job
54+@related_action(action=unwrap_binding)
55 def export_invoice(session, model_name, record_id):
56 """ Export a validated or paid invoice. """
57 invoice = session.browse(model_name, record_id)
58
59=== modified file 'magentoerpconnect/magento_model.py'
60--- magentoerpconnect/magento_model.py 2014-05-06 09:33:40 +0000
61+++ magentoerpconnect/magento_model.py 2014-05-19 11:42:35 +0000
62@@ -86,6 +86,7 @@
63 'Location',
64 required=True,
65 help="Url to magento application"),
66+ 'admin_location': fields.char('Admin Location'),
67 'use_custom_api_path': fields.boolean(
68 'Custom Api Path',
69 help="The default API path is '/index.php/api/xmlrpc'. "
70@@ -517,18 +518,21 @@
71 class WebsiteAdapter(GenericAdapter):
72 _model_name = 'magento.website'
73 _magento_model = 'ol_websites'
74+ _admin_path = 'system_store/editWebsite/website_id/{id}'
75
76
77 @magento
78 class StoreAdapter(GenericAdapter):
79 _model_name = 'magento.store'
80 _magento_model = 'ol_groups'
81+ _admin_path = 'system_store/editGroup/group_id/{id}'
82
83
84 @magento
85 class StoreviewAdapter(GenericAdapter):
86 _model_name = 'magento.storeview'
87 _magento_model = 'ol_storeviews'
88+ _admin_path = 'system_store/editStore/store_id/{id}'
89
90
91 @magento
92
93=== modified file 'magentoerpconnect/magento_model_view.xml'
94--- magentoerpconnect/magento_model_view.xml 2014-04-04 08:46:16 +0000
95+++ magentoerpconnect/magento_model_view.xml 2014-05-19 11:42:35 +0000
96@@ -123,6 +123,7 @@
97
98 <page name="advanced_configuration" string="Advanced Configuration">
99 <group>
100+ <field name="admin_location" placeholder="e.g. http://my.magento.com/admin"/>
101 <field name="default_lang_id" widget="selection"/>
102 <field name="default_category_id"/>
103 <field name="sale_prefix" placeholder="mag-" />
104
105=== modified file 'magentoerpconnect/partner.py'
106--- magentoerpconnect/partner.py 2014-04-17 08:40:19 +0000
107+++ magentoerpconnect/partner.py 2014-05-19 11:42:35 +0000
108@@ -206,6 +206,7 @@
109 class PartnerAdapter(GenericAdapter):
110 _model_name = 'magento.res.partner'
111 _magento_model = 'customer'
112+ _admin_path = '/{model}/edit/id/{id}'
113
114 def _call(self, method, arguments):
115 try:
116
117=== modified file 'magentoerpconnect/partner_category.py'
118--- magentoerpconnect/partner_category.py 2013-07-26 09:06:53 +0000
119+++ magentoerpconnect/partner_category.py 2014-05-19 11:42:35 +0000
120@@ -73,6 +73,7 @@
121 class PartnerCategoryAdapter(GenericAdapter):
122 _model_name = 'magento.res.partner.category'
123 _magento_model = 'ol_customer_groups'
124+ _admin_path = '/customer_group/edit/id/{id}'
125
126 def search(self, filters=None):
127 """ Search records according to some criterias
128
129=== modified file 'magentoerpconnect/product.py'
130--- magentoerpconnect/product.py 2014-05-06 16:20:16 +0000
131+++ magentoerpconnect/product.py 2014-05-19 11:42:35 +0000
132@@ -27,7 +27,7 @@
133 import sys
134 from openerp.osv import orm, fields
135 from openerp.tools.translate import _
136-from openerp.addons.connector.queue.job import job
137+from openerp.addons.connector.queue.job import job, related_action
138 from openerp.addons.connector.event import on_record_write
139 from openerp.addons.connector.unit.synchronizer import (ImportSynchronizer,
140 ExportSynchronizer
141@@ -49,6 +49,7 @@
142 )
143 from .connector import get_environment
144 from .backend import magento
145+from .related_action import unwrap_binding
146
147 _logger = logging.getLogger(__name__)
148
149@@ -176,6 +177,7 @@
150 class ProductProductAdapter(GenericAdapter):
151 _model_name = 'magento.product.product'
152 _magento_model = 'catalog_product'
153+ _admin_path = '/{model}/edit/id/{id}'
154
155 def _call(self, method, arguments):
156 try:
157@@ -557,6 +559,7 @@
158
159
160 @job
161+@related_action(action=unwrap_binding)
162 def export_product_inventory(session, model_name, record_id, fields=None):
163 """ Export the inventory configuration and quantity of a product. """
164 product = session.browse(model_name, record_id)
165
166=== modified file 'magentoerpconnect/product_category.py'
167--- magentoerpconnect/product_category.py 2013-07-26 09:06:53 +0000
168+++ magentoerpconnect/product_category.py 2014-05-19 11:42:35 +0000
169@@ -87,6 +87,7 @@
170 class ProductCategoryAdapter(GenericAdapter):
171 _model_name = 'magento.product.category'
172 _magento_model = 'catalog_category'
173+ _admin_path = '/{model}/index/'
174
175 def _call(self, method, arguments):
176 try:
177
178=== added file 'magentoerpconnect/related_action.py'
179--- magentoerpconnect/related_action.py 1970-01-01 00:00:00 +0000
180+++ magentoerpconnect/related_action.py 2014-05-19 11:42:35 +0000
181@@ -0,0 +1,65 @@
182+# -*- coding: utf-8 -*-
183+##############################################################################
184+#
185+# Author: Guewen Baconnier
186+# Copyright 2014 Camptocamp SA
187+#
188+# This program is free software: you can redistribute it and/or modify
189+# it under the terms of the GNU Affero General Public License as
190+# published by the Free Software Foundation, either version 3 of the
191+# License, or (at your option) any later version.
192+#
193+# This program is distributed in the hope that it will be useful,
194+# but WITHOUT ANY WARRANTY; without even the implied warranty of
195+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
196+# GNU Affero General Public License for more details.
197+#
198+# You should have received a copy of the GNU Affero General Public License
199+# along with this program. If not, see <http://www.gnu.org/licenses/>.
200+#
201+##############################################################################
202+
203+"""
204+Related Actions for Magento:
205+
206+Related actions are associated with jobs.
207+When called on a job, they will return an action to the client.
208+
209+"""
210+
211+import functools
212+from openerp.osv import orm
213+from openerp.tools.translate import _
214+from openerp.addons.connector import related_action
215+from .connector import get_environment
216+from .unit.backend_adapter import GenericAdapter
217+from .unit.binder import MagentoBinder
218+
219+unwrap_binding = functools.partial(related_action.unwrap_binding,
220+ binder_class=MagentoBinder)
221+
222+
223+def link(session, job, backend_id_pos=2, magento_id_pos=3):
224+ """ Open a Magento URL on the admin page to view/edit the record
225+ related to the job.
226+ """
227+ binding_model = job.args[0]
228+ # shift one to the left because session is not in job.args
229+ backend_id = job.args[backend_id_pos - 1]
230+ magento_id = job.args[magento_id_pos - 1]
231+ env = get_environment(session, binding_model, backend_id)
232+ adapter = env.get_connector_unit(GenericAdapter)
233+ try:
234+ url = adapter.admin_url(magento_id)
235+ except ValueError:
236+ raise orm.except_orm(
237+ _('Error'),
238+ _('No admin URL configured on the backend or '
239+ 'no admin path is defined for this record.'))
240+
241+ action = {
242+ 'type': 'ir.actions.act_url',
243+ 'target': 'new',
244+ 'url': url,
245+ }
246+ return action
247
248=== modified file 'magentoerpconnect/sale.py'
249--- magentoerpconnect/sale.py 2014-05-06 08:36:26 +0000
250+++ magentoerpconnect/sale.py 2014-05-19 11:42:35 +0000
251@@ -211,6 +211,7 @@
252 class SaleOrderAdapter(GenericAdapter):
253 _model_name = 'magento.sale.order'
254 _magento_model = 'sales_order'
255+ _admin_path = '{model}/view/order_id/{id}'
256
257 def _call(self, method, arguments):
258 try:
259
260=== modified file 'magentoerpconnect/stock_picking.py'
261--- magentoerpconnect/stock_picking.py 2014-01-14 10:38:32 +0000
262+++ magentoerpconnect/stock_picking.py 2014-05-19 11:42:35 +0000
263@@ -23,7 +23,7 @@
264 import xmlrpclib
265 from openerp.osv import orm, fields
266 from openerp.tools.translate import _
267-from openerp.addons.connector.queue.job import job
268+from openerp.addons.connector.queue.job import job, related_action
269 from openerp.addons.connector.event import on_record_create
270 from openerp.addons.connector.exception import NothingToDoJob
271 from openerp.addons.connector.unit.synchronizer import ExportSynchronizer
272@@ -33,6 +33,7 @@
273 from .connector import get_environment
274 from .backend import magento
275 from .stock_tracking import export_tracking_number
276+from .related_action import unwrap_binding
277
278 _logger = logging.getLogger(__name__)
279
280@@ -99,6 +100,7 @@
281 class StockPickingAdapter(GenericAdapter):
282 _model_name = 'magento.stock.picking.out'
283 _magento_model = 'sales_order_shipment'
284+ _admin_path = 'sales_shipment/view/shipment_id/{id}'
285
286 def _call(self, method, arguments):
287 try:
288@@ -248,6 +250,7 @@
289
290
291 @job
292+@related_action(action=unwrap_binding)
293 def export_picking_done(session, model_name, record_id):
294 """ Export a complete or partial delivery order. """
295 picking = session.browse(model_name, record_id)
296
297=== modified file 'magentoerpconnect/stock_tracking.py'
298--- magentoerpconnect/stock_tracking.py 2013-10-12 19:50:31 +0000
299+++ magentoerpconnect/stock_tracking.py 2014-05-19 11:42:35 +0000
300@@ -21,12 +21,13 @@
301
302 import logging
303 from openerp.tools.translate import _
304-from openerp.addons.connector.queue.job import job
305+from openerp.addons.connector.queue.job import job, related_action
306 from openerp.addons.connector.exception import FailedJobError, NoExternalId
307 from openerp.addons.connector.unit.synchronizer import ExportSynchronizer
308 from openerp.addons.connector_ecommerce.event import on_tracking_number_added
309 from .connector import get_environment
310 from .backend import magento
311+from .related_action import unwrap_binding
312
313 _logger = logging.getLogger(__name__)
314
315@@ -117,6 +118,7 @@
316
317
318 @job
319+@related_action(action=unwrap_binding)
320 def export_tracking_number(session, model_name, record_id):
321 """ Export the tracking number of a delivery order. """
322 picking = session.browse(model_name, record_id)
323
324=== modified file 'magentoerpconnect/tests/__init__.py'
325--- magentoerpconnect/tests/__init__.py 2014-03-19 10:34:00 +0000
326+++ magentoerpconnect/tests/__init__.py 2014-05-19 11:42:35 +0000
327@@ -23,6 +23,9 @@
328 import test_address_book
329 import test_export_invoice
330 import test_import_product_image
331+import test_related_action
332+
333+
334 fast_suite = [
335 ]
336
337@@ -31,4 +34,5 @@
338 test_address_book,
339 test_export_invoice,
340 test_import_product_image,
341+ test_related_action,
342 ]
343
344=== added file 'magentoerpconnect/tests/test_related_action.py'
345--- magentoerpconnect/tests/test_related_action.py 1970-01-01 00:00:00 +0000
346+++ magentoerpconnect/tests/test_related_action.py 2014-05-19 11:42:35 +0000
347@@ -0,0 +1,98 @@
348+# -*- coding: utf-8 -*-
349+import mock
350+import unittest2
351+
352+import openerp
353+import openerp.tests.common as common
354+from openerp.addons.connector.queue.job import (
355+ Job,
356+ OpenERPJobStorage,
357+ related_action)
358+from openerp.addons.connector.session import (
359+ ConnectorSession)
360+from .common import (mock_api,
361+ mock_urlopen_image)
362+from .test_data import magento_base_responses
363+from ..unit.import_synchronizer import import_batch, import_record
364+from ..unit.export_synchronizer import export_record
365+from ..related_action import unwrap_binding, link
366+
367+
368+class test_related_action_storage(common.TransactionCase):
369+ """ Test related actions on stored jobs """
370+
371+ def setUp(self):
372+ super(test_related_action_storage, self).setUp()
373+ cr, uid = self.cr, self.uid
374+ backend_model = self.registry('magento.backend')
375+ self.session = ConnectorSession(cr, uid)
376+ warehouse_id = self.ref('stock.warehouse0')
377+ backend_id = backend_model.create(
378+ cr,
379+ uid,
380+ {'name': 'Test Magento',
381+ 'version': '1.7',
382+ 'location': 'http://anyurl',
383+ 'username': 'username',
384+ 'warehouse_id': warehouse_id,
385+ 'password': '42'})
386+ self.backend = backend_model.browse(cr, uid, backend_id)
387+ # import the base informations
388+ with mock_api(magento_base_responses):
389+ import_batch(self.session, 'magento.website', backend_id)
390+ import_batch(self.session, 'magento.store', backend_id)
391+ import_batch(self.session, 'magento.storeview', backend_id)
392+ self.MagentoProduct = self.registry('magento.product.product')
393+ self.QueueJob = self.registry('queue.job')
394+
395+ def test_unwrap_binding(self):
396+ """ Open a related action opening an unwrapped binding """
397+ cr, uid = self.cr, self.uid
398+ product_id = self.ref('product.product_product_7')
399+ magento_product_id = self.MagentoProduct.create(
400+ cr, uid,
401+ {'openerp_id': product_id,
402+ 'backend_id': self.backend.id})
403+ stored = self._create_job(export_record, 'magento.product.product',
404+ magento_product_id)
405+ expected = {
406+ 'name': mock.ANY,
407+ 'type': 'ir.actions.act_window',
408+ 'view_type': 'form',
409+ 'view_mode': 'form',
410+ 'res_id': product_id,
411+ 'res_model': 'product.product',
412+ }
413+ self.assertEquals(stored.open_related_action(), expected)
414+
415+ def _create_job(self, func, *args):
416+ cr, uid = self.cr, self.uid
417+ job = Job(func=func, args=args)
418+ storage = OpenERPJobStorage(self.session)
419+ storage.store(job)
420+ stored_ids = self.QueueJob.search(self.cr, self.uid,
421+ [('uuid', '=', job.uuid)])
422+ self.assertEqual(len(stored_ids), 1)
423+ return self.QueueJob.browse(cr, uid, stored_ids[0])
424+
425+ def test_link(self):
426+ """ Open a related action opening an url on Magento """
427+ self.backend.write({'admin_location': 'http://www.example.com/admin'})
428+ self.backend.refresh()
429+ stored = self._create_job(import_record, 'magento.product.product',
430+ self.backend.id, 123456)
431+ expected = {
432+ 'type': 'ir.actions.act_url',
433+ 'target': 'new',
434+ 'url': 'http://www.example.com/admin/catalog_product/edit/id/123456',
435+ }
436+ self.assertEquals(stored.open_related_action(), expected)
437+
438+ def test_link_no_location(self):
439+ """ Open a related action opening an url but admin location is not configured """
440+ self.backend.write({'admin_location': False})
441+ self.backend.refresh()
442+ stored = self._create_job(import_record, 'magento.product.product',
443+ self.backend.id, 123456)
444+ with self.assertRaises(openerp.osv.orm.except_orm):
445+ stored.open_related_action()
446
447=== modified file 'magentoerpconnect/unit/backend_adapter.py'
448--- magentoerpconnect/unit/backend_adapter.py 2014-05-06 09:33:40 +0000
449+++ magentoerpconnect/unit/backend_adapter.py 2014-05-19 11:42:35 +0000
450@@ -182,6 +182,7 @@
451
452 _model_name = None
453 _magento_model = None
454+ _admin_path = None
455
456 def search(self, filters=None):
457 """ Search records according to some criterias
458@@ -228,3 +229,18 @@
459 def delete(self, id):
460 """ Delete a record on the external system """
461 return self._call('%s.delete' % self._magento_model, [int(id)])
462+
463+ def admin_url(self, id):
464+ """ Return the URL in the Magento admin for a record """
465+ if self._admin_path is None:
466+ raise ValueError('No admin path is defined for this record')
467+ backend = self.backend_record
468+ url = backend.admin_location
469+ if not url:
470+ raise ValueError('No admin URL configured on the backend.')
471+ path = self._admin_path.format(model=self._magento_model,
472+ id=id)
473+ url = url.rstrip('/')
474+ path = path.lstrip('/')
475+ url = '/'.join((url, path))
476+ return url
477
478=== modified file 'magentoerpconnect/unit/binder.py'
479--- magentoerpconnect/unit/binder.py 2013-11-21 09:34:17 +0000
480+++ magentoerpconnect/unit/binder.py 2014-05-19 11:42:35 +0000
481@@ -124,3 +124,36 @@
482 {'magento_id': str(external_id),
483 'sync_date': now_fmt},
484 context=context)
485+
486+ def unwrap_binding(self, binding_id, browse=False):
487+ """ For a binding record, gives the normal record.
488+
489+ Example: when called with a ``magento.product.product`` id,
490+ it will return the corresponding ``product.product`` id.
491+
492+ :param browse: when True, returns a browse_record instance
493+ rather than an ID
494+ """
495+ binding = self.session.read(self.model._name, binding_id,
496+ ['openerp_id'])
497+ openerp_id = binding['openerp_id'][0]
498+ if browse:
499+ return self.session.browse(self.unwrap_model(),
500+ openerp_id)
501+ return openerp_id
502+
503+ def unwrap_model(self):
504+ """ For a binding model, gives the name of the normal model.
505+
506+ Example: when called on a binder for ``magento.product.product``,
507+ it will return ``product.product``.
508+
509+ This binder assumes that the normal model lays in ``openerp_id`` since
510+ this is the field we use in the ``_inherits`` bindings.
511+ """
512+ try:
513+ column = self.model._columns['openerp_id']
514+ except KeyError:
515+ raise ValueError('Cannot unwrap model %s, because it has '
516+ 'no openerp_id field' % self.model._name)
517+ return column._obj
518
519=== modified file 'magentoerpconnect/unit/delete_synchronizer.py'
520--- magentoerpconnect/unit/delete_synchronizer.py 2013-03-19 16:53:26 +0000
521+++ magentoerpconnect/unit/delete_synchronizer.py 2014-05-19 11:42:35 +0000
522@@ -20,9 +20,10 @@
523 ##############################################################################
524
525 from openerp.tools.translate import _
526-from openerp.addons.connector.queue.job import job
527+from openerp.addons.connector.queue.job import job, related_action
528 from openerp.addons.connector.unit.synchronizer import DeleteSynchronizer
529 from ..connector import get_environment
530+from ..related_action import link
531
532
533 class MagentoDeleteSynchronizer(DeleteSynchronizer):
534@@ -38,6 +39,7 @@
535
536
537 @job
538+@related_action(action=link)
539 def export_delete_record(session, model_name, backend_id, magento_id):
540 """ Delete a record on Magento """
541 env = get_environment(session, model_name, backend_id)
542
543=== modified file 'magentoerpconnect/unit/export_synchronizer.py'
544--- magentoerpconnect/unit/export_synchronizer.py 2014-04-02 14:32:31 +0000
545+++ magentoerpconnect/unit/export_synchronizer.py 2014-05-19 11:42:35 +0000
546@@ -23,11 +23,12 @@
547 from datetime import datetime
548 from openerp.tools.translate import _
549 from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
550-from openerp.addons.connector.queue.job import job
551+from openerp.addons.connector.queue.job import job, related_action
552 from openerp.addons.connector.unit.synchronizer import ExportSynchronizer
553 from openerp.addons.connector.exception import IDMissingInBackend
554 from .import_synchronizer import import_record
555 from ..connector import get_environment
556+from ..related_action import unwrap_binding
557
558 _logger = logging.getLogger(__name__)
559
560@@ -209,6 +210,7 @@
561
562
563 @job
564+@related_action(action=unwrap_binding)
565 def export_record(session, model_name, binding_id, fields=None):
566 """ Export a record on Magento """
567 record = session.browse(model_name, binding_id)
568
569=== modified file 'magentoerpconnect/unit/import_synchronizer.py'
570--- magentoerpconnect/unit/import_synchronizer.py 2014-03-19 07:31:29 +0000
571+++ magentoerpconnect/unit/import_synchronizer.py 2014-05-19 11:42:35 +0000
572@@ -23,12 +23,13 @@
573 from datetime import datetime
574 from openerp.tools.translate import _
575 from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
576-from openerp.addons.connector.queue.job import job
577+from openerp.addons.connector.queue.job import job, related_action
578 from openerp.addons.connector.connector import ConnectorUnit
579 from openerp.addons.connector.unit.synchronizer import ImportSynchronizer
580 from openerp.addons.connector.exception import IDMissingInBackend
581 from ..backend import magento
582 from ..connector import get_environment, add_checkpoint
583+from ..related_action import link
584
585 _logger = logging.getLogger(__name__)
586
587@@ -359,6 +360,7 @@
588
589
590 @job
591+@related_action(action=link)
592 def import_record(session, model_name, backend_id, magento_id, force=False):
593 """ Import a record from Magento """
594 env = get_environment(session, model_name, backend_id)
595
596=== modified file 'magentoerpconnect_pricing/product.py'
597--- magentoerpconnect_pricing/product.py 2013-07-01 11:20:54 +0000
598+++ magentoerpconnect_pricing/product.py 2014-05-19 11:42:35 +0000
599@@ -21,7 +21,7 @@
600
601
602 from openerp.tools.translate import _
603-from openerp.addons.connector.queue.job import job
604+from openerp.addons.connector.queue.job import job, related_action
605 from openerp.addons.connector.exception import FailedJobError
606 from openerp.addons.connector.unit.mapper import (mapping,
607 only_create
608@@ -32,8 +32,12 @@
609 from openerp.addons.magentoerpconnect.backend import magento
610 from openerp.addons.magentoerpconnect import product
611 from openerp.addons.magentoerpconnect.connector import get_environment
612-
613-
614+from openerp.addons.magentoerpconnect.related_action import (
615+ unwrap_binding,
616+)
617+
618+
619+# TODO: replace a price mapper only, not the full mapper
620 @magento(replacing=product.ProductImportMapper)
621 class ProductImportMapper(product.ProductImportMapper):
622 _model_name = 'magento.product.product'
623@@ -142,6 +146,7 @@
624
625
626 @job
627+@related_action(action=unwrap_binding)
628 def export_product_price(session, model_name, record_id, website_id=None):
629 """ Export the price of a product. """
630 product_bind = session.browse(model_name, record_id)

Subscribers

People subscribed via source and target branches

to all changes: