Merge lp:~savoirfairelinux-openerp/openerp-sage-50/7.0-exportsage50 into lp:openerp-sage-50
- 7.0-exportsage50
- Merge into 7.0
Status: | Rejected |
---|---|
Rejected by: | Sandy Carter (http://www.savoirfairelinux.com) |
Proposed branch: | lp:~savoirfairelinux-openerp/openerp-sage-50/7.0-exportsage50 |
Merge into: | lp:openerp-sage-50 |
Diff against target: |
596 lines (+545/-0) 7 files modified
exportsage50/__init__.py (+24/-0) exportsage50/__openerp__.py (+121/-0) exportsage50/i18n/exportsage50.pot (+140/-0) exportsage50/security/ir.model.access.csv (+2/-0) exportsage50/wizard/__init__.py (+22/-0) exportsage50/wizard/exportsage50.py (+189/-0) exportsage50/wizard/exportsage50_view.xml (+47/-0) |
To merge this branch: | bzr merge lp:~savoirfairelinux-openerp/openerp-sage-50/7.0-exportsage50 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sandy Carter (http://www.savoirfairelinux.com) | Needs Resubmitting | ||
Maxime Chambreuil (http://www.savoirfairelinux.com) | code review | Approve | |
Joao Alfredo Gama Batista | Needs Fixing | ||
OpenERP Community Reviewer/Maintainer | Pending | ||
Review via email: mp+191893@code.launchpad.net |
Commit message
Description of the change
[UPG] Upgrade to version 7.0
- 5. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Move files into module directory
Joao Alfredo Gama Batista (joao-gama) wrote : | # |
El Hadji Dem (http://www.savoirfairelinux.com) (eh-dem) wrote : | # |
> Hi eh.dem,
>
> l.157.158.161 - On the 7.0 it's better to use the keywords data and demo
> instead of init_xml, update_xml and demo_xml.
>
> l.366.377 - osv.osv is deprecated. Use "from openerp.osv import fields, orm"
> and "class exportsage(
Thanks Joao
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) : | # |
- 9. By Maxime Chambreuil (http://www.savoirfairelinux.com)
-
[IMP] Move contributors in description file and remove french doc
- 10. By Maxime Chambreuil (http://www.savoirfairelinux.com)
-
[IMP] Fix PEP8 issues
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
I would rename the module to export_sage50 or accounting_
Code issues:
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
Minor code / Style issues:
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
exportsage50/
- 11. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Improve code : comments from launchpad
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
This PR has been moved to https:/
Please continue further development there.
Unmerged revisions
- 11. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Improve code : comments from launchpad
- 10. By Maxime Chambreuil (http://www.savoirfairelinux.com)
-
[IMP] Fix PEP8 issues
- 9. By Maxime Chambreuil (http://www.savoirfairelinux.com)
-
[IMP] Move contributors in description file and remove french doc
- 8. By EL HADJI DEM <email address hidden>
-
[IMP] add author file
- 7. By EL HADJI DEM <email address hidden>
-
[IMP] add pot file, indent code, write the original author
- 6. By EL HADJI DEM <email address hidden>
-
code review
- 5. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Move files into module directory
- 4. By El Hadji Dem (http://www.savoirfairelinux.com)
-
Migration du code pour OE7 et code review
- 3. By El Hadji Dem (http://www.savoirfairelinux.com)
-
supprimer le dossier images
- 2. By El Hadji Dem (http://www.savoirfairelinux.com)
-
Migration du code vers OE7 et code review
Preview Diff
1 | === added directory 'exportsage50' |
2 | === added file 'exportsage50/__init__.py' |
3 | --- exportsage50/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ exportsage50/__init__.py 2014-01-17 23:22:31 +0000 |
5 | @@ -0,0 +1,24 @@ |
6 | +# -*- encoding: utf-8 -*- |
7 | +############################################################################### |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>). |
11 | +# |
12 | +# This program is free software: you can redistribute it and/or modify |
13 | +# it under the terms of the GNU Affero General Public License as |
14 | +# published by the Free Software Foundation, either version 3 of the |
15 | +# License, or (at your option) any later version. |
16 | +# |
17 | +# This program is distributed in the hope that it will be useful, |
18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | +# GNU Affero General Public License for more details. |
21 | +# |
22 | +# You should have received a copy of the GNU Affero General Public License |
23 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
24 | +# |
25 | +############################################################################### |
26 | + |
27 | +from . import wizard |
28 | + |
29 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
30 | |
31 | === added file 'exportsage50/__init__.pyc' |
32 | Binary files exportsage50/__init__.pyc 1970-01-01 00:00:00 +0000 and exportsage50/__init__.pyc 2014-01-17 23:22:31 +0000 differ |
33 | === added file 'exportsage50/__openerp__.py' |
34 | --- exportsage50/__openerp__.py 1970-01-01 00:00:00 +0000 |
35 | +++ exportsage50/__openerp__.py 2014-01-17 23:22:31 +0000 |
36 | @@ -0,0 +1,121 @@ |
37 | +# -*- encoding: utf-8 -*- |
38 | +############################################################################### |
39 | +# |
40 | +# OpenERP, Open Source Management Solution |
41 | +# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>). |
42 | +# |
43 | +# This program is free software: you can redistribute it and/or modify |
44 | +# it under the terms of the GNU Affero General Public License as |
45 | +# published by the Free Software Foundation, either version 3 of the |
46 | +# License, or (at your option) any later version. |
47 | +# |
48 | +# This program is distributed in the hope that it will be useful, |
49 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
50 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
51 | +# GNU Affero General Public License for more details. |
52 | +# |
53 | +# You should have received a copy of the GNU Affero General Public License |
54 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
55 | +# |
56 | +############################################################################### |
57 | + |
58 | +{ |
59 | + 'name': 'Export to Sage50', |
60 | + 'version': '1.0', |
61 | + "category": 'Accounting & Finance', |
62 | + 'complexity': "easy", |
63 | + 'description': """ |
64 | + |
65 | +Export accounting data from OpenERP to Sage50 |
66 | +============================================= |
67 | + |
68 | +Export accounting data from OpenERP to Sage50. The export generates the imp file to import in Sage50. |
69 | + |
70 | + |
71 | +Documentation : layout of the import file (.IMP) |
72 | +------------------------------------------------ |
73 | + |
74 | +A PDF document (in the /doc repository) gives more details about the .IMP file layout that can be imported |
75 | +into Sage 50. This document is part of the Sage 50 SDK (Software Development Kit) available for download at |
76 | +the following address : http://na.sage.com/sage-simply-accounting/lp/partners/sdk/?isnow=ssa. |
77 | + |
78 | +Sage 50: After creating .IMP file |
79 | +--------------------------------- |
80 | + |
81 | +Solution: |
82 | +* Importing purchase invoices, purchase quotes, sales invoices and sales orders into Sage 50 |
83 | + |
84 | +How to import purchase invoices, purchase quotes, sales invoices and sales orders? |
85 | + |
86 | +You can import purchase invoices, purchase quotes, sales invoices and sales orders into Sage 50. |
87 | +The transaction(s) details should be in a text file with extension .IMP. |
88 | + |
89 | +After you have created the .IMP file, you can import the transaction(s) into Sage 50 by following these steps: |
90 | +(Account information is not included in the .IMP format because when importing the file, you will receive |
91 | +a pop-up screen to ask you "Select an Account to match".) |
92 | + |
93 | +* From the Home Window, go to File, Import/Export |
94 | +* Click on Import Transactions (the Import Transactions Wizard appears) |
95 | +* Select on 'Import purchase invoices, purchase quotes, sales invoices, sales orders or time slips' and click Next |
96 | +* You can now create a backup of your file |
97 | +* Click Next |
98 | +* Click on Browse and select the .IMP file previously created |
99 | +* If the customer (or vendor) in the transaction(s) you are trying to import does not exist in the Sage 50 company, |
100 | +you will get a new window asking you if you want to add this customer (or vendor), or if you want to select |
101 | +another customer (or vendor) from the existing ones |
102 | +* You will also get a similar window if the import file uses an inventory item which does not exist in Sage 50. |
103 | +* You will see a summary of the imported transactions, click OK and then Finish. |
104 | +* If you got any errors importing the data, open the .IMP file in Notepad and use the attached .PDF document |
105 | +to verify the file format. Once the errors have been corrected, you can try the import again. |
106 | + |
107 | +Note: View KB25664 for information about some possible errors when importing .IMP file. |
108 | + |
109 | +Sage Business Care plan does NOT include support for SDK. Please, contact one of our partners website |
110 | +for further assistance. |
111 | + |
112 | +Possible errors when importing purchase invoices, purchase quotes, sales invoices and/or sales orders |
113 | +===================================================================================================== |
114 | + |
115 | +Questions and Answers |
116 | + |
117 | +Import started... Errors occurred while importing. |
118 | +Line x does not contain compatible tax information. |
119 | +Invalid date. The date must be between <date1> and <date2>. |
120 | + |
121 | + |
122 | +A: These are the possible reasons for getting any of these error messages when importing transactions |
123 | +into Simply Accounting: |
124 | + |
125 | +* The import file (extension .IMP) you are using does not have the proper format. |
126 | + Refer to the KB article 25659 for more information about the format of the import file. |
127 | + |
128 | +* The transaction type is not enabled in the Simply Accounting company. To enable the feature, from the Home Window |
129 | +in Simply Accounting, go to Setup, Settings, Company, Features, make sure the type of transaction you want to import |
130 | +is checked |
131 | + |
132 | +* The dates in the import file do not match the fiscal year dates in Simply Accounting. |
133 | + Open the import file in Notepad and make the necessary changes |
134 | + |
135 | +Contributors |
136 | +------------ |
137 | + |
138 | +* El Hadji Dem <elhadji.dem@savoirfairelinux.com> |
139 | +* Maxime Chambreuil <maxime.chambreuil@savoirfairelinux.com> |
140 | + |
141 | + """, |
142 | + 'author': 'Gestion-Ressources', |
143 | + 'website': 'http://www.gestion-ressources.com', |
144 | + "license": "AGPL-3", |
145 | + 'images': [], |
146 | + 'depends': ['account'], |
147 | + 'data': [ |
148 | + 'security/ir.model.access.csv', |
149 | + 'wizard/exportsage50_view.xml' |
150 | + ], |
151 | + 'demo': [], |
152 | + 'test': [], |
153 | + 'installable': True, |
154 | + 'auto_install': False, |
155 | + 'application': True, |
156 | +} |
157 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
158 | |
159 | === added directory 'exportsage50/docs' |
160 | === added file 'exportsage50/docs/Guide_Export_Sage_50_OpenERP_FR.pdf' |
161 | Binary files exportsage50/docs/Guide_Export_Sage_50_OpenERP_FR.pdf 1970-01-01 00:00:00 +0000 and exportsage50/docs/Guide_Export_Sage_50_OpenERP_FR.pdf 2014-01-17 23:22:31 +0000 differ |
162 | === added file 'exportsage50/docs/dev-import.pdf' |
163 | Binary files exportsage50/docs/dev-import.pdf 1970-01-01 00:00:00 +0000 and exportsage50/docs/dev-import.pdf 2014-01-17 23:22:31 +0000 differ |
164 | === added directory 'exportsage50/i18n' |
165 | === added file 'exportsage50/i18n/exportsage50.pot' |
166 | --- exportsage50/i18n/exportsage50.pot 1970-01-01 00:00:00 +0000 |
167 | +++ exportsage50/i18n/exportsage50.pot 2014-01-17 23:22:31 +0000 |
168 | @@ -0,0 +1,140 @@ |
169 | +# Translation of OpenERP Server. |
170 | +# This file contains the translation of the following modules: |
171 | +# * exportsage50 |
172 | +# |
173 | +msgid "" |
174 | +msgstr "" |
175 | +"Project-Id-Version: OpenERP Server 7.0\n" |
176 | +"Report-Msgid-Bugs-To: \n" |
177 | +"POT-Creation-Date: 2013-11-15 16:22+0000\n" |
178 | +"PO-Revision-Date: 2013-11-15 16:22+0000\n" |
179 | +"Last-Translator: <>\n" |
180 | +"Language-Team: \n" |
181 | +"MIME-Version: 1.0\n" |
182 | +"Content-Type: text/plain; charset=UTF-8\n" |
183 | +"Content-Transfer-Encoding: \n" |
184 | +"Plural-Forms: \n" |
185 | + |
186 | +#. module: exportsage50 |
187 | +#: field:exportsage,name:0 |
188 | +msgid "Filename" |
189 | +msgstr "" |
190 | + |
191 | +#. module: exportsage50 |
192 | +#: field:exportsage,format:0 |
193 | +msgid "File Format" |
194 | +msgstr "" |
195 | + |
196 | +#. module: exportsage50 |
197 | +#: field:exportsage,state:0 |
198 | +msgid "unknown" |
199 | +msgstr "" |
200 | + |
201 | +#. module: exportsage50 |
202 | +#: view:exportsage:0 |
203 | +msgid "Here is the exported file:" |
204 | +msgstr "" |
205 | + |
206 | +#. module: exportsage50 |
207 | +#: model:ir.model,name:exportsage50.model_exportsage |
208 | +msgid "Create imp file to export in sage50" |
209 | +msgstr "" |
210 | + |
211 | +#. module: exportsage50 |
212 | +#: selection:exportsage,state:0 |
213 | +msgid "choose" |
214 | +msgstr "" |
215 | + |
216 | +#. module: exportsage50 |
217 | +#: view:exportsage:0 |
218 | +msgid "Unicode/UTF-8" |
219 | +msgstr "" |
220 | + |
221 | +#. module: exportsage50 |
222 | +#: view:exportsage:0 |
223 | +msgid "file encoding, please be sure to view and edit using the same encoding." |
224 | +msgstr "" |
225 | + |
226 | +#. module: exportsage50 |
227 | +#: selection:exportsage,state:0 |
228 | +msgid "get" |
229 | +msgstr "" |
230 | + |
231 | +#. module: exportsage50 |
232 | +#: view:exportsage:0 |
233 | +msgid "This file was generated using the universal" |
234 | +msgstr "" |
235 | + |
236 | +#. module: exportsage50 |
237 | +#: view:exportsage:0 |
238 | +msgid "Cancel" |
239 | +msgstr "" |
240 | + |
241 | +#. module: exportsage50 |
242 | +#: code:addons/exportsage50/wizard/exportsage50.py:68 |
243 | +#, python-format |
244 | +msgid "Error" |
245 | +msgstr "" |
246 | + |
247 | +#. module: exportsage50 |
248 | +#: view:exportsage:0 |
249 | +msgid "Export Complete" |
250 | +msgstr "" |
251 | + |
252 | +#. module: exportsage50 |
253 | +#: view:exportsage:0 |
254 | +msgid "Export Settings" |
255 | +msgstr "" |
256 | + |
257 | +#. module: exportsage50 |
258 | +#: help:exportsage,invoice_ids:0 |
259 | +msgid "This is the list of invoices that have been generated for this sales order. The same sales order may have been invoiced in several times (by line for example)." |
260 | +msgstr "" |
261 | + |
262 | +#. module: exportsage50 |
263 | +#: model:ir.actions.act_window,name:exportsage50.action_account_invoice_generate_export_view |
264 | +#: model:ir.ui.menu,name:exportsage50.menu_account_invoice_generate_export_view |
265 | +msgid "Export accounting data to Sage50" |
266 | +msgstr "" |
267 | + |
268 | +#. module: exportsage50 |
269 | +#: field:exportsage,invoice_ids:0 |
270 | +msgid "Invoices" |
271 | +msgstr "" |
272 | + |
273 | +#. module: exportsage50 |
274 | +#: view:exportsage:0 |
275 | +msgid "or" |
276 | +msgstr "" |
277 | + |
278 | +#. module: exportsage50 |
279 | +#: code:addons/exportsage50/wizard/exportsage50.py:68 |
280 | +#, python-format |
281 | +msgid "You have to select at least 1 Invoice. And try again" |
282 | +msgstr "" |
283 | + |
284 | +#. module: exportsage50 |
285 | +#: view:exportsage:0 |
286 | +msgid "This action allows you to export accounting data from OpenErp to Simply account.You should have the same configuration about the tax information" |
287 | +msgstr "" |
288 | + |
289 | +#. module: exportsage50 |
290 | +#: field:exportsage,data:0 |
291 | +msgid "File" |
292 | +msgstr "" |
293 | + |
294 | +#. module: exportsage50 |
295 | +#: view:exportsage:0 |
296 | +msgid "Export to Sage50" |
297 | +msgstr "" |
298 | + |
299 | +#. module: exportsage50 |
300 | +#: view:exportsage:0 |
301 | +msgid "Close" |
302 | +msgstr "" |
303 | + |
304 | +#. module: exportsage50 |
305 | +#: view:exportsage:0 |
306 | +msgid "Export" |
307 | +msgstr "" |
308 | + |
309 | |
310 | === added directory 'exportsage50/security' |
311 | === added file 'exportsage50/security/ir.model.access.csv' |
312 | --- exportsage50/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
313 | +++ exportsage50/security/ir.model.access.csv 2014-01-17 23:22:31 +0000 |
314 | @@ -0,0 +1,2 @@ |
315 | +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
316 | +access_exportsage,exportsage,model_exportsage,account.group_account_user,1,0,0,0 |
317 | |
318 | === added directory 'exportsage50/static' |
319 | === added directory 'exportsage50/static/src' |
320 | === added directory 'exportsage50/static/src/img' |
321 | === added file 'exportsage50/static/src/img/icon.png' |
322 | Binary files exportsage50/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and exportsage50/static/src/img/icon.png 2014-01-17 23:22:31 +0000 differ |
323 | === added directory 'exportsage50/wizard' |
324 | === added file 'exportsage50/wizard/__init__.py' |
325 | --- exportsage50/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
326 | +++ exportsage50/wizard/__init__.py 2014-01-17 23:22:31 +0000 |
327 | @@ -0,0 +1,22 @@ |
328 | +# -*- encoding: utf-8 -*- |
329 | +############################################################################### |
330 | +# |
331 | +# OpenERP, Open Source Management Solution |
332 | +# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>). |
333 | +# |
334 | +# This program is free software: you can redistribute it and/or modify |
335 | +# it under the terms of the GNU Affero General Public License as |
336 | +# published by the Free Software Foundation, either version 3 of the |
337 | +# License, or (at your option) any later version. |
338 | +# |
339 | +# This program is distributed in the hope that it will be useful, |
340 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
341 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
342 | +# GNU Affero General Public License for more details. |
343 | +# |
344 | +# You should have received a copy of the GNU Affero General Public License |
345 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
346 | +# |
347 | +############################################################################### |
348 | +from . import exportsage50 |
349 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
350 | |
351 | === added file 'exportsage50/wizard/exportsage50.py' |
352 | --- exportsage50/wizard/exportsage50.py 1970-01-01 00:00:00 +0000 |
353 | +++ exportsage50/wizard/exportsage50.py 2014-01-17 23:22:31 +0000 |
354 | @@ -0,0 +1,189 @@ |
355 | +# -*- encoding: utf-8 -*- |
356 | +############################################################################### |
357 | +# |
358 | +# OpenERP, Open Source Management Solution |
359 | +# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>). |
360 | +# |
361 | +# This program is free software: you can redistribute it and/or modify |
362 | +# it under the terms of the GNU Affero General Public License as |
363 | +# published by the Free Software Foundation, either version 3 of the |
364 | +# License, or (at your option) any later version. |
365 | +# |
366 | +# This program is distributed in the hope that it will be useful, |
367 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
368 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
369 | +# GNU Affero General Public License for more details. |
370 | +# |
371 | +# You should have received a copy of the GNU Affero General Public License |
372 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
373 | +# |
374 | +############################################################################### |
375 | + |
376 | +from openerp.osv import fields, orm |
377 | +import base64 |
378 | +from openerp.tools.translate import _ |
379 | +import pooler |
380 | +from datetime import datetime |
381 | +import unicodedata |
382 | + |
383 | + |
384 | +class exportsage(orm.Model): |
385 | + _name = "exportsage" |
386 | + _description = "Create imp file to export in sage50" |
387 | + _columns = { |
388 | + 'data': fields.binary('File', readonly=True), |
389 | + 'name': fields.char('Filename', 20, readonly=True), |
390 | + 'format': fields.char('File Format', 10), |
391 | + 'state': fields.selection([('choose', 'choose'), |
392 | + ('get', 'get')]), |
393 | + 'invoice_ids': fields.many2many('account.invoice', 'sale_order_invoice_export_rel', 'order_id', 'invoice_id', |
394 | + 'Invoices', required=True, |
395 | + help="This is the list of invoices that have been generated " |
396 | + "for this sales order. The same sales order may have been invoiced " |
397 | + "in several times (by line for example)."), |
398 | + } |
399 | + |
400 | + _defaults = { |
401 | + 'state': lambda *a: 'choose', |
402 | + } |
403 | + |
404 | + def act_cancel(self, cr, uid, ids, context=None): |
405 | + return {'type': 'ir.actions.act_window_close'} |
406 | + |
407 | + def act_destroy(self, *args): |
408 | + return {'type': 'ir.actions.act_window_close'} |
409 | + |
410 | + def create_report(self, cr, uid, ids, context=None): |
411 | + if context is None: |
412 | + context = {} |
413 | + this = self.browse(cr, uid, ids, context=context)[0] |
414 | + data = self.read(cr, uid, ids, [], context=context)[0] |
415 | + |
416 | + if not data['invoice_ids']: |
417 | + raise orm.except_orm(_('Error'), _('You have to select at least 1 Invoice. And try again')) |
418 | + |
419 | + output = '<Version>''\n' + '"12001"' + ',' + '"1"''\n' + '</Version>\n\n' |
420 | + # Do the treatment of other lines in the invoice lines |
421 | + pool = pooler.get_pool(cr.dbname) |
422 | + line_obj = pool.get('account.invoice') |
423 | + account_move_line_obj = self.pool.get('account.move.line') |
424 | + account_invoice_line_obj = self.pool.get('account.invoice.line') |
425 | + decimal_precision_obj = self.pool.get('decimal.precision') |
426 | + |
427 | + for line in line_obj.browse(cr, uid, data['invoice_ids'], context=context): |
428 | + # start tag for invoice lines |
429 | + output += '<SalInvoice>''\n' |
430 | + #informations sur le client |
431 | + costumer_name = line.partner_id.name |
432 | + onetimefield = "" |
433 | + contact_name = line.partner_id.name or "" |
434 | + street1 = line.partner_id.street or "" |
435 | + street2 = line.partner_id.street2 or "" |
436 | + city = line.partner_id.city or "" |
437 | + province_state = line.partner_id.state_id.name or "" |
438 | + zip_code = line.partner_id.zip or "" |
439 | + country = line.partner_id.country_id.name or "" |
440 | + phone1 = line.partner_id.phone or "" |
441 | + mobile = line.partner_id.mobile or "" |
442 | + fax = line.partner_id.fax or "" |
443 | + email = line.partner_id.email or "" |
444 | + # Customer line |
445 | + fields = [costumer_name, onetimefield, contact_name, street1, street2, |
446 | + city, province_state, zip_code, country, phone1, mobile, fax, email |
447 | + ] |
448 | + costumer = ','.join(['"%s"' % field for field in fields]) |
449 | + output += costumer.encode('UTF-8') + '\n' |
450 | + # Invoice informations |
451 | + no_of_details = str(len(line.invoice_line)) |
452 | + order_no = "" |
453 | + # Invoice number (Max 20 chars) |
454 | + invoice_no = str(line.number) |
455 | + # Get invoice date |
456 | + entry_date = datetime.strptime(line.date_invoice, "%Y-%m-%d").strftime('%m-%d-%Y')\ |
457 | + if line.date_invoice else "" |
458 | + # Type of payment (between 0 and 3) |
459 | + # 0 = pay later , 1 = cash , 2 = cheque , 3 = credit card |
460 | + # Select last payment |
461 | + list_id = [] |
462 | + # Paid by source (20 Chars) : Blank- pay later and cash Cheque number or credit card |
463 | + paid_by_source = "" |
464 | + if line.payment_ids: |
465 | + lastId = max(line.payment_ids).id |
466 | + for oneId in line.payment_ids: |
467 | + list_id.append(oneId.id) |
468 | + lastId = max(list_id) |
469 | + # access from the last payment account_move_line object |
470 | + account_move_line = account_move_line_obj.browse(cr, uid, lastId, context=context) |
471 | + paiement_type = account_move_line.journal_id.type |
472 | + if paiement_type == 'cash': |
473 | + paid_by_type = str(1) |
474 | + paid_by_source = account_move_line.ref |
475 | + elif paiement_type == 'bank': |
476 | + paid_by_type = str(2) |
477 | + else: |
478 | + paid_by_type = str(0) # default value 0 = pay later |
479 | + else: |
480 | + paid_by_type = str(0) # default value 0 = pay later |
481 | + total_amount = str(line.amount_total) or "" |
482 | + freight_amount = "0.0" |
483 | + fields_sale_invoice = [no_of_details, order_no, invoice_no, entry_date, paid_by_type, |
484 | + paid_by_source, total_amount, freight_amount] |
485 | + sale_invoice = ','.join(['"%s"' % one_field for one_field in fields_sale_invoice]) |
486 | + output += sale_invoice.encode('UTF-8') + '\n' |
487 | + product_line_invoice_with_tax = "" |
488 | + #Sale invoice detail lines |
489 | + product_ids = account_invoice_line_obj.search(cr, |
490 | + uid, |
491 | + [('invoice_id', '=', line.id)], |
492 | + context=context) |
493 | + |
494 | + if product_ids: |
495 | + for product in account_invoice_line_obj.browse(cr, |
496 | + uid, |
497 | + product_ids, |
498 | + context=context): |
499 | + item_number = unicode(product.name, "utf8", "replace") \ |
500 | + if isinstance(product.name, str) else unicodedata.normalize('NFD', product.name) |
501 | + quantity = str(product.quantity) |
502 | + price = str(product.price_unit) |
503 | + amount = product.quantity * product.price_unit |
504 | + amount = str(round(amount, decimal_precision_obj.precision_get(cr, uid, 'Account'))) |
505 | + fields_one_product_invoice = [item_number, quantity, price, amount] |
506 | + one_product_invoice = ','.join(['"%s"' % field_one_product_invoice |
507 | + for field_one_product_invoice in fields_one_product_invoice]) |
508 | + one_product_invoice = one_product_invoice.encode('UTF-8') |
509 | + tax_product_line = "" |
510 | + # Tax information for each product |
511 | + if product.invoice_line_tax_id: |
512 | + for one_tax in product.invoice_line_tax_id: |
513 | + tax_name = one_tax.description # or one_tax.description or one_tax.name |
514 | + # 1=yes, 0=No |
515 | + tax_included = str(1) if one_tax.price_include else str(0) |
516 | + tax_refundable = str(1) # 1=yes, 0=No |
517 | + tax_rate = str(one_tax.amount) |
518 | + tax_amount = str(one_tax.amount) |
519 | + fields_tax_product_line = [tax_name, tax_included, tax_refundable, tax_rate, tax_amount, ] |
520 | + tax_product_line = ',' + ','.join(['"%s"' % one_tax_field |
521 | + for one_tax_field in fields_tax_product_line]) |
522 | + tax_product_line = tax_product_line.encode('UTF-8') |
523 | + product_line_invoice_with_tax += one_product_invoice + tax_product_line + '\n' |
524 | + output += product_line_invoice_with_tax |
525 | + # End of invoice lines |
526 | + output += '</SalInvoice>\n\n\n' |
527 | + this.format = 'imp' |
528 | + filename = 'export_to_sage50' |
529 | + this.name = "%s.%s" % (filename, this.format) |
530 | + out = base64.encodestring(output) |
531 | + self.write(cr, uid, ids, {'state': 'get', 'data': out, 'name': this.name, |
532 | + 'format': this.format}, context=context) |
533 | + |
534 | + return { |
535 | + 'type': 'ir.actions.act_window', |
536 | + 'res_model': 'exportsage', |
537 | + 'view_mode': 'form', |
538 | + 'view_type': 'form', |
539 | + 'res_id': this.id, |
540 | + 'views': [(False, 'form')], |
541 | + 'target': 'new', |
542 | + } |
543 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
544 | |
545 | === added file 'exportsage50/wizard/exportsage50_view.xml' |
546 | --- exportsage50/wizard/exportsage50_view.xml 1970-01-01 00:00:00 +0000 |
547 | +++ exportsage50/wizard/exportsage50_view.xml 2014-01-17 23:22:31 +0000 |
548 | @@ -0,0 +1,47 @@ |
549 | +<?xml version="1.0" encoding="utf-8"?> |
550 | +<openerp> |
551 | + <data> |
552 | + <record id="account_invoice_generate_export_view" model="ir.ui.view"> |
553 | + <field name="name">Export to Sage50</field> |
554 | + <field name="model">exportsage</field> |
555 | + <field name="arch" type="xml"> |
556 | + <form string="Export to Sage50" version="7.0"> |
557 | + <field invisible="1" name="state"/> |
558 | + <field invisible="1" name="format"/> |
559 | + <label string="This action allows you to export accounting data from OpenErp |
560 | + to Simply account.You should have the same configuration about the tax information"/> |
561 | + <group states="choose" string="Export Settings"> |
562 | + <field name="invoice_ids" colspan="4" nolabel="1"/> |
563 | + </group> |
564 | + <div states="get"> |
565 | + <h2>Export Complete</h2> |
566 | + <p>Here is the exported file: <field name="data" readonly="1" filename="name"/></p> |
567 | + <p>This file was generated using the universal |
568 | + <strong>Unicode/UTF-8</strong> |
569 | + file encoding, please be sure to view and edit using the same encoding. |
570 | + </p> |
571 | + </div> |
572 | + <footer states="choose"> |
573 | + <button name="create_report" string="Export" type="object" class="oe_highlight"/> |
574 | + or |
575 | + <button special="cancel" string="Cancel" type="object" class="oe_link"/> |
576 | + </footer> |
577 | + <footer states="get"> |
578 | + <button special="cancel" string="Close" type="object"/> |
579 | + </footer> |
580 | + </form> |
581 | + </field> |
582 | + </record> |
583 | + <record id="action_account_invoice_generate_export_view" model="ir.actions.act_window"> |
584 | + <field name="name">Export accounting data to Sage50</field> |
585 | + <field name="type">ir.actions.act_window</field> |
586 | + <field name="res_model">exportsage</field> |
587 | + <field name="view_type">form</field> |
588 | + <field name="view_mode">form</field> |
589 | + <field name="target">new</field> |
590 | + </record> |
591 | + <menuitem action="action_account_invoice_generate_export_view" |
592 | + id="menu_account_invoice_generate_export_view" |
593 | + parent="account.menu_finance_legal_statement"/> |
594 | + </data> |
595 | +</openerp> |
596 | \ No newline at end of file |
Hi eh.dem,
l.157.158.161 - On the 7.0 it's better to use the keywords data and demo instead of init_xml, update_xml and demo_xml.
l.366.377 - osv.osv is deprecated. Use "from openerp.osv import fields, orm" and "class exportsage( orm.Model) ".