Merge lp:~altegra/pepess/pepess_dev_carlos_magentopepess into lp:pepess

Status: Merged
Merged at revision: 76
Proposed branch: lp:~altegra/pepess/pepess_dev_carlos_magentopepess
Merge into: lp:pepess
Diff against target: 259 lines (+244/-0)
3 files modified
magento_bridge_pepess/__init__.py (+32/-0)
magento_bridge_pepess/__openerp__.py (+51/-0)
magento_bridge_pepess/magento_bridge.py (+161/-0)
To merge this branch: bzr merge lp:~altegra/pepess/pepess_dev_carlos_magentopepess
Reviewer Review Type Date Requested Status
Eric Hernández - http://www.grupoaltegra.com Approve
Review via email: mp+240794@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Eric Hernández - http://www.grupoaltegra.com (daimon) wrote :

Good job, keep going !!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'magento_bridge_pepess'
2=== added file 'magento_bridge_pepess/__init__.py'
3--- magento_bridge_pepess/__init__.py 1970-01-01 00:00:00 +0000
4+++ magento_bridge_pepess/__init__.py 2014-11-05 23:08:04 +0000
5@@ -0,0 +1,32 @@
6+#!/usr/bin/env python
7+#-*- coding:utf-8 -*-
8+
9+#############################################################################
10+# Module Writen to OpenERP, Open Source Management Solution
11+# CopyLeft 2012 - http://www.grupoaltegra.com
12+# You are free to share, copy, distribute, transmit, adapt and use for commercial purpose
13+# More information about license: http://www.gnu.org/licenses/agpl.html
14+# info Grupo Altegra (openerp@grupoaltegra.com)
15+#
16+#############################################################################
17+#
18+# Coded by: Carlos Blanco (carlos.blanco@grupoaltegra.com)
19+#
20+#############################################################################
21+#
22+# This program is free software: you can redistribute it and/or modify
23+# it under the terms of the GNU Affero General Public License as
24+# published by the Free Software Foundation, either version 3 of the
25+# License, or (at your option) any later version.
26+#
27+# This program is distributed in the hope that it will be useful,
28+# but WITHOUT ANY WARRANTY; without even the implied warranty of
29+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+# GNU Affero General Public License for more details.
31+#
32+# You should have received a copy of the GNU Affero General Public License
33+# along with this program. If not, see <http://www.gnu.org/licenses/>.
34+#
35+#############################################################################
36+
37+import magento_bridge
38
39=== added file 'magento_bridge_pepess/__openerp__.py'
40--- magento_bridge_pepess/__openerp__.py 1970-01-01 00:00:00 +0000
41+++ magento_bridge_pepess/__openerp__.py 2014-11-05 23:08:04 +0000
42@@ -0,0 +1,51 @@
43+#!/usr/bin/env python
44+#-*- coding:utf-8 -*-
45+
46+#############################################################################
47+# Module Writen to OpenERP, Open Source Management Solution
48+# CopyLeft 2012 - http://www.grupoaltegra.com
49+# You are free to share, copy, distribute, transmit, adapt and use for commercial purpose
50+# More information about license: http://www.gnu.org/licenses/agpl.html
51+# info Grupo Altegra (openerp@grupoaltegra.com)
52+#
53+#############################################################################
54+#
55+# Coded by: Carlos Blanco (carlos.blanco@grupoaltegra.com)
56+#
57+#############################################################################
58+#
59+# This program is free software: you can redistribute it and/or modify
60+# it under the terms of the GNU Affero General Public License as
61+# published by the Free Software Foundation, either version 3 of the
62+# License, or (at your option) any later version.
63+#
64+# This program is distributed in the hope that it will be useful,
65+# but WITHOUT ANY WARRANTY; without even the implied warranty of
66+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67+# GNU Affero General Public License for more details.
68+#
69+# You should have received a copy of the GNU Affero General Public License
70+# along with this program. If not, see <http://www.gnu.org/licenses/>.
71+#
72+#############################################################################
73+
74+{
75+ "name" : 'Magento custom for Pepess ',
76+ "version" : '0.1',
77+ "author" : 'Grupo Altegra',
78+ "category" : 'Custom Modules',
79+ "website" : "http://www.grupoaltegra.com",
80+ "description" : """ The basic fields are sent Pepess ERP """,
81+ "init_xml" : [],
82+ "depends" : ['base','magento_bridge'],
83+ "update_xml" : [
84+
85+ ],
86+ "demo_xml" : [
87+ ],
88+ "test" : [
89+ ],
90+ "installable" : True,
91+ "images": [],
92+ "auto_install" : False,
93+}
94
95=== added file 'magento_bridge_pepess/magento_bridge.py'
96--- magento_bridge_pepess/magento_bridge.py 1970-01-01 00:00:00 +0000
97+++ magento_bridge_pepess/magento_bridge.py 2014-11-05 23:08:04 +0000
98@@ -0,0 +1,161 @@
99+#!/usr/bin/env python
100+#-*- coding:utf-8 -*-
101+
102+#############################################################################
103+# Module Writen to OpenERP, Open Source Management Solution
104+# CopyLeft 2012 - http://www.grupoaltegra.com
105+# You are free to share, copy, distribute, transmit, adapt and use for commercial purpose
106+# More information about license: http://www.gnu.org/licenses/agpl.html
107+# info Grupo Altegra (openerp@grupoaltegra.com)
108+#
109+#############################################################################
110+#
111+# Coded by: Carlos Blanco (carlos.blanco@grupoaltegra.com)
112+#
113+#############################################################################
114+#
115+# This program is free software: you can redistribute it and/or modify
116+# it under the terms of the GNU Affero General Public License as
117+# published by the Free Software Foundation, either version 3 of the
118+# License, or (at your option) any later version.
119+#
120+# This program is distributed in the hope that it will be useful,
121+# but WITHOUT ANY WARRANTY; without even the implied warranty of
122+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
123+# GNU Affero General Public License for more details.
124+#
125+# You should have received a copy of the GNU Affero General Public License
126+# along with this program. If not, see <http://www.gnu.org/licenses/>.
127+#
128+#############################################################################
129+
130+from osv import osv, fields
131+import xmlrpclib
132+
133+class product_sync(osv.osv_memory):
134+
135+ _inherit="product.sync"
136+
137+ #############################################
138+ ## update all products ##
139+ #############################################
140+ def update_products(self,cr,uid,ids,context=None):
141+ count = pro = 0
142+ text = text1 = ''
143+ error_ids = []
144+ get_product_data = {}
145+ connection = self.pool.get('magento.configure')._create_connection(cr,uid)
146+ if connection:
147+ url = connection[0]
148+ session = connection[1]
149+ server = xmlrpclib.Server(url)
150+ map_id = self.pool.get('magento.product').search(cr,uid,[('need_sync','=','Yes')])
151+ pro_ids = self.pool.get('product.product').search(cr,uid,[])
152+ if not map_id or not pro_ids:
153+ raise osv.except_osv(_('Information'), _("No product(s) has been found to be Update on Magento!!!"))
154+ if map_id:
155+ for i in map_id:
156+ pro_obj = self.pool.get('magento.product').browse(cr,uid,i)
157+ pro_id = pro_obj.oe_product_id
158+ mage_id = pro_obj.mag_product_id
159+ if pro_id in pro_ids and mage_id:
160+ prod_catg = 2
161+ quantity = 0
162+ stock = 0
163+ obj_pro = self.pool.get('product.product').browse(cr,uid,pro_id)
164+ if obj_pro.categ_id.id:
165+ prod_catg = self.pool.get('category.sync').sync_categories(cr, uid, url, session, obj_pro.categ_id.id)
166+ get_product_data['name'] = obj_pro.name
167+ get_product_data['price'] = obj_pro.list_price or 0.00
168+ get_product_data['weight'] = obj_pro.weight_net or 0.00
169+ get_product_data['categories'] = [prod_catg]
170+
171+ ##################
172+ # Campos Pepess #
173+ ##################
174+ get_product_data['linea'] = obj_pro.line_id and obj_pro.line_id.name or ''
175+ get_product_data['tipo'] = obj_pro.kind_id and obj_pro.kind_id.name or ''
176+ get_product_data['tarca'] = obj_pro.brand_id and obj_pro.brand_id.name or ''
177+
178+ update_data = [mage_id, get_product_data]
179+ try:
180+ pro = server.call(session, 'product.update', update_data)
181+ self.pool.get('magento.product').write(cr, uid, i, {'need_sync':'No'})
182+ count = count + 1
183+ except xmlrpclib.Fault, e:
184+ error_ids.append(pro_id)
185+ if pro and obj_pro.qty_available>0:
186+ quantity = obj_pro.qty_available
187+ stock = 1
188+ server.call(session, 'product_stock.update', [mage_id, {'manage_stock':1, 'qty':quantity,'is_in_stock':stock}])
189+ if count:
190+ text = '%s Product has been sucessfully updated to Magento. \n'%count
191+ self.pool.get('magento.sync.history').create(cr,uid,{'status':'yes','action_on':'product','action':'c','error_message':text})
192+ if error_ids:
193+ text1 = 'The Listed Product ids %s does not updated on magento.'%error_ids
194+ self.pool.get('magento.sync.history').create(cr,uid,{'status':'no','action_on':'product','action':'c','error_message':text1})
195+ text2 = text+text1
196+ if not text2:
197+ raise osv.except_osv(_('Information'), _("No product(s) has been found to be Update on Magento!!!"))
198+ partial = self.pool.get('message.wizard').create(cr, uid, {'text':text2})
199+ return { 'name':_("Information"),
200+ 'view_mode': 'form',
201+ 'view_id': False,
202+ 'view_type': 'form',
203+ 'res_model': 'message.wizard',
204+ 'res_id': partial,
205+ 'type': 'ir.actions.act_window',
206+ 'nodestroy': True,
207+ 'target': 'new',
208+ 'domain': '[]',
209+ }
210+
211+
212+ #############################################
213+ ## Specific product sync ##
214+ #############################################
215+ def _export_specific_product(self, cr, uid, id, url, session,context=None):
216+
217+ """
218+ @param code: product Id.
219+ @param context: A standard dictionary
220+ @return: list
221+ """
222+ prod_catg = False
223+ get_product_data = {}
224+ server = xmlrpclib.Server(url)
225+ if id:
226+ obj_pro = self.pool.get('product.product').browse(cr,uid,id)
227+ if obj_pro.categ_id.id:
228+ prod_catg = self.pool.get('category.sync').sync_categories(cr, uid, url, session, obj_pro.categ_id.id)
229+ sku = obj_pro.default_code or 'Ref %s'%id
230+ get_product_data['name'] = obj_pro.name
231+ get_product_data['short_description'] = obj_pro.description_sale or 'None'
232+ get_product_data['description'] = obj_pro.description or 'None'
233+ get_product_data['price'] = obj_pro.list_price or 0.00
234+ get_product_data['weight'] = obj_pro.weight_net or 0.00
235+ get_product_data['categories'] = [prod_catg]
236+ get_product_data['websites'] = [1]
237+ get_product_data['status'] = 1
238+ get_product_data['tax_class_id'] = 0
239+
240+ ##################
241+ # Campos Pepess #
242+ ##################
243+ get_product_data['linea'] = obj_pro.line_id and obj_pro.line_id.name or ''
244+ get_product_data['tipo'] = obj_pro.kind_id and obj_pro.kind_id.name or ''
245+ get_product_data['marca'] = obj_pro.brand_id and obj_pro.brand_id.name or ''
246+
247+ if obj_pro.type in ['product','consu']:
248+ prodtype = 'simple'
249+ else:
250+ prodtype = 'virtual'
251+ pro = self.prodcreate(cr,uid,url,session,id,prodtype,sku,get_product_data)
252+ if pro[0] != 0:
253+ if obj_pro.image:
254+ file = {'content':obj_pro.image,'mime':'image/jpeg'}
255+ type = ['image','small_image','thumbnail']
256+ pic = {'file':file,'label':'Label', 'position':'100','types':type, 'exclude':1}
257+ image = [pro[1],pic]
258+ k = server.call(session,'catalog_product_attribute_media.create',image)
259+ return pro

Subscribers

People subscribed via source and target branches

to all changes: