parent
4f91796b0b
commit
c431b4647b
|
@ -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:
|
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'])
|
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)
|
account = self.pool.get('account.account').browse(cr, uid, account)
|
||||||
data['account_id'] = account.id
|
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 = partner_id and self.pool.get('res.partner').browse(cr, uid, partner_id) or False
|
||||||
# part = False is acceptable for fiscal position.
|
# 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)
|
account = self.pool.get('account.account').browse(cr, uid, account)
|
||||||
|
|
||||||
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
|
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
|
||||||
data['account_id'] = account.id
|
data['account_id'] = account.id
|
||||||
# Propose the price VAT excluded, the VAT will be added when confirming line
|
# Propose the price VAT excluded, the VAT will be added when confirming line
|
||||||
if account.tax_ids:
|
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)
|
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):
|
for t in self.pool.get('account.tax').compute_inv(cr, uid, tax, total, 1):
|
||||||
total -= t['amount']
|
total -= t['amount']
|
||||||
|
@ -472,10 +472,10 @@ class account_move_line(osv.osv):
|
||||||
if journal:
|
if journal:
|
||||||
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
|
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
|
||||||
if jt=='sale':
|
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':
|
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):
|
if val.get('account_id', False):
|
||||||
d = self.onchange_account_id(cr, uid, ids, val['account_id'])
|
d = self.onchange_account_id(cr, uid, ids, val['account_id'])
|
||||||
val.update(d['value'])
|
val.update(d['value'])
|
||||||
|
@ -489,7 +489,7 @@ class account_move_line(osv.osv):
|
||||||
tax_ids = res.tax_ids
|
tax_ids = res.tax_ids
|
||||||
if tax_ids and partner_id:
|
if tax_ids and partner_id:
|
||||||
part = self.pool.get('res.partner').browse(cr, uid, 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:
|
else:
|
||||||
tax_id = tax_ids and tax_ids[0].id or False
|
tax_id = tax_ids and tax_ids[0].id or False
|
||||||
val['account_tax_id'] = tax_id
|
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):
|
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
|
||||||
if not context:
|
if not context:
|
||||||
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')
|
account_obj = self.pool.get('account.account')
|
||||||
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
|
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']:
|
if data['tax_code_id']:
|
||||||
self.create(cr, uid, data, context)
|
self.create(cr, uid, data, context)
|
||||||
|
del vals['account_tax_id']
|
||||||
|
|
||||||
if not is_new_move and 'date' in vals:
|
if not is_new_move and 'date' in vals:
|
||||||
self.pool.get('account.move').write(cr, uid, [move_id], {'date':vals['date']}, context=context)
|
self.pool.get('account.move').write(cr, uid, [move_id], {'date':vals['date']}, context=context)
|
||||||
|
|
|
@ -732,7 +732,7 @@
|
||||||
<field name="state" select="2"/>
|
<field name="state" select="2"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Analytic Lines">
|
<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>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -255,7 +255,11 @@ class account_invoice(osv.osv):
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||||
'check_total': fields.float('Total', digits=(16,2), states={'open':[('readonly',True)],'close':[('readonly',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',
|
'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',
|
'partner_bank': fields.many2one('res.partner.bank', 'Bank Account',
|
||||||
help='The bank account to pay to or to be paid from'),
|
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'),
|
'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')
|
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)+')')
|
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()) )
|
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:
|
if l.account_id.id==src_account_id:
|
||||||
line_ids.append(l.id)
|
line_ids.append(l.id)
|
||||||
total += (l.debit or 0.0) - (l.credit or 0.0)
|
total += (l.debit or 0.0) - (l.credit or 0.0)
|
||||||
|
|
Loading…
Reference in New Issue