Add partner bank on invoice
- new field partner_bank on invoice - use the partner bank for the payment - don't fill the payment line wizard by default bzr revid: ced-57fdec04527d5105ca707e17514424752dc14241
This commit is contained in:
parent
7b67622bb3
commit
5ea034d92a
|
@ -138,7 +138,9 @@
|
|||
<field name="date_due" select="1"/>
|
||||
<field name="reference_type" select="2" nolabel="1" size="0"/>
|
||||
<field name="reference" select="1" nolabel="1"/>
|
||||
<field name="name" select="2"/>
|
||||
<field name="partner_bank" select="2"
|
||||
domain="[('partner_id', '=', partner_id)]"
|
||||
on_change="onchange_partner_bank(partner_bank)"/>
|
||||
<field name="check_total" required="2"/>
|
||||
<field name="currency_id" on_change="onchange_currency_id(currency_id)" select="2"/>
|
||||
<field name="invoice_line" nolabel="1" colspan="4"
|
||||
|
@ -190,6 +192,7 @@
|
|||
<field name="company_id"/>
|
||||
<newline/>
|
||||
<field name="payment_term" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)" />
|
||||
<field name="name" select="2"/>
|
||||
<newline/>
|
||||
<field name="number" select="2"/>
|
||||
<field name="origin"/>
|
||||
|
|
|
@ -149,6 +149,8 @@ class account_invoice(osv.osv):
|
|||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'check_total': fields.float('Total', digits=(16,2), states={'open':[('readonly',True)],'close':[('readonly',True)]}),
|
||||
'reconciled': fields.function(_reconciled, method=True, string='Reconciled', type='boolean'),
|
||||
'partner_bank': fields.many2one('res.partner.bank', 'Bank Account',
|
||||
help='The partner bank account to pay\nKeep empty to use the default'),
|
||||
}
|
||||
_defaults = {
|
||||
'type': _get_type,
|
||||
|
@ -238,6 +240,9 @@ class account_invoice(osv.osv):
|
|||
def onchange_invoice_line(self, cr, uid, ids, lines):
|
||||
return {}
|
||||
|
||||
def onchange_partner_bank(self, cursor, user, ids, partner_bank_id):
|
||||
return {'value': {}}
|
||||
|
||||
# go from canceled state to draft state
|
||||
def action_cancel_draft(self, cr, uid, ids, *args):
|
||||
self.write(cr, uid, ids, {'state':'draft'})
|
||||
|
|
|
@ -81,7 +81,7 @@ class account_move_line(osv.osv):
|
|||
return [('id','=','0')]
|
||||
return [('id','in',map(lambda x:x[0], res))]
|
||||
|
||||
def line2bank(self,cr,uid,ids,payment_type= 'manual',context=None):
|
||||
def line2bank(self, cr, uid, ids, payment_type='manual', context=None):
|
||||
"""
|
||||
Try to return for each account move line a corresponding bank
|
||||
account according to the payment type. This work using one of
|
||||
|
@ -89,28 +89,22 @@ class account_move_line(osv.osv):
|
|||
associated to the line.
|
||||
Return the first suitable bank for the corresponding partner.
|
||||
"""
|
||||
if not ids: return {}
|
||||
bank_type= self.pool.get('payment.mode').suitable_bank_types(cr,uid,payment_type,context=context)
|
||||
cr.execute('''select DISTINCT l.id,b.id,b.state
|
||||
from account_invoice i
|
||||
join account_move m on (i.move_id = m.id)
|
||||
join account_move_line l on (m.id = l.move_id)
|
||||
join res_partner p on (p.id = i.partner_id)
|
||||
join res_partner_bank b on (p.id = b.partner_id)
|
||||
where l.id in (%s)
|
||||
''' % ",".join(map(str,ids)) )
|
||||
|
||||
r= cr.fetchall()
|
||||
type_ok=[]
|
||||
line2bank={}.fromkeys(ids)
|
||||
for line,bank,t in r:
|
||||
if not line2bank[line]:
|
||||
line2bank[line]= bank
|
||||
if t in bank_type:
|
||||
type_ok.append(line)
|
||||
elif (line not in type_ok) and (t in bank_type) :
|
||||
line2bank[line]= bank
|
||||
type_ok.append(line)
|
||||
payment_mode_obj = self.pool.get('payment.mode')
|
||||
line2bank = {}
|
||||
if not ids:
|
||||
return {}
|
||||
bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type,
|
||||
context=context)
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
if line.invoice and line.invoice.partner_bank:
|
||||
line2bank[line.id] = line.invoice.partner_bank.id
|
||||
elif line.partner:
|
||||
for bank in line.partner.bank_ids:
|
||||
if bank.state in bank_type:
|
||||
line2bank[line.id] = bank.id
|
||||
break
|
||||
if line.id not in line2bank and line.partner.bank_ids:
|
||||
line2bank[line.id] = line.partner.bank_ids[0].id
|
||||
return line2bank
|
||||
|
||||
_columns = {
|
||||
|
|
|
@ -52,7 +52,7 @@ def search_entries(self, cr, uid, data, context):
|
|||
<field name="entries" colspan="4" height="300" width="800" nolabel="1"
|
||||
domain="[('id', 'in', [%s])]"/>
|
||||
</form>''' % (','.join([str(x) for x in line_ids]))
|
||||
return {'entries': line_ids}
|
||||
return {}
|
||||
|
||||
def create_payment(self, cr, uid, data, context):
|
||||
line_ids= data['form']['entries'][0][2]
|
||||
|
|
Loading…
Reference in New Issue