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