Merge lp:~magentoerpconnect-core-editors/magentoerpconnect/trunk-fix-876312 into lp:~magentoerpconnect-core-editors/magentoerpconnect/oerp7.0-refactor
- trunk-fix-876312
- Merge into oerp7.0-refactor
Status: | Superseded |
---|---|
Proposed branch: | lp:~magentoerpconnect-core-editors/magentoerpconnect/trunk-fix-876312 |
Merge into: | lp:~magentoerpconnect-core-editors/magentoerpconnect/oerp7.0-refactor |
Diff against target: |
4695 lines (+3433/-115) (has conflicts) 27 files modified
magento_sku_is_code/product.py (+29/-10) magentoerpconnect/__openerp__.py (+16/-1) magentoerpconnect/board_view.xml (+30/-0) magentoerpconnect/magerp_core.py (+28/-12) magentoerpconnect/magerp_menu.xml (+3/-27) magentoerpconnect/magerp_osv.py (+129/-20) magentoerpconnect/partner.py (+252/-0) magentoerpconnect/partner_view.xml (+38/-0) magentoerpconnect/product.py (+752/-19) magentoerpconnect/product_images.py (+54/-5) magentoerpconnect/sale.py (+594/-0) magentoerpconnect/sale_view.xml (+19/-0) magentoerpconnect/settings/1.3.2.4/external.mapping.template.csv (+1/-1) magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv (+244/-20) magentoerpconnect/settings/1.4.0.0/external.mapping.template.csv (+14/-0) magentoerpconnect/settings/1.4.0.0/external.mappinglines.template.csv (+321/-0) magentoerpconnect/settings/1.4.0.0/external.referential.type.csv (+2/-0) magentoerpconnect/settings/1.4.2.0/external.mapping.template.csv (+14/-0) magentoerpconnect/settings/1.4.2.0/external.mappinglines.template.csv (+318/-0) magentoerpconnect/settings/1.4.2.0/external.referential.type.csv (+2/-0) magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv (+17/-0) magentoerpconnect/settings/1.5.0.0/external.mappinglines.template.csv.OTHER (+330/-0) magentoerpconnect/settings/update/fix_product_categories.sql (+7/-0) magentoerpconnect/settings/update/magerp.product_category_attribute_options.xml (+16/-0) magentoerpconnect/stock.py (+19/-0) magentoerpconnect_payment/sale.py (+95/-0) magentoerpconnect_product_variant/product.py (+89/-0) Text conflict in magentoerpconnect/__openerp__.py Text conflict in magentoerpconnect/magerp_core.py Text conflict in magentoerpconnect/magerp_osv.py Text conflict in magentoerpconnect/partner.py Text conflict in magentoerpconnect/partner_view.xml Text conflict in magentoerpconnect/product.py Text conflict in magentoerpconnect/product_images.py Text conflict in magentoerpconnect/sale.py Text conflict in magentoerpconnect/sale_view.xml Text conflict in magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv Text conflict in magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv Contents conflict in magentoerpconnect/settings/1.5.0.0/external.mappinglines.template.csv Text conflict in magentoerpconnect/stock.py Text conflict in magentoerpconnect_product_variant/product.py |
To merge this branch: | bzr merge lp:~magentoerpconnect-core-editors/magentoerpconnect/trunk-fix-876312 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Pending | ||
Review via email: mp+113748@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-07-06.
Commit message
Description of the change
Work around magento bug wrt product categories. Closes https:/
Unmerged revisions
- 647. By Alexandre Fayolle @ camptocamp <email address hidden>
-
[FIX] magentoerpconnect: fix export product.category issues
* the product.category meta_title has a max length of 255 char on magento
* add mappings for Magento 1.4.0.0 and 1.4.2.0, for the product.category available_sort_by bug (lp:876312)
* duplicate the option used for default value with an empty string and fix mappings (>> 1.4)I did not simply change the value of the option as there might be a chance that
the 'None' trick works with Magento 1.3.x (and I don't have such an instance to
run a test on it)In the mappings, the options are looked for by value, so the new option is used
with the new mappings.
* added settings/update/ fix_product_ categories. sql script to fix the related options on product_category on an existing database. Must be run manually - 646. By Alexandre Fayolle @ camptocamp <email address hidden>
-
bump up version number, reflecting schema change
- 645. By Alexandre Fayolle @ camptocamp <email address hidden>
-
[FIX] magentoerpconnect: the product.category metat_title has a max length of 255 char on magento
- 644. By Alexandre Fayolle @ camptocamp <email address hidden>
-
[FIX] magentoerpconnect: we can get a bool instead of a list of values to log. Don't truncate in that case
- 643. By Alexandre Fayolle @ camptocamp <email address hidden>
-
[IMP] magentoerpconnect: also truncate long strings in logging of returned value
- 642. By Alexandre Fayolle @ camptocamp <email address hidden>
-
[IMP] magentoerpconnect: enhance logging truncation by processing dict argument elements
- 641. By Alexandre Fayolle @ camptocamp <email address hidden>
-
[IMP] reduce verbosity logs for large strings such as images
- 640. By Guewen Baconnier @ Camptocamp <email address hidden>
-
[FIX] write the last_products_
export_ date only at the end of the products export to avoid locking sale.shop during the whole export - 639. By Guewen Baconnier @ Camptocamp <email address hidden>
-
[FIX] mappings for page_layout and default_sort_by fail when empty, force export of categories which are missing when exporting a product
- 638. By Alexandre Fayolle @ camptocamp <email address hidden>
-
[FIX] fix product_category export and stock sync problems
Preview Diff
1 | === modified file 'magento_sku_is_code/product.py' | |||
2 | --- magento_sku_is_code/product.py 2012-03-15 09:47:04 +0000 | |||
3 | +++ magento_sku_is_code/product.py 2012-07-06 14:53:18 +0000 | |||
4 | @@ -19,16 +19,26 @@ | |||
5 | 19 | # | 19 | # |
6 | 20 | ############################################################################## | 20 | ############################################################################## |
7 | 21 | 21 | ||
8 | 22 | import copy | ||
9 | 23 | |||
10 | 22 | from osv import osv, fields | 24 | from osv import osv, fields |
11 | 23 | 25 | ||
12 | 24 | 26 | ||
13 | 25 | class Product(osv.osv): | 27 | class Product(osv.osv): |
15 | 26 | """Inherit product to use the default code as the Magento SKU. Copy the default code into the magento_sku field.""" | 28 | """Inherit product to use the default code as the Magento SKU. |
16 | 29 | Copy the default code into the magento_sku field, but doesn't | ||
17 | 30 | change it if the product has already been exported to an | ||
18 | 31 | external referential.""" | ||
19 | 32 | |||
20 | 27 | _inherit = 'product.product' | 33 | _inherit = 'product.product' |
21 | 28 | 34 | ||
23 | 29 | _columns = {'magento_sku':fields.char('Magento SKU', size=64, readonly=True),} | 35 | _columns = { |
24 | 36 | 'magento_sku': fields.char('Magento SKU', size=64, readonly=True), | ||
25 | 37 | } | ||
26 | 30 | 38 | ||
28 | 31 | _sql_constraints = [('code_uniq', 'unique(default_code)', 'The code must be unique')] | 39 | _sql_constraints = [ |
29 | 40 | ('code_uniq', 'unique(default_code)', 'The code must be unique') | ||
30 | 41 | ] | ||
31 | 32 | 42 | ||
32 | 33 | def _get_sku(self, cr, uid, vals, product=None, context=None): | 43 | def _get_sku(self, cr, uid, vals, product=None, context=None): |
33 | 34 | """ | 44 | """ |
34 | @@ -36,7 +46,7 @@ | |||
35 | 36 | @param vals: vals to be created / modified | 46 | @param vals: vals to be created / modified |
36 | 37 | @param product: optional browse instance of the product (when writing) | 47 | @param product: optional browse instance of the product (when writing) |
37 | 38 | """ | 48 | """ |
39 | 39 | return vals['default_code'] | 49 | return vals['default_code'].strip() |
40 | 40 | 50 | ||
41 | 41 | def create(self, cr, uid, vals, context=None): | 51 | def create(self, cr, uid, vals, context=None): |
42 | 42 | if vals.get('default_code'): | 52 | if vals.get('default_code'): |
43 | @@ -49,18 +59,27 @@ | |||
44 | 49 | ids_to_write = ids[:] | 59 | ids_to_write = ids[:] |
45 | 50 | if vals.get('default_code'): | 60 | if vals.get('default_code'): |
46 | 51 | for product in self.browse(cr, uid, ids, context=context): | 61 | for product in self.browse(cr, uid, ids, context=context): |
48 | 52 | # write separately on each product if they are not already exported | 62 | # write separately on each product if they |
49 | 63 | # are not already exported. because the sku value | ||
50 | 64 | # will change for each product. Concretely, when a value | ||
51 | 65 | # for default_code is given, we should have only one product | ||
52 | 66 | # in the write | ||
53 | 53 | if not product.magento_exported: | 67 | if not product.magento_exported: |
57 | 54 | new_vals = vals.copy() | 68 | atomic_vals = copy.deepcopy(vals) |
58 | 55 | new_vals['magento_sku'] = self._get_sku(cr, uid, new_vals, product=product, context=context) | 69 | atomic_vals['magento_sku'] = self._get_sku( |
59 | 56 | super(Product, self).write(cr, uid, [product.id], new_vals, context=context) | 70 | cr, uid, atomic_vals, product=product, context=context) |
60 | 71 | |||
61 | 72 | super(Product, self).write( | ||
62 | 73 | cr, uid, [product.id], atomic_vals, context=context) | ||
63 | 57 | ids_to_write.remove(product.id) | 74 | ids_to_write.remove(product.id) |
64 | 58 | 75 | ||
66 | 59 | return super(Product, self).write(cr, uid, ids_to_write, vals, context=context) | 76 | return super(Product, self).write( |
67 | 77 | cr, uid, ids_to_write, vals, context=context) | ||
68 | 60 | 78 | ||
69 | 61 | def copy(self, cr, uid, id, default=None, context=None): | 79 | def copy(self, cr, uid, id, default=None, context=None): |
70 | 62 | if not default is None: default = {} | 80 | if not default is None: default = {} |
71 | 63 | default['default_code'] = False | 81 | default['default_code'] = False |
73 | 64 | return super(Product, self).copy(cr, uid, id, default=default, context=context) | 82 | return super(Product, self).copy( |
74 | 83 | cr, uid, id, default=default, context=context) | ||
75 | 65 | 84 | ||
76 | 66 | Product() | 85 | Product() |
77 | 67 | 86 | ||
78 | === modified file 'magentoerpconnect/__openerp__.py' | |||
79 | --- magentoerpconnect/__openerp__.py 2012-05-16 08:01:05 +0000 | |||
80 | +++ magentoerpconnect/__openerp__.py 2012-07-06 14:53:18 +0000 | |||
81 | @@ -18,7 +18,7 @@ | |||
82 | 18 | ######################################################################### | 18 | ######################################################################### |
83 | 19 | { | 19 | { |
84 | 20 | "name" : "Magento e-commerce", | 20 | "name" : "Magento e-commerce", |
86 | 21 | "version" : "1.0", | 21 | "version" : "1.0.1", |
87 | 22 | "depends" : ["base", | 22 | "depends" : ["base", |
88 | 23 | "product", | 23 | "product", |
89 | 24 | "product_m2mcategories", | 24 | "product_m2mcategories", |
90 | @@ -44,9 +44,22 @@ | |||
91 | 44 | "demo_xml" : [], | 44 | "demo_xml" : [], |
92 | 45 | "update_xml" : [ | 45 | "update_xml" : [ |
93 | 46 | 'security/ir.model.access.csv', | 46 | 'security/ir.model.access.csv', |
94 | 47 | <<<<<<< TREE | ||
95 | 47 | 'settings/magerp.product_category_attribute_options.csv', | 48 | 'settings/magerp.product_category_attribute_options.csv', |
96 | 48 | 'settings/external.referential.type.csv', | 49 | 'settings/external.referential.type.csv', |
97 | 49 | 'settings/1.5.0.0/external.referential.version.csv', | 50 | 'settings/1.5.0.0/external.referential.version.csv', |
98 | 51 | ======= | ||
99 | 52 | 'settings/1.3.2.4/external.referential.type.csv', | ||
100 | 53 | 'settings/1.3.2.4/external.mapping.template.csv', | ||
101 | 54 | 'settings/1.3.2.4/external.mappinglines.template.csv', | ||
102 | 55 | 'settings/1.4.0.0/external.referential.type.csv', | ||
103 | 56 | 'settings/1.4.0.0/external.mapping.template.csv', | ||
104 | 57 | 'settings/1.4.0.0/external.mappinglines.template.csv', | ||
105 | 58 | 'settings/1.4.2.0/external.referential.type.csv', | ||
106 | 59 | 'settings/1.4.2.0/external.mapping.template.csv', | ||
107 | 60 | 'settings/1.4.2.0/external.mappinglines.template.csv', | ||
108 | 61 | 'settings/1.5.0.0/external.referential.type.csv', | ||
109 | 62 | >>>>>>> MERGE-SOURCE | ||
110 | 50 | 'settings/1.5.0.0/external.mapping.template.csv', | 63 | 'settings/1.5.0.0/external.mapping.template.csv', |
111 | 51 | 'settings/1.5.0.0/external.shop.group/external.mappinglines.template.csv', | 64 | 'settings/1.5.0.0/external.shop.group/external.mappinglines.template.csv', |
112 | 52 | 'settings/1.5.0.0/magerp.storeviews/external.mappinglines.template.csv', | 65 | 'settings/1.5.0.0/magerp.storeviews/external.mappinglines.template.csv', |
113 | @@ -64,7 +77,9 @@ | |||
114 | 64 | 'settings/1.5.0.0/account.invoice/external.mappinglines.template.csv', | 77 | 'settings/1.5.0.0/account.invoice/external.mappinglines.template.csv', |
115 | 65 | 'settings/1.5.0.0/product.link/external.mappinglines.template.csv', | 78 | 'settings/1.5.0.0/product.link/external.mappinglines.template.csv', |
116 | 66 | 'settings/magerp_product_product_type.xml', | 79 | 'settings/magerp_product_product_type.xml', |
117 | 80 | 'settings/update/magerp.product_category_attribute_options.xml', | ||
118 | 67 | 'magerp_data.xml', | 81 | 'magerp_data.xml', |
119 | 82 | 'board_view.xml', | ||
120 | 68 | 'magerp_core_view.xml', | 83 | 'magerp_core_view.xml', |
121 | 69 | 'product_view.xml', | 84 | 'product_view.xml', |
122 | 70 | 'partner_view.xml', | 85 | 'partner_view.xml', |
123 | 71 | 86 | ||
124 | === added file 'magentoerpconnect/board_view.xml' | |||
125 | --- magentoerpconnect/board_view.xml 1970-01-01 00:00:00 +0000 | |||
126 | +++ magentoerpconnect/board_view.xml 2012-07-06 14:53:18 +0000 | |||
127 | @@ -0,0 +1,30 @@ | |||
128 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
129 | 2 | <openerp> | ||
130 | 3 | <data> | ||
131 | 4 | |||
132 | 5 | <record id="board_magentoerpconnect_form" model="ir.ui.view"> | ||
133 | 6 | <field name="name">board.magentoerpconnect.form</field> | ||
134 | 7 | <field name="model">board.board</field> | ||
135 | 8 | <field name="type">form</field> | ||
136 | 9 | <field name="arch" type="xml"> | ||
137 | 10 | <form string="Magentoerpconnect Dashboard"> | ||
138 | 11 | <board style="2-1"> | ||
139 | 12 | <column> | ||
140 | 13 | <action name="%(base_external_referentials.ir_actions_act_window_external_report_line)d" string="Last Synchronizations Errors" /> | ||
141 | 14 | </column> | ||
142 | 15 | <column/> | ||
143 | 16 | </board> | ||
144 | 17 | </form> | ||
145 | 18 | </field> | ||
146 | 19 | </record> | ||
147 | 20 | |||
148 | 21 | <record id="open_board_magentoerpconnect" model="ir.actions.act_window"> | ||
149 | 22 | <field name="name">Magentoerpconnect Dashboard</field> | ||
150 | 23 | <field name="res_model">board.board</field> | ||
151 | 24 | <field name="view_type">form</field> | ||
152 | 25 | <field name="view_mode">form</field> | ||
153 | 26 | <field name="view_id" ref="board_magentoerpconnect_form"/> | ||
154 | 27 | </record> | ||
155 | 28 | |||
156 | 29 | </data> | ||
157 | 30 | </openerp> | ||
158 | 0 | 31 | ||
159 | === modified file 'magentoerpconnect/invoice.py' | |||
160 | === modified file 'magentoerpconnect/magerp_core.py' | |||
161 | --- magentoerpconnect/magerp_core.py 2012-05-25 15:37:26 +0000 | |||
162 | +++ magentoerpconnect/magerp_core.py 2012-07-06 14:53:18 +0000 | |||
163 | @@ -25,6 +25,10 @@ | |||
164 | 25 | from osv import osv, fields | 25 | from osv import osv, fields |
165 | 26 | import magerp_osv | 26 | import magerp_osv |
166 | 27 | import pooler | 27 | import pooler |
167 | 28 | <<<<<<< TREE | ||
168 | 29 | ======= | ||
169 | 30 | import logging | ||
170 | 31 | >>>>>>> MERGE-SOURCE | ||
171 | 28 | import base64, urllib | 32 | import base64, urllib |
172 | 29 | from magerp_osv import Connection | 33 | from magerp_osv import Connection |
173 | 30 | import tools | 34 | import tools |
174 | @@ -101,6 +105,10 @@ | |||
175 | 101 | def sync_attribs(self, cr, uid, ids, context=None): | 105 | def sync_attribs(self, cr, uid, ids, context=None): |
176 | 102 | attr_obj = self.pool.get('magerp.product_attributes') | 106 | attr_obj = self.pool.get('magerp.product_attributes') |
177 | 103 | attr_set_obj = self.pool.get('magerp.product_attribute_set') | 107 | attr_set_obj = self.pool.get('magerp.product_attribute_set') |
178 | 108 | <<<<<<< TREE | ||
179 | 109 | ======= | ||
180 | 110 | logger = logging.getLogger('ext synchro') | ||
181 | 111 | >>>>>>> MERGE-SOURCE | ||
182 | 104 | for referential in self.browse(cr, uid, ids, context=context): | 112 | for referential in self.browse(cr, uid, ids, context=context): |
183 | 105 | external_session = ExternalSession(referential, referential) | 113 | external_session = ExternalSession(referential, referential) |
184 | 106 | attr_conn = external_session.connection | 114 | attr_conn = external_session.connection |
185 | @@ -130,7 +138,11 @@ | |||
186 | 130 | context=context, | 138 | context=context, |
187 | 131 | ) | 139 | ) |
188 | 132 | import_cr.commit() | 140 | import_cr.commit() |
189 | 141 | <<<<<<< TREE | ||
190 | 133 | _logger.info("All attributs for the attributs set id %s was succesfully imported", attr_set_id) | 142 | _logger.info("All attributs for the attributs set id %s was succesfully imported", attr_set_id) |
191 | 143 | ======= | ||
192 | 144 | logger.info("All attributs for the attributs set id %s was succesfully imported", attr_set_id) | ||
193 | 145 | >>>>>>> MERGE-SOURCE | ||
194 | 134 | #Relate attribute sets & attributes | 146 | #Relate attribute sets & attributes |
195 | 135 | mage_inp = {} | 147 | mage_inp = {} |
196 | 136 | #Pass in {attribute_set_id:{attributes},attribute_set_id2:{attributes}} | 148 | #Pass in {attribute_set_id:{attributes},attribute_set_id2:{attributes}} |
197 | @@ -289,6 +301,8 @@ | |||
198 | 289 | filter = [filters] | 301 | filter = [filters] |
199 | 290 | return attr_conn.call('ol_customer.search', filter) | 302 | return attr_conn.call('ol_customer.search', filter) |
200 | 291 | 303 | ||
201 | 304 | partner_obj = self.pool.get('res.partner') | ||
202 | 305 | |||
203 | 292 | for referential in self.browse(cr, uid, ids, context): | 306 | for referential in self.browse(cr, uid, ids, context): |
204 | 293 | attr_conn = referential.external_connection(DEBUG) | 307 | attr_conn = referential.external_connection(DEBUG) |
205 | 294 | last_imported_id = 0 | 308 | last_imported_id = 0 |
206 | @@ -296,22 +310,24 @@ | |||
207 | 296 | last_imported_id = referential.last_imported_partner_id | 310 | last_imported_id = referential.last_imported_partner_id |
208 | 297 | 311 | ||
209 | 298 | ext_customer_ids = next_partners(attr_conn, last_imported_id + 1, self.SYNC_PARTNER_STEP) | 312 | ext_customer_ids = next_partners(attr_conn, last_imported_id + 1, self.SYNC_PARTNER_STEP) |
210 | 313 | |||
211 | 314 | context['use_external_log'] = True | ||
212 | 299 | import_cr = pooler.get_db(cr.dbname).cursor() | 315 | import_cr = pooler.get_db(cr.dbname).cursor() |
213 | 300 | try: | 316 | try: |
214 | 301 | while ext_customer_ids: | 317 | while ext_customer_ids: |
215 | 302 | for ext_customer_id in ext_customer_ids: | 318 | for ext_customer_id in ext_customer_ids: |
228 | 303 | customer_info = attr_conn.call('customer.info', [ext_customer_id]) | 319 | customer_info = attr_conn.call( |
229 | 304 | customer_address_info = attr_conn.call('customer_address.list', [ext_customer_id]) | 320 | 'customer.info', [ext_customer_id]) |
230 | 305 | 321 | ||
231 | 306 | address_info = False | 322 | partner_obj.ext_import( |
232 | 307 | if customer_address_info: | 323 | import_cr, uid, [customer_info], |
233 | 308 | address_info = customer_address_info[0] | 324 | referential.id, context=context) |
234 | 309 | address_info['customer_id'] = ext_customer_id | 325 | partner_id = partner_obj.extid_to_oeid( |
235 | 310 | address_info['email'] = customer_info['email'] | 326 | import_cr, uid, ext_customer_id, |
236 | 311 | 327 | referential.id, context=context) | |
237 | 312 | self.pool.get('res.partner').ext_import(import_cr, uid, [customer_info], referential.id, context=context) | 328 | partner_obj.import_magento_address_book( |
238 | 313 | if address_info: | 329 | import_cr, uid, partner_id, |
239 | 314 | self.pool.get('res.partner.address').ext_import(import_cr, uid, [address_info], referential.id, context=context) | 330 | referential.id, context=context) |
240 | 315 | 331 | ||
241 | 316 | last_imported_id = int(ext_customer_id) | 332 | last_imported_id = int(ext_customer_id) |
242 | 317 | self.write(import_cr, uid, referential.id, {'last_imported_partner_id': last_imported_id}, context=context) | 333 | self.write(import_cr, uid, referential.id, {'last_imported_partner_id': last_imported_id}, context=context) |
243 | 318 | 334 | ||
244 | === modified file 'magentoerpconnect/magerp_menu.xml' | |||
245 | --- magentoerpconnect/magerp_menu.xml 2012-03-15 09:47:04 +0000 | |||
246 | +++ magentoerpconnect/magerp_menu.xml 2012-07-06 14:53:18 +0000 | |||
247 | @@ -1,7 +1,7 @@ | |||
248 | 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
249 | 2 | <openerp> | 2 | <openerp> |
250 | 3 | <data> | 3 | <data> |
252 | 4 | <menuitem id="menu_magerp" name="MagentoERPconnect" icon="terp-sale" | 4 | <menuitem id="menu_magerp" name="MagentoERPconnect" icon="terp-sale" action="open_board_magentoerpconnect" |
253 | 5 | web_icon="images/magento.png" | 5 | web_icon="images/magento.png" |
254 | 6 | web_icon_hover="images/magento-hover.png"/> | 6 | web_icon_hover="images/magento-hover.png"/> |
255 | 7 | 7 | ||
256 | @@ -25,41 +25,17 @@ | |||
257 | 25 | 25 | ||
258 | 26 | <menuitem id="menu_magerp_reporting" name="Reporting" parent="menu_magerp" /> | 26 | <menuitem id="menu_magerp_reporting" name="Reporting" parent="menu_magerp" /> |
259 | 27 | 27 | ||
260 | 28 | <record id="action_magerp_external_report" model="ir.actions.act_window"> | ||
261 | 29 | <field name="name">External Reports</field> | ||
262 | 30 | <field name="type">ir.actions.act_window</field> | ||
263 | 31 | <field name="res_model">external.report</field> | ||
264 | 32 | <field name="view_type">form</field> | ||
265 | 33 | <field name="domain">[('external_referential_id.type_id.name', 'like', 'Magento')]</field> <!-- erk --> | ||
266 | 34 | <field name="view_id" ref="base_external_referentials.external_report_tree_view"/> | ||
267 | 35 | <field name="search_view_id" ref="base_external_referentials.external_report_search_form_view"/> | ||
268 | 36 | </record> | ||
269 | 37 | <menuitem id="menu_magerp_reporting_report" name="Synchronisation Report" | ||
270 | 38 | parent="menu_magerp_reporting" action="action_magerp_external_report" sequence="20"/> | ||
271 | 39 | |||
272 | 40 | <record id="action_magerp_external_report_history" model="ir.actions.act_window"> | ||
273 | 41 | <field name="name">External Report History</field> | ||
274 | 42 | <field name="type">ir.actions.act_window</field> | ||
275 | 43 | <field name="res_model">external.report.history</field> | ||
276 | 44 | <field name="view_type">form</field> | ||
277 | 45 | <field name="domain">[('external_report_id.external_referential_id.type_id.name', 'like', 'Magento')]</field> <!-- erk --> | ||
278 | 46 | <field name="view_id" ref="base_external_referentials.external_report_history_tree_view"/> | ||
279 | 47 | <field name="search_view_id" ref="base_external_referentials.external_report_history_search_view"/> | ||
280 | 48 | </record> | ||
281 | 49 | |||
282 | 50 | <menuitem id="menu_magerp_reporting_report_history" name="Synchronisation History" | ||
283 | 51 | parent="menu_magerp_reporting" action="action_magerp_external_report_history" sequence="25" /> | ||
284 | 52 | 28 | ||
285 | 53 | <record id="action_magerp_external_report_line" model="ir.actions.act_window"> | 29 | <record id="action_magerp_external_report_line" model="ir.actions.act_window"> |
286 | 54 | <field name="name">External Report Lines</field> | 30 | <field name="name">External Report Lines</field> |
287 | 55 | <field name="type">ir.actions.act_window</field> | 31 | <field name="type">ir.actions.act_window</field> |
288 | 56 | <field name="res_model">external.report.line</field> | 32 | <field name="res_model">external.report.line</field> |
289 | 57 | <field name="view_type">form</field> | 33 | <field name="view_type">form</field> |
291 | 58 | <field name="domain">[('external_report_id.external_referential_id.type_id.name', 'like', 'Magento')]</field> <!-- erk --> | 34 | <field name="domain">[('referential_id.type_id.name', 'like', 'Magento')]</field> <!-- erk --> |
292 | 59 | <field name="view_id" ref="base_external_referentials.external_report_line_tree_view"/> | 35 | <field name="view_id" ref="base_external_referentials.external_report_line_tree_view"/> |
293 | 60 | <field name="search_view_id" ref="base_external_referentials.external_report_line_search_view"/> | 36 | <field name="search_view_id" ref="base_external_referentials.external_report_line_search_view"/> |
294 | 61 | </record> | 37 | </record> |
296 | 62 | <menuitem id="menu_magerp_reporting_report_line" name="Last Synchronisation Details" | 38 | <menuitem id="menu_magerp_reporting_report_line" name="Synchronisation Errors" |
297 | 63 | parent="menu_magerp_reporting" action="action_magerp_external_report_line" sequence="30"/> | 39 | parent="menu_magerp_reporting" action="action_magerp_external_report_line" sequence="30"/> |
298 | 64 | </data> | 40 | </data> |
299 | 65 | </openerp> | 41 | </openerp> |
300 | 66 | 42 | ||
301 | === modified file 'magentoerpconnect/magerp_osv.py' | |||
302 | --- magentoerpconnect/magerp_osv.py 2012-05-24 20:52:38 +0000 | |||
303 | +++ magentoerpconnect/magerp_osv.py 2012-07-06 14:53:18 +0000 | |||
304 | @@ -23,9 +23,16 @@ | |||
305 | 23 | import time | 23 | import time |
306 | 24 | import datetime | 24 | import datetime |
307 | 25 | import xmlrpclib | 25 | import xmlrpclib |
308 | 26 | <<<<<<< TREE | ||
309 | 27 | ======= | ||
310 | 28 | import logging | ||
311 | 29 | >>>>>>> MERGE-SOURCE | ||
312 | 26 | import urllib2 | 30 | import urllib2 |
313 | 27 | import base64 | 31 | import base64 |
314 | 32 | import pooler | ||
315 | 28 | from tools.translate import _ | 33 | from tools.translate import _ |
316 | 34 | from openerp.addons.base_external_referentials.external_osv import MappingError | ||
317 | 35 | from psycopg2 import IntegrityError | ||
318 | 29 | 36 | ||
319 | 30 | 37 | ||
320 | 31 | #NEW FEATURE | 38 | #NEW FEATURE |
321 | @@ -175,7 +182,7 @@ | |||
322 | 175 | def __init__(self, location, username, password, debug=False, logger=False): | 182 | def __init__(self, location, username, password, debug=False, logger=False): |
323 | 176 | #Append / if not there | 183 | #Append / if not there |
324 | 177 | if not location[-1] == '/': | 184 | if not location[-1] == '/': |
326 | 178 | location += '/' | 185 | location += '/' |
327 | 179 | self.corelocation = location | 186 | self.corelocation = location |
328 | 180 | #Please do not remove the str indeed xmlrpc lib require a string for the location | 187 | #Please do not remove the str indeed xmlrpc lib require a string for the location |
329 | 181 | #if an unicode is send it will raise you an error | 188 | #if an unicode is send it will raise you an error |
330 | @@ -184,26 +191,46 @@ | |||
331 | 184 | self.password = password | 191 | self.password = password |
332 | 185 | self.debug = debug | 192 | self.debug = debug |
333 | 186 | self.result = {} | 193 | self.result = {} |
334 | 194 | <<<<<<< TREE | ||
335 | 187 | self.logger = logger or _logger | 195 | self.logger = logger or _logger |
336 | 188 | 196 | ||
337 | 189 | 197 | ||
338 | 198 | ======= | ||
339 | 199 | self.logger = logging.getLogger('Connection(%s)' % self.location) | ||
340 | 200 | |||
341 | 201 | |||
342 | 202 | >>>>>>> MERGE-SOURCE | ||
343 | 190 | def connect(self): | 203 | def connect(self): |
344 | 191 | if not self.location[-1] == '/': | 204 | if not self.location[-1] == '/': |
345 | 192 | self.location += '/' | 205 | self.location += '/' |
346 | 193 | if self.debug: | 206 | if self.debug: |
347 | 207 | <<<<<<< TREE | ||
348 | 194 | self.logger.info("Attempting connection with Settings:%s,%s,%s" % (self.location, self.username, self.password)) | 208 | self.logger.info("Attempting connection with Settings:%s,%s,%s" % (self.location, self.username, self.password)) |
349 | 209 | ======= | ||
350 | 210 | self.logger.info(_("Attempting connection with Settings:%s,%s,%s"), self.location, self.username, self.password) | ||
351 | 211 | >>>>>>> MERGE-SOURCE | ||
352 | 195 | self.ser = xmlrpclib.ServerProxy(self.location) | 212 | self.ser = xmlrpclib.ServerProxy(self.location) |
353 | 196 | for sleep_time in [1, 3, 6]: | 213 | for sleep_time in [1, 3, 6]: |
354 | 197 | try: | 214 | try: |
355 | 198 | self.session = self.ser.login(self.username, self.password) | 215 | self.session = self.ser.login(self.username, self.password) |
356 | 199 | if self.debug: | 216 | if self.debug: |
357 | 217 | <<<<<<< TREE | ||
358 | 200 | self.logger.info("Login Successful") | 218 | self.logger.info("Login Successful") |
359 | 219 | ======= | ||
360 | 220 | self.logger.info(_("Login Successful")) | ||
361 | 221 | >>>>>>> MERGE-SOURCE | ||
362 | 201 | return True | 222 | return True |
363 | 202 | except IOError, e: | 223 | except IOError, e: |
364 | 224 | <<<<<<< TREE | ||
365 | 203 | self.logger.error("Error in connecting:%s" % e) | 225 | self.logger.error("Error in connecting:%s" % e) |
366 | 204 | self.logger.warning("Webservice Failure, sleeping %s second before next attempt" % sleep_time) | 226 | self.logger.warning("Webservice Failure, sleeping %s second before next attempt" % sleep_time) |
367 | 227 | ======= | ||
368 | 228 | self.logger.error(_("Error in connecting:%s"), e, exc_info=True) | ||
369 | 229 | self.logger.warn(_("Webservice Failure, sleeping %s second before next attempt"), sleep_time) | ||
370 | 230 | >>>>>>> MERGE-SOURCE | ||
371 | 205 | time.sleep(sleep_time) | 231 | time.sleep(sleep_time) |
372 | 206 | except Exception,e: | 232 | except Exception,e: |
373 | 233 | <<<<<<< TREE | ||
374 | 207 | self.logger.error("Magento Connection" + netsvc.LOG_ERROR + "Error in connecting:%s" % e) | 234 | self.logger.error("Magento Connection" + netsvc.LOG_ERROR + "Error in connecting:%s" % e) |
375 | 208 | self.logger.warning("Webservice Failure, sleeping %s second before next attempt" % sleep_time) | 235 | self.logger.warning("Webservice Failure, sleeping %s second before next attempt" % sleep_time) |
376 | 209 | time.sleep(sleep_time) | 236 | time.sleep(sleep_time) |
377 | @@ -211,6 +238,34 @@ | |||
378 | 211 | 238 | ||
379 | 212 | 239 | ||
380 | 213 | def call(self, method, *arguments): | 240 | def call(self, method, *arguments): |
381 | 241 | ======= | ||
382 | 242 | self.logger.error(_("Error in connecting:%s"), e, exc_info=True) | ||
383 | 243 | self.logger.warn(_("Webservice Failure, sleeping %s second before next attempt"), sleep_time) | ||
384 | 244 | time.sleep(sleep_time) | ||
385 | 245 | raise osv.except_osv(_('User Error'), _('Error connecting to magento, are your sure that your login is right? Did you configure API user in magento?')) | ||
386 | 246 | |||
387 | 247 | def _truncate_arguments(self, arguments, max_length=128): | ||
388 | 248 | """truncate long strings in arguments for logging purpose""" | ||
389 | 249 | logged_args = [] | ||
390 | 250 | try: | ||
391 | 251 | for arg in arguments: | ||
392 | 252 | # reduce verbosity of log for large strings (e.g. base64 encoded images...) | ||
393 | 253 | if isinstance(arg, basestring) and len(arg) > max_length: | ||
394 | 254 | arg = arg[:max_length] + '...' | ||
395 | 255 | elif isinstance(arg, dict): | ||
396 | 256 | new_arg = {} | ||
397 | 257 | for key, value in arg.iteritems(): | ||
398 | 258 | if isinstance(value, basestring) and len(value) > max_length: | ||
399 | 259 | value = value[:max_length] + '...' | ||
400 | 260 | new_arg[key] = value | ||
401 | 261 | arg = new_arg | ||
402 | 262 | logged_args.append(arg) | ||
403 | 263 | return logged_args | ||
404 | 264 | except TypeError: # arguments can be a bool | ||
405 | 265 | return arguments | ||
406 | 266 | |||
407 | 267 | def call(self, method, *arguments): | ||
408 | 268 | >>>>>>> MERGE-SOURCE | ||
409 | 214 | if arguments: | 269 | if arguments: |
410 | 215 | arguments = list(arguments)[0] | 270 | arguments = list(arguments)[0] |
411 | 216 | else: | 271 | else: |
412 | @@ -218,18 +273,37 @@ | |||
413 | 218 | for sleep_time in [1, 3, 6]: | 273 | for sleep_time in [1, 3, 6]: |
414 | 219 | try: | 274 | try: |
415 | 220 | if self.debug: | 275 | if self.debug: |
416 | 276 | <<<<<<< TREE | ||
417 | 221 | self.logger.info(_("Calling Method:%s,Arguments:%s") % (method, arguments)) | 277 | self.logger.info(_("Calling Method:%s,Arguments:%s") % (method, arguments)) |
418 | 278 | ======= | ||
419 | 279 | logged_args = self._truncate_arguments(arguments) | ||
420 | 280 | self.logger.info(_("Calling Method:%s,Arguments:%s"), method, logged_args) | ||
421 | 281 | >>>>>>> MERGE-SOURCE | ||
422 | 222 | res = self.ser.call(self.session, method, arguments) | 282 | res = self.ser.call(self.session, method, arguments) |
423 | 223 | if self.debug: | 283 | if self.debug: |
424 | 284 | logged_res = self._truncate_arguments(res) | ||
425 | 224 | if method=='catalog_product.list': | 285 | if method=='catalog_product.list': |
426 | 225 | # the response of the method catalog_product.list can be very very long so it's better to see it only if debug log is activate | 286 | # the response of the method catalog_product.list can be very very long so it's better to see it only if debug log is activate |
427 | 287 | <<<<<<< TREE | ||
428 | 226 | self.logger.debug(_("Query Returned:%s") % (res)) | 288 | self.logger.debug(_("Query Returned:%s") % (res)) |
429 | 289 | ======= | ||
430 | 290 | self.logger.debug(_("Query Returned:%s"), logged_res) | ||
431 | 291 | >>>>>>> MERGE-SOURCE | ||
432 | 227 | else: | 292 | else: |
433 | 293 | <<<<<<< TREE | ||
434 | 228 | self.logger.info(_("Query Returned:%s") % (res)) | 294 | self.logger.info(_("Query Returned:%s") % (res)) |
435 | 295 | ======= | ||
436 | 296 | self.logger.info(_("Query Returned:%s"), logged_res) | ||
437 | 297 | >>>>>>> MERGE-SOURCE | ||
438 | 229 | return res | 298 | return res |
439 | 230 | except IOError, e: | 299 | except IOError, e: |
440 | 300 | <<<<<<< TREE | ||
441 | 231 | self.logger.error(_("Method: %s\nArguments:%s\nError:%s") % (method, arguments, e)) | 301 | self.logger.error(_("Method: %s\nArguments:%s\nError:%s") % (method, arguments, e)) |
442 | 232 | self.logger.warning(_("Webservice Failure, sleeping %s second before next attempt") % (sleep_time)) | 302 | self.logger.warning(_("Webservice Failure, sleeping %s second before next attempt") % (sleep_time)) |
443 | 303 | ======= | ||
444 | 304 | self.logger.error(_("Method: %s\nArguments:%s\nError:%s"), method, arguments, e, exc_info=True) | ||
445 | 305 | self.logger.warn(_("Webservice Failure, sleeping %s second before next attempt"), sleep_time) | ||
446 | 306 | >>>>>>> MERGE-SOURCE | ||
447 | 233 | time.sleep(sleep_time) | 307 | time.sleep(sleep_time) |
448 | 234 | raise | 308 | raise |
449 | 235 | 309 | ||
450 | @@ -254,7 +328,7 @@ | |||
451 | 254 | _DELETE_METHOD = False | 328 | _DELETE_METHOD = False |
452 | 255 | _mapping = {} | 329 | _mapping = {} |
453 | 256 | DEBUG = False | 330 | DEBUG = False |
455 | 257 | 331 | ||
456 | 258 | #TODO deprecated, remove use | 332 | #TODO deprecated, remove use |
457 | 259 | def mage_to_oe(self, cr, uid, mageid, instance, *arguments): | 333 | def mage_to_oe(self, cr, uid, mageid, instance, *arguments): |
458 | 260 | """given a record id in the Magento referential, returns a tuple (id, name) with the id in the OpenERP referential; Magento instance wise""" | 334 | """given a record id in the Magento referential, returns a tuple (id, name) with the id in the OpenERP referential; Magento instance wise""" |
459 | @@ -279,7 +353,7 @@ | |||
460 | 279 | read = self.read(cr, uid, oeid, [self._rec_name]) | 353 | read = self.read(cr, uid, oeid, [self._rec_name]) |
461 | 280 | return (read[0]['id'], read[0][self._rec_name]) | 354 | return (read[0]['id'], read[0][self._rec_name]) |
462 | 281 | return False | 355 | return False |
464 | 282 | 356 | ||
465 | 283 | #TODO deprecated, remove use | 357 | #TODO deprecated, remove use |
466 | 284 | def sync_import(self, cr, uid, magento_records, instance, debug=False, defaults=None, *attrs): | 358 | def sync_import(self, cr, uid, magento_records, instance, debug=False, defaults=None, *attrs): |
467 | 285 | 359 | ||
468 | @@ -314,7 +388,7 @@ | |||
469 | 314 | 'temp_vars':{}, | 388 | 'temp_vars':{}, |
470 | 315 | 'mage2oe_filters':mage2oe_filters | 389 | 'mage2oe_filters':mage2oe_filters |
471 | 316 | } | 390 | } |
473 | 317 | 391 | ||
474 | 318 | #now properly mapp known Magento attributes to OpenERP entity columns: | 392 | #now properly mapp known Magento attributes to OpenERP entity columns: |
475 | 319 | for each_valid_key in self._mapping: | 393 | for each_valid_key in self._mapping: |
476 | 320 | if each_valid_key in magento_record.keys(): | 394 | if each_valid_key in magento_record.keys(): |
477 | @@ -347,13 +421,12 @@ | |||
478 | 347 | if self._mapping[each_valid_key][0]:#if not function mapping | 421 | if self._mapping[each_valid_key][0]:#if not function mapping |
479 | 348 | vals[self._mapping[each_valid_key][0]] = magento_record[each_valid_key] or False | 422 | vals[self._mapping[each_valid_key][0]] = magento_record[each_valid_key] or False |
480 | 349 | vals['referential_id'] = instance | 423 | vals['referential_id'] = instance |
481 | 350 | tools.debug(vals) | ||
482 | 351 | if self._MAGE_FIELD: | 424 | if self._MAGE_FIELD: |
483 | 352 | if self._MAGE_FIELD in vals.keys() and vals[self._MAGE_FIELD]: | 425 | if self._MAGE_FIELD in vals.keys() and vals[self._MAGE_FIELD]: |
484 | 353 | self.record_save(cr, uid, rec_id, vals, defaults) | 426 | self.record_save(cr, uid, rec_id, vals, defaults) |
485 | 354 | else: | 427 | else: |
486 | 355 | self.record_save(cr, uid, rec_id, vals, defaults) | 428 | self.record_save(cr, uid, rec_id, vals, defaults) |
488 | 356 | 429 | ||
489 | 357 | def record_save(self, cr, uid, rec_id, vals, defaults): | 430 | def record_save(self, cr, uid, rec_id, vals, defaults): |
490 | 358 | if defaults: | 431 | if defaults: |
491 | 359 | for key in defaults.keys(): | 432 | for key in defaults.keys(): |
492 | @@ -364,7 +437,7 @@ | |||
493 | 364 | else: | 437 | else: |
494 | 365 | #Record is not there, create it | 438 | #Record is not there, create it |
495 | 366 | self.create(cr, uid, vals,) | 439 | self.create(cr, uid, vals,) |
497 | 367 | 440 | ||
498 | 368 | def cast_string(self, subject): | 441 | def cast_string(self, subject): |
499 | 369 | """This function will convert string objects to the data type required. Example "0"/"1" to boolean conversion""" | 442 | """This function will convert string objects to the data type required. Example "0"/"1" to boolean conversion""" |
500 | 370 | for key in subject.keys(): | 443 | for key in subject.keys(): |
501 | @@ -374,7 +447,7 @@ | |||
502 | 374 | else: | 447 | else: |
503 | 375 | subject[key] = True | 448 | subject[key] = True |
504 | 376 | return subject | 449 | return subject |
506 | 377 | 450 | ||
507 | 378 | def mage_import_base(self,cr,uid,conn, external_referential_id, defaults=None, context=None): | 451 | def mage_import_base(self,cr,uid,conn, external_referential_id, defaults=None, context=None): |
508 | 379 | if context is None: | 452 | if context is None: |
509 | 380 | context = {} | 453 | context = {} |
510 | @@ -396,7 +469,7 @@ | |||
511 | 396 | list_method = self.pool.get('external.mapping').read(cr,uid,mapping_id[0],['external_list_method']).get('external_list_method',False) | 469 | list_method = self.pool.get('external.mapping').read(cr,uid,mapping_id[0],['external_list_method']).get('external_list_method',False) |
512 | 397 | if list_method: | 470 | if list_method: |
513 | 398 | data = conn.call(list_method, context['ids_or_filter']) | 471 | data = conn.call(list_method, context['ids_or_filter']) |
515 | 399 | 472 | ||
516 | 400 | #it may happen that list method doesn't provide enough information, forcing us to use get_method on each record (case for sale orders) | 473 | #it may happen that list method doesn't provide enough information, forcing us to use get_method on each record (case for sale orders) |
517 | 401 | if context.get('one_by_one', False): | 474 | if context.get('one_by_one', False): |
518 | 402 | self.mage_import_one_by_one(cr, uid, conn, external_referential_id, mapping_id[0], data, defaults, context) | 475 | self.mage_import_one_by_one(cr, uid, conn, external_referential_id, mapping_id[0], data, defaults, context) |
519 | @@ -405,24 +478,60 @@ | |||
520 | 405 | 478 | ||
521 | 406 | return result | 479 | return result |
522 | 407 | 480 | ||
523 | 481 | def _mage_import_one(self, cr, uid, conn, record, referential_id, mapping_id, defaults=None, context=None): | ||
524 | 482 | ext_id = record[self.pool.get('external.mapping').read(cr, uid, mapping_id, ['external_key_name'])['external_key_name']] | ||
525 | 483 | get_method = self.pool.get('external.mapping').read(cr, uid, mapping_id, ['external_get_method']).get('external_get_method',False) | ||
526 | 484 | rec_data = [conn.call(get_method, [ext_id])] | ||
527 | 485 | rec_result = self.ext_import(cr, uid, rec_data, referential_id, defaults, context) | ||
528 | 486 | return rec_result['create_ids'], rec_result['write_ids'] | ||
529 | 487 | |||
530 | 408 | def mage_import_one_by_one(self, cr, uid, conn, external_referential_id, mapping_id, data, defaults=None, context=None): | 488 | def mage_import_one_by_one(self, cr, uid, conn, external_referential_id, mapping_id, data, defaults=None, context=None): |
531 | 409 | if context is None: | 489 | if context is None: |
532 | 410 | context = {} | 490 | context = {} |
533 | 491 | report_line_obj = self.pool.get('external.report.line') | ||
534 | 411 | result = {'create_ids': [], 'write_ids': []} | 492 | result = {'create_ids': [], 'write_ids': []} |
537 | 412 | if context.get('one_by_one', False): | 493 | import_ctx = dict(context) |
538 | 413 | del(context['one_by_one']) | 494 | import_ctx.pop('one_by_one', False) |
539 | 495 | # avoid to use external logs in submethods as they are handle at this level | ||
540 | 496 | import_ctx.pop('use_external_log', False) | ||
541 | 497 | import_ctx['import_no_new_cr'] = True | ||
542 | 414 | for record in data: | 498 | for record in data: |
550 | 415 | id = record[self.pool.get('external.mapping').read(cr, uid, mapping_id, ['external_key_name'])['external_key_name']] | 499 | record_cr = pooler.get_db(cr.dbname).cursor() |
551 | 416 | get_method = self.pool.get('external.mapping').read(cr, uid, mapping_id, ['external_get_method']).get('external_get_method',False) | 500 | try: |
552 | 417 | rec_data = [conn.call(get_method, [id])] | 501 | ext_id = record[self.pool.get('external.mapping').read( |
553 | 418 | rec_result = self.ext_import(cr, uid, rec_data, external_referential_id, defaults, context) | 502 | record_cr, uid, mapping_id, ['external_key_name'])['external_key_name']] |
554 | 419 | result['create_ids'].append(rec_result['create_ids']) | 503 | cids, wids = self._mage_import_one( |
555 | 420 | result['write_ids'].append(rec_result['write_ids']) | 504 | record_cr, uid, conn, record, external_referential_id, mapping_id, defaults=defaults, context=import_ctx) |
556 | 421 | # and let the import continue, because it will be imported on the next import | 505 | except (MappingError, osv.except_osv, xmlrpclib.Fault, IntegrityError): |
557 | 506 | record_cr.rollback() | ||
558 | 507 | report_line_obj.log_failed( | ||
559 | 508 | cr, uid, | ||
560 | 509 | self._name, | ||
561 | 510 | 'import', | ||
562 | 511 | external_referential_id, | ||
563 | 512 | external_id=ext_id, | ||
564 | 513 | defaults=defaults, | ||
565 | 514 | context=context) | ||
566 | 515 | else: | ||
567 | 516 | record_cr.commit() | ||
568 | 517 | report_line_obj.log_success( | ||
569 | 518 | cr, uid, | ||
570 | 519 | self._name, | ||
571 | 520 | 'import', | ||
572 | 521 | external_referential_id, | ||
573 | 522 | external_id=ext_id, | ||
574 | 523 | context=context) | ||
575 | 524 | result['create_ids'].append(cids) | ||
576 | 525 | result['write_ids'].append(wids) | ||
577 | 526 | finally: | ||
578 | 527 | record_cr.close() | ||
579 | 422 | return result | 528 | return result |
580 | 423 | 529 | ||
581 | 424 | def get_external_data(self, cr, uid, conn, external_referential_id, defaults=None, context=None): | 530 | def get_external_data(self, cr, uid, conn, external_referential_id, defaults=None, context=None): |
582 | 425 | """Constructs data using WS or other synch protocols and then call ext_import on it""" | 531 | """Constructs data using WS or other synch protocols and then call ext_import on it""" |
583 | 532 | if context is None: | ||
584 | 533 | context = {} | ||
585 | 534 | context = dict(context) | ||
586 | 426 | return self.mage_import_base(cr, uid, conn, external_referential_id, defaults, context)#TODO refactor mage_import_base calls to this interface | 535 | return self.mage_import_base(cr, uid, conn, external_referential_id, defaults, context)#TODO refactor mage_import_base calls to this interface |
587 | 427 | 536 | ||
588 | 428 | #TODO deprecated, remove use | 537 | #TODO deprecated, remove use |
589 | @@ -438,7 +547,7 @@ | |||
590 | 438 | self.sync_import(cr, uid, magento_records, instance, debug, defaults) | 547 | self.sync_import(cr, uid, magento_records, instance, debug, defaults) |
591 | 439 | else: | 548 | else: |
592 | 440 | raise osv.except_osv(_('Undefined List method !'), _("list method is undefined for this object!")) | 549 | raise osv.except_osv(_('Undefined List method !'), _("list method is undefined for this object!")) |
594 | 441 | 550 | ||
595 | 442 | #TODO deprecated, remove use | 551 | #TODO deprecated, remove use |
596 | 443 | def get_all_mage_ids(self, cr, uid, ids, instance=False): | 552 | def get_all_mage_ids(self, cr, uid, ids, instance=False): |
597 | 444 | search_param = [] | 553 | search_param = [] |
598 | @@ -451,4 +560,4 @@ | |||
599 | 451 | for each in reads: | 560 | for each in reads: |
600 | 452 | mageids.append(each[self._MAGE_FIELD]) | 561 | mageids.append(each[self._MAGE_FIELD]) |
601 | 453 | return mageids | 562 | return mageids |
603 | 454 | 563 | ||
604 | 455 | 564 | ||
605 | === modified file 'magentoerpconnect/partner.py' | |||
606 | --- magentoerpconnect/partner.py 2012-05-19 13:37:23 +0000 | |||
607 | +++ magentoerpconnect/partner.py 2012-07-06 14:53:18 +0000 | |||
608 | @@ -22,6 +22,9 @@ | |||
609 | 22 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # | 22 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
610 | 23 | ######################################################################### | 23 | ######################################################################### |
611 | 24 | 24 | ||
612 | 25 | import string | ||
613 | 26 | import copy | ||
614 | 27 | |||
615 | 25 | from osv import osv, fields | 28 | from osv import osv, fields |
616 | 26 | from tools.translate import _ | 29 | from tools.translate import _ |
617 | 27 | import magerp_osv | 30 | import magerp_osv |
618 | @@ -52,6 +55,7 @@ | |||
619 | 52 | return res | 55 | return res |
620 | 53 | 56 | ||
621 | 54 | _columns = { | 57 | _columns = { |
622 | 58 | <<<<<<< TREE | ||
623 | 55 | 'name': fields.function(_get_partner_name, obj="res.partner.address", type = 'char', size = 256, | 59 | 'name': fields.function(_get_partner_name, obj="res.partner.address", type = 'char', size = 256, |
624 | 56 | store = { | 60 | store = { |
625 | 57 | 'res.partner.address' : (lambda self, cr, uid, ids, c={}: ids, | 61 | 'res.partner.address' : (lambda self, cr, uid, ids, c={}: ids, |
626 | @@ -60,8 +64,22 @@ | |||
627 | 60 | 'firstname':fields.char('First Name', size=100), | 64 | 'firstname':fields.char('First Name', size=100), |
628 | 61 | 'lastname':fields.char('Last Name', size=100), | 65 | 'lastname':fields.char('Last Name', size=100), |
629 | 62 | 'is_magento_order_address':fields.boolean('Magento Order Address?'), #TODO still needed? | 66 | 'is_magento_order_address':fields.boolean('Magento Order Address?'), #TODO still needed? |
630 | 67 | ======= | ||
631 | 68 | 'firstname':fields.char('First Name', size=100), | ||
632 | 69 | 'lastname':fields.char('Last Name', size=100), | ||
633 | 70 | 'is_magento_order_address': | ||
634 | 71 | fields.boolean('Magento Order Address', | ||
635 | 72 | help="Created for a Magento sale order", | ||
636 | 73 | readonly=True), | ||
637 | 74 | 'magento_address_book': | ||
638 | 75 | fields.boolean('Magento Address Book', | ||
639 | 76 | help="Part of the Magento Address Book", | ||
640 | 77 | readonly=True) | ||
641 | 78 | >>>>>>> MERGE-SOURCE | ||
642 | 63 | } | 79 | } |
643 | 80 | |||
644 | 64 | _defaults = { | 81 | _defaults = { |
645 | 82 | <<<<<<< TREE | ||
646 | 65 | 'is_magento_order_address': lambda * a:False, | 83 | 'is_magento_order_address': lambda * a:False, |
647 | 66 | } | 84 | } |
648 | 67 | 85 | ||
649 | @@ -75,6 +93,19 @@ | |||
650 | 75 | ext_create_ids[resource_id] = ext_id | 93 | ext_create_ids[resource_id] = ext_id |
651 | 76 | return ext_create_ids | 94 | return ext_create_ids |
652 | 77 | 95 | ||
653 | 96 | ======= | ||
654 | 97 | 'is_magento_order_address': lambda * a: False, | ||
655 | 98 | } | ||
656 | 99 | |||
657 | 100 | def mage_import_base(self,cr,uid,conn, external_referential_id, defaults=None, context=None): | ||
658 | 101 | # quick hack | ||
659 | 102 | # remove the id so the address will be imported using "list method" | ||
660 | 103 | # instead of "get method" because the entity_id field miss in the get method. | ||
661 | 104 | context.pop('id', False) | ||
662 | 105 | return super(res_partner_address, self).mage_import_base( | ||
663 | 106 | cr, uid, conn, external_referential_id, defaults=defaults, context=context) | ||
664 | 107 | |||
665 | 108 | >>>>>>> MERGE-SOURCE | ||
666 | 78 | res_partner_address() | 109 | res_partner_address() |
667 | 79 | 110 | ||
668 | 80 | class res_partner(magerp_osv.magerp_osv): | 111 | class res_partner(magerp_osv.magerp_osv): |
669 | @@ -107,11 +138,20 @@ | |||
670 | 107 | 'mag_birthday':fields.date('Birthday', help="To be able to receive customer birthday you must set it in Magento Admin Panel, menu System / Configuration / Client Configuration / Name and Address Options."), | 138 | 'mag_birthday':fields.date('Birthday', help="To be able to receive customer birthday you must set it in Magento Admin Panel, menu System / Configuration / Client Configuration / Name and Address Options."), |
671 | 108 | 'mag_newsletter':fields.boolean('Newsletter'), | 139 | 'mag_newsletter':fields.boolean('Newsletter'), |
672 | 109 | 'magento_exported': fields.function(_is_magento_exported, type="boolean", method=True, string="Exists on Magento"), | 140 | 'magento_exported': fields.function(_is_magento_exported, type="boolean", method=True, string="Exists on Magento"), |
673 | 141 | <<<<<<< TREE | ||
674 | 110 | 'magento_pwd': fields.char('Magento Password', size=256), | 142 | 'magento_pwd': fields.char('Magento Password', size=256), |
675 | 143 | ======= | ||
676 | 144 | 'is_magento_guest': fields.boolean( | ||
677 | 145 | 'Is a Magento guest', | ||
678 | 146 | help="This partner has been created for a Magento " | ||
679 | 147 | "guest sale order.", | ||
680 | 148 | readonly=True) | ||
681 | 149 | >>>>>>> MERGE-SOURCE | ||
682 | 111 | } | 150 | } |
683 | 112 | 151 | ||
684 | 113 | _sql_constraints = [('emailid_uniq', 'unique(emailid, website_id)', 'A partner already exists with this email address on the selected website.')] | 152 | _sql_constraints = [('emailid_uniq', 'unique(emailid, website_id)', 'A partner already exists with this email address on the selected website.')] |
685 | 114 | 153 | ||
686 | 154 | <<<<<<< TREE | ||
687 | 115 | @only_for_referential('magento') | 155 | @only_for_referential('magento') |
688 | 116 | def get_ids_and_update_date(self, cr, uid, external_session, ids=None, last_exported_date=None, context=None): | 156 | def get_ids_and_update_date(self, cr, uid, external_session, ids=None, last_exported_date=None, context=None): |
689 | 117 | store_ids = [store.id for store in external_session.sync_from_object.storeview_ids] | 157 | store_ids = [store.id for store in external_session.sync_from_object.storeview_ids] |
690 | @@ -143,5 +183,217 @@ | |||
691 | 143 | for resource_id in resource_ids: | 183 | for resource_id in resource_ids: |
692 | 144 | result = address_obj._export_one_resource(cr, uid, external_session, resource_id, context=context) | 184 | result = address_obj._export_one_resource(cr, uid, external_session, resource_id, context=context) |
693 | 145 | return res | 185 | return res |
694 | 186 | ======= | ||
695 | 187 | def _import_magento_addresses(self, cr, uid, connection, ext_customer_id, | ||
696 | 188 | referential_id, context=None): | ||
697 | 189 | """ | ||
698 | 190 | Import all the magento addresses of a magento customer's address book | ||
699 | 191 | |||
700 | 192 | :param connection: connection to Magento | ||
701 | 193 | :param int ext_customer_id: id on Magento of the customer | ||
702 | 194 | :param int referential_id: id of the Magento external referential | ||
703 | 195 | """ | ||
704 | 196 | if context is None: | ||
705 | 197 | context = {} | ||
706 | 198 | address_obj = self.pool.get('res.partner.address') | ||
707 | 199 | import_ctx = context.copy() | ||
708 | 200 | import_ctx['ids_or_filter'] = [ext_customer_id] | ||
709 | 201 | defaults = {'magento_address_book': True} | ||
710 | 202 | return address_obj.get_external_data( | ||
711 | 203 | cr, uid, connection, referential_id, | ||
712 | 204 | defaults=defaults, context=import_ctx) | ||
713 | 205 | |||
714 | 206 | def _disable_missing_addresses(self, cr, uid, partner_id, curr_address_ids, | ||
715 | 207 | referential_id, context=None): | ||
716 | 208 | """ | ||
717 | 209 | Disable the addresses of the partner which have been deleted on | ||
718 | 210 | Magento since last synchronization. | ||
719 | 211 | |||
720 | 212 | :param int partner_id: id of the partner for whom we | ||
721 | 213 | update the addresses | ||
722 | 214 | :param list curr_address_ids: list of openerp ids of the addresses | ||
723 | 215 | which currently exist in the magento address book | ||
724 | 216 | :param int referential_id: id of the Magento external referential | ||
725 | 217 | :return: True | ||
726 | 218 | """ | ||
727 | 219 | # list of the all the addresses in openerp which have been imported | ||
728 | 220 | # from this referential | ||
729 | 221 | address_obj = self.pool.get('res.partner.address') | ||
730 | 222 | partner_address_ids = address_obj.search( | ||
731 | 223 | cr, uid, [('partner_id', '=', partner_id)], context=context) | ||
732 | 224 | all_ref_address_ids = \ | ||
733 | 225 | [address_id for address_id in partner_address_ids | ||
734 | 226 | if address_obj.oeid_to_extid( | ||
735 | 227 | cr, uid, address_id, referential_id, context=context)] | ||
736 | 228 | |||
737 | 229 | # do a diff to know which addresses does not anymore exist | ||
738 | 230 | # on Magento | ||
739 | 231 | del_address_ids = set(all_ref_address_ids).difference(curr_address_ids) | ||
740 | 232 | address_obj.write( | ||
741 | 233 | cr, uid, del_address_ids, {'active': False}, context=context) | ||
742 | 234 | return True | ||
743 | 235 | |||
744 | 236 | def import_magento_address_book(self, cr, uid, ids, referential_id, | ||
745 | 237 | context=None): | ||
746 | 238 | """ | ||
747 | 239 | Import all the addresses from the Magento referential's address book | ||
748 | 240 | Deactivate the addresses which have been deleted from Magento | ||
749 | 241 | since the last import. | ||
750 | 242 | |||
751 | 243 | :param int/list ids: ids or list of ids of partner to import the | ||
752 | 244 | address book | ||
753 | 245 | :param int referential_id: id of the Magento external referential | ||
754 | 246 | """ | ||
755 | 247 | if context is None: | ||
756 | 248 | context = {} | ||
757 | 249 | |||
758 | 250 | if isinstance(ids, (int, long)): | ||
759 | 251 | ids = [ids] | ||
760 | 252 | |||
761 | 253 | ref_obj = self.pool.get('external.referential') | ||
762 | 254 | connection = context.get('conn_obj') or \ | ||
763 | 255 | ref_obj.external_connection( | ||
764 | 256 | cr, uid, referential_id, context=context) | ||
765 | 257 | |||
766 | 258 | for partner_id in ids: | ||
767 | 259 | ext_customer_id = self.oeid_to_extid( | ||
768 | 260 | cr, uid, partner_id, referential_id, context=context) | ||
769 | 261 | |||
770 | 262 | result = self._import_magento_addresses( | ||
771 | 263 | cr, uid, connection, ext_customer_id, referential_id, | ||
772 | 264 | context=context) | ||
773 | 265 | |||
774 | 266 | # list of all addresses currently in the magento address book | ||
775 | 267 | curr_address_ids = result['create_ids'] + result['write_ids'] | ||
776 | 268 | self._disable_missing_addresses( | ||
777 | 269 | cr, uid, partner_id, curr_address_ids, referential_id, | ||
778 | 270 | context=context) | ||
779 | 271 | |||
780 | 272 | return True | ||
781 | 273 | |||
782 | 274 | def add_magento_vat_number(self, cr, uid, partner_id, tax_vat, country_code=None, context=None): | ||
783 | 275 | """Adds vat number (country code+magento vat) if base_vat module is installed and Magento sends customer_taxvat | ||
784 | 276 | TODO replace me by a generic function maybe the best solution will to have a field vat and a flag vat_ok and a flag force vat_ok | ||
785 | 277 | And so it's will be possible to have an invalid vat number (imported from magento for exemple) but the flag will be not set | ||
786 | 278 | Also we should think about the way to update customer. Indeed by default there are never updated""" | ||
787 | 279 | partner_vals = {'mag_vat': tax_vat} | ||
788 | 280 | cr.execute('select * from ir_module_module where name=%s and state=%s', ('base_vat','installed')) | ||
789 | 281 | if cr.fetchone(): | ||
790 | 282 | allchars = string.maketrans('', '') | ||
791 | 283 | delchars = ''.join([c for c in allchars if c not in string.letters + string.digits]) | ||
792 | 284 | vat = tax_vat.translate(allchars, delchars).upper() | ||
793 | 285 | vat_country, vat_number = vat[:2].lower(), vat[2:] | ||
794 | 286 | vat_ok = False | ||
795 | 287 | if 'check_vat_' + vat_country in dir(self): | ||
796 | 288 | check = getattr(self, 'check_vat_' + vat_country) | ||
797 | 289 | vat_ok = check(vat_number) | ||
798 | 290 | else: | ||
799 | 291 | # Maybe magento vat number has not country code prefix. Take it from billing address. | ||
800 | 292 | if country_code: | ||
801 | 293 | fnct = 'check_vat_' + country_code.lower() | ||
802 | 294 | if fnct in dir(self): | ||
803 | 295 | check = getattr(self, fnct) | ||
804 | 296 | vat_ok = check(vat) | ||
805 | 297 | vat = country_code + vat | ||
806 | 298 | else: | ||
807 | 299 | vat_ok = False | ||
808 | 300 | if vat_ok: | ||
809 | 301 | partner_vals.update({'vat_subjected':True, 'vat':vat}) | ||
810 | 302 | self.write(cr, uid, [partner_id], partner_vals) | ||
811 | 303 | return True | ||
812 | 304 | |||
813 | 305 | def write(self, cr, uid, ids, vals, context=None): | ||
814 | 306 | if isinstance(ids, (int, long)): | ||
815 | 307 | ids = [ids] | ||
816 | 308 | if vals.get('store_id') and not vals.get('store_ids'): | ||
817 | 309 | for partner_id in ids: | ||
818 | 310 | # Add the last store id visited if | ||
819 | 311 | # it is not in the list of store ids | ||
820 | 312 | # partner store_id = last store where he bought (so this order) | ||
821 | 313 | # partner store_ids = all stores where he bought | ||
822 | 314 | atomic_vals = copy.deepcopy(vals) | ||
823 | 315 | partner = self.browse(cr, uid, partner_id, context=context) | ||
824 | 316 | if partner.store_id: | ||
825 | 317 | last_store_id = partner.store_id.id | ||
826 | 318 | if last_store_id not in [st.id for st in partner.store_ids]: | ||
827 | 319 | atomic_vals['store_ids'] = [(4, last_store_id)] | ||
828 | 320 | |||
829 | 321 | super(res_partner, self).write( | ||
830 | 322 | cr, uid, partner_id, atomic_vals, context=context) | ||
831 | 323 | else: | ||
832 | 324 | return super(res_partner, self).write( | ||
833 | 325 | cr, uid, ids, vals, context=context) | ||
834 | 326 | return True | ||
835 | 327 | |||
836 | 328 | def create(self, cr, uid, vals, context=None): | ||
837 | 329 | if vals.get('store_id') and not vals.get('store_ids'): | ||
838 | 330 | vals['store_ids'] = [(4, vals['store_id'])] | ||
839 | 331 | return super(res_partner, self).create(cr, uid, vals, context=context) | ||
840 | 332 | |||
841 | 333 | def search_magento_partner(self, cr, uid, magento_email, website_id, is_bound=None, context=None): | ||
842 | 334 | """ | ||
843 | 335 | Searches and returns the partners which are potentially the same | ||
844 | 336 | based on the mail and the magento website id | ||
845 | 337 | |||
846 | 338 | :param str magento_email: mail of the customer on magento | ||
847 | 339 | :param int website_id: id of the website (openerp id!) | ||
848 | 340 | :param bool is_bound: specify it the partner must already be bound | ||
849 | 341 | with a magento customer (True) or not (False) | ||
850 | 342 | When None value: all partners ids are returned | ||
851 | 343 | :return: id of the found partner or False if any partner's found | ||
852 | 344 | """ | ||
853 | 345 | partner_ids = False | ||
854 | 346 | if website_id: | ||
855 | 347 | partner_ids = self.search(cr, uid, | ||
856 | 348 | [('emailid', '=', magento_email), | ||
857 | 349 | ('website_id', '=', website_id)], | ||
858 | 350 | context=context) | ||
859 | 351 | |||
860 | 352 | # when the partner has been created, the website is not necessarily | ||
861 | 353 | # filled, in such case we search the first occurrence | ||
862 | 354 | # with the same email not already bound with a magento customer | ||
863 | 355 | if not partner_ids: | ||
864 | 356 | partner_ids = self.search(cr, uid, | ||
865 | 357 | [('emailid', '=', magento_email), | ||
866 | 358 | ('website_id', '=', False)], | ||
867 | 359 | context=context) | ||
868 | 360 | # keep or exclude already bound partners according to argument is_bound | ||
869 | 361 | if is_bound is not None: | ||
870 | 362 | partner_ids = [partner.id for partner | ||
871 | 363 | in self.browse(cr, uid, partner_ids[:], context=context) | ||
872 | 364 | if bool(partner.magento_exported) is is_bound] | ||
873 | 365 | |||
874 | 366 | return partner_ids and partner_ids[0] or False | ||
875 | 367 | |||
876 | 368 | def _existing_oeid_for_extid_import(self, cr, uid, vals, external_id, external_referential_id, context=None): | ||
877 | 369 | """ | ||
878 | 370 | When importing a new customer from Magento (no external_id found in ir.model.data), we search | ||
879 | 371 | for a partner with the same emailid and website than the imported one | ||
880 | 372 | (fields must be filled in advance). | ||
881 | 373 | |||
882 | 374 | The external customer will update the partner returned in the tuple. | ||
883 | 375 | The external id will be created on this partner with the external resource | ||
884 | 376 | if the value is False in the tuple. | ||
885 | 377 | |||
886 | 378 | :param dict vals: vals to create in OpenERP, already evaluated by oevals_from_extdata | ||
887 | 379 | :param int external_id: external id of the resource to create | ||
888 | 380 | :param int external_referential_id: external referential id from where we import the resource | ||
889 | 381 | :return: tuple of (ir.model.data id / False: external id to create, model resource id / False: resource to create) | ||
890 | 382 | """ | ||
891 | 383 | existing_ir_model_data_id, existing_res_id = super(res_partner, self)\ | ||
892 | 384 | ._existing_oeid_for_extid_import(cr, uid, vals, external_id, external_referential_id, context=context) | ||
893 | 385 | |||
894 | 386 | if existing_res_id: | ||
895 | 387 | return existing_ir_model_data_id, existing_res_id | ||
896 | 388 | |||
897 | 389 | partner_id = self.search_magento_partner( | ||
898 | 390 | cr, uid, | ||
899 | 391 | vals['emailid'], | ||
900 | 392 | vals.get('website_id', False), | ||
901 | 393 | is_bound=None, | ||
902 | 394 | context=context) | ||
903 | 395 | |||
904 | 396 | return False, partner_id | ||
905 | 397 | >>>>>>> MERGE-SOURCE | ||
906 | 146 | 398 | ||
907 | 147 | res_partner() | 399 | res_partner() |
908 | 148 | 400 | ||
909 | === modified file 'magentoerpconnect/partner_view.xml' | |||
910 | --- magentoerpconnect/partner_view.xml 2012-05-19 13:37:23 +0000 | |||
911 | +++ magentoerpconnect/partner_view.xml 2012-07-06 14:53:18 +0000 | |||
912 | @@ -7,11 +7,15 @@ | |||
913 | 7 | <field name="type">form</field> | 7 | <field name="type">form</field> |
914 | 8 | <field name="inherit_id" ref="base.view_partner_form" /> | 8 | <field name="inherit_id" ref="base.view_partner_form" /> |
915 | 9 | <field name="arch" type="xml"> | 9 | <field name="arch" type="xml"> |
916 | 10 | <<<<<<< TREE | ||
917 | 10 | <xpath expr="/form/notebook/page/field/form/group/field[@name='name']" position="replace" > | 11 | <xpath expr="/form/notebook/page/field/form/group/field[@name='name']" position="replace" > |
918 | 11 | <field name="company" /> | 12 | <field name="company" /> |
919 | 12 | <field name="firstname" /> | 13 | <field name="firstname" /> |
920 | 13 | <field name="lastname" /> | 14 | <field name="lastname" /> |
921 | 14 | </xpath> | 15 | </xpath> |
922 | 16 | ======= | ||
923 | 17 | <data> | ||
924 | 18 | >>>>>>> MERGE-SOURCE | ||
925 | 15 | <xpath expr="/form/notebook" position="inside"> | 19 | <xpath expr="/form/notebook" position="inside"> |
926 | 16 | <page string="Magento Information"> | 20 | <page string="Magento Information"> |
927 | 17 | <field name="magento_exported" invisible="True"/> | 21 | <field name="magento_exported" invisible="True"/> |
928 | @@ -23,11 +27,19 @@ | |||
929 | 23 | <field name="mag_birthday" /> | 27 | <field name="mag_birthday" /> |
930 | 24 | <field name="mag_newsletter" select="2"/> | 28 | <field name="mag_newsletter" select="2"/> |
931 | 25 | <field name="store_id" /> | 29 | <field name="store_id" /> |
932 | 30 | <field name="is_magento_guest"/> | ||
933 | 26 | <newline/> | 31 | <newline/> |
934 | 27 | <separator string="Store views" colspan="4" /> | 32 | <separator string="Store views" colspan="4" /> |
935 | 28 | <field name="store_ids" colspan="4" nolabel="1" attrs="{'readonly': [('magento_exported', '=', True)]}"/> | 33 | <field name="store_ids" colspan="4" nolabel="1" attrs="{'readonly': [('magento_exported', '=', True)]}"/> |
936 | 29 | </page> | 34 | </page> |
937 | 30 | </xpath> | 35 | </xpath> |
938 | 36 | <xpath expr="//tree[@string='Partner Contacts']/field[@name='email']" position="after"> | ||
939 | 37 | <field name="magento_address_book"/> | ||
940 | 38 | </xpath> | ||
941 | 39 | <xpath expr="//form[@string='Partner Contacts']/group[3]/field[@name='email']" position="after"> | ||
942 | 40 | <field name="magento_address_book"/> | ||
943 | 41 | </xpath> | ||
944 | 42 | </data> | ||
945 | 31 | </field> | 43 | </field> |
946 | 32 | </record> | 44 | </record> |
947 | 33 | 45 | ||
948 | @@ -50,11 +62,37 @@ | |||
949 | 50 | <field name="type">form</field> | 62 | <field name="type">form</field> |
950 | 51 | <field name="inherit_id" ref="base.view_partner_address_form1" /> | 63 | <field name="inherit_id" ref="base.view_partner_address_form1" /> |
951 | 52 | <field name="arch" type="xml"> | 64 | <field name="arch" type="xml"> |
952 | 65 | <<<<<<< TREE | ||
953 | 53 | <field name="name" position="replace"> | 66 | <field name="name" position="replace"> |
954 | 54 | <field name="company" /> | 67 | <field name="company" /> |
955 | 55 | <field name="firstname" /> | 68 | <field name="firstname" /> |
956 | 56 | <field name="lastname" /> | 69 | <field name="lastname" /> |
957 | 57 | </field> | 70 | </field> |
958 | 71 | ======= | ||
959 | 72 | <data> | ||
960 | 73 | <field name="active" position="after"> | ||
961 | 74 | <field name="magento_address_book"/> | ||
962 | 75 | </field> | ||
963 | 76 | <field name="name" position="after"> | ||
964 | 77 | <field name="firstname" /> | ||
965 | 78 | <field name="lastname" /> | ||
966 | 79 | </field> | ||
967 | 80 | </data> | ||
968 | 81 | </field> | ||
969 | 82 | </record> | ||
970 | 83 | |||
971 | 84 | <record id="view_partner_address_tree_mag" model="ir.ui.view"> | ||
972 | 85 | <field name="name">res.partner.address.tree.mag</field> | ||
973 | 86 | <field name="model">res.partner.address</field> | ||
974 | 87 | <field name="inherit_id" ref="base.view_partner_address_tree"/> | ||
975 | 88 | <field name="type">tree</field> | ||
976 | 89 | <field name="arch" type="xml"> | ||
977 | 90 | <data> | ||
978 | 91 | <field name="type" position="after"> | ||
979 | 92 | <field name="magento_address_book"/> | ||
980 | 93 | </field> | ||
981 | 94 | </data> | ||
982 | 95 | >>>>>>> MERGE-SOURCE | ||
983 | 58 | </field> | 96 | </field> |
984 | 59 | </record> | 97 | </record> |
985 | 60 | 98 | ||
986 | 61 | 99 | ||
987 | === modified file 'magentoerpconnect/product.py' | |||
988 | --- magentoerpconnect/product.py 2012-05-25 19:24:00 +0000 | |||
989 | +++ magentoerpconnect/product.py 2012-07-06 14:53:18 +0000 | |||
990 | @@ -28,9 +28,14 @@ | |||
991 | 28 | import pooler | 28 | import pooler |
992 | 29 | import magerp_osv | 29 | import magerp_osv |
993 | 30 | from tools.translate import _ | 30 | from tools.translate import _ |
994 | 31 | <<<<<<< TREE | ||
995 | 32 | ======= | ||
996 | 33 | import logging | ||
997 | 34 | >>>>>>> MERGE-SOURCE | ||
998 | 31 | import unicodedata | 35 | import unicodedata |
999 | 32 | import base64, urllib | 36 | import base64, urllib |
1000 | 33 | import os | 37 | import os |
1001 | 38 | import xmlrpclib | ||
1002 | 34 | from lxml import etree | 39 | from lxml import etree |
1003 | 35 | import xmlrpclib | 40 | import xmlrpclib |
1004 | 36 | 41 | ||
1005 | @@ -175,7 +180,7 @@ | |||
1006 | 175 | 'description': fields.text('Description'), | 180 | 'description': fields.text('Description'), |
1007 | 176 | 'image': fields.binary('Image'), | 181 | 'image': fields.binary('Image'), |
1008 | 177 | 'image_name':fields.char('File Name', size=100), | 182 | 'image_name':fields.char('File Name', size=100), |
1010 | 178 | 'meta_title': fields.char('Title (Meta)', size=75), | 183 | 'meta_title': fields.char('Title (Meta)', size=255), |
1011 | 179 | 'meta_keywords': fields.text('Meta Keywords'), | 184 | 'meta_keywords': fields.text('Meta Keywords'), |
1012 | 180 | 'meta_description': fields.text('Meta Description'), | 185 | 'meta_description': fields.text('Meta Description'), |
1013 | 181 | 'url_key': fields.char('URL-key', size=100), #Readonly | 186 | 'url_key': fields.char('URL-key', size=100), #Readonly |
1014 | @@ -209,6 +214,7 @@ | |||
1015 | 209 | vals['magerp_stamp'] = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) | 214 | vals['magerp_stamp'] = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) |
1016 | 210 | return super(product_category, self).write(cr, uid, ids, vals, context) | 215 | return super(product_category, self).write(cr, uid, ids, vals, context) |
1017 | 211 | 216 | ||
1018 | 217 | <<<<<<< TREE | ||
1019 | 212 | def _get_external_resource_ids(self, cr, uid, external_session, resource_filter=None, mapping=None, context=None): | 218 | def _get_external_resource_ids(self, cr, uid, external_session, resource_filter=None, mapping=None, context=None): |
1020 | 213 | def get_child_ids(tree): | 219 | def get_child_ids(tree): |
1021 | 214 | result=[] | 220 | result=[] |
1022 | @@ -222,6 +228,77 @@ | |||
1023 | 222 | categ_tree = external_session.connection.call('catalog_category.tree') #Get the tree | 228 | categ_tree = external_session.connection.call('catalog_category.tree') #Get the tree |
1024 | 223 | ids = get_child_ids(categ_tree) | 229 | ids = get_child_ids(categ_tree) |
1025 | 224 | return ids | 230 | return ids |
1026 | 231 | ======= | ||
1027 | 232 | def record_entire_tree(self, cr, uid, id, conn, categ_tree, DEBUG=False): | ||
1028 | 233 | self.record_category(cr, uid, id, conn, int(categ_tree['category_id'])) | ||
1029 | 234 | for each in categ_tree['children']: | ||
1030 | 235 | self.record_entire_tree(cr, uid, id, conn, each) | ||
1031 | 236 | return True | ||
1032 | 237 | |||
1033 | 238 | def record_category(self, cr, uid, external_referential_id, conn, category_id): | ||
1034 | 239 | #This function should record a category | ||
1035 | 240 | #The parent has to be created before creating child | ||
1036 | 241 | imp_vals = conn.call('category.info', [category_id]) | ||
1037 | 242 | self.ext_import(cr, uid, [imp_vals], external_referential_id, defaults={}, context={'conn_obj':conn}) | ||
1038 | 243 | |||
1039 | 244 | def ext_export(self, cr, uid, ids, external_referential_ids=None, defaults=None, context=None): # We export all the categories if at least one has been modified since last export | ||
1040 | 245 | #TODO Move this function in base_sale_multichannels | ||
1041 | 246 | if context is None: | ||
1042 | 247 | context = {} | ||
1043 | 248 | |||
1044 | 249 | if defaults is None: | ||
1045 | 250 | defaults = {} | ||
1046 | 251 | |||
1047 | 252 | res = False | ||
1048 | 253 | orig_ids = ids[:] | ||
1049 | 254 | ids_exportable = self.search(cr, uid, [('id', 'in', ids), ('magento_exportable', '=', True)]) #restrict export to only exportable products | ||
1050 | 255 | ids = [id for id in ids if id in ids_exportable] #we need to keep the order of the categories | ||
1051 | 256 | if not ids: | ||
1052 | 257 | logger = logging.getLogger('magentoerpconnect') | ||
1053 | 258 | logger.warning('called ext_export with ids %s, of which none were exportable', orig_ids) | ||
1054 | 259 | return res | ||
1055 | 260 | |||
1056 | 261 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id']) | ||
1057 | 262 | |||
1058 | 263 | context_dic = [context.copy()] | ||
1059 | 264 | context_dic[0]['export_url'] = True # for the magento version 1.3.2.4, only one url is autorized by category, so we only export with the MAPPING TEMPLATE the url of the default language | ||
1060 | 265 | context_dic[0]['lang'] = shop.referential_id.default_lang_id.code | ||
1061 | 266 | |||
1062 | 267 | for storeview in shop.storeview_ids: | ||
1063 | 268 | if storeview.lang_id and storeview.lang_id.code != shop.referential_id.default_lang_id.code: | ||
1064 | 269 | context_dic += [context.copy()] | ||
1065 | 270 | context_dic[len(context_dic)-1].update({'storeview_code': storeview.code, 'lang': storeview.lang_id.code}) | ||
1066 | 271 | |||
1067 | 272 | if shop.last_products_export_date and not context.get('force_export'): | ||
1068 | 273 | last_exported_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(shop.last_products_export_date[:19], DEFAULT_SERVER_DATETIME_FORMAT))) | ||
1069 | 274 | else: | ||
1070 | 275 | last_exported_time = False | ||
1071 | 276 | |||
1072 | 277 | if not last_exported_time: | ||
1073 | 278 | for ctx_storeview in context_dic: | ||
1074 | 279 | ctx_storeview['force'] = True | ||
1075 | 280 | res = super(product_category, self).ext_export(cr, uid, ids, external_referential_ids, defaults, ctx_storeview) | ||
1076 | 281 | else: | ||
1077 | 282 | cr.execute("select write_date, create_date from product_category where id in %s", (tuple(ids),)) | ||
1078 | 283 | read = cr.fetchall() | ||
1079 | 284 | for categ in read: | ||
1080 | 285 | last_updated_categ = categ[0] and categ[0].split('.')[0] or categ[1] and categ[1].split('.')[0] or False | ||
1081 | 286 | last_updated_categ_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime(last_updated_categ[:19], DEFAULT_SERVER_DATETIME_FORMAT))) | ||
1082 | 287 | if last_updated_categ_time and last_exported_time: | ||
1083 | 288 | if last_exported_time - datetime.timedelta(seconds=1) < last_updated_categ_time: | ||
1084 | 289 | for ctx_storeview in context_dic: | ||
1085 | 290 | ctx_storeview['force'] = True | ||
1086 | 291 | res = super(product_category, self).ext_export(cr, uid, ids, external_referential_ids, defaults, ctx_storeview) | ||
1087 | 292 | break | ||
1088 | 293 | return res | ||
1089 | 294 | |||
1090 | 295 | def try_ext_update(self, cr, uid, data, conn, method, oe_id, external_id, ir_model_data_id, create_method, context=None): | ||
1091 | 296 | if context is None: context = {} | ||
1092 | 297 | if context.get('storeview_code', False): | ||
1093 | 298 | return conn.call(method, [external_id, data, context.get('storeview_code', False)]) | ||
1094 | 299 | else: | ||
1095 | 300 | return conn.call(method, [external_id, data]) | ||
1096 | 301 | >>>>>>> MERGE-SOURCE | ||
1097 | 225 | 302 | ||
1098 | 226 | product_category() | 303 | product_category() |
1099 | 227 | 304 | ||
1100 | @@ -255,6 +332,7 @@ | |||
1101 | 255 | ('gallery', 'Gallery'), | 332 | ('gallery', 'Gallery'), |
1102 | 256 | ('weee', 'Fixed Product Tax'), | 333 | ('weee', 'Fixed Product Tax'), |
1103 | 257 | ('file', 'File'), #this option is not a magento native field it will be better to found a generic solutionto manage this kind of custom option | 334 | ('file', 'File'), #this option is not a magento native field it will be better to found a generic solutionto manage this kind of custom option |
1104 | 335 | ('weight', 'Weight'), | ||
1105 | 258 | ], 'Frontend Input' | 336 | ], 'Frontend Input' |
1106 | 259 | ), | 337 | ), |
1107 | 260 | 'frontend_class':fields.char('Frontend Class', size=100), | 338 | 'frontend_class':fields.char('Frontend Class', size=100), |
1108 | @@ -290,13 +368,20 @@ | |||
1109 | 290 | #These parameters are for automatic management | 368 | #These parameters are for automatic management |
1110 | 291 | 'field_name':fields.char('Open ERP Field name', size=100), | 369 | 'field_name':fields.char('Open ERP Field name', size=100), |
1111 | 292 | 'attribute_set_info':fields.text('Attribute Set Information'), | 370 | 'attribute_set_info':fields.text('Attribute Set Information'), |
1113 | 293 | 'based_on':fields.selection([('product_product', 'Product Product'), ('product_template', 'Product Template')], 'Based On'), | 371 | 'based_on':fields.selection([('product.product', 'Product Product'), ('product.template', 'Product Template')], 'Based On'), |
1114 | 294 | } | 372 | } |
1115 | 295 | 373 | ||
1116 | 296 | _defaults = { | 374 | _defaults = { |
1118 | 297 | 'based_on': lambda*a: 'product_template', | 375 | 'based_on': lambda*a: 'product.template', |
1119 | 298 | } | 376 | } |
1120 | 299 | 377 | ||
1121 | 378 | def init(self, cr): | ||
1122 | 379 | """ Replace product_product by product.product | ||
1123 | 380 | and product_template by product.template for | ||
1124 | 381 | consistency with model names""" | ||
1125 | 382 | cr.execute("UPDATE magerp_product_attributes SET based_on = REPLACE(based_on, '_', '.')") | ||
1126 | 383 | cr.execute("UPDATE magerp_product_attributes SET based_on = 'product.template' WHERE based_on IS NULL") | ||
1127 | 384 | |||
1128 | 300 | #mapping magentofield:(openerpfield,typecast,) | 385 | #mapping magentofield:(openerpfield,typecast,) |
1129 | 301 | #have an entry for each mapped field | 386 | #have an entry for each mapped field |
1130 | 302 | _no_create_list = [ | 387 | _no_create_list = [ |
1131 | @@ -372,6 +457,7 @@ | |||
1132 | 372 | 'visibility', | 457 | 'visibility', |
1133 | 373 | ] | 458 | ] |
1134 | 374 | 459 | ||
1135 | 460 | <<<<<<< TREE | ||
1136 | 375 | 461 | ||
1137 | 376 | #TODO check if this field have to be in only one way and if yes add this feature | 462 | #TODO check if this field have to be in only one way and if yes add this feature |
1138 | 377 | _sync_way = { | 463 | _sync_way = { |
1139 | @@ -382,19 +468,25 @@ | |||
1140 | 382 | def _is_attribute_translatable(self, vals): | 468 | def _is_attribute_translatable(self, vals): |
1141 | 383 | """Tells if field associated to attribute should be translatable or not. | 469 | """Tells if field associated to attribute should be translatable or not. |
1142 | 384 | For now we are using a default list, later we could say that any attribute | 470 | For now we are using a default list, later we could say that any attribute |
1143 | 471 | ======= | ||
1144 | 472 | MODEL_SERIALIZED_FIELD = { | ||
1145 | 473 | 'product.template': 'magerp_tmpl', | ||
1146 | 474 | 'product.product': 'magerp_variant', | ||
1147 | 475 | } | ||
1148 | 476 | |||
1149 | 477 | def _is_attribute_translatable(self, attribute): | ||
1150 | 478 | """Tells if field associated to attribute | ||
1151 | 479 | should be translatable or not. | ||
1152 | 480 | For now we are using a default list, | ||
1153 | 481 | later we could say that any attribute | ||
1154 | 482 | >>>>>>> MERGE-SOURCE | ||
1155 | 385 | which scope in Magento is 'store' should be translated.""" | 483 | which scope in Magento is 'store' should be translated.""" |
1167 | 386 | if vals['attribute_code'] in self._translatable_default_codes: | 484 | return bool(attribute.attribute_code in self._translatable_default_codes) |
1168 | 387 | return True | 485 | |
1169 | 388 | else: | 486 | def create_ir_fields(self, cr, uid, ids, update_options=False, context=None): |
1170 | 389 | return False | 487 | if isinstance(ids, (int, long)): |
1160 | 390 | |||
1161 | 391 | def write(self, cr, uid, ids, vals, context=None): | ||
1162 | 392 | """Will recreate the mapping attributes, beware if you customized some!""" | ||
1163 | 393 | if context is None: | ||
1164 | 394 | context = {} | ||
1165 | 395 | |||
1166 | 396 | if type(ids) == int: | ||
1171 | 397 | ids = [ids] | 488 | ids = [ids] |
1172 | 489 | <<<<<<< TREE | ||
1173 | 398 | result = super(magerp_product_attributes, self).write(cr, uid, ids, vals, context) | 490 | result = super(magerp_product_attributes, self).write(cr, uid, ids, vals, context) |
1174 | 399 | model_ids = self.pool.get('ir.model').search(cr, uid, [('model', 'in', ['product.product', 'product.template'])]) | 491 | model_ids = self.pool.get('ir.model').search(cr, uid, [('model', 'in', ['product.product', 'product.template'])]) |
1175 | 400 | product_model_id = self.pool.get('ir.model').search(cr, uid, [('model', 'in', ['product.product'])])[0] | 492 | product_model_id = self.pool.get('ir.model').search(cr, uid, [('model', 'in', ['product.product'])])[0] |
1176 | @@ -402,11 +494,26 @@ | |||
1177 | 402 | for id in ids: | 494 | for id in ids: |
1178 | 403 | all_vals = self.read(cr, uid, id, [], context) | 495 | all_vals = self.read(cr, uid, id, [], context) |
1179 | 404 | 496 | ||
1180 | 497 | ======= | ||
1181 | 498 | |||
1182 | 499 | for attribute in self.browse(cr, uid, ids, context=context): | ||
1183 | 500 | if attribute.attribute_code in self._no_create_list: | ||
1184 | 501 | continue | ||
1185 | 502 | >>>>>>> MERGE-SOURCE | ||
1186 | 405 | #Fetch Options | 503 | #Fetch Options |
1187 | 504 | <<<<<<< TREE | ||
1188 | 406 | if 'frontend_input' in all_vals.keys() and all_vals['frontend_input'] in ['select', 'multiselect']: | 505 | if 'frontend_input' in all_vals.keys() and all_vals['frontend_input'] in ['select', 'multiselect']: |
1189 | 407 | core_imp_conn = self.pool.get('external.referential').external_connection(cr, uid, [referential_id]) | 506 | core_imp_conn = self.pool.get('external.referential').external_connection(cr, uid, [referential_id]) |
1190 | 408 | options_data = core_imp_conn.call('ol_catalog_product_attribute.options', [all_vals['magento_id']]) | 507 | options_data = core_imp_conn.call('ol_catalog_product_attribute.options', [all_vals['magento_id']]) |
1191 | 508 | ======= | ||
1192 | 509 | if attribute.frontend_input in ['select', 'multiselect']: | ||
1193 | 510 | core_imp_conn = self.pool.get('external.referential').connect( | ||
1194 | 511 | cr, uid, [attribute.referential_id.id]) | ||
1195 | 512 | options_data = core_imp_conn.call( | ||
1196 | 513 | 'ol_catalog_product_attribute.options', [attribute.magento_id]) | ||
1197 | 514 | >>>>>>> MERGE-SOURCE | ||
1198 | 409 | if options_data: | 515 | if options_data: |
1199 | 516 | <<<<<<< TREE | ||
1200 | 410 | self.pool.get('magerp.product_attribute_options').data_to_save(cr, uid, options_data, update=True, context={'attribute_id': id, 'referential_id': referential_id}) | 517 | self.pool.get('magerp.product_attribute_options').data_to_save(cr, uid, options_data, update=True, context={'attribute_id': id, 'referential_id': referential_id}) |
1201 | 411 | 518 | ||
1202 | 412 | 519 | ||
1203 | @@ -415,20 +522,123 @@ | |||
1204 | 415 | field_ids = self.pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', 'in', model_ids)]) | 522 | field_ids = self.pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', 'in', model_ids)]) |
1205 | 416 | if field_ids: | 523 | if field_ids: |
1206 | 417 | self._create_mapping(cr, uid, self._type_conversion[all_vals.get('frontend_input', False)], field_ids[0], field_name, referential_id, product_model_id, all_vals, id) | 524 | self._create_mapping(cr, uid, self._type_conversion[all_vals.get('frontend_input', False)], field_ids[0], field_name, referential_id, product_model_id, all_vals, id) |
1207 | 525 | ======= | ||
1208 | 526 | options_obj = self.pool.get('magerp.product_attribute_options') | ||
1209 | 527 | ctx_opt = dict(context, | ||
1210 | 528 | attribute_id=attribute.id, | ||
1211 | 529 | referential_id=attribute.referential_id.id) | ||
1212 | 530 | options_obj.data_to_save( | ||
1213 | 531 | cr, uid, options_data, | ||
1214 | 532 | update=update_options, | ||
1215 | 533 | context=ctx_opt) | ||
1216 | 534 | |||
1217 | 535 | # Create fields in ir.model.data if it does not already exist | ||
1218 | 536 | # Create the field accordingly to the "based_on" | ||
1219 | 537 | # configuration of the attribute (product.product or product.template) | ||
1220 | 538 | if attribute.attribute_code and attribute.frontend_input: | ||
1221 | 539 | model_ids = self.pool.get('ir.model').search( | ||
1222 | 540 | cr, uid, [('model', '=', attribute.based_on)], context=context) | ||
1223 | 541 | |||
1224 | 542 | fields_obj = self.pool.get('ir.model.fields') | ||
1225 | 543 | # Check if field already exists | ||
1226 | 544 | field_ids = fields_obj.search( | ||
1227 | 545 | cr, uid, | ||
1228 | 546 | [('name', '=', attribute.field_name), | ||
1229 | 547 | ('model', '=', attribute.based_on)], | ||
1230 | 548 | context=context) | ||
1231 | 549 | field_vals = { | ||
1232 | 550 | 'name': attribute.field_name, | ||
1233 | 551 | 'model_id': model_ids[0], | ||
1234 | 552 | 'model': attribute.based_on, | ||
1235 | 553 | 'field_description': attribute.frontend_label or \ | ||
1236 | 554 | attribute.attribute_code, | ||
1237 | 555 | 'ttype': self._type_conversion[attribute.frontend_input], | ||
1238 | 556 | 'translate': self._is_attribute_translatable(attribute), | ||
1239 | 557 | } | ||
1240 | 558 | if not attribute.attribute_code in self._not_store_in_json: | ||
1241 | 559 | field_vals['serialization_field_id'] = fields_obj.search( | ||
1242 | 560 | cr, uid, | ||
1243 | 561 | [('name', '=', self.MODEL_SERIALIZED_FIELD[attribute.based_on]), | ||
1244 | 562 | ('model', '=', attribute.based_on)], | ||
1245 | 563 | context=context)[0] | ||
1246 | 564 | if not field_ids: | ||
1247 | 565 | #The field is not there create it | ||
1248 | 566 | #IF char add size | ||
1249 | 567 | if field_vals['ttype'] == 'char': | ||
1250 | 568 | field_vals['size'] = 100 | ||
1251 | 569 | elif field_vals['ttype'] == 'many2one': | ||
1252 | 570 | field_vals['relation'] = 'magerp.product_attribute_options' | ||
1253 | 571 | field_vals['domain'] = "[('attribute_id', '=', %s)]" % attribute.id | ||
1254 | 572 | elif field_vals['ttype'] == 'many2many': | ||
1255 | 573 | field_vals['relation'] = 'magerp.product_attribute_options' | ||
1256 | 574 | field_vals['domain'] = "[('attribute_id', '=', %s)]" % attribute.id | ||
1257 | 575 | field_vals['state'] = 'manual' | ||
1258 | 576 | |||
1259 | 577 | #All field values are computed, now save | ||
1260 | 578 | self.pool.get('ir.model.fields').create( | ||
1261 | 579 | cr, uid, field_vals, context=context) | ||
1262 | 580 | return True | ||
1263 | 581 | |||
1264 | 582 | def update_mapping(self, cr, uid, ids, context=None): | ||
1265 | 583 | """Create mappings for the attributes | ||
1266 | 584 | if they have a field name | ||
1267 | 585 | and a field in ir.model.data""" | ||
1268 | 586 | if isinstance(ids, (int, long)): | ||
1269 | 587 | ids = [ids] | ||
1270 | 588 | |||
1271 | 589 | for attribute in self.browse(cr, uid, ids, context=context): | ||
1272 | 590 | if not attribute.field_name: | ||
1273 | 591 | continue | ||
1274 | 592 | field_obj = self.pool.get('ir.model.fields') | ||
1275 | 593 | field_ids = field_obj.search( | ||
1276 | 594 | cr, uid, | ||
1277 | 595 | [('name', '=', attribute.field_name), | ||
1278 | 596 | ('model', '=', attribute.based_on)], | ||
1279 | 597 | context=context) | ||
1280 | 598 | if not field_ids: | ||
1281 | 599 | continue | ||
1282 | 600 | field = field_obj.browse( | ||
1283 | 601 | cr, uid, field_ids[0], context=context) | ||
1284 | 602 | self._create_mapping( | ||
1285 | 603 | cr, uid, | ||
1286 | 604 | attribute, | ||
1287 | 605 | field, | ||
1288 | 606 | context=context) | ||
1289 | 607 | return True | ||
1290 | 608 | |||
1291 | 609 | def write(self, cr, uid, ids, vals, context=None): | ||
1292 | 610 | """Will recreate the mapping attributes, | ||
1293 | 611 | beware if you customized some!""" | ||
1294 | 612 | if context is None: | ||
1295 | 613 | context = {} | ||
1296 | 614 | |||
1297 | 615 | if isinstance(ids, (int, long)): | ||
1298 | 616 | ids = [ids] | ||
1299 | 617 | |||
1300 | 618 | result = super(magerp_product_attributes, self).write(cr, uid, ids, vals, context=context) | ||
1301 | 619 | |||
1302 | 620 | self.create_ir_fields( | ||
1303 | 621 | cr, uid, ids, update_options=True, context=context) | ||
1304 | 622 | |||
1305 | 623 | self.update_mapping(cr, uid, ids, context=context) | ||
1306 | 624 | >>>>>>> MERGE-SOURCE | ||
1307 | 418 | return result | 625 | return result |
1308 | 419 | 626 | ||
1309 | 420 | def create(self, cr, uid, vals, context=None): | 627 | def create(self, cr, uid, vals, context=None): |
1311 | 421 | """Will create product.template new fields accordingly to Magento product custom attributes and also create mappings for them""" | 628 | """Will create product.template new fields accordingly |
1312 | 629 | to Magento product custom attributes | ||
1313 | 630 | and also create mappings for them""" | ||
1314 | 422 | if context is None: | 631 | if context is None: |
1315 | 423 | context = {} | 632 | context = {} |
1316 | 424 | if not vals['attribute_code'] in self._no_create_list: | 633 | if not vals['attribute_code'] in self._no_create_list: |
1317 | 425 | field_name = "x_magerp_" + vals['attribute_code'] | 634 | field_name = "x_magerp_" + vals['attribute_code'] |
1318 | 426 | field_name = convert_to_ascii(field_name) | 635 | field_name = convert_to_ascii(field_name) |
1320 | 427 | vals['field_name']= field_name | 636 | vals['field_name'] = field_name |
1321 | 428 | if 'attribute_set_info' in vals.keys(): | 637 | if 'attribute_set_info' in vals.keys(): |
1322 | 429 | attr_set_info = eval(vals.get('attribute_set_info',{})) | 638 | attr_set_info = eval(vals.get('attribute_set_info',{})) |
1323 | 430 | for each_key in attr_set_info.keys(): | 639 | for each_key in attr_set_info.keys(): |
1324 | 431 | vals['group_id'] = attr_set_info[each_key].get('group_id', False) | 640 | vals['group_id'] = attr_set_info[each_key].get('group_id', False) |
1325 | 641 | <<<<<<< TREE | ||
1326 | 432 | 642 | ||
1327 | 433 | crid = super(magerp_product_attributes, self).create(cr, uid, vals, context) | 643 | crid = super(magerp_product_attributes, self).create(cr, uid, vals, context) |
1328 | 434 | if not vals['attribute_code'] in self._no_create_list: | 644 | if not vals['attribute_code'] in self._no_create_list: |
1329 | @@ -494,7 +704,31 @@ | |||
1330 | 494 | #If the field have restriction on domain | 704 | #If the field have restriction on domain |
1331 | 495 | #Maybe we can give the posibility to map directly m2m and m2o field_description | 705 | #Maybe we can give the posibility to map directly m2m and m2o field_description |
1332 | 496 | #by filtrering directly with the domain and the string value | 706 | #by filtrering directly with the domain and the string value |
1333 | 707 | ======= | ||
1334 | 708 | |||
1335 | 709 | # By default some fields should be based on product variants | ||
1336 | 710 | # instead of templates. | ||
1337 | 711 | if vals['attribute_code'] in self._variant_fields: | ||
1338 | 712 | vals['based_on'] = 'product.product' | ||
1339 | 713 | |||
1340 | 714 | attribute_id = super(magerp_product_attributes, self).create( | ||
1341 | 715 | cr, uid, vals, context=context) | ||
1342 | 716 | |||
1343 | 717 | if attribute_id: | ||
1344 | 718 | self.create_ir_fields( | ||
1345 | 719 | cr, uid, | ||
1346 | 720 | attribute_id, | ||
1347 | 721 | update_options=False, | ||
1348 | 722 | context=context) | ||
1349 | 723 | self.update_mapping(cr, uid, attribute_id, context=context) | ||
1350 | 724 | return attribute_id | ||
1351 | 725 | |||
1352 | 726 | def _default_mapping(self, cr, uid, attribute, field, context=None): | ||
1353 | 727 | in_function = out_function = False | ||
1354 | 728 | ttype = field.ttype | ||
1355 | 729 | >>>>>>> MERGE-SOURCE | ||
1356 | 497 | if ttype in ['char', 'text', 'date', 'float', 'weee', 'boolean']: | 730 | if ttype in ['char', 'text', 'date', 'float', 'weee', 'boolean']: |
1357 | 731 | <<<<<<< TREE | ||
1358 | 498 | mapping_line['evaluation_type'] = 'direct' | 732 | mapping_line['evaluation_type'] = 'direct' |
1359 | 499 | if ttype == 'float': | 733 | if ttype == 'float': |
1360 | 500 | mapping_line['external_type'] = 'float' | 734 | mapping_line['external_type'] = 'float' |
1361 | @@ -503,7 +737,12 @@ | |||
1362 | 503 | else: | 737 | else: |
1363 | 504 | mapping_line['external_type'] = 'unicode' | 738 | mapping_line['external_type'] = 'unicode' |
1364 | 505 | 739 | ||
1365 | 740 | ======= | ||
1366 | 741 | in_function = "result = [('%s', ifield)]" % (field.name,) | ||
1367 | 742 | out_function = "result = [('%s', record['%s'])]" % (attribute.attribute_code, field.name) | ||
1368 | 743 | >>>>>>> MERGE-SOURCE | ||
1369 | 506 | elif ttype in ['many2one']: | 744 | elif ttype in ['many2one']: |
1370 | 745 | <<<<<<< TREE | ||
1371 | 507 | mapping_line['evaluation_type'] = 'function' | 746 | mapping_line['evaluation_type'] = 'function' |
1372 | 508 | mapping_line['in_function'] = \ | 747 | mapping_line['in_function'] = \ |
1373 | 509 | ("if '%(attribute_code)s' in resource:\n" | 748 | ("if '%(attribute_code)s' in resource:\n" |
1374 | @@ -518,7 +757,20 @@ | |||
1375 | 518 | " option = self.pool.get('magerp.product_attribute_options').browse(cr, uid, resource['%(field_name)s'][0])\n" | 757 | " option = self.pool.get('magerp.product_attribute_options').browse(cr, uid, resource['%(field_name)s'][0])\n" |
1376 | 519 | " if option:\n" | 758 | " if option:\n" |
1377 | 520 | " result = [('%(attribute_code)s', option.value)]") % ({'field_name': field_name, 'attribute_code': vals['attribute_code']}) | 759 | " result = [('%(attribute_code)s', option.value)]") % ({'field_name': field_name, 'attribute_code': vals['attribute_code']}) |
1378 | 760 | ======= | ||
1379 | 761 | in_function = ("if ifield:\n" | ||
1380 | 762 | " option_id = self.pool.get('magerp.product_attribute_options').search(cr, uid, [('attribute_id','=',%(attribute_id)s),('value','=',ifield)])\n" | ||
1381 | 763 | " if option_id:\n" | ||
1382 | 764 | " result = [('%(field_name)s', option_id[0])]") % ({'attribute_id': attribute.id, 'field_name': field.name}) | ||
1383 | 765 | # we browse on record['%(field_name)s'][0] because record[field_name] is in the form (id, name) | ||
1384 | 766 | out_function = ("result = [('%(attribute_code)s', False)]\n" | ||
1385 | 767 | "if record.get('%(field_name)s'):\n" | ||
1386 | 768 | " option = self.pool.get('magerp.product_attribute_options').browse(cr, uid, record['%(field_name)s'][0])\n" | ||
1387 | 769 | " if option:\n" | ||
1388 | 770 | " result = [('%(attribute_code)s', option.value)]") % ({'field_name': field.name, 'attribute_code': attribute.attribute_code}) | ||
1389 | 771 | >>>>>>> MERGE-SOURCE | ||
1390 | 521 | elif ttype in ['many2many']: | 772 | elif ttype in ['many2many']: |
1391 | 773 | <<<<<<< TREE | ||
1392 | 522 | mapping_line['evaluation_type'] = 'function' | 774 | mapping_line['evaluation_type'] = 'function' |
1393 | 523 | mapping_line['in_function'] = ("option_ids = []\n" | 775 | mapping_line['in_function'] = ("option_ids = []\n" |
1394 | 524 | "opt_obj = self.pool.get('magerp.product_attribute_options')\n" | 776 | "opt_obj = self.pool.get('magerp.product_attribute_options')\n" |
1395 | @@ -530,7 +782,20 @@ | |||
1396 | 530 | " options = self.pool.get('magerp.product_attribute_options').browse(cr, uid, resource['%(field_name)s'])\n" | 782 | " options = self.pool.get('magerp.product_attribute_options').browse(cr, uid, resource['%(field_name)s'])\n" |
1397 | 531 | " result = [('%(attribute_code)s', [option.value for option in options])]") % \ | 783 | " result = [('%(attribute_code)s', [option.value for option in options])]") % \ |
1398 | 532 | ({'field_name': field_name, 'attribute_code': vals['attribute_code']}) | 784 | ({'field_name': field_name, 'attribute_code': vals['attribute_code']}) |
1399 | 785 | ======= | ||
1400 | 786 | in_function = ("option_ids = []\n" | ||
1401 | 787 | "opt_obj = self.pool.get('magerp.product_attribute_options')\n" | ||
1402 | 788 | "for ext_option_id in ifield:\n" | ||
1403 | 789 | " option_ids.extend(opt_obj.search(cr, uid, [('attribute_id','=',%(attribute_id)s), ('value','=',ext_option_id)]))\n" | ||
1404 | 790 | "result = [('%(field_name)s', [(6, 0, option_ids)])]") % ({'attribute_id': attribute.id, 'field_name': field.name}) | ||
1405 | 791 | out_function = ("result=[('%(attribute_code)s', [])]\n" | ||
1406 | 792 | "if record.get('%(field_name)s'):\n" | ||
1407 | 793 | " options = self.pool.get('magerp.product_attribute_options').browse(cr, uid, record['%(field_name)s'])\n" | ||
1408 | 794 | " result = [('%(attribute_code)s', [option.value for option in options])]") % \ | ||
1409 | 795 | ({'field_name': field.name, 'attribute_code': attribute.attribute_code}) | ||
1410 | 796 | >>>>>>> MERGE-SOURCE | ||
1411 | 533 | elif ttype in ['binary']: | 797 | elif ttype in ['binary']: |
1412 | 798 | <<<<<<< TREE | ||
1413 | 534 | warning_text = "Binary mapping is actually not supported (attribute: %s)" % (vals['attribute_code'],) | 799 | warning_text = "Binary mapping is actually not supported (attribute: %s)" % (vals['attribute_code'],) |
1414 | 535 | _logger.warn(warning_text) | 800 | _logger.warn(warning_text) |
1415 | 536 | warning_msg = ("import logging\n" | 801 | warning_msg = ("import logging\n" |
1416 | @@ -538,11 +803,21 @@ | |||
1417 | 538 | "logger.warn('%s')") % (warning_text,) | 803 | "logger.warn('%s')") % (warning_text,) |
1418 | 539 | mapping_line['in_function'] = mapping_line['out_function'] = warning_msg | 804 | mapping_line['in_function'] = mapping_line['out_function'] = warning_msg |
1419 | 540 | return mapping_line | 805 | return mapping_line |
1420 | 806 | ======= | ||
1421 | 807 | logger = logging.getLogger('ext synchro mapping') | ||
1422 | 808 | logger.warn("Binary mapping is actually not supported (attribute: %s)", attribute.attribute_code) | ||
1423 | 809 | warning_msg = ("import logging\n" | ||
1424 | 810 | "logger = logging.getLogger('ext synchro mapping')\n" | ||
1425 | 811 | "logger.warn('Binary mapping is actually not supported (attribute: %%s)', %s)") % (attribute.attribute_code) | ||
1426 | 812 | in_function = out_function = warning_msg | ||
1427 | 813 | return in_function, out_function | ||
1428 | 814 | >>>>>>> MERGE-SOURCE | ||
1429 | 541 | 815 | ||
1433 | 542 | def _create_mapping(self, cr, uid, ttype, field_id, field_name, referential_id, model_id, vals, attribute_id): | 816 | def _create_mapping(self, cr, uid, attribute, field, context=None): |
1434 | 543 | """Search & create mapping entries""" | 817 | """Search and create mapping entries""" |
1435 | 544 | if vals['attribute_code'] in self._no_create_list: | 818 | if attribute.attribute_code in self._no_create_list: |
1436 | 545 | return False | 819 | return False |
1437 | 820 | <<<<<<< TREE | ||
1438 | 546 | mapping_id = self.pool.get('external.mapping').search(cr, uid, [('referential_id', '=', referential_id), ('model_id', '=', model_id)]) | 821 | mapping_id = self.pool.get('external.mapping').search(cr, uid, [('referential_id', '=', referential_id), ('model_id', '=', model_id)]) |
1439 | 547 | if mapping_id: | 822 | if mapping_id: |
1440 | 548 | existing_line = self.pool.get('external.mapping.line').search(cr, uid, [('external_field', '=', vals['attribute_code']), ('mapping_id', '=', mapping_id[0])]) | 823 | existing_line = self.pool.get('external.mapping.line').search(cr, uid, [('external_field', '=', vals['attribute_code']), ('mapping_id', '=', mapping_id[0])]) |
1441 | @@ -555,6 +830,38 @@ | |||
1442 | 555 | 'field_id': field_id, } | 830 | 'field_id': field_id, } |
1443 | 556 | mapping_line = self._default_mapping(cr, uid, ttype, field_name, vals, attribute_id, model_id, mapping_line, referential_id) | 831 | mapping_line = self._default_mapping(cr, uid, ttype, field_name, vals, attribute_id, model_id, mapping_line, referential_id) |
1444 | 557 | self.pool.get('external.mapping.line').create(cr, uid, mapping_line) | 832 | self.pool.get('external.mapping.line').create(cr, uid, mapping_line) |
1445 | 833 | ======= | ||
1446 | 834 | # the mapping should always be created on the product.product | ||
1447 | 835 | # model, and not on product.template | ||
1448 | 836 | mapping_ids = self.pool.get('external.mapping').search( | ||
1449 | 837 | cr, uid, | ||
1450 | 838 | [('referential_id', '=', attribute.referential_id.id), | ||
1451 | 839 | ('model_id.model', '=', 'product.product')], | ||
1452 | 840 | context=context) | ||
1453 | 841 | if not mapping_ids: | ||
1454 | 842 | raise osv.except_osv( | ||
1455 | 843 | _('Error'), | ||
1456 | 844 | _("No Object Mapping \"Product\"" | ||
1457 | 845 | "for \"%s\"." % attribute.referential_id.name)) | ||
1458 | 846 | existing_line = self.pool.get('external.mapping.line').search( | ||
1459 | 847 | cr, uid, | ||
1460 | 848 | [('external_field', '=', attribute.attribute_code), | ||
1461 | 849 | ('mapping_id', '=', mapping_ids[0])], | ||
1462 | 850 | context=context) | ||
1463 | 851 | if not existing_line: | ||
1464 | 852 | mapping_line = { | ||
1465 | 853 | 'external_field': attribute.attribute_code, | ||
1466 | 854 | 'mapping_id': mapping_ids[0], | ||
1467 | 855 | 'type': 'in_out', | ||
1468 | 856 | 'external_type': self._type_casts[attribute.frontend_input], | ||
1469 | 857 | 'field_id': field.id, | ||
1470 | 858 | 'evaluation_type': 'function', | ||
1471 | 859 | } | ||
1472 | 860 | mapping_line['in_function'], mapping_line['out_function'] = \ | ||
1473 | 861 | self._default_mapping(cr, uid, attribute, field, context=context) | ||
1474 | 862 | self.pool.get('external.mapping.line').create( | ||
1475 | 863 | cr, uid, mapping_line, context=context) | ||
1476 | 864 | >>>>>>> MERGE-SOURCE | ||
1477 | 558 | return True | 865 | return True |
1478 | 559 | 866 | ||
1479 | 560 | magerp_product_attributes() | 867 | magerp_product_attributes() |
1480 | @@ -683,6 +990,11 @@ | |||
1481 | 683 | cr.execute(query) | 990 | cr.execute(query) |
1482 | 684 | return True | 991 | return True |
1483 | 685 | 992 | ||
1484 | 993 | <<<<<<< TREE | ||
1485 | 994 | ======= | ||
1486 | 995 | return True | ||
1487 | 996 | |||
1488 | 997 | >>>>>>> MERGE-SOURCE | ||
1489 | 686 | magerp_product_attribute_set() | 998 | magerp_product_attribute_set() |
1490 | 687 | 999 | ||
1491 | 688 | class magerp_product_attribute_groups(magerp_osv.magerp_osv): | 1000 | class magerp_product_attribute_groups(magerp_osv.magerp_osv): |
1492 | @@ -695,11 +1007,15 @@ | |||
1493 | 695 | for attribute_group in self.browse(cr, uid, ids, context): | 1007 | for attribute_group in self.browse(cr, uid, ids, context): |
1494 | 696 | res[attribute_group.id] = self.pool.get('magerp.product_attribute_set').extid_to_oeid(cr, uid, attribute_group.attribute_set_id, attribute_group.referential_id.id) | 1008 | res[attribute_group.id] = self.pool.get('magerp.product_attribute_set').extid_to_oeid(cr, uid, attribute_group.attribute_set_id, attribute_group.referential_id.id) |
1495 | 697 | return res | 1009 | return res |
1496 | 1010 | <<<<<<< TREE | ||
1497 | 698 | 1011 | ||
1498 | 699 | def _get_filter(self, cr, uid, external_session, step, previous_filter=None, context=None): | 1012 | def _get_filter(self, cr, uid, external_session, step, previous_filter=None, context=None): |
1499 | 700 | attrset_ids = self.pool.get('magerp.product_attribute_set').get_all_extid_from_referential(cr, uid, external_session.referential_id.id, context=context) | 1013 | attrset_ids = self.pool.get('magerp.product_attribute_set').get_all_extid_from_referential(cr, uid, external_session.referential_id.id, context=context) |
1500 | 701 | return {'attribute_set_id':{'in':attrset_ids}} | 1014 | return {'attribute_set_id':{'in':attrset_ids}} |
1501 | 702 | 1015 | ||
1502 | 1016 | ======= | ||
1503 | 1017 | |||
1504 | 1018 | >>>>>>> MERGE-SOURCE | ||
1505 | 703 | _columns = { | 1019 | _columns = { |
1506 | 704 | 'attribute_set_id':fields.integer('Attribute Set ID'), | 1020 | 'attribute_set_id':fields.integer('Attribute Set ID'), |
1507 | 705 | 'attribute_set':fields.function(_get_set, type="many2one", relation="magerp.product_attribute_set", method=True, string="Attribute Set"), | 1021 | 'attribute_set':fields.function(_get_set, type="many2one", relation="magerp.product_attribute_set", method=True, string="Attribute Set"), |
1508 | @@ -1133,12 +1449,25 @@ | |||
1509 | 1133 | #TODO base the import on the mapping and the function ext_import | 1449 | #TODO base the import on the mapping and the function ext_import |
1510 | 1134 | def import_product_image(self, cr, uid, id, referential_id, conn, ext_id=None, context=None): | 1450 | def import_product_image(self, cr, uid, id, referential_id, conn, ext_id=None, context=None): |
1511 | 1135 | image_obj = self.pool.get('product.images') | 1451 | image_obj = self.pool.get('product.images') |
1512 | 1452 | <<<<<<< TREE | ||
1513 | 1453 | ======= | ||
1514 | 1454 | logger = logging.getLogger('ext synchro') | ||
1515 | 1455 | >>>>>>> MERGE-SOURCE | ||
1516 | 1136 | if not ext_id: | 1456 | if not ext_id: |
1517 | 1457 | <<<<<<< TREE | ||
1518 | 1137 | ext_id = self.get_extid(cr, uid, id, referential_id, context=context) | 1458 | ext_id = self.get_extid(cr, uid, id, referential_id, context=context) |
1519 | 1138 | # TODO everythere will should pass the params 'id' for magento api in order to force | 1459 | # TODO everythere will should pass the params 'id' for magento api in order to force |
1520 | 1460 | ======= | ||
1521 | 1461 | ext_id = self.oeid_to_extid(cr, uid, id, referential_id, context=None) | ||
1522 | 1462 | # TODO everythere will should pass the params 'id' for magento api in order to force | ||
1523 | 1463 | >>>>>>> MERGE-SOURCE | ||
1524 | 1139 | # to use the id as external key instead of mixed id/sku | 1464 | # to use the id as external key instead of mixed id/sku |
1525 | 1140 | img_list = conn.call('catalog_product_attribute_media.list', [ext_id, False, 'id']) | 1465 | img_list = conn.call('catalog_product_attribute_media.list', [ext_id, False, 'id']) |
1526 | 1466 | <<<<<<< TREE | ||
1527 | 1141 | _logger.info("Magento image for product ext_id %s: %s", ext_id, img_list) | 1467 | _logger.info("Magento image for product ext_id %s: %s", ext_id, img_list) |
1528 | 1468 | ======= | ||
1529 | 1469 | logger.info("Magento image for product ext_id %s: %s", ext_id, img_list) | ||
1530 | 1470 | >>>>>>> MERGE-SOURCE | ||
1531 | 1142 | images_name = [] | 1471 | images_name = [] |
1532 | 1143 | for image in img_list: | 1472 | for image in img_list: |
1533 | 1144 | img=False | 1473 | img=False |
1534 | @@ -1148,13 +1477,21 @@ | |||
1535 | 1148 | data = f.read() | 1477 | data = f.read() |
1536 | 1149 | f.close() | 1478 | f.close() |
1537 | 1150 | if "DOCTYPE html PUBLIC" in data: | 1479 | if "DOCTYPE html PUBLIC" in data: |
1538 | 1480 | <<<<<<< TREE | ||
1539 | 1151 | _logger.warn("failed to open the image %s from Magento", image['url']) | 1481 | _logger.warn("failed to open the image %s from Magento", image['url']) |
1540 | 1482 | ======= | ||
1541 | 1483 | logger.warn("Failed to open the image %s from Magento", image['url']) | ||
1542 | 1484 | >>>>>>> MERGE-SOURCE | ||
1543 | 1152 | continue | 1485 | continue |
1544 | 1153 | else: | 1486 | else: |
1545 | 1154 | img = base64.encodestring(data) | 1487 | img = base64.encodestring(data) |
1546 | 1155 | except Exception, e: | 1488 | except Exception, e: |
1547 | 1156 | #TODO raise correctly the error | 1489 | #TODO raise correctly the error |
1548 | 1490 | <<<<<<< TREE | ||
1549 | 1157 | _logger.error("failed to open the image %s from Magento, error : %s", image['url'], e, exc_info=True) | 1491 | _logger.error("failed to open the image %s from Magento, error : %s", image['url'], e, exc_info=True) |
1550 | 1492 | ======= | ||
1551 | 1493 | logger.error("Failed to open the image %s from Magento, error : %s", image['url'], e, exc_info=True) | ||
1552 | 1494 | >>>>>>> MERGE-SOURCE | ||
1553 | 1158 | continue | 1495 | continue |
1554 | 1159 | mag_filename, extention = os.path.splitext(os.path.basename(image['file'])) | 1496 | mag_filename, extention = os.path.splitext(os.path.basename(image['file'])) |
1555 | 1160 | data = {'name': image['label'] and not image['label'] in images_name and image['label'] or mag_filename, | 1497 | data = {'name': image['label'] and not image['label'] in images_name and image['label'] or mag_filename, |
1556 | @@ -1180,6 +1517,7 @@ | |||
1557 | 1180 | new_image_id = image_obj.create(cr, uid, data, context=context) | 1517 | new_image_id = image_obj.create(cr, uid, data, context=context) |
1558 | 1181 | image_obj.create_external_id_vals(cr, uid, new_image_id, image['file'], referential_id, context=context) | 1518 | image_obj.create_external_id_vals(cr, uid, new_image_id, image['file'], referential_id, context=context) |
1559 | 1182 | return True | 1519 | return True |
1560 | 1520 | <<<<<<< TREE | ||
1561 | 1183 | 1521 | ||
1562 | 1184 | def get_field_to_export(self, cr, uid, ids, mapping, mapping_id, context=None): | 1522 | def get_field_to_export(self, cr, uid, ids, mapping, mapping_id, context=None): |
1563 | 1185 | res = super(product_product, self).get_field_to_export(cr, uid, ids, mapping, mapping_id, context=context) | 1523 | res = super(product_product, self).get_field_to_export(cr, uid, ids, mapping, mapping_id, context=context) |
1564 | @@ -1215,6 +1553,21 @@ | |||
1565 | 1215 | context=context | 1553 | context=context |
1566 | 1216 | )) | 1554 | )) |
1567 | 1217 | return resources | 1555 | return resources |
1568 | 1556 | ======= | ||
1569 | 1557 | |||
1570 | 1558 | def extid_to_existing_oeid(self, cr, uid, id, external_referential_id, context=None): | ||
1571 | 1559 | """Returns the OpenERP id of a resource by its external id. | ||
1572 | 1560 | Returns False if the resource does not exist.""" | ||
1573 | 1561 | if not context: | ||
1574 | 1562 | context={} | ||
1575 | 1563 | res = super(product_mag_osv, self).extid_to_existing_oeid(cr, uid, id, external_referential_id, context=context) | ||
1576 | 1564 | # TODO : check if this can be replaced by _existing_oeid_for_extid_import (see example in res.partner) | ||
1577 | 1565 | # thus when importing a product which do not already exists in OpenERP, ext_import will create the binding and update it directly | ||
1578 | 1566 | if not res and context.get('magento_sku', False): | ||
1579 | 1567 | product_id = self.search(cr, uid, [('magento_sku', '=', context['magento_sku'])], context=context) | ||
1580 | 1568 | return product_id and product_id[0] or False | ||
1581 | 1569 | return res | ||
1582 | 1570 | >>>>>>> MERGE-SOURCE | ||
1583 | 1218 | 1571 | ||
1584 | 1219 | def _product_type_get(self, cr, uid, context=None): | 1572 | def _product_type_get(self, cr, uid, context=None): |
1585 | 1220 | ids = self.pool.get('magerp.product_product_type').search(cr, uid, [], order='id') | 1573 | ids = self.pool.get('magerp.product_product_type').search(cr, uid, [], order='id') |
1586 | @@ -1344,6 +1697,266 @@ | |||
1587 | 1344 | raise osv.except_osv(_('Warning!'), _('This product is related to Magento. It can not be deleted!\nYou can change it Magento status to "Disabled" and uncheck the active box to hide it from OpenERP.')) | 1697 | raise osv.except_osv(_('Warning!'), _('This product is related to Magento. It can not be deleted!\nYou can change it Magento status to "Disabled" and uncheck the active box to hide it from OpenERP.')) |
1588 | 1345 | else: | 1698 | else: |
1589 | 1346 | return super(product_product, self).unlink(cr, uid, ids, context) | 1699 | return super(product_product, self).unlink(cr, uid, ids, context) |
1590 | 1700 | <<<<<<< TREE | ||
1591 | 1701 | ======= | ||
1592 | 1702 | |||
1593 | 1703 | #TODO move part of this to declarative mapping CSV template | ||
1594 | 1704 | def extdata_from_oevals(self, cr, uid, external_referential_id, data_record, mapping_lines, defaults, context=None): | ||
1595 | 1705 | product_data = super(product_product, self).extdata_from_oevals(cr, uid, external_referential_id, data_record, mapping_lines, defaults, context) #Aapply custom/attributes mappings | ||
1596 | 1706 | if context is None: context = {} | ||
1597 | 1707 | product = self.browse(cr, uid, data_record['id'], context) | ||
1598 | 1708 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id'], context) | ||
1599 | 1709 | |||
1600 | 1710 | if not product_data.get('price', False): | ||
1601 | 1711 | pl_default_id = shop.pricelist_id and shop.pricelist_id.id or self.pool.get('product.pricelist').search(cr, uid, [('type', '=', 'sale')]) | ||
1602 | 1712 | if isinstance(pl_default_id, int): | ||
1603 | 1713 | pl_default_id = [pl_default_id] | ||
1604 | 1714 | product_data.update({'price': self.pool.get('product.pricelist').price_get(cr, uid, pl_default_id, product.id, 1.0)[pl_default_id[0]]}) | ||
1605 | 1715 | |||
1606 | 1716 | if not product_data.get('tax_class_id', False): | ||
1607 | 1717 | product_data.update({'tax_class_id': 2}) #FIXME hugly! | ||
1608 | 1718 | |||
1609 | 1719 | if not product_data.get('status', False): | ||
1610 | 1720 | product_data.update({'status': product.active and 1 or 0}) | ||
1611 | 1721 | |||
1612 | 1722 | if not product_data.get('description', False): | ||
1613 | 1723 | product_data.update({'description': product.description or _("description")}) | ||
1614 | 1724 | if not product_data.get('short_description', False): | ||
1615 | 1725 | product_data.update({'short_description': product.description_sale or _("short description")}) | ||
1616 | 1726 | if not product_data.get('meta_title', False): | ||
1617 | 1727 | product_data.update({'meta_title': product.name}) | ||
1618 | 1728 | if not product_data.get('meta_keyword', False): | ||
1619 | 1729 | product_data.update({'meta_keyword': product.name}) | ||
1620 | 1730 | if not product_data.get('meta_description', False): | ||
1621 | 1731 | product_data.update({'meta_description': product.description_sale and product.description_sale[:255]}) | ||
1622 | 1732 | |||
1623 | 1733 | return product_data | ||
1624 | 1734 | |||
1625 | 1735 | def oevals_from_extdata(self, cr, uid, external_referential_id, data_record, mapping_lines, key_for_external_id=None, parent_data=None, previous_lines=None, defaults=None, context=None): | ||
1626 | 1736 | res = super(product_product, self).oevals_from_extdata(cr, uid, external_referential_id, data_record, mapping_lines, key_for_external_id=key_for_external_id, parent_data=parent_data, previous_lines=previous_lines, defaults=defaults, context=context) | ||
1627 | 1737 | # assign a default product type (Procurement, not the magento's one) | ||
1628 | 1738 | if not res.get('type'): | ||
1629 | 1739 | magerp_type_obj = self.pool.get('magerp.product_product_type') | ||
1630 | 1740 | magerp_type_ids = magerp_type_obj.search(cr, uid, [('product_type', '=', data_record['type_id'])], context=context) | ||
1631 | 1741 | if magerp_type_ids: | ||
1632 | 1742 | res['type'] = magerp_type_obj.read(cr, uid, magerp_type_ids[0], ['default_type'], context=context)['default_type'] | ||
1633 | 1743 | return res | ||
1634 | 1744 | |||
1635 | 1745 | def product_to_sku(self, cr, uid, product): | ||
1636 | 1746 | if product.magento_sku: | ||
1637 | 1747 | sku = product.magento_sku | ||
1638 | 1748 | else: | ||
1639 | 1749 | code = product.code or 'mag' | ||
1640 | 1750 | same_codes = self.search(cr, uid, [('magento_sku', '=', code)]) | ||
1641 | 1751 | if same_codes and len(same_codes) > 0: | ||
1642 | 1752 | sku = code + "_" + str(product.id) | ||
1643 | 1753 | else: | ||
1644 | 1754 | sku = code | ||
1645 | 1755 | return sku | ||
1646 | 1756 | |||
1647 | 1757 | def _ext_update_and_rebind(self, cr, uid, data, conn, oe_id, sku=None, context=None): | ||
1648 | 1758 | if sku is None: | ||
1649 | 1759 | product = self.browse(cr, uid, oe_id, context=context) | ||
1650 | 1760 | sku = product.sku | ||
1651 | 1761 | ext_data = conn.call('catalog_product.info', [sku, False, 'sku']) | ||
1652 | 1762 | ext_id = ext_data['product_id'] | ||
1653 | 1763 | conn.call('ol_catalog_product.update', [ext_id, data, False, 'id']) | ||
1654 | 1764 | return ext_id | ||
1655 | 1765 | |||
1656 | 1766 | def ext_create(self, cr, uid, data, conn, method, oe_id, context=None): | ||
1657 | 1767 | if context is None: context = {} | ||
1658 | 1768 | product = self.browse(cr, uid, oe_id, context=context) | ||
1659 | 1769 | sku = self.product_to_sku(cr, uid, product) | ||
1660 | 1770 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id']) | ||
1661 | 1771 | attr_set_id = product.set and self.pool.get('magerp.product_attribute_set').oeid_to_extid(cr, uid, product.set.id, shop.referential_id.id) or context.get('default_set_id', 1) | ||
1662 | 1772 | |||
1663 | 1773 | product_type = self.read(cr, uid, oe_id, ['product_type'])['product_type'] or 'simple' | ||
1664 | 1774 | |||
1665 | 1775 | try: | ||
1666 | 1776 | ext_id = super(magerp_osv.magerp_osv, self).ext_create( | ||
1667 | 1777 | cr, uid, [product_type, attr_set_id, sku, data], conn, method, oe_id, context) | ||
1668 | 1778 | except xmlrpclib.Fault, e: | ||
1669 | 1779 | # Magento raise error 1 when we try to create | ||
1670 | 1780 | # a product with a SKU which already exists | ||
1671 | 1781 | if e.faultCode == 1: | ||
1672 | 1782 | ext_id = self._ext_update_and_rebind( | ||
1673 | 1783 | cr, uid, data, conn, oe_id, sku=sku, context=context) | ||
1674 | 1784 | else: | ||
1675 | 1785 | raise | ||
1676 | 1786 | self.write(cr, uid, oe_id, {'magento_sku': sku}) | ||
1677 | 1787 | return ext_id | ||
1678 | 1788 | |||
1679 | 1789 | def action_before_exporting_grouped_product(self, cr, uid, id, external_referential_ids=None, defaults=None, context=None): | ||
1680 | 1790 | logger = logging.getLogger('ext synchro') | ||
1681 | 1791 | if context.get('mrp_is_installed', False): | ||
1682 | 1792 | bom_ids = self.read(cr, uid, id, ['bom_ids'])['bom_ids'] | ||
1683 | 1793 | if len(bom_ids): # it has or is part of a BoM | ||
1684 | 1794 | cr.execute("SELECT product_id, product_qty FROM mrp_bom WHERE bom_id = %s", (bom_ids[0],)) #FIXME What if there is more than a materials list? | ||
1685 | 1795 | results = cr.dictfetchall() | ||
1686 | 1796 | child_ids = [] | ||
1687 | 1797 | quantities = {} | ||
1688 | 1798 | for row in results: | ||
1689 | 1799 | child_ids.append(row['product_id']) | ||
1690 | 1800 | quantities.update({row['product_id']: row['product_qty']}) | ||
1691 | 1801 | if child_ids: #it is an assembly and it contains the products child_ids: | ||
1692 | 1802 | self.ext_export(cr, uid, child_ids, external_referential_ids, defaults, context) #so we export them | ||
1693 | 1803 | else: | ||
1694 | 1804 | return False | ||
1695 | 1805 | else: | ||
1696 | 1806 | logger.error("OpenERP 'grouped' products will export to Magento as 'grouped products' only if they have a BOM and if the 'mrp' BOM module is installed") | ||
1697 | 1807 | return quantities, child_ids | ||
1698 | 1808 | |||
1699 | 1809 | def action_before_exporting(self, cr, uid, id, product_type, external_referential_ids=None, defaults=None, context=None): | ||
1700 | 1810 | '''Hook to allow your external module to execute some code before exporting a product''' | ||
1701 | 1811 | return True | ||
1702 | 1812 | |||
1703 | 1813 | #todo move this code to a generic module | ||
1704 | 1814 | def get_last_update_date(self, cr, uid, product_read, context=None): | ||
1705 | 1815 | """if a product have a depends on other object like bom for grouped product, or other product for configurable | ||
1706 | 1816 | the date of last update should be based on the last update of the dependence object""" | ||
1707 | 1817 | conn = context.get('conn_obj', False) | ||
1708 | 1818 | last_updated_date = product_read['write_date'] or product_read['create_date'] or False | ||
1709 | 1819 | if product_read['product_type'] == 'grouped': | ||
1710 | 1820 | if context.get('mrp_is_installed', False): | ||
1711 | 1821 | #TODO improve this part of code as the group product can be based on nan_product_pack | ||
1712 | 1822 | cr.execute("select id, write_date, create_date from mrp_bom where product_id = %s", (product_read['id'],)) | ||
1713 | 1823 | read_bom = cr.dictfetchall() | ||
1714 | 1824 | for bom in read_bom: | ||
1715 | 1825 | last_updated_bom_date = bom['write_date'] or bom['create_date'] or False | ||
1716 | 1826 | if last_updated_bom_date > last_updated_date: | ||
1717 | 1827 | last_updated_date=last_updated_bom_date | ||
1718 | 1828 | else: | ||
1719 | 1829 | conn.logger.error("OpenERP 'grouped' products will export to Magento as 'grouped products' only if they have a BOM and if the 'mrp' BOM module is installed") | ||
1720 | 1830 | return last_updated_date | ||
1721 | 1831 | |||
1722 | 1832 | |||
1723 | 1833 | def get_ordered_ids(self, cr, uid, ids, external_referential_ids=None, defaults=None, context=None): | ||
1724 | 1834 | #TODO pass the shop better than the referentials | ||
1725 | 1835 | dates_2_ids = [] | ||
1726 | 1836 | ids_2_dates = {} | ||
1727 | 1837 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id']) | ||
1728 | 1838 | if shop.last_products_export_date: | ||
1729 | 1839 | last_exported_date = shop.last_products_export_date | ||
1730 | 1840 | else: | ||
1731 | 1841 | last_exported_date = False | ||
1732 | 1842 | #strangely seems that on inherits structure, write_date/create_date are False for children | ||
1733 | 1843 | #TODO check previous comment and check the write date on product template also for variant of product | ||
1734 | 1844 | cr.execute("select id, write_date, create_date, product_type from product_product where id in %s", (tuple(ids),)) | ||
1735 | 1845 | read = cr.dictfetchall() | ||
1736 | 1846 | ids = [] | ||
1737 | 1847 | context['force']=True | ||
1738 | 1848 | |||
1739 | 1849 | for product_read in read: | ||
1740 | 1850 | last_updated_date = self.get_last_update_date(cr, uid, product_read, context=context) | ||
1741 | 1851 | if last_exported_date and last_updated_date < last_exported_date: | ||
1742 | 1852 | continue | ||
1743 | 1853 | dates_2_ids += [(last_updated_date, product_read['id'])] | ||
1744 | 1854 | ids_2_dates[product_read['id']] = last_updated_date | ||
1745 | 1855 | |||
1746 | 1856 | dates_2_ids.sort() | ||
1747 | 1857 | ids = [x[1] for x in dates_2_ids] | ||
1748 | 1858 | |||
1749 | 1859 | return ids, ids_2_dates | ||
1750 | 1860 | |||
1751 | 1861 | def _ext_export_one(self, cr, uid, record_data, referential_id, defaults=None, context=None): | ||
1752 | 1862 | res = super(product_product, self)._ext_export_one( | ||
1753 | 1863 | cr, uid, record_data, referential_id, defaults=defaults, context=context) | ||
1754 | 1864 | |||
1755 | 1865 | self.ext_assign_links( | ||
1756 | 1866 | cr, uid, | ||
1757 | 1867 | record_data['id'], | ||
1758 | 1868 | external_referential_ids=[referential_id], | ||
1759 | 1869 | defaults=defaults, | ||
1760 | 1870 | context=context) | ||
1761 | 1871 | |||
1762 | 1872 | return res | ||
1763 | 1873 | |||
1764 | 1874 | def ext_export(self, cr, uid, ids, external_referential_ids=None, defaults=None, context=None): | ||
1765 | 1875 | #check if mrp is installed | ||
1766 | 1876 | cr.execute('select * from ir_module_module where name=%s and state=%s', ('mrp','installed')) | ||
1767 | 1877 | data_record = cr.fetchone() | ||
1768 | 1878 | if data_record and 'mrp' in data_record: | ||
1769 | 1879 | context['mrp_is_installed']=True | ||
1770 | 1880 | |||
1771 | 1881 | if context is None: | ||
1772 | 1882 | context = {} | ||
1773 | 1883 | |||
1774 | 1884 | if defaults is None: | ||
1775 | 1885 | defaults = {} | ||
1776 | 1886 | #TODO Is external_referential_ids is still used? | ||
1777 | 1887 | if external_referential_ids is None: | ||
1778 | 1888 | external_referential_ids = [] | ||
1779 | 1889 | |||
1780 | 1890 | result = {'create_ids':[], 'write_ids':[]} | ||
1781 | 1891 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id']) | ||
1782 | 1892 | context['external_referential_id'] = shop.referential_id.id | ||
1783 | 1893 | #TODO It will be better if this check was done before | ||
1784 | 1894 | #restrict export to only exportable products | ||
1785 | 1895 | ids = self.search(cr, uid, [('id', 'in', ids), ('magento_exportable', '=', True)]) | ||
1786 | 1896 | if not ids: | ||
1787 | 1897 | return result | ||
1788 | 1898 | |||
1789 | 1899 | if not context.get('force_export', False): | ||
1790 | 1900 | ids, ids_2_dates = self.get_ordered_ids(cr, uid, ids, external_referential_ids, defaults, context) | ||
1791 | 1901 | |||
1792 | 1902 | #set the default_set_id in context and avoid extra request for each product upload | ||
1793 | 1903 | |||
1794 | 1904 | conn = context.get('conn_obj', False) | ||
1795 | 1905 | attr_sets = conn.call('product_attribute_set.list') | ||
1796 | 1906 | default_set_id = 1 | ||
1797 | 1907 | for attr_set in attr_sets: | ||
1798 | 1908 | if attr_set['name'] == 'Default': | ||
1799 | 1909 | default_set_id = attr_set['set_id'] | ||
1800 | 1910 | break | ||
1801 | 1911 | context['default_set_id'] = default_set_id | ||
1802 | 1912 | |||
1803 | 1913 | context_dic = [context.copy()] | ||
1804 | 1914 | context_dic[0]['export_url'] = True # for the magento version 1.3.2.4, only one url is autorized by product, so we only export with the MAPPING TEMPLATE the url of the default language | ||
1805 | 1915 | context_dic[0]['lang'] = shop.referential_id.default_lang_id.code | ||
1806 | 1916 | |||
1807 | 1917 | for storeview in shop.storeview_ids: | ||
1808 | 1918 | if storeview.lang_id and storeview.lang_id.code != shop.referential_id.default_lang_id.code: | ||
1809 | 1919 | context_dic += [context.copy()] | ||
1810 | 1920 | context_dic[len(context_dic)-1].update({'storeview_code': storeview.code, 'lang': storeview.lang_id.code}) | ||
1811 | 1921 | |||
1812 | 1922 | last_export_date = None | ||
1813 | 1923 | try: | ||
1814 | 1924 | for id in ids: | ||
1815 | 1925 | child_ids = [] | ||
1816 | 1926 | product_type = self.read(cr, uid, id, ['product_type'])['product_type'] | ||
1817 | 1927 | if product_type == 'grouped': # lookup for Magento "grouped product" | ||
1818 | 1928 | quantities, child_ids = self.action_before_exporting_grouped_product(cr, uid, id, external_referential_ids, defaults, context) | ||
1819 | 1929 | |||
1820 | 1930 | self.action_before_exporting(cr, uid, id, product_type, external_referential_ids, defaults, context=context) | ||
1821 | 1931 | |||
1822 | 1932 | for context_storeview in context_dic: | ||
1823 | 1933 | temp_result = super(magerp_osv.magerp_osv, self).ext_export(cr, uid, [id], external_referential_ids, defaults, context_storeview) | ||
1824 | 1934 | #TODO maybe refactor this part, did we need to assign and make the link for every store? | ||
1825 | 1935 | if child_ids: | ||
1826 | 1936 | self.ext_product_assign(cr, uid, 'grouped', id, child_ids, quantities=quantities, external_referential_ids=external_referential_ids, defaults=defaults, context=context_storeview) | ||
1827 | 1937 | if not context.get('force_export'): | ||
1828 | 1938 | last_export_date = ids_2_dates[id] | ||
1829 | 1939 | |||
1830 | 1940 | result['create_ids'] += temp_result['create_ids'] | ||
1831 | 1941 | result['write_ids'] += temp_result['write_ids'] | ||
1832 | 1942 | finally: | ||
1833 | 1943 | if last_export_date is not None: | ||
1834 | 1944 | self.pool.get('sale.shop').write( | ||
1835 | 1945 | cr, uid, context['shop_id'], {'last_products_export_date': last_export_date}, context=context) | ||
1836 | 1946 | return result | ||
1837 | 1947 | |||
1838 | 1948 | def try_ext_update(self, cr, uid, data, conn, method, oe_id, external_id, ir_model_data_id, create_method, context=None): | ||
1839 | 1949 | if context is None: context = {} | ||
1840 | 1950 | if context.get('storeview_code', False): | ||
1841 | 1951 | return conn.call(method, [external_id, data, context.get('storeview_code', False)]) | ||
1842 | 1952 | else: | ||
1843 | 1953 | return conn.call(method, [external_id, data]) | ||
1844 | 1954 | |||
1845 | 1955 | def ext_update(self, cr, uid, data, conn, method, oe_id, external_id, ir_model_data_id, create_method, context=None): | ||
1846 | 1956 | product = self.browse(cr, uid, oe_id) | ||
1847 | 1957 | sku = self.product_to_sku(cr, uid, product) | ||
1848 | 1958 | return super(magerp_osv.magerp_osv, self).ext_update(cr, uid, data, conn, method, oe_id, sku, ir_model_data_id, create_method, context) | ||
1849 | 1959 | >>>>>>> MERGE-SOURCE | ||
1850 | 1347 | 1960 | ||
1851 | 1348 | def _prepare_inventory_magento_vals(self, cr, uid, product, stock, shop, | 1961 | def _prepare_inventory_magento_vals(self, cr, uid, product, stock, shop, |
1852 | 1349 | context=None): | 1962 | context=None): |
1853 | @@ -1380,6 +1993,10 @@ | |||
1854 | 1380 | #TODO get also the list of product which the option mag_manage_stock have changed | 1993 | #TODO get also the list of product which the option mag_manage_stock have changed |
1855 | 1381 | #This can be base on the group_fields that can try tle last write date of a group of fields | 1994 | #This can be base on the group_fields that can try tle last write date of a group of fields |
1856 | 1382 | if context is None: context = {} | 1995 | if context is None: context = {} |
1857 | 1996 | <<<<<<< TREE | ||
1858 | 1997 | ======= | ||
1859 | 1998 | logger = logging.getLogger('ext synchro') | ||
1860 | 1999 | >>>>>>> MERGE-SOURCE | ||
1861 | 1383 | 2000 | ||
1862 | 1384 | shop = external_session.sync_from_object | 2001 | shop = external_session.sync_from_object |
1863 | 1385 | 2002 | ||
1864 | @@ -1400,6 +2017,7 @@ | |||
1865 | 1400 | cr, uid, stock_product_ids, context=location_ctx) | 2017 | cr, uid, stock_product_ids, context=location_ctx) |
1866 | 1401 | 2018 | ||
1867 | 1402 | for product in products: | 2019 | for product in products: |
1868 | 2020 | <<<<<<< TREE | ||
1869 | 1403 | self._export_inventory(cr, uid, external_session, product, stock, context=location_ctx) | 2021 | self._export_inventory(cr, uid, external_session, product, stock, context=location_ctx) |
1870 | 1404 | return True | 2022 | return True |
1871 | 1405 | 2023 | ||
1872 | @@ -1424,6 +2042,30 @@ | |||
1873 | 1424 | # ol_catalog_product.update | 2042 | # ol_catalog_product.update |
1874 | 1425 | def ext_update_link_data(self, cr, uid, external_session, resources, mapping=None, mapping_id=None, context=None): | 2043 | def ext_update_link_data(self, cr, uid, external_session, resources, mapping=None, mapping_id=None, context=None): |
1875 | 1426 | for resource_id, resource in resources.items(): | 2044 | for resource_id, resource in resources.items(): |
1876 | 2045 | ======= | ||
1877 | 2046 | mag_product_id = self.oeid_to_extid( | ||
1878 | 2047 | cr, uid, product.id, referential.id, context=context) | ||
1879 | 2048 | if not mag_product_id: | ||
1880 | 2049 | continue # skip products which are not exported | ||
1881 | 2050 | inventory_vals = self._prepare_inventory_magento_vals( | ||
1882 | 2051 | cr, uid, product, stock, shop, context=location_ctx) | ||
1883 | 2052 | |||
1884 | 2053 | connection.call('product_stock.update', | ||
1885 | 2054 | [mag_product_id, inventory_vals]) | ||
1886 | 2055 | |||
1887 | 2056 | logger.info( | ||
1888 | 2057 | "Successfully updated stock level at %s for product with SKU %s", | ||
1889 | 2058 | inventory_vals.get('qty', 'N/A'), | ||
1890 | 2059 | product.magento_sku | ||
1891 | 2060 | ) | ||
1892 | 2061 | return True | ||
1893 | 2062 | |||
1894 | 2063 | def ext_assign_links(self, cr, uid, ids, external_referential_ids=None, defaults=None, context=None): | ||
1895 | 2064 | """ Assign links of type up-sell, cross-sell, related """ | ||
1896 | 2065 | if isinstance(ids, (int, long)): | ||
1897 | 2066 | ids = [ids] | ||
1898 | 2067 | for product in self.browse(cr, uid, ids, context): | ||
1899 | 2068 | >>>>>>> MERGE-SOURCE | ||
1900 | 1427 | for type_selection in self.pool.get('product.link').get_link_type_selection(cr, uid, context): | 2069 | for type_selection in self.pool.get('product.link').get_link_type_selection(cr, uid, context): |
1901 | 1428 | link_type = type_selection[0] | 2070 | link_type = type_selection[0] |
1902 | 1429 | position = {} | 2071 | position = {} |
1903 | @@ -1442,6 +2084,7 @@ | |||
1904 | 1442 | context = context or {} | 2084 | context = context or {} |
1905 | 1443 | position = position or {} | 2085 | position = position or {} |
1906 | 1444 | quantities = quantities or {} | 2086 | quantities = quantities or {} |
1907 | 2087 | <<<<<<< TREE | ||
1908 | 1445 | 2088 | ||
1909 | 1446 | 2089 | ||
1910 | 1447 | #Patch for magento api prototype | 2090 | #Patch for magento api prototype |
1911 | @@ -1493,6 +2136,83 @@ | |||
1912 | 1493 | 'qty': quantities.get(c_ext_id, 1)}]) | 2136 | 'qty': quantities.get(c_ext_id, 1)}]) |
1913 | 1494 | external_session.logger.info(("Successfully updated assignment of type %s of" | 2137 | external_session.logger.info(("Successfully updated assignment of type %s of" |
1914 | 1495 | "product %s to product %s") %(link_type, ext_parent_id, c_ext_id)) | 2138 | "product %s to product %s") %(link_type, ext_parent_id, c_ext_id)) |
1915 | 2139 | ======= | ||
1916 | 2140 | external_referential_ids = external_referential_ids or [] | ||
1917 | 2141 | logger = logging.getLogger('ext assign') | ||
1918 | 2142 | conn = context.get('conn_obj', False) | ||
1919 | 2143 | |||
1920 | 2144 | for ref_id in external_referential_ids: | ||
1921 | 2145 | # ensure that the product to link is exported before assigning it, | ||
1922 | 2146 | # export it if necessary | ||
1923 | 2147 | ids_to_export = [] | ||
1924 | 2148 | for child_id in child_ids: | ||
1925 | 2149 | if not self.oeid_to_extid(cr, uid, child_id, ref_id, context=context): | ||
1926 | 2150 | ids_to_export.append(child_id) | ||
1927 | 2151 | export_ctx = context.copy() | ||
1928 | 2152 | export_ctx['force_export'] = True | ||
1929 | 2153 | self.ext_export( | ||
1930 | 2154 | cr, uid, ids_to_export, [ref_id], defaults=defaults, context=export_ctx) | ||
1931 | 2155 | |||
1932 | 2156 | ext_id = self.oeid_to_extid( | ||
1933 | 2157 | cr, uid, parent_id, ref_id, context=context) | ||
1934 | 2158 | if not ext_id: | ||
1935 | 2159 | continue | ||
1936 | 2160 | |||
1937 | 2161 | # get the sku of the products already assigned | ||
1938 | 2162 | magento_args = [type, ext_id] | ||
1939 | 2163 | |||
1940 | 2164 | # magento existing children ids | ||
1941 | 2165 | child_list = conn.call('product_link.list', magento_args) | ||
1942 | 2166 | old_child_ext_ids = [x['product_id'] for x in child_list] | ||
1943 | 2167 | |||
1944 | 2168 | ext_id_to_remove = [] | ||
1945 | 2169 | ext_id_to_assign = [] | ||
1946 | 2170 | ext_id_to_update = [] | ||
1947 | 2171 | |||
1948 | 2172 | # list of children setup on openerp | ||
1949 | 2173 | new_child_ext_ids = dict([(self.oeid_to_extid(cr, uid, child_id, ref_id, context=context), | ||
1950 | 2174 | child_id) | ||
1951 | 2175 | for child_id in child_ids]) | ||
1952 | 2176 | |||
1953 | 2177 | skus = dict([(p.id, p.magento_sku) | ||
1954 | 2178 | for p in | ||
1955 | 2179 | self.browse( | ||
1956 | 2180 | cr, uid, child_ids + [parent_id], context=context)]) | ||
1957 | 2181 | |||
1958 | 2182 | # compute the diff between openerp and magento | ||
1959 | 2183 | for c_ext_id in old_child_ext_ids: | ||
1960 | 2184 | if c_ext_id not in new_child_ext_ids: | ||
1961 | 2185 | ext_id_to_remove.append(c_ext_id) | ||
1962 | 2186 | for c_ext_id in new_child_ext_ids.keys(): | ||
1963 | 2187 | if c_ext_id in old_child_ext_ids: | ||
1964 | 2188 | ext_id_to_update.append(c_ext_id) | ||
1965 | 2189 | else: | ||
1966 | 2190 | ext_id_to_assign.append(c_ext_id) | ||
1967 | 2191 | |||
1968 | 2192 | # calls to magento to delete, create or update the links | ||
1969 | 2193 | for c_ext_id in ext_id_to_remove: | ||
1970 | 2194 | # remove the product links that are no more setup on openerp | ||
1971 | 2195 | conn.call('product_link.remove', magento_args + [c_ext_id]) | ||
1972 | 2196 | logger.info("Successfully removed assignment of type %s for product %s to product %s", type, skus[parent_id], c_ext_id) | ||
1973 | 2197 | for child_ext_id in ext_id_to_assign: | ||
1974 | 2198 | # assign new product links | ||
1975 | 2199 | product_id = new_child_ext_ids[child_ext_id] | ||
1976 | 2200 | conn.call('product_link.assign', | ||
1977 | 2201 | magento_args + | ||
1978 | 2202 | [child_ext_id, | ||
1979 | 2203 | {'position': position.get(product_id, 0), | ||
1980 | 2204 | 'qty': quantities.get(product_id, 1)}]) | ||
1981 | 2205 | logger.info("Successfully assigned product %s to product %s with type %s", skus[parent_id], skus[product_id], type) | ||
1982 | 2206 | for child_ext_id in ext_id_to_update: | ||
1983 | 2207 | # update products links already assigned | ||
1984 | 2208 | product_id = new_child_ext_ids[child_ext_id] | ||
1985 | 2209 | conn.call('product_link.update', | ||
1986 | 2210 | magento_args + | ||
1987 | 2211 | [child_ext_id, | ||
1988 | 2212 | {'position': position.get(product_id, 0), | ||
1989 | 2213 | 'qty': quantities.get(product_id, 1)}]) | ||
1990 | 2214 | logger.info("Successfully updated assignment of type %s of product %s to product %s", type, skus[parent_id], skus[product_id]) | ||
1991 | 2215 | >>>>>>> MERGE-SOURCE | ||
1992 | 1496 | return True | 2216 | return True |
1993 | 1497 | 2217 | ||
1994 | 1498 | #TODO move this code (get exportable image) and also some code in product_image.py and sale.py in base_sale_multichannel or in a new module in order to be more generic | 2218 | #TODO move this code (get exportable image) and also some code in product_image.py and sale.py in base_sale_multichannel or in a new module in order to be more generic |
1995 | @@ -1508,7 +2228,11 @@ | |||
1996 | 1508 | 2228 | ||
1997 | 1509 | def _mag_import_product_links_type(self, cr, uid, product, link_type, external_session, context=None): | 2229 | def _mag_import_product_links_type(self, cr, uid, product, link_type, external_session, context=None): |
1998 | 1510 | if context is None: context = {} | 2230 | if context is None: context = {} |
1999 | 2231 | <<<<<<< TREE | ||
2000 | 1511 | conn = external_session.connection | 2232 | conn = external_session.connection |
2001 | 2233 | ======= | ||
2002 | 2234 | logger = logging.getLogger('ext synchro') | ||
2003 | 2235 | >>>>>>> MERGE-SOURCE | ||
2004 | 1512 | product_link_obj = self.pool.get('product.link') | 2236 | product_link_obj = self.pool.get('product.link') |
2005 | 1513 | selection_link_types = product_link_obj.get_link_type_selection(cr, uid, context) | 2237 | selection_link_types = product_link_obj.get_link_type_selection(cr, uid, context) |
2006 | 1514 | mag_product_id = self.get_extid( | 2238 | mag_product_id = self.get_extid( |
2007 | @@ -1520,8 +2244,13 @@ | |||
2008 | 1520 | try: | 2244 | try: |
2009 | 1521 | product_links = conn.call('product_link.list', [link_type, mag_product_id]) | 2245 | product_links = conn.call('product_link.list', [link_type, mag_product_id]) |
2010 | 1522 | except Exception, e: | 2246 | except Exception, e: |
2011 | 2247 | <<<<<<< TREE | ||
2012 | 1523 | self.log(cr, uid, product.id, "Error when retrieving the list of links in Magento for product with reference %s and product id %s !" % (product.default_code, product.id,)) | 2248 | self.log(cr, uid, product.id, "Error when retrieving the list of links in Magento for product with reference %s and product id %s !" % (product.default_code, product.id,)) |
2013 | 1524 | conn.logger.debug("Error when retrieving the list of links in Magento for product with reference %s and product id %s !" % (product.magento_sku, product.id,)) | 2249 | conn.logger.debug("Error when retrieving the list of links in Magento for product with reference %s and product id %s !" % (product.magento_sku, product.id,)) |
2014 | 2250 | ======= | ||
2015 | 2251 | self.log(cr, uid, product.id, "Error when retrieving the list of links in Magento for product with sku %s and product id %s !" % (product.magento_sku, product.id,)) | ||
2016 | 2252 | logger.debug("Error when retrieving the list of links in Magento for product with sku %s and product id %s !", product.magento_sku, product.id) | ||
2017 | 2253 | >>>>>>> MERGE-SOURCE | ||
2018 | 1525 | 2254 | ||
2019 | 1526 | for product_link in product_links: | 2255 | for product_link in product_links: |
2020 | 1527 | linked_product_id = self.get_or_create_oeid( | 2256 | linked_product_id = self.get_or_create_oeid( |
2021 | @@ -1545,7 +2274,11 @@ | |||
2022 | 1545 | product_link_obj.write(cr, uid, existing_link, link_data, context=context) | 2274 | product_link_obj.write(cr, uid, existing_link, link_data, context=context) |
2023 | 1546 | else: | 2275 | else: |
2024 | 1547 | product_link_obj.create(cr, uid, link_data, context=context) | 2276 | product_link_obj.create(cr, uid, link_data, context=context) |
2025 | 2277 | <<<<<<< TREE | ||
2026 | 1548 | conn.logger.info("Successfully imported product link of type %s on product %s to product %s" %(link_type, product.id, linked_product_id)) | 2278 | conn.logger.info("Successfully imported product link of type %s on product %s to product %s" %(link_type, product.id, linked_product_id)) |
2027 | 2279 | ======= | ||
2028 | 2280 | logger.info("Successfully imported product link of type %s on product %s to product %s", link_type, product.id, linked_product_id) | ||
2029 | 2281 | >>>>>>> MERGE-SOURCE | ||
2030 | 1549 | return True | 2282 | return True |
2031 | 1550 | 2283 | ||
2032 | 1551 | def mag_import_product_links_types(self, cr, uid, ids, link_types, external_session, context=None): | 2284 | def mag_import_product_links_types(self, cr, uid, ids, link_types, external_session, context=None): |
2033 | 1552 | 2285 | ||
2034 | === modified file 'magentoerpconnect/product_images.py' | |||
2035 | --- magentoerpconnect/product_images.py 2012-05-09 15:40:38 +0000 | |||
2036 | +++ magentoerpconnect/product_images.py 2012-07-06 14:53:18 +0000 | |||
2037 | @@ -23,7 +23,7 @@ | |||
2038 | 23 | from osv import osv, fields | 23 | from osv import osv, fields |
2039 | 24 | import magerp_osv | 24 | import magerp_osv |
2040 | 25 | import mimetypes | 25 | import mimetypes |
2042 | 26 | import netsvc | 26 | import logging |
2043 | 27 | from tools.translate import _ | 27 | from tools.translate import _ |
2044 | 28 | import base64 | 28 | import base64 |
2045 | 29 | 29 | ||
2046 | @@ -52,12 +52,12 @@ | |||
2047 | 52 | 'thumbnail':lambda * a:True, | 52 | 'thumbnail':lambda * a:True, |
2048 | 53 | 'exclude':lambda * a:False | 53 | 'exclude':lambda * a:False |
2049 | 54 | } | 54 | } |
2051 | 55 | 55 | ||
2052 | 56 | def get_changed_ids(self, cr, uid, start_date=False): | 56 | def get_changed_ids(self, cr, uid, start_date=False): |
2053 | 57 | proxy = self.pool.get('product.images') | 57 | proxy = self.pool.get('product.images') |
2054 | 58 | domain = start_date and ['|', ('create_date', '>', start_date), ('write_date', '>', start_date)] or [] | 58 | domain = start_date and ['|', ('create_date', '>', start_date), ('write_date', '>', start_date)] or [] |
2055 | 59 | return proxy.search(cr, uid, domain) | 59 | return proxy.search(cr, uid, domain) |
2057 | 60 | 60 | ||
2058 | 61 | def del_image_name(self, cr, uid, id, context=None): | 61 | def del_image_name(self, cr, uid, id, context=None): |
2059 | 62 | if context is None: context = {} | 62 | if context is None: context = {} |
2060 | 63 | image_ext_name_obj = self.pool.get('product.images.external.name') | 63 | image_ext_name_obj = self.pool.get('product.images.external.name') |
2061 | @@ -69,6 +69,13 @@ | |||
2062 | 69 | def update_remote_images(self, cr, uid, external_session, ids, context=None): | 69 | def update_remote_images(self, cr, uid, external_session, ids, context=None): |
2063 | 70 | if context is None: | 70 | if context is None: |
2064 | 71 | context = {} | 71 | context = {} |
2065 | 72 | <<<<<<< TREE | ||
2066 | 73 | ======= | ||
2067 | 74 | logger = logging.getLogger('ext synchro') | ||
2068 | 75 | conn = context.get('conn_obj', False) | ||
2069 | 76 | if not conn: | ||
2070 | 77 | return False | ||
2071 | 78 | >>>>>>> MERGE-SOURCE | ||
2072 | 72 | 79 | ||
2073 | 73 | ir_model_data_obj = self.pool.get('ir.model.data') | 80 | ir_model_data_obj = self.pool.get('ir.model.data') |
2074 | 74 | 81 | ||
2075 | @@ -112,12 +119,13 @@ | |||
2076 | 112 | image_2_date[image['id']] = image['write_date'] or image['create_date'] | 119 | image_2_date[image['id']] = image['write_date'] or image['create_date'] |
2077 | 113 | list_date = date_2_image.keys() | 120 | list_date = date_2_image.keys() |
2078 | 114 | list_date.sort() | 121 | list_date.sort() |
2080 | 115 | 122 | ||
2081 | 116 | ids = [date_2_image[date] for date in list_date] | 123 | ids = [date_2_image[date] for date in list_date] |
2082 | 117 | 124 | ||
2083 | 118 | while ids: | 125 | while ids: |
2084 | 119 | product_images = self.browse_w_order(cr, uid, ids[:1000], context=context) | 126 | product_images = self.browse_w_order(cr, uid, ids[:1000], context=context) |
2085 | 120 | for each in product_images: | 127 | for each in product_images: |
2086 | 128 | <<<<<<< TREE | ||
2087 | 121 | product_extid = each.product_id.get_extid(external_session.referential_id.id) | 129 | product_extid = each.product_id.get_extid(external_session.referential_id.id) |
2088 | 122 | if not product_extid: | 130 | if not product_extid: |
2089 | 123 | external_session.logger.info("The product %s do not exist on magento" %(each.product_id.default_code)) | 131 | external_session.logger.info("The product %s do not exist on magento" %(each.product_id.default_code)) |
2090 | @@ -163,10 +171,51 @@ | |||
2091 | 163 | 171 | ||
2092 | 164 | 172 | ||
2093 | 165 | if context.get('last_images_export_date') and image_2_date[each.id] > context['last_images_export_date']: #indeed if a product was created a long time ago and checked as exportable recently, the write date of the image can be far away in the past | 173 | if context.get('last_images_export_date') and image_2_date[each.id] > context['last_images_export_date']: #indeed if a product was created a long time ago and checked as exportable recently, the write date of the image can be far away in the past |
2094 | 174 | ======= | ||
2095 | 175 | need_to_be_created = True | ||
2096 | 176 | ext_file_name = each.oeid_to_extid(context['external_referential_id']) | ||
2097 | 177 | if ext_file_name: #If update | ||
2098 | 178 | try: | ||
2099 | 179 | logger.info("Updating %s's image: %s", each.product_id.magento_sku, each.name) | ||
2100 | 180 | result = update_image(ext_file_name, each) | ||
2101 | 181 | logger.info("%s's image updated with sucess: %s", each.product_id.magento_sku, each.name) | ||
2102 | 182 | need_to_be_created = False | ||
2103 | 183 | except Exception, e: | ||
2104 | 184 | logger.error(_("Error in connecting:%s"), e, exc_info=True) | ||
2105 | 185 | if not "Fault 103" in str(e): | ||
2106 | 186 | logger.error(_("Unknow error stop export")) | ||
2107 | 187 | raise | ||
2108 | 188 | else: | ||
2109 | 189 | #If the image was deleded in magento, the external name is automatically deleded before trying to re-create the image in magento | ||
2110 | 190 | model_data_ids = ir_model_data_obj.search(cr, uid, [('model', '=', self._name), ('res_id', '=', each.id), ('external_referential_id', '=', context['external_referential_id'])]) | ||
2111 | 191 | if model_data_ids and len(model_data_ids) > 0: | ||
2112 | 192 | ir_model_data_obj.unlink(cr, uid, model_data_ids, context=context) | ||
2113 | 193 | logger.error(_("The image don't exist in magento, try to create it")) | ||
2114 | 194 | if need_to_be_created: | ||
2115 | 195 | if each.product_id.magento_sku: | ||
2116 | 196 | logger.info("Sending %s's image: %s", each.product_id.magento_sku, each.name) | ||
2117 | 197 | result = conn.call('catalog_product_attribute_media.create', | ||
2118 | 198 | [each.product_id.magento_sku, | ||
2119 | 199 | {'file':{ | ||
2120 | 200 | 'name':each.name, | ||
2121 | 201 | 'content': each.file, | ||
2122 | 202 | 'mime': each.link and each.url and mimetypes.guess_type(each.url)[0] or each.extention and mimetypes.guess_type(each.extention)[0] or 'image/jpeg', | ||
2123 | 203 | } | ||
2124 | 204 | } | ||
2125 | 205 | ]) | ||
2126 | 206 | self.create_external_id_vals(cr, uid, each.id, result, context['external_referential_id'], context=context) | ||
2127 | 207 | result = update_image(result, each) | ||
2128 | 208 | logger.info("%s's image send with sucess: %s", each.product_id.magento_sku, each.name) | ||
2129 | 209 | if image_2_date[each.id] > context['last_images_export_date']: #indeed if a product was created a long time ago and checked as exportable recently, the write date of the image can be far away in the past | ||
2130 | 210 | >>>>>>> MERGE-SOURCE | ||
2131 | 166 | self.pool.get('sale.shop').write(cr,uid,context['shop_id'],{'last_images_export_date':image_2_date[each.id]}) | 211 | self.pool.get('sale.shop').write(cr,uid,context['shop_id'],{'last_images_export_date':image_2_date[each.id]}) |
2132 | 167 | cr.commit() | 212 | cr.commit() |
2133 | 168 | ids = ids[1000:] | 213 | ids = ids[1000:] |
2134 | 214 | <<<<<<< TREE | ||
2135 | 169 | external_session.logger.info("still %s image to export" %len(ids)) | 215 | external_session.logger.info("still %s image to export" %len(ids)) |
2136 | 216 | ======= | ||
2137 | 217 | logger.info("still %s image to export", len(ids)) | ||
2138 | 218 | >>>>>>> MERGE-SOURCE | ||
2139 | 170 | return True | 219 | return True |
2141 | 171 | 220 | ||
2142 | 172 | product_images() | 221 | product_images() |
2143 | 173 | 222 | ||
2144 | === modified file 'magentoerpconnect/sale.py' | |||
2145 | --- magentoerpconnect/sale.py 2012-05-28 19:39:10 +0000 | |||
2146 | +++ magentoerpconnect/sale.py 2012-07-06 14:53:18 +0000 | |||
2147 | @@ -26,6 +26,7 @@ | |||
2148 | 26 | import pooler | 26 | import pooler |
2149 | 27 | import magerp_osv | 27 | import magerp_osv |
2150 | 28 | import netsvc | 28 | import netsvc |
2151 | 29 | import logging | ||
2152 | 29 | from tools.translate import _ | 30 | from tools.translate import _ |
2153 | 30 | import string | 31 | import string |
2154 | 31 | import tools | 32 | import tools |
2155 | @@ -56,6 +57,7 @@ | |||
2156 | 56 | 57 | ||
2157 | 57 | class sale_shop(magerp_osv.magerp_osv): | 58 | class sale_shop(magerp_osv.magerp_osv): |
2158 | 58 | _inherit = "sale.shop" | 59 | _inherit = "sale.shop" |
2159 | 60 | <<<<<<< TREE | ||
2160 | 59 | 61 | ||
2161 | 60 | @only_for_referential('magento') | 62 | @only_for_referential('magento') |
2162 | 61 | def init_context_before_exporting_resource(self, cr, uid, external_session, object_id, resource_name, context=None): | 63 | def init_context_before_exporting_resource(self, cr, uid, external_session, object_id, resource_name, context=None): |
2163 | @@ -73,6 +75,9 @@ | |||
2164 | 73 | 75 | ||
2165 | 74 | 76 | ||
2166 | 75 | 77 | ||
2167 | 78 | ======= | ||
2168 | 79 | |||
2169 | 80 | >>>>>>> MERGE-SOURCE | ||
2170 | 76 | def _get_exportable_product_ids(self, cr, uid, ids, name, args, context=None): | 81 | def _get_exportable_product_ids(self, cr, uid, ids, name, args, context=None): |
2171 | 77 | res = super(sale_shop, self)._get_exportable_product_ids(cr, uid, ids, name, args, context=None) | 82 | res = super(sale_shop, self)._get_exportable_product_ids(cr, uid, ids, name, args, context=None) |
2172 | 78 | for shop_id in res: | 83 | for shop_id in res: |
2173 | @@ -95,6 +100,10 @@ | |||
2174 | 95 | 100 | ||
2175 | 96 | def export_images(self, cr, uid, ids, context=None): | 101 | def export_images(self, cr, uid, ids, context=None): |
2176 | 97 | if context is None: context = {} | 102 | if context is None: context = {} |
2177 | 103 | <<<<<<< TREE | ||
2178 | 104 | ======= | ||
2179 | 105 | logger = logging.getLogger('ext synchro') | ||
2180 | 106 | >>>>>>> MERGE-SOURCE | ||
2181 | 98 | start_date = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) | 107 | start_date = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT) |
2182 | 99 | image_obj = self.pool.get('product.images') | 108 | image_obj = self.pool.get('product.images') |
2183 | 100 | for shop in self.browse(cr, uid, ids): | 109 | for shop in self.browse(cr, uid, ids): |
2184 | @@ -102,11 +111,19 @@ | |||
2185 | 102 | exportable_product_ids = self.read(cr, uid, shop.id, ['exportable_product_ids'], context=context)['exportable_product_ids'] | 111 | exportable_product_ids = self.read(cr, uid, shop.id, ['exportable_product_ids'], context=context)['exportable_product_ids'] |
2186 | 103 | res = self.pool.get('product.product').get_exportable_images(cr, uid, external_session, exportable_product_ids, context=context) | 112 | res = self.pool.get('product.product').get_exportable_images(cr, uid, external_session, exportable_product_ids, context=context) |
2187 | 104 | if res: | 113 | if res: |
2188 | 114 | <<<<<<< TREE | ||
2189 | 105 | _logger.info("Creating %s images", len(res['to_create'])) | 115 | _logger.info("Creating %s images", len(res['to_create'])) |
2190 | 106 | _logger.info("Updating %s images", len(res['to_update'])) | 116 | _logger.info("Updating %s images", len(res['to_update'])) |
2191 | 107 | image_obj.update_remote_images(cr, uid, external_session, res['to_update']+res['to_create'], context) | 117 | image_obj.update_remote_images(cr, uid, external_session, res['to_update']+res['to_create'], context) |
2192 | 108 | shop.write({'last_images_export_date': start_date}) | 118 | shop.write({'last_images_export_date': start_date}) |
2193 | 119 | ======= | ||
2194 | 120 | logger.info("Creating %s images", len(res['to_create'])) | ||
2195 | 121 | logger.info("Updating %s images", len(res['to_update'])) | ||
2196 | 122 | image_obj.update_remote_images(cr, uid, res['to_update']+res['to_create'], context) | ||
2197 | 123 | self.write(cr,uid,context['shop_id'],{'last_images_export_date': start_date}) | ||
2198 | 124 | >>>>>>> MERGE-SOURCE | ||
2199 | 109 | return True | 125 | return True |
2200 | 126 | <<<<<<< TREE | ||
2201 | 110 | 127 | ||
2202 | 111 | #TODO refactor the ay to export images | 128 | #TODO refactor the ay to export images |
2203 | 112 | #No time for doing it now so I just overwrite the generic function | 129 | #No time for doing it now so I just overwrite the generic function |
2204 | @@ -119,6 +136,11 @@ | |||
2205 | 119 | return super(sale_shop, self).export_resources(cr, uid, ids, resource_name, context=context) | 136 | return super(sale_shop, self).export_resources(cr, uid, ids, resource_name, context=context) |
2206 | 120 | 137 | ||
2207 | 121 | def _get_rootcategory(self, cr, uid, ids, name, value, context=None): | 138 | def _get_rootcategory(self, cr, uid, ids, name, value, context=None): |
2208 | 139 | ======= | ||
2209 | 140 | |||
2210 | 141 | |||
2211 | 142 | def _get_rootcategory(self, cr, uid, ids, prop, unknow_none, context=None): | ||
2212 | 143 | >>>>>>> MERGE-SOURCE | ||
2213 | 122 | res = {} | 144 | res = {} |
2214 | 123 | for shop in self.browse(cr, uid, ids, context): | 145 | for shop in self.browse(cr, uid, ids, context): |
2215 | 124 | if shop.root_category_id and shop.shop_group_id.referential_id: | 146 | if shop.root_category_id and shop.shop_group_id.referential_id: |
2216 | @@ -175,12 +197,66 @@ | |||
2217 | 175 | 'allow_magento_notification': lambda * a: False, | 197 | 'allow_magento_notification': lambda * a: False, |
2218 | 176 | } | 198 | } |
2219 | 177 | 199 | ||
2220 | 200 | <<<<<<< TREE | ||
2221 | 178 | def _get_magento_status(self, cr, uid, order, context=None): | 201 | def _get_magento_status(self, cr, uid, order, context=None): |
2222 | 179 | return ORDER_STATUS_MAPPING.get(order.state) | 202 | return ORDER_STATUS_MAPPING.get(order.state) |
2223 | 180 | 203 | ||
2224 | 181 | def update_shop_orders(self, cr, uid, external_session, order, ext_id, context=None): | 204 | def update_shop_orders(self, cr, uid, external_session, order, ext_id, context=None): |
2225 | 182 | if context is None: context = {} | 205 | if context is None: context = {} |
2226 | 183 | result = False | 206 | result = False |
2227 | 207 | ======= | ||
2228 | 208 | |||
2229 | 209 | def import_shop_orders(self, cr, uid, shop, defaults, context=None): | ||
2230 | 210 | if context is None: context = {} | ||
2231 | 211 | result = super(sale_shop, self).import_shop_orders(cr, uid, shop, defaults=defaults, context=context) | ||
2232 | 212 | [result.setdefault(key, []) for key in ['create_ids', 'write_ids', 'unchanged_ids']] | ||
2233 | 213 | if shop.magento_shop: | ||
2234 | 214 | self.check_need_to_update(cr, uid, [shop.id], context=context) | ||
2235 | 215 | for storeview in shop.storeview_ids: | ||
2236 | 216 | magento_storeview_id = self.pool.get('magerp.storeviews').oeid_to_extid(cr, uid, storeview.id, shop.referential_id.id, context={}) | ||
2237 | 217 | ids_or_filter = {'store_id': {'eq': magento_storeview_id}, 'state': {'neq': 'canceled'}} | ||
2238 | 218 | if shop.import_orders_from_date: | ||
2239 | 219 | ids_or_filter.update({'created_at' : {'gt': shop.import_orders_from_date}}) | ||
2240 | 220 | nb_last_created_ids = SALE_ORDER_IMPORT_STEP | ||
2241 | 221 | while nb_last_created_ids: | ||
2242 | 222 | defaults['magento_storeview_id'] = storeview.id | ||
2243 | 223 | ctx = context.copy() | ||
2244 | 224 | ctx['ids_or_filter'] = ids_or_filter | ||
2245 | 225 | resp = self.pool.get('sale.order').mage_import_base(cr, uid, context.get('conn_obj', False), | ||
2246 | 226 | shop.referential_id.id, defaults=defaults, | ||
2247 | 227 | context=ctx) | ||
2248 | 228 | result['create_ids'] += resp.get('create_ids', []) | ||
2249 | 229 | result['write_ids'] += resp.get('write_ids', []) | ||
2250 | 230 | result['unchanged_ids'] += resp.get('unchanged_ids', []) | ||
2251 | 231 | nb_last_created_ids = len(resp.get('create_ids', []) + resp.get('write_ids', []) + resp.get('unchanged_ids', [])) | ||
2252 | 232 | print nb_last_created_ids | ||
2253 | 233 | return result | ||
2254 | 234 | |||
2255 | 235 | def check_need_to_update(self, cr, uid, ids, context=None): | ||
2256 | 236 | """ This function will update the order status in OpenERP for | ||
2257 | 237 | the order which are in the state 'need to update' """ | ||
2258 | 238 | so_obj = self.pool.get('sale.order') | ||
2259 | 239 | |||
2260 | 240 | for shop in self.browse(cr, uid, ids): | ||
2261 | 241 | conn = shop.referential_id.external_connection() | ||
2262 | 242 | # Update the state of orders in OERP that are in "need_to_update":True | ||
2263 | 243 | # from the Magento's corresponding orders | ||
2264 | 244 | |||
2265 | 245 | # Get all need_to_update orders in OERP | ||
2266 | 246 | orders_to_update = so_obj.search( | ||
2267 | 247 | cr, uid, | ||
2268 | 248 | [('need_to_update', '=', True), | ||
2269 | 249 | ('shop_id', '=', shop.id)], | ||
2270 | 250 | context=context) | ||
2271 | 251 | so_obj.check_need_to_update( | ||
2272 | 252 | cr, uid, orders_to_update, conn, context=context) | ||
2273 | 253 | return False | ||
2274 | 254 | |||
2275 | 255 | def update_shop_orders(self, cr, uid, order, ext_id, context=None): | ||
2276 | 256 | if context is None: context = {} | ||
2277 | 257 | result = {} | ||
2278 | 258 | |||
2279 | 259 | >>>>>>> MERGE-SOURCE | ||
2280 | 184 | if order.shop_id.allow_magento_order_status_push: | 260 | if order.shop_id.allow_magento_order_status_push: |
2281 | 185 | sale_obj = self.pool.get('sale.order') | 261 | sale_obj = self.pool.get('sale.order') |
2282 | 186 | #status update: | 262 | #status update: |
2283 | @@ -252,6 +328,7 @@ | |||
2284 | 252 | cr.execute("ALTER TABLE account_invoice_line ALTER COLUMN discount TYPE numeric(16,6);") | 328 | cr.execute("ALTER TABLE account_invoice_line ALTER COLUMN discount TYPE numeric(16,6);") |
2285 | 253 | self.pool.get('sale.report').init(cr) | 329 | self.pool.get('sale.report').init(cr) |
2286 | 254 | super(sale_order, self)._auto_init(cr, context) | 330 | super(sale_order, self)._auto_init(cr, context) |
2287 | 331 | <<<<<<< TREE | ||
2288 | 255 | 332 | ||
2289 | 256 | #TODO reimplement the check on tva in a good way | 333 | #TODO reimplement the check on tva in a good way |
2290 | 257 | # # Adds vat number (country code+magento vat) if base_vat module is installed and Magento sends customer_taxvat | 334 | # # Adds vat number (country code+magento vat) if base_vat module is installed and Magento sends customer_taxvat |
2291 | @@ -296,6 +373,389 @@ | |||
2292 | 296 | vals['paid'] = True | 373 | vals['paid'] = True |
2293 | 297 | vals['amount'] = float(payment_info['amount_paid']) | 374 | vals['amount'] = float(payment_info['amount_paid']) |
2294 | 298 | return vals | 375 | return vals |
2295 | 376 | ======= | ||
2296 | 377 | |||
2297 | 378 | def get_order_addresses(self, cr, uid, referential_id, data_record, context=None): | ||
2298 | 379 | partner_obj = self.pool.get('res.partner') | ||
2299 | 380 | partner_address_obj = self.pool.get('res.partner.address') | ||
2300 | 381 | res = {} | ||
2301 | 382 | |||
2302 | 383 | # Magento allows to create a sale order | ||
2303 | 384 | # without register as a user | ||
2304 | 385 | is_guest_order = bool(int(data_record.get('customer_is_guest', 0))) | ||
2305 | 386 | |||
2306 | 387 | # for a guest order or when magento | ||
2307 | 388 | # does not provide customer_id on a normal order | ||
2308 | 389 | # (it happens magento inconsistencies are common) | ||
2309 | 390 | if (is_guest_order or | ||
2310 | 391 | (data_record.get('website_id') and | ||
2311 | 392 | not data_record.get('customer_id'))): | ||
2312 | 393 | |||
2313 | 394 | website_obj = self.pool.get('external.shop.group') | ||
2314 | 395 | oerp_website_id = website_obj.extid_to_oeid( | ||
2315 | 396 | cr, uid, data_record['website_id'], referential_id, context=context) | ||
2316 | 397 | |||
2317 | 398 | # first, try to find an already bound partner | ||
2318 | 399 | # with same mail for same website | ||
2319 | 400 | partner_id = partner_obj.search_magento_partner( | ||
2320 | 401 | cr, uid, | ||
2321 | 402 | data_record['customer_email'], | ||
2322 | 403 | oerp_website_id, | ||
2323 | 404 | is_bound=True, # search only for partners already bound | ||
2324 | 405 | context=context) | ||
2325 | 406 | |||
2326 | 407 | # if we have found one, we "fix" the data_record | ||
2327 | 408 | # with the magento customer id | ||
2328 | 409 | if partner_id: | ||
2329 | 410 | ext_customer_id = partner_obj.oeid_to_extid( | ||
2330 | 411 | cr, uid, partner_id, referential_id, context=context) | ||
2331 | 412 | data_record['customer_id'] = ext_customer_id | ||
2332 | 413 | |||
2333 | 414 | # no bound partner matching | ||
2334 | 415 | # means that we have to consider it as a guest order | ||
2335 | 416 | else: | ||
2336 | 417 | is_guest_order = True | ||
2337 | 418 | |||
2338 | 419 | # if we do not have a customer_id, the sale order | ||
2339 | 420 | # is a guest sale order, so we cannot link the customer | ||
2340 | 421 | if is_guest_order: | ||
2341 | 422 | # when we import a guest sale order, we create the partner | ||
2342 | 423 | # on the fly and we do not bind it ir.model.data | ||
2343 | 424 | |||
2344 | 425 | # as we do not have a customer data record in the sale order | ||
2345 | 426 | # data record, we manually populate one from the magento | ||
2346 | 427 | # sale order record and import it with the standard mappings | ||
2347 | 428 | address = data_record['billing_address'] | ||
2348 | 429 | |||
2349 | 430 | customer_record = { | ||
2350 | 431 | 'firstname': address['firstname'], | ||
2351 | 432 | 'middlename': address['middlename'], | ||
2352 | 433 | 'lastname': address['lastname'], | ||
2353 | 434 | 'prefix': address['prefix'], | ||
2354 | 435 | 'suffix': address.get('suffix', False), | ||
2355 | 436 | 'email': data_record.get('customer_email', False), | ||
2356 | 437 | 'taxvat': data_record.get('customer_taxvat', False), | ||
2357 | 438 | 'group_id': data_record.get('customer_group_id', False), | ||
2358 | 439 | 'gender': data_record.get('customer_gender', False), | ||
2359 | 440 | 'store_id': data_record['store_id'], | ||
2360 | 441 | 'created_at': data_record['created_at'], | ||
2361 | 442 | 'updated_at': False, | ||
2362 | 443 | 'created_in': False, | ||
2363 | 444 | 'dob': data_record.get('customer_dob', False), | ||
2364 | 445 | 'website_id': data_record.get('website_id', False), | ||
2365 | 446 | } | ||
2366 | 447 | partner_defaults = {'is_magento_guest': True} | ||
2367 | 448 | partner_id = partner_obj.ext_import_unbound( | ||
2368 | 449 | cr, uid, customer_record, referential_id, | ||
2369 | 450 | defaults=partner_defaults, context=context) | ||
2370 | 451 | else: | ||
2371 | 452 | # always update the customer when importing an order | ||
2372 | 453 | imp_ctx = dict(context) | ||
2373 | 454 | imp_ctx['id'] = data_record['customer_id'] | ||
2374 | 455 | partner_obj.get_external_data( | ||
2375 | 456 | cr, uid, | ||
2376 | 457 | context.get('conn_obj'), | ||
2377 | 458 | referential_id, | ||
2378 | 459 | defaults={}, | ||
2379 | 460 | context=imp_ctx) | ||
2380 | 461 | partner_id = partner_obj.extid_to_oeid( | ||
2381 | 462 | cr, uid, data_record['customer_id'], referential_id) | ||
2382 | 463 | |||
2383 | 464 | # update the address book of the customer, this addresses | ||
2384 | 465 | # will be available in the partner form and the searches | ||
2385 | 466 | partner_obj.import_magento_address_book( | ||
2386 | 467 | cr, uid, partner_id, referential_id, context=context) | ||
2387 | 468 | |||
2388 | 469 | # The addresses of the sale order are imported as active=false | ||
2389 | 470 | # so they are linked with the sale order but they are not displayed | ||
2390 | 471 | # in the customer form and the searches. | ||
2391 | 472 | |||
2392 | 473 | # We import the addresses of the sale order as Active = False | ||
2393 | 474 | # so they will be available in the documents generated as the | ||
2394 | 475 | # sale order or the picking, but they won't be available on | ||
2395 | 476 | # the partner form or the searches. Too many adresses would | ||
2396 | 477 | # be displayed. | ||
2397 | 478 | # They are never synchronized, | ||
2398 | 479 | # we keep the revision of the sale order | ||
2399 | 480 | # For the orders which are from guests, we let the addresses | ||
2400 | 481 | # as active because they doesn't have an address book. | ||
2401 | 482 | addresses_defaults = {'partner_id': partner_id, | ||
2402 | 483 | 'email': data_record.get('customer_email', False), | ||
2403 | 484 | 'active': is_guest_order, | ||
2404 | 485 | 'is_magento_order_address': True} | ||
2405 | 486 | # We import the addresses as unbound becauses Magento is not able to | ||
2406 | 487 | # give us an ID when the address is created during the order. | ||
2407 | 488 | # It gives an empty id, a 0 or worse, a wrong id. | ||
2408 | 489 | billing_address = data_record['billing_address'].copy() | ||
2409 | 490 | # remove customer_id because we force it in the defaults | ||
2410 | 491 | # it avoid to try to import the partner by customer_id | ||
2411 | 492 | billing_address.pop('customer_id', False) | ||
2412 | 493 | billing_id = partner_address_obj.ext_import_unbound( | ||
2413 | 494 | cr, uid, billing_address, | ||
2414 | 495 | referential_id, defaults=addresses_defaults, | ||
2415 | 496 | context=context) | ||
2416 | 497 | |||
2417 | 498 | shipping_id = False | ||
2418 | 499 | if data_record['shipping_address']: | ||
2419 | 500 | shipping_address = data_record['shipping_address'].copy() | ||
2420 | 501 | # remove customer_id because we force it in the defaults | ||
2421 | 502 | # it avoid to try to import the partner by customer_id | ||
2422 | 503 | shipping_address.pop('customer_id', False) | ||
2423 | 504 | shipping_id = partner_address_obj.ext_import_unbound( | ||
2424 | 505 | cr, uid, shipping_address, | ||
2425 | 506 | referential_id, defaults=addresses_defaults, | ||
2426 | 507 | context=context) | ||
2427 | 508 | |||
2428 | 509 | # default addresses ids for the sale order | ||
2429 | 510 | res['partner_id'] = partner_id | ||
2430 | 511 | res['partner_order_id'] = res['partner_invoice_id'] = billing_id | ||
2431 | 512 | res['partner_shipping_id'] = shipping_id or billing_id | ||
2432 | 513 | |||
2433 | 514 | if data_record.get('customer_taxvat'): | ||
2434 | 515 | partner_obj.add_magento_vat_number( | ||
2435 | 516 | cr, uid, partner_id, | ||
2436 | 517 | data_record['customer_taxvat'], | ||
2437 | 518 | data_record['billing_address'].get('country_id'), | ||
2438 | 519 | context=context) | ||
2439 | 520 | return res | ||
2440 | 521 | |||
2441 | 522 | def add_order_extra_line(self, cr, uid, res, data_record, ext_field, product_ref, defaults, context=None): | ||
2442 | 523 | """ Add or substract amount on order as a separate line item with single quantity for each type of amounts like : | ||
2443 | 524 | shipping, cash on delivery, discount, gift certificates... | ||
2444 | 525 | |||
2445 | 526 | @param res: dict of the order to create | ||
2446 | 527 | @param data_record: full data dict of the order | ||
2447 | 528 | @param ext_field: name of the field in data_record where the amount of the extra lineis stored | ||
2448 | 529 | @param product_ref: tuple with module and xml_id (module, xml_id) of the product to use for the extra line | ||
2449 | 530 | |||
2450 | 531 | Optional arguments in context: | ||
2451 | 532 | sign: multiply the amount with the sign to add or substract it from the sale order | ||
2452 | 533 | ext_tax_field: name of the field in data_record where the tax amount is stored | ||
2453 | 534 | ext_code_field: name of the field in data_record containing a code (for coupons and gift certificates) which will be printed on the product name | ||
2454 | 535 | """ | ||
2455 | 536 | if context is None: context = {} | ||
2456 | 537 | model_data_obj = self.pool.get('ir.model.data') | ||
2457 | 538 | sign = 'sign' in context and context['sign'] or 1 | ||
2458 | 539 | ext_tax_field = 'ext_tax_field' in context and context['ext_tax_field'] or None | ||
2459 | 540 | ext_code_field = 'ext_code_field' in context and context['ext_code_field'] or None | ||
2460 | 541 | |||
2461 | 542 | model, product_id = model_data_obj.get_object_reference(cr, uid, *product_ref) | ||
2462 | 543 | product = self.pool.get('product.product').browse(cr, uid, product_id, context) | ||
2463 | 544 | is_tax_included = context.get('price_is_tax_included', False) | ||
2464 | 545 | amount = float(data_record[ext_field]) * sign | ||
2465 | 546 | name = product.name | ||
2466 | 547 | if ext_code_field and data_record.get(ext_code_field, False): | ||
2467 | 548 | name = "%s [%s]" % (name, data_record[ext_code_field]) | ||
2468 | 549 | |||
2469 | 550 | if is_tax_included: | ||
2470 | 551 | price_unit = float(amount) + float(data_record[ext_tax_field]) | ||
2471 | 552 | else: | ||
2472 | 553 | price_unit = float(amount) | ||
2473 | 554 | |||
2474 | 555 | extra_line = { | ||
2475 | 556 | 'product_id': product.id, | ||
2476 | 557 | 'name': name, | ||
2477 | 558 | 'product_uom': product.uom_id.id, | ||
2478 | 559 | 'product_uom_qty': 1, | ||
2479 | 560 | 'price_unit': price_unit, | ||
2480 | 561 | } | ||
2481 | 562 | |||
2482 | 563 | if not res.get('order_line'): | ||
2483 | 564 | res['order_line'] = [] | ||
2484 | 565 | |||
2485 | 566 | if context.get('use_external_tax'): | ||
2486 | 567 | # get the tax computed by the external system | ||
2487 | 568 | tax_vat = abs(float(data_record[ext_tax_field]) / amount) | ||
2488 | 569 | line_tax_id = self.pool.get('account.tax').get_tax_from_rate(cr, uid, tax_vat, context.get('is_tax_included'), context=context) | ||
2489 | 570 | extra_line['tax_id'] = [(6, 0, line_tax_id)] | ||
2490 | 571 | else: | ||
2491 | 572 | # compute the taxes, apply fiscal positions, default values and so on | ||
2492 | 573 | extra_line = self.pool.get('sale.order.line').play_sale_order_line_onchange(cr, uid, extra_line, res, res['order_line'], defaults, context=context) | ||
2493 | 574 | res['order_line'].append((0, 0, extra_line)) | ||
2494 | 575 | |||
2495 | 576 | return res | ||
2496 | 577 | |||
2497 | 578 | def add_order_shipping(self, cr, uid, res, external_referential_id, data_record, defaults, context=None): | ||
2498 | 579 | if context is None: context = {} | ||
2499 | 580 | if data_record.get('shipping_amount', False) and float(data_record.get('shipping_amount', False)) > 0: | ||
2500 | 581 | ctx = context.copy() | ||
2501 | 582 | ctx.update({ | ||
2502 | 583 | 'ext_tax_field': 'shipping_tax_amount', | ||
2503 | 584 | }) | ||
2504 | 585 | product_ref = ('base_sale_multichannels', 'product_product_shipping') | ||
2505 | 586 | res = self.add_order_extra_line(cr, uid, res, data_record, 'shipping_amount', product_ref, defaults, ctx) | ||
2506 | 587 | return res | ||
2507 | 588 | |||
2508 | 589 | def add_gift_certificates(self, cr, uid, res, external_referential_id, data_record, defaults, context=None): | ||
2509 | 590 | if context is None: context = {} | ||
2510 | 591 | if data_record.get('giftcert_amount', False) and float(data_record.get('giftcert_amount', False)) > 0: | ||
2511 | 592 | ctx = context.copy() | ||
2512 | 593 | ctx.update({ | ||
2513 | 594 | 'ext_code_field': 'giftcert_code', | ||
2514 | 595 | 'sign': -1, | ||
2515 | 596 | }) | ||
2516 | 597 | product_ref = ('magentoerpconnect', 'product_product_gift') | ||
2517 | 598 | res = self.add_order_extra_line(cr, uid, res, data_record, 'giftcert_amount', product_ref, defaults, ctx) | ||
2518 | 599 | return res | ||
2519 | 600 | |||
2520 | 601 | def add_discount(self, cr, uid, res, external_referential_id, data_record, defaults, context=None): | ||
2521 | 602 | #TODO fix me rev 476 | ||
2522 | 603 | #if data_record.get('discount_amount', False) and float(data_record.get('discount_amount', False)) < 0: | ||
2523 | 604 | # ctx = context.copy() | ||
2524 | 605 | # ctx.update({ | ||
2525 | 606 | # 'ext_code_field': 'coupon_code', | ||
2526 | 607 | # }) | ||
2527 | 608 | # product_ref = ('magentoerpconnect', 'product_product_discount') | ||
2528 | 609 | # res = self.add_order_extra_line(cr, uid, res, data_record, 'discount_amount', product_ref, defaults, ctx) | ||
2529 | 610 | return res | ||
2530 | 611 | |||
2531 | 612 | def add_cash_on_delivery(self, cr, uid, res, external_referential_id, data_record, defaults, context=None): | ||
2532 | 613 | if context is None: context = {} | ||
2533 | 614 | if data_record.get('cod_fee', False) and float(data_record.get('cod_fee', False)) > 0: | ||
2534 | 615 | ctx = context.copy() | ||
2535 | 616 | ctx.update({ | ||
2536 | 617 | 'ext_tax_field': 'cod_tax_amount', | ||
2537 | 618 | }) | ||
2538 | 619 | product_ref = ('magentoerpconnect', 'product_product_cash_on_delivery') | ||
2539 | 620 | res = self.add_order_extra_line(cr, uid, res, data_record, 'cod_fee', product_ref, defaults, ctx) | ||
2540 | 621 | return res | ||
2541 | 622 | |||
2542 | 623 | def convert_extdata_into_oedata(self, cr, uid, external_data, external_referential_id, parent_data=None, defaults=None, context=None): | ||
2543 | 624 | res = super(sale_order, self).convert_extdata_into_oedata(cr, uid, external_data, external_referential_id, parent_data=parent_data, defaults=defaults, context=context) | ||
2544 | 625 | res=res[0] | ||
2545 | 626 | external_data = external_data[0] | ||
2546 | 627 | res = self.add_order_shipping(cr, uid, res, external_referential_id, external_data, defaults, context) | ||
2547 | 628 | res = self.add_gift_certificates(cr, uid, res, external_referential_id, external_data, defaults, context) | ||
2548 | 629 | res = self.add_discount(cr, uid, res, external_referential_id, external_data, defaults, context) | ||
2549 | 630 | res = self.add_cash_on_delivery(cr, uid, res, external_referential_id, external_data, defaults, context) | ||
2550 | 631 | return [res] | ||
2551 | 632 | |||
2552 | 633 | def _merge_sub_items(self, cr, uid, product_type, top_item, child_items, context=None): | ||
2553 | 634 | """ | ||
2554 | 635 | Manage the sub items of the magento sale order lines. A top item contains one | ||
2555 | 636 | or many child_items. For some product types, we want to merge them in the main | ||
2556 | 637 | item, or keep them as order line. | ||
2557 | 638 | |||
2558 | 639 | A list may be returned to add many items (ie to keep all child_items as items. | ||
2559 | 640 | |||
2560 | 641 | :param top_item: main item (bundle, configurable) | ||
2561 | 642 | :param child_items: list of childs of the top item | ||
2562 | 643 | :return: item or list of items | ||
2563 | 644 | """ | ||
2564 | 645 | if product_type == 'configurable': | ||
2565 | 646 | item = top_item.copy() | ||
2566 | 647 | # For configurable product all information regarding the price is in the configurable item | ||
2567 | 648 | # In the child a lot of information is empty, but contains the right sku and product_id | ||
2568 | 649 | # So the real product_id and the sku and the name have to be extracted from the child | ||
2569 | 650 | for field in ['sku', 'product_id', 'name']: | ||
2570 | 651 | item[field] = child_items[0][field] | ||
2571 | 652 | return item | ||
2572 | 653 | return top_item | ||
2573 | 654 | |||
2574 | 655 | def data_record_filter(self, cr, uid, data_record, context=None): | ||
2575 | 656 | child_items = {} # key is the parent item id | ||
2576 | 657 | top_items = [] | ||
2577 | 658 | |||
2578 | 659 | # Group the childs with their parent | ||
2579 | 660 | for item in data_record['items']: | ||
2580 | 661 | if item.get('parent_item_id'): | ||
2581 | 662 | child_items.setdefault(item['parent_item_id'], []).append(item) | ||
2582 | 663 | else: | ||
2583 | 664 | top_items.append(item) | ||
2584 | 665 | |||
2585 | 666 | all_items = [] | ||
2586 | 667 | for top_item in top_items: | ||
2587 | 668 | if top_item['item_id'] in child_items: | ||
2588 | 669 | item_modified = self._merge_sub_items(cr, uid, | ||
2589 | 670 | top_item['product_type'], | ||
2590 | 671 | top_item, | ||
2591 | 672 | child_items[top_item['item_id']], | ||
2592 | 673 | context=context) | ||
2593 | 674 | if not isinstance(item_modified, list): | ||
2594 | 675 | item_modified = [item_modified] | ||
2595 | 676 | all_items.extend(item_modified) | ||
2596 | 677 | else: | ||
2597 | 678 | all_items.append(top_item) | ||
2598 | 679 | |||
2599 | 680 | data_record['items'] = all_items | ||
2600 | 681 | return data_record | ||
2601 | 682 | |||
2602 | 683 | def oevals_from_extdata(self, cr, uid, external_referential_id, data_record, key_field, mapping_lines, parent_data=None, previous_lines=None, defaults=None, context=None): | ||
2603 | 684 | if context is None: context = {} | ||
2604 | 685 | if data_record.get('items', False): | ||
2605 | 686 | data_record = self.data_record_filter(cr, uid, data_record, context=context) | ||
2606 | 687 | #TODO refactor this code regarding the new feature of sub-mapping in base_external_referential | ||
2607 | 688 | if not context.get('one_by_one', False): | ||
2608 | 689 | # we fix the website_id when it is empty because we need it to | ||
2609 | 690 | # find the correct partner (based on email + website_id) | ||
2610 | 691 | # website is based on the store_id which is: | ||
2611 | 692 | # website m2o -> store | ||
2612 | 693 | if not data_record.get('website_id') and data_record.get('store_id'): | ||
2613 | 694 | store_obj = self.pool.get('magerp.storeviews') | ||
2614 | 695 | store_id = store_obj.extid_to_oeid( | ||
2615 | 696 | cr, uid, data_record['store_id'], external_referential_id) | ||
2616 | 697 | store = store_obj.browse(cr, uid, store_id, context=context) | ||
2617 | 698 | data_record['website_id'] = store.website_id.oeid_to_extid( | ||
2618 | 699 | external_referential_id=external_referential_id, context=context) | ||
2619 | 700 | |||
2620 | 701 | defaults.update(self.get_order_addresses( | ||
2621 | 702 | cr, uid, external_referential_id, data_record, context=context)) | ||
2622 | 703 | res = super(magerp_osv.magerp_osv, self).oevals_from_extdata(cr, uid, external_referential_id, data_record, key_field, mapping_lines, parent_data, previous_lines, defaults, context) | ||
2623 | 704 | |||
2624 | 705 | #Move me in a mapping | ||
2625 | 706 | if not context.get('one_by_one', False): | ||
2626 | 707 | if data_record.get('status_history', False) and len(data_record['status_history']) > 0: | ||
2627 | 708 | res['date_order'] = data_record['status_history'][len(data_record['status_history'])-1]['created_at'] | ||
2628 | 709 | return res | ||
2629 | 710 | |||
2630 | 711 | def _parse_external_payment(self, cr, uid, order_data, context=None): | ||
2631 | 712 | """ | ||
2632 | 713 | Parse the external order data and return if the sale order | ||
2633 | 714 | has been paid and the amount to pay or to be paid | ||
2634 | 715 | |||
2635 | 716 | :param dict order_data: payment information of the magento sale | ||
2636 | 717 | order | ||
2637 | 718 | :return: tuple where : | ||
2638 | 719 | - first item indicates if the payment has been done (True or False) | ||
2639 | 720 | - second item represents the amount paid or to be paid | ||
2640 | 721 | """ | ||
2641 | 722 | paid = amount = False | ||
2642 | 723 | payment_info = order_data.get('payment') | ||
2643 | 724 | if payment_info: | ||
2644 | 725 | amount = False | ||
2645 | 726 | if payment_info.get('amount_paid', False): | ||
2646 | 727 | amount = payment_info.get('amount_paid', False) | ||
2647 | 728 | paid = True | ||
2648 | 729 | elif payment_info.get('amount_ordered', False): | ||
2649 | 730 | amount = payment_info.get('amount_ordered', False) | ||
2650 | 731 | return paid, amount | ||
2651 | 732 | |||
2652 | 733 | def create_payments(self, cr, uid, order_id, data_record, context=None): | ||
2653 | 734 | if context is None: | ||
2654 | 735 | context = {} | ||
2655 | 736 | |||
2656 | 737 | if 'Magento' in context.get('external_referential_type', ''): | ||
2657 | 738 | payment_info = data_record.get('payment') | ||
2658 | 739 | paid, amount = self._parse_external_payment( | ||
2659 | 740 | cr, uid, data_record, context=context) | ||
2660 | 741 | if paid: | ||
2661 | 742 | order = self.pool.get('sale.order').browse( | ||
2662 | 743 | cr, uid, order_id, context) | ||
2663 | 744 | self.generate_payment_with_pay_code( | ||
2664 | 745 | cr, uid, | ||
2665 | 746 | payment_info['method'], | ||
2666 | 747 | order.partner_id.id, | ||
2667 | 748 | float(amount), | ||
2668 | 749 | "mag_" + payment_info['payment_id'], | ||
2669 | 750 | "mag_" + data_record['increment_id'], | ||
2670 | 751 | order.date_order, | ||
2671 | 752 | paid, | ||
2672 | 753 | context=context) | ||
2673 | 754 | else: | ||
2674 | 755 | paid = super(sale_order, self).create_payments( | ||
2675 | 756 | cr, uid, order_id, data_record, context=context) | ||
2676 | 757 | return paid | ||
2677 | 758 | >>>>>>> MERGE-SOURCE | ||
2678 | 299 | 759 | ||
2679 | 300 | def _chain_cancel_orders(self, cr, uid, external_id, external_referential_id, defaults=None, context=None): | 760 | def _chain_cancel_orders(self, cr, uid, external_id, external_referential_id, defaults=None, context=None): |
2680 | 301 | """ Get all the chain of edited orders (an edited order is canceled on Magento) | 761 | """ Get all the chain of edited orders (an edited order is canceled on Magento) |
2681 | @@ -304,6 +764,10 @@ | |||
2682 | 304 | """ | 764 | """ |
2683 | 305 | if context is None: | 765 | if context is None: |
2684 | 306 | context = {} | 766 | context = {} |
2685 | 767 | <<<<<<< TREE | ||
2686 | 768 | ======= | ||
2687 | 769 | logger = logging.getLogger('ext synchro') | ||
2688 | 770 | >>>>>>> MERGE-SOURCE | ||
2689 | 307 | conn = context.get('conn_obj', False) | 771 | conn = context.get('conn_obj', False) |
2690 | 308 | parent_list = [] | 772 | parent_list = [] |
2691 | 309 | # get all parents orders (to cancel) of the sale orders | 773 | # get all parents orders (to cancel) of the sale orders |
2692 | @@ -319,7 +783,11 @@ | |||
2693 | 319 | try: | 783 | try: |
2694 | 320 | wf_service.trg_validate(uid, 'sale.order', canceled_order_id, 'cancel', cr) | 784 | wf_service.trg_validate(uid, 'sale.order', canceled_order_id, 'cancel', cr) |
2695 | 321 | self.log(cr, uid, canceled_order_id, "order %s canceled when updated from external system" % (canceled_order_id,)) | 785 | self.log(cr, uid, canceled_order_id, "order %s canceled when updated from external system" % (canceled_order_id,)) |
2696 | 786 | <<<<<<< TREE | ||
2697 | 322 | _logger.info("Order %s canceled when updated from external system because it has been replaced by a new one", canceled_order_id) | 787 | _logger.info("Order %s canceled when updated from external system because it has been replaced by a new one", canceled_order_id) |
2698 | 788 | ======= | ||
2699 | 789 | logger.info("Order %s canceled when updated from external system because it has been replaced by a new one", canceled_order_id) | ||
2700 | 790 | >>>>>>> MERGE-SOURCE | ||
2701 | 323 | except osv.except_osv, e: | 791 | except osv.except_osv, e: |
2702 | 324 | #TODO: generic reporting of errors in magentoerpconnect | 792 | #TODO: generic reporting of errors in magentoerpconnect |
2703 | 325 | # except if the sale order has been confirmed for example, we cannot cancel the order | 793 | # except if the sale order has been confirmed for example, we cannot cancel the order |
2704 | @@ -342,6 +810,7 @@ | |||
2705 | 342 | 'priority': '2' | 810 | 'priority': '2' |
2706 | 343 | }) | 811 | }) |
2707 | 344 | 812 | ||
2708 | 813 | <<<<<<< TREE | ||
2709 | 345 | #NEW FEATURE | 814 | #NEW FEATURE |
2710 | 346 | 815 | ||
2711 | 347 | #TODO reimplement chain cancel orders | 816 | #TODO reimplement chain cancel orders |
2712 | @@ -433,6 +902,118 @@ | |||
2713 | 433 | 902 | ||
2714 | 434 | @only_for_referential('magento') | 903 | @only_for_referential('magento') |
2715 | 435 | def _check_need_to_update_single(self, cr, uid, external_session, order, context=None): | 904 | def _check_need_to_update_single(self, cr, uid, external_session, order, context=None): |
2716 | 905 | ======= | ||
2717 | 906 | def _ext_import_one(self, cr, uid, external_id, vals, external_data, referential_id, defaults=None, context=None): | ||
2718 | 907 | """ | ||
2719 | 908 | Inherit the method to flag the order to "Imported" on Magento right after the importation | ||
2720 | 909 | Before the import, check if the order is already imported and in a such case, skip the import | ||
2721 | 910 | and flag "imported" on Magento. | ||
2722 | 911 | """ | ||
2723 | 912 | if context is None: context = {} | ||
2724 | 913 | if not (context.get('external_referential_type', False) and 'Magento' in context['external_referential_type']): | ||
2725 | 914 | return super(sale_order, self)._ext_import_one( | ||
2726 | 915 | cr, uid, external_id, vals, external_data, referential_id, defaults=defaults, context=context) | ||
2727 | 916 | |||
2728 | 917 | res = False, False | ||
2729 | 918 | if not self.extid_to_existing_oeid(cr, uid, external_id, referential_id, context=context): | ||
2730 | 919 | res = super(sale_order, self)._ext_import_one( | ||
2731 | 920 | cr, uid, external_id, vals, external_data, referential_id, defaults=defaults, context=context) | ||
2732 | 921 | |||
2733 | 922 | if any(res): | ||
2734 | 923 | # if a created order has a relation_parent_real_id, | ||
2735 | 924 | # the new one replaces the original, so we have to cancel the old ones | ||
2736 | 925 | if external_data.get('relation_parent_real_id', False): | ||
2737 | 926 | self._chain_cancel_orders(cr, uid, external_id, referential_id, defaults=defaults, context=context) | ||
2738 | 927 | |||
2739 | 928 | return res | ||
2740 | 929 | |||
2741 | 930 | def _ext_import_one_cr(self, cr, uid, external_data, referential_id, defaults=None, context=None): | ||
2742 | 931 | """ Import one external resource, with cursor management, open a new cursor | ||
2743 | 932 | which is commited on each import | ||
2744 | 933 | |||
2745 | 934 | This method can be inherited to do an action which have to be done after | ||
2746 | 935 | that the imported resource is commited in database. | ||
2747 | 936 | |||
2748 | 937 | @param dict external_data: vals of the external resource before conversion | ||
2749 | 938 | @param external_referential_id: external referential id from where we import the resource | ||
2750 | 939 | @param defaults: defaults value for fields which are not in vals | ||
2751 | 940 | @return: tuple created id / updated id | ||
2752 | 941 | """ | ||
2753 | 942 | |||
2754 | 943 | cid, wid = super(sale_order, self)._ext_import_one_cr( | ||
2755 | 944 | cr, uid, external_data, referential_id, defaults=defaults, context=context) | ||
2756 | 945 | |||
2757 | 946 | if (cid or wid and | ||
2758 | 947 | (context.get('external_referential_type') and | ||
2759 | 948 | 'Magento' in context['external_referential_type'])): | ||
2760 | 949 | ext_id = self.oeid_to_extid(cr, uid, cid or wid, referential_id, | ||
2761 | 950 | context=context) | ||
2762 | 951 | # set the "imported" flag to true on Magento | ||
2763 | 952 | self.ext_set_order_imported(cr, uid, ext_id, referential_id, context=context) | ||
2764 | 953 | return cid, wid | ||
2765 | 954 | |||
2766 | 955 | def ext_set_order_imported(self, cr, uid, external_id, external_referential_id, context=None): | ||
2767 | 956 | if context is None: | ||
2768 | 957 | context = {} | ||
2769 | 958 | logger = logging.getLogger('ext synchro') | ||
2770 | 959 | conn = context.get('conn_obj', False) | ||
2771 | 960 | conn.call('sales_order.done', [external_id]) | ||
2772 | 961 | logger.info("Successfully set the imported flag on Magento on sale order %s", external_id) | ||
2773 | 962 | return True | ||
2774 | 963 | |||
2775 | 964 | def mage_import_base(self, cr, uid, conn, external_referential_id, defaults=None, context=None): | ||
2776 | 965 | """ Inherited method for Sales orders in order to import only order not flagged as "imported" on Magento | ||
2777 | 966 | """ | ||
2778 | 967 | if context is None: | ||
2779 | 968 | context = {} | ||
2780 | 969 | if not 'ids_or_filter' in context.keys(): | ||
2781 | 970 | context['ids_or_filter'] = [] | ||
2782 | 971 | result = {'create_ids': [], 'write_ids': []} | ||
2783 | 972 | |||
2784 | 973 | # returns the non already imported order (limit returns the n first orders) | ||
2785 | 974 | order_retrieve_params = { | ||
2786 | 975 | 'imported': False, | ||
2787 | 976 | 'limit': SALE_ORDER_IMPORT_STEP, | ||
2788 | 977 | 'filters': context['ids_or_filter'], | ||
2789 | 978 | } | ||
2790 | 979 | ext_order_ids = conn.call('sales_order.search', [order_retrieve_params]) | ||
2791 | 980 | result = self._import_orders( | ||
2792 | 981 | cr, uid, conn, ext_order_ids, external_referential_id, defaults=defaults, context=context) | ||
2793 | 982 | return result | ||
2794 | 983 | |||
2795 | 984 | def _import_orders(self, cr, uid, conn, external_ids, referential_id, defaults=None, context=None): | ||
2796 | 985 | if context is None: | ||
2797 | 986 | context = {} | ||
2798 | 987 | |||
2799 | 988 | logger = logging.getLogger('ext synchro') | ||
2800 | 989 | mapping_id = self.pool.get('external.mapping').search( | ||
2801 | 990 | cr, uid, | ||
2802 | 991 | [('model', '=', self._name), | ||
2803 | 992 | ('referential_id', '=', referential_id)], | ||
2804 | 993 | context=context) | ||
2805 | 994 | |||
2806 | 995 | context = dict(context) | ||
2807 | 996 | # we will need the connection to set the flag to "imported" on magento after each order import | ||
2808 | 997 | context['conn_obj'] = conn | ||
2809 | 998 | # use the external log for the orders import | ||
2810 | 999 | context['use_external_log'] = True | ||
2811 | 1000 | order_ids_filtred = [] | ||
2812 | 1001 | unchanged_ids = [] | ||
2813 | 1002 | for ext_order_id in external_ids: | ||
2814 | 1003 | existing_id = self.extid_to_existing_oeid(cr, uid, ext_order_id, referential_id, context=context) | ||
2815 | 1004 | if existing_id: | ||
2816 | 1005 | unchanged_ids.append(existing_id) | ||
2817 | 1006 | logger.info("the order %s already exist in OpenERP", ext_order_id) | ||
2818 | 1007 | self.ext_set_order_imported(cr, uid, ext_order_id, referential_id, context=context) | ||
2819 | 1008 | else: | ||
2820 | 1009 | order_ids_filtred.append({'increment_id' : ext_order_id}) | ||
2821 | 1010 | result = self.mage_import_one_by_one( | ||
2822 | 1011 | cr, uid, conn, referential_id, mapping_id[0], order_ids_filtred, defaults, context) | ||
2823 | 1012 | result['unchanged_ids'] = unchanged_ids | ||
2824 | 1013 | return result | ||
2825 | 1014 | |||
2826 | 1015 | def _check_need_to_update_single(self, cr, uid, order, conn, context=None): | ||
2827 | 1016 | >>>>>>> MERGE-SOURCE | ||
2828 | 436 | """ | 1017 | """ |
2829 | 437 | For one order, check on Magento if it has been paid since last | 1018 | For one order, check on Magento if it has been paid since last |
2830 | 438 | check. If so, it will launch the defined flow based on the | 1019 | check. If so, it will launch the defined flow based on the |
2831 | @@ -535,6 +1116,7 @@ | |||
2832 | 535 | 1116 | ||
2833 | 536 | return created | 1117 | return created |
2834 | 537 | 1118 | ||
2835 | 1119 | <<<<<<< TREE | ||
2836 | 538 | ######################################################################################################################## | 1120 | ######################################################################################################################## |
2837 | 539 | # | 1121 | # |
2838 | 540 | # CODE THAT CLEAN MAGENTO DATA BEFORE IMPORTING IT THE BEST WILL BE TO REFACTOR MAGENTO API | 1122 | # CODE THAT CLEAN MAGENTO DATA BEFORE IMPORTING IT THE BEST WILL BE TO REFACTOR MAGENTO API |
2839 | @@ -632,6 +1214,18 @@ | |||
2840 | 632 | resource['shipping_address']['customer_id'] = resource['customer_id'] | 1214 | resource['shipping_address']['customer_id'] = resource['customer_id'] |
2841 | 633 | return resource | 1215 | return resource |
2842 | 634 | 1216 | ||
2843 | 1217 | ======= | ||
2844 | 1218 | def retry_import(self, cr, uid, id, ext_id, external_referential_id, defaults=None, context=None): | ||
2845 | 1219 | """ When we import again a previously failed import""" | ||
2846 | 1220 | conn = self.pool.get('external.referential').external_connection( | ||
2847 | 1221 | cr, uid, external_referential_id) | ||
2848 | 1222 | res = self._import_orders( | ||
2849 | 1223 | cr, uid, conn, [ext_id], external_referential_id, defaults=defaults, context=context) | ||
2850 | 1224 | if any(res.values()): | ||
2851 | 1225 | return True | ||
2852 | 1226 | return False | ||
2853 | 1227 | |||
2854 | 1228 | >>>>>>> MERGE-SOURCE | ||
2855 | 635 | sale_order() | 1229 | sale_order() |
2856 | 636 | 1230 | ||
2857 | 637 | 1231 | ||
2858 | 638 | 1232 | ||
2859 | === modified file 'magentoerpconnect/sale_view.xml' | |||
2860 | --- magentoerpconnect/sale_view.xml 2012-05-11 15:14:05 +0000 | |||
2861 | +++ magentoerpconnect/sale_view.xml 2012-07-06 14:53:18 +0000 | |||
2862 | @@ -55,6 +55,25 @@ | |||
2863 | 55 | </field> | 55 | </field> |
2864 | 56 | </record> | 56 | </record> |
2865 | 57 | 57 | ||
2866 | 58 | <<<<<<< TREE | ||
2867 | 59 | ======= | ||
2868 | 60 | <record id="magerp_view_shop_auto_import_form" model="ir.ui.view"> | ||
2869 | 61 | <field name="name">magerp_view_shop_auto_import_form</field> | ||
2870 | 62 | <field name="model">sale.shop</field> | ||
2871 | 63 | <field name="type">form</field> | ||
2872 | 64 | <field name="inherit_id" ref="base_sale_multichannels.base_sale_multichannels_view_shop_form"/> | ||
2873 | 65 | <field name="arch" type="xml"> | ||
2874 | 66 | <xpath expr="/form/notebook" position="inside"> | ||
2875 | 67 | <page string="Magento Information" attrs="{'invisible': [('magento_shop','=',False)]}"> | ||
2876 | 68 | <field name="magento_shop" /> | ||
2877 | 69 | <field name="allow_magento_order_status_push" /> | ||
2878 | 70 | <field name="allow_magento_notification"/> | ||
2879 | 71 | </page> | ||
2880 | 72 | </xpath> | ||
2881 | 73 | </field> | ||
2882 | 74 | </record> | ||
2883 | 75 | |||
2884 | 76 | >>>>>>> MERGE-SOURCE | ||
2885 | 58 | <record id="base_sale_multichannel_view_order_form_magento" model="ir.ui.view"> | 77 | <record id="base_sale_multichannel_view_order_form_magento" model="ir.ui.view"> |
2886 | 59 | <field name="name">base_sale_multichannel_view_order_form.magento</field> | 78 | <field name="name">base_sale_multichannel_view_order_form.magento</field> |
2887 | 60 | <field name="model">sale.order</field> | 79 | <field name="model">sale.order</field> |
2888 | 61 | 80 | ||
2889 | === modified file 'magentoerpconnect/settings/1.3.2.4/external.mapping.template.csv' | |||
2890 | --- magentoerpconnect/settings/1.3.2.4/external.mapping.template.csv 2012-03-27 09:52:57 +0000 | |||
2891 | +++ magentoerpconnect/settings/1.3.2.4/external.mapping.template.csv 2012-07-06 14:53:18 +0000 | |||
2892 | @@ -10,5 +10,5 @@ | |||
2893 | 10 | "magento_1324_attr","magento1324","model_magerp_product_attributes","ol_catalog_product_attribute.list",,,,,"attribute_id" | 10 | "magento_1324_attr","magento1324","model_magerp_product_attributes","ol_catalog_product_attribute.list",,,,,"attribute_id" |
2894 | 11 | "magento_1324_prd","magento1324","product.model_product_product","catalog_product.list","catalog_product.info","ol_catalog_product.update","ol_catalog_product.create",,"product_id" | 11 | "magento_1324_prd","magento1324","product.model_product_product","catalog_product.list","catalog_product.info","ol_catalog_product.update","ol_catalog_product.create",,"product_id" |
2895 | 12 | "magento_1324_cst_grp","magento1324","base.model_res_partner_category","ol_customer_groups.list",,,,,"customer_group_id" | 12 | "magento_1324_cst_grp","magento1324","base.model_res_partner_category","ol_customer_groups.list",,,,,"customer_group_id" |
2897 | 13 | "magento_1324_prt_adr","magento1324","base.model_res_partner_address","ol_customer_address.list","ol_customer_address.info",,,,"customer_address_id" | 13 | "magento_1324_prt_adr","magento1324","base.model_res_partner_address","ol_customer_address.list","ol_customer_address.info",,,,"entity_id" |
2898 | 14 | "magento_1324_prt","magento1324","base.model_res_partner","customer.list","customer.info","customer.update",,,"customer_id" | 14 | "magento_1324_prt","magento1324","base.model_res_partner","customer.list","customer.info","customer.update",,,"customer_id" |
2899 | 15 | 15 | ||
2900 | === modified file 'magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv' | |||
2901 | --- magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv 2012-05-24 19:50:22 +0000 | |||
2902 | +++ magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv 2012-07-06 14:53:18 +0000 | |||
2903 | @@ -1,3 +1,4 @@ | |||
2904 | 1 | <<<<<<< TREE | ||
2905 | 1 | "id","version_id:id","model_id:id","external_field","field_id:id","type","evaluation_type","external_type","child_mapping_id:id","in_function","out_function" | 2 | "id","version_id:id","model_id:id","external_field","field_id:id","type","evaluation_type","external_type","child_mapping_id:id","in_function","out_function" |
2906 | 2 | "mag_1324_erp_s_name","magento1324","base_sale_multichannels.model_external_shop_group","name",,"in_out","function","unicode",,"result=[('name',ifield)]","result=[('name',record['name'])]" | 3 | "mag_1324_erp_s_name","magento1324","base_sale_multichannels.model_external_shop_group","name",,"in_out","function","unicode",,"result=[('name',ifield)]","result=[('name',record['name'])]" |
2907 | 3 | "mag_1324_erp_s_code","magento1324","base_sale_multichannels.model_external_shop_group","code",,"in_out","function","unicode",,"result=[('code',ifield)]", | 4 | "mag_1324_erp_s_code","magento1324","base_sale_multichannels.model_external_shop_group","code",,"in_out","function","unicode",,"result=[('code',ifield)]", |
2908 | @@ -19,6 +20,29 @@ | |||
2909 | 19 | "mag_1324_erp_so_total_amount","magento1324","sale.model_sale_order","grand_total",,"in_out","function","float",,"result=[('ext_total_amount',str(ifield))]", | 20 | "mag_1324_erp_so_total_amount","magento1324","sale.model_sale_order","grand_total",,"in_out","function","float",,"result=[('ext_total_amount',str(ifield))]", |
2910 | 20 | "mag_1324_erp_so_name","magento1324","sale.model_sale_order","increment_id",,"in_out","function","unicode",,"result=[('magento_incrementid',str(ifield)), ('name','mag_' + str(ifield))]", | 21 | "mag_1324_erp_so_name","magento1324","sale.model_sale_order","increment_id",,"in_out","function","unicode",,"result=[('magento_incrementid',str(ifield)), ('name','mag_' + str(ifield))]", |
2911 | 21 | "mag_1324_erp_so_carrier_id","magento1324","sale.model_sale_order","shipping_method",,"in_out","function","unicode",,"if ifield: | 22 | "mag_1324_erp_so_carrier_id","magento1324","sale.model_sale_order","shipping_method",,"in_out","function","unicode",,"if ifield: |
2912 | 23 | ======= | ||
2913 | 24 | id,type_id:id,model_id:id,external_field,field_id:id,type,evaluation_type,external_type,child_mapping_id:id,in_function,out_function | ||
2914 | 25 | mag_1324_erp_s_name,magento1324,base_sale_multichannels.model_external_shop_group,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
2915 | 26 | mag_1324_erp_s_code,magento1324,base_sale_multichannels.model_external_shop_group,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
2916 | 27 | mag_1324_erp_s_web,magento1324,base_sale_multichannels.model_external_shop_group,website_id,,in_out,function,int,,"result=[('website_id',ifield)]", | ||
2917 | 28 | mag_1324_erp_s_isa,magento1324,base_sale_multichannels.model_external_shop_group,is_default,,in_out,function,unicode,,"result=[('is_default',bool(eval(ifield)))]", | ||
2918 | 29 | mag_1324_erp_s_stord,magento1324,base_sale_multichannels.model_external_shop_group,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
2919 | 30 | mag_1324_erp_s_gpid,magento1324,base_sale_multichannels.model_external_shop_group,default_group_id,,in_out,function,int,,"result=[('default_shop_integer_id',ifield)]", | ||
2920 | 31 | mag_1324_erp_sv_name,magento1324,model_magerp_storeviews,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
2921 | 32 | mag_1324_erp_sv_code,magento1324,model_magerp_storeviews,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
2922 | 33 | mag_1324_erp_sv_sg,magento1324,model_magerp_storeviews,website_id,,in_out,function,int,,"result=[('website_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
2923 | 34 | mag_1324_erp_sv_isa,magento1324,model_magerp_storeviews,is_active,,in_out,function,unicode,,"result=[('is_active',bool(eval(ifield)))]", | ||
2924 | 35 | mag_1324_erp_sv_stord,magento1324,model_magerp_storeviews,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
2925 | 36 | mag_1324_erp_sv_gpid,magento1324,model_magerp_storeviews,group_id,,in_out,function,int,,"result=[('shop_id',self.pool.get('sale.shop').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
2926 | 37 | mag_1324_erp_st_name,magento1324,sale.model_sale_shop,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
2927 | 38 | mag_1324_erp_st_gpid,magento1324,sale.model_sale_shop,group_id,,in_out,function,int,,"result=[('group_id',ifield)]", | ||
2928 | 39 | mag_1324_erp_st_grp,magento1324,sale.model_sale_shop,website_id,,in_out,function,int,,"result=[('shop_group_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
2929 | 40 | mag_1324_erp_st_default_st,magento1324,sale.model_sale_shop,default_store_id,,in_out,function,int,,"result=[('default_storeview_integer_id',ifield)]", | ||
2930 | 41 | mag_1324_erp_st_root_categ,magento1324,sale.model_sale_shop,root_category_id,,in_out,function,int,,"result=[('root_category_id',ifield)]", | ||
2931 | 42 | mag_1324_erp_so_total_amount,magento1324,sale.model_sale_order,grand_total,,in_out,function,float,,"result=[('ext_total_amount',str(ifield))]", | ||
2932 | 43 | mag_1324_erp_so_name,magento1324,sale.model_sale_order,increment_id,,in_out,function,unicode,,"result=[('magento_incrementid',str(ifield)), ('name','mag_' + str(ifield))]", | ||
2933 | 44 | mag_1324_erp_so_carrier_id,magento1324,sale.model_sale_order,shipping_method,,in_out,function,unicode,,"if ifield: | ||
2934 | 45 | >>>>>>> MERGE-SOURCE | ||
2935 | 22 | carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [('magento_code', '=', ifield)]) | 46 | carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [('magento_code', '=', ifield)]) |
2936 | 23 | if carrier_ids: | 47 | if carrier_ids: |
2937 | 24 | result=[('carrier_id', carrier_ids[0])] | 48 | result=[('carrier_id', carrier_ids[0])] |
2938 | @@ -41,16 +65,24 @@ | |||
2939 | 41 | clean = re.sub('\w:\w:|\w:\w+;', '', ifield) | 65 | clean = re.sub('\w:\w:|\w:\w+;', '', ifield) |
2940 | 42 | for each in clean.split('{'): | 66 | for each in clean.split('{'): |
2941 | 43 | if each.startswith('""label""'): | 67 | if each.startswith('""label""'): |
2943 | 44 | split_info = each.split(';') | 68 | split_info = each.split(';') |
2944 | 45 | options_label.append('%s: %s [%s]' % (split_info[1], split_info[3], data['sku'])) | 69 | options_label.append('%s: %s [%s]' % (split_info[1], split_info[3], data['sku'])) |
2946 | 46 | 70 | ||
2947 | 47 | result=[('notes', """".join(options_label).replace('""""', '\n').replace('""', ''))] | 71 | result=[('notes', """".join(options_label).replace('""""', '\n').replace('""', ''))] |
2948 | 48 | ", | 72 | ", |
2949 | 73 | <<<<<<< TREE | ||
2950 | 49 | "mag_1324_erp_soline_pid","magento1324","sale.model_sale_order_line","product_id",,"in_out","function","unicode",,"context['alternative_key'] = data['sku'] | 74 | "mag_1324_erp_soline_pid","magento1324","sale.model_sale_order_line","product_id",,"in_out","function","unicode",,"context['alternative_key'] = data['sku'] |
2951 | 50 | result=[('product_id',self.pool.get('product.product').extid_to_oeid(cr, uid, external_session, ifield, referential_id))]", | 75 | result=[('product_id',self.pool.get('product.product').extid_to_oeid(cr, uid, external_session, ifield, referential_id))]", |
2952 | 51 | "mag_1324_erp_soline_uomqty","magento1324","sale.model_sale_order_line","qty_ordered",,"in_out","function","unicode",,"result=[('product_uom_qty',ifield)]", | 76 | "mag_1324_erp_soline_uomqty","magento1324","sale.model_sale_order_line","qty_ordered",,"in_out","function","unicode",,"result=[('product_uom_qty',ifield)]", |
2953 | 52 | "mag_1324_erp_soline_uosqty","magento1324","sale.model_sale_order_line","qty_ordered",,"in","function","unicode",,"result=[('product_uos_qty',ifield)]", | 77 | "mag_1324_erp_soline_uosqty","magento1324","sale.model_sale_order_line","qty_ordered",,"in","function","unicode",,"result=[('product_uos_qty',ifield)]", |
2954 | 53 | "mag_1324_erp_soline_price","magento1324","sale.model_sale_order_line","price",,"in","function","unicode",,"if context.get('price_is_tax_included', False): | 78 | "mag_1324_erp_soline_price","magento1324","sale.model_sale_order_line","price",,"in","function","unicode",,"if context.get('price_is_tax_included', False): |
2955 | 79 | ======= | ||
2956 | 80 | mag_1324_erp_soline_pid,magento1324,sale.model_sale_order_line,product_id,,in_out,function,unicode,,"context['alternative_key'] = data['sku'] | ||
2957 | 81 | result=[('product_id',self.pool.get('product.product').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
2958 | 82 | mag_1324_erp_soline_uomqty,magento1324,sale.model_sale_order_line,qty_ordered,,in_out,function,unicode,,"result=[('product_uom_qty',ifield)]", | ||
2959 | 83 | mag_1324_erp_soline_uosqty,magento1324,sale.model_sale_order_line,qty_ordered,,in,function,unicode,,"result=[('product_uos_qty',ifield)]", | ||
2960 | 84 | mag_1324_erp_soline_price,magento1324,sale.model_sale_order_line,price,,in,function,unicode,,"if context.get('price_is_tax_included', False): | ||
2961 | 85 | >>>>>>> MERGE-SOURCE | ||
2962 | 54 | result=[('price_unit', (float(data['row_total']) + float(data['tax_amount']))/float(data['qty_ordered']))] | 86 | result=[('price_unit', (float(data['row_total']) + float(data['tax_amount']))/float(data['qty_ordered']))] |
2963 | 55 | else: | 87 | else: |
2964 | 56 | result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]", | 88 | result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]", |
2965 | @@ -60,15 +92,23 @@ | |||
2966 | 60 | "mag_1324_erp_procat_3","magento1324","product.model_product_category","parent_id",,"in_out","function","int",,"record_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', self._name), ('name', '=', self.prefixed_id(ifield))]) | 92 | "mag_1324_erp_procat_3","magento1324","product.model_product_category","parent_id",,"in_out","function","int",,"record_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', self._name), ('name', '=', self.prefixed_id(ifield))]) |
2967 | 61 | parent_id = False | 93 | parent_id = False |
2968 | 62 | if record_id: | 94 | if record_id: |
2971 | 63 | parent_rec = self.pool.get('ir.model.data').read(cr,uid,record_id[0],[]) | 95 | parent_rec = self.pool.get('ir.model.data').read(cr,uid,record_id[0],[]) |
2972 | 64 | parent_id=parent_rec.get('res_id',False) | 96 | parent_id=parent_rec.get('res_id',False) |
2973 | 65 | result=[('magento_parent_id',ifield),('parent_id',parent_id)]","magento_parent_id = False | 97 | result=[('magento_parent_id',ifield),('parent_id',parent_id)]","magento_parent_id = False |
2974 | 66 | if record.get('parent_id',False): | 98 | if record.get('parent_id',False): |
2975 | 99 | <<<<<<< TREE | ||
2976 | 67 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) | 100 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) |
2977 | 68 | if not magento_parent_id: | 101 | if not magento_parent_id: |
2978 | 69 | self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[referential_id],{},context=context) | 102 | self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[referential_id],{},context=context) |
2979 | 70 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) | 103 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) |
2980 | 104 | ======= | ||
2981 | 105 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
2982 | 106 | if not magento_parent_id: | ||
2983 | 107 | self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[external_referential_id],{},context=context) | ||
2984 | 108 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
2985 | 109 | >>>>>>> MERGE-SOURCE | ||
2986 | 71 | if magento_parent_id: | 110 | if magento_parent_id: |
2987 | 111 | <<<<<<< TREE | ||
2988 | 72 | result = [('parent_id',magento_parent_id)]" | 112 | result = [('parent_id',magento_parent_id)]" |
2989 | 73 | "mag_1324_erp_procat_4","magento1324","product.model_product_category","is_active",,"in_out","function","unicode",,"result=[('is_active',ifield and (eval(ifield)) or False)]","result=[('is_active',record['is_active'])]" | 113 | "mag_1324_erp_procat_4","magento1324","product.model_product_category","is_active",,"in_out","function","unicode",,"result=[('is_active',ifield and (eval(ifield)) or False)]","result=[('is_active',record['is_active'])]" |
2990 | 74 | "mag_1324_erp_procat_5","magento1324","product.model_product_category","description",,"in_out","function","unicode",,"result=[('description',ifield)]","result=[('description',record['description'])]" | 114 | "mag_1324_erp_procat_5","magento1324","product.model_product_category","description",,"in_out","function","unicode",,"result=[('description',ifield)]","result=[('description',record['description'])]" |
2991 | @@ -76,6 +116,15 @@ | |||
2992 | 76 | "mag_1324_erp_procat_7","magento1324","product.model_product_category","meta_keywords",,"in_out","function","unicode",,"result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]" | 116 | "mag_1324_erp_procat_7","magento1324","product.model_product_category","meta_keywords",,"in_out","function","unicode",,"result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]" |
2993 | 77 | "mag_1324_erp_procat_8","magento1324","product.model_product_category","meta_description",,"in_out","function","unicode",,"result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]" | 117 | "mag_1324_erp_procat_8","magento1324","product.model_product_category","meta_description",,"in_out","function","unicode",,"result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]" |
2994 | 78 | "mag_1324_erp_procat_9","magento1324","product.model_product_category","url_key",,"in_out","function","unicode",,"result=[('url_key',ifield)]","if context.get('export_url', False) : | 118 | "mag_1324_erp_procat_9","magento1324","product.model_product_category","url_key",,"in_out","function","unicode",,"result=[('url_key',ifield)]","if context.get('export_url', False) : |
2995 | 119 | ======= | ||
2996 | 120 | result = [('parent_id',magento_parent_id)]" | ||
2997 | 121 | mag_1324_erp_procat_4,magento1324,product.model_product_category,is_active,,in_out,function,unicode,,"result=[('is_active',ifield and (eval(ifield)) or False)]","result=[('is_active',record['is_active'])]" | ||
2998 | 122 | mag_1324_erp_procat_5,magento1324,product.model_product_category,description,,in_out,function,unicode,,"result=[('description',ifield)]","result=[('description',record['description'])]" | ||
2999 | 123 | mag_1324_erp_procat_6,magento1324,product.model_product_category,meta_title,,in_out,function,unicode,,"result=[('meta_title',ifield)]","result=[('meta_title',record['meta_title'])]" | ||
3000 | 124 | mag_1324_erp_procat_7,magento1324,product.model_product_category,meta_keywords,,in_out,function,unicode,,"result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]" | ||
3001 | 125 | mag_1324_erp_procat_8,magento1324,product.model_product_category,meta_description,,in_out,function,unicode,,"result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]" | ||
3002 | 126 | mag_1324_erp_procat_9,magento1324,product.model_product_category,url_key,,in_out,function,unicode,,"result=[('url_key',ifield)]","if context.get('export_url', False) : | ||
3003 | 127 | >>>>>>> MERGE-SOURCE | ||
3004 | 79 | result=[('url_key',record['url_key'])]" | 128 | result=[('url_key',record['url_key'])]" |
3005 | 80 | "mag_1324_erp_procat_10","magento1324","product.model_product_category","name",,"in_out","function","unicode",,"result=[('name',ifield or 'UNDEFINED'),('magento_exportable',True)]","result=[('name',record['name'])]" | 129 | "mag_1324_erp_procat_10","magento1324","product.model_product_category","name",,"in_out","function","unicode",,"result=[('name',ifield or 'UNDEFINED'),('magento_exportable',True)]","result=[('name',record['name'])]" |
3006 | 81 | "mag_1324_erp_procat_11","magento1324","product.model_product_category","is_anchor",,"in_out","function","unicode",,"result=[('is_anchor',ifield and bool(eval(ifield)) or False)]","result=[('is_anchor',record['is_anchor'])]" | 130 | "mag_1324_erp_procat_11","magento1324","product.model_product_category","is_anchor",,"in_out","function","unicode",,"result=[('is_anchor',ifield and bool(eval(ifield)) or False)]","result=[('is_anchor',record['is_anchor'])]" |
3007 | @@ -97,30 +146,44 @@ | |||
3008 | 97 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'sort_by', context=context) | 146 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'sort_by', context=context) |
3009 | 98 | else: | 147 | else: |
3010 | 99 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','sort_by', context=context) | 148 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','sort_by', context=context) |
3012 | 100 | result=[('default_sort_by',att_id)]","cat_attr_option = self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, record['default_sort_by'][0], context=context) | 149 | result=[('default_sort_by',att_id)]","options_obj = self.pool.get('magerp.product_category_attribute_options') |
3013 | 150 | cat_attr_option_id = record['default_sort_by'] | ||
3014 | 151 | if cat_attr_option_id: | ||
3015 | 152 | cat_attr_option_id = cat_attr_option_id[0] | ||
3016 | 153 | else: | ||
3017 | 154 | cat_attr_option_id = options_obj._get_default_option(cr, uid, 'sort_by', 'None', context=context) | ||
3018 | 155 | |||
3019 | 156 | cat_attr_option = options_obj.browse(cr, uid, cat_attr_option_id, context=context) | ||
3020 | 101 | result=[('default_sort_by', cat_attr_option.value)]" | 157 | result=[('default_sort_by', cat_attr_option.value)]" |
3021 | 102 | "mag_1324_erp_procat_14","magento1324","product.model_product_category","updated_at",,"in","function","unicode",,"result=[('magerp_stamp',ifield)]", | 158 | "mag_1324_erp_procat_14","magento1324","product.model_product_category","updated_at",,"in","function","unicode",,"result=[('magerp_stamp',ifield)]", |
3022 | 103 | "mag_1324_erp_procat_15","magento1324","product.model_product_category","image",,"in_out","function","unicode",,"image_binary = False | 159 | "mag_1324_erp_procat_15","magento1324","product.model_product_category","image",,"in_out","function","unicode",,"image_binary = False |
3023 | 104 | if ifield and not ifield=='None': | 160 | if ifield and not ifield=='None': |
3031 | 105 | try: | 161 | try: |
3032 | 106 | image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) | 162 | image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) |
3033 | 107 | except Exception, e: | 163 | except Exception, e: |
3034 | 108 | print e | 164 | print e |
3035 | 109 | pass | 165 | pass |
3036 | 110 | if image_binary: | 166 | if image_binary: |
3037 | 111 | image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) | 167 | image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) |
3038 | 112 | result=[('image_name',ifield),('image',image_binary)]","if record['image']: | 168 | result=[('image_name',ifield),('image',image_binary)]","if record['image']: |
3043 | 113 | img = base64.decodestring(record['image']) | 169 | img = base64.decodestring(record['image']) |
3044 | 114 | img_bin_enc = base64.encodestring(img) | 170 | img_bin_enc = base64.encodestring(img) |
3045 | 115 | conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc]) | 171 | conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc]) |
3046 | 116 | result = [('image',record['image_name'])] | 172 | result = [('image',record['image_name'])] |
3047 | 117 | else: | 173 | else: |
3048 | 174 | <<<<<<< TREE | ||
3049 | 118 | result=[]" | 175 | result=[]" |
3050 | 119 | "mag_1324_erp_procat_16","magento1324","product.model_product_category","include_in_menu",,"in_out","function","unicode",,"result=[('include_in_menu', ifield and (eval(ifield)) or False)]","result=[('include_in_menu',record['include_in_menu'])]" | 176 | "mag_1324_erp_procat_16","magento1324","product.model_product_category","include_in_menu",,"in_out","function","unicode",,"result=[('include_in_menu', ifield and (eval(ifield)) or False)]","result=[('include_in_menu',record['include_in_menu'])]" |
3051 | 120 | "mag_1324_erp_procat_17","magento1324","product.model_product_category","page_layout",,"in_out","function","unicode",,"if ifield: | 177 | "mag_1324_erp_procat_17","magento1324","product.model_product_category","page_layout",,"in_out","function","unicode",,"if ifield: |
3052 | 178 | ======= | ||
3053 | 179 | result=[]" | ||
3054 | 180 | mag_1324_erp_procat_16,magento1324,product.model_product_category,include_in_menu,,in_out,function,unicode,,"result=[('include_in_menu', ifield and (eval(ifield)) or False)]","result=[('include_in_menu',record['include_in_menu'])]" | ||
3055 | 181 | mag_1324_erp_procat_17,magento1324,product.model_product_category,page_layout,,in_out,function,unicode,,"if ifield: | ||
3056 | 182 | >>>>>>> MERGE-SOURCE | ||
3057 | 121 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'page_layout', context=context) | 183 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'page_layout', context=context) |
3058 | 122 | else: | 184 | else: |
3059 | 123 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','page_layout', context=context) | 185 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, 'None','page_layout', context=context) |
3060 | 186 | <<<<<<< TREE | ||
3061 | 124 | result=[('page_layout',att_id)]","result=[('page_layout', record['page_layout'][1] or '')]" | 187 | result=[('page_layout',att_id)]","result=[('page_layout', record['page_layout'][1] or '')]" |
3062 | 125 | "mag_1324_erp_attrgrp_2","magento1324","model_magerp_product_attribute_groups","attribute_set_id",,"in_out","function","int",,"result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]" | 188 | "mag_1324_erp_attrgrp_2","magento1324","model_magerp_product_attribute_groups","attribute_set_id",,"in_out","function","int",,"result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]" |
3063 | 126 | "mag_1324_erp_attrgrp_3","magento1324","model_magerp_product_attribute_groups","attribute_group_name",,"in_out","function","unicode",,"result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]" | 189 | "mag_1324_erp_attrgrp_3","magento1324","model_magerp_product_attribute_groups","attribute_group_name",,"in_out","function","unicode",,"result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]" |
3064 | @@ -155,6 +218,43 @@ | |||
3065 | 155 | "mag_1324_erp_attr_24","magento1324","model_magerp_product_attributes","entity_type_id",,"in_out","function","int",,"result=[('entity_type_id', ifield)]","result=[('entity_type_id', record['entity_type_id'])]" | 218 | "mag_1324_erp_attr_24","magento1324","model_magerp_product_attributes","entity_type_id",,"in_out","function","int",,"result=[('entity_type_id', ifield)]","result=[('entity_type_id', record['entity_type_id'])]" |
3066 | 156 | "mag_1324_erp_attr_25","magento1324","model_magerp_product_attributes","apply_to",,"in_out","function","unicode",,"result=[('apply_to', str(ifield))]","result=[('apply_to', eval(record['%s']))]" | 219 | "mag_1324_erp_attr_25","magento1324","model_magerp_product_attributes","apply_to",,"in_out","function","unicode",,"result=[('apply_to', str(ifield))]","result=[('apply_to', eval(record['%s']))]" |
3067 | 157 | "mag_1324_erp_prd_1","magento1324","product.model_product_product","url_key",,"in_out","function","unicode",,"result=[('x_magerp_url_key',ifield)]","if context.get('export_url', False) : | 220 | "mag_1324_erp_prd_1","magento1324","product.model_product_product","url_key",,"in_out","function","unicode",,"result=[('x_magerp_url_key',ifield)]","if context.get('export_url', False) : |
3068 | 221 | ======= | ||
3069 | 222 | result=[('page_layout',att_id)]","page_layout = record['page_layout'] and record['page_layout'][1] or '' | ||
3070 | 223 | result=[('page_layout', page_layout)]" | ||
3071 | 224 | mag_1324_erp_attrgrp_2,magento1324,model_magerp_product_attribute_groups,attribute_set_id,,in_out,function,int,,"result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]" | ||
3072 | 225 | mag_1324_erp_attrgrp_3,magento1324,model_magerp_product_attribute_groups,attribute_group_name,,in_out,function,unicode,,"result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]" | ||
3073 | 226 | mag_1324_erp_attrgrp_4,magento1324,model_magerp_product_attribute_groups,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
3074 | 227 | mag_1324_erp_attrgrp_5,magento1324,model_magerp_product_attribute_groups,default_id,,in_out,function,int,,"result=[('default_id', ifield)]","result=[('default_id', record['default_id'])]" | ||
3075 | 228 | mag_1324_erp_attrset_1,magento1324,model_magerp_product_attribute_set,attribute_set_id,,in_out,function,int,,"result=[('magento_id', ifield)]","result=[('attribute_set_id', record['magento_id'])]" | ||
3076 | 229 | mag_1324_erp_attrset_2,magento1324,model_magerp_product_attribute_set,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
3077 | 230 | mag_1324_erp_attrset_3,magento1324,model_magerp_product_attribute_set,attribute_set_name,,in_out,function,unicode,,"result=[('attribute_set_name', ifield)]","result=[('attribute_set_name', record['attribute_set_name'])]" | ||
3078 | 231 | mag_1324_erp_attr_1,magento1324,model_magerp_product_attributes,attribute_code,,in_out,function,unicode,,"result=[('attribute_code', ifield)]","result=[('code', record['attribute_code'])]" | ||
3079 | 232 | mag_1324_erp_attr_2,magento1324,model_magerp_product_attributes,attribute_id,,in_out,function,int,,"result=[('magento_id', ifield)]", | ||
3080 | 233 | mag_1324_erp_attr_3,magento1324,model_magerp_product_attributes,frontend_input,,in_out,function,unicode,,"result=[('frontend_input', ifield)]","result=[('frontend_input', record['frontend_input'])]" | ||
3081 | 234 | mag_1324_erp_attr_4,magento1324,model_magerp_product_attributes,frontend_class,,in_out,function,unicode,,"result=[('frontend_class', ifield)]","result=[('frontend_class', record['frontend_class'])]" | ||
3082 | 235 | mag_1324_erp_attr_5,magento1324,model_magerp_product_attributes,backend_model,,in_out,function,unicode,,"result=[('backend_model', ifield)]","result=[('backend_model', record['backend_model'])]" | ||
3083 | 236 | mag_1324_erp_attr_6,magento1324,model_magerp_product_attributes,backend_type,,in_out,function,unicode,,"result=[('backend_type', ifield)]","result=[('backend_type', record['backend_type'])]" | ||
3084 | 237 | mag_1324_erp_attr_7,magento1324,model_magerp_product_attributes,frontend_label,,in_out,function,unicode,,"result=[('frontend_label', ifield)]","result=[('frontend_label', record['frontend_label'])]" | ||
3085 | 238 | mag_1324_erp_attr_8,magento1324,model_magerp_product_attributes,is_visible_in_advanced_search,,in_out,function,unicode,,"result=[('is_visible_in_advanced_search', bool(eval(ifield)))]","result=[('is_visible_in_advanced_search', record['is_visible_in_advanced_search'])]" | ||
3086 | 239 | mag_1324_erp_attr_9,magento1324,model_magerp_product_attributes,is_global,,in_out,function,unicode,,"result=[('is_global', bool(eval(ifield)))]","result=[('is_global', record['is_global'])]" | ||
3087 | 240 | mag_1324_erp_attr_10,magento1324,model_magerp_product_attributes,is_filterable,,in_out,function,unicode,,"result=[('is_filterable', bool(eval(ifield)))]","result=[('is_filterable', record['is_filterable'])]" | ||
3088 | 241 | mag_1324_erp_attr_11,magento1324,model_magerp_product_attributes,is_comparable,,in_out,function,unicode,,"result=[('is_comparable', bool(eval(ifield)))]","result=[('is_comparable', record['is_comparable'])]" | ||
3089 | 242 | mag_1324_erp_attr_12,magento1324,model_magerp_product_attributes,is_visible,,in_out,function,unicode,,"result=[('is_visible', bool(eval(ifield)))]","result=[('is_visible', record['is_visible'])]" | ||
3090 | 243 | mag_1324_erp_attr_13,magento1324,model_magerp_product_attributes,is_searchable,,in_out,function,unicode,,"result=[('is_searchable', bool(eval(ifield)))]","result=[('is_searchable', record['is_searchable'])]" | ||
3091 | 244 | mag_1324_erp_attr_14,magento1324,model_magerp_product_attributes,is_user_defined,,in_out,function,unicode,,"result=[('is_user_defined', bool(eval(ifield)))]","result=[('is_user_defined', record['is_user_defined'])]" | ||
3092 | 245 | mag_1324_erp_attr_15,magento1324,model_magerp_product_attributes,is_configurable,,in_out,function,unicode,,"result=[('is_configurable', bool(eval(ifield)))]","result=[('is_configurable', record['is_configurable'])]" | ||
3093 | 246 | mag_1324_erp_attr_16,magento1324,model_magerp_product_attributes,is_visible_on_front,,in_out,function,unicode,,"result=[('is_visible_on_front', bool(eval(ifield)))]","result=[('is_visible_on_front', record['is_visible_on_front'])]" | ||
3094 | 247 | mag_1324_erp_attr_17,magento1324,model_magerp_product_attributes,is_used_for_price_rules,,in_out,function,unicode,,"result=[('is_used_for_price_rules', bool(eval(ifield)))]","result=[('is_used_for_price_rules', record['is_used_for_price_rules'])]" | ||
3095 | 248 | mag_1324_erp_attr_18,magento1324,model_magerp_product_attributes,is_unique,,in_out,function,unicode,,"result=[('is_unique', bool(eval(ifield)))]","result=[('is_unique', record['is_unique'])]" | ||
3096 | 249 | mag_1324_erp_attr_19,magento1324,model_magerp_product_attributes,is_required,,in_out,function,unicode,,"result=[('is_required', bool(eval(ifield)))]","result=[('is_required', record['is_required'])]" | ||
3097 | 250 | mag_1324_erp_attr_20,magento1324,model_magerp_product_attributes,position,,in_out,function,int,,"result=[('position', ifield)]","result=[('position', record['position'])]" | ||
3098 | 251 | mag_1324_erp_attr_21,magento1324,model_magerp_product_attributes,attribute_set_info,,in_out,function,unicode,,"result=[('attribute_set_info', ifield)]","result=[('attribute_set_info', record['attribute_set_info'])]" | ||
3099 | 252 | mag_1324_erp_attr_22,magento1324,model_magerp_product_attributes,default_value,,in_out,function,unicode,,"result=[('default_value', ifield)]","result=[('default_value', record['default_value'])]" | ||
3100 | 253 | mag_1324_erp_attr_23,magento1324,model_magerp_product_attributes,note,,in_out,function,unicode,,"result=[('note', ifield)]","result=[('note', record['note'])]" | ||
3101 | 254 | mag_1324_erp_attr_24,magento1324,model_magerp_product_attributes,entity_type_id,,in_out,function,int,,"result=[('entity_type_id', ifield)]","result=[('entity_type_id', record['entity_type_id'])]" | ||
3102 | 255 | mag_1324_erp_attr_25,magento1324,model_magerp_product_attributes,apply_to,,in_out,function,unicode,,"result=[('apply_to', str(ifield))]","result=[('apply_to', eval(record['%s']))]" | ||
3103 | 256 | mag_1324_erp_prd_1,magento1324,product.model_product_product,url_key,,in_out,function,unicode,,"result=[('x_magerp_url_key',ifield)]","if context.get('export_url', False) : | ||
3104 | 257 | >>>>>>> MERGE-SOURCE | ||
3105 | 158 | result=[('url_key',record['x_magerp_url_key'])]" | 258 | result=[('url_key',record['x_magerp_url_key'])]" |
3106 | 159 | "mag_1324_erp_prd_2","magento1324","product.model_product_product","name",,"in_out","function","unicode",,"result = [('name',ifield)]","result = [('name',record['name'])]" | 259 | "mag_1324_erp_prd_2","magento1324","product.model_product_product","name",,"in_out","function","unicode",,"result = [('name',ifield)]","result = [('name',record['name'])]" |
3107 | 160 | "mag_1324_erp_prd_3","magento1324","product.model_product_product","description",,"in_out","function","unicode",,"result = [('description',ifield)]", | 260 | "mag_1324_erp_prd_3","magento1324","product.model_product_product","description",,"in_out","function","unicode",,"result = [('description',ifield)]", |
3108 | @@ -164,13 +264,18 @@ | |||
3109 | 164 | "mag_1324_erp_prd_7","magento1324","product.model_product_product","category_ids",,"in_out","function","list",,"categ_ids =[] | 264 | "mag_1324_erp_prd_7","magento1324","product.model_product_product","category_ids",,"in_out","function","list",,"categ_ids =[] |
3110 | 165 | if ifield and len(ifield) > 0: | 265 | if ifield and len(ifield) > 0: |
3111 | 166 | for category_ids in ifield: | 266 | for category_ids in ifield: |
3112 | 267 | <<<<<<< TREE | ||
3113 | 167 | categ_ids.append(self.pool.get('product.category').extid_to_oeid(cr, uid, external_session, category_ids, referential_id)) | 268 | categ_ids.append(self.pool.get('product.category').extid_to_oeid(cr, uid, external_session, category_ids, referential_id)) |
3114 | 269 | ======= | ||
3115 | 270 | categ_ids.append(self.pool.get('product.category').extid_to_oeid(cr, uid, category_ids, external_referential_id, context=context)) | ||
3116 | 271 | >>>>>>> MERGE-SOURCE | ||
3117 | 168 | categ_id = categ_ids.pop() | 272 | categ_id = categ_ids.pop() |
3118 | 169 | else: | 273 | else: |
3119 | 170 | categ_id = self.pool.get('external.referential').browse(cr, uid, referential_id).default_pro_cat.id | 274 | categ_id = self.pool.get('external.referential').browse(cr, uid, referential_id).default_pro_cat.id |
3120 | 171 | result = [('categ_id', categ_id), ('categ_ids',[(6, 0, categ_ids)])]"," | 275 | result = [('categ_id', categ_id), ('categ_ids',[(6, 0, categ_ids)])]"," |
3121 | 172 | cat_obj = self.pool.get('product.category') | 276 | cat_obj = self.pool.get('product.category') |
3122 | 173 | product = self.browse(cr, uid, record['id']) | 277 | product = self.browse(cr, uid, record['id']) |
3123 | 278 | <<<<<<< TREE | ||
3124 | 174 | categ_ids = [product.categ_id.id] + [categ.id for categ in product.categ_ids] | 279 | categ_ids = [product.categ_id.id] + [categ.id for categ in product.categ_ids] |
3125 | 175 | mag_categ_ids = [] | 280 | mag_categ_ids = [] |
3126 | 176 | for categ_id in categ_ids: | 281 | for categ_id in categ_ids: |
3127 | @@ -186,6 +291,23 @@ | |||
3128 | 186 | "mag_1324_erp_prd_11","magento1324","product.model_product_product","special_price",,"in_out","function","float",,"result = [('x_magerp_special_price',ifield)]", | 291 | "mag_1324_erp_prd_11","magento1324","product.model_product_product","special_price",,"in_out","function","float",,"result = [('x_magerp_special_price',ifield)]", |
3129 | 187 | "mag_1324_erp_prd_12","magento1324","product.model_product_product","tier_price",,"in_out","function","unicode",,"result=[]#no mapping by default","result=[]#no mapping by default" | 292 | "mag_1324_erp_prd_12","magento1324","product.model_product_product","tier_price",,"in_out","function","unicode",,"result=[]#no mapping by default","result=[]#no mapping by default" |
3130 | 188 | "mag_1324_erp_prd_13","magento1324","product.model_product_product","minimal_price",,"in_out","function","float",,"result = [('x_magerp_minimal_price',ifield)]"," | 293 | "mag_1324_erp_prd_13","magento1324","product.model_product_product","minimal_price",,"in_out","function","float",,"result = [('x_magerp_minimal_price',ifield)]"," |
3131 | 294 | ======= | ||
3132 | 295 | categ_ids = [categ.id for categ in ([product.categ_id] + product.categ_ids) if categ.magento_exportable] | ||
3133 | 296 | mag_categ_ids = [] | ||
3134 | 297 | for categ_id in categ_ids: | ||
3135 | 298 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
3136 | 299 | if not mag_categ_id: | ||
3137 | 300 | cat_obj.ext_export(cr, uid, [categ_id], [external_referential_id], context=context) | ||
3138 | 301 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
3139 | 302 | mag_categ_ids.append(mag_categ_id) | ||
3140 | 303 | result=[('category_ids', mag_categ_ids)]" | ||
3141 | 304 | mag_1324_erp_prd_8,magento1324,product.model_product_product,price,,in_out,function,float,,"result=[('list_price',ifield)]",result=[]#map later | ||
3142 | 305 | mag_1324_erp_prd_9,magento1324,product.model_product_product,cost,,in_out,function,float,,"result=[('standard_price',ifield)]","result = [('cost',record['standard_price'] or 0)]" | ||
3143 | 306 | mag_1324_erp_prd_10,magento1324,product.model_product_product,set,,in_out,function,unicode,,"result=[('set',self.pool.get('magerp.product_attribute_set').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3144 | 307 | mag_1324_erp_prd_11,magento1324,product.model_product_product,special_price,,in_out,function,float,,"result = [('x_magerp_special_price',ifield)]", | ||
3145 | 308 | mag_1324_erp_prd_12,magento1324,product.model_product_product,tier_price,,in_out,function,unicode,,result=[]#no mapping by default,result=[]#no mapping by default | ||
3146 | 309 | mag_1324_erp_prd_13,magento1324,product.model_product_product,minimal_price,,in_out,function,float,,"result = [('x_magerp_minimal_price',ifield)]"," | ||
3147 | 310 | >>>>>>> MERGE-SOURCE | ||
3148 | 189 | if record['x_magerp_minimal_price'] and record['x_magerp_minimal_price'] != 0: | 311 | if record['x_magerp_minimal_price'] and record['x_magerp_minimal_price'] != 0: |
3149 | 190 | result = [('minimal_price',record['x_magerp_minimal_price'])] | 312 | result = [('minimal_price',record['x_magerp_minimal_price'])] |
3150 | 191 | else: | 313 | else: |
3151 | @@ -199,7 +321,11 @@ | |||
3152 | 199 | result = [('type_id','simple')]" | 321 | result = [('type_id','simple')]" |
3153 | 200 | "mag_1324_erp_prd_15","magento1324","product.model_product_product","websites",,"in_out","function","list",,"websites_ids = [] | 322 | "mag_1324_erp_prd_15","magento1324","product.model_product_product","websites",,"in_out","function","list",,"websites_ids = [] |
3154 | 201 | for ext_id in ifield: | 323 | for ext_id in ifield: |
3155 | 324 | <<<<<<< TREE | ||
3156 | 202 | websites_ids.append(self.pool.get('external.shop.group').extid_to_oeid(cr, uid, external_session, ext_id, context=context)) | 325 | websites_ids.append(self.pool.get('external.shop.group').extid_to_oeid(cr, uid, external_session, ext_id, context=context)) |
3157 | 326 | ======= | ||
3158 | 327 | websites_ids.append(self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ext_id, external_referential_id, context=context)) | ||
3159 | 328 | >>>>>>> MERGE-SOURCE | ||
3160 | 203 | 329 | ||
3161 | 204 | ##### OPTION START, with this if the field websites of the product is empty the product is exported on every website | 330 | ##### OPTION START, with this if the field websites of the product is empty the product is exported on every website |
3162 | 205 | all_oe_websites_ids = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', referential_id)]) | 331 | all_oe_websites_ids = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', referential_id)]) |
3163 | @@ -217,6 +343,7 @@ | |||
3164 | 217 | ext_websites_ids.append(self.pool.get('external.shop.group').oeid_to_extid(cr, uid, oe_id, referential_id)) | 343 | ext_websites_ids.append(self.pool.get('external.shop.group').oeid_to_extid(cr, uid, oe_id, referential_id)) |
3165 | 218 | 344 | ||
3166 | 219 | result=[('websites', ext_websites_ids)]" | 345 | result=[('websites', ext_websites_ids)]" |
3167 | 346 | <<<<<<< TREE | ||
3168 | 220 | "mag_1324_erp_prd_16","magento1324","product.model_product_product","has_options",,"in","function","unicode",,"result =[('x_magerp_has_options',ifield)]", | 347 | "mag_1324_erp_prd_16","magento1324","product.model_product_product","has_options",,"in","function","unicode",,"result =[('x_magerp_has_options',ifield)]", |
3169 | 221 | "magento_1324_cst_grp_1","magento1324","base.model_res_partner_category","customer_group_code",,"in","function","unicode",,"result=[('name',ifield)]", | 348 | "magento_1324_cst_grp_1","magento1324","base.model_res_partner_category","customer_group_code",,"in","function","unicode",,"result=[('name',ifield)]", |
3170 | 222 | "magento_1324_cst_grp_3","magento1324","base.model_res_partner_category","tax_class_id",,"in","function","int",,"result=[('tax_class_id',ifield)]", | 349 | "magento_1324_cst_grp_3","magento1324","base.model_res_partner_category","tax_class_id",,"in","function","int",,"result=[('tax_class_id',ifield)]", |
3171 | @@ -225,17 +352,39 @@ | |||
3172 | 225 | "magento_1324_prt_adr_4","magento1324","base.model_res_partner_address","firstname",,"in_out","function","unicode",,"result = [('name', (data.get('company', False) and (data['company'] + ' ; ') or '') + ifield + ' ' + (data['lastname'] or '')), ('firstname', ifield), ('lastname', (data['lastname'] or ''))]", | 352 | "magento_1324_prt_adr_4","magento1324","base.model_res_partner_address","firstname",,"in_out","function","unicode",,"result = [('name', (data.get('company', False) and (data['company'] + ' ; ') or '') + ifield + ' ' + (data['lastname'] or '')), ('firstname', ifield), ('lastname', (data['lastname'] or ''))]", |
3173 | 226 | "magento_1324_prt_adr_6","magento1324","base.model_res_partner_address","is_active",,"in_out","function","unicode",,"result=[('active',bool(eval(ifield)))]", | 353 | "magento_1324_prt_adr_6","magento1324","base.model_res_partner_address","is_active",,"in_out","function","unicode",,"result=[('active',bool(eval(ifield)))]", |
3174 | 227 | "magento_1324_prt_adr_7","magento1324","base.model_res_partner_address","country_id",,"in_out","function","unicode",,"result = self.pool.get('res.country').search(cr,uid,[('code','=',ifield)]) | 354 | "magento_1324_prt_adr_7","magento1324","base.model_res_partner_address","country_id",,"in_out","function","unicode",,"result = self.pool.get('res.country').search(cr,uid,[('code','=',ifield)]) |
3175 | 355 | ======= | ||
3176 | 356 | mag_1324_erp_prd_16,magento1324,product.model_product_product,has_options,,in,function,unicode,,"result =[('x_magerp_has_options',ifield)]", | ||
3177 | 357 | magento_1324_cst_grp_1,magento1324,base.model_res_partner_category,customer_group_code,,in,function,unicode,,"result=[('name',ifield)]", | ||
3178 | 358 | magento_1324_cst_grp_3,magento1324,base.model_res_partner_category,tax_class_id,,in,function,int,,"result=[('tax_class_id',ifield)]", | ||
3179 | 359 | magento_1324_prt_adr_2,magento1324,base.model_res_partner_address,city,,in_out,function,unicode,,"result=[('city',ifield)]", | ||
3180 | 360 | magento_1324_prt_adr_3,magento1324,base.model_res_partner_address,fax,,in_out,function,unicode,,"result=[('fax',ifield)]", | ||
3181 | 361 | magento_1324_prt_adr_4,magento1324,base.model_res_partner_address,firstname,,in_out,function,unicode,,"name = ' '.join([ f for f in (data['firstname'], data['lastname']) if f]) | ||
3182 | 362 | if data.get('company'): | ||
3183 | 363 | name = ""%s ; %s"" % (data['company'], name) | ||
3184 | 364 | result = [('name', name), ('firstname', ifield), ('lastname', data['lastname'])]", | ||
3185 | 365 | magento_1324_prt_adr_6,magento1324,base.model_res_partner_address,is_active,,in_out,function,unicode,,"result=[('active',bool(eval(ifield)))]", | ||
3186 | 366 | magento_1324_prt_adr_7,magento1324,base.model_res_partner_address,country_id,,in_out,function,unicode,,"result = self.pool.get('res.country').search(cr,uid,[('code','=',ifield)]) | ||
3187 | 367 | >>>>>>> MERGE-SOURCE | ||
3188 | 228 | if result and len(result)==1: | 368 | if result and len(result)==1: |
3190 | 229 | result=[('country_id',result[0])] | 369 | result=[('country_id',result[0])] |
3191 | 230 | else: | 370 | else: |
3193 | 231 | result=[] | 371 | result=[] |
3194 | 232 | ", | 372 | ", |
3195 | 373 | <<<<<<< TREE | ||
3196 | 233 | "magento_1324_prt_adr_8","magento1324","base.model_res_partner_address","street",,"in_out","function","unicode",,"if ifield: | 374 | "magento_1324_prt_adr_8","magento1324","base.model_res_partner_address","street",,"in_out","function","unicode",,"if ifield: |
3197 | 234 | if len(ifield.split('\n')) ==2 : | 375 | if len(ifield.split('\n')) ==2 : |
3198 | 235 | result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] | 376 | result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] |
3199 | 236 | else : | 377 | else : |
3200 | 237 | result = [('street',ifield.replace('\\n',','))] | 378 | result = [('street',ifield.replace('\\n',','))] |
3201 | 379 | ======= | ||
3202 | 380 | magento_1324_prt_adr_8,magento1324,base.model_res_partner_address,street,,in_out,function,unicode,,"if ifield: | ||
3203 | 381 | if len(ifield.split('\n')) ==2 : | ||
3204 | 382 | result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] | ||
3205 | 383 | else : | ||
3206 | 384 | result = [('street',ifield.replace('\\n',','))] | ||
3207 | 385 | >>>>>>> MERGE-SOURCE | ||
3208 | 238 | else: | 386 | else: |
3209 | 387 | <<<<<<< TREE | ||
3210 | 239 | result = []", | 388 | result = []", |
3211 | 240 | "magento_1324_prt_adr_9","magento1324","base.model_res_partner_address","postcode",,"in_out","function","unicode",,"result=[('zip',ifield)]", | 389 | "magento_1324_prt_adr_9","magento1324","base.model_res_partner_address","postcode",,"in_out","function","unicode",,"result=[('zip',ifield)]", |
3212 | 241 | "magento_1324_prt_adr_10","magento1324","base.model_res_partner_address","telephone",,"in_out","function","unicode",,"result=[('phone',ifield)]", | 390 | "magento_1324_prt_adr_10","magento1324","base.model_res_partner_address","telephone",,"in_out","function","unicode",,"result=[('phone',ifield)]", |
3213 | @@ -245,16 +394,39 @@ | |||
3214 | 245 | result = [('state_id',result[0])] | 394 | result = [('state_id',result[0])] |
3215 | 246 | else: | 395 | else: |
3216 | 247 | result=[] | 396 | result=[] |
3217 | 397 | ======= | ||
3218 | 398 | result = []", | ||
3219 | 399 | magento_1324_prt_adr_9,magento1324,base.model_res_partner_address,postcode,,in_out,function,unicode,,"result=[('zip',ifield)]", | ||
3220 | 400 | magento_1324_prt_adr_10,magento1324,base.model_res_partner_address,telephone,,in_out,function,unicode,,"result=[('phone',ifield)]", | ||
3221 | 401 | magento_1324_prt_adr_11,magento1324,base.model_res_partner_address,region,,in_out,function,unicode,,"if ifield: | ||
3222 | 402 | result = self.pool.get('res.country.state').search(cr,uid,[('name','=ilike',ifield)]) | ||
3223 | 403 | if result and len(result)==1: | ||
3224 | 404 | result = [('state_id',result[0])] | ||
3225 | 405 | else: | ||
3226 | 406 | result=[] | ||
3227 | 407 | >>>>>>> MERGE-SOURCE | ||
3228 | 248 | else: | 408 | else: |
3229 | 409 | <<<<<<< TREE | ||
3230 | 249 | result=[]", | 410 | result=[]", |
3231 | 250 | "magento_1324_prt_adr_13","magento1324","base.model_res_partner_address","customer_id",,"in_out","function","int",,"result=self.pool.get('res.partner').extid_to_oeid(cr,uid,ifield,referential_id) | 411 | "magento_1324_prt_adr_13","magento1324","base.model_res_partner_address","customer_id",,"in_out","function","int",,"result=self.pool.get('res.partner').extid_to_oeid(cr,uid,ifield,referential_id) |
3232 | 412 | ======= | ||
3233 | 413 | result=[]", | ||
3234 | 414 | magento_1324_prt_adr_13,magento1324,base.model_res_partner_address,customer_id,,in_out,function,int,,"result=self.pool.get('res.partner').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3235 | 415 | >>>>>>> MERGE-SOURCE | ||
3236 | 251 | if result: | 416 | if result: |
3238 | 252 | result=[('partner_id',result)] | 417 | result=[('partner_id',result)] |
3239 | 253 | else: | 418 | else: |
3240 | 419 | <<<<<<< TREE | ||
3241 | 254 | result=[('partner_id',False)]", | 420 | result=[('partner_id',False)]", |
3242 | 255 | "magento_1324_prt_adr_14","magento1324","base.model_res_partner_address","address_type",,"in_out","function","unicode",,"if ifield=='billing': | 421 | "magento_1324_prt_adr_14","magento1324","base.model_res_partner_address","address_type",,"in_out","function","unicode",,"if ifield=='billing': |
3243 | 256 | result=[('type','invoice')] | 422 | result=[('type','invoice')] |
3244 | 423 | ======= | ||
3245 | 424 | result=[('partner_id',False)]", | ||
3246 | 425 | magento_1324_prt_adr_14,magento1324,base.model_res_partner_address,address_type,,in_out,function,unicode,,"if ifield=='billing': | ||
3247 | 426 | result=[('type','invoice')] | ||
3248 | 427 | >>>>>>> MERGE-SOURCE | ||
3249 | 257 | elif ifield=='shipping': | 428 | elif ifield=='shipping': |
3250 | 429 | <<<<<<< TREE | ||
3251 | 258 | result=[('type','delivery')] | 430 | result=[('type','delivery')] |
3252 | 259 | else: | 431 | else: |
3253 | 260 | result=[]", | 432 | result=[]", |
3254 | @@ -276,15 +448,67 @@ | |||
3255 | 276 | "magento_1324_prt_6","magento1324","base.model_res_partner","created_at",,"in_out","function","unicode",,"result=[('created_at',ifield)]", | 448 | "magento_1324_prt_6","magento1324","base.model_res_partner","created_at",,"in_out","function","unicode",,"result=[('created_at',ifield)]", |
3256 | 277 | "magento_1324_prt_7","magento1324","base.model_res_partner","updated_at",,"in_out","function","unicode",,"result=[('updated_at',ifield)]", | 449 | "magento_1324_prt_7","magento1324","base.model_res_partner","updated_at",,"in_out","function","unicode",,"result=[('updated_at',ifield)]", |
3257 | 278 | "magento_1324_prt_8","magento1324","base.model_res_partner","firstname",,"in_out","function","unicode",,"result = [('name', ifield + ' ' + data['lastname'])]","add_id = self.browse(cr, uid, record['id']) | 450 | "magento_1324_prt_8","magento1324","base.model_res_partner","firstname",,"in_out","function","unicode",,"result = [('name', ifield + ' ' + data['lastname'])]","add_id = self.browse(cr, uid, record['id']) |
3258 | 451 | ======= | ||
3259 | 452 | result=[('type','delivery')] | ||
3260 | 453 | else: | ||
3261 | 454 | result=[]", | ||
3262 | 455 | magento_1324_prt_adr_15,magento1324,base.model_res_partner_address,email,,in_out,function,unicode,,"result = [('email', False)] | ||
3263 | 456 | if ifield: | ||
3264 | 457 | result = [('email', ifield)] | ||
3265 | 458 | else: | ||
3266 | 459 | partner_obj = self.pool.get('res.partner') | ||
3267 | 460 | partner_id = partner_obj.extid_to_existing_oeid(cr, uid, data['customer_id'] ,external_referential_id) | ||
3268 | 461 | if partner_id: | ||
3269 | 462 | result = [('email', partner_obj.browse(cr, uid, partner_id).emailid)]", | ||
3270 | 463 | magento_1324_prt_adr_17,magento1324,base.model_res_partner_address,default_billing,,in_out,function,unicode,,"result = [('type', 'other')] | ||
3271 | 464 | if data.get('default_billing') and data.get('default_shipping'): | ||
3272 | 465 | result = [('type', 'default')] | ||
3273 | 466 | elif data.get('default_billing'): | ||
3274 | 467 | result = [('type', 'invoice')] | ||
3275 | 468 | elif data.get('default_shipping'): | ||
3276 | 469 | result = [('type', 'delivery')]", | ||
3277 | 470 | magento_1324_prt_2,magento1324,base.model_res_partner,group_id,,in_out,function,int,,"if ifield: | ||
3278 | 471 | result=self.pool.get('res.partner.category').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3279 | 472 | if result: | ||
3280 | 473 | result=[('group_id',result)]", | ||
3281 | 474 | magento_1324_prt_3,magento1324,base.model_res_partner,store_id,,in_out,function,int,,"if ifield: | ||
3282 | 475 | result=self.pool.get('magerp.storeviews').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3283 | 476 | if result: | ||
3284 | 477 | store = self.pool.get('magerp.storeviews').browse(cr, uid, result) | ||
3285 | 478 | lang = store.lang_id | ||
3286 | 479 | result=[('store_id',result),('lang',lang and lang.code or False)] | ||
3287 | 480 | if not data.get('website_id'): | ||
3288 | 481 | result.append(('website_id', store.website_id.id))", | ||
3289 | 482 | magento_1324_prt_4,magento1324,base.model_res_partner,website_id,,in_out,function,int,,"if ifield: | ||
3290 | 483 | result=self.pool.get('external.shop.group').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3291 | 484 | if result: | ||
3292 | 485 | result=[('website_id',result)]", | ||
3293 | 486 | magento_1324_prt_5,magento1324,base.model_res_partner,created_in,,in_out,function,unicode,,"result=[('created_in',ifield)]", | ||
3294 | 487 | magento_1324_prt_6,magento1324,base.model_res_partner,created_at,,in_out,function,unicode,,"result=[('created_at',ifield)]", | ||
3295 | 488 | magento_1324_prt_7,magento1324,base.model_res_partner,updated_at,,in_out,function,unicode,,"result=[('updated_at',ifield)]", | ||
3296 | 489 | magento_1324_prt_8,magento1324,base.model_res_partner,firstname,,in_out,function,unicode,,"result = [('name', ifield + ' ' + data['lastname'])]","add_id = self.browse(cr, uid, record['id']) | ||
3297 | 490 | >>>>>>> MERGE-SOURCE | ||
3298 | 279 | fn = add_id.address[0].firstname | 491 | fn = add_id.address[0].firstname |
3299 | 280 | ln = add_id.address[0].lastname | 492 | ln = add_id.address[0].lastname |
3300 | 281 | result=[('firstname', fn), ('lastname', ln)]" | 493 | result=[('firstname', fn), ('lastname', ln)]" |
3301 | 494 | <<<<<<< TREE | ||
3302 | 282 | "magento_1324_prt_10","magento1324","base.model_res_partner","email",,"in_out","function","unicode",,"result=[('emailid',ifield)]", | 495 | "magento_1324_prt_10","magento1324","base.model_res_partner","email",,"in_out","function","unicode",,"result=[('emailid',ifield)]", |
3303 | 283 | "magento_1324_prt_11","magento1324","base.model_res_partner","taxvat",,"in_out","function","unicode",,"if ifield: | 496 | "magento_1324_prt_11","magento1324","base.model_res_partner","taxvat",,"in_out","function","unicode",,"if ifield: |
3304 | 284 | result=[('mag_vat',ifield)] | 497 | result=[('mag_vat',ifield)] |
3305 | 498 | ======= | ||
3306 | 499 | magento_1324_prt_10,magento1324,base.model_res_partner,email,,in_out,function,unicode,,"result=[('emailid',ifield)]", | ||
3307 | 500 | magento_1324_prt_11,magento1324,base.model_res_partner,taxvat,,in_out,function,unicode,,"if ifield: | ||
3308 | 501 | result=[('mag_vat',ifield)] | ||
3309 | 502 | >>>>>>> MERGE-SOURCE | ||
3310 | 285 | else: | 503 | else: |
3311 | 504 | <<<<<<< TREE | ||
3312 | 286 | result=[]", | 505 | result=[]", |
3313 | 287 | "magento_1324_prt_12","magento1324","base.model_res_partner","dob",,"in_out","function","unicode",,"if ifield: | 506 | "magento_1324_prt_12","magento1324","base.model_res_partner","dob",,"in_out","function","unicode",,"if ifield: |
3314 | 288 | result =[('mag_birthday',ifield[:10])] | 507 | result =[('mag_birthday',ifield[:10])] |
3315 | 508 | ======= | ||
3316 | 509 | result=[]", | ||
3317 | 510 | magento_1324_prt_12,magento1324,base.model_res_partner,dob,,in_out,function,unicode,,"if ifield: | ||
3318 | 511 | result =[('mag_birthday',ifield[:10])] | ||
3319 | 512 | >>>>>>> MERGE-SOURCE | ||
3320 | 289 | else: | 513 | else: |
3322 | 290 | result=[]", | 514 | result=[]", |
3323 | 291 | 515 | ||
3324 | === added directory 'magentoerpconnect/settings/1.4.0.0' | |||
3325 | === added file 'magentoerpconnect/settings/1.4.0.0/external.mapping.template.csv' | |||
3326 | --- magentoerpconnect/settings/1.4.0.0/external.mapping.template.csv 1970-01-01 00:00:00 +0000 | |||
3327 | +++ magentoerpconnect/settings/1.4.0.0/external.mapping.template.csv 2012-07-06 14:53:18 +0000 | |||
3328 | @@ -0,0 +1,14 @@ | |||
3329 | 1 | "id","type_id:id","model_id:id","external_list_method","external_get_method","external_update_method","external_create_method","external_delete_method","external_key_name" | ||
3330 | 2 | "magento_1400_website","magento1400","base_sale_multichannels.model_external_shop_group","ol_websites.list",,,,,"website_id" | ||
3331 | 3 | "magento_1400_storeview","magento1400","model_magerp_storeviews","ol_storeviews.list",,,,,"store_id" | ||
3332 | 4 | "magento_1400_store","magento1400","sale.model_sale_shop","ol_groups.list",,,,,"group_id" | ||
3333 | 5 | "magento_1400_order","magento1400","sale.model_sale_order","sales_order.list","sales_order.info",,,,"increment_id" | ||
3334 | 6 | "magento_1400_order_line","magento1400","sale.model_sale_order_line",,,,,,"item_id" | ||
3335 | 7 | "magento_1400_pro_cat","magento1400","product.model_product_category","category.list","category.info","catalog_category.update","catalog_category.create",,"category_id" | ||
3336 | 8 | "magento_1400_attr_grp","magento1400","model_magerp_product_attribute_groups","ol_catalog_product_attribute_group.list","ol_catalog_product_attribute_group.list",,,,"attribute_group_id" | ||
3337 | 9 | "magento_1400_attr_set","magento1400","model_magerp_product_attribute_set","ol_catalog_product_attributeset.list",,,,,"attribute_set_id" | ||
3338 | 10 | "magento_1400_attr","magento1400","model_magerp_product_attributes","ol_catalog_product_attribute.list",,,,,"attribute_id" | ||
3339 | 11 | "magento_1400_prd","magento1400","product.model_product_product","catalog_product.list","catalog_product.info","ol_catalog_product.update","ol_catalog_product.create",,"product_id" | ||
3340 | 12 | "magento_1400_cst_grp","magento1400","base.model_res_partner_category","ol_customer_groups.list",,,,,"customer_group_id" | ||
3341 | 13 | "magento_1400_prt_adr","magento1400","base.model_res_partner_address","ol_customer_address.list","ol_customer_address.info",,,,"entity_id" | ||
3342 | 14 | "magento_1400_prt","magento1400","base.model_res_partner","customer.list","customer.info","customer.update",,,"customer_id" | ||
3343 | 0 | 15 | ||
3344 | === added file 'magentoerpconnect/settings/1.4.0.0/external.mappinglines.template.csv' | |||
3345 | --- magentoerpconnect/settings/1.4.0.0/external.mappinglines.template.csv 1970-01-01 00:00:00 +0000 | |||
3346 | +++ magentoerpconnect/settings/1.4.0.0/external.mappinglines.template.csv 2012-07-06 14:53:18 +0000 | |||
3347 | @@ -0,0 +1,321 @@ | |||
3348 | 1 | id,type_id:id,model_id:id,external_field,field_id:id,type,evaluation_type,external_type,child_mapping_id:id,in_function,out_function | ||
3349 | 2 | mag_1400_erp_s_name,magento1400,base_sale_multichannels.model_external_shop_group,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
3350 | 3 | mag_1400_erp_s_code,magento1400,base_sale_multichannels.model_external_shop_group,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
3351 | 4 | mag_1400_erp_s_web,magento1400,base_sale_multichannels.model_external_shop_group,website_id,,in_out,function,int,,"result=[('website_id',ifield)]", | ||
3352 | 5 | mag_1400_erp_s_isa,magento1400,base_sale_multichannels.model_external_shop_group,is_default,,in_out,function,unicode,,"result=[('is_default',bool(eval(ifield)))]", | ||
3353 | 6 | mag_1400_erp_s_stord,magento1400,base_sale_multichannels.model_external_shop_group,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
3354 | 7 | mag_1400_erp_s_gpid,magento1400,base_sale_multichannels.model_external_shop_group,default_group_id,,in_out,function,int,,"result=[('default_shop_integer_id',ifield)]", | ||
3355 | 8 | mag_1400_erp_sv_name,magento1400,model_magerp_storeviews,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
3356 | 9 | mag_1400_erp_sv_code,magento1400,model_magerp_storeviews,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
3357 | 10 | mag_1400_erp_sv_sg,magento1400,model_magerp_storeviews,website_id,,in_out,function,int,,"result=[('website_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3358 | 11 | mag_1400_erp_sv_isa,magento1400,model_magerp_storeviews,is_active,,in_out,function,unicode,,"result=[('is_active',bool(eval(ifield)))]", | ||
3359 | 12 | mag_1400_erp_sv_stord,magento1400,model_magerp_storeviews,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
3360 | 13 | mag_1400_erp_sv_gpid,magento1400,model_magerp_storeviews,group_id,,in_out,function,int,,"result=[('shop_id',self.pool.get('sale.shop').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3361 | 14 | mag_1400_erp_st_name,magento1400,sale.model_sale_shop,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
3362 | 15 | mag_1400_erp_st_gpid,magento1400,sale.model_sale_shop,group_id,,in_out,function,int,,"result=[('group_id',ifield)]", | ||
3363 | 16 | mag_1400_erp_st_grp,magento1400,sale.model_sale_shop,website_id,,in_out,function,int,,"result=[('shop_group_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3364 | 17 | mag_1400_erp_st_default_st,magento1400,sale.model_sale_shop,default_store_id,,in_out,function,int,,"result=[('default_storeview_integer_id',ifield)]", | ||
3365 | 18 | mag_1400_erp_st_root_categ,magento1400,sale.model_sale_shop,root_category_id,,in_out,function,int,,"result=[('root_category_id',ifield)]", | ||
3366 | 19 | mag_1400_erp_so_total_amount,magento1400,sale.model_sale_order,grand_total,,in_out,function,float,,"result=[('ext_total_amount',str(ifield))]", | ||
3367 | 20 | mag_1400_erp_so_name,magento1400,sale.model_sale_order,increment_id,,in_out,function,unicode,,"result=[('magento_incrementid',str(ifield)), ('name','mag_' + str(ifield))]", | ||
3368 | 21 | mag_1400_erp_so_carrier_id,magento1400,sale.model_sale_order,shipping_method,,in_out,function,unicode,,"if ifield: | ||
3369 | 22 | carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [('magento_code', '=', ifield)]) | ||
3370 | 23 | if carrier_ids: | ||
3371 | 24 | result=[('carrier_id', carrier_ids[0])] | ||
3372 | 25 | else: | ||
3373 | 26 | fake_partner_id = self.pool.get('res.partner').search(cr, uid, [])[0] | ||
3374 | 27 | model_data_obj = self.pool.get('ir.model.data') | ||
3375 | 28 | model, product_id = model_data_obj.get_object_reference(cr, uid, 'base_sale_multichannels', 'product_product_shipping') | ||
3376 | 29 | carrier_id = self.pool.get('delivery.carrier').create(cr, uid, {'partner_id' : fake_partner_id, 'product_id' : product_id, 'name' : ifield, 'magento_code' : ifield}) | ||
3377 | 30 | result=[('carrier_id', carrier_id)]", | ||
3378 | 31 | mag_1400_erp_so_pay,magento1400,sale.model_sale_order,payment,,in_out,function,unicode,," | ||
3379 | 32 | payments_mapping = {'checkmo': 'manual', 'ccsave': 'prepaid', 'free':'prepaid','googlecheckout':'prepaid','paypayl_express':'prepaid', 'paybox_system': 'prepaid', 'paypal_standard': 'prepaid', 'cashondelivery': 'manual', 'servired_standard': 'prepaid', 'bbva': 'prepaid', 'cofidis': 'prepaid'} | ||
3380 | 33 | ifield=eval(ifield) | ||
3381 | 34 | result=[('order_policy', ifield['method'] in payments_mapping and payments_mapping[ifield['method']] or 'prepaid'), ('ext_payment_method', ifield['method'])]", | ||
3382 | 35 | mag_1400_erp_so_item,magento1400,sale.model_sale_order,items,sale.field_sale_order_order_line,in,sub-mapping,dict,magento_1400_order_line,, | ||
3383 | 36 | "mag_1400_erp_soline_name","magento1400","sale.model_sale_order_line","name",,"in_out","function","unicode",,"result=[('name', ifield)] | ||
3384 | 37 | ", | ||
3385 | 38 | "mag_1400_erp_soline_note","magento1400","sale.model_sale_order_line","product_options",,"in","function","unicode",,"if ifield: | ||
3386 | 39 | import re | ||
3387 | 40 | options_label = [] | ||
3388 | 41 | clean = re.sub('\w:\w:|\w:\w+;', '', ifield) | ||
3389 | 42 | for each in clean.split('{'): | ||
3390 | 43 | if each.startswith('""label""'): | ||
3391 | 44 | split_info = each.split(';') | ||
3392 | 45 | options_label.append('%s: %s [%s]' % (split_info[1], split_info[3], data['sku'])) | ||
3393 | 46 | |||
3394 | 47 | result=[('notes', """".join(options_label).replace('""""', '\n').replace('""', ''))] | ||
3395 | 48 | ", | ||
3396 | 49 | mag_1400_erp_soline_pid,magento1400,sale.model_sale_order_line,product_id,,in_out,function,unicode,,"context['alternative_key'] = data['sku'] | ||
3397 | 50 | result=[('product_id',self.pool.get('product.product').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3398 | 51 | mag_1400_erp_soline_uomqty,magento1400,sale.model_sale_order_line,qty_ordered,,in_out,function,unicode,,"result=[('product_uom_qty',ifield)]", | ||
3399 | 52 | mag_1400_erp_soline_uosqty,magento1400,sale.model_sale_order_line,qty_ordered,,in,function,unicode,,"result=[('product_uos_qty',ifield)]", | ||
3400 | 53 | mag_1400_erp_soline_price,magento1400,sale.model_sale_order_line,price,,in,function,unicode,,"if context.get('price_is_tax_included', False): | ||
3401 | 54 | result=[('price_unit', (float(data['row_total']) + float(data['tax_amount']))/float(data['qty_ordered']))] | ||
3402 | 55 | else: | ||
3403 | 56 | result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]", | ||
3404 | 57 | mag_1400_erp_soline_disc,magento1400,sale.model_sale_order_line,discount_amount,,in,function,float,,"if ifield: | ||
3405 | 58 | result=[('discount', float(data['price']) != 0 and float(data['qty_ordered']) != 0 and float(100*ifield)/(float(data['price'])*float(data['qty_ordered'])) or 0)]", | ||
3406 | 59 | mag_1400_erp_procat_2,magento1400,product.model_product_category,level,,in,function,int,,"result=[('sequence',ifield),('level',ifield)]", | ||
3407 | 60 | mag_1400_erp_procat_3,magento1400,product.model_product_category,parent_id,,in_out,function,int,,"record_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', self._name), ('name', '=', self.prefixed_id(ifield))]) | ||
3408 | 61 | parent_id = False | ||
3409 | 62 | if record_id: | ||
3410 | 63 | parent_rec = self.pool.get('ir.model.data').read(cr,uid,record_id[0],[]) | ||
3411 | 64 | parent_id=parent_rec.get('res_id',False) | ||
3412 | 65 | result=[('magento_parent_id',ifield),('parent_id',parent_id)]","magento_parent_id = False | ||
3413 | 66 | if record.get('parent_id',False): | ||
3414 | 67 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
3415 | 68 | if not magento_parent_id: | ||
3416 | 69 | self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[external_referential_id],{},context=context) | ||
3417 | 70 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
3418 | 71 | if magento_parent_id: | ||
3419 | 72 | result = [('parent_id',magento_parent_id)]" | ||
3420 | 73 | mag_1400_erp_procat_4,magento1400,product.model_product_category,is_active,,in_out,function,unicode,,"result=[('is_active',ifield and (eval(ifield)) or False)]","result=[('is_active',record['is_active'])]" | ||
3421 | 74 | mag_1400_erp_procat_5,magento1400,product.model_product_category,description,,in_out,function,unicode,,"result=[('description',ifield)]","result=[('description',record['description'])]" | ||
3422 | 75 | mag_1400_erp_procat_6,magento1400,product.model_product_category,meta_title,,in_out,function,unicode,,"result=[('meta_title',ifield)]","result=[('meta_title',record['meta_title'])]" | ||
3423 | 76 | mag_1400_erp_procat_7,magento1400,product.model_product_category,meta_keywords,,in_out,function,unicode,,"result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]" | ||
3424 | 77 | mag_1400_erp_procat_8,magento1400,product.model_product_category,meta_description,,in_out,function,unicode,,"result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]" | ||
3425 | 78 | mag_1400_erp_procat_9,magento1400,product.model_product_category,url_key,,in_out,function,unicode,,"result=[('url_key',ifield)]","if context.get('export_url', False) : | ||
3426 | 79 | result=[('url_key',record['url_key'])]" | ||
3427 | 80 | mag_1400_erp_procat_10,magento1400,product.model_product_category,name,,in_out,function,unicode,,"result=[('name',ifield or 'UNDEFINED'),('magento_exportable',True)]","result=[('name',record['name'])]" | ||
3428 | 81 | mag_1400_erp_procat_11,magento1400,product.model_product_category,is_anchor,,in_out,function,unicode,,"result=[('is_anchor',ifield and bool(eval(ifield)) or False)]","result=[('is_anchor',record['is_anchor'])]" | ||
3429 | 82 | mag_1400_erp_procat_12,magento1400,product.model_product_category,available_sort_by,,in_out,function,list,,"attr_ids = [] | ||
3430 | 83 | cat_attr_obj = self.pool.get('magerp.product_category_attribute_options') | ||
3431 | 84 | if ifield: | ||
3432 | 85 | for val in ifield: | ||
3433 | 86 | attr_ids.append(cat_attr_obj.get_create_option_id(cr, uid, val,'sort_by', context=context)) | ||
3434 | 87 | result=[('available_sort_by', [(6, 0, attr_ids)]), ('use_default_available_sort_by', False)] | ||
3435 | 88 | else: | ||
3436 | 89 | result=[('use_default_available_sort_by', True)]","if record['use_default_available_sort_by']: | ||
3437 | 90 | res = u'' | ||
3438 | 91 | else: | ||
3439 | 92 | res = [] | ||
3440 | 93 | for cat_attr_option in self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, record['available_sort_by'], context=context): | ||
3441 | 94 | res.append(cat_attr_option.value) | ||
3442 | 95 | # comment out the following line if you can run the following SQL query on the Magento database: | ||
3443 | 96 | # update eav_attribute set is_required = 0 where attribute_code = 'available_sort_by'; | ||
3444 | 97 | res = u'' | ||
3445 | 98 | result=[('available_sort_by', res)]" | ||
3446 | 99 | mag_1400_erp_procat_13,magento1400,product.model_product_category,default_sort_by,,in_out,function,unicode,,"if ifield: | ||
3447 | 100 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'sort_by', context=context) | ||
3448 | 101 | else: | ||
3449 | 102 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','sort_by', context=context) | ||
3450 | 103 | result=[('default_sort_by',att_id)]","options_obj = self.pool.get('magerp.product_category_attribute_options') | ||
3451 | 104 | cat_attr_option_id = record['default_sort_by'] | ||
3452 | 105 | if cat_attr_option_id: | ||
3453 | 106 | cat_attr_option_id = cat_attr_option_id[0] | ||
3454 | 107 | else: | ||
3455 | 108 | cat_attr_option_id = options_obj._get_default_option(cr, uid, 'sort_by', '', context=context) | ||
3456 | 109 | |||
3457 | 110 | cat_attr_option = options_obj.browse(cr, uid, cat_attr_option_id, context=context) | ||
3458 | 111 | result=[('default_sort_by', cat_attr_option.value)]" | ||
3459 | 112 | mag_1400_erp_procat_14,magento1400,product.model_product_category,updated_at,,in,function,unicode,,"result=[('magerp_stamp',ifield)]", | ||
3460 | 113 | mag_1400_erp_procat_15,magento1400,product.model_product_category,image,,in_out,function,unicode,,"image_binary = False | ||
3461 | 114 | if ifield and not ifield=='None': | ||
3462 | 115 | try: | ||
3463 | 116 | image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) | ||
3464 | 117 | except Exception, e: | ||
3465 | 118 | print e | ||
3466 | 119 | pass | ||
3467 | 120 | if image_binary: | ||
3468 | 121 | image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) | ||
3469 | 122 | result=[('image_name',ifield),('image',image_binary)]","if record['image']: | ||
3470 | 123 | img = base64.decodestring(record['image']) | ||
3471 | 124 | img_bin_enc = base64.encodestring(img) | ||
3472 | 125 | conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc]) | ||
3473 | 126 | result = [('image',record['image_name'])] | ||
3474 | 127 | else: | ||
3475 | 128 | result=[]" | ||
3476 | 129 | mag_1400_erp_procat_16,magento1400,product.model_product_category,include_in_menu,,in_out,function,unicode,,"result=[('include_in_menu', ifield and (eval(ifield)) or False)]","result=[('include_in_menu',record['include_in_menu'])]" | ||
3477 | 130 | mag_1400_erp_procat_17,magento1400,product.model_product_category,page_layout,,in_out,function,unicode,,"if ifield: | ||
3478 | 131 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'page_layout', context=context) | ||
3479 | 132 | else: | ||
3480 | 133 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','page_layout', context=context) | ||
3481 | 134 | result=[('page_layout',att_id)]","page_layout = record['page_layout'] and record['page_layout'][1] or '' | ||
3482 | 135 | result=[('page_layout', page_layout)]" | ||
3483 | 136 | mag_1400_erp_attrgrp_2,magento1400,model_magerp_product_attribute_groups,attribute_set_id,,in_out,function,int,,"result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]" | ||
3484 | 137 | mag_1400_erp_attrgrp_3,magento1400,model_magerp_product_attribute_groups,attribute_group_name,,in_out,function,unicode,,"result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]" | ||
3485 | 138 | mag_1400_erp_attrgrp_4,magento1400,model_magerp_product_attribute_groups,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
3486 | 139 | mag_1400_erp_attrgrp_5,magento1400,model_magerp_product_attribute_groups,default_id,,in_out,function,int,,"result=[('default_id', ifield)]","result=[('default_id', record['default_id'])]" | ||
3487 | 140 | mag_1400_erp_attrset_1,magento1400,model_magerp_product_attribute_set,attribute_set_id,,in_out,function,int,,"result=[('magento_id', ifield)]","result=[('attribute_set_id', record['magento_id'])]" | ||
3488 | 141 | mag_1400_erp_attrset_2,magento1400,model_magerp_product_attribute_set,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
3489 | 142 | mag_1400_erp_attrset_3,magento1400,model_magerp_product_attribute_set,attribute_set_name,,in_out,function,unicode,,"result=[('attribute_set_name', ifield)]","result=[('attribute_set_name', record['attribute_set_name'])]" | ||
3490 | 143 | mag_1400_erp_attr_1,magento1400,model_magerp_product_attributes,attribute_code,,in_out,function,unicode,,"result=[('attribute_code', ifield)]","result=[('code', record['attribute_code'])]" | ||
3491 | 144 | mag_1400_erp_attr_2,magento1400,model_magerp_product_attributes,attribute_id,,in_out,function,int,,"result=[('magento_id', ifield)]", | ||
3492 | 145 | mag_1400_erp_attr_3,magento1400,model_magerp_product_attributes,frontend_input,,in_out,function,unicode,,"result=[('frontend_input', ifield)]","result=[('frontend_input', record['frontend_input'])]" | ||
3493 | 146 | mag_1400_erp_attr_4,magento1400,model_magerp_product_attributes,frontend_class,,in_out,function,unicode,,"result=[('frontend_class', ifield)]","result=[('frontend_class', record['frontend_class'])]" | ||
3494 | 147 | mag_1400_erp_attr_5,magento1400,model_magerp_product_attributes,backend_model,,in_out,function,unicode,,"result=[('backend_model', ifield)]","result=[('backend_model', record['backend_model'])]" | ||
3495 | 148 | mag_1400_erp_attr_6,magento1400,model_magerp_product_attributes,backend_type,,in_out,function,unicode,,"result=[('backend_type', ifield)]","result=[('backend_type', record['backend_type'])]" | ||
3496 | 149 | mag_1400_erp_attr_7,magento1400,model_magerp_product_attributes,frontend_label,,in_out,function,unicode,,"result=[('frontend_label', ifield)]","result=[('frontend_label', record['frontend_label'])]" | ||
3497 | 150 | mag_1400_erp_attr_8,magento1400,model_magerp_product_attributes,is_visible_in_advanced_search,,in_out,function,unicode,,"result=[('is_visible_in_advanced_search', bool(eval(ifield)))]","result=[('is_visible_in_advanced_search', record['is_visible_in_advanced_search'])]" | ||
3498 | 151 | mag_1400_erp_attr_9,magento1400,model_magerp_product_attributes,is_global,,in_out,function,unicode,,"result=[('is_global', bool(eval(ifield)))]","result=[('is_global', record['is_global'])]" | ||
3499 | 152 | mag_1400_erp_attr_10,magento1400,model_magerp_product_attributes,is_filterable,,in_out,function,unicode,,"result=[('is_filterable', bool(eval(ifield)))]","result=[('is_filterable', record['is_filterable'])]" | ||
3500 | 153 | mag_1400_erp_attr_11,magento1400,model_magerp_product_attributes,is_comparable,,in_out,function,unicode,,"result=[('is_comparable', bool(eval(ifield)))]","result=[('is_comparable', record['is_comparable'])]" | ||
3501 | 154 | mag_1400_erp_attr_12,magento1400,model_magerp_product_attributes,is_visible,,in_out,function,unicode,,"result=[('is_visible', bool(eval(ifield)))]","result=[('is_visible', record['is_visible'])]" | ||
3502 | 155 | mag_1400_erp_attr_13,magento1400,model_magerp_product_attributes,is_searchable,,in_out,function,unicode,,"result=[('is_searchable', bool(eval(ifield)))]","result=[('is_searchable', record['is_searchable'])]" | ||
3503 | 156 | mag_1400_erp_attr_14,magento1400,model_magerp_product_attributes,is_user_defined,,in_out,function,unicode,,"result=[('is_user_defined', bool(eval(ifield)))]","result=[('is_user_defined', record['is_user_defined'])]" | ||
3504 | 157 | mag_1400_erp_attr_15,magento1400,model_magerp_product_attributes,is_configurable,,in_out,function,unicode,,"result=[('is_configurable', bool(eval(ifield)))]","result=[('is_configurable', record['is_configurable'])]" | ||
3505 | 158 | mag_1400_erp_attr_16,magento1400,model_magerp_product_attributes,is_visible_on_front,,in_out,function,unicode,,"result=[('is_visible_on_front', bool(eval(ifield)))]","result=[('is_visible_on_front', record['is_visible_on_front'])]" | ||
3506 | 159 | mag_1400_erp_attr_17,magento1400,model_magerp_product_attributes,is_used_for_price_rules,,in_out,function,unicode,,"result=[('is_used_for_price_rules', bool(eval(ifield)))]","result=[('is_used_for_price_rules', record['is_used_for_price_rules'])]" | ||
3507 | 160 | mag_1400_erp_attr_18,magento1400,model_magerp_product_attributes,is_unique,,in_out,function,unicode,,"result=[('is_unique', bool(eval(ifield)))]","result=[('is_unique', record['is_unique'])]" | ||
3508 | 161 | mag_1400_erp_attr_19,magento1400,model_magerp_product_attributes,is_required,,in_out,function,unicode,,"result=[('is_required', bool(eval(ifield)))]","result=[('is_required', record['is_required'])]" | ||
3509 | 162 | mag_1400_erp_attr_20,magento1400,model_magerp_product_attributes,position,,in_out,function,int,,"result=[('position', ifield)]","result=[('position', record['position'])]" | ||
3510 | 163 | mag_1400_erp_attr_21,magento1400,model_magerp_product_attributes,attribute_set_info,,in_out,function,unicode,,"result=[('attribute_set_info', ifield)]","result=[('attribute_set_info', record['attribute_set_info'])]" | ||
3511 | 164 | mag_1400_erp_attr_22,magento1400,model_magerp_product_attributes,default_value,,in_out,function,unicode,,"result=[('default_value', ifield)]","result=[('default_value', record['default_value'])]" | ||
3512 | 165 | mag_1400_erp_attr_23,magento1400,model_magerp_product_attributes,note,,in_out,function,unicode,,"result=[('note', ifield)]","result=[('note', record['note'])]" | ||
3513 | 166 | mag_1400_erp_attr_24,magento1400,model_magerp_product_attributes,entity_type_id,,in_out,function,int,,"result=[('entity_type_id', ifield)]","result=[('entity_type_id', record['entity_type_id'])]" | ||
3514 | 167 | mag_1400_erp_attr_25,magento1400,model_magerp_product_attributes,apply_to,,in_out,function,unicode,,"result=[('apply_to', str(ifield))]","result=[('apply_to', eval(record['%s']))]" | ||
3515 | 168 | mag_1400_erp_prd_1,magento1400,product.model_product_product,url_key,,in_out,function,unicode,,"result=[('x_magerp_url_key',ifield)]","if context.get('export_url', False) : | ||
3516 | 169 | result=[('url_key',record['x_magerp_url_key'])]" | ||
3517 | 170 | mag_1400_erp_prd_2,magento1400,product.model_product_product,name,,in_out,function,unicode,,"result = [('name',ifield)]","result = [('name',record['name'])]" | ||
3518 | 171 | mag_1400_erp_prd_3,magento1400,product.model_product_product,description,,in_out,function,unicode,,"result = [('description',ifield)]", | ||
3519 | 172 | mag_1400_erp_prd_4,magento1400,product.model_product_product,short_description,,in_out,function,unicode,,"result = [('description_sale',ifield)]", | ||
3520 | 173 | mag_1400_erp_prd_5,magento1400,product.model_product_product,sku,,in_out,function,unicode,,"result = [('magento_sku',ifield), ('default_code',ifield)]", | ||
3521 | 174 | mag_1400_erp_prd_6,magento1400,product.model_product_product,weight,,in_out,function,float,,"result = [('weight',ifield)]","result = [('weight',record['weight'] or 0)]" | ||
3522 | 175 | mag_1400_erp_prd_7,magento1400,product.model_product_product,category_ids,,in_out,function,list,,"categ_ids =[] | ||
3523 | 176 | if ifield and len(ifield) > 0: | ||
3524 | 177 | for category_ids in ifield: | ||
3525 | 178 | categ_ids.append(self.pool.get('product.category').extid_to_oeid(cr, uid, category_ids, external_referential_id, context=context)) | ||
3526 | 179 | categ_id = categ_ids.pop() | ||
3527 | 180 | else: | ||
3528 | 181 | categ_id = self.pool.get('external.referential').browse(cr, uid, external_referential_id).default_pro_cat.id | ||
3529 | 182 | result = [('categ_id', categ_id), ('categ_ids',[(6, 0, categ_ids)])]"," | ||
3530 | 183 | cat_obj = self.pool.get('product.category') | ||
3531 | 184 | product = self.browse(cr, uid, record['id']) | ||
3532 | 185 | categ_ids = [categ.id for categ in ([product.categ_id] + product.categ_ids) if categ.magento_exportable] | ||
3533 | 186 | mag_categ_ids = [] | ||
3534 | 187 | for categ_id in categ_ids: | ||
3535 | 188 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
3536 | 189 | if not mag_categ_id: | ||
3537 | 190 | cat_obj.ext_export(cr, uid, [categ_id], [external_referential_id], context=context) | ||
3538 | 191 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
3539 | 192 | mag_categ_ids.append(mag_categ_id) | ||
3540 | 193 | result=[('category_ids', mag_categ_ids)]" | ||
3541 | 194 | mag_1400_erp_prd_8,magento1400,product.model_product_product,price,,in_out,function,float,,"result=[('list_price',ifield)]",result=[]#map later | ||
3542 | 195 | mag_1400_erp_prd_9,magento1400,product.model_product_product,cost,,in_out,function,float,,"result=[('standard_price',ifield)]","result = [('cost',record['standard_price'] or 0)]" | ||
3543 | 196 | mag_1400_erp_prd_10,magento1400,product.model_product_product,set,,in_out,function,unicode,,"result=[('set',self.pool.get('magerp.product_attribute_set').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3544 | 197 | mag_1400_erp_prd_11,magento1400,product.model_product_product,special_price,,in_out,function,float,,"result = [('x_magerp_special_price',ifield)]", | ||
3545 | 198 | mag_1400_erp_prd_12,magento1400,product.model_product_product,tier_price,,in_out,function,unicode,,result=[]#no mapping by default,result=[]#no mapping by default | ||
3546 | 199 | mag_1400_erp_prd_13,magento1400,product.model_product_product,minimal_price,,in_out,function,float,,"result = [('x_magerp_minimal_price',ifield)]"," | ||
3547 | 200 | if record['x_magerp_minimal_price'] and record['x_magerp_minimal_price'] != 0: | ||
3548 | 201 | result = [('minimal_price',record['x_magerp_minimal_price'])] | ||
3549 | 202 | else: | ||
3550 | 203 | result = [('minimal_price',False)]" | ||
3551 | 204 | mag_1400_erp_prd_14,magento1400,product.model_product_product,type_id,,in_out,function,unicode,,"if ifield: | ||
3552 | 205 | product_type_ids = self.pool.get('magerp.product_product_type').search(cr,uid,[('product_type','=',ifield)]) | ||
3553 | 206 | if product_type_ids: | ||
3554 | 207 | result = [('product_type',ifield)]","if 'product_type' in record and record['product_type']: | ||
3555 | 208 | result = [('type_id',record['product_type'])] | ||
3556 | 209 | else: | ||
3557 | 210 | result = [('type_id','simple')]" | ||
3558 | 211 | mag_1400_erp_prd_15,magento1400,product.model_product_product,websites,,in_out,function,list,,"websites_ids = [] | ||
3559 | 212 | for ext_id in ifield: | ||
3560 | 213 | websites_ids.append(self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ext_id, external_referential_id, context=context)) | ||
3561 | 214 | |||
3562 | 215 | ##### OPTION START, with this if the field websites of the product is empty the product is exported on every website | ||
3563 | 216 | all_oe_websites_ids = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', external_referential_id)]) | ||
3564 | 217 | if set(websites_ids) == set(all_oe_websites_ids): | ||
3565 | 218 | websites_ids =[] | ||
3566 | 219 | ##### OPTION END | ||
3567 | 220 | |||
3568 | 221 | result=[('websites_ids', [(6,0, websites_ids)])]","##### OPTION START, with this if the field websites of the product is empty the product is exported on every website | ||
3569 | 222 | if not record['websites_ids']: | ||
3570 | 223 | record['websites_ids'] = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', external_referential_id)]) | ||
3571 | 224 | ##### OPTION END | ||
3572 | 225 | |||
3573 | 226 | ext_websites_ids = [] | ||
3574 | 227 | for oe_id in record['websites_ids']: | ||
3575 | 228 | ext_websites_ids.append(self.pool.get('external.shop.group').oeid_to_extid(cr, uid, oe_id, external_referential_id)) | ||
3576 | 229 | |||
3577 | 230 | result=[('websites', ext_websites_ids)]" | ||
3578 | 231 | mag_1400_erp_prd_16,magento1400,product.model_product_product,has_options,,in,function,unicode,,"result =[('x_magerp_has_options',ifield)]", | ||
3579 | 232 | magento_1400_cst_grp_1,magento1400,base.model_res_partner_category,customer_group_code,,in,function,unicode,,"result=[('name',ifield)]", | ||
3580 | 233 | magento_1400_cst_grp_3,magento1400,base.model_res_partner_category,tax_class_id,,in,function,int,,"result=[('tax_class_id',ifield)]", | ||
3581 | 234 | magento_1400_prt_adr_2,magento1400,base.model_res_partner_address,city,,in_out,function,unicode,,"result=[('city',ifield)]", | ||
3582 | 235 | magento_1400_prt_adr_3,magento1400,base.model_res_partner_address,fax,,in_out,function,unicode,,"result=[('fax',ifield)]", | ||
3583 | 236 | magento_1400_prt_adr_4,magento1400,base.model_res_partner_address,firstname,,in_out,function,unicode,,"name = ' '.join([ f for f in (data['firstname'], data['lastname']) if f]) | ||
3584 | 237 | if data.get('company'): | ||
3585 | 238 | name = ""%s ; %s"" % (data['company'], name) | ||
3586 | 239 | result = [('name', name), ('firstname', ifield), ('lastname', data['lastname'])]", | ||
3587 | 240 | magento_1400_prt_adr_6,magento1400,base.model_res_partner_address,is_active,,in_out,function,unicode,,"result=[('active',bool(eval(ifield)))]", | ||
3588 | 241 | magento_1400_prt_adr_7,magento1400,base.model_res_partner_address,country_id,,in_out,function,unicode,,"result = self.pool.get('res.country').search(cr,uid,[('code','=',ifield)]) | ||
3589 | 242 | if result and len(result)==1: | ||
3590 | 243 | result=[('country_id',result[0])] | ||
3591 | 244 | else: | ||
3592 | 245 | result=[] | ||
3593 | 246 | ", | ||
3594 | 247 | magento_1400_prt_adr_8,magento1400,base.model_res_partner_address,street,,in_out,function,unicode,,"if ifield: | ||
3595 | 248 | if len(ifield.split('\n')) ==2 : | ||
3596 | 249 | result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] | ||
3597 | 250 | else : | ||
3598 | 251 | result = [('street',ifield.replace('\\n',','))] | ||
3599 | 252 | else: | ||
3600 | 253 | result = []", | ||
3601 | 254 | magento_1400_prt_adr_9,magento1400,base.model_res_partner_address,postcode,,in_out,function,unicode,,"result=[('zip',ifield)]", | ||
3602 | 255 | magento_1400_prt_adr_10,magento1400,base.model_res_partner_address,telephone,,in_out,function,unicode,,"result=[('phone',ifield)]", | ||
3603 | 256 | magento_1400_prt_adr_11,magento1400,base.model_res_partner_address,region,,in_out,function,unicode,,"if ifield: | ||
3604 | 257 | result = self.pool.get('res.country.state').search(cr,uid,[('name','=ilike',ifield)]) | ||
3605 | 258 | if result and len(result)==1: | ||
3606 | 259 | result = [('state_id',result[0])] | ||
3607 | 260 | else: | ||
3608 | 261 | result=[] | ||
3609 | 262 | else: | ||
3610 | 263 | result=[]", | ||
3611 | 264 | magento_1400_prt_adr_13,magento1400,base.model_res_partner_address,customer_id,,in_out,function,int,,"result=self.pool.get('res.partner').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3612 | 265 | if result: | ||
3613 | 266 | result=[('partner_id',result)] | ||
3614 | 267 | else: | ||
3615 | 268 | result=[('partner_id',False)]", | ||
3616 | 269 | magento_1400_prt_adr_14,magento1400,base.model_res_partner_address,address_type,,in_out,function,unicode,,"if ifield=='billing': | ||
3617 | 270 | result=[('type','invoice')] | ||
3618 | 271 | elif ifield=='shipping': | ||
3619 | 272 | result=[('type','delivery')] | ||
3620 | 273 | else: | ||
3621 | 274 | result=[]", | ||
3622 | 275 | magento_1400_prt_adr_15,magento1400,base.model_res_partner_address,email,,in_out,function,unicode,,"result = [('email', False)] | ||
3623 | 276 | if ifield: | ||
3624 | 277 | result = [('email', ifield)] | ||
3625 | 278 | else: | ||
3626 | 279 | partner_obj = self.pool.get('res.partner') | ||
3627 | 280 | partner_id = partner_obj.extid_to_existing_oeid(cr, uid, data['customer_id'] ,external_referential_id) | ||
3628 | 281 | if partner_id: | ||
3629 | 282 | result = [('email', partner_obj.browse(cr, uid, partner_id).emailid)]", | ||
3630 | 283 | magento_1400_prt_adr_17,magento1400,base.model_res_partner_address,default_billing,,in_out,function,unicode,,"result = [('type', 'other')] | ||
3631 | 284 | if data.get('default_billing') and data.get('default_shipping'): | ||
3632 | 285 | result = [('type', 'default')] | ||
3633 | 286 | elif data.get('default_billing'): | ||
3634 | 287 | result = [('type', 'invoice')] | ||
3635 | 288 | elif data.get('default_shipping'): | ||
3636 | 289 | result = [('type', 'delivery')]", | ||
3637 | 290 | magento_1400_prt_2,magento1400,base.model_res_partner,group_id,,in_out,function,int,,"if ifield: | ||
3638 | 291 | result=self.pool.get('res.partner.category').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3639 | 292 | if result: | ||
3640 | 293 | result=[('group_id',result)]", | ||
3641 | 294 | magento_1400_prt_3,magento1400,base.model_res_partner,store_id,,in_out,function,int,,"if ifield: | ||
3642 | 295 | result=self.pool.get('magerp.storeviews').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3643 | 296 | if result: | ||
3644 | 297 | store = self.pool.get('magerp.storeviews').browse(cr, uid, result) | ||
3645 | 298 | lang = store.lang_id | ||
3646 | 299 | result=[('store_id',result),('lang',lang and lang.code or False)] | ||
3647 | 300 | if not data.get('website_id'): | ||
3648 | 301 | result.append(('website_id', store.website_id.id))", | ||
3649 | 302 | magento_1400_prt_4,magento1400,base.model_res_partner,website_id,,in_out,function,int,,"if ifield: | ||
3650 | 303 | result=self.pool.get('external.shop.group').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3651 | 304 | if result: | ||
3652 | 305 | result=[('website_id',result)]", | ||
3653 | 306 | magento_1400_prt_5,magento1400,base.model_res_partner,created_in,,in_out,function,unicode,,"result=[('created_in',ifield)]", | ||
3654 | 307 | magento_1400_prt_6,magento1400,base.model_res_partner,created_at,,in_out,function,unicode,,"result=[('created_at',ifield)]", | ||
3655 | 308 | magento_1400_prt_7,magento1400,base.model_res_partner,updated_at,,in_out,function,unicode,,"result=[('updated_at',ifield)]", | ||
3656 | 309 | magento_1400_prt_8,magento1400,base.model_res_partner,firstname,,in_out,function,unicode,,"result = [('name', ifield + ' ' + data['lastname'])]","add_id = self.browse(cr, uid, record['id']) | ||
3657 | 310 | fn = add_id.address[0].firstname | ||
3658 | 311 | ln = add_id.address[0].lastname | ||
3659 | 312 | result=[('firstname', fn), ('lastname', ln)]" | ||
3660 | 313 | magento_1400_prt_10,magento1400,base.model_res_partner,email,,in_out,function,unicode,,"result=[('emailid',ifield)]", | ||
3661 | 314 | magento_1400_prt_11,magento1400,base.model_res_partner,taxvat,,in_out,function,unicode,,"if ifield: | ||
3662 | 315 | result=[('mag_vat',ifield)] | ||
3663 | 316 | else: | ||
3664 | 317 | result=[]", | ||
3665 | 318 | magento_1400_prt_12,magento1400,base.model_res_partner,dob,,in_out,function,unicode,,"if ifield: | ||
3666 | 319 | result =[('mag_birthday',ifield[:10])] | ||
3667 | 320 | else: | ||
3668 | 321 | result=[]", | ||
3669 | 0 | 322 | ||
3670 | === added file 'magentoerpconnect/settings/1.4.0.0/external.referential.type.csv' | |||
3671 | --- magentoerpconnect/settings/1.4.0.0/external.referential.type.csv 1970-01-01 00:00:00 +0000 | |||
3672 | +++ magentoerpconnect/settings/1.4.0.0/external.referential.type.csv 2012-07-06 14:53:18 +0000 | |||
3673 | @@ -0,0 +1,2 @@ | |||
3674 | 1 | "id","name" | ||
3675 | 2 | "magento1400","Magento Version 1.4.0.0+" | ||
3676 | 0 | 3 | ||
3677 | === added directory 'magentoerpconnect/settings/1.4.2.0' | |||
3678 | === added file 'magentoerpconnect/settings/1.4.2.0/external.mapping.template.csv' | |||
3679 | --- magentoerpconnect/settings/1.4.2.0/external.mapping.template.csv 1970-01-01 00:00:00 +0000 | |||
3680 | +++ magentoerpconnect/settings/1.4.2.0/external.mapping.template.csv 2012-07-06 14:53:18 +0000 | |||
3681 | @@ -0,0 +1,14 @@ | |||
3682 | 1 | "id","type_id:id","model_id:id","external_list_method","external_get_method","external_update_method","external_create_method","external_delete_method","external_key_name" | ||
3683 | 2 | "magento_1420_website","magento1420","base_sale_multichannels.model_external_shop_group","ol_websites.list",,,,,"website_id" | ||
3684 | 3 | "magento_1420_storeview","magento1420","model_magerp_storeviews","ol_storeviews.list",,,,,"store_id" | ||
3685 | 4 | "magento_1420_store","magento1420","sale.model_sale_shop","ol_groups.list",,,,,"group_id" | ||
3686 | 5 | "magento_1420_order","magento1420","sale.model_sale_order","sales_order.list","sales_order.info",,,,"increment_id" | ||
3687 | 6 | "magento_1420_order_line","magento1420","sale.model_sale_order_line",,,,,,"item_id" | ||
3688 | 7 | "magento_1420_pro_cat","magento1420","product.model_product_category","category.list","category.info","catalog_category.update","catalog_category.create",,"category_id" | ||
3689 | 8 | "magento_1420_attr_grp","magento1420","model_magerp_product_attribute_groups","ol_catalog_product_attribute_group.list","ol_catalog_product_attribute_group.list",,,,"attribute_group_id" | ||
3690 | 9 | "magento_1420_attr_set","magento1420","model_magerp_product_attribute_set","ol_catalog_product_attributeset.list",,,,,"attribute_set_id" | ||
3691 | 10 | "magento_1420_attr","magento1420","model_magerp_product_attributes","ol_catalog_product_attribute.list",,,,,"attribute_id" | ||
3692 | 11 | "magento_1420_prd","magento1420","product.model_product_product","catalog_product.list","catalog_product.info","ol_catalog_product.update","ol_catalog_product.create",,"product_id" | ||
3693 | 12 | "magento_1420_cst_grp","magento1420","base.model_res_partner_category","ol_customer_groups.list",,,,,"customer_group_id" | ||
3694 | 13 | "magento_1420_prt_adr","magento1420","base.model_res_partner_address","ol_customer_address.list","ol_customer_address.info",,,,"entity_id" | ||
3695 | 14 | "magento_1420_prt","magento1420","base.model_res_partner","customer.list","customer.info","customer.update",,,"customer_id" | ||
3696 | 0 | 15 | ||
3697 | === added file 'magentoerpconnect/settings/1.4.2.0/external.mappinglines.template.csv' | |||
3698 | --- magentoerpconnect/settings/1.4.2.0/external.mappinglines.template.csv 1970-01-01 00:00:00 +0000 | |||
3699 | +++ magentoerpconnect/settings/1.4.2.0/external.mappinglines.template.csv 2012-07-06 14:53:18 +0000 | |||
3700 | @@ -0,0 +1,318 @@ | |||
3701 | 1 | id,type_id:id,model_id:id,external_field,field_id:id,type,evaluation_type,external_type,child_mapping_id:id,in_function,out_function | ||
3702 | 2 | mag_1420_erp_s_name,magento1420,base_sale_multichannels.model_external_shop_group,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
3703 | 3 | mag_1420_erp_s_code,magento1420,base_sale_multichannels.model_external_shop_group,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
3704 | 4 | mag_1420_erp_s_web,magento1420,base_sale_multichannels.model_external_shop_group,website_id,,in_out,function,int,,"result=[('website_id',ifield)]", | ||
3705 | 5 | mag_1420_erp_s_isa,magento1420,base_sale_multichannels.model_external_shop_group,is_default,,in_out,function,unicode,,"result=[('is_default',bool(eval(ifield)))]", | ||
3706 | 6 | mag_1420_erp_s_stord,magento1420,base_sale_multichannels.model_external_shop_group,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
3707 | 7 | mag_1420_erp_s_gpid,magento1420,base_sale_multichannels.model_external_shop_group,default_group_id,,in_out,function,int,,"result=[('default_shop_integer_id',ifield)]", | ||
3708 | 8 | mag_1420_erp_sv_name,magento1420,model_magerp_storeviews,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
3709 | 9 | mag_1420_erp_sv_code,magento1420,model_magerp_storeviews,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
3710 | 10 | mag_1420_erp_sv_sg,magento1420,model_magerp_storeviews,website_id,,in_out,function,int,,"result=[('website_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3711 | 11 | mag_1420_erp_sv_isa,magento1420,model_magerp_storeviews,is_active,,in_out,function,unicode,,"result=[('is_active',bool(eval(ifield)))]", | ||
3712 | 12 | mag_1420_erp_sv_stord,magento1420,model_magerp_storeviews,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
3713 | 13 | mag_1420_erp_sv_gpid,magento1420,model_magerp_storeviews,group_id,,in_out,function,int,,"result=[('shop_id',self.pool.get('sale.shop').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3714 | 14 | mag_1420_erp_st_name,magento1420,sale.model_sale_shop,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
3715 | 15 | mag_1420_erp_st_gpid,magento1420,sale.model_sale_shop,group_id,,in_out,function,int,,"result=[('group_id',ifield)]", | ||
3716 | 16 | mag_1420_erp_st_grp,magento1420,sale.model_sale_shop,website_id,,in_out,function,int,,"result=[('shop_group_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3717 | 17 | mag_1420_erp_st_default_st,magento1420,sale.model_sale_shop,default_store_id,,in_out,function,int,,"result=[('default_storeview_integer_id',ifield)]", | ||
3718 | 18 | mag_1420_erp_st_root_categ,magento1420,sale.model_sale_shop,root_category_id,,in_out,function,int,,"result=[('root_category_id',ifield)]", | ||
3719 | 19 | mag_1420_erp_so_total_amount,magento1420,sale.model_sale_order,grand_total,,in_out,function,float,,"result=[('ext_total_amount',str(ifield))]", | ||
3720 | 20 | mag_1420_erp_so_name,magento1420,sale.model_sale_order,increment_id,,in_out,function,unicode,,"result=[('magento_incrementid',str(ifield)), ('name','mag_' + str(ifield))]", | ||
3721 | 21 | mag_1420_erp_so_carrier_id,magento1420,sale.model_sale_order,shipping_method,,in_out,function,unicode,,"if ifield: | ||
3722 | 22 | carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [('magento_code', '=', ifield)]) | ||
3723 | 23 | if carrier_ids: | ||
3724 | 24 | result=[('carrier_id', carrier_ids[0])] | ||
3725 | 25 | else: | ||
3726 | 26 | fake_partner_id = self.pool.get('res.partner').search(cr, uid, [])[0] | ||
3727 | 27 | model_data_obj = self.pool.get('ir.model.data') | ||
3728 | 28 | model, product_id = model_data_obj.get_object_reference(cr, uid, 'base_sale_multichannels', 'product_product_shipping') | ||
3729 | 29 | carrier_id = self.pool.get('delivery.carrier').create(cr, uid, {'partner_id' : fake_partner_id, 'product_id' : product_id, 'name' : ifield, 'magento_code' : ifield}) | ||
3730 | 30 | result=[('carrier_id', carrier_id)]", | ||
3731 | 31 | mag_1420_erp_so_pay,magento1420,sale.model_sale_order,payment,,in_out,function,unicode,," | ||
3732 | 32 | payments_mapping = {'checkmo': 'manual', 'ccsave': 'prepaid', 'free':'prepaid','googlecheckout':'prepaid','paypayl_express':'prepaid', 'paybox_system': 'prepaid', 'paypal_standard': 'prepaid', 'cashondelivery': 'manual', 'servired_standard': 'prepaid', 'bbva': 'prepaid', 'cofidis': 'prepaid'} | ||
3733 | 33 | ifield=eval(ifield) | ||
3734 | 34 | result=[('order_policy', ifield['method'] in payments_mapping and payments_mapping[ifield['method']] or 'prepaid'), ('ext_payment_method', ifield['method'])]", | ||
3735 | 35 | mag_1420_erp_so_item,magento1420,sale.model_sale_order,items,sale.field_sale_order_order_line,in,sub-mapping,dict,magento_1420_order_line,, | ||
3736 | 36 | "mag_1420_erp_soline_name","magento1420","sale.model_sale_order_line","name",,"in_out","function","unicode",,"result=[('name', ifield)] | ||
3737 | 37 | ", | ||
3738 | 38 | "mag_1420_erp_soline_note","magento1420","sale.model_sale_order_line","product_options",,"in","function","unicode",,"if ifield: | ||
3739 | 39 | import re | ||
3740 | 40 | options_label = [] | ||
3741 | 41 | clean = re.sub('\w:\w:|\w:\w+;', '', ifield) | ||
3742 | 42 | for each in clean.split('{'): | ||
3743 | 43 | if each.startswith('""label""'): | ||
3744 | 44 | split_info = each.split(';') | ||
3745 | 45 | options_label.append('%s: %s [%s]' % (split_info[1], split_info[3], data['sku'])) | ||
3746 | 46 | |||
3747 | 47 | result=[('notes', """".join(options_label).replace('""""', '\n').replace('""', ''))] | ||
3748 | 48 | ", | ||
3749 | 49 | mag_1420_erp_soline_pid,magento1420,sale.model_sale_order_line,product_id,,in_out,function,unicode,,"context['alternative_key'] = data['sku'] | ||
3750 | 50 | result=[('product_id',self.pool.get('product.product').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3751 | 51 | mag_1420_erp_soline_uomqty,magento1420,sale.model_sale_order_line,qty_ordered,,in_out,function,unicode,,"result=[('product_uom_qty',ifield)]", | ||
3752 | 52 | mag_1420_erp_soline_uosqty,magento1420,sale.model_sale_order_line,qty_ordered,,in,function,unicode,,"result=[('product_uos_qty',ifield)]", | ||
3753 | 53 | mag_1420_erp_soline_price,magento1420,sale.model_sale_order_line,price,,in,function,unicode,,"if context.get('price_is_tax_included', False): | ||
3754 | 54 | result=[('price_unit', (float(data['row_total']) + float(data['tax_amount']))/float(data['qty_ordered']))] | ||
3755 | 55 | else: | ||
3756 | 56 | result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]", | ||
3757 | 57 | mag_1420_erp_soline_disc,magento1420,sale.model_sale_order_line,discount_amount,,in,function,float,,"if ifield: | ||
3758 | 58 | result=[('discount', float(data['price']) != 0 and float(data['qty_ordered']) != 0 and float(100*ifield)/(float(data['price'])*float(data['qty_ordered'])) or 0)]", | ||
3759 | 59 | mag_1420_erp_procat_2,magento1420,product.model_product_category,level,,in,function,int,,"result=[('sequence',ifield),('level',ifield)]", | ||
3760 | 60 | mag_1420_erp_procat_3,magento1420,product.model_product_category,parent_id,,in_out,function,int,,"record_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', self._name), ('name', '=', self.prefixed_id(ifield))]) | ||
3761 | 61 | parent_id = False | ||
3762 | 62 | if record_id: | ||
3763 | 63 | parent_rec = self.pool.get('ir.model.data').read(cr,uid,record_id[0],[]) | ||
3764 | 64 | parent_id=parent_rec.get('res_id',False) | ||
3765 | 65 | result=[('magento_parent_id',ifield),('parent_id',parent_id)]","magento_parent_id = False | ||
3766 | 66 | if record.get('parent_id',False): | ||
3767 | 67 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
3768 | 68 | if not magento_parent_id: | ||
3769 | 69 | self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[external_referential_id],{},context=context) | ||
3770 | 70 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
3771 | 71 | if magento_parent_id: | ||
3772 | 72 | result = [('parent_id',magento_parent_id)]" | ||
3773 | 73 | mag_1420_erp_procat_4,magento1420,product.model_product_category,is_active,,in_out,function,unicode,,"result=[('is_active',ifield and (eval(ifield)) or False)]","result=[('is_active',record['is_active'])]" | ||
3774 | 74 | mag_1420_erp_procat_5,magento1420,product.model_product_category,description,,in_out,function,unicode,,"result=[('description',ifield)]","result=[('description',record['description'])]" | ||
3775 | 75 | mag_1420_erp_procat_6,magento1420,product.model_product_category,meta_title,,in_out,function,unicode,,"result=[('meta_title',ifield)]","result=[('meta_title',record['meta_title'])]" | ||
3776 | 76 | mag_1420_erp_procat_7,magento1420,product.model_product_category,meta_keywords,,in_out,function,unicode,,"result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]" | ||
3777 | 77 | mag_1420_erp_procat_8,magento1420,product.model_product_category,meta_description,,in_out,function,unicode,,"result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]" | ||
3778 | 78 | mag_1420_erp_procat_9,magento1420,product.model_product_category,url_key,,in_out,function,unicode,,"result=[('url_key',ifield)]","if context.get('export_url', False) : | ||
3779 | 79 | result=[('url_key',record['url_key'])]" | ||
3780 | 80 | mag_1420_erp_procat_10,magento1420,product.model_product_category,name,,in_out,function,unicode,,"result=[('name',ifield or 'UNDEFINED'),('magento_exportable',True)]","result=[('name',record['name'])]" | ||
3781 | 81 | mag_1420_erp_procat_11,magento1420,product.model_product_category,is_anchor,,in_out,function,unicode,,"result=[('is_anchor',ifield and bool(eval(ifield)) or False)]","result=[('is_anchor',record['is_anchor'])]" | ||
3782 | 82 | mag_1420_erp_procat_12,magento1420,product.model_product_category,available_sort_by,,in_out,function,list,,"attr_ids = [] | ||
3783 | 83 | cat_attr_obj = self.pool.get('magerp.product_category_attribute_options') | ||
3784 | 84 | if ifield: | ||
3785 | 85 | for val in ifield: | ||
3786 | 86 | attr_ids.append(cat_attr_obj.get_create_option_id(cr, uid, val,'sort_by', context=context)) | ||
3787 | 87 | result=[('available_sort_by', [(6, 0, attr_ids)]), ('use_default_available_sort_by', False)] | ||
3788 | 88 | else: | ||
3789 | 89 | result=[('use_default_available_sort_by', True)]","if record['use_default_available_sort_by']: | ||
3790 | 90 | res = u'' | ||
3791 | 91 | else: | ||
3792 | 92 | res = [] | ||
3793 | 93 | for cat_attr_option in self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, record['available_sort_by'], context=context): | ||
3794 | 94 | res.append(cat_attr_option.value) | ||
3795 | 95 | result=[('available_sort_by', res)]" | ||
3796 | 96 | mag_1420_erp_procat_13,magento1420,product.model_product_category,default_sort_by,,in_out,function,unicode,,"if ifield: | ||
3797 | 97 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'sort_by', context=context) | ||
3798 | 98 | else: | ||
3799 | 99 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','sort_by', context=context) | ||
3800 | 100 | result=[('default_sort_by',att_id)]","options_obj = self.pool.get('magerp.product_category_attribute_options') | ||
3801 | 101 | cat_attr_option_id = record['default_sort_by'] | ||
3802 | 102 | if cat_attr_option_id: | ||
3803 | 103 | cat_attr_option_id = cat_attr_option_id[0] | ||
3804 | 104 | else: | ||
3805 | 105 | cat_attr_option_id = options_obj._get_default_option(cr, uid, 'sort_by', '', context=context) | ||
3806 | 106 | |||
3807 | 107 | cat_attr_option = options_obj.browse(cr, uid, cat_attr_option_id, context=context) | ||
3808 | 108 | result=[('default_sort_by', cat_attr_option.value)]" | ||
3809 | 109 | mag_1420_erp_procat_14,magento1420,product.model_product_category,updated_at,,in,function,unicode,,"result=[('magerp_stamp',ifield)]", | ||
3810 | 110 | mag_1420_erp_procat_15,magento1420,product.model_product_category,image,,in_out,function,unicode,,"image_binary = False | ||
3811 | 111 | if ifield and not ifield=='None': | ||
3812 | 112 | try: | ||
3813 | 113 | image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) | ||
3814 | 114 | except Exception, e: | ||
3815 | 115 | print e | ||
3816 | 116 | pass | ||
3817 | 117 | if image_binary: | ||
3818 | 118 | image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) | ||
3819 | 119 | result=[('image_name',ifield),('image',image_binary)]","if record['image']: | ||
3820 | 120 | img = base64.decodestring(record['image']) | ||
3821 | 121 | img_bin_enc = base64.encodestring(img) | ||
3822 | 122 | conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc]) | ||
3823 | 123 | result = [('image',record['image_name'])] | ||
3824 | 124 | else: | ||
3825 | 125 | result=[]" | ||
3826 | 126 | mag_1420_erp_procat_16,magento1420,product.model_product_category,include_in_menu,,in_out,function,unicode,,"result=[('include_in_menu', ifield and (eval(ifield)) or False)]","result=[('include_in_menu',record['include_in_menu'])]" | ||
3827 | 127 | mag_1420_erp_procat_17,magento1420,product.model_product_category,page_layout,,in_out,function,unicode,,"if ifield: | ||
3828 | 128 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'page_layout', context=context) | ||
3829 | 129 | else: | ||
3830 | 130 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','page_layout', context=context) | ||
3831 | 131 | result=[('page_layout',att_id)]","page_layout = record['page_layout'] and record['page_layout'][1] or '' | ||
3832 | 132 | result=[('page_layout', page_layout)]" | ||
3833 | 133 | mag_1420_erp_attrgrp_2,magento1420,model_magerp_product_attribute_groups,attribute_set_id,,in_out,function,int,,"result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]" | ||
3834 | 134 | mag_1420_erp_attrgrp_3,magento1420,model_magerp_product_attribute_groups,attribute_group_name,,in_out,function,unicode,,"result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]" | ||
3835 | 135 | mag_1420_erp_attrgrp_4,magento1420,model_magerp_product_attribute_groups,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
3836 | 136 | mag_1420_erp_attrgrp_5,magento1420,model_magerp_product_attribute_groups,default_id,,in_out,function,int,,"result=[('default_id', ifield)]","result=[('default_id', record['default_id'])]" | ||
3837 | 137 | mag_1420_erp_attrset_1,magento1420,model_magerp_product_attribute_set,attribute_set_id,,in_out,function,int,,"result=[('magento_id', ifield)]","result=[('attribute_set_id', record['magento_id'])]" | ||
3838 | 138 | mag_1420_erp_attrset_2,magento1420,model_magerp_product_attribute_set,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
3839 | 139 | mag_1420_erp_attrset_3,magento1420,model_magerp_product_attribute_set,attribute_set_name,,in_out,function,unicode,,"result=[('attribute_set_name', ifield)]","result=[('attribute_set_name', record['attribute_set_name'])]" | ||
3840 | 140 | mag_1420_erp_attr_1,magento1420,model_magerp_product_attributes,attribute_code,,in_out,function,unicode,,"result=[('attribute_code', ifield)]","result=[('code', record['attribute_code'])]" | ||
3841 | 141 | mag_1420_erp_attr_2,magento1420,model_magerp_product_attributes,attribute_id,,in_out,function,int,,"result=[('magento_id', ifield)]", | ||
3842 | 142 | mag_1420_erp_attr_3,magento1420,model_magerp_product_attributes,frontend_input,,in_out,function,unicode,,"result=[('frontend_input', ifield)]","result=[('frontend_input', record['frontend_input'])]" | ||
3843 | 143 | mag_1420_erp_attr_4,magento1420,model_magerp_product_attributes,frontend_class,,in_out,function,unicode,,"result=[('frontend_class', ifield)]","result=[('frontend_class', record['frontend_class'])]" | ||
3844 | 144 | mag_1420_erp_attr_5,magento1420,model_magerp_product_attributes,backend_model,,in_out,function,unicode,,"result=[('backend_model', ifield)]","result=[('backend_model', record['backend_model'])]" | ||
3845 | 145 | mag_1420_erp_attr_6,magento1420,model_magerp_product_attributes,backend_type,,in_out,function,unicode,,"result=[('backend_type', ifield)]","result=[('backend_type', record['backend_type'])]" | ||
3846 | 146 | mag_1420_erp_attr_7,magento1420,model_magerp_product_attributes,frontend_label,,in_out,function,unicode,,"result=[('frontend_label', ifield)]","result=[('frontend_label', record['frontend_label'])]" | ||
3847 | 147 | mag_1420_erp_attr_8,magento1420,model_magerp_product_attributes,is_visible_in_advanced_search,,in_out,function,unicode,,"result=[('is_visible_in_advanced_search', bool(eval(ifield)))]","result=[('is_visible_in_advanced_search', record['is_visible_in_advanced_search'])]" | ||
3848 | 148 | mag_1420_erp_attr_9,magento1420,model_magerp_product_attributes,is_global,,in_out,function,unicode,,"result=[('is_global', bool(eval(ifield)))]","result=[('is_global', record['is_global'])]" | ||
3849 | 149 | mag_1420_erp_attr_10,magento1420,model_magerp_product_attributes,is_filterable,,in_out,function,unicode,,"result=[('is_filterable', bool(eval(ifield)))]","result=[('is_filterable', record['is_filterable'])]" | ||
3850 | 150 | mag_1420_erp_attr_11,magento1420,model_magerp_product_attributes,is_comparable,,in_out,function,unicode,,"result=[('is_comparable', bool(eval(ifield)))]","result=[('is_comparable', record['is_comparable'])]" | ||
3851 | 151 | mag_1420_erp_attr_12,magento1420,model_magerp_product_attributes,is_visible,,in_out,function,unicode,,"result=[('is_visible', bool(eval(ifield)))]","result=[('is_visible', record['is_visible'])]" | ||
3852 | 152 | mag_1420_erp_attr_13,magento1420,model_magerp_product_attributes,is_searchable,,in_out,function,unicode,,"result=[('is_searchable', bool(eval(ifield)))]","result=[('is_searchable', record['is_searchable'])]" | ||
3853 | 153 | mag_1420_erp_attr_14,magento1420,model_magerp_product_attributes,is_user_defined,,in_out,function,unicode,,"result=[('is_user_defined', bool(eval(ifield)))]","result=[('is_user_defined', record['is_user_defined'])]" | ||
3854 | 154 | mag_1420_erp_attr_15,magento1420,model_magerp_product_attributes,is_configurable,,in_out,function,unicode,,"result=[('is_configurable', bool(eval(ifield)))]","result=[('is_configurable', record['is_configurable'])]" | ||
3855 | 155 | mag_1420_erp_attr_16,magento1420,model_magerp_product_attributes,is_visible_on_front,,in_out,function,unicode,,"result=[('is_visible_on_front', bool(eval(ifield)))]","result=[('is_visible_on_front', record['is_visible_on_front'])]" | ||
3856 | 156 | mag_1420_erp_attr_17,magento1420,model_magerp_product_attributes,is_used_for_price_rules,,in_out,function,unicode,,"result=[('is_used_for_price_rules', bool(eval(ifield)))]","result=[('is_used_for_price_rules', record['is_used_for_price_rules'])]" | ||
3857 | 157 | mag_1420_erp_attr_18,magento1420,model_magerp_product_attributes,is_unique,,in_out,function,unicode,,"result=[('is_unique', bool(eval(ifield)))]","result=[('is_unique', record['is_unique'])]" | ||
3858 | 158 | mag_1420_erp_attr_19,magento1420,model_magerp_product_attributes,is_required,,in_out,function,unicode,,"result=[('is_required', bool(eval(ifield)))]","result=[('is_required', record['is_required'])]" | ||
3859 | 159 | mag_1420_erp_attr_20,magento1420,model_magerp_product_attributes,position,,in_out,function,int,,"result=[('position', ifield)]","result=[('position', record['position'])]" | ||
3860 | 160 | mag_1420_erp_attr_21,magento1420,model_magerp_product_attributes,attribute_set_info,,in_out,function,unicode,,"result=[('attribute_set_info', ifield)]","result=[('attribute_set_info', record['attribute_set_info'])]" | ||
3861 | 161 | mag_1420_erp_attr_22,magento1420,model_magerp_product_attributes,default_value,,in_out,function,unicode,,"result=[('default_value', ifield)]","result=[('default_value', record['default_value'])]" | ||
3862 | 162 | mag_1420_erp_attr_23,magento1420,model_magerp_product_attributes,note,,in_out,function,unicode,,"result=[('note', ifield)]","result=[('note', record['note'])]" | ||
3863 | 163 | mag_1420_erp_attr_24,magento1420,model_magerp_product_attributes,entity_type_id,,in_out,function,int,,"result=[('entity_type_id', ifield)]","result=[('entity_type_id', record['entity_type_id'])]" | ||
3864 | 164 | mag_1420_erp_attr_25,magento1420,model_magerp_product_attributes,apply_to,,in_out,function,unicode,,"result=[('apply_to', str(ifield))]","result=[('apply_to', eval(record['%s']))]" | ||
3865 | 165 | mag_1420_erp_prd_1,magento1420,product.model_product_product,url_key,,in_out,function,unicode,,"result=[('x_magerp_url_key',ifield)]","if context.get('export_url', False) : | ||
3866 | 166 | result=[('url_key',record['x_magerp_url_key'])]" | ||
3867 | 167 | mag_1420_erp_prd_2,magento1420,product.model_product_product,name,,in_out,function,unicode,,"result = [('name',ifield)]","result = [('name',record['name'])]" | ||
3868 | 168 | mag_1420_erp_prd_3,magento1420,product.model_product_product,description,,in_out,function,unicode,,"result = [('description',ifield)]", | ||
3869 | 169 | mag_1420_erp_prd_4,magento1420,product.model_product_product,short_description,,in_out,function,unicode,,"result = [('description_sale',ifield)]", | ||
3870 | 170 | mag_1420_erp_prd_5,magento1420,product.model_product_product,sku,,in_out,function,unicode,,"result = [('magento_sku',ifield), ('default_code',ifield)]", | ||
3871 | 171 | mag_1420_erp_prd_6,magento1420,product.model_product_product,weight,,in_out,function,float,,"result = [('weight',ifield)]","result = [('weight',record['weight'] or 0)]" | ||
3872 | 172 | mag_1420_erp_prd_7,magento1420,product.model_product_product,category_ids,,in_out,function,list,,"categ_ids =[] | ||
3873 | 173 | if ifield and len(ifield) > 0: | ||
3874 | 174 | for category_ids in ifield: | ||
3875 | 175 | categ_ids.append(self.pool.get('product.category').extid_to_oeid(cr, uid, category_ids, external_referential_id, context=context)) | ||
3876 | 176 | categ_id = categ_ids.pop() | ||
3877 | 177 | else: | ||
3878 | 178 | categ_id = self.pool.get('external.referential').browse(cr, uid, external_referential_id).default_pro_cat.id | ||
3879 | 179 | result = [('categ_id', categ_id), ('categ_ids',[(6, 0, categ_ids)])]"," | ||
3880 | 180 | cat_obj = self.pool.get('product.category') | ||
3881 | 181 | product = self.browse(cr, uid, record['id']) | ||
3882 | 182 | categ_ids = [categ.id for categ in ([product.categ_id] + product.categ_ids) if categ.magento_exportable] | ||
3883 | 183 | mag_categ_ids = [] | ||
3884 | 184 | for categ_id in categ_ids: | ||
3885 | 185 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
3886 | 186 | if not mag_categ_id: | ||
3887 | 187 | cat_obj.ext_export(cr, uid, [categ_id], [external_referential_id], context=context) | ||
3888 | 188 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
3889 | 189 | mag_categ_ids.append(mag_categ_id) | ||
3890 | 190 | result=[('category_ids', mag_categ_ids)]" | ||
3891 | 191 | mag_1420_erp_prd_8,magento1420,product.model_product_product,price,,in_out,function,float,,"result=[('list_price',ifield)]",result=[]#map later | ||
3892 | 192 | mag_1420_erp_prd_9,magento1420,product.model_product_product,cost,,in_out,function,float,,"result=[('standard_price',ifield)]","result = [('cost',record['standard_price'] or 0)]" | ||
3893 | 193 | mag_1420_erp_prd_10,magento1420,product.model_product_product,set,,in_out,function,unicode,,"result=[('set',self.pool.get('magerp.product_attribute_set').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
3894 | 194 | mag_1420_erp_prd_11,magento1420,product.model_product_product,special_price,,in_out,function,float,,"result = [('x_magerp_special_price',ifield)]", | ||
3895 | 195 | mag_1420_erp_prd_12,magento1420,product.model_product_product,tier_price,,in_out,function,unicode,,result=[]#no mapping by default,result=[]#no mapping by default | ||
3896 | 196 | mag_1420_erp_prd_13,magento1420,product.model_product_product,minimal_price,,in_out,function,float,,"result = [('x_magerp_minimal_price',ifield)]"," | ||
3897 | 197 | if record['x_magerp_minimal_price'] and record['x_magerp_minimal_price'] != 0: | ||
3898 | 198 | result = [('minimal_price',record['x_magerp_minimal_price'])] | ||
3899 | 199 | else: | ||
3900 | 200 | result = [('minimal_price',False)]" | ||
3901 | 201 | mag_1420_erp_prd_14,magento1420,product.model_product_product,type_id,,in_out,function,unicode,,"if ifield: | ||
3902 | 202 | product_type_ids = self.pool.get('magerp.product_product_type').search(cr,uid,[('product_type','=',ifield)]) | ||
3903 | 203 | if product_type_ids: | ||
3904 | 204 | result = [('product_type',ifield)]","if 'product_type' in record and record['product_type']: | ||
3905 | 205 | result = [('type_id',record['product_type'])] | ||
3906 | 206 | else: | ||
3907 | 207 | result = [('type_id','simple')]" | ||
3908 | 208 | mag_1420_erp_prd_15,magento1420,product.model_product_product,websites,,in_out,function,list,,"websites_ids = [] | ||
3909 | 209 | for ext_id in ifield: | ||
3910 | 210 | websites_ids.append(self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ext_id, external_referential_id, context=context)) | ||
3911 | 211 | |||
3912 | 212 | ##### OPTION START, with this if the field websites of the product is empty the product is exported on every website | ||
3913 | 213 | all_oe_websites_ids = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', external_referential_id)]) | ||
3914 | 214 | if set(websites_ids) == set(all_oe_websites_ids): | ||
3915 | 215 | websites_ids =[] | ||
3916 | 216 | ##### OPTION END | ||
3917 | 217 | |||
3918 | 218 | result=[('websites_ids', [(6,0, websites_ids)])]","##### OPTION START, with this if the field websites of the product is empty the product is exported on every website | ||
3919 | 219 | if not record['websites_ids']: | ||
3920 | 220 | record['websites_ids'] = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', external_referential_id)]) | ||
3921 | 221 | ##### OPTION END | ||
3922 | 222 | |||
3923 | 223 | ext_websites_ids = [] | ||
3924 | 224 | for oe_id in record['websites_ids']: | ||
3925 | 225 | ext_websites_ids.append(self.pool.get('external.shop.group').oeid_to_extid(cr, uid, oe_id, external_referential_id)) | ||
3926 | 226 | |||
3927 | 227 | result=[('websites', ext_websites_ids)]" | ||
3928 | 228 | mag_1420_erp_prd_16,magento1420,product.model_product_product,has_options,,in,function,unicode,,"result =[('x_magerp_has_options',ifield)]", | ||
3929 | 229 | magento_1420_cst_grp_1,magento1420,base.model_res_partner_category,customer_group_code,,in,function,unicode,,"result=[('name',ifield)]", | ||
3930 | 230 | magento_1420_cst_grp_3,magento1420,base.model_res_partner_category,tax_class_id,,in,function,int,,"result=[('tax_class_id',ifield)]", | ||
3931 | 231 | magento_1420_prt_adr_2,magento1420,base.model_res_partner_address,city,,in_out,function,unicode,,"result=[('city',ifield)]", | ||
3932 | 232 | magento_1420_prt_adr_3,magento1420,base.model_res_partner_address,fax,,in_out,function,unicode,,"result=[('fax',ifield)]", | ||
3933 | 233 | magento_1420_prt_adr_4,magento1420,base.model_res_partner_address,firstname,,in_out,function,unicode,,"name = ' '.join([ f for f in (data['firstname'], data['lastname']) if f]) | ||
3934 | 234 | if data.get('company'): | ||
3935 | 235 | name = ""%s ; %s"" % (data['company'], name) | ||
3936 | 236 | result = [('name', name), ('firstname', ifield), ('lastname', data['lastname'])]", | ||
3937 | 237 | magento_1420_prt_adr_6,magento1420,base.model_res_partner_address,is_active,,in_out,function,unicode,,"result=[('active',bool(eval(ifield)))]", | ||
3938 | 238 | magento_1420_prt_adr_7,magento1420,base.model_res_partner_address,country_id,,in_out,function,unicode,,"result = self.pool.get('res.country').search(cr,uid,[('code','=',ifield)]) | ||
3939 | 239 | if result and len(result)==1: | ||
3940 | 240 | result=[('country_id',result[0])] | ||
3941 | 241 | else: | ||
3942 | 242 | result=[] | ||
3943 | 243 | ", | ||
3944 | 244 | magento_1420_prt_adr_8,magento1420,base.model_res_partner_address,street,,in_out,function,unicode,,"if ifield: | ||
3945 | 245 | if len(ifield.split('\n')) ==2 : | ||
3946 | 246 | result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] | ||
3947 | 247 | else : | ||
3948 | 248 | result = [('street',ifield.replace('\\n',','))] | ||
3949 | 249 | else: | ||
3950 | 250 | result = []", | ||
3951 | 251 | magento_1420_prt_adr_9,magento1420,base.model_res_partner_address,postcode,,in_out,function,unicode,,"result=[('zip',ifield)]", | ||
3952 | 252 | magento_1420_prt_adr_10,magento1420,base.model_res_partner_address,telephone,,in_out,function,unicode,,"result=[('phone',ifield)]", | ||
3953 | 253 | magento_1420_prt_adr_11,magento1420,base.model_res_partner_address,region,,in_out,function,unicode,,"if ifield: | ||
3954 | 254 | result = self.pool.get('res.country.state').search(cr,uid,[('name','=ilike',ifield)]) | ||
3955 | 255 | if result and len(result)==1: | ||
3956 | 256 | result = [('state_id',result[0])] | ||
3957 | 257 | else: | ||
3958 | 258 | result=[] | ||
3959 | 259 | else: | ||
3960 | 260 | result=[]", | ||
3961 | 261 | magento_1420_prt_adr_13,magento1420,base.model_res_partner_address,customer_id,,in_out,function,int,,"result=self.pool.get('res.partner').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3962 | 262 | if result: | ||
3963 | 263 | result=[('partner_id',result)] | ||
3964 | 264 | else: | ||
3965 | 265 | result=[('partner_id',False)]", | ||
3966 | 266 | magento_1420_prt_adr_14,magento1420,base.model_res_partner_address,address_type,,in_out,function,unicode,,"if ifield=='billing': | ||
3967 | 267 | result=[('type','invoice')] | ||
3968 | 268 | elif ifield=='shipping': | ||
3969 | 269 | result=[('type','delivery')] | ||
3970 | 270 | else: | ||
3971 | 271 | result=[]", | ||
3972 | 272 | magento_1420_prt_adr_15,magento1420,base.model_res_partner_address,email,,in_out,function,unicode,,"result = [('email', False)] | ||
3973 | 273 | if ifield: | ||
3974 | 274 | result = [('email', ifield)] | ||
3975 | 275 | else: | ||
3976 | 276 | partner_obj = self.pool.get('res.partner') | ||
3977 | 277 | partner_id = partner_obj.extid_to_existing_oeid(cr, uid, data['customer_id'] ,external_referential_id) | ||
3978 | 278 | if partner_id: | ||
3979 | 279 | result = [('email', partner_obj.browse(cr, uid, partner_id).emailid)]", | ||
3980 | 280 | magento_1420_prt_adr_17,magento1420,base.model_res_partner_address,default_billing,,in_out,function,unicode,,"result = [('type', 'other')] | ||
3981 | 281 | if data.get('default_billing') and data.get('default_shipping'): | ||
3982 | 282 | result = [('type', 'default')] | ||
3983 | 283 | elif data.get('default_billing'): | ||
3984 | 284 | result = [('type', 'invoice')] | ||
3985 | 285 | elif data.get('default_shipping'): | ||
3986 | 286 | result = [('type', 'delivery')]", | ||
3987 | 287 | magento_1420_prt_2,magento1420,base.model_res_partner,group_id,,in_out,function,int,,"if ifield: | ||
3988 | 288 | result=self.pool.get('res.partner.category').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3989 | 289 | if result: | ||
3990 | 290 | result=[('group_id',result)]", | ||
3991 | 291 | magento_1420_prt_3,magento1420,base.model_res_partner,store_id,,in_out,function,int,,"if ifield: | ||
3992 | 292 | result=self.pool.get('magerp.storeviews').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
3993 | 293 | if result: | ||
3994 | 294 | store = self.pool.get('magerp.storeviews').browse(cr, uid, result) | ||
3995 | 295 | lang = store.lang_id | ||
3996 | 296 | result=[('store_id',result),('lang',lang and lang.code or False)] | ||
3997 | 297 | if not data.get('website_id'): | ||
3998 | 298 | result.append(('website_id', store.website_id.id))", | ||
3999 | 299 | magento_1420_prt_4,magento1420,base.model_res_partner,website_id,,in_out,function,int,,"if ifield: | ||
4000 | 300 | result=self.pool.get('external.shop.group').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
4001 | 301 | if result: | ||
4002 | 302 | result=[('website_id',result)]", | ||
4003 | 303 | magento_1420_prt_5,magento1420,base.model_res_partner,created_in,,in_out,function,unicode,,"result=[('created_in',ifield)]", | ||
4004 | 304 | magento_1420_prt_6,magento1420,base.model_res_partner,created_at,,in_out,function,unicode,,"result=[('created_at',ifield)]", | ||
4005 | 305 | magento_1420_prt_7,magento1420,base.model_res_partner,updated_at,,in_out,function,unicode,,"result=[('updated_at',ifield)]", | ||
4006 | 306 | magento_1420_prt_8,magento1420,base.model_res_partner,firstname,,in_out,function,unicode,,"result = [('name', ifield + ' ' + data['lastname'])]","add_id = self.browse(cr, uid, record['id']) | ||
4007 | 307 | fn = add_id.address[0].firstname | ||
4008 | 308 | ln = add_id.address[0].lastname | ||
4009 | 309 | result=[('firstname', fn), ('lastname', ln)]" | ||
4010 | 310 | magento_1420_prt_10,magento1420,base.model_res_partner,email,,in_out,function,unicode,,"result=[('emailid',ifield)]", | ||
4011 | 311 | magento_1420_prt_11,magento1420,base.model_res_partner,taxvat,,in_out,function,unicode,,"if ifield: | ||
4012 | 312 | result=[('mag_vat',ifield)] | ||
4013 | 313 | else: | ||
4014 | 314 | result=[]", | ||
4015 | 315 | magento_1420_prt_12,magento1420,base.model_res_partner,dob,,in_out,function,unicode,,"if ifield: | ||
4016 | 316 | result =[('mag_birthday',ifield[:10])] | ||
4017 | 317 | else: | ||
4018 | 318 | result=[]", | ||
4019 | 0 | 319 | ||
4020 | === added file 'magentoerpconnect/settings/1.4.2.0/external.referential.type.csv' | |||
4021 | --- magentoerpconnect/settings/1.4.2.0/external.referential.type.csv 1970-01-01 00:00:00 +0000 | |||
4022 | +++ magentoerpconnect/settings/1.4.2.0/external.referential.type.csv 2012-07-06 14:53:18 +0000 | |||
4023 | @@ -0,0 +1,2 @@ | |||
4024 | 1 | "id","name" | ||
4025 | 2 | "magento1420","Magento Version 1.4.2.0+" | ||
4026 | 0 | 3 | ||
4027 | === modified file 'magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv' | |||
4028 | --- magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv 2012-05-19 11:35:11 +0000 | |||
4029 | +++ magentoerpconnect/settings/1.5.0.0/external.mapping.template.csv 2012-07-06 14:53:18 +0000 | |||
4030 | @@ -1,3 +1,4 @@ | |||
4031 | 1 | <<<<<<< TREE | ||
4032 | 1 | id,extra_name,version_id:id,model_id:id,external_list_method,external_get_method,external_update_method,external_create_method,external_delete_method,external_search_method,external_done_method,key_for_external_id,external_resource_name | 2 | id,extra_name,version_id:id,model_id:id,external_list_method,external_get_method,external_update_method,external_create_method,external_delete_method,external_search_method,external_done_method,key_for_external_id,external_resource_name |
4033 | 2 | mag1500_external_shop_group,,magentoerpconnect.magento1500,base_sale_multichannels.model_external_shop_group,ol_websites.list,,,,,,,website_id, | 3 | mag1500_external_shop_group,,magentoerpconnect.magento1500,base_sale_multichannels.model_external_shop_group,ol_websites.list,,,,,,,website_id, |
4034 | 3 | mag1500_magerp_storeviews,,magentoerpconnect.magento1500,magentoerpconnect.model_magerp_storeviews,ol_storeviews.list,,,,,,,store_id, | 4 | mag1500_magerp_storeviews,,magentoerpconnect.magento1500,magentoerpconnect.model_magerp_storeviews,ol_storeviews.list,,,,,,,store_id, |
4035 | @@ -14,3 +15,19 @@ | |||
4036 | 14 | mag1500_sale_order,,magentoerpconnect.magento1500,base_sale_multichannels.model_sale_order,sales_order.list,sales_order.info,,,,sales_order.search,sales_order.done,increment_id, | 15 | mag1500_sale_order,,magentoerpconnect.magento1500,base_sale_multichannels.model_sale_order,sales_order.list,sales_order.info,,,,sales_order.search,sales_order.done,increment_id, |
4037 | 15 | mag1500_account_invoice,,magentoerpconnect.magento1500,account.model_account_invoice,,,,,,,,, | 16 | mag1500_account_invoice,,magentoerpconnect.magento1500,account.model_account_invoice,,,,,,,,, |
4038 | 16 | mag1500_product_link,,magentoerpconnect.magento1500,magentoerpconnect.model_product_link,,,,,,,,, | 17 | mag1500_product_link,,magentoerpconnect.magento1500,magentoerpconnect.model_product_link,,,,,,,,, |
4039 | 18 | ======= | ||
4040 | 19 | "id","type_id:id","model_id:id","external_list_method","external_get_method","external_update_method","external_create_method","external_delete_method","external_key_name" | ||
4041 | 20 | "magento_1500_website","magento1500","base_sale_multichannels.model_external_shop_group","ol_websites.list",,,,,"website_id" | ||
4042 | 21 | "magento_1500_storeview","magento1500","model_magerp_storeviews","ol_storeviews.list",,,,,"store_id" | ||
4043 | 22 | "magento_1500_store","magento1500","sale.model_sale_shop","ol_groups.list",,,,,"group_id" | ||
4044 | 23 | "magento_1500_order","magento1500","sale.model_sale_order","sales_order.list","sales_order.info",,,,"increment_id" | ||
4045 | 24 | "magento_1500_order_line","magento1500","sale.model_sale_order_line",,,,,,"item_id" | ||
4046 | 25 | "magento_1500_pro_cat","magento1500","product.model_product_category","category.list","category.info","catalog_category.update","catalog_category.create",,"category_id" | ||
4047 | 26 | "magento_1500_attr_grp","magento1500","model_magerp_product_attribute_groups","ol_catalog_product_attribute_group.list","ol_catalog_product_attribute_group.list",,,,"attribute_group_id" | ||
4048 | 27 | "magento_1500_attr_set","magento1500","model_magerp_product_attribute_set","ol_catalog_product_attributeset.list",,,,,"attribute_set_id" | ||
4049 | 28 | "magento_1500_attr","magento1500","model_magerp_product_attributes","ol_catalog_product_attribute.list",,,,,"attribute_id" | ||
4050 | 29 | "magento_1500_prd","magento1500","product.model_product_product","catalog_product.list","catalog_product.info","ol_catalog_product.update","ol_catalog_product.create",,"product_id" | ||
4051 | 30 | "magento_1500_cst_grp","magento1500","base.model_res_partner_category","ol_customer_groups.list",,,,,"customer_group_id" | ||
4052 | 31 | "magento_1500_prt_adr","magento1500","base.model_res_partner_address","ol_customer_address.list","ol_customer_address.info",,,,"entity_id" | ||
4053 | 32 | "magento_1500_prt","magento1500","base.model_res_partner","customer.list","customer.info","customer.update",,,"customer_id" | ||
4054 | 33 | >>>>>>> MERGE-SOURCE | ||
4055 | 17 | 34 | ||
4056 | === added file 'magentoerpconnect/settings/1.5.0.0/external.mappinglines.template.csv.OTHER' | |||
4057 | --- magentoerpconnect/settings/1.5.0.0/external.mappinglines.template.csv.OTHER 1970-01-01 00:00:00 +0000 | |||
4058 | +++ magentoerpconnect/settings/1.5.0.0/external.mappinglines.template.csv.OTHER 2012-07-06 14:53:18 +0000 | |||
4059 | @@ -0,0 +1,330 @@ | |||
4060 | 1 | id,type_id:id,model_id:id,external_field,field_id:id,type,evaluation_type,external_type,child_mapping_id:id,in_function,out_function | ||
4061 | 2 | mag_1500_erp_s_name,magento1500,base_sale_multichannels.model_external_shop_group,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
4062 | 3 | mag_1500_erp_s_code,magento1500,base_sale_multichannels.model_external_shop_group,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
4063 | 4 | mag_1500_erp_s_web,magento1500,base_sale_multichannels.model_external_shop_group,website_id,,in_out,function,int,,"result=[('website_id',ifield)]", | ||
4064 | 5 | mag_1500_erp_s_isa,magento1500,base_sale_multichannels.model_external_shop_group,is_default,,in_out,function,unicode,,"result=[('is_default',bool(eval(ifield)))]", | ||
4065 | 6 | mag_1500_erp_s_stord,magento1500,base_sale_multichannels.model_external_shop_group,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
4066 | 7 | mag_1500_erp_s_gpid,magento1500,base_sale_multichannels.model_external_shop_group,default_group_id,,in_out,function,int,,"result=[('default_shop_integer_id',ifield)]", | ||
4067 | 8 | mag_1500_erp_sv_name,magento1500,model_magerp_storeviews,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
4068 | 9 | mag_1500_erp_sv_code,magento1500,model_magerp_storeviews,code,,in_out,function,unicode,,"result=[('code',ifield)]", | ||
4069 | 10 | mag_1500_erp_sv_sg,magento1500,model_magerp_storeviews,website_id,,in_out,function,int,,"result=[('website_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
4070 | 11 | mag_1500_erp_sv_isa,magento1500,model_magerp_storeviews,is_active,,in_out,function,unicode,,"result=[('is_active',bool(eval(ifield)))]", | ||
4071 | 12 | mag_1500_erp_sv_stord,magento1500,model_magerp_storeviews,sort_order,,in_out,function,int,,"result=[('sort_order',ifield)]", | ||
4072 | 13 | mag_1500_erp_sv_gpid,magento1500,model_magerp_storeviews,group_id,,in_out,function,int,,"result=[('shop_id',self.pool.get('sale.shop').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
4073 | 14 | mag_1500_erp_st_name,magento1500,sale.model_sale_shop,name,,in_out,function,unicode,,"result=[('name',ifield)]","result=[('name',record['name'])]" | ||
4074 | 15 | mag_1500_erp_st_gpid,magento1500,sale.model_sale_shop,group_id,,in_out,function,int,,"result=[('group_id',ifield)]", | ||
4075 | 16 | mag_1500_erp_st_grp,magento1500,sale.model_sale_shop,website_id,,in_out,function,int,,"result=[('shop_group_id',self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
4076 | 17 | mag_1500_erp_st_default_st,magento1500,sale.model_sale_shop,default_store_id,,in_out,function,int,,"result=[('default_storeview_integer_id',ifield)]", | ||
4077 | 18 | mag_1500_erp_st_root_categ,magento1500,sale.model_sale_shop,root_category_id,,in_out,function,int,,"result=[('root_category_id',ifield)]", | ||
4078 | 19 | mag_1500_erp_so_name,magento1500,sale.model_sale_order,increment_id,,in_out,function,unicode,,"result=[('magento_incrementid',str(ifield)), ('name','mag_' + str(ifield))]", | ||
4079 | 20 | mag_1500_erp_so_total_amount,magento1500,sale.model_sale_order,grand_total,,in_out,function,float,,"result=[('ext_total_amount',str(ifield))]", | ||
4080 | 21 | mag_1500_erp_so_carrier_id,magento1500,sale.model_sale_order,shipping_method,,in_out,function,unicode,,"if ifield: | ||
4081 | 22 | carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [('magento_code', '=', ifield)]) | ||
4082 | 23 | if carrier_ids: | ||
4083 | 24 | result=[('carrier_id', carrier_ids[0])] | ||
4084 | 25 | else: | ||
4085 | 26 | fake_partner_id = self.pool.get('res.partner').search(cr, uid, [])[0] | ||
4086 | 27 | model_data_obj = self.pool.get('ir.model.data') | ||
4087 | 28 | model, product_id = model_data_obj.get_object_reference(cr, uid, 'base_sale_multichannels', 'product_product_shipping') | ||
4088 | 29 | carrier_id = self.pool.get('delivery.carrier').create(cr, uid, {'partner_id' : fake_partner_id, 'product_id' : product_id, 'name' : ifield, 'magento_code' : ifield}) | ||
4089 | 30 | result=[('carrier_id', carrier_id)]", | ||
4090 | 31 | mag_1500_erp_so_pay,magento1500,sale.model_sale_order,payment,,in_out,function,unicode,," | ||
4091 | 32 | payments_mapping = {'checkmo': 'manual', 'ccsave': 'prepaid', 'free':'prepaid','googlecheckout':'prepaid','paypayl_express':'prepaid', 'paybox_system': 'prepaid', 'paypal_standard': 'prepaid', 'cashondelivery': 'manual', 'servired_standard': 'prepaid', 'bbva': 'prepaid', 'cofidis': 'prepaid'} | ||
4092 | 33 | ifield=eval(ifield) | ||
4093 | 34 | result=[('order_policy', ifield['method'] in payments_mapping and payments_mapping[ifield['method']] or 'prepaid'), ('ext_payment_method', ifield['method'])]", | ||
4094 | 35 | |||
4095 | 36 | mag_1500_erp_so_item,magento1500,sale.model_sale_order,items,sale.field_sale_order_order_line,in,sub-mapping,dict,magento_1500_order_line,, | ||
4096 | 37 | "mag_1500_erp_soline_name","magento1500","sale.model_sale_order_line","name",,"in_out","function","unicode",,"result=[('name', ifield)] | ||
4097 | 38 | ", | ||
4098 | 39 | "Mag_1500_erp_soline_note","magento1500","sale.model_sale_order_line","product_options",,"in","function","unicode",,"if ifield: | ||
4099 | 40 | import re | ||
4100 | 41 | options_label = [] | ||
4101 | 42 | clean = re.sub('\w:\w:|\w:\w+;', '', ifield) | ||
4102 | 43 | for each in clean.split('{'): | ||
4103 | 44 | if each.startswith('""label""'): | ||
4104 | 45 | split_info = each.split(';') | ||
4105 | 46 | options_label.append('%s: %s [%s]' % (split_info[1], split_info[3], data['sku'])) | ||
4106 | 47 | |||
4107 | 48 | result=[('notes', """".join(options_label).replace('""""', '\n').replace('""', ''))] | ||
4108 | 49 | ", | ||
4109 | 50 | mag_1500_erp_soline_pid,magento1500,sale.model_sale_order_line,product_id,,in_out,function,unicode,,"context['alternative_key'] = data['sku'] | ||
4110 | 51 | result=[('product_id',self.pool.get('product.product').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
4111 | 52 | mag_1500_erp_soline_uomqty,magento1500,sale.model_sale_order_line,qty_ordered,,in_out,function,unicode,,"result=[('product_uom_qty',ifield)]", | ||
4112 | 53 | mag_1500_erp_soline_uosqty,magento1500,sale.model_sale_order_line,qty_ordered,,in,function,unicode,,"result=[('product_uos_qty',ifield)]", | ||
4113 | 54 | mag_1500_erp_soline_price,magento1500,sale.model_sale_order_line,price,,in,function,unicode,,"if context.get('price_is_tax_included', False): | ||
4114 | 55 | result=[('price_unit', (float(data['row_total']) + float(data['tax_amount']))/float(data['qty_ordered']))] | ||
4115 | 56 | else: | ||
4116 | 57 | result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]", | ||
4117 | 58 | mag_1500_erp_soline_disc,magento1500,sale.model_sale_order_line,discount_amount,,in,function,float,,"if ifield: | ||
4118 | 59 | result=[('discount', float(data['price']) != 0 and float(data['qty_ordered']) != 0 and float(100*ifield)/(float(data['price'])*float(data['qty_ordered'])) or 0)]", | ||
4119 | 60 | mag_1500_erp_procat_2,magento1500,product.model_product_category,level,,in,function,int,,"result=[('sequence',ifield),('level',ifield)]", | ||
4120 | 61 | mag_1500_erp_procat_3,magento1500,product.model_product_category,parent_id,,in_out,function,int,,"record_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', self._name), ('name', '=', self.prefixed_id(ifield))]) | ||
4121 | 62 | parent_id = False | ||
4122 | 63 | if record_id: | ||
4123 | 64 | parent_rec = self.pool.get('ir.model.data').read(cr,uid,record_id[0],[]) | ||
4124 | 65 | parent_id=parent_rec.get('res_id',False) | ||
4125 | 66 | result=[('magento_parent_id',ifield),('parent_id',parent_id)]","magento_parent_id = False | ||
4126 | 67 | if record.get('parent_id',False): | ||
4127 | 68 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
4128 | 69 | if not magento_parent_id: | ||
4129 | 70 | self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[external_referential_id],{},context=context) | ||
4130 | 71 | magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], external_referential_id) | ||
4131 | 72 | if magento_parent_id: | ||
4132 | 73 | result = [('parent_id',magento_parent_id)]" | ||
4133 | 74 | mag_1500_erp_procat_4,magento1500,product.model_product_category,is_active,,in_out,function,unicode,,"result=[('is_active',ifield and (eval(ifield)) or False)]","result=[('is_active',record['is_active'])]" | ||
4134 | 75 | mag_1500_erp_procat_5,magento1500,product.model_product_category,description,,in_out,function,unicode,,"result=[('description',ifield)]","result=[('description',record['description'])]" | ||
4135 | 76 | mag_1500_erp_procat_6,magento1500,product.model_product_category,meta_title,,in_out,function,unicode,,"result=[('meta_title',ifield)]","result=[('meta_title',record['meta_title'])]" | ||
4136 | 77 | mag_1500_erp_procat_7,magento1500,product.model_product_category,meta_keywords,,in_out,function,unicode,,"result=[('meta_keywords',ifield)]","result=[('meta_keywords',record['meta_keywords'])]" | ||
4137 | 78 | mag_1500_erp_procat_8,magento1500,product.model_product_category,meta_description,,in_out,function,unicode,,"result=[('meta_description',ifield)]","result=[('meta_description',record['meta_description'])]" | ||
4138 | 79 | mag_1500_erp_procat_9,magento1500,product.model_product_category,url_key,,in_out,function,unicode,,"result=[('url_key',ifield)]","if context.get('export_url', False) : | ||
4139 | 80 | result=[('url_key',record['url_key'])]" | ||
4140 | 81 | mag_1500_erp_procat_10,magento1500,product.model_product_category,name,,in_out,function,unicode,,"result=[('name',ifield or 'UNDEFINED'),('magento_exportable',True)]","result=[('name',record['name'])]" | ||
4141 | 82 | mag_1500_erp_procat_11,magento1500,product.model_product_category,is_anchor,,in_out,function,unicode,,"result=[('is_anchor',ifield and bool(eval(ifield)) or False)]","result=[('is_anchor',record['is_anchor'])]" | ||
4142 | 83 | mag_1500_erp_procat_12,magento1500,product.model_product_category,available_sort_by,,in_out,function,unicode,,"attr_ids = [] | ||
4143 | 84 | cat_attr_obj = self.pool.get('magerp.product_category_attribute_options') | ||
4144 | 85 | if ifield: | ||
4145 | 86 | for val in ifield: | ||
4146 | 87 | attr_ids.append(cat_attr_obj.get_create_option_id(cr, uid, val,'sort_by', context=context)) | ||
4147 | 88 | result=[('available_sort_by', [(6, 0, attr_ids)]), ('use_default_available_sort_by', False)] | ||
4148 | 89 | else: | ||
4149 | 90 | result=[('use_default_available_sort_by', True)]","if record['use_default_available_sort_by']: | ||
4150 | 91 | res = u'' | ||
4151 | 92 | else: | ||
4152 | 93 | res = [] | ||
4153 | 94 | for cat_attr_option in self.pool.get('magerp.product_category_attribute_options').browse(cr, uid, record['available_sort_by'], context=context): | ||
4154 | 95 | res.append(cat_attr_option.value) | ||
4155 | 96 | result=[('available_sort_by', res)]" | ||
4156 | 97 | mag_1500_erp_procat_13,magento1500,product.model_product_category,default_sort_by,,in_out,function,unicode,,"if ifield: | ||
4157 | 98 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'sort_by', context=context) | ||
4158 | 99 | else: | ||
4159 | 100 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','sort_by', context=context) | ||
4160 | 101 | result=[('default_sort_by',att_id)]","options_obj = self.pool.get('magerp.product_category_attribute_options') | ||
4161 | 102 | cat_attr_option_id = record['default_sort_by'] | ||
4162 | 103 | if cat_attr_option_id: | ||
4163 | 104 | cat_attr_option_id = cat_attr_option_id[0] | ||
4164 | 105 | else: | ||
4165 | 106 | cat_attr_option_id = options_obj._get_default_option(cr, uid, 'sort_by', '', context=context)[0] | ||
4166 | 107 | |||
4167 | 108 | cat_attr_option = options_obj.browse(cr, uid, cat_attr_option_id, context=context) | ||
4168 | 109 | result=[('default_sort_by', cat_attr_option.value)]" | ||
4169 | 110 | mag_1500_erp_procat_14,magento1500,product.model_product_category,updated_at,,in,function,unicode,,"result=[('magerp_stamp',ifield)]", | ||
4170 | 111 | mag_1500_erp_procat_15,magento1500,product.model_product_category,image,,in_out,function,unicode,,"image_binary = False | ||
4171 | 112 | if ifield and not ifield=='None': | ||
4172 | 113 | try: | ||
4173 | 114 | image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) | ||
4174 | 115 | except Exception, e: | ||
4175 | 116 | print e | ||
4176 | 117 | pass | ||
4177 | 118 | if image_binary: | ||
4178 | 119 | image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) | ||
4179 | 120 | result=[('image_name',ifield),('image',image_binary)]","if record['image']: | ||
4180 | 121 | img = base64.decodestring(record['image']) | ||
4181 | 122 | img_bin_enc = base64.encodestring(img) | ||
4182 | 123 | conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc]) | ||
4183 | 124 | result = [('image',record['image_name'])] | ||
4184 | 125 | else: | ||
4185 | 126 | result=[]" | ||
4186 | 127 | mag_1500_erp_procat_16,magento1500,product.model_product_category,include_in_menu,,in_out,function,unicode,,"result=[('include_in_menu', ifield and (eval(ifield)) or False)]","result=[('include_in_menu',record['include_in_menu'])]" | ||
4187 | 128 | mag_1500_erp_procat_17,magento1500,product.model_product_category,page_layout,,in_out,function,unicode,,"if ifield: | ||
4188 | 129 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'page_layout', context=context) | ||
4189 | 130 | else: | ||
4190 | 131 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, '','page_layout', context=context) | ||
4191 | 132 | result=[('page_layout',att_id)]","page_layout = record['page_layout'] and record['page_layout'][1] or '' | ||
4192 | 133 | result=[('page_layout', page_layout)]" | ||
4193 | 134 | mag_1500_erp_attrgrp_2,magento1500,model_magerp_product_attribute_groups,attribute_set_id,,in_out,function,int,,"result=[('attribute_set_id', ifield)]","result=[('attribute_set_id', record['attribute_set_id'])]" | ||
4194 | 135 | mag_1500_erp_attrgrp_3,magento1500,model_magerp_product_attribute_groups,attribute_group_name,,in_out,function,unicode,,"result=[('attribute_group_name', ifield)]","result=[('attribute_group_name', record['attribute_group_name'])]" | ||
4195 | 136 | mag_1500_erp_attrgrp_4,magento1500,model_magerp_product_attribute_groups,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
4196 | 137 | mag_1500_erp_attrgrp_5,magento1500,model_magerp_product_attribute_groups,default_id,,in_out,function,int,,"result=[('default_id', ifield)]","result=[('default_id', record['default_id'])]" | ||
4197 | 138 | mag_1500_erp_attrset_1,magento1500,model_magerp_product_attribute_set,attribute_set_id,,in_out,function,int,,"result=[('magento_id', ifield)]","result=[('attribute_set_id', record['magento_id'])]" | ||
4198 | 139 | mag_1500_erp_attrset_2,magento1500,model_magerp_product_attribute_set,sort_order,,in_out,function,int,,"result=[('sort_order', ifield)]","result=[('sort_order', record['sort_order'])]" | ||
4199 | 140 | mag_1500_erp_attrset_3,magento1500,model_magerp_product_attribute_set,attribute_set_name,,in_out,function,unicode,,"result=[('attribute_set_name', ifield)]","result=[('attribute_set_name', record['attribute_set_name'])]" | ||
4200 | 141 | mag_1500_erp_attr_1,magento1500,model_magerp_product_attributes,attribute_code,,in_out,function,unicode,,"result=[('attribute_code', ifield)]","result=[('code', record['attribute_code'])]" | ||
4201 | 142 | mag_1500_erp_attr_2,magento1500,model_magerp_product_attributes,attribute_id,,in_out,function,int,,"result=[('magento_id', ifield)]", | ||
4202 | 143 | mag_1500_erp_attr_3,magento1500,model_magerp_product_attributes,frontend_input,,in_out,function,unicode,,"result=[('frontend_input', ifield)]","result=[('frontend_input', record['frontend_input'])]" | ||
4203 | 144 | mag_1500_erp_attr_4,magento1500,model_magerp_product_attributes,frontend_class,,in_out,function,unicode,,"result=[('frontend_class', ifield)]","result=[('frontend_class', record['frontend_class'])]" | ||
4204 | 145 | mag_1500_erp_attr_5,magento1500,model_magerp_product_attributes,backend_model,,in_out,function,unicode,,"result=[('backend_model', ifield)]","result=[('backend_model', record['backend_model'])]" | ||
4205 | 146 | mag_1500_erp_attr_6,magento1500,model_magerp_product_attributes,backend_type,,in_out,function,unicode,,"result=[('backend_type', ifield)]","result=[('backend_type', record['backend_type'])]" | ||
4206 | 147 | mag_1500_erp_attr_7,magento1500,model_magerp_product_attributes,frontend_label,,in_out,function,unicode,,"result=[('frontend_label', ifield)]","result=[('frontend_label', record['frontend_label'])]" | ||
4207 | 148 | mag_1500_erp_attr_8,magento1500,model_magerp_product_attributes,is_visible_in_advanced_search,,in_out,function,unicode,,"result=[('is_visible_in_advanced_search', bool(eval(ifield)))]","result=[('is_visible_in_advanced_search', record['is_visible_in_advanced_search'])]" | ||
4208 | 149 | mag_1500_erp_attr_9,magento1500,model_magerp_product_attributes,is_global,,in_out,function,unicode,,"result=[('is_global', bool(eval(ifield)))]","result=[('is_global', record['is_global'])]" | ||
4209 | 150 | mag_1500_erp_attr_10,magento1500,model_magerp_product_attributes,is_filterable,,in_out,function,unicode,,"result=[('is_filterable', bool(eval(ifield)))]","result=[('is_filterable', record['is_filterable'])]" | ||
4210 | 151 | mag_1500_erp_attr_11,magento1500,model_magerp_product_attributes,is_comparable,,in_out,function,unicode,,"result=[('is_comparable', bool(eval(ifield)))]","result=[('is_comparable', record['is_comparable'])]" | ||
4211 | 152 | mag_1500_erp_attr_12,magento1500,model_magerp_product_attributes,is_visible,,in_out,function,unicode,,"result=[('is_visible', bool(eval(ifield)))]","result=[('is_visible', record['is_visible'])]" | ||
4212 | 153 | mag_1500_erp_attr_13,magento1500,model_magerp_product_attributes,is_searchable,,in_out,function,unicode,,"result=[('is_searchable', bool(eval(ifield)))]","result=[('is_searchable', record['is_searchable'])]" | ||
4213 | 154 | mag_1500_erp_attr_14,magento1500,model_magerp_product_attributes,is_user_defined,,in_out,function,unicode,,"result=[('is_user_defined', bool(eval(ifield)))]","result=[('is_user_defined', record['is_user_defined'])]" | ||
4214 | 155 | mag_1500_erp_attr_15,magento1500,model_magerp_product_attributes,is_configurable,,in_out,function,unicode,,"result=[('is_configurable', bool(eval(ifield)))]","result=[('is_configurable', record['is_configurable'])]" | ||
4215 | 156 | mag_1500_erp_attr_16,magento1500,model_magerp_product_attributes,is_visible_on_front,,in_out,function,unicode,,"result=[('is_visible_on_front', bool(eval(ifield)))]","result=[('is_visible_on_front', record['is_visible_on_front'])]" | ||
4216 | 157 | mag_1500_erp_attr_17,magento1500,model_magerp_product_attributes,is_used_for_price_rules,,in_out,function,unicode,,"result=[('is_used_for_price_rules', bool(eval(ifield)))]","result=[('is_used_for_price_rules', record['is_used_for_price_rules'])]" | ||
4217 | 158 | mag_1500_erp_attr_18,magento1500,model_magerp_product_attributes,is_unique,,in_out,function,unicode,,"result=[('is_unique', bool(eval(ifield)))]","result=[('is_unique', record['is_unique'])]" | ||
4218 | 159 | mag_1500_erp_attr_19,magento1500,model_magerp_product_attributes,is_required,,in_out,function,unicode,,"result=[('is_required', bool(eval(ifield)))]","result=[('is_required', record['is_required'])]" | ||
4219 | 160 | mag_1500_erp_attr_20,magento1500,model_magerp_product_attributes,position,,in_out,function,int,,"result=[('position', ifield)]","result=[('position', record['position'])]" | ||
4220 | 161 | mag_1500_erp_attr_21,magento1500,model_magerp_product_attributes,attribute_set_info,,in_out,function,unicode,,"result=[('attribute_set_info', ifield)]","result=[('attribute_set_info', record['attribute_set_info'])]" | ||
4221 | 162 | mag_1500_erp_attr_22,magento1500,model_magerp_product_attributes,default_value,,in_out,function,unicode,,"result=[('default_value', ifield)]","result=[('default_value', record['default_value'])]" | ||
4222 | 163 | mag_1500_erp_attr_23,magento1500,model_magerp_product_attributes,note,,in_out,function,unicode,,"result=[('note', ifield)]","result=[('note', record['note'])]" | ||
4223 | 164 | mag_1500_erp_attr_24,magento1500,model_magerp_product_attributes,entity_type_id,,in_out,function,int,,"result=[('entity_type_id', ifield)]","result=[('entity_type_id', record['entity_type_id'])]" | ||
4224 | 165 | mag_1500_erp_attr_25,magento1500,model_magerp_product_attributes,apply_to,,in_out,function,unicode,,"result=[('apply_to', str(ifield))]","result=[('apply_to', eval(record['%s']))]" | ||
4225 | 166 | mag_1500_erp_prd_1,magento1500,product.model_product_product,url_key,,in_out,function,unicode,,"result=[('x_magerp_url_key',ifield)]","if context.get('export_url', False) : | ||
4226 | 167 | result=[('url_key',record['x_magerp_url_key'])]" | ||
4227 | 168 | mag_1500_erp_prd_2,magento1500,product.model_product_product,name,,in_out,function,unicode,,"result = [('name',ifield)]","result = [('name',record['name'])]" | ||
4228 | 169 | mag_1500_erp_prd_3,magento1500,product.model_product_product,description,,in_out,function,unicode,,"result = [('description',ifield)]", | ||
4229 | 170 | mag_1500_erp_prd_4,magento1500,product.model_product_product,short_description,,in_out,function,unicode,,"result = [('description_sale',ifield)]", | ||
4230 | 171 | mag_1500_erp_prd_5,magento1500,product.model_product_product,sku,,in_out,function,unicode,,"result = [('magento_sku',ifield), ('default_code',ifield)]", | ||
4231 | 172 | mag_1500_erp_prd_6,magento1500,product.model_product_product,weight,,in_out,function,float,,"result = [('weight',ifield)]","result = [('weight',record['weight'] or 0)]" | ||
4232 | 173 | mag_1500_erp_prd_7,magento1500,product.model_product_product,categories,,in_out,function,list,,"categ_ids =[] | ||
4233 | 174 | if ifield: | ||
4234 | 175 | for category_id in ifield: | ||
4235 | 176 | categ_ids.append(self.pool.get('product.category').extid_to_oeid(cr, uid, category_id, external_referential_id, context=context)) | ||
4236 | 177 | main_categ_id = categ_ids.pop() | ||
4237 | 178 | else: | ||
4238 | 179 | main_categ_id = self.pool.get('external.referential').browse(cr, uid, external_referential_id).default_pro_cat.id | ||
4239 | 180 | result = [('categ_id', main_categ_id), ('categ_ids',[(6, 0, categ_ids)])]"," | ||
4240 | 181 | cat_obj = self.pool.get('product.category') | ||
4241 | 182 | product = self.browse(cr, uid, record['id']) | ||
4242 | 183 | categ_ids = [categ.id for categ in ([product.categ_id] + product.categ_ids) if categ.magento_exportable] | ||
4243 | 184 | mag_categ_ids = [] | ||
4244 | 185 | for categ_id in categ_ids: | ||
4245 | 186 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
4246 | 187 | if not mag_categ_id: | ||
4247 | 188 | ctx = dict(context, force_export=True) | ||
4248 | 189 | cat_obj.ext_export(cr, uid, [categ_id], [external_referential_id], context=ctx) | ||
4249 | 190 | mag_categ_id = cat_obj.oeid_to_extid(cr, uid, categ_id, external_referential_id) | ||
4250 | 191 | mag_categ_ids.append(mag_categ_id) | ||
4251 | 192 | result=[('category_ids', mag_categ_ids)]" | ||
4252 | 193 | mag_1500_erp_prd_8,magento1500,product.model_product_product,price,,in_out,function,float,,"result=[('list_price',ifield)]",result=[]#map later | ||
4253 | 194 | mag_1500_erp_prd_9,magento1500,product.model_product_product,cost,,in_out,function,float,,"result=[('standard_price',ifield)]","result = [('cost',record['standard_price'] or 0)]" | ||
4254 | 195 | mag_1500_erp_prd_10,magento1500,product.model_product_product,set,,in_out,function,unicode,,"result=[('set',self.pool.get('magerp.product_attribute_set').extid_to_oeid(cr, uid, ifield, external_referential_id, context=context))]", | ||
4255 | 196 | mag_1500_erp_prd_11,magento1500,product.model_product_product,special_price,,in_out,function,float,,"result = [('x_magerp_special_price',ifield)]", | ||
4256 | 197 | mag_1500_erp_prd_12,magento1500,product.model_product_product,tier_price,,in_out,function,unicode,,result=[]#no mapping by default,result=[]#no mapping by default | ||
4257 | 198 | mag_1500_erp_prd_13,magento1500,product.model_product_product,minimal_price,,in_out,function,float,,"result = [('x_magerp_minimal_price',ifield)]"," | ||
4258 | 199 | if record['x_magerp_minimal_price'] and record['x_magerp_minimal_price'] != 0: | ||
4259 | 200 | result = [('minimal_price',record['x_magerp_minimal_price'])] | ||
4260 | 201 | else: | ||
4261 | 202 | result = [('minimal_price',False)]" | ||
4262 | 203 | mag_1500_erp_prd_14,magento1500,product.model_product_product,type_id,,in_out,function,unicode,,"if ifield: | ||
4263 | 204 | product_type_ids = self.pool.get('magerp.product_product_type').search(cr,uid,[('product_type','=',ifield)]) | ||
4264 | 205 | if product_type_ids: | ||
4265 | 206 | result = [('product_type',ifield)]","if 'product_type' in record and record['product_type']: | ||
4266 | 207 | result = [('type_id',record['product_type'])] | ||
4267 | 208 | else: | ||
4268 | 209 | result = [('type_id','simple')]" | ||
4269 | 210 | mag_1500_erp_prd_15,magento1500,product.model_product_product,websites,,in_out,function,list,,"websites_ids = [] | ||
4270 | 211 | for ext_id in ifield: | ||
4271 | 212 | websites_ids.append(self.pool.get('external.shop.group').extid_to_oeid(cr, uid, ext_id, external_referential_id, context=context)) | ||
4272 | 213 | |||
4273 | 214 | ##### OPTION START, with this if the field websites of the product is empty the product is exported on every website | ||
4274 | 215 | all_oe_websites_ids = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', external_referential_id)]) | ||
4275 | 216 | if set(websites_ids) == set(all_oe_websites_ids): | ||
4276 | 217 | websites_ids =[] | ||
4277 | 218 | ##### OPTION END | ||
4278 | 219 | |||
4279 | 220 | result=[('websites_ids', [(6,0, websites_ids)])]","##### OPTION START, with this if the field websites of the product is empty the product is exported on every website | ||
4280 | 221 | if not record['websites_ids']: | ||
4281 | 222 | record['websites_ids'] = self.pool.get('external.shop.group').search(cr,uid,[('referential_id', '=', external_referential_id)]) | ||
4282 | 223 | ##### OPTION END | ||
4283 | 224 | |||
4284 | 225 | ext_websites_ids = [] | ||
4285 | 226 | for oe_id in record['websites_ids']: | ||
4286 | 227 | ext_websites_ids.append(self.pool.get('external.shop.group').oeid_to_extid(cr, uid, oe_id, external_referential_id)) | ||
4287 | 228 | |||
4288 | 229 | result=[('websites', ext_websites_ids)]" | ||
4289 | 230 | mag_1500_erp_prd_16,magento1500,product.model_product_product,has_options,,in,function,unicode,,"result =[('x_magerp_has_options',ifield)]", | ||
4290 | 231 | magento_1500_cst_grp_1,magento1500,base.model_res_partner_category,customer_group_code,,in,function,unicode,,"result=[('name',ifield)]", | ||
4291 | 232 | magento_1500_cst_grp_3,magento1500,base.model_res_partner_category,tax_class_id,,in,function,int,,"result=[('tax_class_id',ifield)]", | ||
4292 | 233 | magento_1500_prt_adr_2,magento1500,base.model_res_partner_address,city,,in_out,function,unicode,,"result=[('city',ifield)]", | ||
4293 | 234 | magento_1500_prt_adr_3,magento1500,base.model_res_partner_address,fax,,in_out,function,unicode,,"result=[('fax',ifield)]", | ||
4294 | 235 | magento_1500_prt_adr_4,magento1500,base.model_res_partner_address,firstname,,in_out,function,unicode,,"name = ' '.join([ f for f in (data['firstname'], data['lastname']) if f]) | ||
4295 | 236 | if data.get('company'): | ||
4296 | 237 | name = ""%s ; %s"" % (data['company'], name) | ||
4297 | 238 | result = [('name', name), ('firstname', ifield), ('lastname', data['lastname'])]", | ||
4298 | 239 | magento_1500_prt_adr_6,magento1500,base.model_res_partner_address,is_active,,in_out,function,unicode,,"result=[('active',bool(eval(ifield)))]", | ||
4299 | 240 | magento_1500_prt_adr_7,magento1500,base.model_res_partner_address,country_id,,in_out,function,unicode,,"result = self.pool.get('res.country').search(cr,uid,[('code','=',ifield)]) | ||
4300 | 241 | if result and len(result)==1: | ||
4301 | 242 | result=[('country_id',result[0])] | ||
4302 | 243 | else: | ||
4303 | 244 | result=[] | ||
4304 | 245 | ", | ||
4305 | 246 | magento_1500_prt_adr_8,magento1500,base.model_res_partner_address,street,,in_out,function,unicode,,"if ifield: | ||
4306 | 247 | if len(ifield.split('\n')) ==2 : | ||
4307 | 248 | result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] | ||
4308 | 249 | else : | ||
4309 | 250 | result = [('street',ifield.replace('\\n',','))] | ||
4310 | 251 | else: | ||
4311 | 252 | result = []", | ||
4312 | 253 | magento_1500_prt_adr_9,magento1500,base.model_res_partner_address,postcode,,in_out,function,unicode,,"result=[('zip',ifield)]", | ||
4313 | 254 | magento_1500_prt_adr_10,magento1500,base.model_res_partner_address,telephone,,in_out,function,unicode,,"result=[('phone',ifield)]", | ||
4314 | 255 | magento_1500_prt_adr_11,magento1500,base.model_res_partner_address,region,,in_out,function,unicode,,"if ifield: | ||
4315 | 256 | result = self.pool.get('res.country.state').search(cr,uid,[('name','=ilike',ifield)]) | ||
4316 | 257 | if result and len(result)==1: | ||
4317 | 258 | result = [('state_id',result[0])] | ||
4318 | 259 | else: | ||
4319 | 260 | result=[] | ||
4320 | 261 | else: | ||
4321 | 262 | result=[]", | ||
4322 | 263 | magento_1500_prt_adr_13,magento1500,base.model_res_partner_address,customer_id,,in_out,function,int,," | ||
4323 | 264 | if ifield: | ||
4324 | 265 | result=self.pool.get('res.partner').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
4325 | 266 | if result: | ||
4326 | 267 | result=[('partner_id', result)] | ||
4327 | 268 | else: | ||
4328 | 269 | result=[('partner_id', False)]", | ||
4329 | 270 | magento_1500_prt_adr_14,magento1500,base.model_res_partner_address,address_type,,in_out,function,unicode,,"if ifield=='billing': | ||
4330 | 271 | result=[('type','invoice')] | ||
4331 | 272 | elif ifield=='shipping': | ||
4332 | 273 | result=[('type','delivery')] | ||
4333 | 274 | else: | ||
4334 | 275 | result=[]", | ||
4335 | 276 | magento_1500_prt_adr_15,magento1500,base.model_res_partner_address,email,,in_out,function,unicode,,"result = [('email', False)] | ||
4336 | 277 | if ifield: | ||
4337 | 278 | result = [('email', ifield)] | ||
4338 | 279 | else: | ||
4339 | 280 | if data.get('customer_id'): | ||
4340 | 281 | partner_obj = self.pool.get('res.partner') | ||
4341 | 282 | partner_id = partner_obj.extid_to_existing_oeid(cr, uid, data['customer_id'] ,external_referential_id) | ||
4342 | 283 | if partner_id: | ||
4343 | 284 | result = [('email', partner_obj.browse(cr, uid, partner_id).emailid)] ", | ||
4344 | 285 | magento_1500_prt_adr_16,magento1500,base.model_res_partner_address,prefix,,in_out,function,unicode,,"if ifield: | ||
4345 | 286 | title_ids = self.pool.get('res.partner.title').search(cr, uid, [('domain', '=', 'contact'), ('shortcut', '=', ifield)]) | ||
4346 | 287 | if title_ids: | ||
4347 | 288 | title_id = title_ids[0] | ||
4348 | 289 | else: | ||
4349 | 290 | title_id = self.pool.get('res.partner.title').create(cr, uid, {'domain': 'contact', 'shortcut': ifield, 'name' : ifield}) | ||
4350 | 291 | result=[('title', title_id)]", | ||
4351 | 292 | magento_1500_prt_adr_17,magento1500,base.model_res_partner_address,default_billing,,in_out,function,unicode,,"result = [('type', 'other')] | ||
4352 | 293 | if data.get('default_billing') and data.get('default_shipping'): | ||
4353 | 294 | result = [('type', 'default')] | ||
4354 | 295 | elif data.get('default_billing'): | ||
4355 | 296 | result = [('type', 'invoice')] | ||
4356 | 297 | elif data.get('default_shipping'): | ||
4357 | 298 | result = [('type', 'delivery')]", | ||
4358 | 299 | magento_1500_prt_2,magento1500,base.model_res_partner,group_id,,in_out,function,int,,"if ifield: | ||
4359 | 300 | result=self.pool.get('res.partner.category').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
4360 | 301 | if result: | ||
4361 | 302 | result=[('group_id',result)]", | ||
4362 | 303 | magento_1500_prt_3,magento1500,base.model_res_partner,store_id,,in_out,function,int,,"if ifield: | ||
4363 | 304 | result=self.pool.get('magerp.storeviews').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
4364 | 305 | if result: | ||
4365 | 306 | store = self.pool.get('magerp.storeviews').browse(cr, uid, result) | ||
4366 | 307 | lang = store.lang_id | ||
4367 | 308 | result=[('store_id',result),('lang',lang and lang.code or False)] | ||
4368 | 309 | if not data.get('website_id'): | ||
4369 | 310 | result.append(('website_id', store.website_id.id))", | ||
4370 | 311 | magento_1500_prt_4,magento1500,base.model_res_partner,website_id,,in_out,function,int,,"if ifield: | ||
4371 | 312 | result=self.pool.get('external.shop.group').extid_to_oeid(cr,uid,ifield,external_referential_id, context=context) | ||
4372 | 313 | if result: | ||
4373 | 314 | result=[('website_id',result)]", | ||
4374 | 315 | magento_1500_prt_5,magento1500,base.model_res_partner,created_in,,in_out,function,unicode,,"result=[('created_in',ifield)]", | ||
4375 | 316 | magento_1500_prt_6,magento1500,base.model_res_partner,created_at,,in_out,function,unicode,,"result=[('created_at',ifield)]", | ||
4376 | 317 | magento_1500_prt_7,magento1500,base.model_res_partner,updated_at,,in_out,function,unicode,,"result=[('updated_at',ifield)]", | ||
4377 | 318 | magento_1500_prt_8,magento1500,base.model_res_partner,firstname,,in_out,function,unicode,,"result = [('name', ifield + ' ' + data['lastname'])]","add_id = self.browse(cr, uid, record['id']) | ||
4378 | 319 | fn = add_id.address[0].firstname | ||
4379 | 320 | ln = add_id.address[0].lastname | ||
4380 | 321 | result=[('firstname', fn), ('lastname', ln)]" | ||
4381 | 322 | magento_1500_prt_10,magento1500,base.model_res_partner,email,,in_out,function,unicode,,"result=[('emailid',ifield)]", | ||
4382 | 323 | magento_1500_prt_11,magento1500,base.model_res_partner,taxvat,,in_out,function,unicode,,"if ifield: | ||
4383 | 324 | result=[('mag_vat',ifield)] | ||
4384 | 325 | else: | ||
4385 | 326 | result=[]", | ||
4386 | 327 | magento_1500_prt_12,magento1500,base.model_res_partner,dob,,in_out,function,unicode,,"if ifield: | ||
4387 | 328 | result =[('mag_birthday',ifield[:10])] | ||
4388 | 329 | else: | ||
4389 | 330 | result=[]", | ||
4390 | 0 | 331 | ||
4391 | === added directory 'magentoerpconnect/settings/update' | |||
4392 | === added file 'magentoerpconnect/settings/update/fix_product_categories.sql' | |||
4393 | --- magentoerpconnect/settings/update/fix_product_categories.sql 1970-01-01 00:00:00 +0000 | |||
4394 | +++ magentoerpconnect/settings/update/fix_product_categories.sql 2012-07-06 14:53:18 +0000 | |||
4395 | @@ -0,0 +1,7 @@ | |||
4396 | 1 | UPDATE product_category | ||
4397 | 2 | SET default_sort_by=(SELECT id FROM magerp_product_category_attribute_options WHERE value='' and attribute_name='sort_by') | ||
4398 | 3 | WHERE default_sort_by in (SELECT id FROM magerp_product_category_attribute_options WHERE value='None' and attribute_name='sort_by'); | ||
4399 | 4 | |||
4400 | 5 | UPDATE product_category | ||
4401 | 6 | SET page_layout=(SELECT id FROM magerp_product_category_attribute_options WHERE value='' and attribute_name='page_layout') | ||
4402 | 7 | WHERE page_layout in (SELECT id FROM magerp_product_category_attribute_options WHERE value='None' and attribute_name='page_layout'); | ||
4403 | 0 | 8 | ||
4404 | === added file 'magentoerpconnect/settings/update/magerp.product_category_attribute_options.xml' | |||
4405 | --- magentoerpconnect/settings/update/magerp.product_category_attribute_options.xml 1970-01-01 00:00:00 +0000 | |||
4406 | +++ magentoerpconnect/settings/update/magerp.product_category_attribute_options.xml 2012-07-06 14:53:18 +0000 | |||
4407 | @@ -0,0 +1,16 @@ | |||
4408 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
4409 | 2 | <openerp> | ||
4410 | 3 | <data> | ||
4411 | 4 | <record model='magerp.product_category_attribute_options' id='mag_product_category_attribute_1_1400'> | ||
4412 | 5 | <field name="attribute_name">page_layout</field> | ||
4413 | 6 | <field name="label">No layout updates</field> | ||
4414 | 7 | <field name="value" eval='""' /> | ||
4415 | 8 | </record> | ||
4416 | 9 | |||
4417 | 10 | <record model='magerp.product_category_attribute_options' id='mag_product_category_attribute_7_1400'> | ||
4418 | 11 | <field name="attribute_name">sort_by</field> | ||
4419 | 12 | <field name="label">Use Config Settings</field> | ||
4420 | 13 | <field name="value" eval='""' /> | ||
4421 | 14 | </record> | ||
4422 | 15 | </data> | ||
4423 | 16 | </openerp> | ||
4424 | 0 | 17 | ||
4425 | === modified file 'magentoerpconnect/stock.py' | |||
4426 | --- magentoerpconnect/stock.py 2012-05-25 15:37:26 +0000 | |||
4427 | +++ magentoerpconnect/stock.py 2012-07-06 14:53:18 +0000 | |||
4428 | @@ -20,6 +20,10 @@ | |||
4429 | 20 | ######################################################################### | 20 | ######################################################################### |
4430 | 21 | 21 | ||
4431 | 22 | import xmlrpclib | 22 | import xmlrpclib |
4432 | 23 | <<<<<<< TREE | ||
4433 | 24 | ======= | ||
4434 | 25 | import logging | ||
4435 | 26 | >>>>>>> MERGE-SOURCE | ||
4436 | 23 | 27 | ||
4437 | 24 | from osv import fields,osv | 28 | from osv import fields,osv |
4438 | 25 | from tools.translate import _ | 29 | from tools.translate import _ |
4439 | @@ -69,8 +73,13 @@ | |||
4440 | 69 | else: | 73 | else: |
4441 | 70 | item_qty.update({product_2_item[line['product_id']]: line['product_qty']}) | 74 | item_qty.update({product_2_item[line['product_id']]: line['product_qty']}) |
4442 | 71 | 75 | ||
4443 | 76 | <<<<<<< TREE | ||
4444 | 72 | ext_shipping_id = conn.call('sales_order_shipment.create', [magento_incrementid, item_qty, _("Shipping Created"), mail_notification, True]) | 77 | ext_shipping_id = conn.call('sales_order_shipment.create', [magento_incrementid, item_qty, _("Shipping Created"), mail_notification, True]) |
4445 | 73 | return ext_shipping_id | 78 | return ext_shipping_id |
4446 | 79 | ======= | ||
4447 | 80 | ext_shipping_id = conn.call('sales_order_shipment.create', [magento_incrementid, item_qty, _("Shipping Created"), mail_notification, True]) | ||
4448 | 81 | return ext_shipping_id | ||
4449 | 82 | >>>>>>> MERGE-SOURCE | ||
4450 | 74 | 83 | ||
4451 | 75 | def create_ext_shipping(self, cr, uid, id, picking_type, external_referential_id, context=None): | 84 | def create_ext_shipping(self, cr, uid, id, picking_type, external_referential_id, context=None): |
4452 | 76 | """ | 85 | """ |
4453 | @@ -103,6 +112,8 @@ | |||
4454 | 103 | # in order to exclude it from the future exports | 112 | # in order to exclude it from the future exports |
4455 | 104 | if e.faultCode == 102: | 113 | if e.faultCode == 102: |
4456 | 105 | raise ExternalShippingCreateError(e) | 114 | raise ExternalShippingCreateError(e) |
4457 | 115 | else: | ||
4458 | 116 | raise | ||
4459 | 106 | 117 | ||
4460 | 107 | if ext_shipping_id and carrier_id: | 118 | if ext_shipping_id and carrier_id: |
4461 | 108 | self.add_ext_tracking_reference(cr, uid, id, carrier_id, ext_shipping_id, context) | 119 | self.add_ext_tracking_reference(cr, uid, id, carrier_id, ext_shipping_id, context) |
4462 | @@ -110,6 +121,10 @@ | |||
4463 | 110 | 121 | ||
4464 | 111 | def add_ext_tracking_reference(self, cr, uid, id, carrier_id, ext_shipping_id, context=None): | 122 | def add_ext_tracking_reference(self, cr, uid, id, carrier_id, ext_shipping_id, context=None): |
4465 | 112 | if context is None: context = {} | 123 | if context is None: context = {} |
4466 | 124 | <<<<<<< TREE | ||
4467 | 125 | ======= | ||
4468 | 126 | logger = logging.getLogger('ext synchro') | ||
4469 | 127 | >>>>>>> MERGE-SOURCE | ||
4470 | 113 | conn = context.get('conn_obj', False) | 128 | conn = context.get('conn_obj', False) |
4471 | 114 | carrier = self.pool.get('delivery.carrier').read(cr, uid, carrier_id, ['magento_carrier_code', 'magento_tracking_title'], context) | 129 | carrier = self.pool.get('delivery.carrier').read(cr, uid, carrier_id, ['magento_carrier_code', 'magento_tracking_title'], context) |
4472 | 115 | 130 | ||
4473 | @@ -120,7 +135,11 @@ | |||
4474 | 120 | 135 | ||
4475 | 121 | res = conn.call('sales_order_shipment.addTrack', [ext_shipping_id, carrier['magento_carrier_code'], carrier['magento_tracking_title'] or '', carrier_tracking_ref or '']) | 136 | res = conn.call('sales_order_shipment.addTrack', [ext_shipping_id, carrier['magento_carrier_code'], carrier['magento_tracking_title'] or '', carrier_tracking_ref or '']) |
4476 | 122 | if res: | 137 | if res: |
4477 | 138 | <<<<<<< TREE | ||
4478 | 123 | _logger.info("Successfully adding a tracking reference to the shipping with OpenERP id %s and ext id %s in external sale system", id, ext_shipping_id) | 139 | _logger.info("Successfully adding a tracking reference to the shipping with OpenERP id %s and ext id %s in external sale system", id, ext_shipping_id) |
4479 | 140 | ======= | ||
4480 | 141 | logger.info("Successfully adding a tracking reference to the shipping with OpenERP id %s and ext id %s in external sale system", id, ext_shipping_id) | ||
4481 | 142 | >>>>>>> MERGE-SOURCE | ||
4482 | 124 | return True | 143 | return True |
4483 | 125 | 144 | ||
4484 | 126 | stock_picking() | 145 | stock_picking() |
4485 | 127 | 146 | ||
4486 | === modified file 'magentoerpconnect_payment/sale.py' | |||
4487 | --- magentoerpconnect_payment/sale.py 2012-03-27 09:40:33 +0000 | |||
4488 | +++ magentoerpconnect_payment/sale.py 2012-07-06 14:53:18 +0000 | |||
4489 | @@ -101,6 +101,89 @@ | |||
4490 | 101 | self._magento_create_invoice(cr, uid, order, context=context) | 101 | self._magento_create_invoice(cr, uid, order, context=context) |
4491 | 102 | return True | 102 | return True |
4492 | 103 | 103 | ||
4493 | 104 | def _call_magento_invoice(self, cr, uid, order, order_external_data=None, context=None): | ||
4494 | 105 | """Return the Magento data for all invoices | ||
4495 | 106 | of an order | ||
4496 | 107 | |||
4497 | 108 | :param browse_record order: browsable record of sale order | ||
4498 | 109 | :param dict order_external_data: magento data of the order, optional, | ||
4499 | 110 | a call to magento will be done to get the data if None | ||
4500 | 111 | :return: list of magento invoices as dict | ||
4501 | 112 | """ | ||
4502 | 113 | if context is None: | ||
4503 | 114 | context = {} | ||
4504 | 115 | |||
4505 | 116 | referential = order.shop_id.referential_id | ||
4506 | 117 | connection = context.get('conn_obj') or \ | ||
4507 | 118 | referential.external_connection() | ||
4508 | 119 | |||
4509 | 120 | # Filter on order_increment_id does not work | ||
4510 | 121 | # on magento. | ||
4511 | 122 | # So we need first to get the order id | ||
4512 | 123 | # and filter the invoice on this order id | ||
4513 | 124 | if not order_external_data: | ||
4514 | 125 | order_ext_id = self.oeid_to_extid( | ||
4515 | 126 | cr, uid, order.id, referential.id, context=context) | ||
4516 | 127 | order_external_data = connection.call( | ||
4517 | 128 | 'sales_order.info', [order_ext_id]) | ||
4518 | 129 | |||
4519 | 130 | mag_order_id = order_external_data['order_id'] | ||
4520 | 131 | return connection.call( | ||
4521 | 132 | 'sales_order_invoice.list', [{'order_id': {'eq': mag_order_id}}]) | ||
4522 | 133 | |||
4523 | 134 | def _get_missing_magento_invoice_number(self, cr, uid, order, external_data, context=None): | ||
4524 | 135 | """Get the first invoice number for a magento order | ||
4525 | 136 | and assign it to magento_ref fields | ||
4526 | 137 | so we can later push it on the invoice | ||
4527 | 138 | |||
4528 | 139 | :param browse_record order: browsable record of sale order | ||
4529 | 140 | :param dict external_data: magento data of the order | ||
4530 | 141 | :return: invoice number of magento | ||
4531 | 142 | """ | ||
4532 | 143 | invoice_number = False | ||
4533 | 144 | mag_invoices = self._call_magento_invoice( | ||
4534 | 145 | cr, uid, order, order_external_data=external_data, context=context) | ||
4535 | 146 | if mag_invoices: | ||
4536 | 147 | invoice_number = mag_invoices[0].get('increment_id') | ||
4537 | 148 | |||
4538 | 149 | if invoice_number: | ||
4539 | 150 | self.write( | ||
4540 | 151 | cr, uid, order.id, | ||
4541 | 152 | {'magento_ref': invoice_number}, | ||
4542 | 153 | context=context) | ||
4543 | 154 | # propagate on invoice if some exists | ||
4544 | 155 | # don't care of multiplue invoice because we | ||
4545 | 156 | # don't know which invoice would have | ||
4546 | 157 | # which magento number, 1 invoice on magento | ||
4547 | 158 | # and 1 invoice on openerp expected, otherwise | ||
4548 | 159 | # it has to be manually filled | ||
4549 | 160 | if order.invoice_ids: | ||
4550 | 161 | inv_ids = [inv.id for inv in order.invoice_ids] | ||
4551 | 162 | self.pool.get('account.invoice').write( | ||
4552 | 163 | cr, uid, inv_ids, | ||
4553 | 164 | {'magento_ref': invoice_number}, | ||
4554 | 165 | context=context) | ||
4555 | 166 | return invoice_number | ||
4556 | 167 | |||
4557 | 168 | def create_payments(self, cr, uid, order_id, data_record, context=None): | ||
4558 | 169 | """Inherited to get the magento invoice number. | ||
4559 | 170 | With Magento, we are sure that when we have a payment, | ||
4560 | 171 | we have an invoice, so we get its number to have it | ||
4561 | 172 | on the openerp invoice | ||
4562 | 173 | """ | ||
4563 | 174 | paid = super(sale_order, self).create_payments( | ||
4564 | 175 | cr, uid, order_id, data_record, context=context) | ||
4565 | 176 | |||
4566 | 177 | if 'Magento' in context.get('external_referential_type', ''): | ||
4567 | 178 | order = self.browse(cr, uid, order_id, context=context) | ||
4568 | 179 | |||
4569 | 180 | if paid and not order.magento_ref: | ||
4570 | 181 | # get the invoice number | ||
4571 | 182 | self._get_missing_magento_invoice_number( | ||
4572 | 183 | cr, uid, order, data_record, context=context) | ||
4573 | 184 | |||
4574 | 185 | return paid | ||
4575 | 186 | |||
4576 | 104 | def _prepare_invoice(self, cr, uid, order, lines, context=None): | 187 | def _prepare_invoice(self, cr, uid, order, lines, context=None): |
4577 | 105 | """Prepare the dict of values to create the new invoice for a | 188 | """Prepare the dict of values to create the new invoice for a |
4578 | 106 | sale order. This method may be overridden to implement custom | 189 | sale order. This method may be overridden to implement custom |
4579 | @@ -123,4 +206,16 @@ | |||
4580 | 123 | vals['magento_ref'] = order.magento_ref | 206 | vals['magento_ref'] = order.magento_ref |
4581 | 124 | return vals | 207 | return vals |
4582 | 125 | 208 | ||
4583 | 209 | def _apply_payment_settings(self, cr, uid, order, paid, context=None): | ||
4584 | 210 | """We should deactivate need_to_update to avoid to query magento | ||
4585 | 211 | on each import of orders and not to mislead the users if they use | ||
4586 | 212 | a filter on need_to_update. | ||
4587 | 213 | """ | ||
4588 | 214 | res = super(sale_order, self)._apply_payment_settings(cr, uid, order, | ||
4589 | 215 | paid, context=context) | ||
4590 | 216 | payment_settings = order.base_payment_type_id | ||
4591 | 217 | if payment_settings and payment_settings.allow_magento_manual_invoice: | ||
4592 | 218 | self.write(cr, uid, order.id, {'need_to_update': False}, context=context) | ||
4593 | 219 | return res | ||
4594 | 220 | |||
4595 | 126 | sale_order() | 221 | sale_order() |
4596 | 127 | 222 | ||
4597 | === modified file 'magentoerpconnect_product_variant/product.py' | |||
4598 | --- magentoerpconnect_product_variant/product.py 2012-04-26 21:59:20 +0000 | |||
4599 | +++ magentoerpconnect_product_variant/product.py 2012-07-06 14:53:18 +0000 | |||
4600 | @@ -86,6 +86,95 @@ | |||
4601 | 86 | else: | 86 | else: |
4602 | 87 | vals['product_type'] = 'simple' | 87 | vals['product_type'] = 'simple' |
4603 | 88 | return super(product_product, self).create(cr, uid, vals, context) | 88 | return super(product_product, self).create(cr, uid, vals, context) |
4604 | 89 | <<<<<<< TREE | ||
4605 | 90 | ======= | ||
4606 | 91 | |||
4607 | 92 | def action_before_exporting(self, cr, uid, id, product_type, external_referential_ids, defaults, context): | ||
4608 | 93 | #When the export of a configurable product is forced we should check if all variant are already exported | ||
4609 | 94 | if context.get('force_export', False) and product_type == 'configurable': | ||
4610 | 95 | conn = context.get('conn_obj', False) | ||
4611 | 96 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id']) | ||
4612 | 97 | variant_ids = self.read(cr, uid, id, ['variant_ids'], context)['variant_ids'] | ||
4613 | 98 | variant_ids.remove(id) | ||
4614 | 99 | for variant in self.browse(cr, uid, variant_ids, context=context): | ||
4615 | 100 | if variant.magento_exportable: | ||
4616 | 101 | if not self.oeid_to_extid(cr, uid, variant.id, shop.referential_id.id): | ||
4617 | 102 | conn.logger.info("Force the export of the product %s as it was not exported before", id) | ||
4618 | 103 | self.ext_export(cr, uid, [variant.id], external_referential_ids, defaults, context) | ||
4619 | 104 | return True | ||
4620 | 105 | |||
4621 | 106 | def add_data_to_create_configurable_product(self, cr, uid, oe_id, data, context=None): | ||
4622 | 107 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id']) | ||
4623 | 108 | # check if not already created | ||
4624 | 109 | products_data = {} # values of the attributes used on the element products | ||
4625 | 110 | attributes_data = {} # params of the attributes to use on the configurable product | ||
4626 | 111 | |||
4627 | 112 | variant_ids = self.read(cr, uid, oe_id, ['variant_ids'], context=context)['variant_ids'] | ||
4628 | 113 | variant_ids.remove(oe_id) | ||
4629 | 114 | if variant_ids: | ||
4630 | 115 | associated_skus = [] | ||
4631 | 116 | # create a dict with all values used on the configurable products | ||
4632 | 117 | for product in self.browse(cr, uid, variant_ids): | ||
4633 | 118 | if product.magento_exportable: | ||
4634 | 119 | associated_skus += [product.magento_sku] | ||
4635 | 120 | attr_list = set() | ||
4636 | 121 | # get values for each attribute of the product | ||
4637 | 122 | mag_prod_id = str(self.oeid_to_extid(cr, uid, product.id, shop.referential_id.id)) | ||
4638 | 123 | products_data[mag_prod_id] = {} | ||
4639 | 124 | index=0 | ||
4640 | 125 | for value in product.dimension_value_ids: | ||
4641 | 126 | # get the option selected on the product | ||
4642 | 127 | option = value.option_id.magento_attribut_option | ||
4643 | 128 | attr = option.attribute_id | ||
4644 | 129 | attr_list = attr_list.union(set([attr])) | ||
4645 | 130 | prod_data = { | ||
4646 | 131 | 'attribute_id': attr.magento_id, # id of the attribute | ||
4647 | 132 | 'label': option.label, # label of the option | ||
4648 | 133 | 'value_index': int(option.value), # id of the option | ||
4649 | 134 | 'is_percent': 0, # modification of the price | ||
4650 | 135 | 'pricing_value': '', # modification of the price | ||
4651 | 136 | } | ||
4652 | 137 | #products_data[mag_prod_id][str(attribute_set.configurable_attributes.index(attr))] = prod_data | ||
4653 | 138 | products_data[mag_prod_id][str(index)] = prod_data | ||
4654 | 139 | index += 1 | ||
4655 | 140 | |||
4656 | 141 | # create a dict with attributes used on the configurable product | ||
4657 | 142 | index=-1 | ||
4658 | 143 | for attr in attr_list: | ||
4659 | 144 | index += 1 | ||
4660 | 145 | attr_data = { | ||
4661 | 146 | #'id': False, | ||
4662 | 147 | 'label': '', | ||
4663 | 148 | #'position': False, | ||
4664 | 149 | 'values': [], | ||
4665 | 150 | 'attribute_id': attr.magento_id, # id of the attribute on magento | ||
4666 | 151 | 'attribute_code': attr.attribute_code, # code of the attribute on magento | ||
4667 | 152 | 'frontend_label': attr.frontend_label, # label of the attribute on magento | ||
4668 | 153 | 'html_id': "config_super_product__attribute_%s" % index, # must be config_super_product__attribute_ with an increment | ||
4669 | 154 | } | ||
4670 | 155 | attr_values = [] | ||
4671 | 156 | for prod_id in products_data: | ||
4672 | 157 | [attr_values.append(products_data[prod_id][key]) for key in products_data[prod_id] if products_data[prod_id][key]['attribute_id'] == attr.magento_id] | ||
4673 | 158 | attr_data.update({'values': attr_values}) | ||
4674 | 159 | attributes_data.update({str(index): attr_data}) | ||
4675 | 160 | data.update({'configurable_products_data': products_data, 'configurable_attributes_data': attributes_data, 'associated_skus':associated_skus}) | ||
4676 | 161 | return data | ||
4677 | 162 | |||
4678 | 163 | |||
4679 | 164 | def ext_create(self, cr, uid, data, conn, method, oe_id, context): | ||
4680 | 165 | if data.get('type_id', False) == 'configurable': | ||
4681 | 166 | data = self.add_data_to_create_configurable_product(cr, uid, oe_id, data, context) | ||
4682 | 167 | return super(product_product, self).ext_create(cr, uid, data, conn, method, oe_id, context) | ||
4683 | 168 | |||
4684 | 169 | def extdata_from_oevals(self, cr, uid, external_referential_id, data_record, mapping_lines, defaults, context=None): | ||
4685 | 170 | #TODO maybe this mapping can be in the mapping template but the problem is that this mapping have to be apply at the end | ||
4686 | 171 | #because they will overwrite other mapping result. Maybe adding a sequence on the mapping will be the solution | ||
4687 | 172 | res = super(product_product, self).extdata_from_oevals(cr, uid, external_referential_id, data_record, mapping_lines, defaults, context) | ||
4688 | 173 | if data_record.get('is_multi_variants', False): | ||
4689 | 174 | for dim_value in self.pool.get('product.variant.dimension.value').browse(cr, uid, data_record['dimension_value_ids'], context=context): | ||
4690 | 175 | res[dim_value.dimension_id.magento_attribut.attribute_code] = dim_value.option_id.magento_attribut_option.value | ||
4691 | 176 | return res | ||
4692 | 177 | >>>>>>> MERGE-SOURCE | ||
4693 | 89 | 178 | ||
4694 | 90 | def _filter_fields_to_return(self, cr, uid, field_names, context): | 179 | def _filter_fields_to_return(self, cr, uid, field_names, context): |
4695 | 91 | #In the cas that the magento view is open from the button 'open magento fields', we can give a very customize view because only on for one product | 180 | #In the cas that the magento view is open from the button 'open magento fields', we can give a very customize view because only on for one product |