25
25
import decimal_precision as dp
26
26
from datetime import datetime
28
#TODO add button on sale_form header instead of more button
28
30
class pay_sale_order(TransientModel):
29
31
_name = 'pay.sale.order'
30
32
_description = 'Wizard to generate a payment from the sale order'
35
37
'date': fields.datetime('Payment Date'),
38
def _get_journal_id(self, cr, uid, args):
39
if args.get('payment_method_id'):
40
payment_method = self.pool.get('payment.method').browse(cr, uid, args['payment_method_id'])
41
return payment_method.journal_id.id
40
def _get_journal_id(self, cr, uid, context=None):
43
if context.get('active_id'):
44
order = self.pool.get('sale.order').browse(cr, uid, context['active_id'], context=context)
45
if order.payment_method_id:
46
return order.payment_method_id.journal_id.id
44
def _get_amount(self, cr, uid, args):
45
if args.get('amount_total'):
46
return args['amount_total']
49
def _get_amount(self, cr, uid, context=None):
52
if context.get('active_id'):
53
order = self.pool.get('sale.order').browse(cr, uid, context['active_id'], context=context)
60
68
@param ids: List of account chart’s IDs
61
69
@return: dictionary of Product list window for a given attributs set
63
for wizard in self.browse(cr, uid, ids, context=context):
64
self.pool.get('sale.order').pay_sale_order(cr, uid, context['active_id'], wizard.journal_id.id, wizard.amount, wizard.date, context=context)
71
wizard = self.browse(cr, uid, ids[0], 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)
65
73
return {'type': 'ir.actions.act_window_close'}
75
def pay_sale_order_and_confirm(self, cr, uid, ids, context=None):
78
@param cr: the current row, from the database cursor,
79
@param uid: the current user’s ID for security checks,
80
@param ids: List of account chart’s IDs
81
@return: dictionary of Product list window for a given attributs set
83
self.pay_sale_order(cr, uid, ids, context=context)
84
return self.pool.get('sale.order').action_button_confirm(cr, uid, [context['active_id']], context=context)