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

Proposed by Jan-Philipp Fischer
Status: Needs review
Proposed branch: lp:~jan-philipp-fischer/openerp-connector-magento/7.0-strip-html
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
Diff against target: 63 lines (+34/-2) (has conflicts)
2 files modified
magentoerpconnect/product.py (+6/-2)
magentoerpconnect/unit/mapper.py (+28/-0)
Text conflict in magentoerpconnect/product.py
Conflict adding file magentoerpconnect/unit/mapper.py.  Moved existing file to magentoerpconnect/unit/mapper.py.moved.
To merge this branch: bzr merge lp:~jan-philipp-fischer/openerp-connector-magento/7.0-strip-html
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Needs Resubmitting
Jan-Philipp Fischer (community) Needs Resubmitting
Sébastien BEAU - http://www.akretion.com Needs Fixing
Review via email: mp+211911@code.launchpad.net

Description of the change

Strips HTML Tags from description and sale_description.

Addes a general modifier for that.

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

Hi Jan,
Thanks for the contribution. Can you fix the copyright?
You are the author of the change, be proud of your work ;)

You have some pep-8 issue in the file mapper.py

- miss a blank line before the "class MLStriper" (always 2 blank line before a class)
- miss a blank line before the "def...."
- remove the last blank line at the end of the file.

(Note I use https://github.com/nbessi/openerp-conventions ;) )

Fix the pep8 issue and it will be ok for me

review: Approve (no test, code review)
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

oups sorry wrong status. A small need fixing for the pep8 issue

review: Needs Fixing
965. By Jan-Philipp Fischer

[FIX] Copyright and pep-8 issues

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

Hi Sébastien,

i changed the file. Thanks for you review:)

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

Hi Jan-Philipp,

The MLStripper puts only 1 line break between paragraphs, when we could expect a blank line. Do you know if this can be changed?

As an alternative, you can use the html2text lib which is embedded in openerp.addons.email_template. It does something sligtly different though: it transforms the html to a markdown-like syntax (so <b>hello world</b> becomes **hello world**), but is it something we could expect in the descriptions? In my opinion, using html2text could be nice.

A note about the 'Resubmit': as the one who proposed the merge, you should not use the 'Resubmit' review, it is usually used by reviewers when they *ask* for a resubmit.

review: Needs Fixing
966. By Jan-Philipp Fischer

Using html2text

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

Updated to html2text. You're right. It is nice.

Aren't able to test it in OpenERP at the moment. But tested it with normal python and it worked.
If someone can test it in OpenERP it would be nice.

Thanks!

Revision history for this message
Philippe B (philippe-j) wrote :

Why we can't keep the html tags in openerp with an editor embed so you can make beautiful descriptions to export them to magento like you can do it with saas3
Philippe
sorry for my french english

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

Hi Philippe,

I don't know a way for getting such an editor into OpenERP (Odoo).

Do you?

Revision history for this message
Markus Schneider (markus-schneider) wrote :

Fields.html would do the job.

The problem is we need to change a basic field of product.product and if you are not using webkit it can breaks your sale.order report. But as a seperat module it would be possible
--
Dipl.-Comp.-Math. Markus Schneider
Softwareentwickler

initOS GmbH & Co. KG
An der Eisenbahn 1
21224 Rosengarten

Mobil: +49 (0)172 2303699
Phone: +49 (0)4105 5615613
Fax: +49 (0)4105 5615610

Email: <email address hidden>
Web: http://www.initos.com

Geschäftsführung:
Dipl. Wirt.-Inf. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
Haftende Gesellschafterin: initOS Verwaltungs GmbH

Sitz der Gesellschaft: Rosengarten – Klecken
Amtsgericht Tostedt, HRA 201840
USt-IdNr: DE 275698169
Steuer-Nr: 15/205/21402

Revision history for this message
Philippe B (philippe-j) wrote :

hi Jan-philipp

i'm not a dev only a "good" user
but in magento you can have an html editor for the description fields
i fond on tne web an html editor for python
http://arstechnica.com/information-technology/2009/07/how-to-build-a-desktop-wysiwyg-editor-with-webkit-and-html-5/
tinyMCE i an php java html editor
but i don't know how to implement it in openerp web interface

Philippe

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

This project is now hosted on https://github.com/OCA/connector-magento. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting

Unmerged revisions

966. By Jan-Philipp Fischer

Using html2text

965. By Jan-Philipp Fischer

[FIX] Copyright and pep-8 issues

964. By Jan-Philipp Fischer

[FIX] Stripping HTML Tags from Description

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-05-26 09:37:00 +0000
3+++ magentoerpconnect/product.py 2014-06-11 16:33:16 +0000
4@@ -41,7 +41,11 @@
5 ImportMapper,
6 )
7 from .unit.backend_adapter import GenericAdapter
8+<<<<<<< TREE
9 from .unit.mapper import normalize_datetime
10+=======
11+from .unit.mapper import strip_html
12+>>>>>>> MERGE-SOURCE
13 from .unit.import_synchronizer import (DelayedBatchImport,
14 MagentoImportSynchronizer,
15 TranslationImporter,
16@@ -420,10 +424,10 @@
17 _model_name = 'magento.product.product'
18 # TODO : categ, special_price => minimal_price
19 direct = [('name', 'name'),
20- ('description', 'description'),
21+ (strip_html('description'), 'description'),
22 ('weight', 'weight'),
23 ('cost', 'standard_price'),
24- ('short_description', 'description_sale'),
25+ (strip_html('short_description'), 'description_sale'),
26 ('sku', 'default_code'),
27 ('type_id', 'product_type'),
28 (normalize_datetime('created_at'), 'created_at'),
29
30=== added file 'magentoerpconnect/unit/mapper.py'
31--- magentoerpconnect/unit/mapper.py 1970-01-01 00:00:00 +0000
32+++ magentoerpconnect/unit/mapper.py 2014-06-11 16:33:16 +0000
33@@ -0,0 +1,28 @@
34+# -*- coding: utf-8 -*-
35+##############################################################################
36+#
37+# Author: Jan-Philipp Fischer
38+# Copyright 2014 greencoding.de
39+#
40+# This program is free software: you can redistribute it and/or modify
41+# it under the terms of the GNU Affero General Public License as
42+# published by the Free Software Foundation, either version 3 of the
43+# License, or (at your option) any later version.
44+#
45+# This program is distributed in the hope that it will be useful,
46+# but WITHOUT ANY WARRANTY; without even the implied warranty of
47+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+# GNU Affero General Public License for more details.
49+#
50+# You should have received a copy of the GNU Affero General Public License
51+# along with this program. If not, see <http://www.gnu.org/licenses/>.
52+#
53+##############################################################################
54+
55+import html2text
56+
57+def strip_html(field):
58+ """Strip HTML Tags from Strings"""
59+ def modifier(self, record, to_attr):
60+ return html2text.html2text(record[field])
61+ return modifier
62
63=== renamed file 'magentoerpconnect/unit/mapper.py' => 'magentoerpconnect/unit/mapper.py.moved'