Merge lp:~initos.com/openerp-connector-magento/7.0-magentoerpconnect_options_active into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0

Proposed by Markus Schneider
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp
Approved revision: 970
Merge reported by: Guewen Baconnier @ Camptocamp
Merged at revision: not available
Proposed branch: lp:~initos.com/openerp-connector-magento/7.0-magentoerpconnect_options_active
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
Diff against target: 640 lines (+537/-0)
17 files modified
magentoerpconnect/product.py (+17/-0)
magentoerpconnect_options_active/__init__.py (+24/-0)
magentoerpconnect_options_active/__openerp__.py (+41/-0)
magentoerpconnect_options_active/connector.py (+25/-0)
magentoerpconnect_options_active/i18n/de.po (+27/-0)
magentoerpconnect_options_active/i18n/magentoerpconnect_options_active.pot (+27/-0)
magentoerpconnect_options_active/magento_model.py (+45/-0)
magentoerpconnect_options_active/magento_model_view.xml (+17/-0)
magentoerpconnect_options_active/product.py (+45/-0)
magentoerpconnect_options_active_delisted/__init__.py (+24/-0)
magentoerpconnect_options_active_delisted/__openerp__.py (+40/-0)
magentoerpconnect_options_active_delisted/connector.py (+25/-0)
magentoerpconnect_options_active_delisted/i18n/de.po (+37/-0)
magentoerpconnect_options_active_delisted/i18n/magentoerpconnect_options_active_delisted.pot (+37/-0)
magentoerpconnect_options_active_delisted/magento_model.py (+41/-0)
magentoerpconnect_options_active_delisted/product.py (+47/-0)
magentoerpconnect_options_active_delisted/product_view.xml (+18/-0)
To merge this branch: bzr merge lp:~initos.com/openerp-connector-magento/7.0-magentoerpconnect_options_active
Reviewer Review Type Date Requested Status
Markus Schneider Needs Resubmitting
Guewen Baconnier @ Camptocamp code review Approve
Review via email: mp+217423@code.launchpad.net

Description of the change

Add module to handle product active from magento and add configuration option for user to select how to handle

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

Hi Markus,

Thanks for your contribution!

Adding options for that could be interesting indeed, maybe even in the core module.

From a technical point of view, the problem with the 'replacing' here is that it replaces the entire mapper product.ProductImportMapper, so if 2 modules replace the same mapper, there will be a conflict.

The workaround is to introduce a empty / default mapper only for the mapping 'is_active' in the core module and 'replace' only this mapper (and the main ProductImportMapper calls this 'is_active' mapper)

review: Needs Fixing (code review)
Revision history for this message
Markus Schneider (markus-schneider) wrote :

from our test side we found also that 'replace' was ignored if you have a customer backend setup on top. Is this also a limitation or a bug?

As i saw that you already merge the is_active method from Jan https://code.launchpad.net/~jan-philipp-fischer/openerp-connector-magento/7.0-deactivated-products/+merge/211014 to the next release i was playing with the 'replace'

A other solution maybe is to have a new backend typ inherits from the 'magento' but this also conflicts with other stuff to replace.

Over all, i prefer to remove 'is_active' from the core connector and remove replace from my module.

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

> from our test side we found also that 'replace' was ignored if you have a
> customer backend setup on top. Is this also a limitation or a bug?

You customer's mapper (or ConnectorUnit) has to inherit from the class that you want to extend. Here, it has to inherit from magentoerpconnect_options_active.product.ProductImportMapper (this is a normal python inheritance).

>
> As i saw that you already merge the is_active method from Jan
> https://code.launchpad.net/~jan-philipp-fischer/openerp-connector-magento/7.0
> -deactivated-products/+merge/211014 to the next release i was playing with the
> 'replace'
>
> A other solution maybe is to have a new backend typ inherits from the
> 'magento' but this also conflicts with other stuff to replace.
>
> Over all, i prefer to remove 'is_active' from the core connector and remove
> replace from my module.

By proposal was to propose a default in the core module, but using a dedicated mapper

  In the core module:

    {new}
    class IsActiveProductImportMapper(ImportMapper):
        _model_name = 'magento.product.product'
        @mapping
        def is_active(self, record):
            return {default_mapping}

    {modify}
    class ProductImportMapper(ImportMapper):
        @mapping
        def is_active(self, record):
            mapper = self.get_connector_unit_for_model(IsActiveProductImportMapper)
            return mapper.map_record(record).values()

  In the extension module:
    {inherit the specialized mapper instead of the common one}
    @magento(replacing=product.IsActiveProductImportMapper)
    class IsActiveProductImportMapper(product.IsActiveProductImportMapper):

This is the only way actually to modify a mapper "horizontally" and prevent conflicts between modules.
A way to avoid that could be to implement a mapper pipeline (but it would not resolve the issue for the other ConnectorUnits).

