diff --git a/addons/account/account.py b/addons/account/account.py
index 1797563874a..61d38f3cd68 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -1127,7 +1127,7 @@ class account_tax(osv.osv):
'ref_tax_sign': fields.float('Tax Code Sign', help="Usualy 1 or -1."),
'include_base_amount': fields.boolean('Include in base amount', help="Indicate if the amount of tax must be included in the base amount for the computation of the next taxes"),
'company_id': fields.many2one('res.company', 'Company', required=True),
- 'description': fields.char('Internal Name', 32),
+ 'description': fields.char('Internal Name',size=32),
}
def name_get(self, cr, uid, ids, context={}):
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index b93afede487..795bae5fb83 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -49,9 +49,9 @@ class account_move_line(osv.osv):
if state:
if state.lower() not in ['all']:
where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')"
-
+
if context.get('periods', False):
- ids = ','.join([str(x) for x in context['periods']])
+ ids = ','.join([str(x) for x in context['periods']])
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state)
else:
return obj+".active AND "+obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state)
@@ -71,6 +71,9 @@ class account_move_line(osv.osv):
return data
period_obj = self.pool.get('account.period')
+ tax_obj=self.pool.get('account.tax')
+
+ tax_line=context.get('tax_line',False)
# Compute the current move
move_id = False
@@ -86,6 +89,7 @@ class account_move_line(osv.osv):
(context['journal_id'], context['period_id'], uid, 'draft'))
res = cr.fetchone()
move_id = (res and res[0]) or False
+
if not move_id:
return data
else:
@@ -113,10 +117,33 @@ class account_move_line(osv.osv):
ref_id = False
taxes = {}
move = self.pool.get('account.move').browse(cr, uid, move_id, context)
+
for l in move.line_id:
partner_id = partner_id or l.partner_id.id
ref_id = ref_id or l.ref
- total += (l.debit - l.credit)
+
+ final_debit=l.debit
+ final_credit=l.credit
+
+ if 'name' in fields:
+ data.setdefault('name', l.name)
+
+ if l.amount_taxed:
+ if l.debit:
+ final_debit=l.amount_taxed
+ if not tax_line:
+ final_debit= l.debit - final_debit
+
+ if l.credit:
+ final_credit=l.amount_taxed
+ if not tax_line:
+ final_credit =l.credit - final_credit
+ total += (final_debit - final_credit)
+
+ else:
+ if len(move.line_id)==1:
+ total += (final_debit - final_credit)
+
for tax in l.account_id.tax_ids:
if move.journal_id.type == 'sale':
if l.debit:
@@ -134,8 +161,7 @@ class account_move_line(osv.osv):
acc = tax.account_paid_id.id
taxes.setdefault((acc, code), False)
taxes[(l.account_id.id, l.tax_code_id.id)] = True
- if 'name' in fields:
- data.setdefault('name', l.name)
+
if 'ref' in fields:
data['ref'] = ref_id
@@ -172,7 +198,9 @@ class account_move_line(osv.osv):
s -= tax['amount']
tax_amount += tax['amount'] * \
tax[field_base + 'tax_sign']
+
if ('debit' in fields) or ('credit' in fields):
+
data['debit'] = s>0 and s or 0.0
data['credit'] = s<0 and -s or 0.0
@@ -334,6 +362,9 @@ class account_move_line(osv.osv):
'tax_amount': fields.float('Tax/Base Amount', digits=(16,2), select=True),
'invoice': fields.function(_invoice, method=True, string='Invoice',
type='many2one', relation='account.invoice', fnct_search=_invoice_search),
+ 'account_tax_id':fields.many2one('account.tax', 'Tax'),
+ 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'),
+ 'amount_taxed':fields.float("Taxed Amount",digits=(16,2)),
}
def _get_date(self, cr, uid, context):
@@ -632,7 +663,19 @@ class account_move_line(osv.osv):
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
if not context:
context={}
+ raise_ex=False
account_obj = self.pool.get('account.account')
+ acc=account_obj.browse(cr,uid,ids)[0]
+
+ if ('debit' in vals and 'credit' in vals) and not vals['debit'] and not vals['credit']:
+ raise_ex=True
+ if ('debit' in vals and 'credit' not in vals) and not vals['debit'] and not acc.credit:
+ raise_ex=True
+ if ('credit' in vals and 'debit' not in vals) and not vals['credit'] and not acc.debit:
+ raise_ex=True
+
+ if raise_ex:
+ raise osv.except_osv(_('Wrong Accounting Entry!'), _('Both Credit and Debit cannot be zero!'))
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
@@ -680,7 +723,11 @@ class account_move_line(osv.osv):
def create(self, cr, uid, vals, context=None, check=True):
if not context:
context={}
+
+ if not vals['debit'] and not vals['credit']:
+ raise osv.except_osv(_('Wrong Accounting Entry!'), _('Both Credit and Debit cannot be zero!'))
account_obj = self.pool.get('account.account')
+ tax_obj=self.pool.get('account.tax')
if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']:
raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!'))
@@ -743,7 +790,26 @@ class account_move_line(osv.osv):
vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx)
if not ok:
raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !'))
+
+ tax_go=False
+ if 'account_tax_id' in vals and vals['account_tax_id']:
+ tax_id=tax_obj.browse(cr,uid,vals['account_tax_id'])
+
+ if vals['debit']:
+ vals['amount_taxed']=tax_obj.compute(cr,uid,[tax_id],vals['debit'],1.00)[0]['amount']
+ vals['debit'] +=vals['amount_taxed']
+ if vals['credit']:
+ vals['amount_taxed']=tax_obj.compute(cr,uid,[tax_id],vals['credit'],1.00)[0]['amount']
+ vals['credit'] +=vals['amount_taxed']
+ fields=[x for x in vals]
+ tax_go=True
+
result = super(osv.osv, self).create(cr, uid, vals, context)
+ if tax_go:
+ context['tax_line']=True
+ if vals['amount_taxed']:
+ data_tax=self._default_get(cr, uid, fields, context=context)
+ self.create(cr,uid,data_tax)
if check:
self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context)
return result
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 1b50734c4b6..07d6c1143e4 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -674,6 +674,8 @@
+
+
@@ -716,6 +718,9 @@
+
+
+
@@ -764,6 +769,9 @@
+
+
+
@@ -1365,6 +1373,8 @@
+
+
diff --git a/addons/account/data/account_data2.xml b/addons/account/data/account_data2.xml
index 9f51843efd2..02475a31902 100644
--- a/addons/account/data/account_data2.xml
+++ b/addons/account/data/account_data2.xml
@@ -1,10 +1,10 @@
-
+
+ -->
30 Days Net
@@ -15,7 +15,7 @@
net days
-
+
@@ -74,6 +74,18 @@
credit
+
+
+ Tax
+ account_tax_id
+
+
+
+
+ Analytic Account
+ analytic_account_id
+
+
Ref
@@ -84,9 +96,9 @@
State
state
-
+
-
+
Multi-Currency Cash Journal View
@@ -142,17 +154,29 @@
credit
+
+
+ Tax
+ account_tax_id
+
+
+
+
+ Analytic Account
+ analytic_account_id
+
+
Currency Amt.
amount_currency
-
+
Currency
currency_id
-
+
@@ -164,10 +188,10 @@
State
state
-
+
-
-
+
+
Journal View
@@ -229,30 +253,42 @@
credit
+
+
+ Tax
+ account_tax_id
+
+
+
+
+ Analytic Account
+ analytic_account_id
+
+
Tax Acc.
tax_code_id
-
+
Tax
tax_amount
-
+
State
state
-
+
-
-
+
+
-
+
Account Journal
account.journal
@@ -262,11 +298,11 @@
account.journal
-
+
-
+
Account reconcile sequence
account.reconcile
@@ -278,8 +314,8 @@
-
-
+
+
Bank Statement
account.bank.statement
@@ -291,11 +327,11 @@
-
+
-
+
Sales Journal
SAJ
@@ -316,7 +352,7 @@
-
+
Bank Journal
BNK
@@ -327,7 +363,7 @@
-
+
Stock Journal
STJ
@@ -336,6 +372,6 @@
-
+
\ No newline at end of file