bzr revid: fp@tinyerp.com-20090126222232-4fbo8te2gzwhkv6n
This commit is contained in:
Fabien Pinckaers 2009-01-26 23:22:32 +01:00
parent 4f91796b0b
commit c431b4647b
3 changed files with 16 additions and 9 deletions

View File

@ -115,7 +115,7 @@ class account_move_line(osv.osv):
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)) and 'partner_id' in data:
part = self.pool.get('res.partner').browse(cr, uid, data['partner_id'])
account = self.pool.get('account.fiscal.position').map_account(cr, uid, part.property_account_position, account.id)
account = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, account.id)
account = self.pool.get('account.account').browse(cr, uid, account)
data['account_id'] = account.id
@ -199,14 +199,14 @@ class account_move_line(osv.osv):
part = partner_id and self.pool.get('res.partner').browse(cr, uid, partner_id) or False
# part = False is acceptable for fiscal position.
account = self.pool.get('account.fiscal.position').map_account(cr, uid, part.property_account_position, account.id)
account = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, account.id)
account = self.pool.get('account.account').browse(cr, uid, account)
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
data['account_id'] = account.id
# Propose the price VAT excluded, the VAT will be added when confirming line
if account.tax_ids:
taxes = self.pool.get('account.fiscal.position').map_tax(cr, uid, part.property_account_position, account.tax_ids)
taxes = self.pool.get('account.fiscal.position').map_tax(cr, uid, part and part.property_account_position or False, account.tax_ids)
tax = self.pool.get('account.tax').browse(cr, uid, taxes)
for t in self.pool.get('account.tax').compute_inv(cr, uid, tax, total, 1):
total -= t['amount']
@ -472,10 +472,10 @@ class account_move_line(osv.osv):
if journal:
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
if jt=='sale':
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part.property_account_position, id2)
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2)
elif jt=='purchase':
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part.property_account_position, id1)
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1)
if val.get('account_id', False):
d = self.onchange_account_id(cr, uid, ids, val['account_id'])
val.update(d['value'])
@ -489,7 +489,7 @@ class account_move_line(osv.osv):
tax_ids = res.tax_ids
if tax_ids and partner_id:
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, part.property_account_position, tax_ids)[0]
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, part and part.property_account_position or False, tax_ids)[0]
else:
tax_id = tax_ids and tax_ids[0].id or False
val['account_tax_id'] = tax_id
@ -719,6 +719,8 @@ class account_move_line(osv.osv):
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
if not context:
context={}
if vals.get('account_tax_id', False):
raise osv.except_osv(_('Unable to change tax !'), _('You can not change the tax, you should remove and recreate lines !'))
account_obj = self.pool.get('account.account')
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
@ -929,6 +931,7 @@ class account_move_line(osv.osv):
}
if data['tax_code_id']:
self.create(cr, uid, data, context)
del vals['account_tax_id']
if not is_new_move and 'date' in vals:
self.pool.get('account.move').write(cr, uid, [move_id], {'date':vals['date']}, context=context)

View File

@ -732,7 +732,7 @@
<field name="state" select="2"/>
</page>
<page string="Analytic Lines">
<field colspan="4" name="analytic_lines" nolabel="1"/>
<field colspan="4" name="analytic_lines" nolabel="1" context="{'default_general_account_id':account_id, 'default_name': name, 'default_date':date, 'amount': (debit or 0.0)-(credit or 0.0)}"/>
</page>
</notebook>
</form>

View File

@ -255,7 +255,11 @@ 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='Paid/Reconciled', type='boolean',
store=True, help="The account moves of the invoice have been reconciled with account moves of the payment(s)."),
store={
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, None, 50),
'account.move.line': (_get_invoice_from_line, None, 50),
'account.move.reconcile': (_get_invoice_from_reconcile, None, 50),
}, help="The account moves of the invoice have been reconciled with account moves of the payment(s)."),
'partner_bank': fields.many2one('res.partner.bank', 'Bank Account',
help='The bank account to pay to or to be paid from'),
'move_lines':fields.function(_get_lines , method=True,type='many2many' , relation='account.move.line',string='Move Lines'),
@ -875,7 +879,7 @@ class account_invoice(osv.osv):
line = self.pool.get('account.move.line')
cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')')
lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) )
for l in lines:
for l in lines+invoice.payment_ids:
if l.account_id.id==src_account_id:
line_ids.append(l.id)
total += (l.debit or 0.0) - (l.credit or 0.0)