969. By Markus Schneider

add seperate IsActiveProductImportMapper to fix replacing issues

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

i test your idea and it works, for the default mapping i decide to disable the product in OpenERP feels more natural that you have in both system a disable flag and they match

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

On Tue, May 6, 2014 at 4:31 PM, Markus Schneider
<email address hidden> wrote:
> Review: Resubmit
>
> i test your idea and it works, for the default mapping i decide to disable the product in OpenERP feels more natural that you have in both system a disable flag and they match

I agree with you.

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

Since product_active column is required, can you put a default value?

Once that changed, it will be fine.

Thanks!

970. By Markus Schneider

add defaults option

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

done

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

Looks good to me, thanks

review: Approve (code review)
971. By Markus Schneider

adding description

972. By Markus Schneider

adding translation files

973. By Markus Schneider

add module for delisted options

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

adding module description and translation file

also add new module 'magentoerpconnect_options_active_delisted' to show how to extend option list by a separate module if needed.

So now i finish all my ideas to push the concept on configuration options to the limit.

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'magentoerpconnect/product.py'
--- magentoerpconnect/product.py 2014-01-14 10:41:05 +0000
+++ magentoerpconnect/product.py 2014-05-07 10:04:05 +0000
@@ -385,6 +385,18 @@
385385
386386
387@magento387@magento
388class IsActiveProductImportMapper(ImportMapper):
389 _model_name = 'magento.product.product'
390
391 @mapping
392 def is_active(self, record):
393 """Check if the product is active in Magento
394 and set active flag in OpenERP
395 status == 1 in Magento means active"""
396 return {'active': (record.get('status') == '1')}
397
398
399@magento
388class ProductImportMapper(ImportMapper):400class ProductImportMapper(ImportMapper):
389 _model_name = 'magento.product.product'401 _model_name = 'magento.product.product'
390 #TODO : categ, special_price => minimal_price402 #TODO : categ, special_price => minimal_price
@@ -400,6 +412,11 @@
400 ]412 ]
401413
402 @mapping414 @mapping
415 def is_active(self, record):
416 mapper = self.get_connector_unit_for_model(IsActiveProductImportMapper)
417 return mapper.map_record(record).values()
418
419 @mapping
403 def price(self, record):420 def price(self, record):
404 """ The price is imported at the creation of421 """ The price is imported at the creation of
405 the product, then it is only modified and exported422 the product, then it is only modified and exported
406423
=== added directory 'magentoerpconnect_options_active'
=== added file 'magentoerpconnect_options_active/__init__.py'
--- magentoerpconnect_options_active/__init__.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/__init__.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,24 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from . import connector
23from . import magento_model
24from . import product
025
=== added file 'magentoerpconnect_options_active/__openerp__.py'
--- magentoerpconnect_options_active/__openerp__.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/__openerp__.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,41 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{'name': 'Magento Connector Option Active Products',
23 'version': '1.0.0',
24 'category': 'Connector',
25 'depends': ['magentoerpconnect',
26 ],
27 'external_dependencies': {},
28 'author': 'Connector Core Editors',
29 'license': 'AGPL-3',
30 'website': 'https://launchpad.net/magentoerpconnect',
31 'description': """
32adds options to magento.backend to handle product active flag in Magento
33in diffrent ways in OpenERP
34""",
35 'images': [],
36 'demo': [],
37 'data': ['magento_model_view.xml',
38 ],
39 'installable': True,
40 'application': False,
41 }
042
=== added file 'magentoerpconnect_options_active/connector.py'
--- magentoerpconnect_options_active/connector.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/connector.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.addons.connector.connector import install_in_connector
23
24
25install_in_connector()
026
=== added directory 'magentoerpconnect_options_active/i18n'
=== added file 'magentoerpconnect_options_active/i18n/de.po'
--- magentoerpconnect_options_active/i18n/de.po 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/i18n/de.po 2014-05-07 10:04:05 +0000
@@ -0,0 +1,27 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * magentoerpconnect_options_active
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-05-07 09:49+0000\n"
10"PO-Revision-Date: 2014-05-07 09:49+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#: field:magento.backend,product_active:0
19#. module: magentoerpconnect_options_active
20msgid "Handle disable products"
21msgstr "Deaktivierte Produkte mappen"
22
23#: model:ir.model,name:magentoerpconnect_options_active.model_magento_backend
24#. module: magentoerpconnect_options_active
25msgid "Magento Backend"
26msgstr ""
27
028
=== added file 'magentoerpconnect_options_active/i18n/magentoerpconnect_options_active.pot'
--- magentoerpconnect_options_active/i18n/magentoerpconnect_options_active.pot 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/i18n/magentoerpconnect_options_active.pot 2014-05-07 10:04:05 +0000
@@ -0,0 +1,27 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * magentoerpconnect_options_active
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-05-07 09:49+0000\n"
10"PO-Revision-Date: 2014-05-07 09:49+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: magentoerpconnect_options_active
19#: field:magento.backend,product_active:0
20msgid "Handle disable products"
21msgstr ""
22
23#. module: magentoerpconnect_options_active
24#: model:ir.model,name:magentoerpconnect_options_active.model_magento_backend
25msgid "Magento Backend"
26msgstr ""
27
028
=== added file 'magentoerpconnect_options_active/magento_model.py'
--- magentoerpconnect_options_active/magento_model.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/magento_model.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,45 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import fields, orm
23
24
25class magento_backend(orm.Model):
26
27 _name = 'magento.backend'
28 _inherit = 'magento.backend'
29
30 def _select_product_active(self, cr, uid, context=None):
31 return [('nothing', 'do nothing in OpenERP'),
32 ('disable', 'disable in OpenERP'),
33 ('no_sale', 'disable sale option'),
34 ('no_sale_no_purchase', 'disable sale & purchase option')]
35
36 _columns = {
37 'product_active': fields.selection(
38 _select_product_active,
39 string='Handle disable products',
40 required=True),
41 }
42
43 _defaults = {
44 'product_active': 'disable',
45 }
046
=== added file 'magentoerpconnect_options_active/magento_model_view.xml'
--- magentoerpconnect_options_active/magento_model_view.xml 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/magento_model_view.xml 2014-05-07 10:04:05 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="view_magento_backend_form_options_active" model="ir.ui.view">
6 <field name="name">magento.backend.form.options_active</field>
7 <field name="model">magento.backend</field>
8 <field name="inherit_id" ref="magentoerpconnect.view_magento_backend_form" />
9 <field name="arch" type="xml">
10 <xpath expr="//field[@name='default_category_id']" position="after">
11 <field name="product_active" />
12 </xpath>
13 </field>
14 </record>
15
16 </data>
17</openerp>
0\ No newline at end of file18\ No newline at end of file
119
=== added file 'magentoerpconnect_options_active/product.py'
--- magentoerpconnect_options_active/product.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active/product.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,45 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.addons.connector.unit.mapper import mapping
23from openerp.addons.magentoerpconnect.backend import magento
24from openerp.addons.magentoerpconnect import product
25
26
27@magento(replacing=product.IsActiveProductImportMapper)
28class OptionsIsActiveProductImportMapper(product.IsActiveProductImportMapper):
29 _model_name = 'magento.product.product'
30
31 @mapping
32 def is_active(self, record):
33 """Check if the product is active in Magento
34 and change acording the options"""
35 is_active = (record.get('status') == '1')
36
37 if self.backend_record.product_active == 'nothing':
38 return {}
39 if self.backend_record.product_active == 'disable':
40 return {'active': is_active}
41 if self.backend_record.product_active == 'no_sale':
42 return {'sale_ok': is_active}
43 if self.backend_record.product_active == 'no_sale_no_purchase':
44 return {'sale_ok': is_active,
45 'purchase_ok': is_active}
046
=== added directory 'magentoerpconnect_options_active_delisted'
=== added file 'magentoerpconnect_options_active_delisted/__init__.py'
--- magentoerpconnect_options_active_delisted/__init__.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/__init__.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,24 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from . import connector
23from . import magento_model
24from . import product
025
=== added file 'magentoerpconnect_options_active_delisted/__openerp__.py'
--- magentoerpconnect_options_active_delisted/__openerp__.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/__openerp__.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,40 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{'name': 'Magento Connector Option Active Products as delisted',
23 'version': '1.0.0',
24 'category': 'Connector',
25 'depends': ['magentoerpconnect_options_active',
26 ],
27 'external_dependencies': {},
28 'author': 'Connector Core Editors',
29 'license': 'AGPL-3',
30 'website': 'https://launchpad.net/magentoerpconnect',
31 'description': """
32adds delisted option to magento.backend to handle product active flag
33in Magento as a delisted flag in OpenERP
34""",
35 'images': [],
36 'demo': [],
37 'data': ['product_view.xml'],
38 'installable': True,
39 'application': False,
40 }
041
=== added file 'magentoerpconnect_options_active_delisted/connector.py'
--- magentoerpconnect_options_active_delisted/connector.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/connector.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.addons.connector.connector import install_in_connector
23
24
25install_in_connector()
026
=== added directory 'magentoerpconnect_options_active_delisted/i18n'
=== added file 'magentoerpconnect_options_active_delisted/i18n/de.po'
--- magentoerpconnect_options_active_delisted/i18n/de.po 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/i18n/de.po 2014-05-07 10:04:05 +0000
@@ -0,0 +1,37 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * magentoerpconnect_options_active_delisted
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-05-07 09:57+0000\n"
10"PO-Revision-Date: 2014-05-07 09:57+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#: model:ir.model,name:magentoerpconnect_options_active_delisted.model_product_product
19#. module: magentoerpconnect_options_active_delisted
20msgid "Product"
21msgstr "Produkt"
22
23#: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magento_backend
24#. module: magentoerpconnect_options_active_delisted
25msgid "Magento Backend"
26msgstr ""
27
28#: field:product.product,delisted:0
29#. module: magentoerpconnect_options_active_delisted
30msgid "Product delisted"
31msgstr "Produkt ausgelistet"
32
33#: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magentoerpconnect_options_active_delisted_installed
34#. module: magentoerpconnect_options_active_delisted
35msgid "magentoerpconnect_options_active_delisted.installed"
36msgstr ""
37
038
=== added file 'magentoerpconnect_options_active_delisted/i18n/magentoerpconnect_options_active_delisted.pot'
--- magentoerpconnect_options_active_delisted/i18n/magentoerpconnect_options_active_delisted.pot 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/i18n/magentoerpconnect_options_active_delisted.pot 2014-05-07 10:04:05 +0000
@@ -0,0 +1,37 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * magentoerpconnect_options_active_delisted
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-05-07 09:57+0000\n"
10"PO-Revision-Date: 2014-05-07 09:57+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: magentoerpconnect_options_active_delisted
19#: model:ir.model,name:magentoerpconnect_options_active_delisted.model_product_product
20msgid "Product"
21msgstr ""
22
23#. module: magentoerpconnect_options_active_delisted
24#: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magento_backend
25msgid "Magento Backend"
26msgstr ""
27
28#. module: magentoerpconnect_options_active_delisted
29#: field:product.product,delisted:0
30msgid "Product delisted"
31msgstr ""
32
33#. module: magentoerpconnect_options_active_delisted
34#: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magentoerpconnect_options_active_delisted_installed
35msgid "magentoerpconnect_options_active_delisted.installed"
36msgstr ""
37
038
=== added file 'magentoerpconnect_options_active_delisted/magento_model.py'
--- magentoerpconnect_options_active_delisted/magento_model.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/magento_model.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,41 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import fields, orm
23
24
25class magento_backend(orm.Model):
26
27 _name = 'magento.backend'
28 _inherit = 'magento.backend'
29
30 def _select_product_active(self, cr, uid, context=None):
31 product_active_options = super(magento_backend, self)\
32 ._select_product_active(cr, uid, context=context)
33 product_active_options.append(('delisted', 'mark as delisted'))
34 return product_active_options
35
36 _columns = {
37 'product_active': fields.selection(
38 _select_product_active,
39 string='Handle disable products',
40 required=True),
41 }
042
=== added file 'magentoerpconnect_options_active_delisted/product.py'
--- magentoerpconnect_options_active_delisted/product.py 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/product.py 2014-05-07 10:04:05 +0000
@@ -0,0 +1,47 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Markus Schneider
5# Copyright 2014 initOS GmbH & Co. KG
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import fields, orm
23from openerp.addons.connector.unit.mapper import mapping
24from openerp.addons.magentoerpconnect.backend import magento
25from openerp.addons.magentoerpconnect_options_active import product
26
27
28class product_product(orm.Model):
29 _name = 'product.product'
30 _inherit = 'product.product'
31 _columns = {'delisted': fields.boolean('Product delisted')}
32
33
34@magento(replacing=product.OptionsIsActiveProductImportMapper)
35class AdvProductImportMapper(product.OptionsIsActiveProductImportMapper):
36 _model_name = 'magento.product.product'
37
38 @mapping
39 def is_active(self, record):
40 """Check if the product is active in Magento
41 and change acording the options"""
42 is_active = (record.get('status') == '1')
43
44 if self.backend_record.product_active == 'delisted':
45 return {'delisted': not is_active}
46
47 return super(AdvProductImportMapper, self).is_active(record)
048
=== added file 'magentoerpconnect_options_active_delisted/product_view.xml'
--- magentoerpconnect_options_active_delisted/product_view.xml 1970-01-01 00:00:00 +0000
+++ magentoerpconnect_options_active_delisted/product_view.xml 2014-05-07 10:04:05 +0000
@@ -0,0 +1,18 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="product_product_form_delisted" model="ir.ui.view">
6 <field name="name">product.product.form.delisted</field>
7 <field name="model">product.product</field>
8 <field name="inherit_id" ref="product.product_normal_form_view" />
9 <field name="arch" type="xml">
10 <xpath expr="//label[@for='sale_ok']" position="after">
11 <field name="delisted" />
12 <label for="delisted"/>
13 </xpath>
14 </field>
15 </record>
16
17 </data>
18</openerp>
0\ No newline at end of file19\ No newline at end of file