Merge lp:~initos.com/openerp-connector-magento/7.0-magentoerpconnect_options_active into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
- 7.0-magentoerpconnect_options_active
- Merge into 7.0
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markus Schneider | Needs Resubmitting | ||
Guewen Baconnier @ Camptocamp | code review | Approve | |
Review via email: mp+217423@code.launchpad.net |
Commit message
Description of the change
Add module to handle product active from magento and add configuration option for user to select how to handle
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
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:/
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.
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 magentoerpconne
>
> As i saw that you already merge the is_active method from Jan
> https:/
> -deactivated-
> '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 IsActiveProduct
_model_name = 'magento.
@mapping
def is_active(self, record):
return {default_mapping}
{modify}
class ProductImportMa
@mapping
def is_active(self, record):
mapper = self.get_
return mapper.
In the extension module:
{inherit the specialized mapper instead of the common one}
@magento(
class IsActiveProduct
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 IsActiveProduct
ImportMapper to fix replacing issues
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
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.
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
Markus Schneider (markus-schneider) wrote : | # |
done
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Looks good to me, thanks
- 971. By Markus Schneider
-
adding description
- 972. By Markus Schneider
-
adding translation files
- 973. By Markus Schneider
-
add module for delisted options
Markus Schneider (markus-schneider) wrote : | # |
adding module description and translation file
also add new module 'magentoerpconn
So now i finish all my ideas to push the concept on configuration options to the limit.
Preview Diff
1 | === modified file 'magentoerpconnect/product.py' | |||
2 | --- magentoerpconnect/product.py 2014-01-14 10:41:05 +0000 | |||
3 | +++ magentoerpconnect/product.py 2014-05-07 10:04:05 +0000 | |||
4 | @@ -385,6 +385,18 @@ | |||
5 | 385 | 385 | ||
6 | 386 | 386 | ||
7 | 387 | @magento | 387 | @magento |
8 | 388 | class IsActiveProductImportMapper(ImportMapper): | ||
9 | 389 | _model_name = 'magento.product.product' | ||
10 | 390 | |||
11 | 391 | @mapping | ||
12 | 392 | def is_active(self, record): | ||
13 | 393 | """Check if the product is active in Magento | ||
14 | 394 | and set active flag in OpenERP | ||
15 | 395 | status == 1 in Magento means active""" | ||
16 | 396 | return {'active': (record.get('status') == '1')} | ||
17 | 397 | |||
18 | 398 | |||
19 | 399 | @magento | ||
20 | 388 | class ProductImportMapper(ImportMapper): | 400 | class ProductImportMapper(ImportMapper): |
21 | 389 | _model_name = 'magento.product.product' | 401 | _model_name = 'magento.product.product' |
22 | 390 | #TODO : categ, special_price => minimal_price | 402 | #TODO : categ, special_price => minimal_price |
23 | @@ -400,6 +412,11 @@ | |||
24 | 400 | ] | 412 | ] |
25 | 401 | 413 | ||
26 | 402 | @mapping | 414 | @mapping |
27 | 415 | def is_active(self, record): | ||
28 | 416 | mapper = self.get_connector_unit_for_model(IsActiveProductImportMapper) | ||
29 | 417 | return mapper.map_record(record).values() | ||
30 | 418 | |||
31 | 419 | @mapping | ||
32 | 403 | def price(self, record): | 420 | def price(self, record): |
33 | 404 | """ The price is imported at the creation of | 421 | """ The price is imported at the creation of |
34 | 405 | the product, then it is only modified and exported | 422 | the product, then it is only modified and exported |
35 | 406 | 423 | ||
36 | === added directory 'magentoerpconnect_options_active' | |||
37 | === added file 'magentoerpconnect_options_active/__init__.py' | |||
38 | --- magentoerpconnect_options_active/__init__.py 1970-01-01 00:00:00 +0000 | |||
39 | +++ magentoerpconnect_options_active/__init__.py 2014-05-07 10:04:05 +0000 | |||
40 | @@ -0,0 +1,24 @@ | |||
41 | 1 | # -*- coding: utf-8 -*- | ||
42 | 2 | ############################################################################## | ||
43 | 3 | # | ||
44 | 4 | # Author: Markus Schneider | ||
45 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
46 | 6 | # | ||
47 | 7 | # This program is free software: you can redistribute it and/or modify | ||
48 | 8 | # it under the terms of the GNU Affero General Public License as | ||
49 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
50 | 10 | # License, or (at your option) any later version. | ||
51 | 11 | # | ||
52 | 12 | # This program is distributed in the hope that it will be useful, | ||
53 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
54 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
55 | 15 | # GNU Affero General Public License for more details. | ||
56 | 16 | # | ||
57 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
58 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
59 | 19 | # | ||
60 | 20 | ############################################################################## | ||
61 | 21 | |||
62 | 22 | from . import connector | ||
63 | 23 | from . import magento_model | ||
64 | 24 | from . import product | ||
65 | 0 | 25 | ||
66 | === added file 'magentoerpconnect_options_active/__openerp__.py' | |||
67 | --- magentoerpconnect_options_active/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
68 | +++ magentoerpconnect_options_active/__openerp__.py 2014-05-07 10:04:05 +0000 | |||
69 | @@ -0,0 +1,41 @@ | |||
70 | 1 | # -*- coding: utf-8 -*- | ||
71 | 2 | ############################################################################## | ||
72 | 3 | # | ||
73 | 4 | # Author: Markus Schneider | ||
74 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
75 | 6 | # | ||
76 | 7 | # This program is free software: you can redistribute it and/or modify | ||
77 | 8 | # it under the terms of the GNU Affero General Public License as | ||
78 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
79 | 10 | # License, or (at your option) any later version. | ||
80 | 11 | # | ||
81 | 12 | # This program is distributed in the hope that it will be useful, | ||
82 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
83 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
84 | 15 | # GNU Affero General Public License for more details. | ||
85 | 16 | # | ||
86 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
87 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
88 | 19 | # | ||
89 | 20 | ############################################################################## | ||
90 | 21 | |||
91 | 22 | {'name': 'Magento Connector Option Active Products', | ||
92 | 23 | 'version': '1.0.0', | ||
93 | 24 | 'category': 'Connector', | ||
94 | 25 | 'depends': ['magentoerpconnect', | ||
95 | 26 | ], | ||
96 | 27 | 'external_dependencies': {}, | ||
97 | 28 | 'author': 'Connector Core Editors', | ||
98 | 29 | 'license': 'AGPL-3', | ||
99 | 30 | 'website': 'https://launchpad.net/magentoerpconnect', | ||
100 | 31 | 'description': """ | ||
101 | 32 | adds options to magento.backend to handle product active flag in Magento | ||
102 | 33 | in diffrent ways in OpenERP | ||
103 | 34 | """, | ||
104 | 35 | 'images': [], | ||
105 | 36 | 'demo': [], | ||
106 | 37 | 'data': ['magento_model_view.xml', | ||
107 | 38 | ], | ||
108 | 39 | 'installable': True, | ||
109 | 40 | 'application': False, | ||
110 | 41 | } | ||
111 | 0 | 42 | ||
112 | === added file 'magentoerpconnect_options_active/connector.py' | |||
113 | --- magentoerpconnect_options_active/connector.py 1970-01-01 00:00:00 +0000 | |||
114 | +++ magentoerpconnect_options_active/connector.py 2014-05-07 10:04:05 +0000 | |||
115 | @@ -0,0 +1,25 @@ | |||
116 | 1 | # -*- coding: utf-8 -*- | ||
117 | 2 | ############################################################################## | ||
118 | 3 | # | ||
119 | 4 | # Author: Markus Schneider | ||
120 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
121 | 6 | # | ||
122 | 7 | # This program is free software: you can redistribute it and/or modify | ||
123 | 8 | # it under the terms of the GNU Affero General Public License as | ||
124 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
125 | 10 | # License, or (at your option) any later version. | ||
126 | 11 | # | ||
127 | 12 | # This program is distributed in the hope that it will be useful, | ||
128 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
129 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
130 | 15 | # GNU Affero General Public License for more details. | ||
131 | 16 | # | ||
132 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
133 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
134 | 19 | # | ||
135 | 20 | ############################################################################## | ||
136 | 21 | |||
137 | 22 | from openerp.addons.connector.connector import install_in_connector | ||
138 | 23 | |||
139 | 24 | |||
140 | 25 | install_in_connector() | ||
141 | 0 | 26 | ||
142 | === added directory 'magentoerpconnect_options_active/i18n' | |||
143 | === added file 'magentoerpconnect_options_active/i18n/de.po' | |||
144 | --- magentoerpconnect_options_active/i18n/de.po 1970-01-01 00:00:00 +0000 | |||
145 | +++ magentoerpconnect_options_active/i18n/de.po 2014-05-07 10:04:05 +0000 | |||
146 | @@ -0,0 +1,27 @@ | |||
147 | 1 | # Translation of OpenERP Server. | ||
148 | 2 | # This file contains the translation of the following modules: | ||
149 | 3 | # * magentoerpconnect_options_active | ||
150 | 4 | # | ||
151 | 5 | msgid "" | ||
152 | 6 | msgstr "" | ||
153 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
154 | 8 | "Report-Msgid-Bugs-To: \n" | ||
155 | 9 | "POT-Creation-Date: 2014-05-07 09:49+0000\n" | ||
156 | 10 | "PO-Revision-Date: 2014-05-07 09:49+0000\n" | ||
157 | 11 | "Last-Translator: <>\n" | ||
158 | 12 | "Language-Team: \n" | ||
159 | 13 | "MIME-Version: 1.0\n" | ||
160 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
161 | 15 | "Content-Transfer-Encoding: \n" | ||
162 | 16 | "Plural-Forms: \n" | ||
163 | 17 | |||
164 | 18 | #: field:magento.backend,product_active:0 | ||
165 | 19 | #. module: magentoerpconnect_options_active | ||
166 | 20 | msgid "Handle disable products" | ||
167 | 21 | msgstr "Deaktivierte Produkte mappen" | ||
168 | 22 | |||
169 | 23 | #: model:ir.model,name:magentoerpconnect_options_active.model_magento_backend | ||
170 | 24 | #. module: magentoerpconnect_options_active | ||
171 | 25 | msgid "Magento Backend" | ||
172 | 26 | msgstr "" | ||
173 | 27 | |||
174 | 0 | 28 | ||
175 | === added file 'magentoerpconnect_options_active/i18n/magentoerpconnect_options_active.pot' | |||
176 | --- magentoerpconnect_options_active/i18n/magentoerpconnect_options_active.pot 1970-01-01 00:00:00 +0000 | |||
177 | +++ magentoerpconnect_options_active/i18n/magentoerpconnect_options_active.pot 2014-05-07 10:04:05 +0000 | |||
178 | @@ -0,0 +1,27 @@ | |||
179 | 1 | # Translation of OpenERP Server. | ||
180 | 2 | # This file contains the translation of the following modules: | ||
181 | 3 | # * magentoerpconnect_options_active | ||
182 | 4 | # | ||
183 | 5 | msgid "" | ||
184 | 6 | msgstr "" | ||
185 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
186 | 8 | "Report-Msgid-Bugs-To: \n" | ||
187 | 9 | "POT-Creation-Date: 2014-05-07 09:49+0000\n" | ||
188 | 10 | "PO-Revision-Date: 2014-05-07 09:49+0000\n" | ||
189 | 11 | "Last-Translator: <>\n" | ||
190 | 12 | "Language-Team: \n" | ||
191 | 13 | "MIME-Version: 1.0\n" | ||
192 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
193 | 15 | "Content-Transfer-Encoding: \n" | ||
194 | 16 | "Plural-Forms: \n" | ||
195 | 17 | |||
196 | 18 | #. module: magentoerpconnect_options_active | ||
197 | 19 | #: field:magento.backend,product_active:0 | ||
198 | 20 | msgid "Handle disable products" | ||
199 | 21 | msgstr "" | ||
200 | 22 | |||
201 | 23 | #. module: magentoerpconnect_options_active | ||
202 | 24 | #: model:ir.model,name:magentoerpconnect_options_active.model_magento_backend | ||
203 | 25 | msgid "Magento Backend" | ||
204 | 26 | msgstr "" | ||
205 | 27 | |||
206 | 0 | 28 | ||
207 | === added file 'magentoerpconnect_options_active/magento_model.py' | |||
208 | --- magentoerpconnect_options_active/magento_model.py 1970-01-01 00:00:00 +0000 | |||
209 | +++ magentoerpconnect_options_active/magento_model.py 2014-05-07 10:04:05 +0000 | |||
210 | @@ -0,0 +1,45 @@ | |||
211 | 1 | # -*- coding: utf-8 -*- | ||
212 | 2 | ############################################################################## | ||
213 | 3 | # | ||
214 | 4 | # Author: Markus Schneider | ||
215 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
216 | 6 | # | ||
217 | 7 | # This program is free software: you can redistribute it and/or modify | ||
218 | 8 | # it under the terms of the GNU Affero General Public License as | ||
219 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
220 | 10 | # License, or (at your option) any later version. | ||
221 | 11 | # | ||
222 | 12 | # This program is distributed in the hope that it will be useful, | ||
223 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
224 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
225 | 15 | # GNU Affero General Public License for more details. | ||
226 | 16 | # | ||
227 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
228 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
229 | 19 | # | ||
230 | 20 | ############################################################################## | ||
231 | 21 | |||
232 | 22 | from openerp.osv import fields, orm | ||
233 | 23 | |||
234 | 24 | |||
235 | 25 | class magento_backend(orm.Model): | ||
236 | 26 | |||
237 | 27 | _name = 'magento.backend' | ||
238 | 28 | _inherit = 'magento.backend' | ||
239 | 29 | |||
240 | 30 | def _select_product_active(self, cr, uid, context=None): | ||
241 | 31 | return [('nothing', 'do nothing in OpenERP'), | ||
242 | 32 | ('disable', 'disable in OpenERP'), | ||
243 | 33 | ('no_sale', 'disable sale option'), | ||
244 | 34 | ('no_sale_no_purchase', 'disable sale & purchase option')] | ||
245 | 35 | |||
246 | 36 | _columns = { | ||
247 | 37 | 'product_active': fields.selection( | ||
248 | 38 | _select_product_active, | ||
249 | 39 | string='Handle disable products', | ||
250 | 40 | required=True), | ||
251 | 41 | } | ||
252 | 42 | |||
253 | 43 | _defaults = { | ||
254 | 44 | 'product_active': 'disable', | ||
255 | 45 | } | ||
256 | 0 | 46 | ||
257 | === added file 'magentoerpconnect_options_active/magento_model_view.xml' | |||
258 | --- magentoerpconnect_options_active/magento_model_view.xml 1970-01-01 00:00:00 +0000 | |||
259 | +++ magentoerpconnect_options_active/magento_model_view.xml 2014-05-07 10:04:05 +0000 | |||
260 | @@ -0,0 +1,17 @@ | |||
261 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
262 | 2 | <openerp> | ||
263 | 3 | <data> | ||
264 | 4 | |||
265 | 5 | <record id="view_magento_backend_form_options_active" model="ir.ui.view"> | ||
266 | 6 | <field name="name">magento.backend.form.options_active</field> | ||
267 | 7 | <field name="model">magento.backend</field> | ||
268 | 8 | <field name="inherit_id" ref="magentoerpconnect.view_magento_backend_form" /> | ||
269 | 9 | <field name="arch" type="xml"> | ||
270 | 10 | <xpath expr="//field[@name='default_category_id']" position="after"> | ||
271 | 11 | <field name="product_active" /> | ||
272 | 12 | </xpath> | ||
273 | 13 | </field> | ||
274 | 14 | </record> | ||
275 | 15 | |||
276 | 16 | </data> | ||
277 | 17 | </openerp> | ||
278 | 0 | \ No newline at end of file | 18 | \ No newline at end of file |
279 | 1 | 19 | ||
280 | === added file 'magentoerpconnect_options_active/product.py' | |||
281 | --- magentoerpconnect_options_active/product.py 1970-01-01 00:00:00 +0000 | |||
282 | +++ magentoerpconnect_options_active/product.py 2014-05-07 10:04:05 +0000 | |||
283 | @@ -0,0 +1,45 @@ | |||
284 | 1 | # -*- coding: utf-8 -*- | ||
285 | 2 | ############################################################################## | ||
286 | 3 | # | ||
287 | 4 | # Author: Markus Schneider | ||
288 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
289 | 6 | # | ||
290 | 7 | # This program is free software: you can redistribute it and/or modify | ||
291 | 8 | # it under the terms of the GNU Affero General Public License as | ||
292 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
293 | 10 | # License, or (at your option) any later version. | ||
294 | 11 | # | ||
295 | 12 | # This program is distributed in the hope that it will be useful, | ||
296 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
297 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
298 | 15 | # GNU Affero General Public License for more details. | ||
299 | 16 | # | ||
300 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
301 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
302 | 19 | # | ||
303 | 20 | ############################################################################## | ||
304 | 21 | |||
305 | 22 | from openerp.addons.connector.unit.mapper import mapping | ||
306 | 23 | from openerp.addons.magentoerpconnect.backend import magento | ||
307 | 24 | from openerp.addons.magentoerpconnect import product | ||
308 | 25 | |||
309 | 26 | |||
310 | 27 | @magento(replacing=product.IsActiveProductImportMapper) | ||
311 | 28 | class OptionsIsActiveProductImportMapper(product.IsActiveProductImportMapper): | ||
312 | 29 | _model_name = 'magento.product.product' | ||
313 | 30 | |||
314 | 31 | @mapping | ||
315 | 32 | def is_active(self, record): | ||
316 | 33 | """Check if the product is active in Magento | ||
317 | 34 | and change acording the options""" | ||
318 | 35 | is_active = (record.get('status') == '1') | ||
319 | 36 | |||
320 | 37 | if self.backend_record.product_active == 'nothing': | ||
321 | 38 | return {} | ||
322 | 39 | if self.backend_record.product_active == 'disable': | ||
323 | 40 | return {'active': is_active} | ||
324 | 41 | if self.backend_record.product_active == 'no_sale': | ||
325 | 42 | return {'sale_ok': is_active} | ||
326 | 43 | if self.backend_record.product_active == 'no_sale_no_purchase': | ||
327 | 44 | return {'sale_ok': is_active, | ||
328 | 45 | 'purchase_ok': is_active} | ||
329 | 0 | 46 | ||
330 | === added directory 'magentoerpconnect_options_active_delisted' | |||
331 | === added file 'magentoerpconnect_options_active_delisted/__init__.py' | |||
332 | --- magentoerpconnect_options_active_delisted/__init__.py 1970-01-01 00:00:00 +0000 | |||
333 | +++ magentoerpconnect_options_active_delisted/__init__.py 2014-05-07 10:04:05 +0000 | |||
334 | @@ -0,0 +1,24 @@ | |||
335 | 1 | # -*- coding: utf-8 -*- | ||
336 | 2 | ############################################################################## | ||
337 | 3 | # | ||
338 | 4 | # Author: Markus Schneider | ||
339 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
340 | 6 | # | ||
341 | 7 | # This program is free software: you can redistribute it and/or modify | ||
342 | 8 | # it under the terms of the GNU Affero General Public License as | ||
343 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
344 | 10 | # License, or (at your option) any later version. | ||
345 | 11 | # | ||
346 | 12 | # This program is distributed in the hope that it will be useful, | ||
347 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
348 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
349 | 15 | # GNU Affero General Public License for more details. | ||
350 | 16 | # | ||
351 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
352 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
353 | 19 | # | ||
354 | 20 | ############################################################################## | ||
355 | 21 | |||
356 | 22 | from . import connector | ||
357 | 23 | from . import magento_model | ||
358 | 24 | from . import product | ||
359 | 0 | 25 | ||
360 | === added file 'magentoerpconnect_options_active_delisted/__openerp__.py' | |||
361 | --- magentoerpconnect_options_active_delisted/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
362 | +++ magentoerpconnect_options_active_delisted/__openerp__.py 2014-05-07 10:04:05 +0000 | |||
363 | @@ -0,0 +1,40 @@ | |||
364 | 1 | # -*- coding: utf-8 -*- | ||
365 | 2 | ############################################################################## | ||
366 | 3 | # | ||
367 | 4 | # Author: Markus Schneider | ||
368 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
369 | 6 | # | ||
370 | 7 | # This program is free software: you can redistribute it and/or modify | ||
371 | 8 | # it under the terms of the GNU Affero General Public License as | ||
372 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
373 | 10 | # License, or (at your option) any later version. | ||
374 | 11 | # | ||
375 | 12 | # This program is distributed in the hope that it will be useful, | ||
376 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
377 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
378 | 15 | # GNU Affero General Public License for more details. | ||
379 | 16 | # | ||
380 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
381 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
382 | 19 | # | ||
383 | 20 | ############################################################################## | ||
384 | 21 | |||
385 | 22 | {'name': 'Magento Connector Option Active Products as delisted', | ||
386 | 23 | 'version': '1.0.0', | ||
387 | 24 | 'category': 'Connector', | ||
388 | 25 | 'depends': ['magentoerpconnect_options_active', | ||
389 | 26 | ], | ||
390 | 27 | 'external_dependencies': {}, | ||
391 | 28 | 'author': 'Connector Core Editors', | ||
392 | 29 | 'license': 'AGPL-3', | ||
393 | 30 | 'website': 'https://launchpad.net/magentoerpconnect', | ||
394 | 31 | 'description': """ | ||
395 | 32 | adds delisted option to magento.backend to handle product active flag | ||
396 | 33 | in Magento as a delisted flag in OpenERP | ||
397 | 34 | """, | ||
398 | 35 | 'images': [], | ||
399 | 36 | 'demo': [], | ||
400 | 37 | 'data': ['product_view.xml'], | ||
401 | 38 | 'installable': True, | ||
402 | 39 | 'application': False, | ||
403 | 40 | } | ||
404 | 0 | 41 | ||
405 | === added file 'magentoerpconnect_options_active_delisted/connector.py' | |||
406 | --- magentoerpconnect_options_active_delisted/connector.py 1970-01-01 00:00:00 +0000 | |||
407 | +++ magentoerpconnect_options_active_delisted/connector.py 2014-05-07 10:04:05 +0000 | |||
408 | @@ -0,0 +1,25 @@ | |||
409 | 1 | # -*- coding: utf-8 -*- | ||
410 | 2 | ############################################################################## | ||
411 | 3 | # | ||
412 | 4 | # Author: Markus Schneider | ||
413 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
414 | 6 | # | ||
415 | 7 | # This program is free software: you can redistribute it and/or modify | ||
416 | 8 | # it under the terms of the GNU Affero General Public License as | ||
417 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
418 | 10 | # License, or (at your option) any later version. | ||
419 | 11 | # | ||
420 | 12 | # This program is distributed in the hope that it will be useful, | ||
421 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
422 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
423 | 15 | # GNU Affero General Public License for more details. | ||
424 | 16 | # | ||
425 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
426 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
427 | 19 | # | ||
428 | 20 | ############################################################################## | ||
429 | 21 | |||
430 | 22 | from openerp.addons.connector.connector import install_in_connector | ||
431 | 23 | |||
432 | 24 | |||
433 | 25 | install_in_connector() | ||
434 | 0 | 26 | ||
435 | === added directory 'magentoerpconnect_options_active_delisted/i18n' | |||
436 | === added file 'magentoerpconnect_options_active_delisted/i18n/de.po' | |||
437 | --- magentoerpconnect_options_active_delisted/i18n/de.po 1970-01-01 00:00:00 +0000 | |||
438 | +++ magentoerpconnect_options_active_delisted/i18n/de.po 2014-05-07 10:04:05 +0000 | |||
439 | @@ -0,0 +1,37 @@ | |||
440 | 1 | # Translation of OpenERP Server. | ||
441 | 2 | # This file contains the translation of the following modules: | ||
442 | 3 | # * magentoerpconnect_options_active_delisted | ||
443 | 4 | # | ||
444 | 5 | msgid "" | ||
445 | 6 | msgstr "" | ||
446 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
447 | 8 | "Report-Msgid-Bugs-To: \n" | ||
448 | 9 | "POT-Creation-Date: 2014-05-07 09:57+0000\n" | ||
449 | 10 | "PO-Revision-Date: 2014-05-07 09:57+0000\n" | ||
450 | 11 | "Last-Translator: <>\n" | ||
451 | 12 | "Language-Team: \n" | ||
452 | 13 | "MIME-Version: 1.0\n" | ||
453 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
454 | 15 | "Content-Transfer-Encoding: \n" | ||
455 | 16 | "Plural-Forms: \n" | ||
456 | 17 | |||
457 | 18 | #: model:ir.model,name:magentoerpconnect_options_active_delisted.model_product_product | ||
458 | 19 | #. module: magentoerpconnect_options_active_delisted | ||
459 | 20 | msgid "Product" | ||
460 | 21 | msgstr "Produkt" | ||
461 | 22 | |||
462 | 23 | #: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magento_backend | ||
463 | 24 | #. module: magentoerpconnect_options_active_delisted | ||
464 | 25 | msgid "Magento Backend" | ||
465 | 26 | msgstr "" | ||
466 | 27 | |||
467 | 28 | #: field:product.product,delisted:0 | ||
468 | 29 | #. module: magentoerpconnect_options_active_delisted | ||
469 | 30 | msgid "Product delisted" | ||
470 | 31 | msgstr "Produkt ausgelistet" | ||
471 | 32 | |||
472 | 33 | #: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magentoerpconnect_options_active_delisted_installed | ||
473 | 34 | #. module: magentoerpconnect_options_active_delisted | ||
474 | 35 | msgid "magentoerpconnect_options_active_delisted.installed" | ||
475 | 36 | msgstr "" | ||
476 | 37 | |||
477 | 0 | 38 | ||
478 | === added file 'magentoerpconnect_options_active_delisted/i18n/magentoerpconnect_options_active_delisted.pot' | |||
479 | --- magentoerpconnect_options_active_delisted/i18n/magentoerpconnect_options_active_delisted.pot 1970-01-01 00:00:00 +0000 | |||
480 | +++ magentoerpconnect_options_active_delisted/i18n/magentoerpconnect_options_active_delisted.pot 2014-05-07 10:04:05 +0000 | |||
481 | @@ -0,0 +1,37 @@ | |||
482 | 1 | # Translation of OpenERP Server. | ||
483 | 2 | # This file contains the translation of the following modules: | ||
484 | 3 | # * magentoerpconnect_options_active_delisted | ||
485 | 4 | # | ||
486 | 5 | msgid "" | ||
487 | 6 | msgstr "" | ||
488 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | ||
489 | 8 | "Report-Msgid-Bugs-To: \n" | ||
490 | 9 | "POT-Creation-Date: 2014-05-07 09:57+0000\n" | ||
491 | 10 | "PO-Revision-Date: 2014-05-07 09:57+0000\n" | ||
492 | 11 | "Last-Translator: <>\n" | ||
493 | 12 | "Language-Team: \n" | ||
494 | 13 | "MIME-Version: 1.0\n" | ||
495 | 14 | "Content-Type: text/plain; charset=UTF-8\n" | ||
496 | 15 | "Content-Transfer-Encoding: \n" | ||
497 | 16 | "Plural-Forms: \n" | ||
498 | 17 | |||
499 | 18 | #. module: magentoerpconnect_options_active_delisted | ||
500 | 19 | #: model:ir.model,name:magentoerpconnect_options_active_delisted.model_product_product | ||
501 | 20 | msgid "Product" | ||
502 | 21 | msgstr "" | ||
503 | 22 | |||
504 | 23 | #. module: magentoerpconnect_options_active_delisted | ||
505 | 24 | #: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magento_backend | ||
506 | 25 | msgid "Magento Backend" | ||
507 | 26 | msgstr "" | ||
508 | 27 | |||
509 | 28 | #. module: magentoerpconnect_options_active_delisted | ||
510 | 29 | #: field:product.product,delisted:0 | ||
511 | 30 | msgid "Product delisted" | ||
512 | 31 | msgstr "" | ||
513 | 32 | |||
514 | 33 | #. module: magentoerpconnect_options_active_delisted | ||
515 | 34 | #: model:ir.model,name:magentoerpconnect_options_active_delisted.model_magentoerpconnect_options_active_delisted_installed | ||
516 | 35 | msgid "magentoerpconnect_options_active_delisted.installed" | ||
517 | 36 | msgstr "" | ||
518 | 37 | |||
519 | 0 | 38 | ||
520 | === added file 'magentoerpconnect_options_active_delisted/magento_model.py' | |||
521 | --- magentoerpconnect_options_active_delisted/magento_model.py 1970-01-01 00:00:00 +0000 | |||
522 | +++ magentoerpconnect_options_active_delisted/magento_model.py 2014-05-07 10:04:05 +0000 | |||
523 | @@ -0,0 +1,41 @@ | |||
524 | 1 | # -*- coding: utf-8 -*- | ||
525 | 2 | ############################################################################## | ||
526 | 3 | # | ||
527 | 4 | # Author: Markus Schneider | ||
528 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
529 | 6 | # | ||
530 | 7 | # This program is free software: you can redistribute it and/or modify | ||
531 | 8 | # it under the terms of the GNU Affero General Public License as | ||
532 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
533 | 10 | # License, or (at your option) any later version. | ||
534 | 11 | # | ||
535 | 12 | # This program is distributed in the hope that it will be useful, | ||
536 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
537 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
538 | 15 | # GNU Affero General Public License for more details. | ||
539 | 16 | # | ||
540 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
541 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
542 | 19 | # | ||
543 | 20 | ############################################################################## | ||
544 | 21 | |||
545 | 22 | from openerp.osv import fields, orm | ||
546 | 23 | |||
547 | 24 | |||
548 | 25 | class magento_backend(orm.Model): | ||
549 | 26 | |||
550 | 27 | _name = 'magento.backend' | ||
551 | 28 | _inherit = 'magento.backend' | ||
552 | 29 | |||
553 | 30 | def _select_product_active(self, cr, uid, context=None): | ||
554 | 31 | product_active_options = super(magento_backend, self)\ | ||
555 | 32 | ._select_product_active(cr, uid, context=context) | ||
556 | 33 | product_active_options.append(('delisted', 'mark as delisted')) | ||
557 | 34 | return product_active_options | ||
558 | 35 | |||
559 | 36 | _columns = { | ||
560 | 37 | 'product_active': fields.selection( | ||
561 | 38 | _select_product_active, | ||
562 | 39 | string='Handle disable products', | ||
563 | 40 | required=True), | ||
564 | 41 | } | ||
565 | 0 | 42 | ||
566 | === added file 'magentoerpconnect_options_active_delisted/product.py' | |||
567 | --- magentoerpconnect_options_active_delisted/product.py 1970-01-01 00:00:00 +0000 | |||
568 | +++ magentoerpconnect_options_active_delisted/product.py 2014-05-07 10:04:05 +0000 | |||
569 | @@ -0,0 +1,47 @@ | |||
570 | 1 | # -*- coding: utf-8 -*- | ||
571 | 2 | ############################################################################## | ||
572 | 3 | # | ||
573 | 4 | # Author: Markus Schneider | ||
574 | 5 | # Copyright 2014 initOS GmbH & Co. KG | ||
575 | 6 | # | ||
576 | 7 | # This program is free software: you can redistribute it and/or modify | ||
577 | 8 | # it under the terms of the GNU Affero General Public License as | ||
578 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
579 | 10 | # License, or (at your option) any later version. | ||
580 | 11 | # | ||
581 | 12 | # This program is distributed in the hope that it will be useful, | ||
582 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
583 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
584 | 15 | # GNU Affero General Public License for more details. | ||
585 | 16 | # | ||
586 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
587 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
588 | 19 | # | ||
589 | 20 | ############################################################################## | ||
590 | 21 | |||
591 | 22 | from openerp.osv import fields, orm | ||
592 | 23 | from openerp.addons.connector.unit.mapper import mapping | ||
593 | 24 | from openerp.addons.magentoerpconnect.backend import magento | ||
594 | 25 | from openerp.addons.magentoerpconnect_options_active import product | ||
595 | 26 | |||
596 | 27 | |||
597 | 28 | class product_product(orm.Model): | ||
598 | 29 | _name = 'product.product' | ||
599 | 30 | _inherit = 'product.product' | ||
600 | 31 | _columns = {'delisted': fields.boolean('Product delisted')} | ||
601 | 32 | |||
602 | 33 | |||
603 | 34 | @magento(replacing=product.OptionsIsActiveProductImportMapper) | ||
604 | 35 | class AdvProductImportMapper(product.OptionsIsActiveProductImportMapper): | ||
605 | 36 | _model_name = 'magento.product.product' | ||
606 | 37 | |||
607 | 38 | @mapping | ||
608 | 39 | def is_active(self, record): | ||
609 | 40 | """Check if the product is active in Magento | ||
610 | 41 | and change acording the options""" | ||
611 | 42 | is_active = (record.get('status') == '1') | ||
612 | 43 | |||
613 | 44 | if self.backend_record.product_active == 'delisted': | ||
614 | 45 | return {'delisted': not is_active} | ||
615 | 46 | |||
616 | 47 | return super(AdvProductImportMapper, self).is_active(record) | ||
617 | 0 | 48 | ||
618 | === added file 'magentoerpconnect_options_active_delisted/product_view.xml' | |||
619 | --- magentoerpconnect_options_active_delisted/product_view.xml 1970-01-01 00:00:00 +0000 | |||
620 | +++ magentoerpconnect_options_active_delisted/product_view.xml 2014-05-07 10:04:05 +0000 | |||
621 | @@ -0,0 +1,18 @@ | |||
622 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
623 | 2 | <openerp> | ||
624 | 3 | <data> | ||
625 | 4 | |||
626 | 5 | <record id="product_product_form_delisted" model="ir.ui.view"> | ||
627 | 6 | <field name="name">product.product.form.delisted</field> | ||
628 | 7 | <field name="model">product.product</field> | ||
629 | 8 | <field name="inherit_id" ref="product.product_normal_form_view" /> | ||
630 | 9 | <field name="arch" type="xml"> | ||
631 | 10 | <xpath expr="//label[@for='sale_ok']" position="after"> | ||
632 | 11 | <field name="delisted" /> | ||
633 | 12 | <label for="delisted"/> | ||
634 | 13 | </xpath> | ||
635 | 14 | </field> | ||
636 | 15 | </record> | ||
637 | 16 | |||
638 | 17 | </data> | ||
639 | 18 | </openerp> | ||
640 | 0 | \ No newline at end of file | 19 | \ No newline at end of file |
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. ProductImportMa pper, 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)