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

Subscribers

People subscribed via source and target branches

to all changes: