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