Merge lp:~isaac.delabarrera/prestashoperpconnect/update_product_category into lp:prestashoperpconnect/6.1

Proposed by Isaac De la Barrera on 2012-07-09
Status: Rejected
Rejected by: Sébastien BEAU - http://www.akretion.com on 2014-10-07
Proposed branch: lp:~isaac.delabarrera/prestashoperpconnect/update_product_category
Merge into: lp:prestashoperpconnect/6.1
Diff against target: 140 lines (+50/-21)
5 files modified
prestashoperpconnect/__openerp__.py (+1/-1)
prestashoperpconnect/prestashop_osv.py (+11/-6)
prestashoperpconnect/sale.py (+1/-0)
prestashoperpconnect/settings/1.4.0.0/product.category/external.mappinglines.template.csv (+17/-5)
prestashoperpconnect/settings/1.4.0.0/product.product/external.mappinglines.template.csv (+20/-9)
To merge this branch: bzr merge lp:~isaac.delabarrera/prestashoperpconnect/update_product_category
Reviewer Review Type Date Requested Status
Sébastien BEAU - http://www.akretion.com 2012-07-09 Disapprove on 2014-10-07
Review via email: mp+113982@code.launchpad.net

Description of the change

Updated product.category.csv external mappings lines.

Update functions in external_osv, ext_create() and ext_update().

Modifiy value 'en_US' in transform_one_resource_to_prestashop_vals() by language.

To post a comment you must log in.

Hi Issac I test to merge your work but there is something wrong with the mapping.
Installation is broken :

2012-07-19 17:14:56,333 29059 ERROR prestashop_back openerp.netsvc: No such external ID currently defined in the system: gst_prestashop.field_product_category_level

Can you fix it and propose a new merge?

Also I will not test the change done for 1.4 version (just testing the installation). Indeed I didn't have the time :( and so I prefer to focus my work on 1.5 version.
But don't worry merge and fix are welcome ;)

Thanks for helping us

See you

53. By Isaac De la Barrera on 2012-07-23

Commit

54. By Isaac De la Barrera on 2012-07-23

Update product and category product mapping templates

55. By Isaac De la Barrera on 2012-07-23

Set associations categories in product

56. By Isaac De la Barrera on 2012-07-23

remove unnecesary fields

Ok,

I keep on working on 1.4 PS.
I propose a new branch merge,

Thank you,

2012/7/19 Sébastien BEAU - http://www.akretion.com <
<email address hidden>>

> Hi Issac I test to merge your work but there is something wrong with the
> mapping.
> Installation is broken :
>
> 2012-07-19 17:14:56,333 29059 ERROR prestashop_back openerp.netsvc: No
> such external ID currently defined in the system:
> gst_prestashop.field_product_category_level
>
> Can you fix it and propose a new merge?
>
> Also I will not test the change done for 1.4 version (just testing the
> installation). Indeed I didn't have the time :( and so I prefer to focus my
> work on 1.5 version.
> But don't worry merge and fix are welcome ;)
>
> Thanks for helping us
>
> See you
> --
>
> https://code.launchpad.net/~isaac.delabarrera/prestashoperpconnect/update_product_category/+merge/113982<https://code.launchpad.net/%7Eisaac.delabarrera/prestashoperpconnect/update_product_category/+merge/113982>
> You are the owner of
> lp:~isaac.delabarrera/prestashoperpconnect/update_product_category.
>

--
King Regards
Isaac De la Barrera,

The project has moved to Github https://github.com/OCA/connector-prestashop.
Please resubmit your MP on github using following procedure https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub.

I put this MP in rejected in the meanwhile.

Regards

review: Disapprove

Unmerged revisions

56. By Isaac De la Barrera on 2012-07-23

remove unnecesary fields

55. By Isaac De la Barrera on 2012-07-23

Set associations categories in product

54. By Isaac De la Barrera on 2012-07-23

Update product and category product mapping templates

53. By Isaac De la Barrera on 2012-07-23

Commit

52. By Isaac De la Barrera on 2012-07-09

