Merge lp:~extra-addons-commiter/e-commerce-addons/trunk into lp:~extra-addons-commiter/e-commerce-addons/7.0
- trunk
- Merge into 7.0
Proposed by
Sébastien BEAU - http://www.akretion.com
Status: | Merged |
---|---|
Merged at revision: | 280 |
Proposed branch: | lp:~extra-addons-commiter/e-commerce-addons/trunk |
Merge into: | lp:~extra-addons-commiter/e-commerce-addons/7.0 |
Diff against target: |
1108 lines (+424/-248) 33 files modified
base_sale_export_partner/__openerp__.py (+1/-1) base_sale_export_product/__openerp__.py (+1/-1) base_sale_multichannels/__openerp__.py (+1/-1) base_sale_multichannels/connector.py (+37/-0) base_sale_multichannels/partner.py (+1/-0) base_sale_multichannels/sale.py (+3/-1) base_sale_report_synchronizer/__openerp__.py (+1/-1) product_custom_attributes_shop/__openerp__.py (+1/-1) product_images_sync/__openerp__.py (+1/-1) product_links/__openerp__.py (+1/-1) product_links_goodies/__openerp__.py (+1/-1) product_links_sync/__openerp__.py (+1/-1) sale_automatic_workflow/__init__.py (+2/-1) sale_automatic_workflow/__openerp__.py (+6/-2) sale_automatic_workflow/automatic_workflow_job.py (+1/-1) sale_automatic_workflow/invoice.py (+112/-0) sale_automatic_workflow/sale.py (+1/-75) sale_automatic_workflow/stock.py (+65/-0) sale_exceptions/__openerp__.py (+1/-1) sale_exceptions/sale.py (+4/-4) sale_exceptions/sale_view.xml (+6/-33) sale_exceptions/wizard/sale_exception_confirm_view.xml (+17/-18) sale_quick_payment/__init__.py (+1/-3) sale_quick_payment/__openerp__.py (+5/-5) sale_quick_payment/account_voucher.py (+33/-0) sale_quick_payment/company.py (+0/-33) sale_quick_payment/company_view.xml (+0/-25) sale_quick_payment/migrations/0.1/post-migration.py (+35/-0) sale_quick_payment/sale.py (+31/-11) sale_quick_payment/sale_view.xml (+10/-2) sale_quick_payment/settings/sale.exception.csv (+3/-0) sale_quick_payment/wizard/pay_sale_order.py (+29/-9) sale_quick_payment/wizard/pay_sale_order.xml (+12/-15) |
To merge this branch: | bzr merge lp:~extra-addons-commiter/e-commerce-addons/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Approve | ||
Review via email: mp+142952@code.launchpad.net |
Commit message
Description of the change
this was the previous trunk branch and as some module have been ported we should merge it in stable
To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'base_sale_export_partner/__openerp__.py' | |||
2 | --- base_sale_export_partner/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
3 | +++ base_sale_export_partner/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
4 | @@ -36,6 +36,6 @@ | |||
5 | 36 | 'wizard/export_partner.xml', | 36 | 'wizard/export_partner.xml', |
6 | 37 | ], | 37 | ], |
7 | 38 | 'demo_xml': [], | 38 | 'demo_xml': [], |
9 | 39 | 'installable': True, | 39 | 'installable': False, |
10 | 40 | 'active': False, | 40 | 'active': False, |
11 | 41 | } | 41 | } |
12 | 42 | 42 | ||
13 | === modified file 'base_sale_export_product/__openerp__.py' | |||
14 | --- base_sale_export_product/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
15 | +++ base_sale_export_product/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
16 | @@ -36,6 +36,6 @@ | |||
17 | 36 | 'wizard/export_product.xml', | 36 | 'wizard/export_product.xml', |
18 | 37 | ], | 37 | ], |
19 | 38 | 'demo_xml': [], | 38 | 'demo_xml': [], |
21 | 39 | 'installable': True, | 39 | 'installable': False, |
22 | 40 | 'active': False, | 40 | 'active': False, |
23 | 41 | } | 41 | } |
24 | 42 | 42 | ||
25 | === modified file 'base_sale_multichannels/__openerp__.py' | |||
26 | --- base_sale_multichannels/__openerp__.py 2012-11-30 12:02:42 +0000 | |||
27 | +++ base_sale_multichannels/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
28 | @@ -72,7 +72,7 @@ | |||
29 | 72 | 'account_view.xml', | 72 | 'account_view.xml', |
30 | 73 | ], | 73 | ], |
31 | 74 | 'demo_xml': [], | 74 | 'demo_xml': [], |
33 | 75 | 'installable': True, | 75 | 'installable': False, |
34 | 76 | 'certificate': '', | 76 | 'certificate': '', |
35 | 77 | } | 77 | } |
36 | 78 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 78 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
37 | 79 | 79 | ||
38 | === added file 'base_sale_multichannels/connector.py' | |||
39 | --- base_sale_multichannels/connector.py 1970-01-01 00:00:00 +0000 | |||
40 | +++ base_sale_multichannels/connector.py 2013-01-11 17:08:20 +0000 | |||
41 | @@ -0,0 +1,37 @@ | |||
42 | 1 | # -*- encoding: utf-8 -*- | ||
43 | 2 | ############################################################################### | ||
44 | 3 | # # | ||
45 | 4 | # product_custom_attributes for OpenERP # | ||
46 | 5 | # Copyright (C) 2012 Camptocamp Alexandre Fayolle <alexandre.fayolle@camptocamp.com> # | ||
47 | 6 | # Copyright (C) 2012 Akretion Sebastien Beau <sebastien.beau@akretion.com> # | ||
48 | 7 | # # | ||
49 | 8 | # This program is free software: you can redistribute it and/or modify # | ||
50 | 9 | # it under the terms of the GNU Affero General Public License as # | ||
51 | 10 | # published by the Free Software Foundation, either version 3 of the # | ||
52 | 11 | # License, or (at your option) any later version. # | ||
53 | 12 | # # | ||
54 | 13 | # This program is distributed in the hope that it will be useful, # | ||
55 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
56 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
57 | 16 | # GNU Affero General Public License for more details. # | ||
58 | 17 | # # | ||
59 | 18 | # You should have received a copy of the GNU Affero General Public License # | ||
60 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | ||
61 | 20 | # # | ||
62 | 21 | ############################################################################### | ||
63 | 22 | |||
64 | 23 | from base_external_referentials.connector import AbstractConnector | ||
65 | 24 | |||
66 | 25 | class BaseConnector(AbstractConnector): | ||
67 | 26 | def _get_import_defaults_res_partner(self, cr, uid, context=None): | ||
68 | 27 | pass | ||
69 | 28 | def _get_import_defaults_res_partner(self, cr, uid, context=None): | ||
70 | 29 | pass | ||
71 | 30 | def _get_import_defaults_external_shop_group(self, cr, uid, context=None): | ||
72 | 31 | pass | ||
73 | 32 | |||
74 | 33 | def _get_import_defaults_sale_order(self, cr, uid, context=None): | ||
75 | 34 | pass | ||
76 | 35 | |||
77 | 36 | def _record_one_sale_order(self, cr, uid, res_obj, resource, defaults, context): | ||
78 | 37 | pass | ||
79 | 0 | 38 | ||
80 | === modified file 'base_sale_multichannels/partner.py' | |||
81 | --- base_sale_multichannels/partner.py 2012-10-24 20:17:59 +0000 | |||
82 | +++ base_sale_multichannels/partner.py 2013-01-11 17:08:20 +0000 | |||
83 | @@ -32,6 +32,7 @@ | |||
84 | 32 | 'shop_ids': fields.many2many('sale.shop', 'sale_shop_res_partner_rel', 'shop_id', 'partner_id', 'Present in Shops', readonly=True, help="List of shops in which this customer exists."), | 32 | 'shop_ids': fields.many2many('sale.shop', 'sale_shop_res_partner_rel', 'shop_id', 'partner_id', 'Present in Shops', readonly=True, help="List of shops in which this customer exists."), |
85 | 33 | } | 33 | } |
86 | 34 | 34 | ||
87 | 35 | # xxx move to BaseConnector _get_import_defaults_res_partner | ||
88 | 35 | def _get_default_import_values(self, cr, uid, external_session, mapping_id=None, defaults=None, context=None): | 36 | def _get_default_import_values(self, cr, uid, external_session, mapping_id=None, defaults=None, context=None): |
89 | 36 | if external_session.sync_from_object._name == 'sale.shop': | 37 | if external_session.sync_from_object._name == 'sale.shop': |
90 | 37 | shop = external_session.sync_from_object | 38 | shop = external_session.sync_from_object |
91 | 38 | 39 | ||
92 | === modified file 'base_sale_multichannels/sale.py' | |||
93 | --- base_sale_multichannels/sale.py 2013-01-03 10:08:13 +0000 | |||
94 | +++ base_sale_multichannels/sale.py 2013-01-11 17:08:20 +0000 | |||
95 | @@ -63,7 +63,7 @@ | |||
96 | 63 | 'shop_ids': fields.one2many('sale.shop', 'shop_group_id', 'Sale Shops'), | 63 | 'shop_ids': fields.one2many('sale.shop', 'shop_group_id', 'Sale Shops'), |
97 | 64 | } | 64 | } |
98 | 65 | 65 | ||
100 | 66 | 66 | # xxx move to BaseConnector _get_import_defaults_external_shop_group | |
101 | 67 | def _get_default_import_values(self, cr, uid, external_session, **kwargs): | 67 | def _get_default_import_values(self, cr, uid, external_session, **kwargs): |
102 | 68 | return {'referential_id' : external_session.referential_id.id} | 68 | return {'referential_id' : external_session.referential_id.id} |
103 | 69 | 69 | ||
104 | @@ -539,6 +539,7 @@ | |||
105 | 539 | vals['update_state_date'] = datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT) | 539 | vals['update_state_date'] = datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT) |
106 | 540 | return super(sale_order, self).write(cr, uid, ids, vals, context=context) | 540 | return super(sale_order, self).write(cr, uid, ids, vals, context=context) |
107 | 541 | 541 | ||
108 | 542 | # xxx move to BaseConnector _get_import_defaults_sale_order | ||
109 | 542 | def _get_default_import_values(self, cr, uid, external_session, mapping_id=None, defaults=None, context=None): | 543 | def _get_default_import_values(self, cr, uid, external_session, mapping_id=None, defaults=None, context=None): |
110 | 543 | shop = False | 544 | shop = False |
111 | 544 | if external_session.sync_from_object._name == 'sale.shop': | 545 | if external_session.sync_from_object._name == 'sale.shop': |
112 | @@ -597,6 +598,7 @@ | |||
113 | 597 | 598 | ||
114 | 598 | return False | 599 | return False |
115 | 599 | 600 | ||
116 | 601 | # xxx a deplacer dans BaseConnector sale_order | ||
117 | 600 | @catch_error_in_report | 602 | @catch_error_in_report |
118 | 601 | def _record_one_external_resource(self, cr, uid, external_session, resource, defaults=None, | 603 | def _record_one_external_resource(self, cr, uid, external_session, resource, defaults=None, |
119 | 602 | mapping=None, mapping_id=None, context=None): | 604 | mapping=None, mapping_id=None, context=None): |
120 | 603 | 605 | ||
121 | === modified file 'base_sale_report_synchronizer/__openerp__.py' | |||
122 | --- base_sale_report_synchronizer/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
123 | +++ base_sale_report_synchronizer/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
124 | @@ -41,7 +41,7 @@ | |||
125 | 41 | 'sale_view.xml', | 41 | 'sale_view.xml', |
126 | 42 | ], | 42 | ], |
127 | 43 | 'demo_xml': [], | 43 | 'demo_xml': [], |
129 | 44 | 'installable': True, | 44 | 'installable': False, |
130 | 45 | 'active': False, | 45 | 'active': False, |
131 | 46 | } | 46 | } |
132 | 47 | 47 | ||
133 | 48 | 48 | ||
134 | === modified file 'product_custom_attributes_shop/__openerp__.py' | |||
135 | --- product_custom_attributes_shop/__openerp__.py 2012-12-07 12:44:57 +0000 | |||
136 | +++ product_custom_attributes_shop/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
137 | @@ -46,7 +46,7 @@ | |||
138 | 46 | 'security/ir.model.access.csv', | 46 | 'security/ir.model.access.csv', |
139 | 47 | ], | 47 | ], |
140 | 48 | 'demo_xml': [], | 48 | 'demo_xml': [], |
142 | 49 | 'installable': True, | 49 | 'installable': False, |
143 | 50 | 'active': False, | 50 | 'active': False, |
144 | 51 | } | 51 | } |
145 | 52 | 52 | ||
146 | 53 | 53 | ||
147 | === modified file 'product_images_sync/__openerp__.py' | |||
148 | --- product_images_sync/__openerp__.py 2012-12-07 12:44:57 +0000 | |||
149 | +++ product_images_sync/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
150 | @@ -42,6 +42,6 @@ | |||
151 | 42 | 'update_xml': [ | 42 | 'update_xml': [ |
152 | 43 | ], | 43 | ], |
153 | 44 | 'demo_xml': [], | 44 | 'demo_xml': [], |
155 | 45 | 'installable': True, | 45 | 'installable': False, |
156 | 46 | 'active': False, | 46 | 'active': False, |
157 | 47 | } | 47 | } |
158 | 48 | 48 | ||
159 | === modified file 'product_links/__openerp__.py' | |||
160 | --- product_links/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
161 | +++ product_links/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
162 | @@ -40,6 +40,6 @@ | |||
163 | 40 | 'product_links_view.xml', | 40 | 'product_links_view.xml', |
164 | 41 | ], | 41 | ], |
165 | 42 | 'demo_xml': [], | 42 | 'demo_xml': [], |
167 | 43 | 'installable': True, | 43 | 'installable': False, |
168 | 44 | 'active': False, | 44 | 'active': False, |
169 | 45 | } | 45 | } |
170 | 46 | 46 | ||
171 | === modified file 'product_links_goodies/__openerp__.py' | |||
172 | --- product_links_goodies/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
173 | +++ product_links_goodies/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
174 | @@ -38,7 +38,7 @@ | |||
175 | 38 | 'product_goodies_data.xml', | 38 | 'product_goodies_data.xml', |
176 | 39 | ], | 39 | ], |
177 | 40 | 'demo_xml': [], | 40 | 'demo_xml': [], |
179 | 41 | 'installable': True, | 41 | 'installable': False, |
180 | 42 | 'active': False, | 42 | 'active': False, |
181 | 43 | } | 43 | } |
182 | 44 | 44 | ||
183 | 45 | 45 | ||
184 | === modified file 'product_links_sync/__openerp__.py' | |||
185 | --- product_links_sync/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
186 | +++ product_links_sync/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
187 | @@ -38,7 +38,7 @@ | |||
188 | 38 | 'sale_view.xml', | 38 | 'sale_view.xml', |
189 | 39 | ], | 39 | ], |
190 | 40 | 'demo_xml': [], | 40 | 'demo_xml': [], |
192 | 41 | 'installable': True, | 41 | 'installable': False, |
193 | 42 | 'active': False, | 42 | 'active': False, |
194 | 43 | } | 43 | } |
195 | 44 | 44 | ||
196 | 45 | 45 | ||
197 | === modified file 'sale_automatic_workflow/__init__.py' | |||
198 | --- sale_automatic_workflow/__init__.py 2012-04-22 12:49:21 +0000 | |||
199 | +++ sale_automatic_workflow/__init__.py 2013-01-11 17:08:20 +0000 | |||
200 | @@ -24,7 +24,8 @@ | |||
201 | 24 | import sale_workflow_process | 24 | import sale_workflow_process |
202 | 25 | import payment_method | 25 | import payment_method |
203 | 26 | import automatic_workflow_job | 26 | import automatic_workflow_job |
205 | 27 | 27 | import invoice | |
206 | 28 | import stock | ||
207 | 28 | 29 | ||
208 | 29 | 30 | ||
209 | 30 | 31 | ||
210 | 31 | 32 | ||
211 | === modified file 'sale_automatic_workflow/__openerp__.py' | |||
212 | --- sale_automatic_workflow/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
213 | +++ sale_automatic_workflow/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
214 | @@ -22,13 +22,17 @@ | |||
215 | 22 | 22 | ||
216 | 23 | { | 23 | { |
217 | 24 | 'name': 'sale_automatic_workflow', | 24 | 'name': 'sale_automatic_workflow', |
219 | 25 | 'version': '6.1.1', | 25 | 'version': '0.1', |
220 | 26 | 'category': 'Generic Modules/Others', | 26 | 'category': 'Generic Modules/Others', |
221 | 27 | 'license': 'AGPL-3', | 27 | 'license': 'AGPL-3', |
222 | 28 | 'description': """empty""", | 28 | 'description': """empty""", |
223 | 29 | 'author': 'Akretion', | 29 | 'author': 'Akretion', |
224 | 30 | 'website': 'http://www.akretion.com/', | 30 | 'website': 'http://www.akretion.com/', |
226 | 31 | 'depends': ['sale_quick_payment', 'framework_helpers'], | 31 | 'depends': [ |
227 | 32 | 'sale_quick_payment', | ||
228 | 33 | 'framework_helpers', | ||
229 | 34 | 'stock', | ||
230 | 35 | ], | ||
231 | 32 | 'init_xml': [], | 36 | 'init_xml': [], |
232 | 33 | 'update_xml': [ | 37 | 'update_xml': [ |
233 | 34 | 'sale_view.xml', | 38 | 'sale_view.xml', |
234 | 35 | 39 | ||
235 | === modified file 'sale_automatic_workflow/automatic_workflow_job.py' | |||
236 | --- sale_automatic_workflow/automatic_workflow_job.py 2012-11-21 12:46:53 +0000 | |||
237 | +++ sale_automatic_workflow/automatic_workflow_job.py 2013-01-11 17:08:20 +0000 | |||
238 | @@ -72,7 +72,7 @@ | |||
239 | 72 | with commit_now(cr, logger) as cr: | 72 | with commit_now(cr, logger) as cr: |
240 | 73 | invoice_obj.reconcile_invoice(cr, uid, [invoice_id], context=context) | 73 | invoice_obj.reconcile_invoice(cr, uid, [invoice_id], context=context) |
241 | 74 | 74 | ||
243 | 75 | picking_obj = self.pool.get('stock.picking') | 75 | picking_obj = self.pool.get('stock.picking.out') |
244 | 76 | picking_ids = picking_obj.search(cr, uid, [('state', 'in', ['draft', 'confirmed', 'assigned']), ('workflow_process_id.validate_picking', '=',True)], context=context) | 76 | picking_ids = picking_obj.search(cr, uid, [('state', 'in', ['draft', 'confirmed', 'assigned']), ('workflow_process_id.validate_picking', '=',True)], context=context) |
245 | 77 | if picking_ids: | 77 | if picking_ids: |
246 | 78 | logger.debug(_('start to validate pickings : %s') %picking_ids) | 78 | logger.debug(_('start to validate pickings : %s') %picking_ids) |
247 | 79 | 79 | ||
248 | === added file 'sale_automatic_workflow/invoice.py' | |||
249 | --- sale_automatic_workflow/invoice.py 1970-01-01 00:00:00 +0000 | |||
250 | +++ sale_automatic_workflow/invoice.py 2013-01-11 17:08:20 +0000 | |||
251 | @@ -0,0 +1,112 @@ | |||
252 | 1 | # -*- coding: utf-8 -*- | ||
253 | 2 | ############################################################################### | ||
254 | 3 | # | ||
255 | 4 | # sale_automatic_workflow for OpenERP | ||
256 | 5 | # Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>. | ||
257 | 6 | # All Rights Reserved | ||
258 | 7 | # @author Sébastien BEAU <sebastien.beau@akretion.com> | ||
259 | 8 | # This program is free software: you can redistribute it and/or modify | ||
260 | 9 | # it under the terms of the GNU Affero General Public License as | ||
261 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
262 | 11 | # License, or (at your option) any later version. | ||
263 | 12 | # | ||
264 | 13 | # This program is distributed in the hope that it will be useful, | ||
265 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
266 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
267 | 16 | # GNU Affero General Public License for more details. | ||
268 | 17 | # | ||
269 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
270 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
271 | 20 | # | ||
272 | 21 | ############################################################################### | ||
273 | 22 | from openerp.osv.orm import Model | ||
274 | 23 | from openerp.osv import fields | ||
275 | 24 | |||
276 | 25 | class account_invoice(Model): | ||
277 | 26 | _inherit = "account.invoice" | ||
278 | 27 | _columns = { | ||
279 | 28 | 'workflow_process_id':fields.many2one('sale.workflow.process', 'Sale Workflow Process'), | ||
280 | 29 | #TODO propose a merge to add this field by default in acount module | ||
281 | 30 | 'sale_ids': fields.many2many('sale.order', 'sale_order_invoice_rel', 'invoice_id', 'order_id', 'Sale Orders') | ||
282 | 31 | } | ||
283 | 32 | |||
284 | 33 | def _can_be_reconciled(self, cr, uid, invoice, context=None): | ||
285 | 34 | if not (invoice.sale_ids and invoice.sale_ids[0].payment_ids and invoice.move_id): | ||
286 | 35 | return False | ||
287 | 36 | #Check currency | ||
288 | 37 | for payment in invoice.sale_ids[0].payment_ids: | ||
289 | 38 | for move in payment.move_ids: | ||
290 | 39 | if (move.currency_id.id or invoice.company_id.currency_id.id) != invoice.currency_id.id: | ||
291 | 40 | return False | ||
292 | 41 | return True | ||
293 | 42 | |||
294 | 43 | def _get_sum_invoice_move_line(self, cr, uid, move_lines, context=None): | ||
295 | 44 | return self._get_sum_move_line(cr, uid, move_lines, 'debit', context=None) | ||
296 | 45 | |||
297 | 46 | def _get_sum_payment_move_line(self, cr, uid, move_lines, context=None): | ||
298 | 47 | return self._get_sum_move_line(cr, uid, move_lines, 'credit', context=None) | ||
299 | 48 | |||
300 | 49 | def _get_sum_move_line(self, cr, uid, move_lines, line_type, context=None): | ||
301 | 50 | res = { | ||
302 | 51 | 'max_date': False, | ||
303 | 52 | 'line_ids': [], | ||
304 | 53 | 'total_amount': 0, | ||
305 | 54 | 'total_amount_currency': 0, | ||
306 | 55 | } | ||
307 | 56 | for move_line in move_lines: | ||
308 | 57 | if move_line[line_type] > 0: | ||
309 | 58 | if move_line.date > res['max_date']: | ||
310 | 59 | res['max_date'] = move_line.date | ||
311 | 60 | res['line_ids'].append(move_line.id) | ||
312 | 61 | res['total_amount'] += move_line[line_type] | ||
313 | 62 | res['total_amount_currency'] += move_line.amount_currency | ||
314 | 63 | return res | ||
315 | 64 | |||
316 | 65 | def _prepare_write_off(self, cr, uid, invoice, res_invoice, res_payment, context=None): | ||
317 | 66 | if not context: | ||
318 | 67 | context = {} | ||
319 | 68 | ctx = context.copy() | ||
320 | 69 | if res_invoice['total_amount'] - res_payment['total_amount'] > 0: | ||
321 | 70 | writeoff_type = 'expense' | ||
322 | 71 | else: | ||
323 | 72 | writeoff_type = 'income' | ||
324 | 73 | account_id, journal_id = invoice.company_id.\ | ||
325 | 74 | get_write_off_information('exchange', writeoff_type, context=context) | ||
326 | 75 | max_date = max(res_invoice['max_date'], res_payment['max_date']) | ||
327 | 76 | ctx['p_date'] = max_date | ||
328 | 77 | period_id = self.pool.get('account.period').find(cr, uid, max_date, context=context)[0] | ||
329 | 78 | return { | ||
330 | 79 | 'type': 'auto', | ||
331 | 80 | 'writeoff_acc_id': account_id, | ||
332 | 81 | 'writeoff_period_id': period_id, | ||
333 | 82 | 'writeoff_journal_id': journal_id, | ||
334 | 83 | 'context': ctx, | ||
335 | 84 | } | ||
336 | 85 | |||
337 | 86 | def reconcile_invoice(self, cr, uid, ids, context=None): | ||
338 | 87 | """ | ||
339 | 88 | Simple method to reconcile the invoice with the payment generated on the sale order | ||
340 | 89 | """ | ||
341 | 90 | if not context: | ||
342 | 91 | context={} | ||
343 | 92 | precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') | ||
344 | 93 | obj_move_line = self.pool.get('account.move.line') | ||
345 | 94 | for invoice in self.browse(cr, uid, ids, context=context): | ||
346 | 95 | use_currency = invoice.currency_id.id != invoice.company_id.currency_id.id | ||
347 | 96 | if self._can_be_reconciled(cr, uid, invoice, context=context): | ||
348 | 97 | payment_move_line = [] | ||
349 | 98 | for payment in invoice.sale_ids[0].payment_ids: | ||
350 | 99 | payment_move_line += payment.move_ids | ||
351 | 100 | res_payment = self._get_sum_payment_move_line(cr, uid, payment_move_line, context=context) | ||
352 | 101 | res_invoice = self._get_sum_invoice_move_line(cr, uid, invoice.move_id.line_id, context=context) | ||
353 | 102 | line_ids = res_invoice['line_ids'] + res_payment['line_ids'] | ||
354 | 103 | if not use_currency: | ||
355 | 104 | balance = abs(res_invoice['total_amount']-res_payment['total_amount']) | ||
356 | 105 | if line_ids and not round(balance, precision): | ||
357 | 106 | obj_move_line.reconcile(cr, uid, line_ids, context=context) | ||
358 | 107 | else: | ||
359 | 108 | balance = abs(res_invoice['total_amount_currency']-res_payment['total_amount_currency']) | ||
360 | 109 | if line_ids and not round(balance, precision): | ||
361 | 110 | kwargs = self._prepare_write_off(cr, uid, invoice, res_invoice, res_payment, context=context) | ||
362 | 111 | obj_move_line.reconcile(cr, uid, line_ids, **kwargs) | ||
363 | 112 | return True | ||
364 | 0 | 113 | ||
365 | === modified file 'sale_automatic_workflow/sale.py' | |||
366 | --- sale_automatic_workflow/sale.py 2012-09-19 13:24:46 +0000 | |||
367 | +++ sale_automatic_workflow/sale.py 2013-01-11 17:08:20 +0000 | |||
368 | @@ -1,4 +1,4 @@ | |||
370 | 1 | # -*- encoding: utf-8 -*- | 1 | # -*- encoding: utf-8 -*- |
371 | 2 | ################################################################################# | 2 | ################################################################################# |
372 | 3 | # # | 3 | # # |
373 | 4 | # sale_automatic_workflow for OpenERP # | 4 | # sale_automatic_workflow for OpenERP # |
374 | @@ -39,77 +39,3 @@ | |||
375 | 39 | picking_vals = super(sale_order, self)._prepare_order_picking(cr, uid, order, context=context) | 39 | picking_vals = super(sale_order, self)._prepare_order_picking(cr, uid, order, context=context) |
376 | 40 | picking_vals['workflow_process_id'] = order.workflow_process_id.id | 40 | picking_vals['workflow_process_id'] = order.workflow_process_id.id |
377 | 41 | return picking_vals | 41 | return picking_vals |
378 | 42 | |||
379 | 43 | class stock_picking(Model): | ||
380 | 44 | _inherit = "stock.picking" | ||
381 | 45 | _columns = { | ||
382 | 46 | 'workflow_process_id':fields.many2one('sale.workflow.process', 'Sale Workflow Process'), | ||
383 | 47 | } | ||
384 | 48 | |||
385 | 49 | def _prepare_invoice(self, cr, uid, picking, partner, inv_type, journal_id, context=None): | ||
386 | 50 | invoice_vals = super(stock_picking, self)._prepare_invoice(cr, uid, picking, partner, \ | ||
387 | 51 | inv_type, journal_id, context=context) | ||
388 | 52 | invoice_vals['workflow_process_id'] = picking.workflow_process_id.id | ||
389 | 53 | if picking.workflow_process_id.invoice_date_is_order_date: | ||
390 | 54 | invoice_vals['date_invoice'] = picking.sale_id.date_order | ||
391 | 55 | return invoice_vals | ||
392 | 56 | |||
393 | 57 | def validate_picking(self, cr, uid, ids, context=None): | ||
394 | 58 | for picking in self.browse(cr, uid, ids, context=context): | ||
395 | 59 | self.force_assign(cr, uid, [picking.id]) | ||
396 | 60 | partial_data = {} | ||
397 | 61 | for move in picking.move_lines: | ||
398 | 62 | partial_data["move" + str(move.id)] = {'product_qty': move.product_qty, | ||
399 | 63 | 'product_uom': move.product_uom.id} | ||
400 | 64 | self.do_partial(cr, uid, [picking.id], partial_data) | ||
401 | 65 | return True | ||
402 | 66 | |||
403 | 67 | #TODO reimplement me | ||
404 | 68 | # def validate_manufactoring_order(self, cr, uid, origin, context=None): #we do not create class mrp.production to avoid dependence with the module mrp | ||
405 | 69 | # if context is None: | ||
406 | 70 | # context = {} | ||
407 | 71 | # wf_service = netsvc.LocalService("workflow") | ||
408 | 72 | # mrp_prod_obj = self.pool.get('mrp.production') | ||
409 | 73 | # mrp_product_produce_obj = self.pool.get('mrp.product.produce') | ||
410 | 74 | # production_ids = mrp_prod_obj.search(cr, uid, [('origin', 'ilike', origin)]) | ||
411 | 75 | # for production in mrp_prod_obj.browse(cr, uid, production_ids): | ||
412 | 76 | # mrp_prod_obj.force_production(cr, uid, [production.id]) | ||
413 | 77 | # wf_service.trg_validate(uid, 'mrp.production', production.id, 'button_produce', cr) | ||
414 | 78 | # context.update({'active_model': 'mrp.production', 'active_ids': [production.id], 'search_default_ready': 1, 'active_id': production.id}) | ||
415 | 79 | # produce = mrp_product_produce_obj.create(cr, uid, {'mode': 'consume_produce', 'product_qty': production.product_qty}, context) | ||
416 | 80 | # mrp_product_produce_obj.do_produce(cr, uid, [produce], context) | ||
417 | 81 | # self.validate_manufactoring_order(cr, uid, production.name, context) | ||
418 | 82 | # return True | ||
419 | 83 | # | ||
420 | 84 | |||
421 | 85 | class account_invoice(Model): | ||
422 | 86 | _inherit = "account.invoice" | ||
423 | 87 | _columns = { | ||
424 | 88 | 'workflow_process_id':fields.many2one('sale.workflow.process', 'Sale Workflow Process'), | ||
425 | 89 | #TODO propose a merge to add this field by default in acount module | ||
426 | 90 | 'sale_ids': fields.many2many('sale.order', 'sale_order_invoice_rel', 'invoice_id', 'order_id', 'Sale Orders') | ||
427 | 91 | } | ||
428 | 92 | |||
429 | 93 | def reconcile_invoice(self, cr, uid, ids, context=None): | ||
430 | 94 | """ | ||
431 | 95 | Simple method to reconcile the invoice with the payment generated on the sale order | ||
432 | 96 | """ | ||
433 | 97 | obj_move_line = self.pool.get('account.move.line') | ||
434 | 98 | for invoice in self.browse(cr, uid, ids, context=context): | ||
435 | 99 | line_ids = [] | ||
436 | 100 | payment_amount = 0 | ||
437 | 101 | invoice_amount = 0 | ||
438 | 102 | if invoice.sale_ids and invoice.sale_ids[0].payment_id and invoice.move_id: | ||
439 | 103 | for move in invoice.sale_ids[0].payment_id.move_ids: | ||
440 | 104 | if move.credit > 0 and not move.reconcile_id: | ||
441 | 105 | line_ids.append(move.id) | ||
442 | 106 | payment_amount += move.credit | ||
443 | 107 | for move in invoice.move_id.line_id: | ||
444 | 108 | if move.debit > 0 and not move.reconcile_id: | ||
445 | 109 | line_ids.append(move.id) | ||
446 | 110 | invoice_amount += move.debit | ||
447 | 111 | balance = abs(payment_amount-invoice_amount) | ||
448 | 112 | precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') | ||
449 | 113 | if line_ids and not round(balance, precision): | ||
450 | 114 | obj_move_line.reconcile(cr, uid, line_ids, context=context) | ||
451 | 115 | return True | ||
452 | 116 | 42 | ||
453 | === added file 'sale_automatic_workflow/stock.py' | |||
454 | --- sale_automatic_workflow/stock.py 1970-01-01 00:00:00 +0000 | |||
455 | +++ sale_automatic_workflow/stock.py 2013-01-11 17:08:20 +0000 | |||
456 | @@ -0,0 +1,65 @@ | |||
457 | 1 | # -*- coding: utf-8 -*- | ||
458 | 2 | ############################################################################### | ||
459 | 3 | # | ||
460 | 4 | # sale_automatic_workflow for OpenERP | ||
461 | 5 | # Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>. | ||
462 | 6 | # All Rights Reserved | ||
463 | 7 | # @author Sébastien BEAU <sebastien.beau@akretion.com> | ||
464 | 8 | # This program is free software: you can redistribute it and/or modify | ||
465 | 9 | # it under the terms of the GNU Affero General Public License as | ||
466 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
467 | 11 | # License, or (at your option) any later version. | ||
468 | 12 | # | ||
469 | 13 | # This program is distributed in the hope that it will be useful, | ||
470 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
471 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
472 | 16 | # GNU Affero General Public License for more details. | ||
473 | 17 | # | ||
474 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
475 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
476 | 20 | # | ||
477 | 21 | ############################################################################### | ||
478 | 22 | from openerp.osv.orm import Model | ||
479 | 23 | from openerp.osv import fields | ||
480 | 24 | |||
481 | 25 | class stock_picking_out(Model): | ||
482 | 26 | _inherit = "stock.picking.out" | ||
483 | 27 | _columns = { | ||
484 | 28 | 'workflow_process_id':fields.many2one('sale.workflow.process', 'Sale Workflow Process'), | ||
485 | 29 | } | ||
486 | 30 | |||
487 | 31 | def _prepare_invoice(self, cr, uid, picking, partner, inv_type, journal_id, context=None): | ||
488 | 32 | invoice_vals = super(stock_picking_out, self)._prepare_invoice(cr, uid, picking, partner, \ | ||
489 | 33 | inv_type, journal_id, context=context) | ||
490 | 34 | invoice_vals['workflow_process_id'] = picking.workflow_process_id.id | ||
491 | 35 | if picking.workflow_process_id.invoice_date_is_order_date: | ||
492 | 36 | invoice_vals['date_invoice'] = picking.sale_id.date_order | ||
493 | 37 | return invoice_vals | ||
494 | 38 | |||
495 | 39 | def validate_picking(self, cr, uid, ids, context=None): | ||
496 | 40 | for picking in self.browse(cr, uid, ids, context=context): | ||
497 | 41 | self.force_assign(cr, uid, [picking.id]) | ||
498 | 42 | partial_data = {} | ||
499 | 43 | for move in picking.move_lines: | ||
500 | 44 | partial_data["move" + str(move.id)] = {'product_qty': move.product_qty, | ||
501 | 45 | 'product_uom': move.product_uom.id} | ||
502 | 46 | self.do_partial(cr, uid, [picking.id], partial_data) | ||
503 | 47 | return True | ||
504 | 48 | |||
505 | 49 | #TODO reimplement me | ||
506 | 50 | # def validate_manufactoring_order(self, cr, uid, origin, context=None): #we do not create class mrp.production to avoid dependence with the module mrp | ||
507 | 51 | # if context is None: | ||
508 | 52 | # context = {} | ||
509 | 53 | # wf_service = netsvc.LocalService("workflow") | ||
510 | 54 | # mrp_prod_obj = self.pool.get('mrp.production') | ||
511 | 55 | # mrp_product_produce_obj = self.pool.get('mrp.product.produce') | ||
512 | 56 | # production_ids = mrp_prod_obj.search(cr, uid, [('origin', 'ilike', origin)]) | ||
513 | 57 | # for production in mrp_prod_obj.browse(cr, uid, production_ids): | ||
514 | 58 | # mrp_prod_obj.force_production(cr, uid, [production.id]) | ||
515 | 59 | # wf_service.trg_validate(uid, 'mrp.production', production.id, 'button_produce', cr) | ||
516 | 60 | # context.update({'active_model': 'mrp.production', 'active_ids': [production.id], 'search_default_ready': 1, 'active_id': production.id}) | ||
517 | 61 | # produce = mrp_product_produce_obj.create(cr, uid, {'mode': 'consume_produce', 'product_qty': production.product_qty}, context) | ||
518 | 62 | # mrp_product_produce_obj.do_produce(cr, uid, [produce], context) | ||
519 | 63 | # self.validate_manufactoring_order(cr, uid, production.name, context) | ||
520 | 64 | # return True | ||
521 | 65 | # | ||
522 | 0 | 66 | ||
523 | === modified file 'sale_exceptions/__openerp__.py' | |||
524 | --- sale_exceptions/__openerp__.py 2012-11-21 13:48:17 +0000 | |||
525 | +++ sale_exceptions/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
526 | @@ -25,7 +25,7 @@ | |||
527 | 25 | 25 | ||
528 | 26 | { | 26 | { |
529 | 27 | 'name': 'Sale Exceptions', | 27 | 'name': 'Sale Exceptions', |
531 | 28 | 'version': '6.1.0', | 28 | 'version': '0.1', |
532 | 29 | 'category': 'Generic Modules/Sale', | 29 | 'category': 'Generic Modules/Sale', |
533 | 30 | 'description': """ | 30 | 'description': """ |
534 | 31 | This module allows you attach several customizable exceptions to your sale order in a way that you can filter orders by exceptions type and fix them. | 31 | This module allows you attach several customizable exceptions to your sale order in a way that you can filter orders by exceptions type and fix them. |
535 | 32 | 32 | ||
536 | === modified file 'sale_exceptions/sale.py' | |||
537 | --- sale_exceptions/sale.py 2012-12-07 14:11:56 +0000 | |||
538 | +++ sale_exceptions/sale.py 2013-01-11 17:08:20 +0000 | |||
539 | @@ -33,6 +33,7 @@ | |||
540 | 33 | class sale_exception(Model): | 33 | class sale_exception(Model): |
541 | 34 | _name = "sale.exception" | 34 | _name = "sale.exception" |
542 | 35 | _description = "Sale Exceptions" | 35 | _description = "Sale Exceptions" |
543 | 36 | _order="active desc, sequence asc" | ||
544 | 36 | _columns = { | 37 | _columns = { |
545 | 37 | 'name': fields.char('Exception Name', size=64, required=True, translate=True), | 38 | 'name': fields.char('Exception Name', size=64, required=True, translate=True), |
546 | 38 | 'description': fields.text('Description', translate=True), | 39 | 'description': fields.text('Description', translate=True), |
547 | @@ -106,6 +107,7 @@ | |||
548 | 106 | view_id = model_data_obj.get_object_reference( | 107 | view_id = model_data_obj.get_object_reference( |
549 | 107 | cr, uid, 'sale_exceptions', 'view_sale_exception_confirm')[1] | 108 | cr, uid, 'sale_exceptions', 'view_sale_exception_confirm')[1] |
550 | 108 | action = { | 109 | action = { |
551 | 110 | 'name': _("Exceptions On Sale Order"), | ||
552 | 109 | 'type': 'ir.actions.act_window', | 111 | 'type': 'ir.actions.act_window', |
553 | 110 | 'view_type': 'form', | 112 | 'view_type': 'form', |
554 | 111 | 'view_mode': 'form', | 113 | 'view_mode': 'form', |
555 | @@ -117,14 +119,12 @@ | |||
556 | 117 | } | 119 | } |
557 | 118 | return action | 120 | return action |
558 | 119 | 121 | ||
560 | 120 | def button_order_confirm(self, cr, uid, ids, context=None): | 122 | def action_button_confirm(self, cr, uid, ids, context=None): |
561 | 121 | exception_ids = self.detect_exceptions(cr, uid, ids, context=context) | 123 | exception_ids = self.detect_exceptions(cr, uid, ids, context=context) |
562 | 122 | if exception_ids: | 124 | if exception_ids: |
563 | 123 | return self._popup_exceptions(cr, uid, ids[0], context=context) | 125 | return self._popup_exceptions(cr, uid, ids[0], context=context) |
564 | 124 | else: | 126 | else: |
568 | 125 | wf_service = netsvc.LocalService("workflow") | 127 | return super(sale_order, self).action_button_confirm(cr, uid, ids, context=context) |
566 | 126 | wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr) | ||
567 | 127 | return True | ||
569 | 128 | 128 | ||
570 | 129 | def test_exceptions(self, cr, uid, ids, context=None): | 129 | def test_exceptions(self, cr, uid, ids, context=None): |
571 | 130 | """ | 130 | """ |
572 | 131 | 131 | ||
573 | === modified file 'sale_exceptions/sale_view.xml' | |||
574 | --- sale_exceptions/sale_view.xml 2012-10-22 14:39:18 +0000 | |||
575 | +++ sale_exceptions/sale_view.xml 2013-01-11 17:08:20 +0000 | |||
576 | @@ -2,29 +2,13 @@ | |||
577 | 2 | <openerp> | 2 | <openerp> |
578 | 3 | <data> | 3 | <data> |
579 | 4 | 4 | ||
580 | 5 | <record id="view_sale_exception_search" model="ir.ui.view"> | ||
581 | 6 | <field name="name">sale.exception.view.search</field> | ||
582 | 7 | <field name="model">sale.exception</field> | ||
583 | 8 | <field name="type">search</field> | ||
584 | 9 | <field name="arch" type="xml"> | ||
585 | 10 | <search string="Search Sale Exceptions"> | ||
586 | 11 | <group> | ||
587 | 12 | <filter name="all" icon="gtk-fullscreen" string="See All" domain="['|', ('active','=', False), ('active','=', True)]" help="See all rule active or unactive"/> | ||
588 | 13 | </group> | ||
589 | 14 | <newline/> | ||
590 | 15 | <group> | ||
591 | 16 | <field name="name"/> | ||
592 | 17 | </group> | ||
593 | 18 | </search> | ||
594 | 19 | </field> | ||
595 | 20 | </record> | ||
596 | 21 | |||
597 | 22 | <record id="view_sale_exception_tree" model="ir.ui.view"> | 5 | <record id="view_sale_exception_tree" model="ir.ui.view"> |
598 | 23 | <field name="name">sale.exception.tree</field> | 6 | <field name="name">sale.exception.tree</field> |
599 | 24 | <field name="model">sale.exception</field> | 7 | <field name="model">sale.exception</field> |
600 | 25 | <field name="type">tree</field> | 8 | <field name="type">tree</field> |
601 | 26 | <field name="arch" type="xml"> | 9 | <field name="arch" type="xml"> |
602 | 27 | <tree string="Sale Exception"> | 10 | <tree string="Sale Exception"> |
603 | 11 | <field name="active"/> | ||
604 | 28 | <field name="name"/> | 12 | <field name="name"/> |
605 | 29 | <field name="description"/> | 13 | <field name="description"/> |
606 | 30 | <field name="model"/> | 14 | <field name="model"/> |
607 | @@ -66,7 +50,7 @@ | |||
608 | 66 | <field name="view_type">form</field> | 50 | <field name="view_type">form</field> |
609 | 67 | <field name="view_mode">tree,form</field> | 51 | <field name="view_mode">tree,form</field> |
610 | 68 | <field name="view_id" ref="view_sale_exception_tree"/> | 52 | <field name="view_id" ref="view_sale_exception_tree"/> |
612 | 69 | <field name="search_view_id" ref="view_sale_exception_search"/> | 53 | <field name="context">{'active_test': False}</field> |
613 | 70 | </record> | 54 | </record> |
614 | 71 | 55 | ||
615 | 72 | <menuitem action="action_sale_test_tree" id="menu_sale_test" parent="base.menu_sale_config_sales" /> | 56 | <menuitem action="action_sale_test_tree" id="menu_sale_test" parent="base.menu_sale_config_sales" /> |
616 | @@ -79,28 +63,17 @@ | |||
617 | 79 | <field name="priority">100</field> | 63 | <field name="priority">100</field> |
618 | 80 | <field name="inherit_id" ref="sale.view_order_form"/> | 64 | <field name="inherit_id" ref="sale.view_order_form"/> |
619 | 81 | <field name="arch" type="xml"> | 65 | <field name="arch" type="xml"> |
622 | 82 | <xpath expr="/form/notebook/page[@string='Sales Order']/group/field[@name='state']" | 66 | <field name="name" position="after"> |
621 | 83 | position="after"> | ||
623 | 84 | <field name="main_exception_id" nolabel="1" | 67 | <field name="main_exception_id" nolabel="1" |
624 | 85 | attrs="{'invisible':[('main_exception_id','=', False)]}"/> | 68 | attrs="{'invisible':[('main_exception_id','=', False)]}"/> |
628 | 86 | </xpath> | 69 | </field> |
629 | 87 | <xpath expr="/form/notebook/page[@string='Other Information']/separator[@string='Notes']" | 70 | <xpath expr="//page[@string='Other Information']/group" |
630 | 88 | position="before"> | 71 | position="inside"> |
631 | 89 | <group name="exception" colspan="2" col="2"> | 72 | <group name="exception" colspan="2" col="2"> |
632 | 90 | <separator string="Exception" colspan="2"/> | 73 | <separator string="Exception" colspan="2"/> |
633 | 91 | <field name="exceptions_ids" colspan="2" nolabel="1"/> | 74 | <field name="exceptions_ids" colspan="2" nolabel="1"/> |
634 | 92 | </group> | 75 | </group> |
635 | 93 | <group name="notes" colspan="2" col="2"> | ||
636 | 94 | <separator colspan="2" string="Notes"/> | ||
637 | 95 | <field colspan="2" name="note" nolabel="1"/> | ||
638 | 96 | </group> | ||
639 | 97 | </xpath> | 76 | </xpath> |
640 | 98 | <xpath expr="/form/notebook/page[@string='Other Information']/separator[@string='Notes']" position="replace"/> | ||
641 | 99 | <xpath expr="/form/notebook/page[@string='Other Information']/field[@name='note']" position="replace"/> | ||
642 | 100 | <button name="order_confirm" position="attributes"> | ||
643 | 101 | <attribute name="name">button_order_confirm</attribute> | ||
644 | 102 | <attribute name="type">object</attribute> | ||
645 | 103 | </button> | ||
646 | 104 | </field> | 77 | </field> |
647 | 105 | </record> | 78 | </record> |
648 | 106 | 79 | ||
649 | 107 | 80 | ||
650 | === modified file 'sale_exceptions/wizard/sale_exception_confirm_view.xml' | |||
651 | --- sale_exceptions/wizard/sale_exception_confirm_view.xml 2012-03-23 14:41:24 +0000 | |||
652 | +++ sale_exceptions/wizard/sale_exception_confirm_view.xml 2013-01-11 17:08:20 +0000 | |||
653 | @@ -7,26 +7,25 @@ | |||
654 | 7 | <field name="model">sale.exception.confirm</field> | 7 | <field name="model">sale.exception.confirm</field> |
655 | 8 | <field name="type">form</field> | 8 | <field name="type">form</field> |
656 | 9 | <field name="arch" type="xml"> | 9 | <field name="arch" type="xml"> |
674 | 10 | <form string="Sale Exceptions"> | 10 | <form string="Sale Exceptions On Sale Order" version="7.0"> |
675 | 11 | <separator colspan="4" string="Exceptions on the sale order" /> | 11 | <group> |
676 | 12 | <field name="exception_ids" nolabel="1" colspan="4"> | 12 | <field name="exception_ids" nolabel="1" colspan="4"> |
677 | 13 | <form string="Sale Exception"> | 13 | <form string="Sale Exception"> |
678 | 14 | <field name="name" colspan="4"/> | 14 | <field name="name" colspan="4"/> |
679 | 15 | <field name="description" colspan="4"/> | 15 | <field name="description" colspan="4"/> |
680 | 16 | </form> | 16 | </form> |
681 | 17 | <tree string="Sale Exceptions"> | 17 | <tree string="Sale Exceptions"> |
682 | 18 | <field name="name"/> | 18 | <field name="name"/> |
683 | 19 | <field name="description"/> | 19 | <field name="description"/> |
684 | 20 | </tree> | 20 | </tree> |
685 | 21 | </field> | 21 | </field> |
686 | 22 | <newline/> | 22 | <newline/> |
687 | 23 | <field name="ignore" groups='base.group_sale_manager'/> | 23 | <field name="ignore" groups='base.group_sale_manager'/> |
688 | 24 | <newline/> | 24 | </group> |
689 | 25 | <separator colspan="4"/> | 25 | <footer> |
673 | 26 | <group col="2" colspan="4"> | ||
690 | 27 | <button name="action_confirm" string="_Ok" | 26 | <button name="action_confirm" string="_Ok" |
691 | 28 | colspan="1" type="object" icon="gtk-ok" /> | 27 | colspan="1" type="object" icon="gtk-ok" /> |
693 | 29 | </group> | 28 | </footer> |
694 | 30 | </form> | 29 | </form> |
695 | 31 | </field> | 30 | </field> |
696 | 32 | </record> | 31 | </record> |
697 | 33 | 32 | ||
698 | === modified file 'sale_quick_payment/__init__.py' | |||
699 | --- sale_quick_payment/__init__.py 2012-05-18 09:00:34 +0000 | |||
700 | +++ sale_quick_payment/__init__.py 2013-01-11 17:08:20 +0000 | |||
701 | @@ -23,6 +23,4 @@ | |||
702 | 23 | import sale | 23 | import sale |
703 | 24 | import payment_method | 24 | import payment_method |
704 | 25 | import wizard | 25 | import wizard |
708 | 26 | import company | 26 | import account_voucher |
706 | 27 | |||
707 | 28 | |||
709 | 29 | 27 | ||
710 | === modified file 'sale_quick_payment/__openerp__.py' | |||
711 | --- sale_quick_payment/__openerp__.py 2012-12-07 12:44:57 +0000 | |||
712 | +++ sale_quick_payment/__openerp__.py 2013-01-11 17:08:20 +0000 | |||
713 | @@ -22,7 +22,7 @@ | |||
714 | 22 | 22 | ||
715 | 23 | { | 23 | { |
716 | 24 | 'name': 'sale_quick_payment', | 24 | 'name': 'sale_quick_payment', |
718 | 25 | 'version': '6.1.0', | 25 | 'version': '0.1', |
719 | 26 | 'category': 'Generic Modules/Others', | 26 | 'category': 'Generic Modules/Others', |
720 | 27 | 'license': 'AGPL-3', | 27 | 'license': 'AGPL-3', |
721 | 28 | 'description': """ | 28 | 'description': """ |
722 | @@ -36,16 +36,16 @@ | |||
723 | 36 | 'author': 'Akretion', | 36 | 'author': 'Akretion', |
724 | 37 | 'website': 'http://www.akretion.com/', | 37 | 'website': 'http://www.akretion.com/', |
725 | 38 | 'depends': [ | 38 | 'depends': [ |
727 | 39 | 'sale', | 39 | 'sale_exceptions', |
728 | 40 | 'account_voucher', | 40 | 'account_voucher', |
729 | 41 | ], | 41 | ], |
730 | 42 | 'init_xml': [], | 42 | 'init_xml': [], |
732 | 43 | 'update_xml': [ | 43 | 'update_xml': [ |
733 | 44 | 'wizard/pay_sale_order.xml', | ||
734 | 44 | 'sale_view.xml', | 45 | 'sale_view.xml', |
735 | 45 | 'payment_method_view.xml', | 46 | 'payment_method_view.xml', |
736 | 46 | 'wizard/pay_sale_order.xml', | ||
737 | 47 | 'company_view.xml', | ||
738 | 48 | 'security/ir.model.access.csv', | 47 | 'security/ir.model.access.csv', |
739 | 48 | 'settings/sale.exception.csv', | ||
740 | 49 | ], | 49 | ], |
741 | 50 | 'demo_xml': [], | 50 | 'demo_xml': [], |
742 | 51 | 'installable': True, | 51 | 'installable': True, |
743 | 52 | 52 | ||
744 | === added file 'sale_quick_payment/account_voucher.py' | |||
745 | --- sale_quick_payment/account_voucher.py 1970-01-01 00:00:00 +0000 | |||
746 | +++ sale_quick_payment/account_voucher.py 2013-01-11 17:08:20 +0000 | |||
747 | @@ -0,0 +1,33 @@ | |||
748 | 1 | # -*- encoding: utf-8 -*- | ||
749 | 2 | ############################################################################### | ||
750 | 3 | # | ||
751 | 4 | # sale_quick_payment for OpenERP | ||
752 | 5 | # Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. | ||
753 | 6 | # All Rights Reserved | ||
754 | 7 | # @author Sébastien BEAU <sebastien.beau@akretion.com> | ||
755 | 8 | # This program is free software: you can redistribute it and/or modify | ||
756 | 9 | # it under the terms of the GNU Affero General Public License as | ||
757 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
758 | 11 | # License, or (at your option) any later version. | ||
759 | 12 | # | ||
760 | 13 | # This program is distributed in the hope that it will be useful, | ||
761 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
762 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
763 | 16 | # GNU Affero General Public License for more details. | ||
764 | 17 | # | ||
765 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
766 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
767 | 20 | # | ||
768 | 21 | ############################################################################### | ||
769 | 22 | |||
770 | 23 | from openerp.osv.orm import Model | ||
771 | 24 | from openerp.osv import fields | ||
772 | 25 | |||
773 | 26 | class payment_method(Model): | ||
774 | 27 | _inherit = "account.voucher" | ||
775 | 28 | |||
776 | 29 | _columns = { | ||
777 | 30 | 'order_ids': fields.many2many('sale.order', string='Sale Order'), | ||
778 | 31 | } | ||
779 | 32 | |||
780 | 33 | |||
781 | 0 | 34 | ||
782 | === removed file 'sale_quick_payment/company.py' | |||
783 | --- sale_quick_payment/company.py 2012-08-21 13:57:44 +0000 | |||
784 | +++ sale_quick_payment/company.py 1970-01-01 00:00:00 +0000 | |||
785 | @@ -1,33 +0,0 @@ | |||
786 | 1 | # -*- encoding: utf-8 -*- | ||
787 | 2 | ################################################################################# | ||
788 | 3 | # # | ||
789 | 4 | # sale_quick_payment for OpenERP # | ||
790 | 5 | # Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com> # | ||
791 | 6 | # # | ||
792 | 7 | # This program is free software: you can redistribute it and/or modify # | ||
793 | 8 | # it under the terms of the GNU Affero General Public License as # | ||
794 | 9 | # published by the Free Software Foundation, either version 3 of the # | ||
795 | 10 | # License, or (at your option) any later version. # | ||
796 | 11 | # # | ||
797 | 12 | # This program is distributed in the hope that it will be useful, # | ||
798 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | ||
799 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | ||
800 | 15 | # GNU Affero General Public License for more details. # | ||
801 | 16 | # # | ||
802 | 17 | # You should have received a copy of the GNU Affero General Public License # | ||
803 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | ||
804 | 19 | # # | ||
805 | 20 | ################################################################################# | ||
806 | 21 | |||
807 | 22 | from openerp.osv.orm import Model | ||
808 | 23 | from openerp.osv import fields | ||
809 | 24 | from tools.translate import _ | ||
810 | 25 | |||
811 | 26 | class res_company(Model): | ||
812 | 27 | """Override company to add payment configuration""" | ||
813 | 28 | _inherit = "res.company" | ||
814 | 29 | _columns = { | ||
815 | 30 | 'sale_order_must_be_paid':fields.boolean('Sale Order Must Be Paid', | ||
816 | 31 | help='If this option is check an order can not be validaded without payment' | ||
817 | 32 | ), | ||
818 | 33 | } | ||
819 | 34 | 0 | ||
820 | === removed file 'sale_quick_payment/company_view.xml' | |||
821 | --- sale_quick_payment/company_view.xml 2012-05-18 09:00:34 +0000 | |||
822 | +++ sale_quick_payment/company_view.xml 1970-01-01 00:00:00 +0000 | |||
823 | @@ -1,25 +0,0 @@ | |||
824 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
825 | 2 | <!-- | ||
826 | 3 | sale_quick_payment for OpenERP | ||
827 | 4 | Copyright (C) 2012 Akretion Sébastien BEAU <sebastien.beau@akretion.com> | ||
828 | 5 | The licence is in the file __openerp__.py | ||
829 | 6 | --> | ||
830 | 7 | |||
831 | 8 | |||
832 | 9 | <openerp> | ||
833 | 10 | <data> | ||
834 | 11 | <record model="ir.ui.view" id="view_company_form"> | ||
835 | 12 | <field name="name">sale_quick_payment.view_company_form</field> | ||
836 | 13 | <field name="model">res.company</field> | ||
837 | 14 | <field name="inherit_id" ref="base.view_company_form"/> | ||
838 | 15 | <field name="type">form</field> | ||
839 | 16 | <field name="arch" type="xml"> | ||
840 | 17 | <page string="Configuration" position="inside"> | ||
841 | 18 | <separator string="Sale Configuration" colspan="4"/> | ||
842 | 19 | <field name="sale_order_must_be_paid"/> | ||
843 | 20 | </page> | ||
844 | 21 | </field> | ||
845 | 22 | </record> | ||
846 | 23 | </data> | ||
847 | 24 | </openerp> | ||
848 | 25 | |||
849 | 26 | 0 | ||
850 | === added directory 'sale_quick_payment/migrations' | |||
851 | === added directory 'sale_quick_payment/migrations/0.1' | |||
852 | === added file 'sale_quick_payment/migrations/0.1/post-migration.py' | |||
853 | --- sale_quick_payment/migrations/0.1/post-migration.py 1970-01-01 00:00:00 +0000 | |||
854 | +++ sale_quick_payment/migrations/0.1/post-migration.py 2013-01-11 17:08:20 +0000 | |||
855 | @@ -0,0 +1,35 @@ | |||
856 | 1 | # -*- encoding: utf-8 -*- | ||
857 | 2 | ############################################################################### | ||
858 | 3 | # | ||
859 | 4 | # sale_quick_payment for OpenERP | ||
860 | 5 | # Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. | ||
861 | 6 | # All Rights Reserved | ||
862 | 7 | # @author Sébastien BEAU <sebastien.beau@akretion.com> | ||
863 | 8 | # This program is free software: you can redistribute it and/or modify | ||
864 | 9 | # it under the terms of the GNU Affero General Public License as | ||
865 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
866 | 11 | # License, or (at your option) any later version. | ||
867 | 12 | # | ||
868 | 13 | # This program is distributed in the hope that it will be useful, | ||
869 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
870 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
871 | 16 | # GNU Affero General Public License for more details. | ||
872 | 17 | # | ||
873 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
874 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
875 | 20 | # | ||
876 | 21 | ############################################################################### | ||
877 | 22 | |||
878 | 23 | """ r0.1: Migration 6.1 => 7.0.0.1 | ||
879 | 24 | migrate the field payment_id from one2many to payment_ids many2many | ||
880 | 25 | """ | ||
881 | 26 | __name__ = ("sale.order:: V7 change/rename the field payment_id into a" | ||
882 | 27 | "many2many with the name payment_ids") | ||
883 | 28 | |||
884 | 29 | def migrate(cr, version): | ||
885 | 30 | cr.execute("INSERT INTO account_voucher_sale_order_rel" | ||
886 | 31 | "(sale_order_id, account_voucher_id) " | ||
887 | 32 | "(SELECT id, payment_id FROM " | ||
888 | 33 | " sale_order " | ||
889 | 34 | "WHERE payment_id IS NOT NULL )") | ||
890 | 35 | |||
891 | 0 | 36 | ||
892 | === modified file 'sale_quick_payment/sale.py' | |||
893 | --- sale_quick_payment/sale.py 2012-12-07 12:44:57 +0000 | |||
894 | +++ sale_quick_payment/sale.py 2013-01-11 17:08:20 +0000 | |||
895 | @@ -25,20 +25,48 @@ | |||
896 | 25 | import netsvc | 25 | import netsvc |
897 | 26 | from collections import Iterable | 26 | from collections import Iterable |
898 | 27 | from openerp.tools.translate import _ | 27 | from openerp.tools.translate import _ |
899 | 28 | import decimal_precision as dp | ||
900 | 28 | 29 | ||
901 | 29 | class sale_order(Model): | 30 | class sale_order(Model): |
902 | 30 | _inherit = "sale.order" | 31 | _inherit = "sale.order" |
903 | 31 | 32 | ||
904 | 33 | def _get_order_from_voucher(self, cr, uid, ids, context=None): | ||
905 | 34 | result = [] | ||
906 | 35 | for voucher in self.pool.get('account.voucher').browse(cr, uid, ids, context=context): | ||
907 | 36 | for order in voucher.order_ids: | ||
908 | 37 | result.append(order.id) | ||
909 | 38 | return list(set(result)) | ||
910 | 39 | |||
911 | 40 | def _get_order_from_line(self, cr, uid, ids, context=None): | ||
912 | 41 | return self.pool.get('sale.order')._get_order(cr, uid, ids, context=context) | ||
913 | 42 | |||
914 | 43 | def _amount_residual(self, cr, uid, ids, field_name, args, context=None): | ||
915 | 44 | res = {} | ||
916 | 45 | #TODO add here the support of multi-currency payment if need | ||
917 | 46 | for order in self.browse(cr, uid, ids, context=context): | ||
918 | 47 | res[order.id] = order.amount_total | ||
919 | 48 | for payment in order.payment_ids: | ||
920 | 49 | if payment.state == 'posted': | ||
921 | 50 | res[order.id] -= payment.amount | ||
922 | 51 | return res | ||
923 | 52 | |||
924 | 32 | _columns = { | 53 | _columns = { |
926 | 33 | 'payment_id': fields.many2one('account.voucher', 'Payment'), | 54 | 'payment_ids': fields.many2many('account.voucher', string='Payments'), |
927 | 34 | 'payment_method_id': fields.many2one('payment.method', 'Payment Method'), | 55 | 'payment_method_id': fields.many2one('payment.method', 'Payment Method'), |
928 | 56 | 'residual': fields.function(_amount_residual, digits_compute=dp.get_precision('Account'), string='Balance', | ||
929 | 57 | store = { | ||
930 | 58 | 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line', 'payment_ids'], 10), | ||
931 | 59 | 'sale.order.line': (_get_order_from_line, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 20), | ||
932 | 60 | 'account.voucher': (_get_order_from_voucher, ['amount'], 30), | ||
933 | 61 | }, | ||
934 | 62 | ), | ||
935 | 35 | } | 63 | } |
936 | 36 | 64 | ||
937 | 37 | def copy(self, cr, uid, id, default=None, context=None): | 65 | def copy(self, cr, uid, id, default=None, context=None): |
938 | 38 | if not default: | 66 | if not default: |
939 | 39 | default = {} | 67 | default = {} |
940 | 40 | default.update({ | 68 | default.update({ |
942 | 41 | 'payment_id': False, | 69 | 'payment_ids': False, |
943 | 42 | }) | 70 | }) |
944 | 43 | return super(sale_order, self).copy(cr, uid, id, default, context=context) | 71 | return super(sale_order, self).copy(cr, uid, id, default, context=context) |
945 | 44 | 72 | ||
946 | @@ -132,14 +160,6 @@ | |||
947 | 132 | wf_service = netsvc.LocalService("workflow") | 160 | wf_service = netsvc.LocalService("workflow") |
948 | 133 | wf_service.trg_validate( | 161 | wf_service.trg_validate( |
949 | 134 | uid, 'account.voucher', voucher_id, 'proforma_voucher', cr) | 162 | uid, 'account.voucher', voucher_id, 'proforma_voucher', cr) |
951 | 135 | sale.write({'payment_id': voucher_id}, context=context) | 163 | sale.write({'payment_ids': [(4,voucher_id)]}, context=context) |
952 | 136 | return True | 164 | return True |
953 | 137 | 165 | ||
954 | 138 | def button_order_confirm(self, cr, uid, ids, context=None): | ||
955 | 139 | for order in self.browse(cr, uid, ids, context=context): | ||
956 | 140 | if order.company_id.sale_order_must_be_paid and not order.payment_id: | ||
957 | 141 | raise except_osv(_('User Error!'), | ||
958 | 142 | _('The sale Order %s Must be paid before validation') % (order.name)) | ||
959 | 143 | return super(sale_order, self).button_order_confirm(cr, uid, ids, context=context) | ||
960 | 144 | |||
961 | 145 | |||
962 | 146 | 166 | ||
963 | === modified file 'sale_quick_payment/sale_view.xml' | |||
964 | --- sale_quick_payment/sale_view.xml 2012-05-24 20:44:25 +0000 | |||
965 | +++ sale_quick_payment/sale_view.xml 2013-01-11 17:08:20 +0000 | |||
966 | @@ -17,15 +17,23 @@ | |||
967 | 17 | <field eval="16" name="priority"/> | 17 | <field eval="16" name="priority"/> |
968 | 18 | <field name="type">form</field> | 18 | <field name="type">form</field> |
969 | 19 | <field name="arch" type="xml"> | 19 | <field name="arch" type="xml"> |
970 | 20 | <button name="print_quotation" position="after"> | ||
971 | 21 | <button name="%(open_pay_sale_order)d" string="Register Payments" type="action" states="draft,sent"/> | ||
972 | 22 | </button> | ||
973 | 20 | <page string="Other Information" position="after"> | 23 | <page string="Other Information" position="after"> |
974 | 21 | <page name="automation_information" string="Automation Information"> | 24 | <page name="automation_information" string="Automation Information"> |
975 | 22 | <group name="payment_information" colspan="4"> | 25 | <group name="payment_information" colspan="4"> |
976 | 23 | <separator string="Payment Information" colspan="4"/> | ||
977 | 24 | <field name="payment_method_id" /> | 26 | <field name="payment_method_id" /> |
979 | 25 | <field name="payment_id" /> | 27 | <group name="payments" colspan="4"> |
980 | 28 | <separator string="Payments" colspan="4"/> | ||
981 | 29 | <field name="payment_ids" nolabel="1" /> | ||
982 | 30 | </group> | ||
983 | 26 | </group> | 31 | </group> |
984 | 27 | </page> | 32 | </page> |
985 | 28 | </page> | 33 | </page> |
986 | 34 | <field name="amount_total" position="after"> | ||
987 | 35 | <field name="residual" invisible="1"/> | ||
988 | 36 | </field> | ||
989 | 29 | </field> | 37 | </field> |
990 | 30 | </record> | 38 | </record> |
991 | 31 | 39 | ||
992 | 32 | 40 | ||
993 | === added directory 'sale_quick_payment/settings' | |||
994 | === added file 'sale_quick_payment/settings/sale.exception.csv' | |||
995 | --- sale_quick_payment/settings/sale.exception.csv 1970-01-01 00:00:00 +0000 | |||
996 | +++ sale_quick_payment/settings/sale.exception.csv 2013-01-11 17:08:20 +0000 | |||
997 | @@ -0,0 +1,3 @@ | |||
998 | 1 | id,name,description,sequence,model,code | ||
999 | 2 | must_be_paid,Sale order must be paid before validation,The sale order must be paid before the validation. Please fix it,50,sale.order,"if order.residual > 0: | ||
1000 | 3 | failed = True" | ||
1001 | 0 | 4 | ||
1002 | === modified file 'sale_quick_payment/wizard/pay_sale_order.py' | |||
1003 | --- sale_quick_payment/wizard/pay_sale_order.py 2012-08-21 13:57:44 +0000 | |||
1004 | +++ sale_quick_payment/wizard/pay_sale_order.py 2013-01-11 17:08:20 +0000 | |||
1005 | @@ -25,6 +25,8 @@ | |||
1006 | 25 | import decimal_precision as dp | 25 | import decimal_precision as dp |
1007 | 26 | from datetime import datetime | 26 | from datetime import datetime |
1008 | 27 | 27 | ||
1009 | 28 | #TODO add button on sale_form header instead of more button | ||
1010 | 29 | |||
1011 | 28 | class pay_sale_order(TransientModel): | 30 | class pay_sale_order(TransientModel): |
1012 | 29 | _name = 'pay.sale.order' | 31 | _name = 'pay.sale.order' |
1013 | 30 | _description = 'Wizard to generate a payment from the sale order' | 32 | _description = 'Wizard to generate a payment from the sale order' |
1014 | @@ -35,15 +37,21 @@ | |||
1015 | 35 | 'date': fields.datetime('Payment Date'), | 37 | 'date': fields.datetime('Payment Date'), |
1016 | 36 | } | 38 | } |
1017 | 37 | 39 | ||
1022 | 38 | def _get_journal_id(self, cr, uid, args): | 40 | def _get_journal_id(self, cr, uid, context=None): |
1023 | 39 | if args.get('payment_method_id'): | 41 | if context is None: |
1024 | 40 | payment_method = self.pool.get('payment.method').browse(cr, uid, args['payment_method_id']) | 42 | context = {} |
1025 | 41 | return payment_method.journal_id.id | 43 | if context.get('active_id'): |
1026 | 44 | order = self.pool.get('sale.order').browse(cr, uid, context['active_id'], context=context) | ||
1027 | 45 | if order.payment_method_id: | ||
1028 | 46 | return order.payment_method_id.journal_id.id | ||
1029 | 42 | return False | 47 | return False |
1030 | 43 | 48 | ||
1034 | 44 | def _get_amount(self, cr, uid, args): | 49 | def _get_amount(self, cr, uid, context=None): |
1035 | 45 | if args.get('amount_total'): | 50 | if context is None: |
1036 | 46 | return args['amount_total'] | 51 | context = {} |
1037 | 52 | if context.get('active_id'): | ||
1038 | 53 | order = self.pool.get('sale.order').browse(cr, uid, context['active_id'], context=context) | ||
1039 | 54 | return order.residual | ||
1040 | 47 | return False | 55 | return False |
1041 | 48 | 56 | ||
1042 | 49 | _defaults = { | 57 | _defaults = { |
1043 | @@ -60,6 +68,18 @@ | |||
1044 | 60 | @param ids: List of account chart’s IDs | 68 | @param ids: List of account chart’s IDs |
1045 | 61 | @return: dictionary of Product list window for a given attributs set | 69 | @return: dictionary of Product list window for a given attributs set |
1046 | 62 | """ | 70 | """ |
1049 | 63 | for wizard in self.browse(cr, uid, ids, context=context): | 71 | wizard = self.browse(cr, uid, ids[0], context=context) |
1050 | 64 | self.pool.get('sale.order').pay_sale_order(cr, uid, context['active_id'], wizard.journal_id.id, wizard.amount, wizard.date, context=context) | 72 | self.pool.get('sale.order').pay_sale_order(cr, uid, context['active_id'], wizard.journal_id.id, wizard.amount, wizard.date, context=context) |
1051 | 65 | return {'type': 'ir.actions.act_window_close'} | 73 | return {'type': 'ir.actions.act_window_close'} |
1052 | 74 | |||
1053 | 75 | def pay_sale_order_and_confirm(self, cr, uid, ids, context=None): | ||
1054 | 76 | """ | ||
1055 | 77 | Pay the sale order | ||
1056 | 78 | @param cr: the current row, from the database cursor, | ||
1057 | 79 | @param uid: the current user’s ID for security checks, | ||
1058 | 80 | @param ids: List of account chart’s IDs | ||
1059 | 81 | @return: dictionary of Product list window for a given attributs set | ||
1060 | 82 | """ | ||
1061 | 83 | self.pay_sale_order(cr, uid, ids, context=context) | ||
1062 | 84 | return self.pool.get('sale.order').action_button_confirm(cr, uid, [context['active_id']], context=context) | ||
1063 | 85 | |||
1064 | 66 | 86 | ||
1065 | === modified file 'sale_quick_payment/wizard/pay_sale_order.xml' | |||
1066 | --- sale_quick_payment/wizard/pay_sale_order.xml 2012-04-22 12:48:34 +0000 | |||
1067 | +++ sale_quick_payment/wizard/pay_sale_order.xml 2013-01-11 17:08:20 +0000 | |||
1068 | @@ -6,14 +6,19 @@ | |||
1069 | 6 | <field name="model">pay.sale.order</field> | 6 | <field name="model">pay.sale.order</field> |
1070 | 7 | <field name="type">form</field> | 7 | <field name="type">form</field> |
1071 | 8 | <field name="arch" type="xml"> | 8 | <field name="arch" type="xml"> |
1079 | 9 | <form string="Pay Sale Order"> | 9 | <form string="Pay Sale Order" version="7.0"> |
1080 | 10 | <field name="journal_id" colspan="4"/> | 10 | <group> |
1081 | 11 | <field name="amount" colspan="4"/> | 11 | <field name="journal_id" string="Journal"/> |
1082 | 12 | <field name="date" colspan="4"/> | 12 | <field name="amount" string="Paid Amount"/> |
1083 | 13 | <group colspan="4"> | 13 | <field name="date" string="Date"/> |
1077 | 14 | <button icon="gtk-cancel" special="cancel" string="Cancel"/> | ||
1078 | 15 | <button icon="gtk-ok" name="pay_sale_order" string="Pay" type="object"/> | ||
1084 | 16 | </group> | 14 | </group> |
1085 | 15 | <footer> | ||
1086 | 16 | <button string="Pay" name="pay_sale_order" type="object" class="oe_highlight"/> | ||
1087 | 17 | or | ||
1088 | 18 | <button string="Pay And Confirm Order" name="pay_sale_order_and_confirm" type="object" class="oe_highlight"/> | ||
1089 | 19 | or | ||
1090 | 20 | <button string="Cancel" class="oe_link" special="cancel"/> | ||
1091 | 21 | </footer> | ||
1092 | 17 | </form> | 22 | </form> |
1093 | 18 | </field> | 23 | </field> |
1094 | 19 | </record> | 24 | </record> |
1095 | @@ -26,13 +31,5 @@ | |||
1096 | 26 | <field name="target">new</field> | 31 | <field name="target">new</field> |
1097 | 27 | <field name="view_id" ref="pay_sale_order_view"/> | 32 | <field name="view_id" ref="pay_sale_order_view"/> |
1098 | 28 | </record> | 33 | </record> |
1099 | 29 | |||
1100 | 30 | <record id="ir_action_open_pay_sale_order" model="ir.values"> | ||
1101 | 31 | <field name="key2">client_action_multi</field> | ||
1102 | 32 | <field name="model">sale.order</field> | ||
1103 | 33 | <field name="name">Sale.Order</field> | ||
1104 | 34 | <field eval="'ir.actions.act_window,%d'%open_pay_sale_order" name="value"/> | ||
1105 | 35 | <field eval="True" name="object"/> | ||
1106 | 36 | </record> | ||
1107 | 37 | </data> | 34 | </data> |
1108 | 38 | </openerp> | 35 | </openerp> |