Merge lp:~savoirfairelinux-openerp/openerp-sage-50/7.0-exportsage50 into lp:openerp-sage-50

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
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

Description of the change

[UPG] Upgrade to version 7.0

To post a comment you must log in.
5. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP] Move files into module directory

Revision history for this message
Joao Alfredo Gama Batista (joao-gama) 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(orm.Model)".

review: Needs Fixing (code review, no test.)
Revision history for this message
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(orm.Model)".

Thanks Joao

6. By EL HADJI DEM <email address hidden>

code review

7. By EL HADJI DEM <email address hidden>

[IMP] add pot file, indent code, write the original author

8. By EL HADJI DEM <email address hidden>

[IMP] add author file

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve (code review)
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

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :
Download full text (5.4 KiB)

I would rename the module to export_sage50 or accounting_export_sage50

Code issues:
exportsage50/wizard/exportsage50.py:61:16: missing context=context
exportsage50/wizard/exportsage50.py:61:16: no checking if there are any results, can lead to index errors
exportsage50/wizard/exportsage50.py:61:17: no checking if there are any results, can lead to index errors
exportsage50/wizard/exportsage50.py:120:51: or "" has no effect due to use of str() (str(None) -> 'None')
exportsage50/wizard/exportsage50.py:134:37: the list generator here is pointless just use ','.join(fields_sale_invoice), it is also EXTREMELY hard to read your choice of variable names
exportsage50/wizard/exportsage50.py:140:27: search without context=context
exportsage50/wizard/exportsage50.py:143:32: browse without context=context
exportsage50/wizard/exportsage50.py:148:48: precision_get without context=context
exportsage50/wizard/exportsage50.py:167:63: the list generator here is pointless just use ','.join(fields_sale_invoice), it is also EXTREMELY hard to read your choice of variable names

Minor code / Style issues:
exportsage50/wizard/exportsage50.py:30:5: Content of docstring is pointless
exportsage50/wizard/exportsage50.py:35:5: Commented out code
exportsage50/wizard/exportsage50.py:44:46: Excessively long line, consider breaking at 120 chars.
exportsage50/wizard/exportsage50.py:44:48: Not sure what use lambda is here, you don't need it
exportsage50/wizard/exportsage50.py:51:5: Method can be static
exportsage50/wizard/exportsage50.py:52:5: Commented out code
exportsage50/wizard/exportsage50.py:55:5: Method can be static
exportsage50/wizard/exportsage50.py:55:5: *args
exportsage50/wizard/exportsage50.py:58:5: Monolithic function, consider breaking it down into multiple smaller functions
exportsage50/wizard/exportsage50.py:68:9: French comment
exportsage50/wizard/exportsage50.py:73:13: French comment
exportsage50/wizard/exportsage50.py:75:13: French comment
exportsage50/wizard/exportsage50.py:77:13: mix of CamelCase and underline_case, pick one and be consistent
exportsage50/wizard/exportsage50.py:89:13: French comment
exportsage50/wizard/exportsage50.py:90:13: Shadowing 'fields' from openerp.osv.fields
exportsage50/wizard/exportsage50.py:94:13: Commented out code
exportsage50/wizard/exportsage50.py:95:13: Commented out code
exportsage50/wizard/exportsage50.py:97:13: French comment
exportsage50/wizard/exportsage50.py:102:13: French comment
exportsage50/wizard/exportsage50.py:104:101: Comment could be more descriptive, as it is now, it is redundant to someone reading your code, I would also put it a line above instead of at the end of the line
exportsage50/wizard/exportsage50.py:107:13: French comment
exportsage50/wizard/exportsage50.py:109:13: French comment
exportsage50/wizard/exportsage50.py:111,114-116,119: You should be able to directly apply max() to line.payment_ids
exportsage50/wizard/exportsage50.py:116:17: mix of CamelCase and underline_case, pick one and be consistent
exportsage50/wizard/exportsage50.py:117:17: French comment
exportsage50/wizard/exportsage50.py:118:41: pool.get is an expensive function that always returns the same result, don't call it inside of a ...

Read more...