Product Category Mapping Lines. ext_create() and ext_update() functiosn modified

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'prestashoperpconnect/__openerp__.py'
--- prestashoperpconnect/__openerp__.py 2012-07-06 07:49:07 +0000
+++ prestashoperpconnect/__openerp__.py 2012-07-23 16:40:26 +0000
@@ -29,7 +29,7 @@
29 "product",29 "product",
30# "product_m2mcategories",30# "product_m2mcategories",
31 "base_sale_multichannels",31 "base_sale_multichannels",
32# "product_images_olbs",32 "product_images_olbs",
33 ],33 ],
34 "author" : "PrestashopERPconnect Core Editors",34 "author" : "PrestashopERPconnect Core Editors",
35 "description": """This module connects OpenERP and Prestashop.35 "description": """This module connects OpenERP and Prestashop.
3636
=== modified file 'prestashoperpconnect/prestashop_osv.py'
--- prestashoperpconnect/prestashop_osv.py 2012-04-20 10:35:19 +0000
+++ prestashoperpconnect/prestashop_osv.py 2012-07-23 16:40:26 +0000
@@ -111,7 +111,10 @@
111 resource_data[key] = {}111 resource_data[key] = {}
112 if method == 'edit':112 if method == 'edit':
113 external_id = external_data[key]['id']113 external_id = external_data[key]['id']
114 language = 'es_ES'
114 for data_value in external_data[key]:115 for data_value in external_data[key]:
116 if data_value == 'link_rewrite':
117 r = 0
115 if isinstance(external_data[key][data_value],dict):118 if isinstance(external_data[key][data_value],dict):
116 if 'language' in external_data[key][data_value]:119 if 'language' in external_data[key][data_value]:
117 resource_data[key][data_value] = {}120 resource_data[key][data_value] = {}
@@ -130,13 +133,15 @@
130 lang = lang_obj.read(cr, uid, oe_lang_id, ['code'], context=context)133 lang = lang_obj.read(cr, uid, oe_lang_id, ['code'], context=context)
131 if lang['code'] in resource:134 if lang['code'] in resource:
132 vals['value'] = resource[lang['code']].get(data_value,False) or ''135 vals['value'] = resource[lang['code']].get(data_value,False) or ''
133 if not vals['value'] and 'en_US' in resource and data_value in resource['en_US']:136 if not vals['value'] and language in resource and data_value in resource[language]:
134 vals['value'] = resource['en_US'].get(data_value,False) or ''137 vals['value'] = resource[language].get(data_value,False) or ''
135 new_lang_vals.append(vals)138 new_lang_vals.append(vals)
136 resource_data[key][data_value]['language'] = new_lang_vals139 resource_data[key][data_value]['language'] = new_lang_vals
140 elif data_value == 'associations' and (data_value in resource[language]):
141 resource_data[key][data_value] = resource[language][data_value]
137 else:142 else:
138 if data_value in resource['en_US']:143 if data_value in resource[language]:
139 resource_data[key][data_value] = str(resource['en_US'][data_value])144 resource_data[key][data_value] = str(resource[language][data_value])
140 else:145 else:
141 resource_data[key][data_value] = ''146 resource_data[key][data_value] = ''
142 if method == 'edit':147 if method == 'edit':
@@ -144,7 +149,7 @@
144 return resource_data149 return resource_data
145 150
146 @only_for_referential('prestashop')151 @only_for_referential('prestashop')
147 def ext_create(self, cr, uid, external_session, resources, context=None):152 def ext_create(self, cr, uid, external_session, resources, mapping, mapping_id, context=None):
148 search_vals = [('model', '=', self._name), ('referential_id', '=', external_session.referential_id.id)]153 search_vals = [('model', '=', self._name), ('referential_id', '=', external_session.referential_id.id)]
149 mapping_ids = self.pool.get('external.mapping').search(cr, uid, search_vals, context=context)154 mapping_ids = self.pool.get('external.mapping').search(cr, uid, search_vals, context=context)
150 mapping = {mapping_ids[0] : self._get_mapping(cr, uid, external_session.referential_id.id, context=context)}155 mapping = {mapping_ids[0] : self._get_mapping(cr, uid, external_session.referential_id.id, context=context)}
@@ -167,7 +172,7 @@
167 return external_ids172 return external_ids
168 173
169 @only_for_referential('prestashop')174 @only_for_referential('prestashop')
170 def ext_update(self, cr, uid, external_session, resources, context=None):175 def ext_update(self, cr, uid, external_session, resources, mapping, mapping_id, context=None):
171 search_vals = [('model', '=', self._name), ('referential_id', '=', external_session.referential_id.id)]176 search_vals = [('model', '=', self._name), ('referential_id', '=', external_session.referential_id.id)]
172 mapping_ids = self.pool.get('external.mapping').search(cr, uid, search_vals, context=context)177 mapping_ids = self.pool.get('external.mapping').search(cr, uid, search_vals, context=context)
173 mapping = {mapping_ids[0] : self._get_mapping(cr, uid, external_session.referential_id.id, context=context)}178 mapping = {mapping_ids[0] : self._get_mapping(cr, uid, external_session.referential_id.id, context=context)}
174179
=== modified file 'prestashoperpconnect/sale.py'
--- prestashoperpconnect/sale.py 2012-04-20 10:35:19 +0000
+++ prestashoperpconnect/sale.py 2012-07-23 16:40:26 +0000
@@ -82,6 +82,7 @@
82 context['lang_to_export'] = self.get_shop_lang_to_export(cr, uid, ids, context=context)82 context['lang_to_export'] = self.get_shop_lang_to_export(cr, uid, ids, context=context)
83 self.export_resources(cr, uid, ids, 'product.category', context=context)83 self.export_resources(cr, uid, ids, 'product.category', context=context)
84 self.export_resources(cr, uid, ids, 'product.template', context=context)84 self.export_resources(cr, uid, ids, 'product.template', context=context)
85 self.export_resources(cr, uid, ids, 'product.images', context=context)
85 #TODO update the last date86 #TODO update the last date
86 #I don't know where it's thebest to update it ere or in the epxot functions87 #I don't know where it's thebest to update it ere or in the epxot functions
87 #take care about concurent write with diferent cursor88 #take care about concurent write with diferent cursor
8889
=== modified file 'prestashoperpconnect/settings/1.4.0.0/product.category/external.mappinglines.template.csv'
--- prestashoperpconnect/settings/1.4.0.0/product.category/external.mappinglines.template.csv 2012-04-10 14:58:33 +0000
+++ prestashoperpconnect/settings/1.4.0.0/product.category/external.mappinglines.template.csv 2012-07-23 16:40:26 +0000
@@ -1,7 +1,19 @@
1"id","mapping_id:id","external_field","field_id:id","type","evaluation_type","external_type","child_mapping_id:id","alternative_key","in_function","out_function"1id,sequence,type,evaluation_type,external_field,field_id:id,external_type,alternative_key,mapping_id:id,function_name,in_function,out_function,child_mapping_id:id,datetime_format
2"prestashoperpconnect.prestashop_1400_product_category_position","prestashoperpconnect.prestashop_1400_product_categ","position","product.field_product_category_sequence","in_out","direct","int",,"False",,2prestashoperpconnect.prestashop_1400_product_category_parent_id,0,in_out,function,id_parent,product.field_product_category_parent_id,int,False,prestashoperpconnect.prestashop_1400_product_categ,id_parent,"if resource.get('id_parent') and resource.get('id_parent') != '0':
3"prestashoperpconnect.prestashop_1400_product_category_name","prestashoperpconnect.prestashop_1400_product_categ","name","product.field_product_category_name","in_out","function","unicode",,"False","if ifield:3 parent_id = self.extid_to_oeid(cr,uid, external_session, int(resource.get('id_parent')))
4 result = [('parent_id', parent_id)]
5else:
6 result = [('parent_id', None)]","if resource.get('parent_id'):
7 parent_id = self.get_extid(cr, uid, data.get('parent_id')[0], external_session.referential_id.id, context=context)
8 result = [('id_parent', str(parent_id))]
9else:
10 result = [('id_parent', '')]",,
11prestashoperpconnect.prestashop1400_product_category_nright,0,in_out,direct,nright,product.field_product_category_parent_right,int,False,prestashoperpconnect.prestashop_1400_product_categ,,,,,
12prestashoperpconnect.prestashop1400_product_category_nleft,0,in_out,direct,nleft,product.field_product_category_parent_left,int,False,prestashoperpconnect.prestashop_1400_product_categ,,,,,
13prestashoperpconnect.prestashop_1400_product_category_position,0,in_out,direct,position,product.field_product_category_sequence,int,False,prestashoperpconnect.prestashop_1400_product_categ,,,,,
14prestashoperpconnect.prestashop_1400_product_category_name,0,in_out,direct,name,product.field_product_category_name,unicode,False,prestashoperpconnect.prestashop_1400_product_categ,,"if ifield:
4 result = [('name', ifield)]15 result = [('name', ifield)]
5else:16else:
6 result = [('name', 'No name')]",17 result = [('name', 'No name')]",,,
7"prestashoperpconnect.prestashop_1400_product_category_parent_id","prestashoperpconnect.prestashop_1400_product_categ","parent_id","product.field_product_category_parent_id","in_out","direct","int",,"False",,18prestashoperpconnect.prestashop1400_product_category_link_rewrite,0,out,function,link_rewrite,product.field_product_category_complete_name,unicode,False,prestashoperpconnect.prestashop_1400_product_categ,link_rewrite,,"result = [('link_rewrite', (resource.get('name').lower()).replace(' ', '_' ))]",,
19prestashoperpconnect.prestashop1400_product_category_active,0,in_out,function,active,,unicode,False,prestashoperpconnect.prestashop_1400_product_categ,active,"result=[('active',1)]","result=[('active',1)]",,
820
=== modified file 'prestashoperpconnect/settings/1.4.0.0/product.product/external.mappinglines.template.csv'
--- prestashoperpconnect/settings/1.4.0.0/product.product/external.mappinglines.template.csv 2012-04-10 13:31:53 +0000
+++ prestashoperpconnect/settings/1.4.0.0/product.product/external.mappinglines.template.csv 2012-07-23 16:40:26 +0000
@@ -1,9 +1,20 @@
1"id","mapping_id:id","external_field","field_id:id","type","evaluation_type","external_type","child_mapping_id:id","alternative_key","in_function","out_function"1id,sequence,type,evaluation_type,external_field,field_id:id,external_type,alternative_key,mapping_id:id,function_name,in_function,out_function,child_mapping_id:id,datetime_format
2"prestashoperpconnect.prestashop1400_erp_available_for_sale","prestashoperpconnect.prestashop_1400_product","available_for_sale","product.field_product_template_sale_ok","in_out","direct","bool",,"False",,2prestashoperpconnect.prestashop1400_erp_weight,0,in_out,direct,weight,product.field_product_template_weight,float,False,prestashoperpconnect.prestashop_1400_product,,,,,
3"prestashoperpconnect.prestashop1400_erp_weight","prestashoperpconnect.prestashop_1400_product","weight","product.field_product_template_weight","in_out","direct","float",,"False",,3prestashop1400_product_product_id_tax_rules_group,0,in_out,function,id_tax_rules_group,,unicode,False,prestashoperpconnect.prestashop_1400_product,id_tax_rules_group,,"result = [('id_tax_rules_group', 1)]",,
4"prestashoperpconnect.prestashop1400_product_product_ean13","prestashoperpconnect.prestashop_1400_product","ean13","product.field_product_product_ean13","in_out","direct","unicode",,"False",,4prestashop1400_product_product_quantity,0,in_out,direct,quantity,product.field_product_product_virtual_available,unicode,False,prestashoperpconnect.prestashop_1400_product,,,,,
5"prestashoperpconnect.prestashop1400_product_product_price","prestashoperpconnect.prestashop_1400_product","price","product.field_product_product_lst_price","in_out","direct","float",,"False",,5prestashop1400_product_product_name,0,in_out,direct,name,product.field_product_template_name,unicode,False,prestashoperpconnect.prestashop_1400_product,,,,,
6"prestashoperpconnect.prestashop1400_product_product_price","prestashoperpconnect.prestashop_1400_product","price","product.field_product_product_price","in_out","direct","unicode",,"False",,6prestashoperpconnect.prestashop1400_product_product_reference,0,in_out,direct,reference,product.field_product_product_variants,unicode,False,prestashoperpconnect.prestashop_1400_product,,,,,
7"prestashoperpconnect.prestashop1400_product_product_wholesale_price","prestashoperpconnect.prestashop_1400_product","wholesale_price","product.field_product_product_price_extra","in_out","direct","float",,"False",,7prestashop1400_product_product_quantity,0,in_out,direct,quantity,product.field_product_product_virtual_available,unicode,False,prestashoperpconnect.prestashop_1400_product,,,,,
8"prestashoperpconnect.prestashop1400_product_product_id_product","prestashoperpconnect.prestashop_1400_product","id_product","product.field_product_product_product_tmpl_id","in_out","direct","int","prestashoperpconnect.prestashop_1400_product_template","False",,8prestashop1400_product_product_active,0,in_out,function,,,unicode,False,prestashoperpconnect.prestashop_1400_product,active,,"result = [('active', '1')]",,
9"prestashoperpconnect.prestashop1400_product_product_reference","prestashoperpconnect.prestashop_1400_product","reference","product.field_product_product_variants","in_out","direct","unicode",,"False",,9prestashop1400_product_product_id_category_default,0,in_out,direct,id_category_default,product.field_product_template_categ_id,int,False,prestashoperpconnect.prestashop_1400_product,,,,,
10prestashop1400_product_product_available_for_order,0,out,function,,,unicode,False,prestashoperpconnect.prestashop_1400_product,available_for_order,,"result = [('available_for_order', '1')]",,
11prestashop1400_product_product_show_price,0,in_out,function,,,unicode,False,prestashoperpconnect.prestashop_1400_product,show_price,,"result = [('show_price', '1')]",,
12prestashop1400_product_product_on_sale,0,in_out,function,,,unicode,False,prestashoperpconnect.prestashop_1400_product,on_sale,,"result = [('on_sale', '1')]",,
13prestashop1400_product_product_link_rewrite,0,out,function,link_rewrite,product.field_product_template_name,unicode,False,prestashoperpconnect.prestashop_1400_product,link_rewrite,,"result = [('link_rewrite', 'hola')]",,
14prestashoperpconnect.prestashop1400_product_product_ean13,0,in_out,direct,ean13,product.field_product_product_ean13,unicode,False,prestashoperpconnect.prestashop_1400_product,,,,,
15prestashoperpconnect.prestashop1400_product_product_price,0,in_out,direct,price,product.field_product_product_price,unicode,False,prestashoperpconnect.prestashop_1400_product,,,,,
16prestashoperpconnect.prestashop1400_product_product_wholesale_price,0,in_out,direct,wholesale_price,product.field_product_product_price_extra,float,False,prestashoperpconnect.prestashop_1400_product,,,,,
17prestashoperpconnect.prestashop1400_product_product_id_product,0,in_out,direct,id_product,product.field_product_product_product_tmpl_id,int,False,prestashoperpconnect.prestashop_1400_product,,,,prestashoperpconnect.prestashop_1400_product_template,
18prestashoperpconnect.prestashop1400_erp_available_for_sale,0,in_out,direct,available_for_sale,product.field_product_template_sale_ok,bool,False,prestashoperpconnect.prestashop_1400_product,,,,,
19prestashop1400_product_product_associations,1,in_out,function,associations,,dict,False,prestashoperpconnect.prestashop_1400_product,associations,,"categ_id = self.pool.get('product.category').get_extid(cr, uid, data.get('categ_id')[0], external_session.referential_id.id, context=context)
20result = [('associations', {'categories': {'category':{'id': categ_id}}})]",,