21
21
###############################################################################
23
from openerp.osv import osv, fields
26
class account_invoice(osv.Model):
23
from openerp.osv import orm, fields
25
class sale_order(orm.Model):
26
_inherit = "sale.order"
28
def _prepare_invoice(self, cr, uid, order, lines, context=None):
29
vals = super(sale_order, self)._prepare_invoice(cr, uid, order,
30
lines, context=context)
31
vals['payment_method_id'] = order.payment_method_id.id
35
class account_invoice(orm.Model):
27
36
_inherit = "account.invoice"
44
53
WHERE account_invoice.id = rel.invoice_id;
47
def _prepare_invoice(self, cr, uid, order, lines, context=None):
48
vals = super(account_invoice, self)._prepare_invoice(cr, uid, order,
49
lines, context=context)
50
vals['payment_method_id'] = order.payment_method_id.id
56
def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, context=None):
60
method_obj = self.pool['payment.method']
61
#compatibility for sale_payment_method_sale_journal
62
if method_obj._columns.get('sale_account_id'):
63
method = method_obj.browse(cr, uid, payment_method_id, context=context)
64
if method.sale_account_id:
65
res['value']['account_id'] = method.sale_account_id.id
66
if method.sale_journal_id:
67
res['value']['journal_id'] = method.sale_journal_id.id
70
def _prepare_refund(self, cr, uid, invoice_id, *args, **kwargs):
71
result = super(account_invoice, self)._prepare_refund(cr, uid, invoice_id, *args, **kwargs)
72
invoice = self.read(cr, uid, invoice_id, ['payment_method_id'], context=kwargs['context'])
73
result['payment_method_id'] = invoice['payment_method_id'][0]
b'\\ No newline at end of file'