review: Needs Fixing (code review, no test)
11. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP] Improve code : comments from launchpad

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

This PR has been moved to https://github.com/OCA/connector-sage-50/pull/7

Please continue further development there.

review: Needs Resubmitting

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'exportsage50'
=== added file 'exportsage50/__init__.py'
--- exportsage50/__init__.py 1970-01-01 00:00:00 +0000
+++ exportsage50/__init__.py 2014-01-17 23:22:31 +0000
@@ -0,0 +1,24 @@
1# -*- encoding: utf-8 -*-
2###############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20###############################################################################
21
22from . import wizard
23
24# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
025
=== added file 'exportsage50/__init__.pyc'
1Binary files exportsage50/__init__.pyc 1970-01-01 00:00:00 +0000 and exportsage50/__init__.pyc 2014-01-17 23:22:31 +0000 differ26Binary files exportsage50/__init__.pyc 1970-01-01 00:00:00 +0000 and exportsage50/__init__.pyc 2014-01-17 23:22:31 +0000 differ
=== added file 'exportsage50/__openerp__.py'
--- exportsage50/__openerp__.py 1970-01-01 00:00:00 +0000
+++ exportsage50/__openerp__.py 2014-01-17 23:22:31 +0000
@@ -0,0 +1,121 @@
1# -*- encoding: utf-8 -*-
2###############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20###############################################################################
21
22{
23 'name': 'Export to Sage50',
24 'version': '1.0',
25 "category": 'Accounting & Finance',
26 'complexity': "easy",
27 'description': """
28
29Export accounting data from OpenERP to Sage50
30=============================================
31
32Export accounting data from OpenERP to Sage50. The export generates the imp file to import in Sage50.
33
34
35Documentation : layout of the import file (.IMP)
36------------------------------------------------
37
38A PDF document (in the /doc repository) gives more details about the .IMP file layout that can be imported
39into Sage 50. This document is part of the Sage 50 SDK (Software Development Kit) available for download at
40the following address : http://na.sage.com/sage-simply-accounting/lp/partners/sdk/?isnow=ssa.
41
42Sage 50: After creating .IMP file
43---------------------------------
44
45Solution:
46* Importing purchase invoices, purchase quotes, sales invoices and sales orders into Sage 50
47
48How to import purchase invoices, purchase quotes, sales invoices and sales orders?
49
50You can import purchase invoices, purchase quotes, sales invoices and sales orders into Sage 50.
51The transaction(s) details should be in a text file with extension .IMP.
52
53After you have created the .IMP file, you can import the transaction(s) into Sage 50 by following these steps:
54(Account information is not included in the .IMP format because when importing the file, you will receive
55a pop-up screen to ask you "Select an Account to match".)
56
57* From the Home Window, go to File, Import/Export
58* Click on Import Transactions (the Import Transactions Wizard appears)
59* Select on 'Import purchase invoices, purchase quotes, sales invoices, sales orders or time slips' and click Next
60* You can now create a backup of your file
61* Click Next
62* Click on Browse and select the .IMP file previously created
63* If the customer (or vendor) in the transaction(s) you are trying to import does not exist in the Sage 50 company,
64you will get a new window asking you if you want to add this customer (or vendor), or if you want to select
65another customer (or vendor) from the existing ones
66* You will also get a similar window if the import file uses an inventory item which does not exist in Sage 50.
67* You will see a summary of the imported transactions, click OK and then Finish.
68* If you got any errors importing the data, open the .IMP file in Notepad and use the attached .PDF document
69to verify the file format. Once the errors have been corrected, you can try the import again.
70
71Note: View KB25664 for information about some possible errors when importing .IMP file.
72
73Sage Business Care plan does NOT include support for SDK. Please, contact one of our partners website
74for further assistance.
75
76Possible errors when importing purchase invoices, purchase quotes, sales invoices and/or sales orders
77=====================================================================================================
78
79Questions and Answers
80
81Import started... Errors occurred while importing.
82Line x does not contain compatible tax information.
83Invalid date. The date must be between <date1> and <date2>.
84
85
86A: These are the possible reasons for getting any of these error messages when importing transactions
87into Simply Accounting:
88
89* The import file (extension .IMP) you are using does not have the proper format.
90 Refer to the KB article 25659 for more information about the format of the import file.
91
92* The transaction type is not enabled in the Simply Accounting company. To enable the feature, from the Home Window
93in Simply Accounting, go to Setup, Settings, Company, Features, make sure the type of transaction you want to import
94is checked
95
96* The dates in the import file do not match the fiscal year dates in Simply Accounting.
97 Open the import file in Notepad and make the necessary changes
98
99Contributors
100------------
101
102* El Hadji Dem <elhadji.dem@savoirfairelinux.com>
103* Maxime Chambreuil <maxime.chambreuil@savoirfairelinux.com>
104
105 """,
106 'author': 'Gestion-Ressources',
107 'website': 'http://www.gestion-ressources.com',
108 "license": "AGPL-3",
109 'images': [],
110 'depends': ['account'],
111 'data': [
112 'security/ir.model.access.csv',
113 'wizard/exportsage50_view.xml'
114 ],
115 'demo': [],
116 'test': [],
117 'installable': True,
118 'auto_install': False,
119 'application': True,
120}
121# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0122
=== added directory 'exportsage50/docs'
=== added file 'exportsage50/docs/Guide_Export_Sage_50_OpenERP_FR.pdf'
1Binary 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 differ123Binary 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
=== added file 'exportsage50/docs/dev-import.pdf'
2Binary 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 differ124Binary 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
=== added directory 'exportsage50/i18n'
=== added file 'exportsage50/i18n/exportsage50.pot'
--- exportsage50/i18n/exportsage50.pot 1970-01-01 00:00:00 +0000
+++ exportsage50/i18n/exportsage50.pot 2014-01-17 23:22:31 +0000
@@ -0,0 +1,140 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * exportsage50
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-11-15 16:22+0000\n"
10"PO-Revision-Date: 2013-11-15 16:22+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: exportsage50
19#: field:exportsage,name:0
20msgid "Filename"
21msgstr ""
22
23#. module: exportsage50
24#: field:exportsage,format:0
25msgid "File Format"
26msgstr ""
27
28#. module: exportsage50
29#: field:exportsage,state:0
30msgid "unknown"
31msgstr ""
32
33#. module: exportsage50
34#: view:exportsage:0
35msgid "Here is the exported file:"
36msgstr ""
37
38#. module: exportsage50
39#: model:ir.model,name:exportsage50.model_exportsage
40msgid "Create imp file to export in sage50"
41msgstr ""
42
43#. module: exportsage50
44#: selection:exportsage,state:0
45msgid "choose"
46msgstr ""
47
48#. module: exportsage50
49#: view:exportsage:0
50msgid "Unicode/UTF-8"
51msgstr ""
52
53#. module: exportsage50
54#: view:exportsage:0
55msgid "file encoding, please be sure to view and edit using the same encoding."
56msgstr ""
57
58#. module: exportsage50
59#: selection:exportsage,state:0
60msgid "get"
61msgstr ""
62
63#. module: exportsage50
64#: view:exportsage:0
65msgid "This file was generated using the universal"
66msgstr ""
67
68#. module: exportsage50
69#: view:exportsage:0
70msgid "Cancel"
71msgstr ""
72
73#. module: exportsage50
74#: code:addons/exportsage50/wizard/exportsage50.py:68
75#, python-format
76msgid "Error"
77msgstr ""
78
79#. module: exportsage50
80#: view:exportsage:0
81msgid "Export Complete"
82msgstr ""
83
84#. module: exportsage50
85#: view:exportsage:0
86msgid "Export Settings"
87msgstr ""
88
89#. module: exportsage50
90#: help:exportsage,invoice_ids:0
91msgid "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)."
92msgstr ""
93
94#. module: exportsage50
95#: model:ir.actions.act_window,name:exportsage50.action_account_invoice_generate_export_view
96#: model:ir.ui.menu,name:exportsage50.menu_account_invoice_generate_export_view
97msgid "Export accounting data to Sage50"
98msgstr ""
99
100#. module: exportsage50
101#: field:exportsage,invoice_ids:0
102msgid "Invoices"
103msgstr ""
104
105#. module: exportsage50
106#: view:exportsage:0
107msgid "or"
108msgstr ""
109
110#. module: exportsage50
111#: code:addons/exportsage50/wizard/exportsage50.py:68
112#, python-format
113msgid "You have to select at least 1 Invoice. And try again"
114msgstr ""
115
116#. module: exportsage50
117#: view:exportsage:0
118msgid "This action allows you to export accounting data from OpenErp to Simply account.You should have the same configuration about the tax information"
119msgstr ""
120
121#. module: exportsage50
122#: field:exportsage,data:0
123msgid "File"
124msgstr ""
125
126#. module: exportsage50
127#: view:exportsage:0
128msgid "Export to Sage50"
129msgstr ""
130
131#. module: exportsage50
132#: view:exportsage:0
133msgid "Close"
134msgstr ""
135
136#. module: exportsage50
137#: view:exportsage:0
138msgid "Export"
139msgstr ""
140
0141
=== added directory 'exportsage50/security'
=== added file 'exportsage50/security/ir.model.access.csv'
--- exportsage50/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ exportsage50/security/ir.model.access.csv 2014-01-17 23:22:31 +0000
@@ -0,0 +1,2 @@
1id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2access_exportsage,exportsage,model_exportsage,account.group_account_user,1,0,0,0
03
=== added directory 'exportsage50/static'
=== added directory 'exportsage50/static/src'
=== added directory 'exportsage50/static/src/img'
=== added file 'exportsage50/static/src/img/icon.png'
1Binary 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 differ4Binary 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
=== added directory 'exportsage50/wizard'
=== added file 'exportsage50/wizard/__init__.py'
--- exportsage50/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ exportsage50/wizard/__init__.py 2014-01-17 23:22:31 +0000
@@ -0,0 +1,22 @@
1# -*- encoding: utf-8 -*-
2###############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20###############################################################################
21from . import exportsage50
22# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
023
=== added file 'exportsage50/wizard/exportsage50.py'
--- exportsage50/wizard/exportsage50.py 1970-01-01 00:00:00 +0000
+++ exportsage50/wizard/exportsage50.py 2014-01-17 23:22:31 +0000
@@ -0,0 +1,189 @@
1# -*- encoding: utf-8 -*-
2###############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Gestion-Ressources (<http://www.gestion-ressources.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20###############################################################################
21
22from openerp.osv import fields, orm
23import base64
24from openerp.tools.translate import _
25import pooler
26from datetime import datetime
27import unicodedata
28
29
30class exportsage(orm.Model):
31 _name = "exportsage"
32 _description = "Create imp file to export in sage50"
33 _columns = {
34 'data': fields.binary('File', readonly=True),
35 'name': fields.char('Filename', 20, readonly=True),
36 'format': fields.char('File Format', 10),
37 'state': fields.selection([('choose', 'choose'),
38 ('get', 'get')]),
39 'invoice_ids': fields.many2many('account.invoice', 'sale_order_invoice_export_rel', 'order_id', 'invoice_id',
40 'Invoices', required=True,
41 help="This is the list of invoices that have been generated "
42 "for this sales order. The same sales order may have been invoiced "
43 "in several times (by line for example)."),
44 }
45
46 _defaults = {
47 'state': lambda *a: 'choose',
48 }
49
50 def act_cancel(self, cr, uid, ids, context=None):
51 return {'type': 'ir.actions.act_window_close'}
52
53 def act_destroy(self, *args):
54 return {'type': 'ir.actions.act_window_close'}
55
56 def create_report(self, cr, uid, ids, context=None):
57 if context is None:
58 context = {}
59 this = self.browse(cr, uid, ids, context=context)[0]
60 data = self.read(cr, uid, ids, [], context=context)[0]
61
62 if not data['invoice_ids']:
63 raise orm.except_orm(_('Error'), _('You have to select at least 1 Invoice. And try again'))
64
65 output = '<Version>''\n' + '"12001"' + ',' + '"1"''\n' + '</Version>\n\n'
66 # Do the treatment of other lines in the invoice lines
67 pool = pooler.get_pool(cr.dbname)
68 line_obj = pool.get('account.invoice')
69 account_move_line_obj = self.pool.get('account.move.line')
70 account_invoice_line_obj = self.pool.get('account.invoice.line')
71 decimal_precision_obj = self.pool.get('decimal.precision')
72
73 for line in line_obj.browse(cr, uid, data['invoice_ids'], context=context):
74 # start tag for invoice lines
75 output += '<SalInvoice>''\n'
76 #informations sur le client
77 costumer_name = line.partner_id.name
78 onetimefield = ""
79 contact_name = line.partner_id.name or ""
80 street1 = line.partner_id.street or ""
81 street2 = line.partner_id.street2 or ""
82 city = line.partner_id.city or ""
83 province_state = line.partner_id.state_id.name or ""
84 zip_code = line.partner_id.zip or ""
85 country = line.partner_id.country_id.name or ""
86 phone1 = line.partner_id.phone or ""
87 mobile = line.partner_id.mobile or ""
88 fax = line.partner_id.fax or ""
89 email = line.partner_id.email or ""
90 # Customer line
91 fields = [costumer_name, onetimefield, contact_name, street1, street2,
92 city, province_state, zip_code, country, phone1, mobile, fax, email
93 ]
94 costumer = ','.join(['"%s"' % field for field in fields])
95 output += costumer.encode('UTF-8') + '\n'
96 # Invoice informations
97 no_of_details = str(len(line.invoice_line))
98 order_no = ""
99 # Invoice number (Max 20 chars)
100 invoice_no = str(line.number)
101 # Get invoice date
102 entry_date = datetime.strptime(line.date_invoice, "%Y-%m-%d").strftime('%m-%d-%Y')\
103 if line.date_invoice else ""
104 # Type of payment (between 0 and 3)
105 # 0 = pay later , 1 = cash , 2 = cheque , 3 = credit card
106 # Select last payment
107 list_id = []
108 # Paid by source (20 Chars) : Blank- pay later and cash Cheque number or credit card
109 paid_by_source = ""
110 if line.payment_ids:
111 lastId = max(line.payment_ids).id
112 for oneId in line.payment_ids:
113 list_id.append(oneId.id)
114 lastId = max(list_id)
115 # access from the last payment account_move_line object
116 account_move_line = account_move_line_obj.browse(cr, uid, lastId, context=context)
117 paiement_type = account_move_line.journal_id.type
118 if paiement_type == 'cash':
119 paid_by_type = str(1)
120 paid_by_source = account_move_line.ref
121 elif paiement_type == 'bank':
122 paid_by_type = str(2)
123 else:
124 paid_by_type = str(0) # default value 0 = pay later
125 else:
126 paid_by_type = str(0) # default value 0 = pay later
127 total_amount = str(line.amount_total) or ""
128 freight_amount = "0.0"
129 fields_sale_invoice = [no_of_details, order_no, invoice_no, entry_date, paid_by_type,
130 paid_by_source, total_amount, freight_amount]
131 sale_invoice = ','.join(['"%s"' % one_field for one_field in fields_sale_invoice])
132 output += sale_invoice.encode('UTF-8') + '\n'
133 product_line_invoice_with_tax = ""
134 #Sale invoice detail lines
135 product_ids = account_invoice_line_obj.search(cr,
136 uid,
137 [('invoice_id', '=', line.id)],
138 context=context)
139
140 if product_ids:
141 for product in account_invoice_line_obj.browse(cr,
142 uid,
143 product_ids,
144 context=context):
145 item_number = unicode(product.name, "utf8", "replace") \
146 if isinstance(product.name, str) else unicodedata.normalize('NFD', product.name)
147 quantity = str(product.quantity)
148 price = str(product.price_unit)
149 amount = product.quantity * product.price_unit
150 amount = str(round(amount, decimal_precision_obj.precision_get(cr, uid, 'Account')))
151 fields_one_product_invoice = [item_number, quantity, price, amount]
152 one_product_invoice = ','.join(['"%s"' % field_one_product_invoice
153 for field_one_product_invoice in fields_one_product_invoice])
154 one_product_invoice = one_product_invoice.encode('UTF-8')
155 tax_product_line = ""
156 # Tax information for each product
157 if product.invoice_line_tax_id:
158 for one_tax in product.invoice_line_tax_id:
159 tax_name = one_tax.description # or one_tax.description or one_tax.name
160 # 1=yes, 0=No
161 tax_included = str(1) if one_tax.price_include else str(0)
162 tax_refundable = str(1) # 1=yes, 0=No
163 tax_rate = str(one_tax.amount)
164 tax_amount = str(one_tax.amount)
165 fields_tax_product_line = [tax_name, tax_included, tax_refundable, tax_rate, tax_amount, ]
166 tax_product_line = ',' + ','.join(['"%s"' % one_tax_field
167 for one_tax_field in fields_tax_product_line])
168 tax_product_line = tax_product_line.encode('UTF-8')
169 product_line_invoice_with_tax += one_product_invoice + tax_product_line + '\n'
170 output += product_line_invoice_with_tax
171 # End of invoice lines
172 output += '</SalInvoice>\n\n\n'
173 this.format = 'imp'
174 filename = 'export_to_sage50'
175 this.name = "%s.%s" % (filename, this.format)
176 out = base64.encodestring(output)
177 self.write(cr, uid, ids, {'state': 'get', 'data': out, 'name': this.name,
178 'format': this.format}, context=context)
179
180 return {
181 'type': 'ir.actions.act_window',
182 'res_model': 'exportsage',
183 'view_mode': 'form',
184 'view_type': 'form',
185 'res_id': this.id,
186 'views': [(False, 'form')],
187 'target': 'new',
188 }
189# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0190
=== added file 'exportsage50/wizard/exportsage50_view.xml'
--- exportsage50/wizard/exportsage50_view.xml 1970-01-01 00:00:00 +0000
+++ exportsage50/wizard/exportsage50_view.xml 2014-01-17 23:22:31 +0000
@@ -0,0 +1,47 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="account_invoice_generate_export_view" model="ir.ui.view">
5 <field name="name">Export to Sage50</field>
6 <field name="model">exportsage</field>
7 <field name="arch" type="xml">
8 <form string="Export to Sage50" version="7.0">
9 <field invisible="1" name="state"/>
10 <field invisible="1" name="format"/>
11 <label string="This action allows you to export accounting data from OpenErp
12 to Simply account.You should have the same configuration about the tax information"/>
13 <group states="choose" string="Export Settings">
14 <field name="invoice_ids" colspan="4" nolabel="1"/>
15 </group>
16 <div states="get">
17 <h2>Export Complete</h2>
18 <p>Here is the exported file: <field name="data" readonly="1" filename="name"/></p>
19 <p>This file was generated using the universal
20 <strong>Unicode/UTF-8</strong>
21 file encoding, please be sure to view and edit using the same encoding.
22 </p>
23 </div>
24 <footer states="choose">
25 <button name="create_report" string="Export" type="object" class="oe_highlight"/>
26 or
27 <button special="cancel" string="Cancel" type="object" class="oe_link"/>
28 </footer>
29 <footer states="get">
30 <button special="cancel" string="Close" type="object"/>
31 </footer>
32 </form>
33 </field>
34 </record>
35 <record id="action_account_invoice_generate_export_view" model="ir.actions.act_window">
36 <field name="name">Export accounting data to Sage50</field>
37 <field name="type">ir.actions.act_window</field>
38 <field name="res_model">exportsage</field>
39 <field name="view_type">form</field>
40 <field name="view_mode">form</field>
41 <field name="target">new</field>
42 </record>
43 <menuitem action="action_account_invoice_generate_export_view"
44 id="menu_account_invoice_generate_export_view"
45 parent="account.menu_finance_legal_statement"/>
46 </data>
47</openerp>
0\ No newline at end of file48\ No newline at end of file

Subscribers

People subscribed via source and target branches