Merge lp:~jan-philipp-fischer/openerp-connector-magento/7.0-date-bugfix into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0

Proposed by Jan-Philipp Fischer
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp
Approved revision: 966
Merge reported by: Guewen Baconnier @ Camptocamp
Merged at revision: not available
Proposed branch: lp:~jan-philipp-fischer/openerp-connector-magento/7.0-date-bugfix
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
Diff against target: 58 lines (+34/-2)
2 files modified
magentoerpconnect/product.py (+3/-2)
magentoerpconnect/unit/mapper.py (+31/-0)
To merge this branch: bzr merge lp:~jan-philipp-fischer/openerp-connector-magento/7.0-date-bugfix
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Jan-Philipp Fischer (community) Needs Resubmitting
Review via email: mp+211683@code.launchpad.net

Description of the change

Fixes this bug: https://bugs.launchpad.net/openerp-connector-magento/+bug/1210471

Done with the new modifier function, so newest version of openerp-connector is needed.

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

I'm happy to see that finally fixed, thanks!

Ideally it should be done on all date fields coming from Magento, but the rest can be done in another proposal eventually.

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

Could you rename the modifier to normalize_datetime?
I think a normalize_date will be necessary as well and we have to make the distinction.

Thanks

review: Needs Fixing
966. By Jan-Philipp Fischer

Change Function Name

Revision history for this message
Jan-Philipp Fischer (jan-philipp-fischer) wrote :

Done. Please Review

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

Perfect! thanks

review: Approve
Revision history for this message
Jan-Philipp Fischer (jan-philipp-fischer) wrote :

> I'm happy to see that finally fixed, thanks!
>
> Ideally it should be done on all date fields coming from Magento, but the rest
> can be done in another proposal eventually.

Yes think so, too. But I think this proposal should only for that reported bug.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/product.py'
2--- magentoerpconnect/product.py 2014-01-14 10:41:05 +0000
3+++ magentoerpconnect/product.py 2014-03-19 10:56:30 +0000
4@@ -41,6 +41,7 @@
5 ImportMapper,
6 )
7 from .unit.backend_adapter import GenericAdapter
8+from .unit.mapper import normalize_datetime
9 from .unit.import_synchronizer import (DelayedBatchImport,
10 MagentoImportSynchronizer,
11 TranslationImporter,
12@@ -395,8 +396,8 @@
13 ('short_description', 'description_sale'),
14 ('sku', 'default_code'),
15 ('type_id', 'product_type'),
16- ('created_at', 'created_at'),
17- ('updated_at', 'updated_at'),
18+ (normalize_datetime('created_at'), 'created_at'),
19+ (normalize_datetime('updated_at'), 'updated_at'),
20 ]
21
22 @mapping
23
24=== added file 'magentoerpconnect/unit/mapper.py'
25--- magentoerpconnect/unit/mapper.py 1970-01-01 00:00:00 +0000
26+++ magentoerpconnect/unit/mapper.py 2014-03-19 10:56:30 +0000
27@@ -0,0 +1,31 @@
28+# -*- coding: utf-8 -*-
29+##############################################################################
30+#
31+# Author: Guewen Baconnier
32+# Copyright 2013 Camptocamp SA
33+#
34+# This program is free software: you can redistribute it and/or modify
35+# it under the terms of the GNU Affero General Public License as
36+# published by the Free Software Foundation, either version 3 of the
37+# License, or (at your option) any later version.
38+#
39+# This program is distributed in the hope that it will be useful,
40+# but WITHOUT ANY WARRANTY; without even the implied warranty of
41+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42+# GNU Affero General Public License for more details.
43+#
44+# You should have received a copy of the GNU Affero General Public License
45+# along with this program. If not, see <http://www.gnu.org/licenses/>.
46+#
47+##############################################################################
48+
49+
50+def normalize_datetime(field):
51+ """Change a invalid date which comes from Magento, if
52+ no real date is set to null for correct import to
53+ OpenERP"""
54+ def modifier(self, record, to_attr):
55+ if record[field] == '0000-00-00 00:00:00':
56+ return None
57+ return record[field]
58+ return modifier