Merge lp:~sebastien.beau/magentoerpconnect/oerp6.1-cleanning into lp:magentoerpconnect/oerp6.1-stable
- oerp6.1-cleanning
- Merge into oerp6.1-stable
Status: | Merged |
---|---|
Merged at revision: | 678 |
Proposed branch: | lp:~sebastien.beau/magentoerpconnect/oerp6.1-cleanning |
Merge into: | lp:magentoerpconnect/oerp6.1-stable |
Diff against target: |
4911 lines (+1653/-1559) 65 files modified
magento_product_auto_sku/__openerp__.py (+1/-1) magento_product_auto_sku/data.xml (+3/-3) magento_product_auto_sku/product.py (+9/-15) magento_sku_is_code/__init__.py (+0/-22) magento_sku_is_code/__openerp__.py (+0/-41) magento_sku_is_code/product.py (+0/-66) magento_sku_is_code/product_view.xml (+0/-24) magentoerpconnect/__openerp__.py (+2/-2) magentoerpconnect/delivery.py (+6/-4) magentoerpconnect/delivery_view.xml (+2/-2) magentoerpconnect/invoice.py (+76/-27) magentoerpconnect/magerp_core.py (+26/-26) magentoerpconnect/magerp_core_view.xml (+152/-156) magentoerpconnect/magerp_data.xml (+10/-10) magentoerpconnect/magerp_menu.xml (+1/-1) magentoerpconnect/magerp_osv.py (+67/-64) magentoerpconnect/partner.py (+49/-49) magentoerpconnect/partner_view.xml (+2/-6) magentoerpconnect/product.py (+151/-186) magentoerpconnect/product_images.py (+25/-19) magentoerpconnect/product_images_view.xml (+21/-21) magentoerpconnect/product_links.py (+6/-10) magentoerpconnect/product_view.xml (+310/-310) magentoerpconnect/sale.py (+40/-37) magentoerpconnect/sale_view.xml (+72/-42) magentoerpconnect/server_tmp.patch (+0/-14) magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv (+53/-53) magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv (+8/-8) magentoerpconnect/settings/1.5.0.0/product/external.mappinglines.template.csv (+1/-1) magentoerpconnect/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv (+13/-2) magentoerpconnect/settings/1.5.0.0/res.partner/external.mappinglines.template.csv (+2/-1) magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv (+3/-2) magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv (+14/-3) magentoerpconnect/stock.py (+4/-7) magentoerpconnect/wizard/open_product_by_attribut_set.py (+5/-7) magentoerpconnect_bundle/__openerp__.py (+3/-3) magentoerpconnect_bundle/product.py (+9/-16) magentoerpconnect_bundle/product_view.xml (+31/-31) magentoerpconnect_bundle/sale.py (+4/-6) magentoerpconnect_bundle/sale_bundle_product.py (+6/-16) magentoerpconnect_bundle/sale_bundle_product_view.xml (+14/-14) magentoerpconnect_bundle_split/__openerp__.py (+1/-1) magentoerpconnect_bundle_split/sale.py (+16/-21) magentoerpconnect_bundle_split/stock.py (+8/-14) magentoerpconnect_customer_fiscal_category/__openerp__.py (+2/-2) magentoerpconnect_customer_fiscal_category/settings/1.5.0.0/external.mappinglines.template.csv (+2/-7) magentoerpconnect_init_stock/__openerp__.py (+1/-1) magentoerpconnect_init_stock/product.py (+2/-5) magentoerpconnect_magento_invoice/__init__.py (+28/-0) magentoerpconnect_magento_invoice/__openerp__.py (+44/-0) magentoerpconnect_magento_invoice/account.py (+35/-0) magentoerpconnect_openerp_invoice/__init__.py (+1/-5) magentoerpconnect_openerp_invoice/__openerp__.py (+9/-5) magentoerpconnect_openerp_invoice/external_referential.py (+33/-0) magentoerpconnect_openerp_invoice/external_referential_view.xml (+22/-0) magentoerpconnect_openerp_invoice/invoice.py (+57/-24) magentoerpconnect_partner_surname/__init__.py (+21/-0) magentoerpconnect_partner_surname/__openerp__.py (+43/-0) magentoerpconnect_partner_surname/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv (+3/-0) magentoerpconnect_payment/__openerp__.py (+1/-1) magentoerpconnect_payment/payment_type.py (+6/-8) magentoerpconnect_payment/sale.py (+18/-20) magentoerpconnect_product_variant/__openerp__.py (+3/-3) magentoerpconnect_product_variant/product.py (+20/-38) magentoerpconnect_product_variant/product_view.xml (+76/-76) |
To merge this branch: | bzr merge lp:~sebastien.beau/magentoerpconnect/oerp6.1-cleanning |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Fayolle - camptocamp | code review, no test | Approve | |
Guewen Baconnier @ Camptocamp | no test, review | Needs Fixing | |
Review via email: mp+135024@code.launchpad.net |
Commit message
Description of the change
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
invoice.py
==========
map_magento_order is puzzling to me : it can return True or an invoice id, and there's a case where no id is mapped and nothing is logged (case when len(invoice_ids) != 1). This is probably something which should not happen, but I'd rather have a trace of the event.
in create_
magerp_core.py
===============
one leftover TODO (non blocking for the review)
product.py
==========
in _get_oe_resources, use iteritems rather than items (avoid generating a useless python list)
product_images.py
=================
not your fault, I could not understand the meaning of the comments at the beginning of the file. If you have a clearer idea of what is meant, clarification is welcome.
These are minor points, no need to resubmit before merging.
Thanks for your work.
- 678. By Sébastien BEAU - http://www.akretion.com
-
[MERGE] merge with cleaning branch, please do not forget to update dependency, product-
extra-addons, openobject- extention, e-commerce-adddons. magentoerpconnect :
- REFACTOR
- refactor the invoice syncronisation
2 modules are available, 1 for using Magento Invoice, one for using OpenERP invoice
moreover if invoice syncronisation failed try to map if an existing one already exist : fonction => map_magento_order
- refactor view for compatibility in multi-e-commerce solution
- NAME REFACTOR : by default use only name if you need to use the lastname and firstname please first update magentoerpconnect and them install magentoerpconnect_partner_ surname. DO IT ON A DATABASE TEST BEFORE. If you have any trouble please open a bug on lp
- use new api for moving the category and updating the stock informationADD
- add reporting when exporting stock level
Preview Diff
1 | === modified file 'magento_product_auto_sku/__openerp__.py' |
2 | --- magento_product_auto_sku/__openerp__.py 2012-03-15 09:47:04 +0000 |
3 | +++ magento_product_auto_sku/__openerp__.py 2012-12-03 15:22:20 +0000 |
4 | @@ -20,7 +20,7 @@ |
5 | ############################################################################## |
6 | { |
7 | 'name' : 'magento_product_auto_sku', |
8 | - 'version' : '1.0', |
9 | + 'version' : '6.1.0', |
10 | 'depends' : ['base', 'product', 'magentoerpconnect'], |
11 | 'author' : 'Camptocamp', |
12 | 'license': 'AGPL-3', |
13 | |
14 | === modified file 'magento_product_auto_sku/data.xml' |
15 | --- magento_product_auto_sku/data.xml 2011-06-07 14:51:43 +0000 |
16 | +++ magento_product_auto_sku/data.xml 2012-12-03 15:22:20 +0000 |
17 | @@ -11,8 +11,8 @@ |
18 | <field name="name">Product Magento SKU</field> |
19 | <field name="code">product.magento.sku</field> |
20 | <field name="prefix">%(year)s/</field> |
21 | - <field name="padding">5</field> |
22 | - </record> |
23 | - |
24 | + <field name="padding">5</field> |
25 | + </record> |
26 | + |
27 | </data> |
28 | </openerp> |
29 | |
30 | === modified file 'magento_product_auto_sku/product.py' |
31 | --- magento_product_auto_sku/product.py 2012-03-15 09:47:04 +0000 |
32 | +++ magento_product_auto_sku/product.py 2012-12-03 15:22:20 +0000 |
33 | @@ -17,25 +17,19 @@ |
34 | # You should have received a copy of the GNU Affero General Public License |
35 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
36 | # |
37 | -############################################################################## |
38 | -from osv import osv, fields |
39 | - |
40 | - |
41 | -class Product(osv.osv): |
42 | +############################################################################## |
43 | +from openerp.osv.orm import Model |
44 | +from openerp.osv import fields |
45 | + |
46 | +class Product(Model): |
47 | " Inherit product to add the sequence on the Magento SKU field" |
48 | _inherit = 'product.product' |
49 | - |
50 | - _columns = { |
51 | - 'magento_sku':fields.char('Magento SKU', size=64, readonly=True), |
52 | - } |
53 | - |
54 | - _defaults = { |
55 | - 'magento_sku':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'product.magento.sku'), |
56 | - } |
57 | + _columns = {'magento_sku':fields.char('Magento SKU', size=64, readonly=True), |
58 | + } |
59 | + _defaults = {'magento_sku':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'product.magento.sku'), |
60 | + } |
61 | |
62 | def copy(self, cr, uid, id, default=None, context=None): |
63 | default['magento_sku'] = self.pool.get('ir.sequence').get(cr, uid, 'product.magento.sku') |
64 | return super(Product, self).copy(cr, uid, id, default=default, context=context) |
65 | |
66 | -Product() |
67 | - |
68 | |
69 | === removed directory 'magento_sku_is_code' |
70 | === removed file 'magento_sku_is_code/__init__.py' |
71 | --- magento_sku_is_code/__init__.py 2012-03-15 09:47:04 +0000 |
72 | +++ magento_sku_is_code/__init__.py 1970-01-01 00:00:00 +0000 |
73 | @@ -1,22 +0,0 @@ |
74 | -# -*- coding: utf-8 -*- |
75 | -############################################################################## |
76 | -# |
77 | -# Author: Guewen Baconnier |
78 | -# Copyright 2011-2012 Camptocamp SA |
79 | -# |
80 | -# This program is free software: you can redistribute it and/or modify |
81 | -# it under the terms of the GNU Affero General Public License as |
82 | -# published by the Free Software Foundation, either version 3 of the |
83 | -# License, or (at your option) any later version. |
84 | -# |
85 | -# This program is distributed in the hope that it will be useful, |
86 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
87 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
88 | -# GNU Affero General Public License for more details. |
89 | -# |
90 | -# You should have received a copy of the GNU Affero General Public License |
91 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
92 | -# |
93 | -############################################################################## |
94 | - |
95 | -import product |
96 | |
97 | === removed file 'magento_sku_is_code/__openerp__.py' |
98 | --- magento_sku_is_code/__openerp__.py 2012-03-15 09:47:04 +0000 |
99 | +++ magento_sku_is_code/__openerp__.py 1970-01-01 00:00:00 +0000 |
100 | @@ -1,41 +0,0 @@ |
101 | -# -*- coding: utf-8 -*- |
102 | -############################################################################## |
103 | -# |
104 | -# Author: Guewen Baconnier |
105 | -# Copyright 2011-2012 Camptocamp SA |
106 | -# |
107 | -# This program is free software: you can redistribute it and/or modify |
108 | -# it under the terms of the GNU Affero General Public License as |
109 | -# published by the Free Software Foundation, either version 3 of the |
110 | -# License, or (at your option) any later version. |
111 | -# |
112 | -# This program is distributed in the hope that it will be useful, |
113 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
114 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
115 | -# GNU Affero General Public License for more details. |
116 | -# |
117 | -# You should have received a copy of the GNU Affero General Public License |
118 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
119 | -# |
120 | -############################################################################## |
121 | - |
122 | -{ |
123 | - "name" : "Magento sku is product's code", |
124 | - "version" : "1.0", |
125 | - "depends" : ["base", |
126 | - "product", |
127 | - "magentoerpconnect",], |
128 | - "author" : "Camptocamp", |
129 | - "license": 'AGPL-3', |
130 | - "description": """Use product's code as SKU for Magento. |
131 | - Once exported to Magento, the Magento SKU is not changed, even if you change the product's code. |
132 | -""", |
133 | - "website" : "http://www.camptocamp.com", |
134 | - "category" : "Generic Modules", |
135 | - "init_xml" : [], |
136 | - "demo_xml" : [], |
137 | - "update_xml" : ['product_view.xml'], |
138 | - "active": False, |
139 | - "installable": True, |
140 | - |
141 | -} |
142 | |
143 | === removed directory 'magento_sku_is_code/i18n' |
144 | === removed file 'magento_sku_is_code/product.py' |
145 | --- magento_sku_is_code/product.py 2012-03-15 09:47:04 +0000 |
146 | +++ magento_sku_is_code/product.py 1970-01-01 00:00:00 +0000 |
147 | @@ -1,66 +0,0 @@ |
148 | -# -*- coding: utf-8 -*- |
149 | -############################################################################## |
150 | -# |
151 | -# Author: Guewen Baconnier |
152 | -# Copyright 2011-2012 Camptocamp SA |
153 | -# |
154 | -# This program is free software: you can redistribute it and/or modify |
155 | -# it under the terms of the GNU Affero General Public License as |
156 | -# published by the Free Software Foundation, either version 3 of the |
157 | -# License, or (at your option) any later version. |
158 | -# |
159 | -# This program is distributed in the hope that it will be useful, |
160 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
161 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
162 | -# GNU Affero General Public License for more details. |
163 | -# |
164 | -# You should have received a copy of the GNU Affero General Public License |
165 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
166 | -# |
167 | -############################################################################## |
168 | - |
169 | -from osv import osv, fields |
170 | - |
171 | - |
172 | -class Product(osv.osv): |
173 | - """Inherit product to use the default code as the Magento SKU. Copy the default code into the magento_sku field.""" |
174 | - _inherit = 'product.product' |
175 | - |
176 | - _columns = {'magento_sku':fields.char('Magento SKU', size=64, readonly=True),} |
177 | - |
178 | - _sql_constraints = [('code_uniq', 'unique(default_code)', 'The code must be unique')] |
179 | - |
180 | - def _get_sku(self, cr, uid, vals, product=None, context=None): |
181 | - """ |
182 | - Returns the SKU value. |
183 | - @param vals: vals to be created / modified |
184 | - @param product: optional browse instance of the product (when writing) |
185 | - """ |
186 | - return vals['default_code'] |
187 | - |
188 | - def create(self, cr, uid, vals, context=None): |
189 | - if vals.get('default_code'): |
190 | - vals['magento_sku'] = self._get_sku(cr, uid, vals, context=context) |
191 | - return super(Product, self).create(cr, uid, vals, context) |
192 | - |
193 | - def write(self, cr, uid, ids, vals, context=None): |
194 | - if isinstance(ids, (int, long)): |
195 | - ids = [ids] |
196 | - ids_to_write = ids[:] |
197 | - if vals.get('default_code'): |
198 | - for product in self.browse(cr, uid, ids, context=context): |
199 | - # write separately on each product if they are not already exported |
200 | - if not product.magento_exported: |
201 | - new_vals = vals.copy() |
202 | - new_vals['magento_sku'] = self._get_sku(cr, uid, new_vals, product=product, context=context) |
203 | - super(Product, self).write(cr, uid, [product.id], new_vals, context=context) |
204 | - ids_to_write.remove(product.id) |
205 | - |
206 | - return super(Product, self).write(cr, uid, ids_to_write, vals, context=context) |
207 | - |
208 | - def copy(self, cr, uid, id, default=None, context=None): |
209 | - if not default is None: default = {} |
210 | - default['default_code'] = False |
211 | - return super(Product, self).copy(cr, uid, id, default=default, context=context) |
212 | - |
213 | -Product() |
214 | |
215 | === removed file 'magento_sku_is_code/product_view.xml' |
216 | --- magento_sku_is_code/product_view.xml 2011-11-28 10:01:34 +0000 |
217 | +++ magento_sku_is_code/product_view.xml 1970-01-01 00:00:00 +0000 |
218 | @@ -1,24 +0,0 @@ |
219 | -<?xml version="1.0" encoding="utf-8"?> |
220 | -<openerp> |
221 | - <data> |
222 | - <record model="ir.ui.view" id="product_product_form_view_magerp_sku"> |
223 | - <field name="name">product.normal.form_magerp.sku</field> |
224 | - <field name="model">product.product</field> |
225 | - <field name="type">form</field> |
226 | - <field name="inherit_id" ref="magentoerpconnect.product_product_form_view_magerp"/> |
227 | - <field name="arch" type="xml"> |
228 | - <data> |
229 | - <field name="default_code" position="attributes"> |
230 | - <attribute name="attrs">{'required':[('magento_exportable','=',True)]}</attribute> |
231 | - </field> |
232 | - <field name="magento_sku" position="attributes"> |
233 | - <attribute name="attrs"/> |
234 | - </field> |
235 | - <field name="magento_sku" position="attributes"> |
236 | - <attribute name="readonly">True</attribute> |
237 | - </field> |
238 | - </data> |
239 | - </field> |
240 | - </record> |
241 | - </data> |
242 | -</openerp> |
243 | |
244 | === removed directory 'magento_sku_is_code/security' |
245 | === modified file 'magentoerpconnect/__openerp__.py' |
246 | --- magentoerpconnect/__openerp__.py 2012-05-16 08:01:05 +0000 |
247 | +++ magentoerpconnect/__openerp__.py 2012-12-03 15:22:20 +0000 |
248 | @@ -18,14 +18,14 @@ |
249 | ######################################################################### |
250 | { |
251 | "name" : "Magento e-commerce", |
252 | - "version" : "1.0", |
253 | + "version" : "6.1.1", |
254 | "depends" : ["base", |
255 | "product", |
256 | "product_m2mcategories", |
257 | 'delivery', |
258 | "base_sale_multichannels", |
259 | "product_images_olbs", |
260 | - "product_links", |
261 | + "product_links_sync", |
262 | ], |
263 | "author" : "MagentoERPconnect Core Editors", |
264 | "description": """Magento E-commerce management |
265 | |
266 | === modified file 'magentoerpconnect/delivery.py' |
267 | --- magentoerpconnect/delivery.py 2012-03-27 09:52:57 +0000 |
268 | +++ magentoerpconnect/delivery.py 2012-12-03 15:22:20 +0000 |
269 | @@ -19,10 +19,12 @@ |
270 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
271 | ######################################################################### |
272 | |
273 | -from osv import fields,osv |
274 | -from tools.translate import _ |
275 | +from openerp.osv.orm import Model |
276 | +from openerp.osv import fields |
277 | +from openerp.osv.osv import except_osv |
278 | +from openerp.tools.translate import _ |
279 | |
280 | -class delivery_carrier(osv.osv): |
281 | +class delivery_carrier(Model): |
282 | _inherit = "delivery.carrier" |
283 | |
284 | def _carrier_code(self, cr, uid, ids, name, args, context=None): |
285 | @@ -57,7 +59,7 @@ |
286 | carrier = self.read( |
287 | cr, uid, id, ['magento_carrier_code', 'name'], context=context) |
288 | if not carrier['magento_carrier_code'] in mag_carrier.keys(): |
289 | - raise osv.except_osv( |
290 | + raise except_osv( |
291 | _("Error"), |
292 | _("The carrier %s doesn't have a magento_code valid !" |
293 | "The value %s is not in the carrier list %s " |
294 | |
295 | === modified file 'magentoerpconnect/delivery_view.xml' |
296 | --- magentoerpconnect/delivery_view.xml 2011-06-07 14:33:14 +0000 |
297 | +++ magentoerpconnect/delivery_view.xml 2012-12-03 15:22:20 +0000 |
298 | @@ -10,8 +10,8 @@ |
299 | <field name="arch" type="xml"> |
300 | <data> |
301 | <field name="product_id" select="1" position="after"> |
302 | - <field name="magento_code"/> |
303 | - <field name="magento_tracking_title"/> |
304 | + <field name="magento_code"/> |
305 | + <field name="magento_tracking_title"/> |
306 | </field> |
307 | </data> |
308 | </field> |
309 | |
310 | === modified file 'magentoerpconnect/invoice.py' |
311 | --- magentoerpconnect/invoice.py 2012-06-01 17:48:14 +0000 |
312 | +++ magentoerpconnect/invoice.py 2012-12-03 15:22:20 +0000 |
313 | @@ -21,26 +21,27 @@ |
314 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
315 | ######################################################################### |
316 | |
317 | -from osv import osv, fields |
318 | -from tools.translate import _ |
319 | +from openerp.osv.orm import Model |
320 | +from openerp.osv import fields |
321 | +from openerp.tools.translate import _ |
322 | +from base_external_referentials.external_osv import ExternalSession |
323 | +from openerp.osv.osv import except_osv |
324 | |
325 | -class account_invoice(osv.osv): |
326 | +class account_invoice(Model): |
327 | _inherit = "account.invoice" |
328 | - |
329 | _columns = { |
330 | 'magento_ref':fields.char('Magento REF', size=32), |
331 | - } |
332 | - |
333 | - |
334 | -#TODO instead of calling again the sale order information |
335 | -# it will be better to store the ext_id of each sale order line |
336 | -#Moreover some code should be share between the partial export of picking and invoice |
337 | - |
338 | + } |
339 | + |
340 | + |
341 | + #TODO instead of calling again the sale order information |
342 | + # it will be better to store the ext_id of each sale order line |
343 | + #Moreover some code should be share between the partial export of picking and invoice |
344 | def add_invoice_line(self, cr, uid, lines, line, context=None): |
345 | """ A line to add in the invoice is a dict with : product_id and product_qty keys.""" |
346 | line_info = {'product_id': line.product_id.id, |
347 | 'product_qty': line.quantity, |
348 | - } |
349 | + } |
350 | lines.append(line_info) |
351 | return lines |
352 | |
353 | @@ -55,7 +56,7 @@ |
354 | for item in order_items: |
355 | product_2_item.update({self.pool.get('product.product').get_oeid(cr, uid, item['product_id'], |
356 | external_session.referential_id.id, context={}): item['item_id']}) |
357 | - |
358 | + |
359 | lines = [] |
360 | # get product and quantities to invoice from the invoice |
361 | for line in invoice.invoice_line: |
362 | @@ -70,31 +71,80 @@ |
363 | item_qty.update({product_2_item[line['product_id']]: line['product_qty']}) |
364 | return item_qty |
365 | |
366 | + def map_magento_order(self, cr, uid, external_session, invoice_id, order_increment_id, context=None): |
367 | + #TODO Error should be catch by the external report system (need some improvement before) |
368 | + #For now error are just logged into the OpenERP log file |
369 | + try: |
370 | + external_session.logger.warning('Try to map the invoice with an existing order') |
371 | + invoice_ids = external_session.connection.call('sales_order.get_invoice_ids', [order_increment_id]) |
372 | + #TODO support mapping for partiel invoice if needed |
373 | + if len(invoice_ids) == 1: |
374 | + external_session.logger.info( |
375 | + 'Success to map the invoice %s with an existing order for the order %s.' |
376 | + %(invoice_ids[0], order_increment_id)) |
377 | + return invoice_ids[0] |
378 | + else: |
379 | + external_session.logger.error( |
380 | + 'Failed to map the invoice %s with an existing order for the order %s. Too many invoice found' |
381 | + %(invoice_ids[0], order_increment_id)) |
382 | + return False |
383 | + except Exception, e: |
384 | + external_session.logger.error( |
385 | + 'Failed to map the invoice with an existing order for the order %s. Error : %s' |
386 | + %(order_increment_id, e)) |
387 | + return False |
388 | + |
389 | def create_magento_invoice(self, cr, uid, external_session, invoice_id, order_increment_id, context=None): |
390 | item_qty = self.get_invoice_items(cr, uid, external_session, invoice_id, order_increment_id, context=context) |
391 | try: |
392 | return external_session.connection.call('sales_order_invoice.create', [order_increment_id, |
393 | item_qty, _('Invoice Created'), False, False]) |
394 | except Exception, e: |
395 | - external_session.logger.warning(_('Can not create the invoice for the order %s in the external system. Error : %s')%(order_increment_id, e)) |
396 | - return False |
397 | + external_session.logger.warning( |
398 | + 'Can not create the invoice for the order %s in the external system. Error : %s' |
399 | + %(order_increment_id, e)) |
400 | + invoice_id = self.map_magento_order(cr, uid, external_session, invoice_id, order_increment_id, context=context) |
401 | + if invoice_id: |
402 | + return invoice_id |
403 | + else: |
404 | + raise except_osv(_('Magento Error'), _('Failed to synchronize Magento invoice with OpenERP invoice')) |
405 | |
406 | def ext_create(self, cr, uid, external_session, resources, mapping=None, mapping_id=None, context=None): |
407 | ext_create_ids={} |
408 | for resource_id, resource in resources.items(): |
409 | - resource = resource[resource.keys()[0]] |
410 | - if resource['type'] == 'out_invoice': |
411 | - ext_create_ids[resource_id] = self.create_magento_invoice(cr, uid, external_session, |
412 | - resource_id, resource['order_increment_id'], context=context) |
413 | + res = self.ext_create_one_invoice(cr, uid, external_session, resource_id, resource, context=context) |
414 | + if res: |
415 | + ext_create_ids[resource_id] = res |
416 | return ext_create_ids |
417 | |
418 | -account_invoice() |
419 | - |
420 | - |
421 | -class account_invoice_line(osv.osv): |
422 | - |
423 | + def ext_create_one_invoice(self, cr, uid, external_session, resource_id, resource, context=None): |
424 | + resource = resource[resource.keys()[0]] |
425 | + if resource['type'] == 'out_invoice': |
426 | + return self.create_magento_invoice(cr, uid, external_session, |
427 | + resource_id, resource['order_increment_id'], context=context) |
428 | + return False |
429 | + |
430 | + def _export_one_invoice(self, cr, uid, invoice, context=None): |
431 | + if invoice.sale_ids: |
432 | + sale = invoice.sale_ids[0] |
433 | + referential = sale.shop_id.referential_id |
434 | + if referential and referential.type_name == 'Magento': |
435 | + ext_id = invoice.get_extid(referential.id) |
436 | + if ext_id: |
437 | + return ext_id |
438 | + else: |
439 | + external_session = ExternalSession(referential, sale.shop_id) |
440 | + return self._export_one_resource(cr, uid, external_session, invoice.id, |
441 | + context=context) |
442 | + |
443 | + def export_invoice(self, cr, uid, ids, context=None): |
444 | + for invoice in self .browse(cr, uid, ids, context=context): |
445 | + self._export_one_invoice(cr, uid, invoice, context=context) |
446 | + return True |
447 | + |
448 | + |
449 | +class account_invoice_line(Model): |
450 | _inherit = 'account.invoice.line' |
451 | - |
452 | _columns = { |
453 | # Forced the precision of the account.invoice.line discount field |
454 | # to 3 digits in order to be able to have the same amount as Magento. |
455 | @@ -103,5 +153,4 @@ |
456 | # With a 2 digits precision, we can have 50.17 % => 148.99 or 50.16% => 149.02. |
457 | # Force the digits to 3 allows to have 50.167% => 149€ |
458 | 'discount': fields.float('Discount (%)', digits=(16, 3)), |
459 | - } |
460 | -account_invoice_line() |
461 | + } |
462 | |
463 | === modified file 'magentoerpconnect/magerp_core.py' |
464 | --- magentoerpconnect/magerp_core.py 2012-05-25 15:37:26 +0000 |
465 | +++ magentoerpconnect/magerp_core.py 2012-12-03 15:22:20 +0000 |
466 | @@ -22,24 +22,30 @@ |
467 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
468 | ######################################################################### |
469 | |
470 | -from osv import osv, fields |
471 | -import magerp_osv |
472 | -import pooler |
473 | -import base64, urllib |
474 | -from magerp_osv import Connection |
475 | -import tools |
476 | -from tools.translate import _ |
477 | import os |
478 | +import logging |
479 | + |
480 | +from openerp.osv import fields |
481 | +from openerp.osv.osv import except_osv |
482 | +from openerp import pooler |
483 | +from openerp import tools |
484 | +from openerp.tools.translate import _ |
485 | + |
486 | +from .magerp_osv import MagerpModel, Connection |
487 | from base_external_referentials.decorator import only_for_referential |
488 | from base_external_referentials.external_osv import ExternalSession |
489 | |
490 | -import logging |
491 | +from base_external_referentials.external_referentials import REF_VISIBLE_FIELDS |
492 | + |
493 | +REF_VISIBLE_FIELDS['Magento'] = ['location', 'apiusername', 'apipass'] |
494 | + |
495 | + |
496 | _logger = logging.getLogger(__name__) |
497 | |
498 | DEBUG = True |
499 | TIMEOUT = 2 |
500 | |
501 | -class external_referential(magerp_osv.magerp_osv): |
502 | +class external_referential(MagerpModel): |
503 | #This class stores instances of magento to which the ERP will connect, so you can connect OpenERP to multiple Magento installations (eg different Magento databases) |
504 | _inherit = "external.referential" |
505 | |
506 | @@ -209,7 +215,7 @@ |
507 | if lang_id: |
508 | lang = lang_id.code |
509 | else: |
510 | - osv.except_osv(_('Warning!'), _('The storeviews have no language defined')) |
511 | + except_osv(_('Warning!'), _('The storeviews have no language defined')) #TODO needed? |
512 | lang = referential.default_lang_id.code |
513 | if not lang_2_storeview.get(lang, False): |
514 | lang_2_storeview[lang] = storeview |
515 | @@ -282,6 +288,7 @@ |
516 | shop.export_products(cr, uid, shop, context) |
517 | return True |
518 | |
519 | + #TODO refactor me |
520 | def sync_partner(self, cr, uid, ids, context=None): |
521 | def next_partners(connection, start, step): |
522 | filters = {'customer_id': {'in': range(start, start + step)}} |
523 | @@ -308,11 +315,10 @@ |
524 | address_info = customer_address_info[0] |
525 | address_info['customer_id'] = ext_customer_id |
526 | address_info['email'] = customer_info['email'] |
527 | - |
528 | - self.pool.get('res.partner').ext_import(import_cr, uid, [customer_info], referential.id, context=context) |
529 | + external_session = ExternalSession(referential, referential) |
530 | + self.pool.get('res.partner')._record_one_external_resource(import_cr, uid, external_session, customer_info, context=context) |
531 | if address_info: |
532 | - self.pool.get('res.partner.address').ext_import(import_cr, uid, [address_info], referential.id, context=context) |
533 | - |
534 | + self.pool.get('res.partner.address')._record_one_external_resource(import_cr, uid, external_session, address_info, context=context) |
535 | last_imported_id = int(ext_customer_id) |
536 | self.write(import_cr, uid, referential.id, {'last_imported_partner_id': last_imported_id}, context=context) |
537 | import_cr.commit() |
538 | @@ -382,10 +388,8 @@ |
539 | if DEBUG: |
540 | print "run_import_newsletter_unsubscriber_scheduler: %s" % referential_ids |
541 | |
542 | -external_referential() |
543 | - |
544 | - |
545 | -class external_shop_group(magerp_osv.magerp_osv): |
546 | + |
547 | +class external_shop_group(MagerpModel): |
548 | _inherit = "external.shop.group" |
549 | #Return format of API:{'code': 'base', 'name': 'Main', 'website_id': '1', 'is_default': '1', 'sort_order': '0', 'default_group_id': '1'} |
550 | # default_group_id is the default shop of the external_shop_group (external_shop_group = website) |
551 | @@ -407,12 +411,10 @@ |
552 | 'default_shop_integer_id':fields.integer('Default Store'), #This field can't be a many2one because shop_group field will be mapped before creating Shop (Shop = Store, shop_group = website) |
553 | 'default_shop_id':fields.function(_get_default_shop_id, type="many2one", relation="sale.shop", method=True, string="Default Store"), |
554 | 'referential_type' : fields.related('referential_id', 'type_id', type='many2one', relation='external.referential.type', string='External Referential Type'), |
555 | - } |
556 | - |
557 | -external_shop_group() |
558 | - |
559 | - |
560 | -class magerp_storeviews(magerp_osv.magerp_osv): |
561 | + } |
562 | + |
563 | + |
564 | +class magerp_storeviews(MagerpModel): |
565 | _name = "magerp.storeviews" |
566 | _description = "The magento store views information" |
567 | |
568 | @@ -427,5 +429,3 @@ |
569 | } |
570 | |
571 | #Return format of API:{'code': 'default', 'store_id': '1', 'website_id': '1', 'is_active': '1', 'sort_order': '0', 'group_id': '1', 'name': 'Default Store View'} |
572 | - |
573 | -magerp_storeviews() |
574 | |
575 | === modified file 'magentoerpconnect/magerp_core_view.xml' |
576 | --- magentoerpconnect/magerp_core_view.xml 2012-05-19 12:23:36 +0000 |
577 | +++ magentoerpconnect/magerp_core_view.xml 2012-12-03 15:22:20 +0000 |
578 | @@ -1,172 +1,168 @@ |
579 | <?xml version="1.0" encoding="utf-8"?> |
580 | <openerp> |
581 | - <data> |
582 | - <!--Magento Instances Tree/Form view --> |
583 | + <data> |
584 | + <!--Magento Instances Tree/Form view --> |
585 | |
586 | - <record model="ir.ui.view" id="magerp_instances_form"> |
587 | - <field name="name">External Referentials</field> |
588 | - <field name="model">external.referential</field> |
589 | - <field name="inherit_id" ref="base_external_referentials.external_referential_form_view" /> |
590 | - <field name="type">form</field> |
591 | - <field name="priority">30</field> |
592 | - <field name="arch" type="xml"> |
593 | - <xpath expr="/form/group[2]/notebook/page[@string='Referential Actions']" position="replace"> |
594 | - <page string="Referential Actions"> |
595 | - <separator string="Compulsory" colspan="4" /> |
596 | - <button name="refresh_mapping" string="1 - Reload Referential Mapping Templates" colspan="2" type="object" /> |
597 | - <button name="import_referentials" string="2 - Synchronize Referential Settings" colspan="2" type="object" attrs="{'readonly':[('mapping_ids','=',[])]}"/> |
598 | - <separator string="Optional - Initial import only" colspan="4" /> |
599 | - <button name="import_customer_groups" string="1 - Import Customer Groups (Partner Categories)" colspan="2" type="object" /> |
600 | - <group colspan="2" col="12"> |
601 | - <button name="sync_attribs" string="5 - Import Product Attributes" colspan="10" type="object" /> |
602 | - <field name="import_all_attributs"/> |
603 | - </group> |
604 | - <button name="import_product_categories" string="2 - Import Product Categories" colspan="2" type="object" /> |
605 | - <group colspan="2" col="14"> |
606 | + <record model="ir.ui.view" id="magerp_instances_form"> |
607 | + <field name="name">External Referentials</field> |
608 | + <field name="model">external.referential</field> |
609 | + <field name="inherit_id" ref="base_external_referentials.external_referential_form_view" /> |
610 | + <field name="type">form</field> |
611 | + <field name="priority">30</field> |
612 | + <field name="arch" type="xml"> |
613 | + <group name="compulsory" position="after"> |
614 | + <group name="magento" col="4" colspan="4" attrs="{'invisible': [['type_name', '!=', 'Magento']]}"> |
615 | + <separator string="Optional - Initial import only" colspan="4" /> |
616 | + <button name="import_customer_groups" string="1 - Import Customer Groups (Partner Categories)" colspan="2" type="object" /> |
617 | + <group colspan="2" col="12"> |
618 | + <button name="sync_attribs" string="5 - Import Product Attributes" colspan="10" type="object" /> |
619 | + <field name="import_all_attributs"/> |
620 | + </group> |
621 | + <button name="import_product_categories" string="2 - Import Product Categories" colspan="2" type="object" /> |
622 | + <group colspan="2" col="14"> |
623 | <group colspan="8"> |
624 | - <button name="sync_products" string="6 - Import Products" type="object" attrs="{'invisible':[('import_image_with_product','=',True)]}" /> |
625 | + <button name="sync_products" string="6 - Import Products" type="object" attrs="{'invisible':[('import_image_with_product','=',True)]}" /> |
626 | <button name="sync_products" string="6 - Import Products And Images" type="object" attrs="{'invisible':[('import_image_with_product','=',False)]}" /> |
627 | </group> |
628 | - <field name="import_image_with_product"/> |
629 | + <field name="import_image_with_product"/> |
630 | <field name="import_links_with_product"/> |
631 | - <field name="last_imported_product_id" string=""/> |
632 | - </group> |
633 | - <button name="sync_attrib_sets" string="3 - Import Product Attribute Sets" colspan="2" type="object" /> |
634 | - <button name="sync_images" string="7 - Import Images" colspan="2" type="object" attrs="{'invisible':[('import_image_with_product','=',True)]}"/> |
635 | - <button name="sync_attrib_groups" string="4 - Import Attribute Groups" colspan="2" type="object" /> |
636 | + <field name="last_imported_product_id" string=""/> |
637 | + </group> |
638 | + <button name="sync_attrib_sets" string="3 - Import Product Attribute Sets" colspan="2" type="object" /> |
639 | + <button name="sync_images" string="7 - Import Images" colspan="2" type="object" attrs="{'invisible':[('import_image_with_product','=',True)]}"/> |
640 | + <button name="sync_attrib_groups" string="4 - Import Attribute Groups" colspan="2" type="object" /> |
641 | <button name="sync_product_links" string="8 - Import Product Links" colspan="2" type="object" /> |
642 | - <separator string="Default values" colspan="4" /> |
643 | - <field name="default_pro_cat" required="1"/> |
644 | - <field name="default_lang_id" required="1"/> |
645 | -<!-- <button name="sync_customer_addresses" string="Sync Customer Addresses" colspan="2" type="object" />--> |
646 | -<!-- <button name="export_products" string="Export Products" colspan="2" type="object" />--> |
647 | - </page> |
648 | - </xpath> |
649 | + <separator string="Default values" colspan="4" /> |
650 | + <field name="default_pro_cat" attrs="{'required': [['type_name', '=', 'Magento']]}"/> |
651 | + <field name="default_lang_id" attrs="{'required': [['type_name', '=', 'Magento']]}"/> |
652 | + </group> |
653 | + </group> |
654 | |
655 | - <xpath expr="/form/group[2]/notebook" position="inside"> |
656 | - <page string="Websites"> |
657 | - <field name="shop_group_ids" nolabel="1" /> |
658 | - </page> |
659 | - <!-- <page string="Store Views"> |
660 | - <field name="storeviews" nolabel="1" /> |
661 | - </page> |
662 | - <page string="Groups (Stores)"> |
663 | - <field name="shop_ids" nolabel="1" /> |
664 | - </page>--> |
665 | - <page string="Product Attributes / Sets"> |
666 | - <newline /> |
667 | - <field name="attribute_sets" nolabel="1" colspan="4"/> |
668 | - </page> |
669 | - <page string="Advanced"> |
670 | + <notebook position="inside"> |
671 | + <page string="Websites" attrs="{'invisible': [['type_name', '!=', 'Magento']]}"> |
672 | + <field name="shop_group_ids" nolabel="1" /> |
673 | + </page> |
674 | + <!-- <page string="Store Views"> |
675 | + <field name="storeviews" nolabel="1" /> |
676 | + </page> |
677 | + <page string="Groups (Stores)"> |
678 | + <field name="shop_ids" nolabel="1" /> |
679 | + </page>--> |
680 | + <page string="Product Attributes / Sets" attrs="{'invisible': [['type_name', '!=', 'Magento']]}"> |
681 | + <newline /> |
682 | + <field name="attribute_sets" nolabel="1" colspan="4"/> |
683 | + </page> |
684 | + <page string="Advanced" attrs="{'invisible': [['type_name', '!=', 'Magento']]}"> |
685 | <separator string="Partner" colspan="4"/> |
686 | <group colspan="2" col="12"> |
687 | - <button name="sync_partner" string="Import All Partners" colspan="10" type="object" /> |
688 | + <button name="sync_partner" string="Import All Partners" colspan="10" type="object" /> |
689 | <field name="last_imported_partner_id" string=""/> |
690 | </group> |
691 | - <button name="sync_newsletter" string="Import Newsletter Subscribers" colspan="2" type="object" /> |
692 | - <button name="sync_newsletter_unsubscriber" string="Export Newsletter UnSubscribers" colspan="2" type="object" /> |
693 | + <button name="sync_newsletter" string="Import Newsletter Subscribers" colspan="2" type="object" /> |
694 | + <button name="sync_newsletter_unsubscriber" string="Export Newsletter UnSubscribers" colspan="2" type="object" /> |
695 | <separator string="Others" colspan="4"/> |
696 | <field name="active" select="2"/> |
697 | - </page> |
698 | - </xpath> |
699 | - </field> |
700 | - </record> |
701 | - <record id="act_magerp_instances_form" model="ir.actions.act_window"> |
702 | - <field name="name">Magento Instances</field> |
703 | - <field name="res_model">external.referential</field> |
704 | - <field name="type">ir.actions.act_window</field> |
705 | - <field name="view_type">form</field> |
706 | - <field name="view_mode">tree,form</field> |
707 | - <field name="view_id" ref="base_external_referentials.external_referential_tree_view" /> |
708 | - </record> |
709 | - |
710 | - <!--Magento Websites Tree/Form view --> |
711 | - <record model="ir.ui.view" id="magerp_websites_form"> |
712 | - <field name="name">external.shop.group.form</field> |
713 | - <field name="model">external.shop.group</field> |
714 | - <field name="type">form</field> |
715 | - <field name="arch" type="xml"> |
716 | - <form string="Magento websites"> |
717 | - <group col="4" colspan="4"> |
718 | - <field name="name" readonly="1" /> |
719 | - <field name="code" readonly="1" /> |
720 | - <field name="is_default" readonly="1" /> |
721 | - <field name="sort_order" readonly="1" /> |
722 | - <field name="default_shop_id" readonly="1" /> |
723 | - <field name="referential_id" readonly="1" /> |
724 | - </group> |
725 | - <group col="4" colspan="4"> |
726 | - <field name="shop_ids" readonly="1"/> |
727 | - </group> |
728 | - </form> |
729 | - </field> |
730 | - </record> |
731 | - <record model="ir.ui.view" id="magerp_websites_tree"> |
732 | - <field name="name">external.shop.group.tree</field> |
733 | - <field name="model">external.shop.group</field> |
734 | - <field name="type">tree</field> |
735 | - <field name="arch" type="xml"> |
736 | - <tree string="Magento websites"> |
737 | - <field name="name" readonly="1" select="1" /> |
738 | - <field name="code" readonly="1" select="1" /> |
739 | - <field name="is_default" readonly="1" select="2" /> |
740 | - <field name="sort_order" readonly="1" select="2" /> |
741 | - <field name="default_shop_id" readonly="1" select="2" /> |
742 | - <field name="shop_ids" readonly="1" /> |
743 | - </tree> |
744 | - </field> |
745 | - </record> |
746 | - <record id="act_magerp_websites_form" model="ir.actions.act_window"> |
747 | - <field name="name">Magento websites</field> |
748 | - <field name="res_model">external.shop.group</field> |
749 | - <field name="type">ir.actions.act_window</field> |
750 | - <field name="view_type">form</field> |
751 | - <field name="view_mode">tree,form</field> |
752 | - <field name="view_id" ref="magerp_websites_tree" /> |
753 | - </record> |
754 | - |
755 | - <!--Magento storeviews Tree/Form view --> |
756 | - <record model="ir.ui.view" id="magerp_storeviews_form"> |
757 | - <field name="name">magerp.storeviews.form</field> |
758 | - <field name="model">magerp.storeviews</field> |
759 | - <field name="type">form</field> |
760 | - <field name="arch" type="xml"> |
761 | - <form string="Magento storeviews"> |
762 | - <group col="4" colspan="4"> |
763 | - <field name="name" readonly="1" /> |
764 | - <field name="code" readonly="1" /> |
765 | - <field name="shop_id" readonly="1" /> |
766 | - <field name="website_id" readonly="1" /> |
767 | - <field name="is_active" readonly="1" /> |
768 | - <field name="sort_order" readonly="1" /> |
769 | - <field name="lang_id" /> |
770 | - </group> |
771 | - </form> |
772 | - </field> |
773 | - </record> |
774 | - <record model="ir.ui.view" id="magerp_storeviews_tree"> |
775 | - <field name="name">magerp.storeviews.tree</field> |
776 | - <field name="model">magerp.storeviews</field> |
777 | - <field name="type">tree</field> |
778 | - <field name="arch" type="xml"> |
779 | - <tree string="Magento storeviews"> |
780 | - <field name="name" readonly="1" select="1" /> |
781 | - <field name="code" readonly="1" select="1" /> |
782 | - <field name="shop_id" readonly="1" select="1" /> |
783 | - <field name="is_active" readonly="1" select="2" /> |
784 | - <field name="sort_order" readonly="1" select="2" /> |
785 | - <field name="lang_id" /> |
786 | - </tree> |
787 | - </field> |
788 | - </record> |
789 | - <record id="act_magerp_storeviews_form" model="ir.actions.act_window"> |
790 | - <field name="name">Magento storeviews</field> |
791 | - <field name="res_model">magerp.storeviews</field> |
792 | - <field name="type">ir.actions.act_window</field> |
793 | - <field name="view_type">form</field> |
794 | - <field name="view_mode">tree,form</field> |
795 | - <field name="view_id" ref="magerp_storeviews_tree" /> |
796 | - </record> |
797 | - |
798 | - </data> |
799 | + </page> |
800 | + </notebook> |
801 | + </field> |
802 | + </record> |
803 | + <record id="act_magerp_instances_form" model="ir.actions.act_window"> |
804 | + <field name="name">Magento Instances</field> |
805 | + <field name="res_model">external.referential</field> |
806 | + <field name="type">ir.actions.act_window</field> |
807 | + <field name="view_type">form</field> |
808 | + <field name="view_mode">tree,form</field> |
809 | + <field name="view_id" ref="base_external_referentials.external_referential_tree_view" /> |
810 | + <field name="domain">[['type_name', '=', 'Magento']]</field> |
811 | + </record> |
812 | + |
813 | + <!--Magento Websites Tree/Form view --> |
814 | + <record model="ir.ui.view" id="magerp_websites_form"> |
815 | + <field name="name">external.shop.group.form</field> |
816 | + <field name="model">external.shop.group</field> |
817 | + <field name="type">form</field> |
818 | + <field name="arch" type="xml"> |
819 | + <form string="Magento websites"> |
820 | + <group col="4" colspan="4"> |
821 | + <field name="name" readonly="1" /> |
822 | + <field name="code" readonly="1" /> |
823 | + <field name="is_default" readonly="1" /> |
824 | + <field name="sort_order" readonly="1" /> |
825 | + <field name="default_shop_id" readonly="1" /> |
826 | + <field name="referential_id" readonly="1" /> |
827 | + </group> |
828 | + <group col="4" colspan="4"> |
829 | + <field name="shop_ids" readonly="1"/> |
830 | + </group> |
831 | + </form> |
832 | + </field> |
833 | + </record> |
834 | + <record model="ir.ui.view" id="magerp_websites_tree"> |
835 | + <field name="name">external.shop.group.tree</field> |
836 | + <field name="model">external.shop.group</field> |
837 | + <field name="type">tree</field> |
838 | + <field name="arch" type="xml"> |
839 | + <tree string="Magento websites"> |
840 | + <field name="name" readonly="1" select="1" /> |
841 | + <field name="code" readonly="1" select="1" /> |
842 | + <field name="is_default" readonly="1" select="2" /> |
843 | + <field name="sort_order" readonly="1" select="2" /> |
844 | + <field name="default_shop_id" readonly="1" select="2" /> |
845 | + <field name="shop_ids" readonly="1" /> |
846 | + </tree> |
847 | + </field> |
848 | + </record> |
849 | + <record id="act_magerp_websites_form" model="ir.actions.act_window"> |
850 | + <field name="name">Magento websites</field> |
851 | + <field name="res_model">external.shop.group</field> |
852 | + <field name="type">ir.actions.act_window</field> |
853 | + <field name="view_type">form</field> |
854 | + <field name="view_mode">tree,form</field> |
855 | + <field name="view_id" ref="magerp_websites_tree" /> |
856 | + </record> |
857 | + |
858 | + <!--Magento storeviews Tree/Form view --> |
859 | + <record model="ir.ui.view" id="magerp_storeviews_form"> |
860 | + <field name="name">magerp.storeviews.form</field> |
861 | + <field name="model">magerp.storeviews</field> |
862 | + <field name="type">form</field> |
863 | + <field name="arch" type="xml"> |
864 | + <form string="Magento storeviews"> |
865 | + <group col="4" colspan="4"> |
866 | + <field name="name" readonly="1" /> |
867 | + <field name="code" readonly="1" /> |
868 | + <field name="shop_id" readonly="1" /> |
869 | + <field name="website_id" readonly="1" /> |
870 | + <field name="is_active" readonly="1" /> |
871 | + <field name="sort_order" readonly="1" /> |
872 | + <field name="lang_id" /> |
873 | + </group> |
874 | + </form> |
875 | + </field> |
876 | + </record> |
877 | + <record model="ir.ui.view" id="magerp_storeviews_tree"> |
878 | + <field name="name">magerp.storeviews.tree</field> |
879 | + <field name="model">magerp.storeviews</field> |
880 | + <field name="type">tree</field> |
881 | + <field name="arch" type="xml"> |
882 | + <tree string="Magento storeviews"> |
883 | + <field name="name" readonly="1" select="1" /> |
884 | + <field name="code" readonly="1" select="1" /> |
885 | + <field name="shop_id" readonly="1" select="1" /> |
886 | + <field name="is_active" readonly="1" select="2" /> |
887 | + <field name="sort_order" readonly="1" select="2" /> |
888 | + <field name="lang_id" /> |
889 | + </tree> |
890 | + </field> |
891 | + </record> |
892 | + <record id="act_magerp_storeviews_form" model="ir.actions.act_window"> |
893 | + <field name="name">Magento storeviews</field> |
894 | + <field name="res_model">magerp.storeviews</field> |
895 | + <field name="type">ir.actions.act_window</field> |
896 | + <field name="view_type">form</field> |
897 | + <field name="view_mode">tree,form</field> |
898 | + <field name="view_id" ref="magerp_storeviews_tree" /> |
899 | + </record> |
900 | + |
901 | + </data> |
902 | </openerp> |
903 | |
904 | === modified file 'magentoerpconnect/magerp_data.xml' |
905 | --- magentoerpconnect/magerp_data.xml 2012-06-21 17:33:57 +0000 |
906 | +++ magentoerpconnect/magerp_data.xml 2012-12-03 15:22:20 +0000 |
907 | @@ -1,7 +1,7 @@ |
908 | <?xml version="1.0"?> |
909 | <openerp> |
910 | - <data noupdate="1"> |
911 | - |
912 | + <data noupdate="1"> |
913 | + |
914 | |
915 | <record forcecreate="True" id="ir_cron_import_orders_scheduler_action" model="ir.cron"> |
916 | <field name="name">Magento Import Orders</field> |
917 | @@ -122,15 +122,15 @@ |
918 | <!-- |
919 | |
920 | <record id="payment_type1" model="base.sale.payment.type"> |
921 | - <field name="name">checkmo;cashondelivery</field> |
922 | - <field name="order_policy">manual</field> |
923 | - </record> |
924 | - |
925 | + <field name="name">checkmo;cashondelivery</field> |
926 | + <field name="order_policy">manual</field> |
927 | + </record> |
928 | + |
929 | <record id="payment_type2" model="base.sale.payment.type"> |
930 | - <field name="name">ccsave;free;googlecheckout;paypayl_express;paybox_system;paypal_standard;servired_standard;bbva;cofidis</field> |
931 | - <field name="order_policy">prepaid</field> |
932 | - </record> |
933 | + <field name="name">ccsave;free;googlecheckout;paypayl_express;paybox_system;paypal_standard;servired_standard;bbva;cofidis</field> |
934 | + <field name="order_policy">prepaid</field> |
935 | + </record> |
936 | |
937 | --> |
938 | - </data> |
939 | + </data> |
940 | </openerp> |
941 | |
942 | === modified file 'magentoerpconnect/magerp_menu.xml' |
943 | --- magentoerpconnect/magerp_menu.xml 2012-07-13 11:39:38 +0000 |
944 | +++ magentoerpconnect/magerp_menu.xml 2012-12-03 15:22:20 +0000 |
945 | @@ -2,7 +2,7 @@ |
946 | <openerp> |
947 | <data> |
948 | <menuitem id="menu_magerp" name="MagentoERPconnect" icon="terp-sale" |
949 | - web_icon="images/magento.png" |
950 | + web_icon="images/magento.png" |
951 | web_icon_hover="images/magento-hover.png"/> |
952 | |
953 | <menuitem id="menu_magerp_core" name="Core Settings" parent="menu_magerp" /> |
954 | |
955 | === modified file 'magentoerpconnect/magerp_osv.py' |
956 | --- magentoerpconnect/magerp_osv.py 2012-05-24 20:52:38 +0000 |
957 | +++ magentoerpconnect/magerp_osv.py 2012-12-03 15:22:20 +0000 |
958 | @@ -21,7 +21,6 @@ |
959 | ######################################################################### |
960 | |
961 | import time |
962 | -import datetime |
963 | import xmlrpclib |
964 | import urllib2 |
965 | import base64 |
966 | @@ -30,7 +29,9 @@ |
967 | |
968 | #NEW FEATURE |
969 | |
970 | -from osv import osv, fields |
971 | +from openerp.osv.orm import Model |
972 | +from openerp.osv.osv import except_osv |
973 | +from openerp import tools |
974 | from base_external_referentials.decorator import only_for_referential |
975 | from base_external_referentials.decorator import open_report |
976 | from base_external_referentials.decorator import catch_error_in_report |
977 | @@ -38,42 +39,42 @@ |
978 | import logging |
979 | _logger = logging.getLogger(__name__) |
980 | |
981 | -osv.osv.mag_transform_and_send_one_resource = osv.osv._transform_and_send_one_resource |
982 | +Model.mag_transform_and_send_one_resource = Model._transform_and_send_one_resource |
983 | |
984 | -@only_for_referential('magento', super_function = osv.osv.mag_transform_and_send_one_resource) |
985 | +@only_for_referential('magento', super_function = Model.mag_transform_and_send_one_resource) |
986 | @catch_error_in_report |
987 | def _transform_and_send_one_resource(self, cr, uid, external_session, *args, **kwargs): |
988 | return self.mag_transform_and_send_one_resource(cr, uid, external_session, *args, **kwargs) |
989 | |
990 | -osv.osv._transform_and_send_one_resource = _transform_and_send_one_resource |
991 | - |
992 | - |
993 | -osv.osv.mag_export_resources = osv.osv._export_resources |
994 | - |
995 | -@only_for_referential('magento', super_function = osv.osv.mag_export_resources) |
996 | +Model._transform_and_send_one_resource = _transform_and_send_one_resource |
997 | + |
998 | + |
999 | +Model.mag_export_resources = Model._export_resources |
1000 | + |
1001 | +@only_for_referential('magento', super_function = Model.mag_export_resources) |
1002 | @open_report |
1003 | def _export_resources(self, *args, **kwargs): |
1004 | return self.mag_export_resources( *args, **kwargs) |
1005 | -osv.osv._export_resources = _export_resources |
1006 | - |
1007 | - |
1008 | -osv.osv._mag_get_external_resource_ids = osv.osv._get_external_resource_ids |
1009 | - |
1010 | -@only_for_referential('magento', super_function = osv.osv._get_external_resource_ids) |
1011 | +Model._export_resources = _export_resources |
1012 | + |
1013 | + |
1014 | +Model._mag_get_external_resource_ids = Model._get_external_resource_ids |
1015 | + |
1016 | +@only_for_referential('magento', super_function = Model._get_external_resource_ids) |
1017 | def _get_external_resource_ids(self, cr, uid, external_session, resource_filter=None, mapping=None, mapping_id=None, context=None): |
1018 | mapping, mapping_id = self._init_mapping(cr, uid, external_session.referential_id.id, mapping=mapping, mapping_id=mapping_id, context=context) |
1019 | ext_resource = mapping[mapping_id]['external_resource_name'] |
1020 | search_method = mapping[mapping_id]['external_search_method'] |
1021 | if not search_method: |
1022 | - #TODO don't forget to replace model by nam ewhen name will be implemented |
1023 | - raise osv.except_osv(_('User Error'), _('There is not search method for the mapping %s')%(mapping[mapping_id]['model'],)) |
1024 | + #TODO don't forget to replace model by name when name will be implemented |
1025 | + raise except_osv(_('User Error'), _('There is not search method for the mapping %s')%(mapping[mapping_id]['model'],)) |
1026 | return external_session.connection.call(search_method, [resource_filter]) |
1027 | |
1028 | -osv.osv._get_external_resource_ids = _get_external_resource_ids |
1029 | - |
1030 | -osv.osv._mag_get_external_resources = osv.osv._get_external_resources |
1031 | - |
1032 | -@only_for_referential('magento', super_function = osv.osv._mag_get_external_resources) |
1033 | +Model._get_external_resource_ids = _get_external_resource_ids |
1034 | + |
1035 | +Model._mag_get_external_resources = Model._get_external_resources |
1036 | + |
1037 | +@only_for_referential('magento', super_function = Model._mag_get_external_resources) |
1038 | def _get_external_resources(self, cr, uid, external_session, external_id=None, resource_filter=None, mapping=None, mapping_id=None, fields=None, context=None): |
1039 | mapping, mapping_id = self._init_mapping(cr, uid, external_session.referential_id.id, mapping=mapping, mapping_id=mapping_id, context=context) |
1040 | ext_resource = mapping[mapping_id]['external_resource_name'] |
1041 | @@ -81,7 +82,7 @@ |
1042 | read_method = mapping[mapping_id]['external_get_method'] |
1043 | if not read_method: |
1044 | #TODO don't forget to replace model by nam ewhen name will be implemented |
1045 | - raise osv.except_osv(_('User Error'), |
1046 | + raise except_osv(_('User Error'), |
1047 | _('There is no "Get Method" configured on the mapping %s') % |
1048 | mapping[mapping_id]['model']) |
1049 | return external_session.connection.call(read_method, [external_id]) |
1050 | @@ -89,16 +90,16 @@ |
1051 | search_read_method = mapping[mapping_id]['external_list_method'] |
1052 | if not search_read_method: |
1053 | #TODO don't forget to replace model by nam ewhen name will be implemented |
1054 | - raise osv.except_osv(_('User Error'), |
1055 | + raise except_osv(_('User Error'), |
1056 | _('There is no "List Method" configured on the mapping %s') % |
1057 | mapping[mapping_id]['model']) |
1058 | return external_session.connection.call(search_read_method, [resource_filter or {}]) |
1059 | |
1060 | -osv.osv._get_external_resources = _get_external_resources |
1061 | - |
1062 | -osv.osv._mag_ext_create = osv.osv.ext_create |
1063 | - |
1064 | -@only_for_referential('magento', super_function = osv.osv._mag_ext_create) |
1065 | +Model._get_external_resources = _get_external_resources |
1066 | + |
1067 | +Model._mag_ext_create = Model.ext_create |
1068 | + |
1069 | +@only_for_referential('magento', super_function = Model._mag_ext_create) |
1070 | def ext_create(self, cr, uid, external_session, resources, mapping, mapping_id, context=None): |
1071 | ext_create_ids = {} |
1072 | main_lang = context['main_lang'] |
1073 | @@ -107,11 +108,11 @@ |
1074 | ext_create_ids[resource_id] = ext_id |
1075 | return ext_create_ids |
1076 | |
1077 | -osv.osv.ext_create = ext_create |
1078 | - |
1079 | - |
1080 | -osv.osv._mag_ext_update= osv.osv.ext_update |
1081 | -@only_for_referential('magento', super_function = osv.osv._mag_ext_update) |
1082 | +Model.ext_create = ext_create |
1083 | + |
1084 | + |
1085 | +Model._mag_ext_update= Model.ext_update |
1086 | +@only_for_referential('magento', super_function = Model._mag_ext_update) |
1087 | def ext_update(self, cr, uid, external_session, resources, mapping=None, mapping_id=None, context=None): |
1088 | if not mapping[mapping_id]['external_update_method']: |
1089 | external_session.logger.warning(_("Not update method for mapping %s")%mapping[mapping_id]['model']) |
1090 | @@ -124,9 +125,9 @@ |
1091 | [ext_id, resource[main_lang]]) |
1092 | return True |
1093 | |
1094 | -osv.osv.ext_update = ext_update |
1095 | +Model.ext_update = ext_update |
1096 | |
1097 | -#@only_for_referential('magento', super_function = osv.osv.send_to_external) |
1098 | +#@only_for_referential('magento', super_function = Model.send_to_external) |
1099 | #def send_to_external(self, cr, uid, external_session, resource, update_date, context=None): |
1100 | # print 'send this data to the external system', update_date |
1101 | # print 'data', resource |
1102 | @@ -134,14 +135,14 @@ |
1103 | # import pdb; pdb.set_trace() |
1104 | # return True |
1105 | |
1106 | -#osv.osv.send_to_external = send_to_external |
1107 | - |
1108 | - |
1109 | -#osv.osv.ori_mag_init_context_before_exporting_resource = osv.osv.init_context_before_exporting_resource |
1110 | - |
1111 | -#@only_for_referential('magento', super_function = osv.osv.init_context_before_exporting_resource) |
1112 | +#Model.send_to_external = send_to_external |
1113 | + |
1114 | + |
1115 | +#Model.ori_mag_init_context_before_exporting_resource = Model.init_context_before_exporting_resource |
1116 | + |
1117 | +#@only_for_referential('magento', super_function = Model.init_context_before_exporting_resource) |
1118 | #def init_context_before_exporting_resource(self, cr, uid, object_id, resource_name, context=None): |
1119 | -# context = osv.osv.ori_mag_init_context_before_exporting_resource(cr, uid, object_id, resource_name, context=context) |
1120 | +# context = Model.ori_mag_init_context_before_exporting_resource(cr, uid, object_id, resource_name, context=context) |
1121 | # if self._name == 'external.referential': |
1122 | # referential = self.browse(cr, uid, object_id, context=context) |
1123 | # elif 'referential_id' in self._columns.keys(): |
1124 | @@ -155,7 +156,7 @@ |
1125 | # context['store_to_lang'][storeview.id] = storeview.lang_id.code |
1126 | # return context |
1127 | |
1128 | -#osv.osv.init_context_before_exporting_resource = osv.osv.init_context_before_exporting_resource |
1129 | +#Model.init_context_before_exporting_resource = Model.init_context_before_exporting_resource |
1130 | |
1131 | |
1132 | def ext_set_resource_as_imported(self, cr, uid, external_session, external_id, mapping=None, mapping_id=None, context=None): |
1133 | @@ -165,7 +166,7 @@ |
1134 | return external_session.connection.call(done_method, [external_id]) |
1135 | return False |
1136 | |
1137 | -osv.osv.ext_set_resource_as_imported = ext_set_resource_as_imported |
1138 | +Model.ext_set_resource_as_imported = ext_set_resource_as_imported |
1139 | |
1140 | #DEPRECATED FEATURE!! YES ALL FUNCTION UNDER HIS LINE ARE DEPRECATED |
1141 | |
1142 | @@ -175,7 +176,7 @@ |
1143 | def __init__(self, location, username, password, debug=False, logger=False): |
1144 | #Append / if not there |
1145 | if not location[-1] == '/': |
1146 | - location += '/' |
1147 | + location += '/' |
1148 | self.corelocation = location |
1149 | #Please do not remove the str indeed xmlrpc lib require a string for the location |
1150 | #if an unicode is send it will raise you an error |
1151 | @@ -186,7 +187,7 @@ |
1152 | self.result = {} |
1153 | self.logger = logger or _logger |
1154 | |
1155 | - |
1156 | + |
1157 | def connect(self): |
1158 | if not self.location[-1] == '/': |
1159 | self.location += '/' |
1160 | @@ -206,11 +207,11 @@ |
1161 | except Exception,e: |
1162 | self.logger.error("Magento Connection" + netsvc.LOG_ERROR + "Error in connecting:%s" % e) |
1163 | self.logger.warning("Webservice Failure, sleeping %s second before next attempt" % sleep_time) |
1164 | - time.sleep(sleep_time) |
1165 | - raise osv.except_osv(_('User Error'), _('Error when try to connect to magento, are your sure that your login is right? Did openerp can access to your magento?')) |
1166 | - |
1167 | - |
1168 | - def call(self, method, *arguments): |
1169 | + time.sleep(sleep_time) |
1170 | + raise except_osv(_('User Error'), _('Error when try to connect to magento, are your sure that your login is right? Did openerp can access to your magento?')) |
1171 | + |
1172 | + |
1173 | + def call(self, method, *arguments): |
1174 | if arguments: |
1175 | arguments = list(arguments)[0] |
1176 | else: |
1177 | @@ -242,7 +243,7 @@ |
1178 | except Exception, e: |
1179 | pass |
1180 | |
1181 | -class magerp_osv(osv.osv): |
1182 | +class MagerpModel(Model): |
1183 | _register = False # Set to false if the model shouldn't be automatically discovered. |
1184 | |
1185 | _MAGE_FIELD = 'magento_id' |
1186 | @@ -254,7 +255,7 @@ |
1187 | _DELETE_METHOD = False |
1188 | _mapping = {} |
1189 | DEBUG = False |
1190 | - |
1191 | + |
1192 | #TODO deprecated, remove use |
1193 | def mage_to_oe(self, cr, uid, mageid, instance, *arguments): |
1194 | """given a record id in the Magento referential, returns a tuple (id, name) with the id in the OpenERP referential; Magento instance wise""" |
1195 | @@ -279,7 +280,7 @@ |
1196 | read = self.read(cr, uid, oeid, [self._rec_name]) |
1197 | return (read[0]['id'], read[0][self._rec_name]) |
1198 | return False |
1199 | - |
1200 | + |
1201 | #TODO deprecated, remove use |
1202 | def sync_import(self, cr, uid, magento_records, instance, debug=False, defaults=None, *attrs): |
1203 | |
1204 | @@ -314,7 +315,7 @@ |
1205 | 'temp_vars':{}, |
1206 | 'mage2oe_filters':mage2oe_filters |
1207 | } |
1208 | - |
1209 | + |
1210 | #now properly mapp known Magento attributes to OpenERP entity columns: |
1211 | for each_valid_key in self._mapping: |
1212 | if each_valid_key in magento_record.keys(): |
1213 | @@ -353,7 +354,7 @@ |
1214 | self.record_save(cr, uid, rec_id, vals, defaults) |
1215 | else: |
1216 | self.record_save(cr, uid, rec_id, vals, defaults) |
1217 | - |
1218 | + |
1219 | def record_save(self, cr, uid, rec_id, vals, defaults): |
1220 | if defaults: |
1221 | for key in defaults.keys(): |
1222 | @@ -364,7 +365,7 @@ |
1223 | else: |
1224 | #Record is not there, create it |
1225 | self.create(cr, uid, vals,) |
1226 | - |
1227 | + |
1228 | def cast_string(self, subject): |
1229 | """This function will convert string objects to the data type required. Example "0"/"1" to boolean conversion""" |
1230 | for key in subject.keys(): |
1231 | @@ -374,7 +375,7 @@ |
1232 | else: |
1233 | subject[key] = True |
1234 | return subject |
1235 | - |
1236 | + |
1237 | def mage_import_base(self,cr,uid,conn, external_referential_id, defaults=None, context=None): |
1238 | if context is None: |
1239 | context = {} |
1240 | @@ -396,7 +397,7 @@ |
1241 | list_method = self.pool.get('external.mapping').read(cr,uid,mapping_id[0],['external_list_method']).get('external_list_method',False) |
1242 | if list_method: |
1243 | data = conn.call(list_method, context['ids_or_filter']) |
1244 | - |
1245 | + |
1246 | #it may happen that list method doesn't provide enough information, forcing us to use get_method on each record (case for sale orders) |
1247 | if context.get('one_by_one', False): |
1248 | self.mage_import_one_by_one(cr, uid, conn, external_referential_id, mapping_id[0], data, defaults, context) |
1249 | @@ -437,8 +438,8 @@ |
1250 | else: |
1251 | self.sync_import(cr, uid, magento_records, instance, debug, defaults) |
1252 | else: |
1253 | - raise osv.except_osv(_('Undefined List method !'), _("list method is undefined for this object!")) |
1254 | - |
1255 | + raise except_osv(_('Undefined List method !'), _("list method is undefined for this object!")) |
1256 | + |
1257 | #TODO deprecated, remove use |
1258 | def get_all_mage_ids(self, cr, uid, ids, instance=False): |
1259 | search_param = [] |
1260 | @@ -451,4 +452,6 @@ |
1261 | for each in reads: |
1262 | mageids.append(each[self._MAGE_FIELD]) |
1263 | return mageids |
1264 | - |
1265 | + |
1266 | +# deprecated, bw compat |
1267 | +magerp_osv = MagerpModel |
1268 | |
1269 | === modified file 'magentoerpconnect/partner.py' |
1270 | --- magentoerpconnect/partner.py 2012-06-01 18:21:53 +0000 |
1271 | +++ magentoerpconnect/partner.py 2012-12-03 15:22:20 +0000 |
1272 | @@ -22,47 +22,51 @@ |
1273 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
1274 | ######################################################################### |
1275 | |
1276 | -from osv import osv, fields |
1277 | -from tools.translate import _ |
1278 | -import magerp_osv |
1279 | +import hashlib |
1280 | + |
1281 | +from openerp.osv import fields |
1282 | +from .magerp_osv import MagerpModel |
1283 | from base_external_referentials.decorator import only_for_referential |
1284 | -import hashlib |
1285 | |
1286 | -class res_partner_category(magerp_osv.magerp_osv): |
1287 | +class res_partner_category(MagerpModel): |
1288 | _inherit = "res.partner.category" |
1289 | - |
1290 | - _columns = { |
1291 | - 'tax_class_id':fields.integer('Tax Class ID'), |
1292 | + _columns = {'tax_class_id':fields.integer('Tax Class ID'), |
1293 | } |
1294 | -res_partner_category() |
1295 | |
1296 | -class res_partner_address(magerp_osv.magerp_osv): |
1297 | +class res_partner_address(MagerpModel): |
1298 | _inherit = "res.partner.address" |
1299 | |
1300 | - |
1301 | - #TODO maybe move the fields company, firstname, lastname in an extra module |
1302 | - #On v7 the partner address model will totaly change so maybe it's not worth |
1303 | - def _get_partner_name(self, cr, uid, ids, field_name, arg, context=None): |
1304 | - res ={} |
1305 | - for partner in self.browse(cr, uid, ids, context=context): |
1306 | - res[partner.id] = ((partner.company and partner.company + ' : ') or '') + \ |
1307 | - (partner.lastname and partner.lastname + ' ' or '') + \ |
1308 | - (partner.firstname or '') |
1309 | - return res |
1310 | + #Migration script for 6.1.0 to 6.1.1 |
1311 | + def _auto_init(self, cr, context=None): |
1312 | + # recompute the field name with firstname + lastname |
1313 | + # in order to have the same data as the data of base_partner_surname |
1314 | + first_install=False |
1315 | + cr.execute("SELECT column_name FROM information_schema.columns " |
1316 | + "WHERE table_name = 'res_partner_address' " |
1317 | + "AND column_name = 'firstname'") |
1318 | + if cr.fetchone(): |
1319 | + cr.execute( |
1320 | + "UPDATE res_partner_address " |
1321 | + "SET name = CASE " |
1322 | + "WHEN firstname IS NOT NULL AND lastname IS NOT NULL THEN (firstname || ' ' || lastname) " |
1323 | + "WHEN firstname IS NOT NULL AND lastname IS NULL THEN firstname " |
1324 | + "WHEN firstname IS NULL AND lastname IS NOT NULL THEN lastname " |
1325 | + "ELSE name " |
1326 | + "END" |
1327 | + ) |
1328 | + cr.execute("ALTER TABLE res_partner_address " |
1329 | + "RENAME COLUMN firstname TO first_name") |
1330 | + cr.execute("ALTER TABLE res_partner_address " |
1331 | + "RENAME COLUMN lastname TO last_name") |
1332 | + return super(res_partner_address, self)._auto_init(cr, context=context) |
1333 | |
1334 | _columns = { |
1335 | - 'name': fields.function(_get_partner_name, obj="res.partner.address", type = 'char', size = 256, string='Name', |
1336 | - store = { |
1337 | - 'res.partner.address' : (lambda self, cr, uid, ids, c={}: ids, |
1338 | - ['company', 'firstname', 'lastname'], 10)}), |
1339 | 'company':fields.char('Company', size=100), |
1340 | - 'firstname':fields.char('First Name', size=100), |
1341 | - 'lastname':fields.char('Last Name', size=100), |
1342 | 'is_magento_order_address':fields.boolean('Magento Order Address?'), #TODO still needed? |
1343 | - } |
1344 | + } |
1345 | _defaults = { |
1346 | 'is_magento_order_address': lambda * a:False, |
1347 | - } |
1348 | + } |
1349 | |
1350 | @only_for_referential('magento') |
1351 | def ext_create(self, cr, uid, external_session, resources, mapping, mapping_id, context=None): |
1352 | @@ -74,9 +78,7 @@ |
1353 | ext_create_ids[resource_id] = ext_id |
1354 | return ext_create_ids |
1355 | |
1356 | -res_partner_address() |
1357 | - |
1358 | -class res_partner(magerp_osv.magerp_osv): |
1359 | +class res_partner(MagerpModel): |
1360 | _inherit = "res.partner" |
1361 | |
1362 | def _is_magento_exported(self, cr, uid, ids, field_name, arg, context=None): |
1363 | @@ -94,20 +96,20 @@ |
1364 | return res |
1365 | |
1366 | _columns = { |
1367 | - 'group_id':fields.many2one('res.partner.category', 'Magento Group(Category)'), |
1368 | - 'store_id':fields.many2one('magerp.storeviews', 'Last Store View', help="Last store view where the customer has bought."), |
1369 | - 'store_ids':fields.many2many('magerp.storeviews', 'magerp_storeid_rel', 'partner_id', 'store_id', 'Store Views'), |
1370 | - 'website_id':fields.many2one('external.shop.group', 'Magento Website', help='Select a website for which the Magento customer will be bound.'), |
1371 | - 'created_in':fields.char('Created in', size=100), |
1372 | - 'created_at':fields.datetime('Created Date'), |
1373 | - 'updated_at':fields.datetime('Updated At'), |
1374 | - 'emailid':fields.char('Email Address', size=100, help="Magento uses this email ID to match the customer. If filled, if a Magento customer is imported from the selected website with the exact same email, he will be bound with this partner and this latter will be updated with Magento's values."), |
1375 | - 'mag_vat':fields.char('Magento VAT', size=50, help="To be able to receive customer VAT number you must set it in Magento Admin Panel, menu System / Configuration / Client Configuration / Name and Address Options."), |
1376 | - '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."), |
1377 | - 'mag_newsletter':fields.boolean('Newsletter'), |
1378 | - 'magento_exported': fields.function(_is_magento_exported, type="boolean", method=True, string="Exists on Magento"), |
1379 | - 'magento_pwd': fields.char('Magento Password', size=256), |
1380 | - } |
1381 | + 'group_id':fields.many2one('res.partner.category', 'Magento Group(Category)'), |
1382 | + 'store_id':fields.many2one('magerp.storeviews', 'Last Store View', help="Last store view where the customer has bought."), |
1383 | + 'store_ids':fields.many2many('magerp.storeviews', 'magerp_storeid_rel', 'partner_id', 'store_id', 'Store Views'), |
1384 | + 'website_id':fields.many2one('external.shop.group', 'Magento Website', help='Select a website for which the Magento customer will be bound.'), |
1385 | + 'created_in':fields.char('Created in', size=100), |
1386 | + 'created_at':fields.datetime('Created Date'), |
1387 | + 'updated_at':fields.datetime('Updated At'), |
1388 | + 'emailid':fields.char('Email Address', size=100, help="Magento uses this email ID to match the customer. If filled, if a Magento customer is imported from the selected website with the exact same email, he will be bound with this partner and this latter will be updated with Magento's values."), |
1389 | + 'mag_vat':fields.char('Magento VAT', size=50, help="To be able to receive customer VAT number you must set it in Magento Admin Panel, menu System / Configuration / Client Configuration / Name and Address Options."), |
1390 | + '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."), |
1391 | + 'mag_newsletter':fields.boolean('Newsletter'), |
1392 | + 'magento_exported': fields.function(_is_magento_exported, type="boolean", method=True, string="Exists on Magento"), |
1393 | + 'magento_pwd': fields.char('Magento Password', size=256), |
1394 | + } |
1395 | |
1396 | _sql_constraints = [('emailid_uniq', 'unique(emailid, website_id)', 'A partner already exists with this email address on the selected website.')] |
1397 | |
1398 | @@ -124,7 +126,7 @@ |
1399 | AND ir_model_data.model = 'res.partner' |
1400 | AND ir_model_data.referential_id = %(ref_id)s |
1401 | WHERE ir_model_data.res_id IS NULL AND magerp_storeid_rel.store_id IN %(store_ids)s""" |
1402 | - params = {'ref_id': external_session.referential_id.id, |
1403 | + params = {'ref_id': external_session.referential_id.id, |
1404 | 'store_ids': tuple(store_ids)} |
1405 | cr.execute(query,params) |
1406 | results = cr.dictfetchall() |
1407 | @@ -134,7 +136,7 @@ |
1408 | @only_for_referential('magento') |
1409 | def _transform_and_send_one_resource(self, cr, uid, external_session, resource, resource_id, |
1410 | update_date, mapping, mapping_id, defaults=None, context=None): |
1411 | - res = super(res_partner, self)._transform_and_send_one_resource(cr, uid, external_session, |
1412 | + res = super(res_partner, self)._transform_and_send_one_resource(cr, uid, external_session, |
1413 | resource, resource_id, update_date, mapping, mapping_id, defaults=defaults, context=context) |
1414 | if res: |
1415 | address_obj = self.pool.get('res.partner.address') |
1416 | @@ -142,5 +144,3 @@ |
1417 | for resource_id in resource_ids: |
1418 | result = address_obj._export_one_resource(cr, uid, external_session, resource_id, context=context) |
1419 | return res |
1420 | - |
1421 | -res_partner() |
1422 | |
1423 | === modified file 'magentoerpconnect/partner_view.xml' |
1424 | --- magentoerpconnect/partner_view.xml 2012-05-19 13:37:23 +0000 |
1425 | +++ magentoerpconnect/partner_view.xml 2012-12-03 15:22:20 +0000 |
1426 | @@ -7,10 +7,8 @@ |
1427 | <field name="type">form</field> |
1428 | <field name="inherit_id" ref="base.view_partner_form" /> |
1429 | <field name="arch" type="xml"> |
1430 | - <xpath expr="/form/notebook/page/field/form/group/field[@name='name']" position="replace" > |
1431 | + <xpath expr="/form/notebook/page/field/form/group/field[@name='name']" position="after" > |
1432 | <field name="company" /> |
1433 | - <field name="firstname" /> |
1434 | - <field name="lastname" /> |
1435 | </xpath> |
1436 | <xpath expr="/form/notebook" position="inside"> |
1437 | <page string="Magento Information"> |
1438 | @@ -50,10 +48,8 @@ |
1439 | <field name="type">form</field> |
1440 | <field name="inherit_id" ref="base.view_partner_address_form1" /> |
1441 | <field name="arch" type="xml"> |
1442 | - <field name="name" position="replace"> |
1443 | + <field name="name" position="after"> |
1444 | <field name="company" /> |
1445 | - <field name="firstname" /> |
1446 | - <field name="lastname" /> |
1447 | </field> |
1448 | </field> |
1449 | </record> |
1450 | |
1451 | === modified file 'magentoerpconnect/product.py' |
1452 | --- magentoerpconnect/product.py 2012-08-14 15:46:07 +0000 |
1453 | +++ magentoerpconnect/product.py 2012-12-03 15:22:20 +0000 |
1454 | @@ -22,26 +22,27 @@ |
1455 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
1456 | ######################################################################### |
1457 | |
1458 | -from osv import osv, orm, fields |
1459 | -import datetime |
1460 | import time |
1461 | -import pooler |
1462 | -import magerp_osv |
1463 | -from tools.translate import _ |
1464 | import unicodedata |
1465 | import base64, urllib |
1466 | import os |
1467 | +import xmlrpclib |
1468 | from lxml import etree |
1469 | -import xmlrpclib |
1470 | - |
1471 | import logging |
1472 | + |
1473 | +from openerp.osv.orm import Model, setup_modifiers |
1474 | +from openerp.osv import fields |
1475 | +from openerp.osv.osv import except_osv |
1476 | +from openerp import pooler |
1477 | +from openerp.tools.translate import _ |
1478 | +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT |
1479 | + |
1480 | +from .magerp_osv import MagerpModel |
1481 | +from base_external_referentials.decorator import only_for_referential, catch_error_in_report |
1482 | +from base_external_referentials.external_osv import ExternalSession |
1483 | + |
1484 | _logger = logging.getLogger(__name__) |
1485 | |
1486 | -from tools import DEFAULT_SERVER_DATETIME_FORMAT |
1487 | - |
1488 | -from base_external_referentials.decorator import only_for_referential |
1489 | -from base_external_referentials.external_osv import ExternalSession |
1490 | - |
1491 | #Enabling this to True will put all custom attributes into One page in |
1492 | #the products view |
1493 | GROUP_CUSTOM_ATTRS_TOGETHER = False |
1494 | @@ -70,7 +71,7 @@ |
1495 | else: |
1496 | return False |
1497 | |
1498 | -class magerp_product_category_attribute_options(magerp_osv.magerp_osv): |
1499 | +class magerp_product_category_attribute_options(MagerpModel): |
1500 | _name = "magerp.product_category_attribute_options" |
1501 | _description = "Option products category Attributes" |
1502 | _rec_name = "label" |
1503 | @@ -98,13 +99,10 @@ |
1504 | 'value':fields.char('Value', size=200), |
1505 | #'ipcast':fields.char('Type cast', size=50), |
1506 | 'label':fields.char('Label', size=100), |
1507 | - } |
1508 | - |
1509 | - |
1510 | -magerp_product_category_attribute_options() |
1511 | - |
1512 | - |
1513 | -class product_category(magerp_osv.magerp_osv): |
1514 | + } |
1515 | + |
1516 | + |
1517 | +class product_category(MagerpModel): |
1518 | _inherit = "product.category" |
1519 | |
1520 | def _merge_with_default_values(self, cr, uid, external_session, ressource, vals, sub_mapping_list, defaults=None, context=None): |
1521 | @@ -152,16 +150,13 @@ |
1522 | parent_id = resource[main_lang]['parent_id'] |
1523 | del resource[main_lang]['parent_id'] |
1524 | external_session.connection.call('catalog_category.update', [ext_id, resource[main_lang], False]) |
1525 | - external_session.connection.call('catalog_category.move', [ext_id, parent_id]) |
1526 | + external_session.connection.call('oerp_catalog_category.move', [ext_id, parent_id]) |
1527 | for storeview, lang in storeview_to_lang.items(): |
1528 | del resource[lang]['ext_id'] |
1529 | external_session.connection.call('catalog_category.update', [ext_id, resource[lang], storeview]) |
1530 | ext_update_ids[resource_id] = ext_id |
1531 | return ext_update_ids |
1532 | |
1533 | - |
1534 | - |
1535 | - |
1536 | _columns = { |
1537 | 'magerp_fields' : fields.serialized('Magento Product Categories Extra Fields'), |
1538 | 'create_date': fields.datetime('Created date', readonly=True), |
1539 | @@ -194,8 +189,6 @@ |
1540 | 'page_layout': fields.many2one('magerp.product_category_attribute_options', 'Page Layout', domain="[('attribute_name', '=', 'page_layout')]"), |
1541 | } |
1542 | |
1543 | - |
1544 | - |
1545 | _defaults = { |
1546 | 'display_mode':lambda * a:'PRODUCTS', |
1547 | 'use_default_available_sort_by': lambda * a:True, |
1548 | @@ -203,7 +196,7 @@ |
1549 | 'level':lambda * a:1, |
1550 | 'include_in_menu': lambda * a:True, |
1551 | 'page_layout': lambda self,cr,uid,c: self.pool.get('magerp.product_category_attribute_options')._get_default_option(cr, uid, 'page_layout', 'None', context=c), |
1552 | - } |
1553 | + } |
1554 | |
1555 | def write(self, cr, uid, ids, vals, context=None): |
1556 | if not 'magerp_stamp' in vals.keys(): |
1557 | @@ -224,10 +217,8 @@ |
1558 | ids = get_child_ids(categ_tree) |
1559 | return ids |
1560 | |
1561 | -product_category() |
1562 | - |
1563 | - |
1564 | -class magerp_product_attributes(magerp_osv.magerp_osv): |
1565 | + |
1566 | +class magerp_product_attributes(MagerpModel): |
1567 | _name = "magerp.product_attributes" |
1568 | _description = "Attributes of products" |
1569 | _rec_name = "attribute_code" |
1570 | @@ -295,95 +286,84 @@ |
1571 | 'based_on':fields.selection([('product_product', 'Product Product'), ('product_template', 'Product Template')], 'Based On'), |
1572 | } |
1573 | |
1574 | - _defaults = { |
1575 | - 'based_on': lambda*a: 'product_template', |
1576 | - } |
1577 | - |
1578 | + _defaults = {'based_on': lambda*a: 'product_template', |
1579 | + } |
1580 | #mapping magentofield:(openerpfield,typecast,) |
1581 | #have an entry for each mapped field |
1582 | - _no_create_list = [ |
1583 | - 'product_id', |
1584 | - 'name', |
1585 | - 'description', |
1586 | - 'short_description', |
1587 | - 'sku', |
1588 | - 'weight', |
1589 | - 'category_ids', |
1590 | - 'price', |
1591 | - 'cost', |
1592 | - 'set', |
1593 | - 'ean', |
1594 | - ] |
1595 | - |
1596 | - _translatable_default_codes = [ |
1597 | - 'description', |
1598 | - 'meta_description', |
1599 | - 'meta_keyword', |
1600 | - 'meta_title', |
1601 | - 'name', |
1602 | - 'short_description', |
1603 | - 'url_key', |
1604 | - ] |
1605 | - |
1606 | - _not_store_in_json = [ |
1607 | - 'minimal_price', |
1608 | - 'special_price', |
1609 | - 'description', |
1610 | - 'meta_description', |
1611 | - 'meta_keyword', |
1612 | - 'meta_title', |
1613 | - 'name', |
1614 | - 'short_description', |
1615 | - 'url_key', |
1616 | - ] |
1617 | - |
1618 | - _type_conversion = { |
1619 | - '':'char', |
1620 | - 'text':'char', |
1621 | - 'textarea':'text', |
1622 | - 'select':'many2one', |
1623 | - 'date':'date', |
1624 | - 'price':'float', |
1625 | - 'media_image':'binary', |
1626 | - 'gallery':'binary', |
1627 | - 'multiselect':'many2many', |
1628 | - 'boolean':'boolean', |
1629 | - 'weee':'char', |
1630 | - False:'char', |
1631 | - 'file':'char', #this option is not a magento native field it will be better to found a generic solutionto manage this kind of custom option |
1632 | - } |
1633 | - |
1634 | - _type_casts = { |
1635 | - '':'unicode', |
1636 | - 'text':'unicode', |
1637 | - 'textarea':'unicode', |
1638 | - 'select':'unicode', |
1639 | - 'date':'unicode', |
1640 | - 'price':'float', |
1641 | - 'media_image':'False', |
1642 | - 'gallery':'False', |
1643 | - 'multiselect':'list', |
1644 | - 'boolean':'int', |
1645 | - 'weee':'unicode', |
1646 | - False:'unicode', |
1647 | - 'file':'unicode', #this option is not a magento native field it will be better to found a generic solutionto manage this kind of custom option |
1648 | - } |
1649 | - |
1650 | - _variant_fields = [ |
1651 | - 'color', |
1652 | - 'dimension', |
1653 | - 'visibility', |
1654 | - 'special_price', |
1655 | - 'special_price_from_date', |
1656 | - 'special_price_to_date', |
1657 | - ] |
1658 | - |
1659 | - |
1660 | - #TODO check if this field have to be in only one way and if yes add this feature |
1661 | - _sync_way = { |
1662 | - 'has_options' : 'in', |
1663 | - 'special_price' : 'in', |
1664 | - } |
1665 | + _no_create_list = ['product_id', |
1666 | + 'name', |
1667 | + 'description', |
1668 | + 'short_description', |
1669 | + 'sku', |
1670 | + 'weight', |
1671 | + 'category_ids', |
1672 | + 'price', |
1673 | + 'cost', |
1674 | + 'set', |
1675 | + 'ean', |
1676 | + ] |
1677 | + _translatable_default_codes = ['description', |
1678 | + 'meta_description', |
1679 | + 'meta_keyword', |
1680 | + 'meta_title', |
1681 | + 'name', |
1682 | + 'short_description', |
1683 | + 'url_key', |
1684 | + ] |
1685 | + _not_store_in_json = ['minimal_price', |
1686 | + 'special_price', |
1687 | + 'description', |
1688 | + 'meta_description', |
1689 | + 'meta_keyword', |
1690 | + 'meta_title', |
1691 | + 'name', |
1692 | + 'short_description', |
1693 | + 'url_key', |
1694 | + ] |
1695 | + _type_conversion = {'':'char', |
1696 | + 'text':'char', |
1697 | + 'textarea':'text', |
1698 | + 'select':'many2one', |
1699 | + 'date':'date', |
1700 | + 'price':'float', |
1701 | + 'media_image':'binary', |
1702 | + 'gallery':'binary', |
1703 | + 'multiselect':'many2many', |
1704 | + 'boolean':'boolean', |
1705 | + 'weee':'char', |
1706 | + False:'char', |
1707 | + 'file':'char', #this option is not a magento native field it will be better to found a generic solutionto manage this kind of custom option |
1708 | + } |
1709 | + _type_casts = {'':'unicode', |
1710 | + 'text':'unicode', |
1711 | + 'textarea':'unicode', |
1712 | + 'select':'unicode', |
1713 | + 'date':'unicode', |
1714 | + 'price':'float', |
1715 | + 'media_image':'False', |
1716 | + 'gallery':'False', |
1717 | + 'multiselect':'list', |
1718 | + 'boolean':'int', |
1719 | + 'weee':'unicode', |
1720 | + False:'unicode', |
1721 | + 'file':'unicode', #this option is not a magento native field it will be better to found a generic solutionto manage this kind of custom option |
1722 | + } |
1723 | + _variant_fields = ['color', |
1724 | + 'dimension', |
1725 | + 'visibility', |
1726 | + 'special_price', |
1727 | + 'special_price_from_date', |
1728 | + 'special_price_to_date', |
1729 | + ] |
1730 | + |
1731 | + |
1732 | + #For some field you can specify the syncronisation way |
1733 | + #in : Magento => OpenERP |
1734 | + #out : Magento <= OpenERP |
1735 | + #in_out (default_value) : Magento <=> OpenERP |
1736 | + _sync_way = {'has_options' : 'in', |
1737 | + 'tier_price': 'in', |
1738 | + } |
1739 | |
1740 | def _is_attribute_translatable(self, vals): |
1741 | """Tells if field associated to attribute should be translatable or not. |
1742 | @@ -493,7 +473,6 @@ |
1743 | # mapping have to be based on product.product |
1744 | model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'product.product')])[0] |
1745 | self._create_mapping(cr, uid, field_vals['ttype'], field_id, field_name, referential_id, model_id, vals, crid) |
1746 | - |
1747 | return crid |
1748 | |
1749 | def _default_mapping(self, cr, uid, ttype, field_name, vals, attribute_id, model_id, mapping_line, referential_id): |
1750 | @@ -557,17 +536,16 @@ |
1751 | mapping_line = {'external_field': vals['attribute_code'], |
1752 | 'sequence': 0, |
1753 | 'mapping_id': mapping_id[0], |
1754 | - 'type': 'in_out', |
1755 | + 'type': self._sync_way.get(vals['attribute_code'], 'in_out'), |
1756 | 'external_type': self._type_casts[vals.get('frontend_input', False)], |
1757 | 'field_id': field_id, } |
1758 | mapping_line = self._default_mapping(cr, uid, ttype, field_name, vals, attribute_id, model_id, mapping_line, referential_id) |
1759 | self.pool.get('external.mapping.line').create(cr, uid, mapping_line) |
1760 | return True |
1761 | |
1762 | -magerp_product_attributes() |
1763 | |
1764 | """Dont remove the code, we might need it --sharoon |
1765 | -class magerp_product_attributes_set_info(osv.osv): |
1766 | +class magerp_product_attributes_set_info(Model): |
1767 | _name="magerp.product_attributes.set_info" |
1768 | _description = "Attribute Set information for each attribute" |
1769 | _columns = { |
1770 | @@ -579,7 +557,7 @@ |
1771 | } |
1772 | magerp_product_attributes_set_info()""" |
1773 | |
1774 | -class magerp_product_attribute_options(magerp_osv.magerp_osv): |
1775 | +class magerp_product_attribute_options(MagerpModel): |
1776 | _name = "magerp.product_attribute_options" |
1777 | _description = "Options of selected attributes" |
1778 | _rec_name = "label" |
1779 | @@ -635,9 +613,8 @@ |
1780 | else: |
1781 | return False |
1782 | |
1783 | -magerp_product_attribute_options() |
1784 | |
1785 | -class magerp_product_attribute_set(magerp_osv.magerp_osv): |
1786 | +class magerp_product_attribute_set(MagerpModel): |
1787 | _name = "magerp.product_attribute_set" |
1788 | _description = "Attribute sets in products" |
1789 | _rec_name = 'attribute_set_name' |
1790 | @@ -649,8 +626,8 @@ |
1791 | 'referential_id':fields.many2one('external.referential', 'Magento Instance', readonly=True), |
1792 | 'magento_id':fields.integer('Magento ID'), |
1793 | } |
1794 | - |
1795 | - |
1796 | + |
1797 | + |
1798 | def update_attribute(self, cr, uid, ids, context=None): |
1799 | ref_obj = self.pool.get('external.referential') |
1800 | mag_ref_ids = ref_obj.search(cr, uid, [('version_id','ilike', 'magento')], context=context) |
1801 | @@ -735,9 +712,8 @@ |
1802 | cr.execute(query) |
1803 | return True |
1804 | |
1805 | -magerp_product_attribute_set() |
1806 | |
1807 | -class magerp_product_attribute_groups(magerp_osv.magerp_osv): |
1808 | +class magerp_product_attribute_groups(MagerpModel): |
1809 | _name = "magerp.product_attribute_groups" |
1810 | _description = "Attribute groups in Magento" |
1811 | _rec_name = 'attribute_group_name' |
1812 | @@ -759,10 +735,9 @@ |
1813 | 'sort_order':fields.integer('Sort Order'), |
1814 | 'default_id':fields.integer('Default'), |
1815 | 'referential_id':fields.many2one('external.referential', 'Magento Instance', readonly=True), |
1816 | - } |
1817 | -magerp_product_attribute_groups() |
1818 | + } |
1819 | |
1820 | -class product_tierprice(osv.osv): |
1821 | +class product_tierprice(Model): |
1822 | _name = "product.tierprice" |
1823 | _description = "Implements magento tier pricing" |
1824 | |
1825 | @@ -782,7 +757,7 @@ |
1826 | 'price_qty':fields.float('Quantity Slab', digits=(10, 4), help="Slab & above eg.For 10 and above enter 10"), |
1827 | 'product':fields.many2one('product.product', 'Product'), |
1828 | 'referential_id':fields.many2one('external.referential', 'Magento Instance', readonly=True), |
1829 | - } |
1830 | + } |
1831 | _mapping = { |
1832 | 'cust_group':(False, int, """result=self.pool.get('res.partner.category').mage_to_oe(cr,uid,cust_group,instance)\nif result:\n\tresult=[('cust_group',result[0])]\nelse:\n\tresult=[('cust_group',False)]"""), |
1833 | 'all_groups':(False, str, """if all_groups=='1':\n\tresult=[('group_scope','1')]\nelse:\n\tresult=[('group_scope','1')]"""), |
1834 | @@ -790,21 +765,18 @@ |
1835 | 'price':('price', float), |
1836 | 'website_id':(False, int, """result=self.pool.get('external.shop.group').mage_to_oe(cr,uid,website_id,instance)\nif result:\n\tresult=[('website_id',result[0])]\nelse:\n\tresult=[('website_id',False)]"""), |
1837 | 'price_qty':('price_qty', float), |
1838 | - } |
1839 | -product_tierprice() |
1840 | + } |
1841 | |
1842 | -class product_product_type(osv.osv): |
1843 | +class product_product_type(Model): |
1844 | _name = 'magerp.product_product_type' |
1845 | _columns = { |
1846 | 'name': fields.char('Name', size=100, required=True, translate=True), |
1847 | 'product_type': fields.char('Type', size=100, required=True, help="Use the same name of Magento product type, for example 'simple'."), |
1848 | 'default_type': fields.selection([('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Default Product Type', required=True, help="Default product's type (Procurement) when a product is imported from Magento."), |
1849 | - } |
1850 | -product_product_type() |
1851 | - |
1852 | - |
1853 | - |
1854 | -class product_mag_osv(magerp_osv.magerp_osv): |
1855 | + } |
1856 | + |
1857 | + |
1858 | +class product_mag_osv(MagerpModel): |
1859 | _register = False # Set to false if the model shouldn't be automatically discovered. |
1860 | |
1861 | #remember one thing in life: Magento lies: it tells attributes are required while they are awkward to fill |
1862 | @@ -819,7 +791,7 @@ |
1863 | set_id = self.read(cr, uid, ids, fields=['set'], context=context)[0]['set'] |
1864 | |
1865 | if not set_id: |
1866 | - raise osv.except_osv(_('User Error'), _('Please chose an attribut set before')) |
1867 | + raise except_osv(_('User Error'), _('Please chose an attribute set before')) |
1868 | |
1869 | return { |
1870 | 'name': 'Magento Fields', |
1871 | @@ -948,17 +920,15 @@ |
1872 | f.set('nolabel', "1") |
1873 | f.set('colspan', "4") |
1874 | |
1875 | - orm.setup_modifiers( |
1876 | - f, fields_get[attribute['field_name']], |
1877 | - context=context) |
1878 | + setup_modifiers(f, fields_get[attribute['field_name']], |
1879 | + context=context) |
1880 | |
1881 | if multiwebsites: |
1882 | website_page = etree.SubElement( |
1883 | notebook, 'page', string=_('Websites')) |
1884 | wf = etree.SubElement( |
1885 | website_page, 'field', name='websites_ids', nolabel="1") |
1886 | - orm.setup_modifiers( |
1887 | - wf, fields_get['websites_ids'], context=context) |
1888 | + setup_modifiers(wf, fields_get['websites_ids'], context=context) |
1889 | |
1890 | return notebook |
1891 | |
1892 | @@ -1025,14 +995,13 @@ |
1893 | 'page', |
1894 | string=_('Magento Information'), |
1895 | attrs=attrs_mag_notebook) |
1896 | - orm.setup_modifiers(magento_page, context=context) |
1897 | + setup_modifiers(magento_page, context=context) |
1898 | f = etree.SubElement( |
1899 | magento_page, |
1900 | 'field', |
1901 | name='product_type', |
1902 | attrs="{'required': [('magento_exportable', '=', True)]}") |
1903 | - orm.setup_modifiers( |
1904 | - f, field=result['fields']['product_type'], context=context) |
1905 | + setup_modifiers(f, field=result['fields']['product_type'], context=context) |
1906 | magento_page.append(attributes_notebook) |
1907 | btn.getparent().remove(btn) |
1908 | else: |
1909 | @@ -1050,18 +1019,21 @@ |
1910 | type='object', |
1911 | colspan='2', |
1912 | attrs=attrs_mag_notebook) |
1913 | - orm.setup_modifiers(new_btn, context=context) |
1914 | + setup_modifiers(new_btn, context=context) |
1915 | btn.getparent().replace(btn, new_btn) |
1916 | if page_placeholder: |
1917 | placeholder = page_placeholder[0] |
1918 | placeholder.getparent().remove(placeholder) |
1919 | |
1920 | result['arch'] = etree.tostring(eview, pretty_print=True) |
1921 | + #TODO understand (and fix) why the orm fill the field size for the text field :S |
1922 | + for field in result['fields']: |
1923 | + if result['fields'][field]['type'] == 'text': |
1924 | + if 'size' in result['fields'][field]: del result['fields'][field]['size'] |
1925 | return result |
1926 | |
1927 | class product_template(product_mag_osv): |
1928 | _inherit = "product.template" |
1929 | - |
1930 | _columns = { |
1931 | 'magerp_tmpl' : fields.serialized('Magento Template Fields'), |
1932 | 'set':fields.many2one('magerp.product_attribute_set', 'Attribute Set'), |
1933 | @@ -1071,19 +1043,15 @@ |
1934 | ('no', 'Do Not Manage Stock'), |
1935 | ('yes','Manage Stock')], |
1936 | 'Manage Stock Level'), |
1937 | - } |
1938 | - |
1939 | + } |
1940 | _defaults = { |
1941 | 'mag_manage_stock': 'use_default', |
1942 | - } |
1943 | - |
1944 | -product_template() |
1945 | + } |
1946 | |
1947 | |
1948 | class product_product(product_mag_osv): |
1949 | _inherit = "product.product" |
1950 | |
1951 | - |
1952 | def send_to_external(self, cr, uid, external_session, resources, mapping, mapping_id, update_date=None, context=None): |
1953 | product_ids = resources.keys() |
1954 | res = super(product_product, self).send_to_external(cr, uid, external_session, resources, mapping, mapping_id, update_date=update_date, context=context) |
1955 | @@ -1096,7 +1064,7 @@ |
1956 | ext_id = res['product_id'] |
1957 | external_session.connection.call('ol_catalog_product.update', [ext_id, resource, False, 'id']) |
1958 | return ext_id |
1959 | - |
1960 | + |
1961 | @only_for_referential('magento') |
1962 | def _get_external_resources(self, cr, uid, external_session, external_id=None, resource_filter=None, |
1963 | mapping=None, mapping_id=None, fields=None, context=None): |
1964 | @@ -1110,8 +1078,8 @@ |
1965 | mapping_id=mapping_id, |
1966 | fields=fields, |
1967 | context=context) |
1968 | - |
1969 | - |
1970 | + |
1971 | + |
1972 | #TODO reimplement the grouped product |
1973 | def ext_create(self, cr, uid, external_session, resources, mapping=None, mapping_id=None, context=None): |
1974 | ext_create_ids={} |
1975 | @@ -1134,7 +1102,7 @@ |
1976 | try: |
1977 | ext_id = self.map_and_update_product(cr, uid, external_session, resource[main_lang], sku, context=context) |
1978 | except: |
1979 | - raise osv.except_osv(_('Error!'), _("Product %s already exist in Magento. Failed to rebind it. Please do it manually")%(sku)) |
1980 | + raise except_osv(_('Error!'), _("Product %s already exist in Magento. Failed to rebind it. Please do it manually")%(sku)) |
1981 | else: |
1982 | raise |
1983 | |
1984 | @@ -1256,10 +1224,10 @@ |
1985 | set_to_product_ids[product.set.id] = [product.id] |
1986 | else: |
1987 | set_to_product_ids[product.set.id].append(product.id) |
1988 | - for attribut_id in set_to_product_ids: |
1989 | + for attribut_id, product_ids in set_to_product_ids.iteritems(): |
1990 | context['attribut_set_id'] = attribut_id |
1991 | resources.update(super(product_product, self)._get_oe_resources( |
1992 | - cr, uid, external_session, ids, langs, |
1993 | + cr, uid, external_session, product_ids, langs, |
1994 | smart_export=smart_export, |
1995 | last_exported_date=last_exported_date, |
1996 | mapping=mapping, |
1997 | @@ -1391,9 +1359,17 @@ |
1998 | break |
1999 | if not_delete: |
2000 | if len(ids) > 1: |
2001 | - raise osv.except_osv(_('Warning!'), _('They are some products related to Magento. They can not be deleted!\nYou can change their Magento status to "Disabled" and uncheck the active box to hide them from OpenERP.')) |
2002 | + raise except_osv(_('Warning!'), |
2003 | + _('They are some products related to Magento. ' |
2004 | + 'They can not be deleted!\n' |
2005 | + 'You can change their Magento status to "Disabled" ' |
2006 | + 'and uncheck the active box to hide them from OpenERP.')) |
2007 | else: |
2008 | - 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.')) |
2009 | + raise except_osv(_('Warning!'), |
2010 | + _('This product is related to Magento. ' |
2011 | + 'It can not be deleted!\n' |
2012 | + 'You can change it Magento status to "Disabled" ' |
2013 | + 'and uncheck the active box to hide it from OpenERP.')) |
2014 | else: |
2015 | return super(product_product, self).unlink(cr, uid, ids, context) |
2016 | |
2017 | @@ -1433,29 +1409,20 @@ |
2018 | #This can be base on the group_fields that can try tle last write date of a group of fields |
2019 | if context is None: context = {} |
2020 | |
2021 | - shop = external_session.sync_from_object |
2022 | - |
2023 | - # exclude service products |
2024 | - stock_product_ids = self.search( |
2025 | - cr, uid, |
2026 | - [('id', 'in', ids), |
2027 | - ('type', '!=', 'service'), |
2028 | - ('magento_exportable', '=', True)], |
2029 | - context=context) |
2030 | - |
2031 | # use the stock location defined on the sale shop |
2032 | # to compute the stock value |
2033 | - stock = shop.warehouse_id.lot_stock_id |
2034 | + stock = external_session.sync_from_object.warehouse_id.lot_stock_id |
2035 | location_ctx = context.copy() |
2036 | location_ctx['location'] = stock.id |
2037 | - products = self.browse( |
2038 | - cr, uid, stock_product_ids, context=location_ctx) |
2039 | + for product_id in ids: |
2040 | + self._export_inventory(cr, uid, external_session, product_id, context=location_ctx) |
2041 | |
2042 | - for product in products: |
2043 | - self._export_inventory(cr, uid, external_session, product, stock, context=location_ctx) |
2044 | return True |
2045 | |
2046 | - def _export_inventory(self, cr, uid, external_session, product, stock, context=None): |
2047 | + @catch_error_in_report |
2048 | + def _export_inventory(self, cr, uid, external_session, product_id, context=None): |
2049 | + product = self.browse(cr, uid, product_id, context=context) |
2050 | + stock = external_session.sync_from_object.warehouse_id.lot_stock_id |
2051 | mag_product_id = self.get_extid( |
2052 | cr, uid, product.id, external_session.referential_id.id, context=context) |
2053 | if not mag_product_id: |
2054 | @@ -1463,7 +1430,7 @@ |
2055 | inventory_vals = self._prepare_inventory_magento_vals( |
2056 | cr, uid, product, stock, external_session.sync_from_object, context=context) |
2057 | |
2058 | - external_session.connection.call('product_stock.update', |
2059 | + external_session.connection.call('oerp_cataloginventory_stock_item.update', |
2060 | [mag_product_id, inventory_vals]) |
2061 | |
2062 | external_session.logger.info( |
2063 | @@ -1617,5 +1584,3 @@ |
2064 | finally: |
2065 | local_cr.close() |
2066 | return True |
2067 | - |
2068 | -product_product() |
2069 | |
2070 | === modified file 'magentoerpconnect/product_images.py' |
2071 | --- magentoerpconnect/product_images.py 2012-06-22 10:15:40 +0000 |
2072 | +++ magentoerpconnect/product_images.py 2012-12-03 15:22:20 +0000 |
2073 | @@ -20,22 +20,30 @@ |
2074 | #You should have received a copy of the GNU General Public License # |
2075 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
2076 | ######################################################################### |
2077 | -from osv import osv, fields |
2078 | -import magerp_osv |
2079 | import mimetypes |
2080 | -import netsvc |
2081 | -from tools.translate import _ |
2082 | -import base64 |
2083 | + |
2084 | +from openerp.osv.orm import Model |
2085 | +from openerp.osv import fields |
2086 | +from openerp.tools.translate import _ |
2087 | + |
2088 | +from .magerp_osv import MagerpModel |
2089 | from base_external_referentials.decorator import commit_now |
2090 | from base_external_referentials.decorator import only_for_referential |
2091 | |
2092 | -#TODO the option small_image, thumbnail, exclude, base_image, should be store diferently indeed this is not compatible with mutli instance (maybe serialized will be a good solution) |
2093 | -#Moreover when a small is selected the flag on other image should be remove as magento does |
2094 | - |
2095 | -#TODO refactor all of this code and use the generic function from base_external_referentials. |
2096 | -#To must useless line of code |
2097 | - |
2098 | -class product_images(magerp_osv.magerp_osv): |
2099 | +#TODO Option on image should be compatible with multi-referential |
2100 | +#Indeed when you have two Magento maybe you do not want to use the |
2101 | +#same image for the base_image, thumbnail ot small_image |
2102 | +#Maybe the solution will to use a serialized field that store the |
2103 | +#value for each referential |
2104 | + |
2105 | +#TODO As only one image can be a small_image, thumbnail or base_image |
2106 | +#We should add some constraint or automatically remove the flag on the |
2107 | +#other image of the product. |
2108 | + |
2109 | +#TODO refactor all of this code and use the generic function from |
2110 | +#base_external_referentials. |
2111 | + |
2112 | +class product_images(MagerpModel): |
2113 | _inherit = "product.images" |
2114 | _columns = { |
2115 | 'base_image':fields.boolean('Base Image'), |
2116 | @@ -46,20 +54,20 @@ |
2117 | 'sync_status':fields.boolean('Sync Status', readonly=True), |
2118 | 'create_date': fields.datetime('Created date', readonly=True), |
2119 | 'write_date': fields.datetime('Updated date', readonly=True), |
2120 | - } |
2121 | + } |
2122 | _defaults = { |
2123 | 'sync_status':lambda * a: False, |
2124 | 'base_image':lambda * a:True, |
2125 | 'small_image':lambda * a:True, |
2126 | 'thumbnail':lambda * a:True, |
2127 | 'exclude':lambda * a:False |
2128 | - } |
2129 | - |
2130 | + } |
2131 | + |
2132 | def get_changed_ids(self, cr, uid, start_date=False): |
2133 | proxy = self.pool.get('product.images') |
2134 | domain = start_date and ['|', ('create_date', '>', start_date), ('write_date', '>', start_date)] or [] |
2135 | return proxy.search(cr, uid, domain) |
2136 | - |
2137 | + |
2138 | def del_image_name(self, cr, uid, id, context=None): |
2139 | if context is None: context = {} |
2140 | image_ext_name_obj = self.pool.get('product.images.external.name') |
2141 | @@ -129,7 +137,7 @@ |
2142 | image_2_date[image['id']] = image['write_date'] or image['create_date'] |
2143 | list_date = date_2_image.keys() |
2144 | list_date.sort() |
2145 | - |
2146 | + |
2147 | ids = [date_2_image[date] for date in list_date] |
2148 | |
2149 | while ids: |
2150 | @@ -185,5 +193,3 @@ |
2151 | ids = ids[1000:] |
2152 | external_session.logger.info("still %s image to export" %len(ids)) |
2153 | return True |
2154 | - |
2155 | -product_images() |
2156 | |
2157 | === modified file 'magentoerpconnect/product_images_view.xml' |
2158 | --- magentoerpconnect/product_images_view.xml 2011-11-27 15:12:39 +0000 |
2159 | +++ magentoerpconnect/product_images_view.xml 2012-12-03 15:22:20 +0000 |
2160 | @@ -1,24 +1,24 @@ |
2161 | <?xml version="1.0" encoding="UTF-8"?> |
2162 | <openerp> |
2163 | - <data> |
2164 | - <record id="view_product_image_form" model="ir.ui.view"> |
2165 | - <field name="name">product.images.form.inherit</field> |
2166 | - <field name="model">product.images</field> |
2167 | - <field name="inherit_id" ref="product_images_olbs.view_product_image_form" /> |
2168 | - <field name="type">form</field> |
2169 | - <field name="arch" type="xml"> |
2170 | - <xpath expr="/form/notebook/page/field[@name='file']" |
2171 | - position="after"> |
2172 | - <group col="4" colspan="2"> |
2173 | - <field name="base_image" colspan="4" /> |
2174 | - <field name="small_image" colspan="4" /> |
2175 | - </group> |
2176 | - <group col="4" colspan="2"> |
2177 | - <field name="thumbnail" colspan="4" /> |
2178 | - <field name="exclude" colspan="4" /> |
2179 | - </group> |
2180 | - </xpath> |
2181 | - </field> |
2182 | - </record> |
2183 | - </data> |
2184 | + <data> |
2185 | + <record id="view_product_image_form" model="ir.ui.view"> |
2186 | + <field name="name">product.images.form.inherit</field> |
2187 | + <field name="model">product.images</field> |
2188 | + <field name="inherit_id" ref="product_images_olbs.view_product_image_form" /> |
2189 | + <field name="type">form</field> |
2190 | + <field name="arch" type="xml"> |
2191 | + <xpath expr="/form/notebook/page/field[@name='file']" |
2192 | + position="after"> |
2193 | + <group col="4" colspan="2"> |
2194 | + <field name="base_image" colspan="4" /> |
2195 | + <field name="small_image" colspan="4" /> |
2196 | + </group> |
2197 | + <group col="4" colspan="2"> |
2198 | + <field name="thumbnail" colspan="4" /> |
2199 | + <field name="exclude" colspan="4" /> |
2200 | + </group> |
2201 | + </xpath> |
2202 | + </field> |
2203 | + </record> |
2204 | + </data> |
2205 | </openerp> |
2206 | |
2207 | === modified file 'magentoerpconnect/product_links.py' |
2208 | --- magentoerpconnect/product_links.py 2011-06-07 14:33:14 +0000 |
2209 | +++ magentoerpconnect/product_links.py 2012-12-03 15:22:20 +0000 |
2210 | @@ -18,14 +18,10 @@ |
2211 | # |
2212 | ############################################################################## |
2213 | |
2214 | -from osv import fields, osv |
2215 | - |
2216 | - |
2217 | -class product_link(osv.osv): |
2218 | +from openerp.osv.orm import Model |
2219 | +from openerp.osv import fields |
2220 | + |
2221 | +class product_link(Model): |
2222 | _inherit = 'product.link' |
2223 | - |
2224 | - _columns = { |
2225 | - 'sequence': fields.integer('Position'), |
2226 | - } |
2227 | - |
2228 | -product_link() |
2229 | + _columns = {'sequence': fields.integer('Position'), |
2230 | + } |
2231 | |
2232 | === modified file 'magentoerpconnect/product_view.xml' |
2233 | --- magentoerpconnect/product_view.xml 2012-06-21 16:33:03 +0000 |
2234 | +++ magentoerpconnect/product_view.xml 2012-12-03 15:22:20 +0000 |
2235 | @@ -1,270 +1,270 @@ |
2236 | <?xml version="1.0" encoding="utf-8"?> |
2237 | <openerp> |
2238 | - <data> |
2239 | - <!--Magento Product Category Tree/Form view --> |
2240 | + <data> |
2241 | + <!--Magento Product Category Tree/Form view --> |
2242 | |
2243 | - <record model="ir.ui.view" id="product_category_form_view_magerp2"> |
2244 | - <field name="name">product.category.form_view_magerp2</field> |
2245 | - <field name="model">product.category</field> |
2246 | - <field name="inherit_id" ref="product.product_category_form_view" /> |
2247 | - <field name="type">form</field> |
2248 | - <field name="arch" type="xml"> |
2249 | - <xpath expr="/form/field[@name='sequence']" position="after"> |
2250 | - <group colspan="4" col="4" attrs="{'invisible':[('magento_exportable','!=',1)],'readonly':[('level','=',0)]}"> |
2251 | - <separator string="Magento Information" colspan="4" /> |
2252 | - <notebook attrs="{'invisible':[('magento_exportable','!=',1)]}" colspan="4"> |
2253 | - <page string="General Information"> |
2254 | - <group cols="2" colspan="4"> |
2255 | - <group col="2" colspan="1"> |
2256 | - <separator string="Meta Information" colspan="2" /> |
2257 | - <field name="meta_title" colspan="2" /> |
2258 | - <field name="meta_keywords" colspan="2" /> |
2259 | - <field name="meta_description" colspan="2" /> |
2260 | - <field name="url_key" colspan="2" /> |
2261 | - <field name="level" colspan="2" /> |
2262 | + <record model="ir.ui.view" id="product_category_form_view_magerp2"> |
2263 | + <field name="name">product.category.form_view_magerp2</field> |
2264 | + <field name="model">product.category</field> |
2265 | + <field name="inherit_id" ref="product.product_category_form_view" /> |
2266 | + <field name="type">form</field> |
2267 | + <field name="arch" type="xml"> |
2268 | + <xpath expr="/form/field[@name='sequence']" position="after"> |
2269 | + <group colspan="4" col="4" attrs="{'invisible':[('magento_exportable','!=',1)],'readonly':[('level','=',0)]}"> |
2270 | + <separator string="Magento Information" colspan="4" /> |
2271 | + <notebook attrs="{'invisible':[('magento_exportable','!=',1)]}" colspan="4"> |
2272 | + <page string="General Information"> |
2273 | + <group cols="2" colspan="4"> |
2274 | + <group col="2" colspan="1"> |
2275 | + <separator string="Meta Information" colspan="2" /> |
2276 | + <field name="meta_title" colspan="2" /> |
2277 | + <field name="meta_keywords" colspan="2" /> |
2278 | + <field name="meta_description" colspan="2" /> |
2279 | + <field name="url_key" colspan="2" /> |
2280 | + <field name="level" colspan="2" /> |
2281 | <field name="include_in_menu" colspan="2" /> |
2282 | - </group> |
2283 | - <group col="1" colspan="1"> |
2284 | - <separator string="Category Image" /> |
2285 | - <field name="image" nolabel="1" widget="image" /> |
2286 | - <field name="image_name" colspan="1" nolabel="1" /> |
2287 | - <separator string="Description" /> |
2288 | - <field name="description" colspan="1" nolabel="1" /> |
2289 | - <group col="4" colspan="1"> |
2290 | - <field name="is_active" colspan="1" /> |
2291 | - <field name="magento_parent_id" /> |
2292 | - </group> |
2293 | - </group> |
2294 | - </group> |
2295 | + </group> |
2296 | + <group col="1" colspan="1"> |
2297 | + <separator string="Category Image" /> |
2298 | + <field name="image" nolabel="1" widget="image" /> |
2299 | + <field name="image_name" colspan="1" nolabel="1" /> |
2300 | + <separator string="Description" /> |
2301 | + <field name="description" colspan="1" nolabel="1" /> |
2302 | + <group col="4" colspan="1"> |
2303 | + <field name="is_active" colspan="1" /> |
2304 | + <field name="magento_parent_id" /> |
2305 | + </group> |
2306 | + </group> |
2307 | + </group> |
2308 | |
2309 | - </page> |
2310 | - <page string="Display Settings"> |
2311 | - <group col="4" colspan="4"> |
2312 | - <separator string="Display Mode" colspan="4" /> |
2313 | - <field name="display_mode" colspan="1" nolabel="1" /> |
2314 | - <label string="Products only means that the products associated to the category will display, but not any static blocks.Static block only means that the selected static block will display, but none of the products.Static block and products means that the static block will display with the products listed directly beneath it." colspan="3" /> |
2315 | - </group> |
2316 | - <separator string="Use Anchor" colspan="4" /> |
2317 | - <group col="4" colspan="4"> |
2318 | - <field name="is_anchor" colspan="1" /> |
2319 | - <label string="Anchored categories will display all products associated to all child categories (and child of child, and child of child of child,etc.) on that category's page, along with the products associated directly to the parent category." colspan="3" /> |
2320 | - </group> |
2321 | + </page> |
2322 | + <page string="Display Settings"> |
2323 | + <group col="4" colspan="4"> |
2324 | + <separator string="Display Mode" colspan="4" /> |
2325 | + <field name="display_mode" colspan="1" nolabel="1" /> |
2326 | + <label string="Products only means that the products associated to the category will display, but not any static blocks.Static block only means that the selected static block will display, but none of the products.Static block and products means that the static block will display with the products listed directly beneath it." colspan="3" /> |
2327 | + </group> |
2328 | + <separator string="Use Anchor" colspan="4" /> |
2329 | + <group col="4" colspan="4"> |
2330 | + <field name="is_anchor" colspan="1" /> |
2331 | + <label string="Anchored categories will display all products associated to all child categories (and child of child, and child of child of child,etc.) on that category's page, along with the products associated directly to the parent category." colspan="3" /> |
2332 | + </group> |
2333 | <group col="4" colspan="4"> |
2334 | <group col="10" colspan="2"> |
2335 | - <separator string="Available Sorting method" colspan="10" /> |
2336 | + <separator string="Available Sorting method" colspan="10" /> |
2337 | <field name="use_default_available_sort_by" string="Use Default Config"/> |
2338 | - <field name="available_sort_by" colspan="10" nolabel="1" attrs="{'readonly':[('use_default_available_sort_by','=',True)],'required':[('use_default_available_sort_by','=',False)]}"> |
2339 | + <field name="available_sort_by" colspan="10" nolabel="1" attrs="{'readonly':[('use_default_available_sort_by','=',True)],'required':[('use_default_available_sort_by','=',False)]}"> |
2340 | <tree string="Available Sort By"> |
2341 | <field name="label"/> |
2342 | </tree> |
2343 | </field> |
2344 | - </group> |
2345 | + </group> |
2346 | <group col="2" colspan="2"> |
2347 | - <separator string="Default Sorting method" colspan="2" /> |
2348 | - <field name="default_sort_by" widget="selection" nolabel="1" domain="[('attribute_name', '=', 'sort_by')]"/> |
2349 | - <separator string="Page Layout" colspan="2" /> |
2350 | - <field name="page_layout" nolabel="1" widget="selection" domain="[('attribute_name', '=', 'page_layout')]"/> |
2351 | + <separator string="Default Sorting method" colspan="2" /> |
2352 | + <field name="default_sort_by" widget="selection" nolabel="1" domain="[('attribute_name', '=', 'sort_by')]"/> |
2353 | + <separator string="Page Layout" colspan="2" /> |
2354 | + <field name="page_layout" nolabel="1" widget="selection" domain="[('attribute_name', '=', 'page_layout')]"/> |
2355 | </group> |
2356 | </group> |
2357 | - </page> |
2358 | - </notebook> |
2359 | - </group> |
2360 | - </xpath> |
2361 | - </field> |
2362 | - </record> |
2363 | - |
2364 | - <record model="ir.ui.view" id="product_category_form_view_magerp"> |
2365 | - <field name="name">product.category.form_view_magerp</field> |
2366 | - <field name="model">product.category</field> |
2367 | - <field name="inherit_id" ref="product.product_category_form_view" /> |
2368 | - <field name="type">form</field> |
2369 | - <field name="arch" type="xml"> |
2370 | - <field name="sequence" position="after"> |
2371 | - <field name="magento_exportable" /> |
2372 | - </field> |
2373 | - </field> |
2374 | - </record> |
2375 | - |
2376 | - <!--Magento product_attribute_set Tree/Form view --> |
2377 | - <record model="ir.ui.view" id="magerp_product_attribute_set_form"> |
2378 | - <field name="name">magerp.product_attribute_set.form</field> |
2379 | - <field name="model">magerp.product_attribute_set</field> |
2380 | - <field name="type">form</field> |
2381 | - <field name="arch" type="xml"> |
2382 | - <form string="Magento Product Attribute Sets"> |
2383 | - <group col="4" colspan="4"> |
2384 | - <field name="sort_order" readonly="1" /> |
2385 | - <field name="attribute_set_name" readonly="1" /> |
2386 | - <button name="update_attribute" string="Update Attributes" colspan="2" type="object" /> |
2387 | - </group> |
2388 | - <separator string="Attributes in Set" colspan="4" /> |
2389 | - <field name="attributes" nolabel="1" readonly="1" /> |
2390 | - </form> |
2391 | - </field> |
2392 | - </record> |
2393 | - <record model="ir.ui.view" id="magerp_product_attribute_set_tree"> |
2394 | - <field name="name">magerp.product_attribute_set.tree</field> |
2395 | - <field name="model">magerp.product_attribute_set</field> |
2396 | - <field name="type">tree</field> |
2397 | - <field name="arch" type="xml"> |
2398 | - <tree string="Magento Product Attribute Set"> |
2399 | - <field name="sort_order" select="2" /> |
2400 | - <field name="attribute_set_name" select="1" /> |
2401 | - </tree> |
2402 | - </field> |
2403 | - </record> |
2404 | - <record id="act_magerp_product_attribute_set_form" model="ir.actions.act_window"> |
2405 | - <field name="name">Magento Product Attribute Sets</field> |
2406 | - <field name="res_model">magerp.product_attribute_set</field> |
2407 | - <field name="src_model">magerp.product_attribute_set</field> |
2408 | - <field name="type">ir.actions.act_window</field> |
2409 | - <field name="view_type">form</field> |
2410 | - <field name="view_mode">tree,form</field> |
2411 | - <field name="view_id" ref="magerp_product_attribute_set_tree" /> |
2412 | - </record> |
2413 | - |
2414 | - <!--Magento product_attributes Tree/Form view --> |
2415 | - <record model="ir.ui.view" id="magerp_product_attributes_form"> |
2416 | - <field name="name">magerp.product_attributes.form</field> |
2417 | - <field name="model">magerp.product_attributes</field> |
2418 | - <field name="type">form</field> |
2419 | - <field name="arch" type="xml"> |
2420 | - <form string="Magento Product Attributes"> |
2421 | - <group col="4" colspan="4"> |
2422 | - <field name="attribute_code" /> |
2423 | - <field name="frontend_input" select="2" /> |
2424 | - <field name="frontend_class" /> |
2425 | - <field name="backend_model" /> |
2426 | - <field name="backend_type" select="2" /> |
2427 | - <field name="frontend_label"/> |
2428 | - |
2429 | - <field name="is_visible_in_advanced_search" select="2" /> |
2430 | - <field name="is_global" /> |
2431 | - <field name="is_filterable" /> |
2432 | - <field name="is_comparable" /> |
2433 | - <field name="is_visible" /> |
2434 | - <field name="is_searchable" /> |
2435 | - <field name="is_user_defined" /> |
2436 | - <field name="is_configurable" /> |
2437 | - |
2438 | - <field name="is_visible_on_front" /> |
2439 | - <field name="is_used_for_price_rules" /> |
2440 | - <field name="is_unique" /> |
2441 | - <field name="is_required" /> |
2442 | - <field name="position" /> |
2443 | - |
2444 | - <field name="group" /> |
2445 | - <field name="apply_to" select="2" /> |
2446 | - <field name="default_value" /> |
2447 | - <field name="note" /> |
2448 | - <field name="entity_type_id" /> |
2449 | - <field name="options" readonly="1" /> |
2450 | + </page> |
2451 | + </notebook> |
2452 | + </group> |
2453 | + </xpath> |
2454 | + </field> |
2455 | + </record> |
2456 | + |
2457 | + <record model="ir.ui.view" id="product_category_form_view_magerp"> |
2458 | + <field name="name">product.category.form_view_magerp</field> |
2459 | + <field name="model">product.category</field> |
2460 | + <field name="inherit_id" ref="product.product_category_form_view" /> |
2461 | + <field name="type">form</field> |
2462 | + <field name="arch" type="xml"> |
2463 | + <field name="sequence" position="after"> |
2464 | + <field name="magento_exportable" /> |
2465 | + </field> |
2466 | + </field> |
2467 | + </record> |
2468 | + |
2469 | + <!--Magento product_attribute_set Tree/Form view --> |
2470 | + <record model="ir.ui.view" id="magerp_product_attribute_set_form"> |
2471 | + <field name="name">magerp.product_attribute_set.form</field> |
2472 | + <field name="model">magerp.product_attribute_set</field> |
2473 | + <field name="type">form</field> |
2474 | + <field name="arch" type="xml"> |
2475 | + <form string="Magento Product Attribute Sets"> |
2476 | + <group col="4" colspan="4"> |
2477 | + <field name="sort_order" readonly="1" /> |
2478 | + <field name="attribute_set_name" readonly="1" /> |
2479 | + <button name="update_attribute" string="Update Attributes" colspan="2" type="object" /> |
2480 | + </group> |
2481 | + <separator string="Attributes in Set" colspan="4" /> |
2482 | + <field name="attributes" nolabel="1" readonly="1" /> |
2483 | + </form> |
2484 | + </field> |
2485 | + </record> |
2486 | + <record model="ir.ui.view" id="magerp_product_attribute_set_tree"> |
2487 | + <field name="name">magerp.product_attribute_set.tree</field> |
2488 | + <field name="model">magerp.product_attribute_set</field> |
2489 | + <field name="type">tree</field> |
2490 | + <field name="arch" type="xml"> |
2491 | + <tree string="Magento Product Attribute Set"> |
2492 | + <field name="sort_order" select="2" /> |
2493 | + <field name="attribute_set_name" select="1" /> |
2494 | + </tree> |
2495 | + </field> |
2496 | + </record> |
2497 | + <record id="act_magerp_product_attribute_set_form" model="ir.actions.act_window"> |
2498 | + <field name="name">Magento Product Attribute Sets</field> |
2499 | + <field name="res_model">magerp.product_attribute_set</field> |
2500 | + <field name="src_model">magerp.product_attribute_set</field> |
2501 | + <field name="type">ir.actions.act_window</field> |
2502 | + <field name="view_type">form</field> |
2503 | + <field name="view_mode">tree,form</field> |
2504 | + <field name="view_id" ref="magerp_product_attribute_set_tree" /> |
2505 | + </record> |
2506 | + |
2507 | + <!--Magento product_attributes Tree/Form view --> |
2508 | + <record model="ir.ui.view" id="magerp_product_attributes_form"> |
2509 | + <field name="name">magerp.product_attributes.form</field> |
2510 | + <field name="model">magerp.product_attributes</field> |
2511 | + <field name="type">form</field> |
2512 | + <field name="arch" type="xml"> |
2513 | + <form string="Magento Product Attributes"> |
2514 | + <group col="4" colspan="4"> |
2515 | + <field name="attribute_code" /> |
2516 | + <field name="frontend_input" select="2" /> |
2517 | + <field name="frontend_class" /> |
2518 | + <field name="backend_model" /> |
2519 | + <field name="backend_type" select="2" /> |
2520 | + <field name="frontend_label"/> |
2521 | + |
2522 | + <field name="is_visible_in_advanced_search" select="2" /> |
2523 | + <field name="is_global" /> |
2524 | + <field name="is_filterable" /> |
2525 | + <field name="is_comparable" /> |
2526 | + <field name="is_visible" /> |
2527 | + <field name="is_searchable" /> |
2528 | + <field name="is_user_defined" /> |
2529 | + <field name="is_configurable" /> |
2530 | + |
2531 | + <field name="is_visible_on_front" /> |
2532 | + <field name="is_used_for_price_rules" /> |
2533 | + <field name="is_unique" /> |
2534 | + <field name="is_required" /> |
2535 | + <field name="position" /> |
2536 | + |
2537 | + <field name="group" /> |
2538 | + <field name="apply_to" select="2" /> |
2539 | + <field name="default_value" /> |
2540 | + <field name="note" /> |
2541 | + <field name="entity_type_id" /> |
2542 | + <field name="options" readonly="1" /> |
2543 | <field name="field_name" /> |
2544 | <field name="based_on" /> |
2545 | - </group> |
2546 | - </form> |
2547 | - </field> |
2548 | - </record> |
2549 | - <record model="ir.ui.view" id="magerp_product_attributes_tree"> |
2550 | - <field name="name">magerp.product_attributes.tree</field> |
2551 | - <field name="model">magerp.product_attributes</field> |
2552 | - <field name="type">tree</field> |
2553 | - <field name="arch" type="xml"> |
2554 | - <tree string="Magento Product Attributes"> |
2555 | - <field name="attribute_code" select="1" /> |
2556 | - <field name="frontend_label" select="1"/> |
2557 | - <field name="is_visible" select="1"/> |
2558 | - <field name="is_required" select="1"/> |
2559 | - <field name="is_searchable" select="1" /> |
2560 | - <field name="is_comparable" select="1" /> |
2561 | - <field name="entity_type_id" select="1" /> |
2562 | - <field name="group" select="1" /> |
2563 | - </tree> |
2564 | - </field> |
2565 | - </record> |
2566 | - <record id="act_magerp_product_attributes_form" model="ir.actions.act_window"> |
2567 | - <field name="name">Magento Product Attributes</field> |
2568 | - <field name="res_model">magerp.product_attributes</field> |
2569 | - <field name="src_model">magerp.product_attributes</field> |
2570 | - <field name="type">ir.actions.act_window</field> |
2571 | - <field name="view_type">form</field> |
2572 | - <field name="view_mode">tree,form</field> |
2573 | - <field name="view_id" ref="magerp_product_attributes_tree" /> |
2574 | - </record> |
2575 | - |
2576 | - <!--Magento product_attribute groups Tree/Form view --> |
2577 | - <record model="ir.ui.view" id="magerp_product_attribute_groups_form"> |
2578 | - <field name="name">magerp.product_attribute_groups.form</field> |
2579 | - <field name="model">magerp.product_attribute_groups</field> |
2580 | - <field name="type">form</field> |
2581 | - <field name="arch" type="xml"> |
2582 | - <form string="Magento Product Attributes Groups"> |
2583 | - <group col="4" colspan="4"> |
2584 | - <field name="attribute_group_name" /> |
2585 | - <field name="attribute_set" /> |
2586 | - <field name="default_id" /> |
2587 | - <field name="sort_order" /> |
2588 | - </group> |
2589 | - </form> |
2590 | - </field> |
2591 | - </record> |
2592 | - <record model="ir.ui.view" id="magerp_product_attribute_groups_tree"> |
2593 | - <field name="name">magerp.product_attribute_groups.tree</field> |
2594 | - <field name="model">magerp.product_attribute_groups</field> |
2595 | - <field name="type">tree</field> |
2596 | - <field name="arch" type="xml"> |
2597 | - <tree string="Magento Product Attribute groups"> |
2598 | - <field name="attribute_group_name" select="1" /> |
2599 | - <field name="attribute_set" select="2" /> |
2600 | - <field name="default_id" select="2" /> |
2601 | - <field name="sort_order" select="2" /> |
2602 | - </tree> |
2603 | - </field> |
2604 | - </record> |
2605 | - <record id="act_magerp_product_attribute_groups_form" model="ir.actions.act_window"> |
2606 | - <field name="name">Magento Product Attribute Groups</field> |
2607 | - <field name="res_model">magerp.product_attribute_groups</field> |
2608 | - <field name="src_model">magerp.product_attribute_groups</field> |
2609 | - <field name="type">ir.actions.act_window</field> |
2610 | - <field name="view_type">form</field> |
2611 | - <field name="view_mode">tree,form</field> |
2612 | - <field name="view_id" ref="magerp_product_attribute_groups_tree" /> |
2613 | - </record> |
2614 | - |
2615 | - <!-- This is a product inherited form that will be dynamically populated--> |
2616 | - <record model="ir.ui.view" id="product_product_form_view_magerp"> |
2617 | - <field name="name">product.normal.form_magerp</field> |
2618 | - <field name="model">product.product</field> |
2619 | - <field name="inherit_id" ref="product.product_normal_form_view" /> |
2620 | - <field name="type">form</field> |
2621 | - <field name="arch" type="xml"> |
2622 | - <data> |
2623 | - <xpath expr="/form/group/group/field[@name='ean13']" position="after"> |
2624 | + </group> |
2625 | + </form> |
2626 | + </field> |
2627 | + </record> |
2628 | + <record model="ir.ui.view" id="magerp_product_attributes_tree"> |
2629 | + <field name="name">magerp.product_attributes.tree</field> |
2630 | + <field name="model">magerp.product_attributes</field> |
2631 | + <field name="type">tree</field> |
2632 | + <field name="arch" type="xml"> |
2633 | + <tree string="Magento Product Attributes"> |
2634 | + <field name="attribute_code" select="1" /> |
2635 | + <field name="frontend_label" select="1"/> |
2636 | + <field name="is_visible" select="1"/> |
2637 | + <field name="is_required" select="1"/> |
2638 | + <field name="is_searchable" select="1" /> |
2639 | + <field name="is_comparable" select="1" /> |
2640 | + <field name="entity_type_id" select="1" /> |
2641 | + <field name="group" select="1" /> |
2642 | + </tree> |
2643 | + </field> |
2644 | + </record> |
2645 | + <record id="act_magerp_product_attributes_form" model="ir.actions.act_window"> |
2646 | + <field name="name">Magento Product Attributes</field> |
2647 | + <field name="res_model">magerp.product_attributes</field> |
2648 | + <field name="src_model">magerp.product_attributes</field> |
2649 | + <field name="type">ir.actions.act_window</field> |
2650 | + <field name="view_type">form</field> |
2651 | + <field name="view_mode">tree,form</field> |
2652 | + <field name="view_id" ref="magerp_product_attributes_tree" /> |
2653 | + </record> |
2654 | + |
2655 | + <!--Magento product_attribute groups Tree/Form view --> |
2656 | + <record model="ir.ui.view" id="magerp_product_attribute_groups_form"> |
2657 | + <field name="name">magerp.product_attribute_groups.form</field> |
2658 | + <field name="model">magerp.product_attribute_groups</field> |
2659 | + <field name="type">form</field> |
2660 | + <field name="arch" type="xml"> |
2661 | + <form string="Magento Product Attributes Groups"> |
2662 | + <group col="4" colspan="4"> |
2663 | + <field name="attribute_group_name" /> |
2664 | + <field name="attribute_set" /> |
2665 | + <field name="default_id" /> |
2666 | + <field name="sort_order" /> |
2667 | + </group> |
2668 | + </form> |
2669 | + </field> |
2670 | + </record> |
2671 | + <record model="ir.ui.view" id="magerp_product_attribute_groups_tree"> |
2672 | + <field name="name">magerp.product_attribute_groups.tree</field> |
2673 | + <field name="model">magerp.product_attribute_groups</field> |
2674 | + <field name="type">tree</field> |
2675 | + <field name="arch" type="xml"> |
2676 | + <tree string="Magento Product Attribute groups"> |
2677 | + <field name="attribute_group_name" select="1" /> |
2678 | + <field name="attribute_set" select="2" /> |
2679 | + <field name="default_id" select="2" /> |
2680 | + <field name="sort_order" select="2" /> |
2681 | + </tree> |
2682 | + </field> |
2683 | + </record> |
2684 | + <record id="act_magerp_product_attribute_groups_form" model="ir.actions.act_window"> |
2685 | + <field name="name">Magento Product Attribute Groups</field> |
2686 | + <field name="res_model">magerp.product_attribute_groups</field> |
2687 | + <field name="src_model">magerp.product_attribute_groups</field> |
2688 | + <field name="type">ir.actions.act_window</field> |
2689 | + <field name="view_type">form</field> |
2690 | + <field name="view_mode">tree,form</field> |
2691 | + <field name="view_id" ref="magerp_product_attribute_groups_tree" /> |
2692 | + </record> |
2693 | + |
2694 | + <!-- This is a product inherited form that will be dynamically populated--> |
2695 | + <record model="ir.ui.view" id="product_product_form_view_magerp"> |
2696 | + <field name="name">product.normal.form_magerp</field> |
2697 | + <field name="model">product.product</field> |
2698 | + <field name="inherit_id" ref="product.product_normal_form_view" /> |
2699 | + <field name="type">form</field> |
2700 | + <field name="arch" type="xml"> |
2701 | + <data> |
2702 | + <xpath expr="/form/group/group/field[@name='ean13']" position="after"> |
2703 | <field name="magento_exported" invisible="True"/> |
2704 | - </xpath> |
2705 | - <xpath expr="/form/group/group/field[@name='variants']" position="after"> |
2706 | - <field name="set" select="2" attrs="{'required':[('magento_exportable','==',True)], 'readonly': [('magento_exported', '=', True)]}"/> |
2707 | - </xpath> |
2708 | - <xpath expr="/form/group/group/field[@name='sale_ok']" position="before"> |
2709 | - <button name="open_magento_fields"/> |
2710 | - </xpath> |
2711 | - <xpath expr="/form/notebook" position="before"> |
2712 | - <field name="magento_exportable" select="2"/> |
2713 | - </xpath> |
2714 | - </data> |
2715 | - </field> |
2716 | - </record> |
2717 | - <record model="ir.ui.view" id="product_product_form_view_magerpdynamic"> |
2718 | - <field name="name">product.normal.form_magerp_dynamic</field> |
2719 | - <field name="model">product.product</field> |
2720 | - <field name="inherit_id" ref="product.product_normal_form_view" /> |
2721 | - <field name="type">form</field> |
2722 | - <field name="arch" type="xml"> |
2723 | - <xpath expr="/form/notebook" position="inside"> |
2724 | - <page string="attributes_placeholder"/> |
2725 | - </xpath> |
2726 | - </field> |
2727 | - </record> |
2728 | + </xpath> |
2729 | + <xpath expr="/form/group/group/field[@name='variants']" position="after"> |
2730 | + <field name="set" select="2" attrs="{'required':[('magento_exportable','==',True)], 'readonly': [('magento_exported', '=', True)]}"/> |
2731 | + </xpath> |
2732 | + <xpath expr="/form/group/group/field[@name='sale_ok']" position="before"> |
2733 | + <button name="open_magento_fields"/> |
2734 | + </xpath> |
2735 | + <xpath expr="/form/notebook" position="before"> |
2736 | + <field name="magento_exportable" select="2"/> |
2737 | + </xpath> |
2738 | + </data> |
2739 | + </field> |
2740 | + </record> |
2741 | + <record model="ir.ui.view" id="product_product_form_view_magerpdynamic"> |
2742 | + <field name="name">product.normal.form_magerp_dynamic</field> |
2743 | + <field name="model">product.product</field> |
2744 | + <field name="inherit_id" ref="product.product_normal_form_view" /> |
2745 | + <field name="type">form</field> |
2746 | + <field name="arch" type="xml"> |
2747 | + <xpath expr="/form/notebook" position="inside"> |
2748 | + <page string="attributes_placeholder"/> |
2749 | + </xpath> |
2750 | + </field> |
2751 | + </record> |
2752 | |
2753 | <!--Magento Product Product Wizard Form view--> |
2754 | |
2755 | @@ -293,34 +293,34 @@ |
2756 | </field> |
2757 | </record> |
2758 | |
2759 | - <!--Magento Product Type Tree/Form view --> |
2760 | - <record model="ir.ui.view" id="magerp_product_type_form"> |
2761 | - <field name="name">magerp.product_product_type.form</field> |
2762 | - <field name="model">magerp.product_product_type</field> |
2763 | - <field name="type">form</field> |
2764 | - <field name="priority" eval="5"/> |
2765 | - <field name="arch" type="xml"> |
2766 | - <form string="Product Type"> |
2767 | + <!--Magento Product Type Tree/Form view --> |
2768 | + <record model="ir.ui.view" id="magerp_product_type_form"> |
2769 | + <field name="name">magerp.product_product_type.form</field> |
2770 | + <field name="model">magerp.product_product_type</field> |
2771 | + <field name="type">form</field> |
2772 | + <field name="priority" eval="5"/> |
2773 | + <field name="arch" type="xml"> |
2774 | + <form string="Product Type"> |
2775 | <field name="product_type"/> |
2776 | <field name="name"/> |
2777 | <field name="default_type"/> |
2778 | - </form> |
2779 | - </field> |
2780 | - </record> |
2781 | - |
2782 | - <record model="ir.ui.view" id="magerp_product_type_tree"> |
2783 | - <field name="name">magerp.product_product_type.tree</field> |
2784 | - <field name="model">magerp.product_product_type</field> |
2785 | - <field name="type">tree</field> |
2786 | - <field name="priority" eval="5"/> |
2787 | - <field name="arch" type="xml"> |
2788 | - <tree string="Product Type" editable="top"> |
2789 | - <field name="name" select="1"/> |
2790 | - <field name="product_type" select="1"/> |
2791 | + </form> |
2792 | + </field> |
2793 | + </record> |
2794 | + |
2795 | + <record model="ir.ui.view" id="magerp_product_type_tree"> |
2796 | + <field name="name">magerp.product_product_type.tree</field> |
2797 | + <field name="model">magerp.product_product_type</field> |
2798 | + <field name="type">tree</field> |
2799 | + <field name="priority" eval="5"/> |
2800 | + <field name="arch" type="xml"> |
2801 | + <tree string="Product Type" editable="top"> |
2802 | + <field name="name" select="1"/> |
2803 | + <field name="product_type" select="1"/> |
2804 | <field name="default_type" select="1"/> |
2805 | - </tree> |
2806 | - </field> |
2807 | - </record> |
2808 | + </tree> |
2809 | + </field> |
2810 | + </record> |
2811 | |
2812 | <record model="ir.actions.act_window" id="act_magerp_product_type_form"> |
2813 | <field name="name">Product Types</field> |
2814 | @@ -331,43 +331,43 @@ |
2815 | |
2816 | |
2817 | <!--Magento product_category attribute_option Tree/Form view --> |
2818 | - <record model="ir.ui.view" id="magerp_product_category_attribute_options_form"> |
2819 | - <field name="name">magerp.product_category_attribute_options.form</field> |
2820 | - <field name="model">magerp.product_category_attribute_options</field> |
2821 | - <field name="type">form</field> |
2822 | - <field name="arch" type="xml"> |
2823 | - <form string="Magento Product Category Attribute Option"> |
2824 | - <group col="4" colspan="4"> |
2825 | - <field name="attribute_name" /> |
2826 | - <field name="label" /> |
2827 | - <field name="value" /> |
2828 | - </group> |
2829 | - </form> |
2830 | - </field> |
2831 | - </record> |
2832 | - |
2833 | - <record model="ir.ui.view" id="magerp_product_category_attribute_options_tree"> |
2834 | - <field name="name">magerp.product_category_attribute_options.tree</field> |
2835 | - <field name="model">magerp.product_category_attribute_options</field> |
2836 | - <field name="type">tree</field> |
2837 | - <field name="arch" type="xml"> |
2838 | - <tree string="Magento Product Category Attribute Option"> |
2839 | - <field name="attribute_name" /> |
2840 | - <field name="label" /> |
2841 | - <field name="value" /> |
2842 | - </tree> |
2843 | - </field> |
2844 | - </record> |
2845 | - |
2846 | - <record id="act_magerp_product_category_attribute_options_form" model="ir.actions.act_window"> |
2847 | - <field name="name">Magento Product Category Attribute Options</field> |
2848 | - <field name="res_model">magerp.product_category_attribute_options</field> |
2849 | + <record model="ir.ui.view" id="magerp_product_category_attribute_options_form"> |
2850 | + <field name="name">magerp.product_category_attribute_options.form</field> |
2851 | + <field name="model">magerp.product_category_attribute_options</field> |
2852 | + <field name="type">form</field> |
2853 | + <field name="arch" type="xml"> |
2854 | + <form string="Magento Product Category Attribute Option"> |
2855 | + <group col="4" colspan="4"> |
2856 | + <field name="attribute_name" /> |
2857 | + <field name="label" /> |
2858 | + <field name="value" /> |
2859 | + </group> |
2860 | + </form> |
2861 | + </field> |
2862 | + </record> |
2863 | + |
2864 | + <record model="ir.ui.view" id="magerp_product_category_attribute_options_tree"> |
2865 | + <field name="name">magerp.product_category_attribute_options.tree</field> |
2866 | + <field name="model">magerp.product_category_attribute_options</field> |
2867 | + <field name="type">tree</field> |
2868 | + <field name="arch" type="xml"> |
2869 | + <tree string="Magento Product Category Attribute Option"> |
2870 | + <field name="attribute_name" /> |
2871 | + <field name="label" /> |
2872 | + <field name="value" /> |
2873 | + </tree> |
2874 | + </field> |
2875 | + </record> |
2876 | + |
2877 | + <record id="act_magerp_product_category_attribute_options_form" model="ir.actions.act_window"> |
2878 | + <field name="name">Magento Product Category Attribute Options</field> |
2879 | + <field name="res_model">magerp.product_category_attribute_options</field> |
2880 | <field name="src_model">magerp.product_category_attribute_options</field> |
2881 | - <field name="type">ir.actions.act_window</field> |
2882 | - <field name="view_type">form</field> |
2883 | - <field name="view_mode">tree,form</field> |
2884 | - <field name="view_id" ref="magerp_product_category_attribute_options_tree" /> |
2885 | - </record> |
2886 | + <field name="type">ir.actions.act_window</field> |
2887 | + <field name="view_type">form</field> |
2888 | + <field name="view_mode">tree,form</field> |
2889 | + <field name="view_id" ref="magerp_product_category_attribute_options_tree" /> |
2890 | + </record> |
2891 | |
2892 | <!--Magento attribute_option Search/Tree/Form view --> |
2893 | |
2894 | @@ -433,5 +433,5 @@ |
2895 | <field name="search_view_id" ref="magerp_product_attribute_options_search"/> |
2896 | </record> |
2897 | |
2898 | - </data> |
2899 | + </data> |
2900 | </openerp> |
2901 | |
2902 | === modified file 'magentoerpconnect/sale.py' |
2903 | --- magentoerpconnect/sale.py 2012-08-20 09:39:45 +0000 |
2904 | +++ magentoerpconnect/sale.py 2012-12-03 15:22:20 +0000 |
2905 | @@ -22,17 +22,16 @@ |
2906 | #along with this program. If not, see <http://www.gnu.org/licenses/>. # |
2907 | ######################################################################### |
2908 | |
2909 | -from osv import osv, fields |
2910 | -import pooler |
2911 | -import magerp_osv |
2912 | +from openerp.osv.orm import Model |
2913 | +from openerp.osv import fields |
2914 | +from openerp.osv.osv import except_osv |
2915 | import netsvc |
2916 | from tools.translate import _ |
2917 | -import string |
2918 | -import tools |
2919 | +from openerp import tools |
2920 | import time |
2921 | from tools import DEFAULT_SERVER_DATETIME_FORMAT |
2922 | from base_external_referentials.external_osv import ExternalSession |
2923 | -from base_external_referentials.decorator import only_for_referential |
2924 | +from base_external_referentials.decorator import only_for_referential, open_report |
2925 | |
2926 | #from base_external_referentials import report |
2927 | |
2928 | @@ -54,7 +53,7 @@ |
2929 | 'waiting_date': 'holded'} |
2930 | SALE_ORDER_IMPORT_STEP = 200 |
2931 | |
2932 | -class sale_shop(osv.osv): |
2933 | +class sale_shop(Model): |
2934 | _inherit = "sale.shop" |
2935 | |
2936 | @only_for_referential('magento') |
2937 | @@ -71,14 +70,16 @@ |
2938 | context['lang_to_export'].append(storeview.lang_id.code) |
2939 | return context |
2940 | |
2941 | - |
2942 | - |
2943 | def _get_exportable_product_ids(self, cr, uid, ids, name, args, context=None): |
2944 | res = super(sale_shop, self)._get_exportable_product_ids(cr, uid, ids, name, args, context=None) |
2945 | for shop_id in res: |
2946 | website_id = self.read(cr, uid, shop_id, ['shop_group_id']) |
2947 | if website_id.get('shop_group_id', False): |
2948 | - res[shop_id] = self.pool.get('product.product').search(cr, uid, [('magento_exportable', '=', True), ('id', 'in', res[shop_id]), "|", ('websites_ids', 'in', [website_id['shop_group_id'][0]]) , ('websites_ids', '=', False)]) |
2949 | + res[shop_id] = self.pool.get('product.product').search(cr, uid, |
2950 | + [('magento_exportable', '=', True), |
2951 | + ('id', 'in', res[shop_id]), |
2952 | + "|", ('websites_ids', 'in', [website_id['shop_group_id'][0]]), |
2953 | + ('websites_ids', '=', False)]) |
2954 | else: |
2955 | res[shop_id] = [] |
2956 | return res |
2957 | @@ -138,7 +139,10 @@ |
2958 | if model_data_id: |
2959 | ir_model_data_obj.write(cr, uid, model_data_id, {'res_id' : value}, context=context) |
2960 | else: |
2961 | - raise osv.except_osv(_('Warning!'), _('No external id found, are you sure that the referential are syncronized? Please contact your administrator. (more information in magentoerpconnect/sale.py)')) |
2962 | + raise except_osv(_('Warning!'), |
2963 | + _('No external id found, are you sure that the referential are syncronized? ' |
2964 | + 'Please contact your administrator. ' |
2965 | + '(more information in magentoerpconnect/sale.py)')) |
2966 | return True |
2967 | |
2968 | def _get_exportable_root_category_ids(self, cr, uid, ids, prop, unknow_none, context=None): |
2969 | @@ -155,6 +159,11 @@ |
2970 | defaults.update({'magento_shop' : True}) |
2971 | return defaults |
2972 | |
2973 | + @only_for_referential('magento') |
2974 | + @open_report |
2975 | + def _export_inventory(self, *args, **kwargs): |
2976 | + return super(sale_shop, self)._export_inventory(*args, **kwargs) |
2977 | + |
2978 | _columns = { |
2979 | 'default_storeview_integer_id':fields.integer('Magento default Storeview ID'), #This field can't be a many2one because store field will be mapped before creating storeviews |
2980 | 'default_storeview_id':fields.function(_get_default_storeview_id, type="many2one", relation="magerp.storeviews", method=True, string="Default Storeview"), |
2981 | @@ -234,12 +243,9 @@ |
2982 | def run_import_check_need_to_update(self, cr, uid, context=None): |
2983 | self._sale_shop(cr, uid, self.check_need_to_update, context=context) |
2984 | |
2985 | -sale_shop() |
2986 | - |
2987 | - |
2988 | -class sale_order(osv.osv): |
2989 | + |
2990 | +class sale_order(Model): |
2991 | _inherit = "sale.order" |
2992 | - |
2993 | _columns = { |
2994 | 'magento_incrementid': fields.char('Magento Increment ID', size=32), |
2995 | 'magento_storeview_id': fields.many2one('magerp.storeviews', 'Magento Store View'), |
2996 | @@ -247,7 +253,7 @@ |
2997 | 'shop_id', 'referential_id', 'magento_referential', |
2998 | type='boolean', |
2999 | string='Is a Magento Sale Order') |
3000 | - } |
3001 | + } |
3002 | |
3003 | def _auto_init(self, cr, context=None): |
3004 | tools.drop_view_if_exists(cr, 'sale_report') |
3005 | @@ -323,7 +329,7 @@ |
3006 | wf_service.trg_validate(uid, 'sale.order', canceled_order_id, 'cancel', cr) |
3007 | self.log(cr, uid, canceled_order_id, "order %s canceled when updated from external system" % (canceled_order_id,)) |
3008 | _logger.info("Order %s canceled when updated from external system because it has been replaced by a new one", canceled_order_id) |
3009 | - except osv.except_osv, e: |
3010 | + except except_osv, e: |
3011 | #TODO: generic reporting of errors in magentoerpconnect |
3012 | # except if the sale order has been confirmed for example, we cannot cancel the order |
3013 | to_cancel_order_name = self.read(cr, uid, canceled_order_id, ['name'])['name'] |
3014 | @@ -384,7 +390,7 @@ |
3015 | resource['lastname'] = resource['customer_lastname'] |
3016 | resource['email'] = resource['customer_email'] |
3017 | |
3018 | - shop = self.pool.get('sale.shop').browse(cr, uid, defaults['shop_id'], context=context) |
3019 | + shop = external_session.sync_from_object |
3020 | partner_defaults = {'website_id': shop.shop_group_id.id} |
3021 | res = self.pool.get('res.partner')._record_one_external_resource(cr, uid, external_session, resource,\ |
3022 | mapping=mapping, defaults=partner_defaults, context=context) |
3023 | @@ -401,14 +407,17 @@ |
3024 | mapping_line_filter_ids=None, parent_data=None, previous_result=None, defaults=None, context=None): |
3025 | resource = self.clean_magento_resource(cr, uid, resource, context=context) |
3026 | resource = self.clean_magento_items(cr, uid, resource, context=context) |
3027 | - if not resource['customer_id']: |
3028 | - #If there is not partner it's a guest order |
3029 | - #So we remove the useless information |
3030 | - #And create a partner on fly and set the data in the default value |
3031 | - del resource['customer_id'] |
3032 | - del resource['billing_address']['customer_id'] |
3033 | - del resource['shipping_address']['customer_id'] |
3034 | - defaults = self.create_onfly_partner(cr, uid, external_session, resource, mapping, defaults, context=context) |
3035 | + for line in mapping[mapping_id]['mapping_lines']: |
3036 | + if line['name'] == 'customer_id' and not resource.get('customer_id'): |
3037 | + #If there is not partner it's a guest order |
3038 | + #So we remove the useless information |
3039 | + #And create a partner on fly and set the data in the default value |
3040 | + #We only do this if the customer_id is in the mapping line |
3041 | + #Indeed when we check if a sale order exist only the name is asked for convertion |
3042 | + resource.pop('customer_id', None) |
3043 | + resource['billing_address'].pop('customer_id', None) |
3044 | + resource['shipping_address'].pop('customer_id', None) |
3045 | + defaults = self.create_onfly_partner(cr, uid, external_session, resource, mapping, defaults, context=context) |
3046 | |
3047 | return super(sale_order, self)._transform_one_resource(cr, uid, external_session, convertion_type, resource,\ |
3048 | mapping, mapping_id, mapping_line_filter_ids=mapping_line_filter_ids, parent_data=parent_data,\ |
3049 | @@ -624,7 +633,7 @@ |
3050 | # in the sale order and sometime it's equal to NONE in the address but at least the |
3051 | # the information is correct in one of this field |
3052 | # So I make this ugly code to try to fix it. |
3053 | - if not resource['customer_id']: |
3054 | + if not resource.get('customer_id'): |
3055 | if resource['billing_address'].get('customer_id'): |
3056 | resource['customer_id'] = resource['billing_address']['customer_id'] |
3057 | else: |
3058 | @@ -634,13 +643,9 @@ |
3059 | resource['shipping_address']['customer_id'] = resource['customer_id'] |
3060 | return resource |
3061 | |
3062 | -sale_order() |
3063 | - |
3064 | - |
3065 | -class sale_order_line(osv.osv): |
3066 | - |
3067 | + |
3068 | +class sale_order_line(Model): |
3069 | _inherit = 'sale.order.line' |
3070 | - |
3071 | _columns = { |
3072 | # Rised the precision of the sale.order.line discount field |
3073 | # from 2 to 3 digits in order to be able to have the same amount as Magento. |
3074 | @@ -649,7 +654,5 @@ |
3075 | # With a 2 digits precision, we can have 50.17 % => 148.99 or 50.16% => 149.02. |
3076 | # Rise the digits to 3 allows to have 50.167% => 149€ |
3077 | 'discount': fields.float('Discount (%)', digits=(16, 3), readonly=True, states={'draft': [('readonly', False)]}), |
3078 | - } |
3079 | - |
3080 | -sale_order_line() |
3081 | + } |
3082 | |
3083 | |
3084 | === modified file 'magentoerpconnect/sale_view.xml' |
3085 | --- magentoerpconnect/sale_view.xml 2012-08-14 09:18:30 +0000 |
3086 | +++ magentoerpconnect/sale_view.xml 2012-12-03 15:22:20 +0000 |
3087 | @@ -1,45 +1,75 @@ |
3088 | <?xml version="1.0" encoding="utf-8"?> |
3089 | <openerp> |
3090 | - <data> |
3091 | - |
3092 | - <record model="ir.ui.view" id="magerp_view_shop_form"> |
3093 | - <field name="name">magerp_view_shop_form</field> |
3094 | - <field name="model">sale.shop</field> |
3095 | - <field name="inherit_id" |
3096 | - ref="base_sale_multichannels.base_sale_multichannels_view_shop_form" /> |
3097 | - <field name="type">form</field> |
3098 | - <field name="arch" type="xml"> |
3099 | - <data> |
3100 | - <field name="referential_id" position="replace"> |
3101 | - <field name="referential_id" attrs="{'readonly': [('magento_shop','=',True)]}"/> |
3102 | - </field> |
3103 | - <field name="shop_group_id" position="replace"> |
3104 | - <field name="shop_group_id" readonly="True"/> |
3105 | - <field name="magento_root_category"/> |
3106 | - <field name="storeview_ids" nolabel="1" colspan="4"/> |
3107 | - <separator string="Magento Option" colspan="4"/> |
3108 | - <field name="magento_shop" /> |
3109 | - <field name="allow_magento_order_status_push" /> |
3110 | - <field name="allow_magento_notification"/> |
3111 | - </field> |
3112 | - <button name="export_inventory" position="after"> |
3113 | - <button name="export_images" string="Export Images" colspan="2" type="object" /> |
3114 | - </button> |
3115 | - <field name="last_inventory_export_date" position="after"> |
3116 | - <field name="last_images_export_date" /> |
3117 | - </field> |
3118 | - </data> |
3119 | - </field> |
3120 | - </record> |
3121 | - |
3122 | - <record id="act_magerp_shop_form" model="ir.actions.act_window"> |
3123 | - <field name="name">Magento Shops</field> |
3124 | - <field name="res_model">sale.shop</field> |
3125 | - <field name="type">ir.actions.act_window</field> |
3126 | - <field name="view_type">form</field> |
3127 | - <field name="view_mode">tree,form</field> |
3128 | - <field name="domain">[('magento_shop', '=', True)]</field> |
3129 | - </record> |
3130 | + <data> |
3131 | + |
3132 | + |
3133 | + <record model="ir.ui.view" id="magerp_view_shop_form"> |
3134 | + <field name="name">magerp_view_shop_form</field> |
3135 | + <field name="model">sale.shop</field> |
3136 | + <field name="inherit_id" |
3137 | + ref="base_sale_multichannels.base_sale_multichannels_view_shop_form" /> |
3138 | + <field name="type">form</field> |
3139 | + <field name="arch" type="xml"> |
3140 | + <field name="referential_id" position="replace"> |
3141 | + <field name="referential_id" attrs="{'readonly': [('type_name', '=', 'Magento')]}"/> |
3142 | + </field> |
3143 | + <page string="External Shop Settings" position="before"> |
3144 | + <page string="Magento Actions" attrs="{'invisible': [('type_name', '!=', 'Magento')]}"> |
3145 | + <group col="6" colspan="4"> |
3146 | + <group col="3" colspan="3"> |
3147 | + <separator string="Catalog" colspan="3"/> |
3148 | + <group col="1" colspan="1"> |
3149 | + <button name="export_catalog" string="Export Catalog" colspan="1" type="object"/> |
3150 | + <button name="export_inventory" string="Export Stock Levels Only" colspan="1" type="object"/> |
3151 | + <button name="export_images" string="Export Images" colspan="2" type="object" /> |
3152 | + </group> |
3153 | + <group col="2" colspan="2"> |
3154 | + <field name="last_products_export_date" colspan="2"/> |
3155 | + <field name="last_special_products_export_date" colspan="2"/> |
3156 | + <field name="last_category_export_date" colspan="2"/> |
3157 | + <field name="last_inventory_export_date" colspan="2"/> |
3158 | + <field name="last_images_export_date" /> |
3159 | + </group> |
3160 | + </group> |
3161 | + <group col="3" colspan="3"> |
3162 | + <separator string="Orders" colspan="3"/> |
3163 | + <group col="4" colspan="3"> |
3164 | + <button name="import_orders" string="Import Orders" colspan="1" type="object"/> |
3165 | + <button name="check_need_to_update" string="Check Payments from Channel" colspan="1" type="object"/> |
3166 | + <field name="import_orders_from_date" colspan="2"/> |
3167 | + </group> |
3168 | + <button name="update_orders" string="Update Orders State on Channel" colspan="1" type="object"/> |
3169 | + <field name="last_update_order_export_date" colspan="2"/> |
3170 | + <button name="export_invoices" string="Export Invoices" colspan="1" type="object"/> |
3171 | + <button name="export_shipping" string="Export Shippings" colspan="1" type="object"/> |
3172 | + </group> |
3173 | + <separator string="Partners" colspan="3"/> |
3174 | + <newline/> |
3175 | + <button name="export_shop_partners" string="Export Partners" colspan="1" type="object"/> |
3176 | + <newline/> |
3177 | + </group> |
3178 | + </page> |
3179 | + </page> |
3180 | + <field name="shop_group_id" position="replace"> |
3181 | + <field name="shop_group_id" readonly="True"/> |
3182 | + <field name="magento_root_category"/> |
3183 | + <field name="storeview_ids" nolabel="1" colspan="4"/> |
3184 | + <separator string="Magento Option" colspan="4"/> |
3185 | + <field name="magento_shop" /> |
3186 | + <field name="allow_magento_order_status_push" /> |
3187 | + <field name="allow_magento_notification"/> |
3188 | + </field> |
3189 | + </field> |
3190 | + </record> |
3191 | + |
3192 | + <record id="act_magerp_shop_form" model="ir.actions.act_window"> |
3193 | + <field name="name">Magento Shops</field> |
3194 | + <field name="res_model">sale.shop</field> |
3195 | + <field name="type">ir.actions.act_window</field> |
3196 | + <field name="view_type">form</field> |
3197 | + <field name="view_mode">tree,form</field> |
3198 | + <field name="domain">[['type_name', '=', 'Magento']]</field> |
3199 | + </record> |
3200 | |
3201 | <record id="base_sale_multichannel_view_order_form_magento" model="ir.ui.view"> |
3202 | <field name="name">base_sale_multichannel_view_order_form.magento</field> |
3203 | @@ -59,6 +89,6 @@ |
3204 | </data> |
3205 | </field> |
3206 | </record> |
3207 | - |
3208 | - </data> |
3209 | + |
3210 | + </data> |
3211 | </openerp> |
3212 | |
3213 | === removed file 'magentoerpconnect/server_tmp.patch' |
3214 | --- magentoerpconnect/server_tmp.patch 2011-07-08 07:34:47 +0000 |
3215 | +++ magentoerpconnect/server_tmp.patch 1970-01-01 00:00:00 +0000 |
3216 | @@ -1,14 +0,0 @@ |
3217 | -=== modified file 'bin/osv/orm.py' |
3218 | ---- bin/osv/orm.py 2011-05-24 10:18:10 +0000 |
3219 | -+++ bin/osv/orm.py 2011-06-07 20:17:29 +0000 |
3220 | -@@ -2449,6 +2450,9 @@ |
3221 | - if k.startswith('x_') and not update_custom_fields: |
3222 | - continue |
3223 | - |
3224 | -+ if k.startswith('x_js_'): |
3225 | -+ continue |
3226 | -+ |
3227 | - f = self._columns[k] |
3228 | - |
3229 | - if isinstance(f, fields.one2many): |
3230 | - |
3231 | |
3232 | === modified file 'magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv' |
3233 | --- magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv 2012-05-24 19:50:22 +0000 |
3234 | +++ magentoerpconnect/settings/1.3.2.4/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
3235 | @@ -41,16 +41,16 @@ |
3236 | clean = re.sub('\w:\w:|\w:\w+;', '', ifield) |
3237 | for each in clean.split('{'): |
3238 | if each.startswith('""label""'): |
3239 | - split_info = each.split(';') |
3240 | + split_info = each.split(';') |
3241 | options_label.append('%s: %s [%s]' % (split_info[1], split_info[3], data['sku'])) |
3242 | - |
3243 | + |
3244 | result=[('notes', """".join(options_label).replace('""""', '\n').replace('""', ''))] |
3245 | ", |
3246 | "mag_1324_erp_soline_pid","magento1324","sale.model_sale_order_line","product_id",,"in_out","function","unicode",,"context['alternative_key'] = data['sku'] |
3247 | result=[('product_id',self.pool.get('product.product').extid_to_oeid(cr, uid, external_session, ifield, referential_id))]", |
3248 | "mag_1324_erp_soline_uomqty","magento1324","sale.model_sale_order_line","qty_ordered",,"in_out","function","unicode",,"result=[('product_uom_qty',ifield)]", |
3249 | "mag_1324_erp_soline_uosqty","magento1324","sale.model_sale_order_line","qty_ordered",,"in","function","unicode",,"result=[('product_uos_qty',ifield)]", |
3250 | -"mag_1324_erp_soline_price","magento1324","sale.model_sale_order_line","price",,"in","function","unicode",,"if context.get('price_is_tax_included', False): |
3251 | +"mag_1324_erp_soline_price","magento1324","sale.model_sale_order_line","price",,"in","function","unicode",,"if context.get('price_is_tax_included', False): |
3252 | result=[('price_unit', (float(data['row_total']) + float(data['tax_amount']))/float(data['qty_ordered']))] |
3253 | else: |
3254 | result=[('price_unit', float(data['row_total'])/float(data['qty_ordered']))]", |
3255 | @@ -60,16 +60,16 @@ |
3256 | "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))]) |
3257 | parent_id = False |
3258 | if record_id: |
3259 | - parent_rec = self.pool.get('ir.model.data').read(cr,uid,record_id[0],[]) |
3260 | - parent_id=parent_rec.get('res_id',False) |
3261 | + parent_rec = self.pool.get('ir.model.data').read(cr,uid,record_id[0],[]) |
3262 | + parent_id=parent_rec.get('res_id',False) |
3263 | result=[('magento_parent_id',ifield),('parent_id',parent_id)]","magento_parent_id = False |
3264 | if record.get('parent_id',False): |
3265 | - magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) |
3266 | - if not magento_parent_id: |
3267 | - self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[referential_id],{},context=context) |
3268 | - magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) |
3269 | + magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) |
3270 | + if not magento_parent_id: |
3271 | + self.ext_export(cr,uid,[record.get('parent_id',[False])[0]],[referential_id],{},context=context) |
3272 | + magento_parent_id = self.oeid_to_extid(cr, uid, record.get('parent_id')[0], referential_id) |
3273 | if magento_parent_id: |
3274 | - result = [('parent_id',magento_parent_id)]" |
3275 | + result = [('parent_id',magento_parent_id)]" |
3276 | "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'])]" |
3277 | "mag_1324_erp_procat_5","magento1324","product.model_product_category","description",,"in_out","function","unicode",,"result=[('description',ifield)]","result=[('description',record['description'])]" |
3278 | "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'])]" |
3279 | @@ -102,20 +102,20 @@ |
3280 | "mag_1324_erp_procat_14","magento1324","product.model_product_category","updated_at",,"in","function","unicode",,"result=[('magerp_stamp',ifield)]", |
3281 | "mag_1324_erp_procat_15","magento1324","product.model_product_category","image",,"in_out","function","unicode",,"image_binary = False |
3282 | if ifield and not ifield=='None': |
3283 | - try: |
3284 | - image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) |
3285 | - except Exception, e: |
3286 | - print e |
3287 | - pass |
3288 | - if image_binary: |
3289 | - image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) |
3290 | + try: |
3291 | + image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) |
3292 | + except Exception, e: |
3293 | + print e |
3294 | + pass |
3295 | + if image_binary: |
3296 | + image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) |
3297 | result=[('image_name',ifield),('image',image_binary)]","if record['image']: |
3298 | - img = base64.decodestring(record['image']) |
3299 | - img_bin_enc = base64.encodestring(img) |
3300 | + img = base64.decodestring(record['image']) |
3301 | + img_bin_enc = base64.encodestring(img) |
3302 | conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc]) |
3303 | - result = [('image',record['image_name'])] |
3304 | + result = [('image',record['image_name'])] |
3305 | else: |
3306 | - result=[]" |
3307 | + result=[]" |
3308 | "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'])]" |
3309 | "mag_1324_erp_procat_17","magento1324","product.model_product_category","page_layout",,"in_out","function","unicode",,"if ifield: |
3310 | att_id = self.pool.get('magerp.product_category_attribute_options').get_create_option_id(cr, uid, ifield,'page_layout', context=context) |
3311 | @@ -226,52 +226,52 @@ |
3312 | "magento_1324_prt_adr_6","magento1324","base.model_res_partner_address","is_active",,"in_out","function","unicode",,"result=[('active',bool(eval(ifield)))]", |
3313 | "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)]) |
3314 | if result and len(result)==1: |
3315 | - result=[('country_id',result[0])] |
3316 | + result=[('country_id',result[0])] |
3317 | else: |
3318 | - result=[] |
3319 | + result=[] |
3320 | ", |
3321 | "magento_1324_prt_adr_8","magento1324","base.model_res_partner_address","street",,"in_out","function","unicode",,"if ifield: |
3322 | - if len(ifield.split('\n')) ==2 : |
3323 | - result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] |
3324 | - else : |
3325 | - result = [('street',ifield.replace('\\n',','))] |
3326 | + if len(ifield.split('\n')) ==2 : |
3327 | + result = [('street', ifield.split('\n')[0]) , ('street2', ifield.split('\n')[1])] |
3328 | + else : |
3329 | + result = [('street',ifield.replace('\\n',','))] |
3330 | else: |
3331 | - result = []", |
3332 | + result = []", |
3333 | "magento_1324_prt_adr_9","magento1324","base.model_res_partner_address","postcode",,"in_out","function","unicode",,"result=[('zip',ifield)]", |
3334 | "magento_1324_prt_adr_10","magento1324","base.model_res_partner_address","telephone",,"in_out","function","unicode",,"result=[('phone',ifield)]", |
3335 | "magento_1324_prt_adr_11","magento1324","base.model_res_partner_address","region",,"in_out","function","unicode",,"if ifield: |
3336 | - result = self.pool.get('res.country.state').search(cr,uid,[('name','ilike',ifield)]) |
3337 | - if result and len(result)==1: |
3338 | - result = [('state_id',result[0])] |
3339 | - else: |
3340 | - result=[] |
3341 | + result = self.pool.get('res.country.state').search(cr,uid,[('name','ilike',ifield)]) |
3342 | + if result and len(result)==1: |
3343 | + result = [('state_id',result[0])] |
3344 | + else: |
3345 | + result=[] |
3346 | else: |
3347 | - result=[]", |
3348 | + result=[]", |
3349 | "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) |
3350 | if result: |
3351 | - result=[('partner_id',result)] |
3352 | + result=[('partner_id',result)] |
3353 | else: |
3354 | - result=[('partner_id',False)]", |
3355 | + result=[('partner_id',False)]", |
3356 | "magento_1324_prt_adr_14","magento1324","base.model_res_partner_address","address_type",,"in_out","function","unicode",,"if ifield=='billing': |
3357 | - result=[('type','invoice')] |
3358 | + result=[('type','invoice')] |
3359 | elif ifield=='shipping': |
3360 | - result=[('type','delivery')] |
3361 | + result=[('type','delivery')] |
3362 | else: |
3363 | - result=[]", |
3364 | + result=[]", |
3365 | "magento_1324_prt_adr_15","magento1324","base.model_res_partner_address","email",,"in_out","function","unicode",,"result=[('email',ifield)]", |
3366 | "magento_1324_prt_2","magento1324","base.model_res_partner","group_id",,"in_out","function","int",,"if ifield: |
3367 | - result=self.pool.get('res.partner.category').extid_to_oeid(cr,uid,ifield,referential_id) |
3368 | - if result: |
3369 | - result=[('group_id',result)]", |
3370 | + result=self.pool.get('res.partner.category').extid_to_oeid(cr,uid,ifield,referential_id) |
3371 | + if result: |
3372 | + result=[('group_id',result)]", |
3373 | "magento_1324_prt_3","magento1324","base.model_res_partner","store_id",,"in_out","function","int",,"if ifield: |
3374 | - result=self.pool.get('magerp.storeviews').extid_to_oeid(cr,uid,ifield,referential_id) |
3375 | - if result: |
3376 | - lang = self.pool.get('magerp.storeviews').browse(cr, uid, result).lang_id |
3377 | - result=[('store_id',result),('lang',lang and lang.code or False)]", |
3378 | + result=self.pool.get('magerp.storeviews').extid_to_oeid(cr,uid,ifield,referential_id) |
3379 | + if result: |
3380 | + lang = self.pool.get('magerp.storeviews').browse(cr, uid, result).lang_id |
3381 | + result=[('store_id',result),('lang',lang and lang.code or False)]", |
3382 | "magento_1324_prt_4","magento1324","base.model_res_partner","website_id",,"in_out","function","int",,"if ifield: |
3383 | - result=self.pool.get('external.shop.group').extid_to_oeid(cr,uid,ifield,referential_id) |
3384 | - if result: |
3385 | - result=[('website_id',result)]", |
3386 | + result=self.pool.get('external.shop.group').extid_to_oeid(cr,uid,ifield,referential_id) |
3387 | + if result: |
3388 | + result=[('website_id',result)]", |
3389 | "magento_1324_prt_5","magento1324","base.model_res_partner","created_in",,"in_out","function","unicode",,"result=[('created_in',ifield)]", |
3390 | "magento_1324_prt_6","magento1324","base.model_res_partner","created_at",,"in_out","function","unicode",,"result=[('created_at',ifield)]", |
3391 | "magento_1324_prt_7","magento1324","base.model_res_partner","updated_at",,"in_out","function","unicode",,"result=[('updated_at',ifield)]", |
3392 | @@ -281,10 +281,10 @@ |
3393 | result=[('firstname', fn), ('lastname', ln)]" |
3394 | "magento_1324_prt_10","magento1324","base.model_res_partner","email",,"in_out","function","unicode",,"result=[('emailid',ifield)]", |
3395 | "magento_1324_prt_11","magento1324","base.model_res_partner","taxvat",,"in_out","function","unicode",,"if ifield: |
3396 | - result=[('mag_vat',ifield)] |
3397 | + result=[('mag_vat',ifield)] |
3398 | else: |
3399 | - result=[]", |
3400 | + result=[]", |
3401 | "magento_1324_prt_12","magento1324","base.model_res_partner","dob",,"in_out","function","unicode",,"if ifield: |
3402 | - result =[('mag_birthday',ifield[:10])] |
3403 | + result =[('mag_birthday',ifield[:10])] |
3404 | else: |
3405 | - result=[]", |
3406 | + result=[]", |
3407 | |
3408 | === modified file 'magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv' |
3409 | --- magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv 2012-05-07 20:54:47 +0000 |
3410 | +++ magentoerpconnect/settings/1.5.0.0/product.category/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
3411 | @@ -43,17 +43,17 @@ |
3412 | magentoerpconnect.mag1500_product_category_is_anchor,magentoerpconnect.mag1500_product_category,is_anchor,magentoerpconnect.field_product_category_is_anchor,in_out,direct,int,,False,, |
3413 | magentoerpconnect.mag1500_product_category_image,magentoerpconnect.mag1500_product_category,image,,in_out,function,unicode,,False,"image_binary = False |
3414 | if resource['image'] and not resource['image']=='None': |
3415 | - try: |
3416 | - image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) |
3417 | - except Exception, e: |
3418 | - print e |
3419 | - pass |
3420 | - if image_binary: |
3421 | - image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) |
3422 | + try: |
3423 | + image_binary = conn.call('ol_catalog_category_media.info', [int(data['category_id'])]) |
3424 | + except Exception, e: |
3425 | + print e |
3426 | + pass |
3427 | + if image_binary: |
3428 | + image_binary = base64.encodestring(base64.urlsafe_b64decode(image_binary[0]['image_data'])) |
3429 | result=[('image_name',ifield),('image',image_binary)]","if 'image' in resource: |
3430 | if resource['image']: |
3431 | img = base64.decodestring(record['image']) |
3432 | - img_bin_enc = base64.encodestring(img) |
3433 | + img_bin_enc = base64.encodestring(img) |
3434 | conn.call('ol_catalog_category_media.create', [record['image_name'], img_bin_enc]) |
3435 | result = [('image',record['image_name'])] |
3436 | else: |
3437 | |
3438 | === modified file 'magentoerpconnect/settings/1.5.0.0/product/external.mappinglines.template.csv' |
3439 | --- magentoerpconnect/settings/1.5.0.0/product/external.mappinglines.template.csv 2012-06-21 16:17:58 +0000 |
3440 | +++ magentoerpconnect/settings/1.5.0.0/product/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
3441 | @@ -59,7 +59,7 @@ |
3442 | mag_categ_id = cat_obj.get_or_create_extid(cr, uid, external_session, categ_id, context=context) |
3443 | mag_categ_ids.append(mag_categ_id) |
3444 | result=[('categories', mag_categ_ids)]",, |
3445 | -"mag1500_product_product_special_price",,"in_out","function","special_price",,"float","False","magentoerpconnect.mag1500_product_product","special_price","if 'x_magerp_special_price' in resource: result = [('x_magerp_special_price', ifield)]","if 'x_magerp_special_price' in resource: |
3446 | +"mag1500_product_product_special_price",,"in_out","function","special_price",,"float","False","magentoerpconnect.mag1500_product_product","special_price","if 'x_magerp_special_price' in resource: result = [('x_magerp_special_price', ifield)]","if 'x_magerp_special_price' in resource: |
3447 | if resource['x_magerp_special_price']: |
3448 | result = [('special_price', resource['x_magerp_special_price'])] |
3449 | else: |
3450 | |
3451 | === modified file 'magentoerpconnect/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv' |
3452 | --- magentoerpconnect/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv 2012-05-19 17:26:11 +0000 |
3453 | +++ magentoerpconnect/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
3454 | @@ -1,5 +1,17 @@ |
3455 | id,sequence,type,evaluation_type,external_field,field_id:id,external_type,alternative_key,mapping_id:id,function_name,in_function,out_function,child_mapping_id:id,datetime_format |
3456 | -magentoerpconnect.mag1500_res_partner_address_name,,in_out,direct,firstname,magentoerpconnect.field_res_partner_address_firstname,unicode,True,magentoerpconnect.mag1500_res_partner_address,name,,,, |
3457 | +magentoerpconnect.mag1500_res_partner_address_name,,in_out,function,firstname,base.field_res_partner_address_name,unicode,True,magentoerpconnect.mag1500_res_partner_address,name,"if 'firstname' in resource or 'lastname' in resource: |
3458 | + result = [('name', (resource.get('firstname') or '') + (resource.get('firstname') and ' ' or '') + (resource.get('lastname') or ''))]","if 'name' in resource: |
3459 | + name_split = name.split(' ') |
3460 | + if len(name_split) >= 2: |
3461 | + firstname = name_split[0] |
3462 | + lastname = name.replace(firstname, '').strip() |
3463 | + else: |
3464 | + firstname = '-' |
3465 | + lastname = name |
3466 | +else: |
3467 | + firstname = '' |
3468 | + lastname = '' |
3469 | +result = [('firstname', firstname), ('lastname', lastname)]",, |
3470 | magentoerpconnect.mag1500_res_partner_address_telephone,,in_out,direct,telephone,base.field_res_partner_address_phone,unicode,False,magentoerpconnect.mag1500_res_partner_address,,,,, |
3471 | magentoerpconnect.mag1500_res_partner_address_region,,in_out,function,region,,unicode,False,magentoerpconnect.mag1500_res_partner_address,region,"if ifield: |
3472 | result = self.pool.get('res.country.state').search(cr,uid,[('name','ilike',ifield)]) |
3473 | @@ -42,7 +54,6 @@ |
3474 | result = [('prefix',resource['title'][1])]",, |
3475 | magentoerpconnect.mag1500_res_partner_address_city,,in_out,direct,city,base.field_res_partner_address_city,unicode,True,magentoerpconnect.mag1500_res_partner_address,,"result=[('city',ifield)]",,, |
3476 | magentoerpconnect.mag1500_res_partner_address_fax,,in_out,direct,fax,base.field_res_partner_address_fax,unicode,False,magentoerpconnect.mag1500_res_partner_address,,,,, |
3477 | -magentoerpconnect.mag1500_res_partner_address_lastname,,in_out,direct,lastname,magentoerpconnect.field_res_partner_address_lastname,unicode,False,magentoerpconnect.mag1500_res_partner_address,,,,, |
3478 | mag1500_res_partner_address_email,,in_out,direct,email,base.field_res_partner_address_email,unicode,False,magentoerpconnect.mag1500_res_partner_address,,,,, |
3479 | mag1500_res_partner_address_company,,in_out,direct,company,magentoerpconnect.field_res_partner_address_company,unicode,True,magentoerpconnect.mag1500_res_partner_address,,,,, |
3480 | magentoerpconnect.mag1500_res_partner_address_zip,,in_out,direct,postcode,base.field_res_partner_address_zip,unicode,True,magentoerpconnect.mag1500_res_partner_address,,"result=[('zip',ifield)]",,, |
3481 | |
3482 | === modified file 'magentoerpconnect/settings/1.5.0.0/res.partner/external.mappinglines.template.csv' |
3483 | --- magentoerpconnect/settings/1.5.0.0/res.partner/external.mappinglines.template.csv 2012-08-14 14:53:28 +0000 |
3484 | +++ magentoerpconnect/settings/1.5.0.0/res.partner/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
3485 | @@ -11,7 +11,8 @@ |
3486 | mag1500_res_partner_created_in,,in_out,direct,created_in,magentoerpconnect.field_res_partner_created_in,unicode,False,magentoerpconnect.mag1500_res_partner,,,,, |
3487 | mag1500_res_partner_created_at,,in_out,direct,created_at,magentoerpconnect.field_res_partner_created_at,unicode,False,magentoerpconnect.mag1500_res_partner,,,,, |
3488 | mag1500_res_partner_updated_at,,in_out,direct,updated_at,magentoerpconnect.field_res_partner_updated_at,unicode,False,magentoerpconnect.mag1500_res_partner,,,,,%Y-%m-%d %H:%M:%S |
3489 | -mag1500_res_partner_name,,in_out,function,firstname,,unicode,False,magentoerpconnect.mag1500_res_partner,name,"result = [('name',resource['firstname'] + ' ' + resource['lastname'])]","add_id = self.browse(cr, uid, resource['id']) |
3490 | +mag1500_res_partner_name,,in_out,function,firstname,,unicode,False,magentoerpconnect.mag1500_res_partner,name,"if 'firstname' in resource or 'lastname' in resource: |
3491 | + result = [('name', (resource.get('firstname') or '') + (resource.get('firstname') and ' ' or '') + (resource.get('lastname') or ''))]","add_id = self.browse(cr, uid, resource['id']) |
3492 | fn = add_id.address[0].firstname |
3493 | ln = add_id.address[0].lastname |
3494 | result=[('firstname', fn), ('lastname', ln)]",, |
3495 | |
3496 | === modified file 'magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv' |
3497 | --- magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv 2012-08-20 21:52:00 +0000 |
3498 | +++ magentoerpconnect/settings/1.5.0.0/sale.order.line/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
3499 | @@ -9,9 +9,9 @@ |
3500 | clean = re.sub('\w:\w:|\w:\w+;', '', ifield) |
3501 | for each in clean.split('{'): |
3502 | if each.startswith('""label""'): |
3503 | - split_info = each.split(';') |
3504 | + split_info = each.split(';') |
3505 | options_label.append('%s: %s [%s]' % (split_info[1], split_info[3], data['sku'])) |
3506 | - |
3507 | + |
3508 | result=[('notes', """".join(options_label).replace('""""', '\n').replace('""', ''))] |
3509 | ",,, |
3510 | mag1500_sale_order_line_product_id=>,,in,direct,product_id,sale.field_sale_order_line_product_id,int,False,mag1500_sale_order_line,,,,, |
3511 | @@ -21,3 +21,4 @@ |
3512 | ('price_unit_tax_excluded', (float(resource['base_row_total']))/float(resource['qty_ordered'])), |
3513 | ('tax_rate', float(resource['base_row_total']) and (float(resource['base_row_total_incl_tax'])/float(resource['base_row_total'])-1)), |
3514 | ]",,, |
3515 | +mag1500_sale_order_line_id,,in,direct,item_id,base_sale_multichannels.field_sale_order_line_ext_ref_line,int,False,mag1500_sale_order_line,,,,, |
3516 | |
3517 | === modified file 'magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv' |
3518 | --- magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv 2012-08-14 14:53:28 +0000 |
3519 | +++ magentoerpconnect/settings/1.5.0.0/sale.order/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
3520 | @@ -16,7 +16,6 @@ |
3521 | mag1500_sale_order_cod_fee=>,,in,function,cod_fee,,float,False,mag1500_sale_order,cod_fee,"#TODO map me |
3522 | ",,, |
3523 | mag1500_sale_order_gift_certificates_amount=>,,in,function,giftcert_amount,,float,False,mag1500_sale_order,gift_certificates_amount,"result=[('gift_certificates_amount', ifield)]",,, |
3524 | -mag1500_sale_order_shipping_amount_tax_excluded=>,,in,function,shipping_amount,,float,False,mag1500_sale_order,shipping_amount_tax_excluded,"result=[('shipping_amount_tax_excluded', ifield)]",,, |
3525 | mag1500_sale_order_gift_certificates_code=>,,in,function,giftcert_code,,unicode,False,mag1500_sale_order,gift_certificates_code,"result = [('gift_certificates_code', ifield)]",,, |
3526 | mag1500_sale_order_carrier_id=>,,in,function,shipping_method,,unicode,False,mag1500_sale_order,carrier_id,"if ifield: |
3527 | carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [('magento_code', '=', ifield)]) |
3528 | @@ -28,5 +27,17 @@ |
3529 | model, product_id = model_data_obj.get_object_reference(cr, uid, 'base_sale_multichannels', 'product_product_shipping') |
3530 | carrier_id = self.pool.get('delivery.carrier').create(cr, uid, {'partner_id' : fake_partner_id, 'product_id' : product_id, 'name' : ifield, 'magento_code' : ifield}) |
3531 | result=[('carrier_id', carrier_id)]",,, |
3532 | -mag1500_sale_order_shipping_amount_tax_included=>,,in,function,base_shipping_incl_tax,,float,False,mag1500_sale_order,shipping_amount_tax_included,"result=[('shipping_amount_tax_included', ifield), ('shipping_tax_rate', ifield and (ifield/float(data['shipping_amount'])-1)) or 0]",,, |
3533 | -mag1500_s ale_order_date,,in,direct,created_at,sale.field_sale_order_date_order,datetime,False,mag1500_sale_order,,,,,%Y-%m-%d %H:%M:%S |
3534 | +mag1500_sale_order_shipping_amount_tax_included=>,,in,function,base_shipping_incl_tax,,float,False,mag1500_sale_order,shipping_amount_tax_included,"amount_tax_inc = float(resource.get('base_shipping_incl_tax', 0.0)) - float(resource.get('shipping_discount_amount', 0.0)) |
3535 | +amount_tax_exc = float(resource.get('shipping_amount', 0)) |
3536 | + |
3537 | +if amount_tax_exc: |
3538 | + tax_rate = amount_tax_inc/amount_tax_exc -1 |
3539 | +else: |
3540 | + tax_rate = 0 |
3541 | + |
3542 | +result=[ |
3543 | + ('shipping_amount_tax_included', amount_tax_inc), |
3544 | + ('shipping_amount_tax_excluded', amount_tax_exc), |
3545 | + ('shipping_tax_rate', tax_rate), |
3546 | +]",,, |
3547 | +mag1500_sale_order_date,,in,direct,created_at,sale.field_sale_order_date_order,datetime,False,mag1500_sale_order,,,,,%Y-%m-%d %H:%M:%S |
3548 | |
3549 | === modified file 'magentoerpconnect/stock.py' |
3550 | --- magentoerpconnect/stock.py 2012-05-25 15:37:26 +0000 |
3551 | +++ magentoerpconnect/stock.py 2012-12-03 15:22:20 +0000 |
3552 | @@ -21,15 +21,14 @@ |
3553 | |
3554 | import xmlrpclib |
3555 | |
3556 | -from osv import fields,osv |
3557 | -from tools.translate import _ |
3558 | -from openerp.addons.base_sale_multichannels.sale import \ |
3559 | - ExternalShippingCreateError |
3560 | +from openerp.osv.orm import Model |
3561 | +from openerp.tools.translate import _ |
3562 | +from base_sale_multichannels.sale import ExternalShippingCreateError |
3563 | |
3564 | import logging |
3565 | _logger = logging.getLogger(__name__) |
3566 | |
3567 | -class stock_picking(osv.osv): |
3568 | +class stock_picking(Model): |
3569 | |
3570 | _inherit = "stock.picking" |
3571 | |
3572 | @@ -122,5 +121,3 @@ |
3573 | if res: |
3574 | _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) |
3575 | return True |
3576 | - |
3577 | -stock_picking() |
3578 | |
3579 | === modified file 'magentoerpconnect/wizard/open_product_by_attribut_set.py' |
3580 | --- magentoerpconnect/wizard/open_product_by_attribut_set.py 2011-12-17 20:57:57 +0000 |
3581 | +++ magentoerpconnect/wizard/open_product_by_attribut_set.py 2012-12-03 15:22:20 +0000 |
3582 | @@ -19,13 +19,13 @@ |
3583 | # # |
3584 | ################################################################################# |
3585 | |
3586 | -from osv import fields,osv |
3587 | - |
3588 | - |
3589 | -class open_product_by_attribut_set(osv.osv_memory): |
3590 | +from openerp.osv.orm import TransientModel |
3591 | +from openerp.osv import fields |
3592 | + |
3593 | + |
3594 | +class open_product_by_attribut_set(TransientModel): |
3595 | _name = 'open.product.by.attribut.set' |
3596 | _description = 'Wizard to open product by attributs set' |
3597 | - |
3598 | _columns = { |
3599 | 'attributs_set':fields.many2one('magerp.product_attribute_set', 'Attributs Set'), |
3600 | } |
3601 | @@ -51,5 +51,3 @@ |
3602 | result['domain'] = "[('set', '=', %s)]" % attribute_set.id |
3603 | result['name'] = attribute_set.attribute_set_name |
3604 | return result |
3605 | - |
3606 | -open_product_by_attribut_set() |
3607 | |
3608 | === modified file 'magentoerpconnect_bundle/__openerp__.py' |
3609 | --- magentoerpconnect_bundle/__openerp__.py 2012-03-15 09:47:04 +0000 |
3610 | +++ magentoerpconnect_bundle/__openerp__.py 2012-12-03 15:22:20 +0000 |
3611 | @@ -22,7 +22,7 @@ |
3612 | |
3613 | { |
3614 | 'name': 'magentoerpconnect_bundle', |
3615 | - 'version': '0.1', |
3616 | + 'version': '6.1.0', |
3617 | 'category': 'Generic Modules', |
3618 | 'license': 'AGPL-3', |
3619 | 'description': """Module to extend the module magentoerpconnect, with it you will be able to create bundle product in magento directly from Openerp. |
3620 | @@ -41,9 +41,9 @@ |
3621 | 'images/magentoerpconnect.png', |
3622 | ], |
3623 | "website" : "https://launchpad.net/magentoerpconnect", |
3624 | - 'depends': ['magentoerpconnect','sale_bundle_product'], |
3625 | + 'depends': ['magentoerpconnect','sale_bundle_product'], |
3626 | 'init_xml': [], |
3627 | - 'update_xml': [ |
3628 | + 'update_xml': [ |
3629 | 'sale_bundle_product_view.xml', |
3630 | 'product_view.xml', |
3631 | 'settings/1.3.2.4/external.mappinglines.template.csv', |
3632 | |
3633 | === modified file 'magentoerpconnect_bundle/product.py' |
3634 | --- magentoerpconnect_bundle/product.py 2012-03-28 09:49:00 +0000 |
3635 | +++ magentoerpconnect_bundle/product.py 2012-12-03 15:22:20 +0000 |
3636 | @@ -19,13 +19,11 @@ |
3637 | # # |
3638 | ################################################################################# |
3639 | |
3640 | -from osv import osv, fields |
3641 | -import netsvc |
3642 | - |
3643 | - |
3644 | -class product_product(osv.osv): |
3645 | +from openerp.osv.orm import Model |
3646 | + |
3647 | +class product_product(Model): |
3648 | _inherit = "product.product" |
3649 | - |
3650 | + |
3651 | def get_bundle_component(self, cr, uid, ids, context): |
3652 | res = {} |
3653 | for product in self.browse(cr, uid, ids, context=context): |
3654 | @@ -34,7 +32,7 @@ |
3655 | for product_item_set_line in product_item_set.item_set_line_ids: |
3656 | res[product.id].append(product_item_set_line.product_id.id) |
3657 | return res |
3658 | - |
3659 | + |
3660 | def action_before_exporting(self, cr, uid, id, product_type, external_referential_ids, defaults, context=None): |
3661 | #When the export of a bundle product is forced we should check if all variant are already exported |
3662 | if context.get('force_export', False) and product_type == 'bundle': |
3663 | @@ -44,24 +42,19 @@ |
3664 | if not self.oeid_to_extid(cr, uid, id, shop.referential_id.id): |
3665 | self.ext_export(cr, uid, [id], external_referential_ids, defaults, context) |
3666 | return super(product_product, self).action_before_exporting(cr, uid, id, product_type, external_referential_ids, defaults, context=context) |
3667 | - |
3668 | + |
3669 | |
3670 | def add_data_to_create_bundle_product(self, cr, uid, oe_id, data, context=None): |
3671 | shop = self.pool.get('sale.shop').browse(cr, uid, context['shop_id']) |
3672 | # check if not already created |
3673 | - |
3674 | - |
3675 | #TODO add the data |
3676 | - |
3677 | - data.update({'configurable_products_data': products_data, 'configurable_attributes_data': attributes_data, 'associated_skus':associated_skus}) |
3678 | + data.update({'configurable_products_data': products_data, |
3679 | + 'configurable_attributes_data': attributes_data, |
3680 | + 'associated_skus':associated_skus}) |
3681 | return data |
3682 | |
3683 | - |
3684 | def ext_create(self, cr, uid, data, conn, method, oe_id, context): |
3685 | if data.get('type_id', False) == 'bundle': |
3686 | data = self.add_data_to_create_bundle_product(cr, uid, oe_id, data, context) |
3687 | return super(product_product, self).ext_create(cr, uid, data, conn, method, oe_id, context) |
3688 | - |
3689 | - |
3690 | -product_product() |
3691 | |
3692 | |
3693 | === modified file 'magentoerpconnect_bundle/product_view.xml' |
3694 | --- magentoerpconnect_bundle/product_view.xml 2011-07-06 19:15:30 +0000 |
3695 | +++ magentoerpconnect_bundle/product_view.xml 2012-12-03 15:22:20 +0000 |
3696 | @@ -7,37 +7,37 @@ |
3697 | |
3698 | <openerp> |
3699 | <data> |
3700 | - |
3701 | - <!-- INHERITED VIEW FOR THE OBJECT : product_product |
3702 | - |
3703 | - <record id="product_view_form" model="ir.ui.view"> |
3704 | - <field name="name">magentoerpconnect_bundle.product_product.view_form</field> |
3705 | - <field name="model">product.product</field> |
3706 | - <field name="inherit_id" ref="module_name_to_inherit.view_id" /> |
3707 | - <field eval="16" name="priority"/> |
3708 | - <field name="type">form</field> |
3709 | - <field name="arch" type="xml"> |
3710 | - <data> |
3711 | - <field name="field_reference" position="after"> |
3712 | - </field> |
3713 | - </data> |
3714 | - </field> |
3715 | - </record> |
3716 | - |
3717 | - <record id="product_view_tree" model="ir.ui.view"> |
3718 | - <field name="name">magentoerpconnect_bundle.product_product.view_tree</field> |
3719 | - <field name="model">product.product</field> |
3720 | - <field name="inherit_id" ref="module_name_to_inherit.view_id" /> |
3721 | - <field eval="16" name="priority"/> |
3722 | - <field name="type">tree</field> |
3723 | - <field name="arch" type="xml"> |
3724 | - <data> |
3725 | - <field name="field_reference" position="after"> |
3726 | - </field> |
3727 | - </data> |
3728 | - </field> |
3729 | - </record> |
3730 | - |
3731 | + |
3732 | + <!-- INHERITED VIEW FOR THE OBJECT : product_product |
3733 | + |
3734 | + <record id="product_view_form" model="ir.ui.view"> |
3735 | + <field name="name">magentoerpconnect_bundle.product_product.view_form</field> |
3736 | + <field name="model">product.product</field> |
3737 | + <field name="inherit_id" ref="module_name_to_inherit.view_id" /> |
3738 | + <field eval="16" name="priority"/> |
3739 | + <field name="type">form</field> |
3740 | + <field name="arch" type="xml"> |
3741 | + <data> |
3742 | + <field name="field_reference" position="after"> |
3743 | + </field> |
3744 | + </data> |
3745 | + </field> |
3746 | + </record> |
3747 | + |
3748 | + <record id="product_view_tree" model="ir.ui.view"> |
3749 | + <field name="name">magentoerpconnect_bundle.product_product.view_tree</field> |
3750 | + <field name="model">product.product</field> |
3751 | + <field name="inherit_id" ref="module_name_to_inherit.view_id" /> |
3752 | + <field eval="16" name="priority"/> |
3753 | + <field name="type">tree</field> |
3754 | + <field name="arch" type="xml"> |
3755 | + <data> |
3756 | + <field name="field_reference" position="after"> |
3757 | + </field> |
3758 | + </data> |
3759 | + </field> |
3760 | + </record> |
3761 | + |
3762 | --> |
3763 | |
3764 | |
3765 | |
3766 | === modified file 'magentoerpconnect_bundle/sale.py' |
3767 | --- magentoerpconnect_bundle/sale.py 2012-03-15 09:47:04 +0000 |
3768 | +++ magentoerpconnect_bundle/sale.py 2012-12-03 15:22:20 +0000 |
3769 | @@ -19,10 +19,10 @@ |
3770 | # # |
3771 | ################################################################################# |
3772 | |
3773 | -from osv import osv |
3774 | - |
3775 | - |
3776 | -class sale_order(osv.osv): |
3777 | +from openerp.osv.orm import Model |
3778 | + |
3779 | + |
3780 | +class sale_order(Model): |
3781 | _inherit = "sale.order" |
3782 | |
3783 | def _merge_sub_items(self, cr, uid, product_type, top_item, child_items, context=None): |
3784 | @@ -37,5 +37,3 @@ |
3785 | else: |
3786 | return super(sale_order, self)._merge_sub_items(cr, uid, product_type, |
3787 | top_item, child_items, context=context) |
3788 | - |
3789 | -sale_order() |
3790 | |
3791 | === modified file 'magentoerpconnect_bundle/sale_bundle_product.py' |
3792 | --- magentoerpconnect_bundle/sale_bundle_product.py 2011-10-30 20:09:37 +0000 |
3793 | +++ magentoerpconnect_bundle/sale_bundle_product.py 2012-12-03 15:22:20 +0000 |
3794 | @@ -19,24 +19,14 @@ |
3795 | # # |
3796 | ################################################################################# |
3797 | |
3798 | -from osv import osv, fields |
3799 | -import netsvc |
3800 | - |
3801 | - |
3802 | -class product_item_set_line(osv.osv): |
3803 | - |
3804 | +from openerp.osv.orm import Model |
3805 | +from openerp.osv import fields |
3806 | + |
3807 | + |
3808 | +class product_item_set_line(Model): |
3809 | _inherit = "product.item.set" |
3810 | - |
3811 | - |
3812 | _columns = { |
3813 | 'magento_render_type': fields.selection((('list','List'), ('c','Check Box')), 'Magento Render'), |
3814 | - |
3815 | - } |
3816 | - |
3817 | - _defaults = { |
3818 | - |
3819 | - } |
3820 | - |
3821 | -product_item_set_line() |
3822 | + } |
3823 | |
3824 | |
3825 | |
3826 | === modified file 'magentoerpconnect_bundle/sale_bundle_product_view.xml' |
3827 | --- magentoerpconnect_bundle/sale_bundle_product_view.xml 2011-10-30 20:09:37 +0000 |
3828 | +++ magentoerpconnect_bundle/sale_bundle_product_view.xml 2012-12-03 15:22:20 +0000 |
3829 | @@ -7,23 +7,23 @@ |
3830 | |
3831 | <openerp> |
3832 | <data> |
3833 | - |
3834 | + |
3835 | <!-- INHERITED VIEW FOR THE OBJECT : product_item_set_line --> |
3836 | |
3837 | - <record id="product_item_set_view_form" model="ir.ui.view"> |
3838 | - <field name="name">magentoerpconnect_bundle.product_item_set.view_form</field> |
3839 | - <field name="model">product.item.set</field> |
3840 | - <field name="inherit_id" ref="sale_bundle_product.product_item_set_view_form" /> |
3841 | + <record id="product_item_set_view_form" model="ir.ui.view"> |
3842 | + <field name="name">magentoerpconnect_bundle.product_item_set.view_form</field> |
3843 | + <field name="model">product.item.set</field> |
3844 | + <field name="inherit_id" ref="sale_bundle_product.product_item_set_view_form" /> |
3845 | <field eval="16" name="priority"/> |
3846 | - <field name="type">form</field> |
3847 | - <field name="arch" type="xml"> |
3848 | - <data> |
3849 | - <field name="required" position="after"> |
3850 | - <field name="magento_render_type" /> |
3851 | - </field> |
3852 | - </data> |
3853 | - </field> |
3854 | - </record> |
3855 | + <field name="type">form</field> |
3856 | + <field name="arch" type="xml"> |
3857 | + <data> |
3858 | + <field name="required" position="after"> |
3859 | + <field name="magento_render_type" /> |
3860 | + </field> |
3861 | + </data> |
3862 | + </field> |
3863 | + </record> |
3864 | |
3865 | </data> |
3866 | </openerp> |
3867 | |
3868 | === modified file 'magentoerpconnect_bundle_split/__openerp__.py' |
3869 | --- magentoerpconnect_bundle_split/__openerp__.py 2012-05-18 13:38:51 +0000 |
3870 | +++ magentoerpconnect_bundle_split/__openerp__.py 2012-12-03 15:22:20 +0000 |
3871 | @@ -21,7 +21,7 @@ |
3872 | |
3873 | { |
3874 | 'name': 'Magentoerpconnect Bundle Split', |
3875 | - 'version': '1.0', |
3876 | + 'version': '6.1.0', |
3877 | 'category': 'Generic Modules', |
3878 | "author" : "Camptocamp", |
3879 | 'license': 'AGPL-3', |
3880 | |
3881 | === modified file 'magentoerpconnect_bundle_split/sale.py' |
3882 | --- magentoerpconnect_bundle_split/sale.py 2012-05-23 17:38:35 +0000 |
3883 | +++ magentoerpconnect_bundle_split/sale.py 2012-12-03 15:22:20 +0000 |
3884 | @@ -19,10 +19,11 @@ |
3885 | # |
3886 | ############################################################################## |
3887 | |
3888 | -from osv import osv, fields |
3889 | - |
3890 | - |
3891 | -class sale_order(osv.osv): |
3892 | +from openerp.osv.orm import Model |
3893 | +from openerp.osv import fields |
3894 | + |
3895 | + |
3896 | +class sale_order(Model): |
3897 | _inherit = "sale.order" |
3898 | |
3899 | def _merge_sub_items(self, cr, uid, product_type, top_item, child_items, context=None): |
3900 | @@ -47,15 +48,15 @@ |
3901 | else: |
3902 | return super(sale_order, self)._merge_sub_items(cr, uid, product_type, |
3903 | top_item, child_items, context=context) |
3904 | - def oe_create(self, cr, uid, |
3905 | - external_session, vals, resource, defaults, context): |
3906 | + def oe_create(self, cr, uid, |
3907 | + external_session, vals, resource, defaults, context): |
3908 | |
3909 | - order_id = super(sale_order, self).\ |
3910 | - oe_create(cr, uid, external_session, |
3911 | - vals, |
3912 | - resource, |
3913 | - defaults=defaults, |
3914 | - context=context) |
3915 | + order_id = super(sale_order, self).\ |
3916 | + oe_create(cr, uid, external_session, |
3917 | + vals, |
3918 | + resource, |
3919 | + defaults=defaults, |
3920 | + context=context) |
3921 | |
3922 | order_line_obj = self.pool.get('sale.order.line') |
3923 | order = self.browse(cr, uid, order_id, context=context) |
3924 | @@ -86,17 +87,11 @@ |
3925 | res['sale_line_bundle_id'] = line.bundle_parent_id.id |
3926 | return res |
3927 | |
3928 | -sale_order() |
3929 | - |
3930 | - |
3931 | -class sale_order_line(osv.osv): |
3932 | - |
3933 | + |
3934 | +class sale_order_line(Model): |
3935 | _inherit = 'sale.order.line' |
3936 | - |
3937 | _columns = { |
3938 | 'bundle_parent_id': fields.many2one('sale.order.line', 'Bundle Line'), |
3939 | 'magento_item_id': fields.integer('Magento Item ID'), |
3940 | 'magento_parent_item_id': fields.integer('Magento Item ID'), |
3941 | - } |
3942 | - |
3943 | -sale_order_line() |
3944 | + } |
3945 | |
3946 | === modified file 'magentoerpconnect_bundle_split/stock.py' |
3947 | --- magentoerpconnect_bundle_split/stock.py 2012-05-23 17:38:35 +0000 |
3948 | +++ magentoerpconnect_bundle_split/stock.py 2012-12-03 15:22:20 +0000 |
3949 | @@ -19,11 +19,11 @@ |
3950 | # |
3951 | ############################################################################## |
3952 | |
3953 | -from osv import osv, fields |
3954 | - |
3955 | - |
3956 | -class stock_picking(osv.osv): |
3957 | - |
3958 | +from openerp.osv.orm import Model |
3959 | +from openerp.osv import fields |
3960 | + |
3961 | + |
3962 | +class stock_picking(Model): |
3963 | _inherit = 'stock.picking' |
3964 | |
3965 | def create_ext_shipping(self, cr, uid, id, picking_type, |
3966 | @@ -56,16 +56,10 @@ |
3967 | cr, uid, id, picking_type, |
3968 | external_referential_id, context) |
3969 | |
3970 | -stock_picking() |
3971 | - |
3972 | - |
3973 | -class stock_move(osv.osv): |
3974 | - |
3975 | + |
3976 | +class stock_move(Model): |
3977 | _inherit = 'stock.move' |
3978 | - |
3979 | _columns = { |
3980 | 'sale_line_bundle_id': fields.many2one('sale.order.line', |
3981 | string='Sale Order Line Bundle') |
3982 | - } |
3983 | - |
3984 | -stock_move() |
3985 | + } |
3986 | |
3987 | === renamed directory 'magentoerpconnect_partner_fiscal_category' => 'magentoerpconnect_customer_fiscal_category' |
3988 | === modified file 'magentoerpconnect_customer_fiscal_category/__openerp__.py' |
3989 | --- magentoerpconnect_partner_fiscal_category/__openerp__.py 2012-03-27 09:51:08 +0000 |
3990 | +++ magentoerpconnect_customer_fiscal_category/__openerp__.py 2012-12-03 15:22:20 +0000 |
3991 | @@ -21,7 +21,7 @@ |
3992 | |
3993 | { |
3994 | 'name': 'Magentoerpconnect Partner Fiscal Category', |
3995 | - 'version': '1.0', |
3996 | + 'version': '6.1.0', |
3997 | 'category': 'Generic Modules', |
3998 | "author" : "Camptocamp", |
3999 | 'license': 'AGPL-3', |
4000 | @@ -46,7 +46,7 @@ |
4001 | 'depends': ['magentoerpconnect', |
4002 | 'account_fiscal_rules_partner_category', ], |
4003 | 'init_xml': [], |
4004 | - 'update_xml': ['settings/1.3.2.4/external.mappinglines.template.csv', |
4005 | + 'update_xml': [#'settings/1.3.2.4/external.mappinglines.template.csv', |
4006 | 'settings/1.5.0.0/external.mappinglines.template.csv', ], |
4007 | 'demo_xml': [], |
4008 | 'installable': True, |
4009 | |
4010 | === modified file 'magentoerpconnect_customer_fiscal_category/settings/1.5.0.0/external.mappinglines.template.csv' |
4011 | --- magentoerpconnect_partner_fiscal_category/settings/1.5.0.0/external.mappinglines.template.csv 2012-05-09 12:54:07 +0000 |
4012 | +++ magentoerpconnect_customer_fiscal_category/settings/1.5.0.0/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
4013 | @@ -1,7 +1,2 @@ |
4014 | -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 |
4015 | -magento_1500_prt_tax_class_id,magentoerpconnect.magento1500,base.model_res_partner,tax_class_id,,in_out,function,int,,"result = [('fiscal_category_id', False)] |
4016 | -if ifield: |
4017 | - category_obj = self.pool.get('res.partner.category') |
4018 | - category_ids = category_obj.search(cr, uid, [('tax_class_id', '=', ifield)]) |
4019 | - if category_ids: |
4020 | - result = [('fiscal_category_id', category_ids[0])]", |
4021 | +id,sequence,type,evaluation_type,external_field,field_id:id,external_type,alternative_key,mapping_id:id,function_name,in_function,out_function,child_mapping_id:id,datetime_format |
4022 | +mag1500_res_partner_group_id,,in_out,direct,group_id,account_fiscal_rules_partner_category.field_res_partner_fiscal_category_id,int,False,magentoerpconnect.mag1500_res_partner,,,,, |
4023 | |
4024 | === modified file 'magentoerpconnect_init_stock/__openerp__.py' |
4025 | --- magentoerpconnect_init_stock/__openerp__.py 2012-03-21 11:09:29 +0000 |
4026 | +++ magentoerpconnect_init_stock/__openerp__.py 2012-12-03 15:22:20 +0000 |
4027 | @@ -20,7 +20,7 @@ |
4028 | ############################################################################## |
4029 | |
4030 | {'name' : 'Magentoerpconnect Initialize Stock', |
4031 | - 'version' : '1.0', |
4032 | + 'version' : '6.1.0', |
4033 | 'author' : 'Camptocamp', |
4034 | 'maintainer': 'Camptocamp', |
4035 | 'license': 'AGPL-3', |
4036 | |
4037 | === modified file 'magentoerpconnect_init_stock/product.py' |
4038 | --- magentoerpconnect_init_stock/product.py 2012-03-21 11:09:29 +0000 |
4039 | +++ magentoerpconnect_init_stock/product.py 2012-12-03 15:22:20 +0000 |
4040 | @@ -20,12 +20,11 @@ |
4041 | ############################################################################## |
4042 | |
4043 | import logging |
4044 | -from osv import osv |
4045 | +from openerp.osv.orm import Model |
4046 | |
4047 | _logger = logging.getLogger(__name__) |
4048 | |
4049 | - |
4050 | -class product_product(osv.osv): |
4051 | +class product_product(Model): |
4052 | |
4053 | _inherit = 'product.product' |
4054 | |
4055 | @@ -52,5 +51,3 @@ |
4056 | self._magento_init_stock(cr, uid, oe_id, magento_product_id, |
4057 | conn, context=context) |
4058 | return magento_product_id |
4059 | - |
4060 | -product_product() |
4061 | |
4062 | === added directory 'magentoerpconnect_magento_invoice' |
4063 | === added file 'magentoerpconnect_magento_invoice/__init__.py' |
4064 | --- magentoerpconnect_magento_invoice/__init__.py 1970-01-01 00:00:00 +0000 |
4065 | +++ magentoerpconnect_magento_invoice/__init__.py 2012-12-03 15:22:20 +0000 |
4066 | @@ -0,0 +1,28 @@ |
4067 | +# -*- encoding: utf-8 -*- |
4068 | +############################################################################### |
4069 | +# |
4070 | +# magentoerpconnect_magento_invoice for OpenERP |
4071 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. All Rights Reserved |
4072 | +# @author Sébastien BEAU <sebastien.beau@akretion.com> |
4073 | +# This program is free software: you can redistribute it and/or modify |
4074 | +# it under the terms of the GNU Affero General Public License as |
4075 | +# published by the Free Software Foundation, either version 3 of the |
4076 | +# License, or (at your option) any later version. |
4077 | +# |
4078 | +# This program is distributed in the hope that it will be useful, |
4079 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4080 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4081 | +# GNU Affero General Public License for more details. |
4082 | +# |
4083 | +# You should have received a copy of the GNU Affero General Public License |
4084 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
4085 | +# |
4086 | +############################################################################### |
4087 | + |
4088 | + |
4089 | + |
4090 | +import account |
4091 | + |
4092 | + |
4093 | + |
4094 | + |
4095 | |
4096 | === added file 'magentoerpconnect_magento_invoice/__openerp__.py' |
4097 | --- magentoerpconnect_magento_invoice/__openerp__.py 1970-01-01 00:00:00 +0000 |
4098 | +++ magentoerpconnect_magento_invoice/__openerp__.py 2012-12-03 15:22:20 +0000 |
4099 | @@ -0,0 +1,44 @@ |
4100 | +# -*- encoding: utf-8 -*- |
4101 | +############################################################################### |
4102 | +# |
4103 | +# magentoerpconnect_magento_invoice for OpenERP |
4104 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. All Rights Reserved |
4105 | +# @author Sébastien BEAU <sebastien.beau@akretion.com> |
4106 | +# This program is free software: you can redistribute it and/or modify |
4107 | +# it under the terms of the GNU Affero General Public License as |
4108 | +# published by the Free Software Foundation, either version 3 of the |
4109 | +# License, or (at your option) any later version. |
4110 | +# |
4111 | +# This program is distributed in the hope that it will be useful, |
4112 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4113 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4114 | +# GNU Affero General Public License for more details. |
4115 | +# |
4116 | +# You should have received a copy of the GNU Affero General Public License |
4117 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
4118 | +# |
4119 | +############################################################################### |
4120 | + |
4121 | + |
4122 | + |
4123 | + |
4124 | +{ |
4125 | + 'name': 'magentoerpconnect_magento_invoice', |
4126 | + 'version': '6.1.1', |
4127 | + 'category': 'Generic Modules', |
4128 | + 'license': 'AGPL-3', |
4129 | + 'description': """This module will use the Magento invoice number for the OpenERP Invoice. |
4130 | + Be carefull if your Magento is not available you can not validade an invoice in OpenERP |
4131 | + TODO refactor MagentoERPconnect in order to extract the other way to synchronise order |
4132 | + """, |
4133 | + 'author': 'Akretion', |
4134 | + 'website': 'http://www.akretion.com/', |
4135 | + 'depends': ['magentoerpconnect'], |
4136 | + 'init_xml': [], |
4137 | + 'update_xml': [ |
4138 | + ], |
4139 | + 'demo_xml': [], |
4140 | + 'installable': True, |
4141 | + 'active': False, |
4142 | +} |
4143 | + |
4144 | |
4145 | === added file 'magentoerpconnect_magento_invoice/account.py' |
4146 | --- magentoerpconnect_magento_invoice/account.py 1970-01-01 00:00:00 +0000 |
4147 | +++ magentoerpconnect_magento_invoice/account.py 2012-12-03 15:22:20 +0000 |
4148 | @@ -0,0 +1,35 @@ |
4149 | +# -*- encoding: utf-8 -*- |
4150 | +############################################################################### |
4151 | +# |
4152 | +# magentoerpconnect_magento_invoice for OpenERP |
4153 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. All Rights Reserved |
4154 | +# @author Sébastien BEAU <sebastien.beau@akretion.com> |
4155 | +# This program is free software: you can redistribute it and/or modify |
4156 | +# it under the terms of the GNU Affero General Public License as |
4157 | +# published by the Free Software Foundation, either version 3 of the |
4158 | +# License, or (at your option) any later version. |
4159 | +# |
4160 | +# This program is distributed in the hope that it will be useful, |
4161 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4162 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4163 | +# GNU Affero General Public License for more details. |
4164 | +# |
4165 | +# You should have received a copy of the GNU Affero General Public License |
4166 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
4167 | +# |
4168 | +############################################################################### |
4169 | + |
4170 | + |
4171 | +from openerp.osv.orm import Model |
4172 | + |
4173 | +class account_invoice(Model): |
4174 | + _inherit = "account.invoice" |
4175 | + |
4176 | + def action_move_create(self, cr, uid, ids, context=None): |
4177 | + if context is None: |
4178 | + context = {'lang': 'en_US'} |
4179 | + for invoice in self.browse(cr, uid, ids, context=context): |
4180 | + ext_invoice_id = self._export_one_invoice(cr, uid, invoice, context=context) |
4181 | + invoice.write({'internal_number': ext_invoice_id}, context=context) |
4182 | + return super(account_invoice, self).action_move_create(cr, uid, ids, context=context) |
4183 | + |
4184 | |
4185 | === renamed directory 'magentoerpconnect_report_synchronizer' => 'magentoerpconnect_openerp_invoice' |
4186 | === modified file 'magentoerpconnect_openerp_invoice/__init__.py' |
4187 | --- magentoerpconnect_report_synchronizer/__init__.py 2012-06-01 17:48:36 +0000 |
4188 | +++ magentoerpconnect_openerp_invoice/__init__.py 2012-12-03 15:22:20 +0000 |
4189 | @@ -20,9 +20,5 @@ |
4190 | ############################################################################### |
4191 | |
4192 | |
4193 | - |
4194 | import invoice |
4195 | - |
4196 | - |
4197 | - |
4198 | - |
4199 | +import external_referential |
4200 | |
4201 | === modified file 'magentoerpconnect_openerp_invoice/__openerp__.py' |
4202 | --- magentoerpconnect_report_synchronizer/__openerp__.py 2012-06-01 17:48:36 +0000 |
4203 | +++ magentoerpconnect_openerp_invoice/__openerp__.py 2012-12-03 15:22:20 +0000 |
4204 | @@ -1,7 +1,7 @@ |
4205 | # -*- encoding: utf-8 -*- |
4206 | ############################################################################### |
4207 | # # |
4208 | -# magentoerpconnect_report_synchronizer for OpenERP # |
4209 | +# magentoerpconnect_openerp_invoice for OpenERP # |
4210 | # Copyright (C) 2012 Akretion Sébastien BEAU <sebastien.beau@akretion.com> # |
4211 | # # |
4212 | # This program is free software: you can redistribute it and/or modify # |
4213 | @@ -22,8 +22,8 @@ |
4214 | |
4215 | |
4216 | { |
4217 | - 'name': 'magentoerpconnect_report_synchronizer', |
4218 | - 'version': '0.1', |
4219 | + 'name': 'magentoerpconnect_openerp_invoice', |
4220 | + 'version': '6.1.1', |
4221 | 'category': 'Generic Modules/Others', |
4222 | 'license': 'AGPL-3', |
4223 | 'description': """ |
4224 | @@ -32,9 +32,13 @@ |
4225 | """, |
4226 | 'author': 'Akretion', |
4227 | 'website': 'http://www.akretion.com/', |
4228 | - 'depends': ['base_sale_report_synchronizer'], |
4229 | + 'depends': [ |
4230 | + 'base_sale_report_synchronizer', |
4231 | + 'magentoerpconnect', |
4232 | + ], |
4233 | 'init_xml': [], |
4234 | - 'update_xml': [ |
4235 | + 'update_xml': [ |
4236 | + 'external_referential_view.xml', |
4237 | ], |
4238 | 'demo_xml': [], |
4239 | 'installable': True, |
4240 | |
4241 | === added file 'magentoerpconnect_openerp_invoice/external_referential.py' |
4242 | --- magentoerpconnect_openerp_invoice/external_referential.py 1970-01-01 00:00:00 +0000 |
4243 | +++ magentoerpconnect_openerp_invoice/external_referential.py 2012-12-03 15:22:20 +0000 |
4244 | @@ -0,0 +1,33 @@ |
4245 | +# -*- encoding: utf-8 -*- |
4246 | +############################################################################### |
4247 | +# # |
4248 | +# base_sale_report_synchronizer for OpenERP # |
4249 | +# Copyright (C) 2012 Akretion Sébastien BEAU <sebastien.beau@akretion.com> # |
4250 | +# # |
4251 | +# This program is free software: you can redistribute it and/or modify # |
4252 | +# it under the terms of the GNU Affero General Public License as # |
4253 | +# published by the Free Software Foundation, either version 3 of the # |
4254 | +# License, or (at your option) any later version. # |
4255 | +# # |
4256 | +# This program is distributed in the hope that it will be useful, # |
4257 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
4258 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
4259 | +# GNU Affero General Public License for more details. # |
4260 | +# # |
4261 | +# You should have received a copy of the GNU Affero General Public License # |
4262 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. # |
4263 | +# # |
4264 | +############################################################################### |
4265 | + |
4266 | +from openerp.osv.orm import Model |
4267 | +from openerp.osv import fields |
4268 | +import netsvc |
4269 | + |
4270 | +class external_referential(Model): |
4271 | + _inherit = "external.referential" |
4272 | + |
4273 | + _columns = { |
4274 | + 'ext_file_referential_id': fields.many2one('external.referential', 'External Referential File', |
4275 | + help='Referential file where the OpenERP report will be push'), |
4276 | + } |
4277 | + |
4278 | |
4279 | === added file 'magentoerpconnect_openerp_invoice/external_referential_view.xml' |
4280 | --- magentoerpconnect_openerp_invoice/external_referential_view.xml 1970-01-01 00:00:00 +0000 |
4281 | +++ magentoerpconnect_openerp_invoice/external_referential_view.xml 2012-12-03 15:22:20 +0000 |
4282 | @@ -0,0 +1,22 @@ |
4283 | +<?xml version="1.0" encoding="utf-8"?> |
4284 | +<!-- |
4285 | + base_sale_report_synchronizer for OpenERP |
4286 | + Copyright (C) 2012 Akretion Sébastien BEAU <sebastien.beau@akretion.com> |
4287 | + The licence is in the file __openerp__.py |
4288 | +--> |
4289 | + |
4290 | +<openerp> |
4291 | + <data> |
4292 | + <record id="external_referential_form_view" model="ir.ui.view"> |
4293 | + <field name="name">base_sale_report_synchronizer.external_referential_form_view</field> |
4294 | + <field name="model">external.referential</field> |
4295 | + <field name="inherit_id" ref="base_external_referentials.external_referential_form_view" /> |
4296 | + <field name="type">form</field> |
4297 | + <field name="arch" type="xml"> |
4298 | + <field name="location" position="after"> |
4299 | + <field name="ext_file_referential_id"/> |
4300 | + </field> |
4301 | + </field> |
4302 | + </record> |
4303 | + </data> |
4304 | +</openerp> |
4305 | |
4306 | === modified file 'magentoerpconnect_openerp_invoice/invoice.py' |
4307 | --- magentoerpconnect_report_synchronizer/invoice.py 2012-06-01 17:48:36 +0000 |
4308 | +++ magentoerpconnect_openerp_invoice/invoice.py 2012-12-03 15:22:20 +0000 |
4309 | @@ -19,30 +19,63 @@ |
4310 | # # |
4311 | ############################################################################### |
4312 | |
4313 | -from osv import osv, fields |
4314 | -from tools.translate import _ |
4315 | +from openerp.osv.orm import Model |
4316 | +from openerp.osv import fields |
4317 | +from base_external_referentials.external_osv import ExternalSession |
4318 | +import os |
4319 | |
4320 | -class account_invoice(osv.osv): |
4321 | +class account_invoice(Model): |
4322 | _inherit = "account.invoice" |
4323 | |
4324 | - def ext_create(self, cr, uid, external_session, resources, mapping=None, mapping_id=None, context=None): |
4325 | - ext_create_ids={} |
4326 | - for resource_id, resource in resources.items(): |
4327 | - resource = resource[resource.keys()[0]] |
4328 | - if resource['type'] == 'out_refund': |
4329 | - method = "synoopenerpadapter_creditmemo.addInfo" |
4330 | - elif resource['type'] == 'out_invoice': |
4331 | - method = "synoopenerpadapter_invoice.addInfo" |
4332 | - resource['reference'] = context.get('report_name') |
4333 | - ext_create_ids[resource_id] = external_session.connection.call(method, |
4334 | - [ |
4335 | - resource['customer_id'], |
4336 | - resource['order_increment_id'], |
4337 | - resource['reference'], |
4338 | - resource['amount'], |
4339 | - resource['date'], |
4340 | - resource['customer_name'], |
4341 | - ]) |
4342 | - super(account_invoice, self).ext_create(cr, uid, external_session, resources, |
4343 | - mapping=mapping, mapping_id=mapping_id, context=context) |
4344 | - return ext_create_ids |
4345 | + def _export_one_resource(self, cr, uid, external_session, invoice_id, context=None): |
4346 | + #TODO think about a better solution to pass the report_name |
4347 | + context['report_name'] = self._send_invoice_report(cr, uid, external_session, |
4348 | + invoice_id, context=context) |
4349 | + return super(account_invoice, self)._export_one_resource(cr, uid, external_session, |
4350 | + invoice_id, context=context) |
4351 | + |
4352 | + def _send_invoice_report(self, cr, uid, external_session, invoice_id, context=None): |
4353 | + invoice = self.browse(cr, uid, invoice_id, context=context) |
4354 | + invoice_number = invoice.number.replace('/', '-') |
4355 | + invoice_path = self._get_invoice_path(cr, uid, external_session, invoice, context=context) |
4356 | + if not external_session.sync_from_object.invoice_report: |
4357 | + raise except_osv(_("User Error"), _("You must define a report for the invoice for your sale shop")) |
4358 | + report_name = "report.%s"%external_session.sync_from_object.invoice_report.report_name |
4359 | + #Init the connection with the sftp/ftp/... referential |
4360 | + if not hasattr(external_session, 'file_session'): |
4361 | + external_session.file_session = ExternalSession( |
4362 | + external_session.referential_id.ext_file_referential_id, |
4363 | + external_session.sync_from_object, |
4364 | + ) |
4365 | + return self.send_report(cr, uid, external_session.file_session, [invoice.id], report_name, |
4366 | + invoice_number, invoice_path, add_extension=False, context=context) |
4367 | + |
4368 | + def _get_invoice_path(self, cr, uid, external_session, invoice, context=None): |
4369 | + ref_id = external_session.referential_id.id |
4370 | + ext_partner_id = invoice.partner_id.get_extid(ref_id, context=context) |
4371 | + ext_sale_id = invoice.sale_ids[0].get_extid(ref_id, context=context) |
4372 | + if invoice.type == 'out_invoice': |
4373 | + basepath = 'invoice' |
4374 | + elif invoice.type == 'out_refund': |
4375 | + basepath = 'creditmemo' |
4376 | + return os.path.join(basepath, str(ext_partner_id), str(ext_sale_id)) |
4377 | + |
4378 | + def ext_create_one_invoice(self, cr, uid, external_session, resource_id, resource, context=None): |
4379 | + data = resource[resource.keys()[0]] |
4380 | + if data['type'] == 'out_refund': |
4381 | + method = "synoopenerpadapter_creditmemo.addInfo" |
4382 | + elif data['type'] == 'out_invoice': |
4383 | + method = "synoopenerpadapter_invoice.addInfo" |
4384 | + data['reference'] = context.get('report_name') |
4385 | + res = external_session.connection.call(method, |
4386 | + [ |
4387 | + data['customer_id'], |
4388 | + data['order_increment_id'], |
4389 | + data['reference'], |
4390 | + data['amount'], |
4391 | + data['date'], |
4392 | + data['customer_name'], |
4393 | + ]) |
4394 | + super(account_invoice, self).ext_create_one_invoice(cr, uid, external_session, |
4395 | + resource_id, resource, context=context) |
4396 | + return res |
4397 | |
4398 | === added directory 'magentoerpconnect_partner_surname' |
4399 | === added file 'magentoerpconnect_partner_surname/__init__.py' |
4400 | --- magentoerpconnect_partner_surname/__init__.py 1970-01-01 00:00:00 +0000 |
4401 | +++ magentoerpconnect_partner_surname/__init__.py 2012-12-03 15:22:20 +0000 |
4402 | @@ -0,0 +1,21 @@ |
4403 | +# -*- encoding: utf-8 -*- |
4404 | +############################################################################### |
4405 | +# |
4406 | +# magentoerpconnect_partner_surname for OpenERP |
4407 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. |
4408 | +# All Rights Reserved |
4409 | +# @author Sébastien BEAU <sebastien.beau@akretion.com> |
4410 | +# This program is free software: you can redistribute it and/or modify |
4411 | +# it under the terms of the GNU Affero General Public License as |
4412 | +# published by the Free Software Foundation, either version 3 of the |
4413 | +# License, or (at your option) any later version. |
4414 | +# |
4415 | +# This program is distributed in the hope that it will be useful, |
4416 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4417 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4418 | +# GNU Affero General Public License for more details. |
4419 | +# |
4420 | +# You should have received a copy of the GNU Affero General Public License |
4421 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
4422 | +# |
4423 | +############################################################################### |
4424 | |
4425 | === added file 'magentoerpconnect_partner_surname/__openerp__.py' |
4426 | --- magentoerpconnect_partner_surname/__openerp__.py 1970-01-01 00:00:00 +0000 |
4427 | +++ magentoerpconnect_partner_surname/__openerp__.py 2012-12-03 15:22:20 +0000 |
4428 | @@ -0,0 +1,43 @@ |
4429 | +# -*- encoding: utf-8 -*- |
4430 | +############################################################################### |
4431 | +# |
4432 | +# magentoerpconnect_partner_surname for OpenERP |
4433 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. |
4434 | +# All Rights Reserved |
4435 | +# @author Sébastien BEAU <sebastien.beau@akretion.com> |
4436 | +# This program is free software: you can redistribute it and/or modify |
4437 | +# it under the terms of the GNU Affero General Public License as |
4438 | +# published by the Free Software Foundation, either version 3 of the |
4439 | +# License, or (at your option) any later version. |
4440 | +# |
4441 | +# This program is distributed in the hope that it will be useful, |
4442 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4443 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4444 | +# GNU Affero General Public License for more details. |
4445 | +# |
4446 | +# You should have received a copy of the GNU Affero General Public License |
4447 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
4448 | +# |
4449 | +############################################################################### |
4450 | + |
4451 | +{ |
4452 | + 'name': 'magentoerpconnect_partner_surname', |
4453 | + 'version': '6.1.0', |
4454 | + 'category': 'Generic Modules/Others', |
4455 | + 'license': 'AGPL-3', |
4456 | + 'description': """ |
4457 | + This module with the dependency base_partner_surname add the |
4458 | + posibility to manage the fistname and the last name in a separated field |
4459 | + instead of having only one field 'name' |
4460 | + """, |
4461 | + 'author': 'Akretion', |
4462 | + 'website': 'http://www.akretion.com/', |
4463 | + 'depends': ['magentoerpconnect', 'base_partner_surname'], |
4464 | + 'init_xml': [], |
4465 | + 'update_xml': [ |
4466 | + 'settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv', |
4467 | + ], |
4468 | + 'demo_xml': [], |
4469 | + 'installable': True, |
4470 | + 'auto_install': True, |
4471 | +} |
4472 | |
4473 | === added directory 'magentoerpconnect_partner_surname/settings' |
4474 | === added directory 'magentoerpconnect_partner_surname/settings/1.5.0.0' |
4475 | === added directory 'magentoerpconnect_partner_surname/settings/1.5.0.0/res.partner.address' |
4476 | === added file 'magentoerpconnect_partner_surname/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv' |
4477 | --- magentoerpconnect_partner_surname/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv 1970-01-01 00:00:00 +0000 |
4478 | +++ magentoerpconnect_partner_surname/settings/1.5.0.0/res.partner.address/external.mappinglines.template.csv 2012-12-03 15:22:20 +0000 |
4479 | @@ -0,0 +1,3 @@ |
4480 | +id,sequence,type,evaluation_type,external_field,field_id:id,external_type,alternative_key,mapping_id:id,function_name,in_function,out_function,child_mapping_id:id,datetime_format |
4481 | +magentoerpconnect.mag1500_res_partner_address_name,,in_out,direct,firstname,base_partner_surname.field_res_partner_address_first_name,unicode,True,magentoerpconnect.mag1500_res_partner_address,,,,, |
4482 | +mag1500_res_partner_address_lastname,,in_out,direct,lastname,base_partner_surname.field_res_partner_address_last_name,unicode,True,magentoerpconnect.mag1500_res_partner_address,,,,, |
4483 | |
4484 | === modified file 'magentoerpconnect_payment/__openerp__.py' |
4485 | --- magentoerpconnect_payment/__openerp__.py 2012-03-27 09:40:33 +0000 |
4486 | +++ magentoerpconnect_payment/__openerp__.py 2012-12-03 15:22:20 +0000 |
4487 | @@ -21,7 +21,7 @@ |
4488 | |
4489 | |
4490 | {'name': 'Magentoerpconnect Payment', |
4491 | - 'version': '1.0', |
4492 | + 'version': '6.1.0', |
4493 | 'category': 'Generic Modules', |
4494 | 'author': "Camptocamp", |
4495 | 'license': 'AGPL-3', |
4496 | |
4497 | === modified file 'magentoerpconnect_payment/payment_type.py' |
4498 | --- magentoerpconnect_payment/payment_type.py 2012-03-27 09:40:33 +0000 |
4499 | +++ magentoerpconnect_payment/payment_type.py 2012-12-03 15:22:20 +0000 |
4500 | @@ -19,16 +19,14 @@ |
4501 | # |
4502 | ############################################################################## |
4503 | |
4504 | -from osv import osv, fields |
4505 | - |
4506 | - |
4507 | -class base_sale_payment_type(osv.osv): |
4508 | - |
4509 | +from openerp.osv.orm import Model |
4510 | +from openerp.osv import fields |
4511 | + |
4512 | + |
4513 | +class base_sale_payment_type(Model): |
4514 | _inherit = 'base.sale.payment.type' |
4515 | - |
4516 | _columns = { |
4517 | 'allow_magento_manual_invoice': |
4518 | fields.boolean('Allow Manual Creation of Magento Invoice') |
4519 | - } |
4520 | + } |
4521 | |
4522 | -base_sale_payment_type() |
4523 | |
4524 | === modified file 'magentoerpconnect_payment/sale.py' |
4525 | --- magentoerpconnect_payment/sale.py 2012-03-27 09:40:33 +0000 |
4526 | +++ magentoerpconnect_payment/sale.py 2012-12-03 15:22:20 +0000 |
4527 | @@ -20,11 +20,13 @@ |
4528 | ############################################################################## |
4529 | import xmlrpclib |
4530 | |
4531 | -from osv import osv, fields |
4532 | +from openerp.osv.orm import Model |
4533 | +from openerp.osv import fields |
4534 | +from openerp.osv.osv import except_osv |
4535 | from tools.translate import _ |
4536 | |
4537 | |
4538 | -class sale_order(osv.osv): |
4539 | +class sale_order(Model): |
4540 | |
4541 | _inherit = 'sale.order' |
4542 | |
4543 | @@ -52,10 +54,9 @@ |
4544 | # TODO: in case of error on Magento because the invoice has |
4545 | # already been created, get the invoice number |
4546 | # and store it in magento_ref |
4547 | - raise osv.except_osv( |
4548 | - _('Error'), _("Error on Magento on the invoice creation " |
4549 | - "for order %s :\n" \ |
4550 | - "%s" % (order.name, magento_error))) |
4551 | + raise except_osv(_('Error'), |
4552 | + _("Error on Magento on the invoice creation " |
4553 | + "for order %s :\n%s") % (order.name, magento_error)) |
4554 | self.write( |
4555 | cr, uid, order.id, |
4556 | {'magento_ref': external_invoice}, |
4557 | @@ -69,24 +70,23 @@ |
4558 | def button_magento_create_invoice(self, cr, uid, ids, context=None): |
4559 | order = self.browse(cr, uid, ids[0], context=context) |
4560 | if order.state != 'draft': |
4561 | - raise osv.except_osv( |
4562 | - _('Error'), _('This order is not a quotation.')) |
4563 | + raise except_osv(_('Error'), |
4564 | + _('This order is not a quotation.')) |
4565 | |
4566 | if not order.is_magento: |
4567 | - raise osv.except_osv( |
4568 | - _('Error'), _('This is not a Magento sale order.')) |
4569 | + raise except_osv(_('Error'), |
4570 | + _('This is not a Magento sale order.')) |
4571 | |
4572 | if not order.base_payment_type_id: |
4573 | - raise osv.except_osv( |
4574 | - _('Error'), _('This order has no external ' |
4575 | - 'payment type settings.')) |
4576 | + raise except_osv(_('Error'), |
4577 | + _('This order has no external ' |
4578 | + 'payment type settings.')) |
4579 | |
4580 | if not order.base_payment_type_id.allow_magento_manual_invoice: |
4581 | - raise osv.except_osv( |
4582 | - _('Error'), _( |
4583 | - "Manual creation of the invoice on Magento " |
4584 | - "is forbidden for external payment : %s" % |
4585 | - order.ext_payment_method)) |
4586 | + raise except_osv(_('Error'), |
4587 | + _("Manual creation of the invoice on Magento " |
4588 | + "is forbidden for external payment : %s") % |
4589 | + order.ext_payment_method) |
4590 | |
4591 | # sale_exceptions module methods |
4592 | # in order to check if the order is valid |
4593 | @@ -122,5 +122,3 @@ |
4594 | if order.magento_ref: |
4595 | vals['magento_ref'] = order.magento_ref |
4596 | return vals |
4597 | - |
4598 | -sale_order() |
4599 | |
4600 | === modified file 'magentoerpconnect_product_variant/__openerp__.py' |
4601 | --- magentoerpconnect_product_variant/__openerp__.py 2012-04-24 12:36:18 +0000 |
4602 | +++ magentoerpconnect_product_variant/__openerp__.py 2012-12-03 15:22:20 +0000 |
4603 | @@ -22,7 +22,7 @@ |
4604 | |
4605 | { |
4606 | 'name': 'magentoerpconnect_configurable_product', |
4607 | - 'version': '0.1', |
4608 | + 'version': '6.1.0', |
4609 | 'category': 'Generic Modules', |
4610 | 'license': 'AGPL-3', |
4611 | 'description': """Module to extend the module magentoerpconnect, with it you will be able to create variant of product in magento directly from Openerp. Enjoy it ! |
4612 | @@ -36,9 +36,9 @@ |
4613 | 'images/magentoerpconnect.png', |
4614 | ], |
4615 | "website" : "https://launchpad.net/magentoerpconnect", |
4616 | - 'depends': ['magentoerpconnect', 'product_variant_multi'], |
4617 | + 'depends': ['magentoerpconnect', 'product_variant_multi'], |
4618 | 'init_xml': [], |
4619 | - 'update_xml': [ |
4620 | + 'update_xml': [ |
4621 | 'product_view.xml', |
4622 | # 'settings/1.3.2.4/external.mappinglines.template.csv', |
4623 | 'settings/1.5.0.0/external.mappinglines.template.csv', |
4624 | |
4625 | === modified file 'magentoerpconnect_product_variant/product.py' |
4626 | --- magentoerpconnect_product_variant/product.py 2012-08-20 21:52:00 +0000 |
4627 | +++ magentoerpconnect_product_variant/product.py 2012-12-03 15:22:20 +0000 |
4628 | @@ -19,42 +19,30 @@ |
4629 | # # |
4630 | ################################################################################# |
4631 | |
4632 | -from osv import osv, fields |
4633 | +from openerp.osv.orm import Model |
4634 | +from openerp.osv import fields |
4635 | import netsvc |
4636 | |
4637 | -class product_variant_dimension_type(osv.osv): |
4638 | - |
4639 | +class product_variant_dimension_type(Model): |
4640 | _inherit = "product.variant.dimension.type" |
4641 | - |
4642 | - |
4643 | _columns = { |
4644 | - 'magento_attribut': fields.many2one('magerp.product_attributes', 'magento_attributs', domain = "[('frontend_input', '=', 'select'), ('is_global', '=', True), ('is_configurable', '=', True)]"), |
4645 | - } |
4646 | - |
4647 | -product_variant_dimension_type() |
4648 | - |
4649 | - |
4650 | -class product_variant_dimension_option(osv.osv): |
4651 | - |
4652 | + 'magento_attribut': fields.many2one('magerp.product_attributes', 'magento_attributs', |
4653 | + domain="[('frontend_input', '=', 'select'), ('is_global', '=', True), ('is_configurable', '=', True)]"), |
4654 | + } |
4655 | + |
4656 | + |
4657 | +class product_variant_dimension_option(Model): |
4658 | _inherit = "product.variant.dimension.option" |
4659 | - |
4660 | - |
4661 | _columns = { |
4662 | - #'magento_attribut': fields.related('dimension_id', 'magento_attribut', type="many2one", relation="magerp.product_attributes", string="Magento attributs", readonly=True), |
4663 | - 'magento_attribut_option': fields.many2one('magerp.product_attribute_options', 'magento_attributs_option', domain = "[('attribute_id', '=', parent.magento_attribut)]"), |
4664 | - |
4665 | - } |
4666 | - |
4667 | - |
4668 | -product_variant_dimension_option() |
4669 | - |
4670 | -class product_product(osv.osv): |
4671 | - |
4672 | + 'magento_attribut_option': fields.many2one('magerp.product_attribute_options', 'magento_attributs_option', |
4673 | + domain="[('attribute_id', '=', parent.magento_attribut)]"), |
4674 | + } |
4675 | + |
4676 | + |
4677 | +class product_product(Model): |
4678 | _inherit = "product.product" |
4679 | |
4680 | - |
4681 | -#TODO for update A configurable product have to be updated if a variant is added |
4682 | - |
4683 | + #TODO for update A configurable product have to be updated if a variant is added |
4684 | def build_product_code_and_properties(self, cr, uid, ids, context=None): |
4685 | super(product_product, self).build_product_code_and_properties(cr, uid, ids, context=context) |
4686 | magento_product_exportable_ids = [] |
4687 | @@ -68,7 +56,7 @@ |
4688 | # vals['x_magerp_visibility'] = option_id |
4689 | self.write(cr, uid, magento_product_exportable_ids, vals, context=context) |
4690 | return True |
4691 | - |
4692 | + |
4693 | def generate_variant_name(self, cr, uid, product_id, context=None): |
4694 | res = super(product_product, self).generate_variant_name(cr, uid, product_id, context) |
4695 | if res == '': |
4696 | @@ -86,7 +74,7 @@ |
4697 | else: |
4698 | vals['product_type'] = 'simple' |
4699 | return super(product_product, self).create(cr, uid, vals, context) |
4700 | - |
4701 | + |
4702 | def _filter_fields_to_return(self, cr, uid, field_names, context): |
4703 | #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 |
4704 | field_names = super(product_product, self)._filter_fields_to_return(cr, uid, field_names, context) |
4705 | @@ -145,15 +133,11 @@ |
4706 | return ext_update_ids |
4707 | |
4708 | |
4709 | -product_product() |
4710 | - |
4711 | -class product_template(osv.osv): |
4712 | - |
4713 | +class product_template(Model): |
4714 | _inherit = "product.template" |
4715 | - |
4716 | _columns = { |
4717 | 'magento_exportable':fields.boolean('Exported all variant to Magento?'), |
4718 | - } |
4719 | + } |
4720 | |
4721 | |
4722 | #TODO improve me, it will be great to have the posibility to create various configurable per template |
4723 | @@ -162,7 +146,5 @@ |
4724 | res = res + [[]] |
4725 | return res |
4726 | |
4727 | -product_template() |
4728 | - |
4729 | |
4730 | |
4731 | |
4732 | === modified file 'magentoerpconnect_product_variant/product_view.xml' |
4733 | --- magentoerpconnect_product_variant/product_view.xml 2012-05-23 14:01:19 +0000 |
4734 | +++ magentoerpconnect_product_variant/product_view.xml 2012-12-03 15:22:20 +0000 |
4735 | @@ -7,88 +7,88 @@ |
4736 | |
4737 | <openerp> |
4738 | <data> |
4739 | - |
4740 | + |
4741 | <!-- INHERITED VIEW FOR THE OBJECT : product_variant_dimension_option --> |
4742 | |
4743 | - <record id="magentoerpconnect_cp_product_variant_dimension_option_view_form" model="ir.ui.view"> |
4744 | - <field name="name">magentoerpconnect_cp.product_variant_dimension_option.view_form</field> |
4745 | - <field name="model">product.variant.dimension.option</field> |
4746 | - <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_option_form" /> |
4747 | + <record id="magentoerpconnect_cp_product_variant_dimension_option_view_form" model="ir.ui.view"> |
4748 | + <field name="name">magentoerpconnect_cp.product_variant_dimension_option.view_form</field> |
4749 | + <field name="model">product.variant.dimension.option</field> |
4750 | + <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_option_form" /> |
4751 | <field eval="16" name="priority"/> |
4752 | - <field name="type">form</field> |
4753 | - <field name="arch" type="xml"> |
4754 | - <data> |
4755 | - <field name="sequence" position="after"> |
4756 | - <field name="magento_attribut_option" /> |
4757 | - </field> |
4758 | - </data> |
4759 | - </field> |
4760 | - </record> |
4761 | + <field name="type">form</field> |
4762 | + <field name="arch" type="xml"> |
4763 | + <data> |
4764 | + <field name="sequence" position="after"> |
4765 | + <field name="magento_attribut_option" /> |
4766 | + </field> |
4767 | + </data> |
4768 | + </field> |
4769 | + </record> |
4770 | |
4771 | - <record id="magentoerpconnect_cp_product_variant_dimension_option_view_tree" model="ir.ui.view"> |
4772 | - <field name="name">magentoerpconnect_cp.product_variant_dimension_option.view_tree</field> |
4773 | - <field name="model">product.variant.dimension.option</field> |
4774 | - <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_option_tree" /> |
4775 | + <record id="magentoerpconnect_cp_product_variant_dimension_option_view_tree" model="ir.ui.view"> |
4776 | + <field name="name">magentoerpconnect_cp.product_variant_dimension_option.view_tree</field> |
4777 | + <field name="model">product.variant.dimension.option</field> |
4778 | + <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_option_tree" /> |
4779 | <field eval="16" name="priority"/> |
4780 | - <field name="type">tree</field> |
4781 | - <field name="arch" type="xml"> |
4782 | - <data> |
4783 | - <field name="sequence" position="after"> |
4784 | - <field name="magento_attribut_option" /> |
4785 | - </field> |
4786 | - </data> |
4787 | - </field> |
4788 | - </record> |
4789 | + <field name="type">tree</field> |
4790 | + <field name="arch" type="xml"> |
4791 | + <data> |
4792 | + <field name="sequence" position="after"> |
4793 | + <field name="magento_attribut_option" /> |
4794 | + </field> |
4795 | + </data> |
4796 | + </field> |
4797 | + </record> |
4798 | |
4799 | |
4800 | <!-- INHERITED VIEW FOR THE OBJECT : product_variant_dimension_type --> |
4801 | |
4802 | - <record id="magentoerpconnect_cp_product_variant_dimension_type_view_form" model="ir.ui.view"> |
4803 | - <field name="name">magentoerpconnect_cp.product_variant_dimension_type.view_form</field> |
4804 | - <field name="model">product.variant.dimension.type</field> |
4805 | - <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_type_form" /> |
4806 | - <field eval="16" name="priority"/> |
4807 | - <field name="type">form</field> |
4808 | - <field name="arch" type="xml"> |
4809 | - <data> |
4810 | - <field name="description" position="after"> |
4811 | - <field name="magento_attribut" /> |
4812 | - </field> |
4813 | - </data> |
4814 | - </field> |
4815 | - </record> |
4816 | - |
4817 | - <record id="magentoerpconnect_cp_product_variant_dimension_type_view_tree" model="ir.ui.view"> |
4818 | - <field name="name">magentoerpconnect_cp.product_variant_dimension_type.view_tree</field> |
4819 | - <field name="model">product.variant.dimension.type</field> |
4820 | - <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_type_tree" /> |
4821 | - <field eval="16" name="priority"/> |
4822 | - <field name="type">tree</field> |
4823 | - <field name="arch" type="xml"> |
4824 | - <data> |
4825 | - <field name="description" position="after"> |
4826 | - <field name="magento_attribut" /> |
4827 | - </field> |
4828 | - </data> |
4829 | - </field> |
4830 | - </record> |
4831 | - |
4832 | + <record id="magentoerpconnect_cp_product_variant_dimension_type_view_form" model="ir.ui.view"> |
4833 | + <field name="name">magentoerpconnect_cp.product_variant_dimension_type.view_form</field> |
4834 | + <field name="model">product.variant.dimension.type</field> |
4835 | + <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_type_form" /> |
4836 | + <field eval="16" name="priority"/> |
4837 | + <field name="type">form</field> |
4838 | + <field name="arch" type="xml"> |
4839 | + <data> |
4840 | + <field name="description" position="after"> |
4841 | + <field name="magento_attribut" /> |
4842 | + </field> |
4843 | + </data> |
4844 | + </field> |
4845 | + </record> |
4846 | + |
4847 | + <record id="magentoerpconnect_cp_product_variant_dimension_type_view_tree" model="ir.ui.view"> |
4848 | + <field name="name">magentoerpconnect_cp.product_variant_dimension_type.view_tree</field> |
4849 | + <field name="model">product.variant.dimension.type</field> |
4850 | + <field name="inherit_id" ref="product_variant_multi.product_variant_multi_dimension_type_tree" /> |
4851 | + <field eval="16" name="priority"/> |
4852 | + <field name="type">tree</field> |
4853 | + <field name="arch" type="xml"> |
4854 | + <data> |
4855 | + <field name="description" position="after"> |
4856 | + <field name="magento_attribut" /> |
4857 | + </field> |
4858 | + </data> |
4859 | + </field> |
4860 | + </record> |
4861 | + |
4862 | <!-- INHERITED VIEW FOR THE OBJECT : product_template --> |
4863 | |
4864 | - <record id="magentoerpconnect_cp_product_template_view_form" model="ir.ui.view"> |
4865 | - <field name="name">magentoerpconnect_cp.product_template.view_form</field> |
4866 | - <field name="model">product.template</field> |
4867 | - <field name="inherit_id" ref="product_variant_multi.product_variant_multi_product_template_form_view" /> |
4868 | + <record id="magentoerpconnect_cp_product_template_view_form" model="ir.ui.view"> |
4869 | + <field name="name">magentoerpconnect_cp.product_template.view_form</field> |
4870 | + <field name="model">product.template</field> |
4871 | + <field name="inherit_id" ref="product_variant_multi.product_variant_multi_product_template_form_view" /> |
4872 | <field eval="16" name="priority"/> |
4873 | - <field name="type">form</field> |
4874 | - <field name="arch" type="xml"> |
4875 | - <data> |
4876 | - <field name="is_multi_variants" position="after"> |
4877 | - <field name="set" /> |
4878 | - </field> |
4879 | - <field name="variants" position="after"> |
4880 | - <field name="product_type" /> |
4881 | - </field> |
4882 | + <field name="type">form</field> |
4883 | + <field name="arch" type="xml"> |
4884 | + <data> |
4885 | + <field name="is_multi_variants" position="after"> |
4886 | + <field name="set" /> |
4887 | + </field> |
4888 | + <field name="variants" position="after"> |
4889 | + <field name="product_type" /> |
4890 | + </field> |
4891 | |
4892 | <xpath expr="/form/notebook" position="before"> |
4893 | <group colsan="1"> |
4894 | @@ -98,12 +98,12 @@ |
4895 | <xpath expr="/form/notebook" position="inside"> |
4896 | <page string="attributes_placeholder"/> |
4897 | </xpath> |
4898 | - <field name="variant_track_outgoing" position="after"> |
4899 | - <field name="magento_exportable"/> |
4900 | - </field> |
4901 | - </data> |
4902 | - </field> |
4903 | - </record> |
4904 | + <field name="variant_track_outgoing" position="after"> |
4905 | + <field name="magento_exportable"/> |
4906 | + </field> |
4907 | + </data> |
4908 | + </field> |
4909 | + </record> |
4910 | |
4911 | <!--Magento Product Template Wizard Form view --> |
4912 |
Hi,
Some minor things:
Line 200: order`` is public (accessible from XMR/RPC) but may return a None value if they are zero or many invoices.
The method ``map_magento_
Line 1133
You've put an unused local variable ``first_install``.
Lines 1138-1149, I would rather use only one UPDATE with a CASE, it should something like:
UPDATE res_partner_address
SET name = CASE
WHEN firstname IS NOT NULL AND lastname IS NOT NULL THEN (firstname || ' ' || lastname)
WHEN firstname IS NOT NULL AND lastname IS NULL THEN firstname
WHEN firstname IS NULL AND lastname IS NOT NULL THEN lastname
ELSE '';
Otherwise, it seems good.
Thanks