parent
9b3bb243e5
commit
e88f1cb71a
|
@ -68,8 +68,9 @@ class account_payment_term(osv.osv):
|
||||||
pt = self.browse(cr, uid, id, context=context)
|
pt = self.browse(cr, uid, id, context=context)
|
||||||
amount = value
|
amount = value
|
||||||
result = []
|
result = []
|
||||||
|
obj_precision = self.pool.get('decimal.precision')
|
||||||
for line in pt.line_ids:
|
for line in pt.line_ids:
|
||||||
prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
|
prec = obj_precision.precision_get(cr, uid, 'Account')
|
||||||
if line.value == 'fixed':
|
if line.value == 'fixed':
|
||||||
amt = round(line.value_amount, prec)
|
amt = round(line.value_amount, prec)
|
||||||
elif line.value == 'procent':
|
elif line.value == 'procent':
|
||||||
|
@ -700,7 +701,7 @@ class account_journal(osv.osv):
|
||||||
return self.name_get(cr, user, ids, context=context)
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
def onchange_type(self, cr, uid, ids, type, currency):
|
def onchange_type(self, cr, uid, ids, type, currency):
|
||||||
data_pool = self.pool.get('ir.model.data')
|
obj_data = self.pool.get('ir.model.data')
|
||||||
user_pool = self.pool.get('res.users')
|
user_pool = self.pool.get('res.users')
|
||||||
|
|
||||||
type_map = {
|
type_map = {
|
||||||
|
@ -722,8 +723,8 @@ class account_journal(osv.osv):
|
||||||
if type in ('cash', 'bank') and currency and user.company_id.currency_id.id != currency:
|
if type in ('cash', 'bank') and currency and user.company_id.currency_id.id != currency:
|
||||||
view_id = 'account_journal_bank_view_multi'
|
view_id = 'account_journal_bank_view_multi'
|
||||||
|
|
||||||
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)])
|
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)])
|
||||||
data = data_pool.browse(cr, uid, data_id[0])
|
data = obj_data.browse(cr, uid, data_id[0])
|
||||||
|
|
||||||
res.update({
|
res.update({
|
||||||
'centralisation':type == 'situation',
|
'centralisation':type == 'situation',
|
||||||
|
@ -1155,7 +1156,7 @@ class account_move(osv.osv):
|
||||||
|
|
||||||
if not valid_moves:
|
if not valid_moves:
|
||||||
raise osv.except_osv(_('Integrity Error !'), _('You cannot validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !'))
|
raise osv.except_osv(_('Integrity Error !'), _('You cannot validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !'))
|
||||||
|
obj_sequence = self.pool.get('ir.sequence')
|
||||||
for move in self.browse(cr, uid, valid_moves):
|
for move in self.browse(cr, uid, valid_moves):
|
||||||
if move.name =='/':
|
if move.name =='/':
|
||||||
new_name = False
|
new_name = False
|
||||||
|
@ -1166,7 +1167,7 @@ class account_move(osv.osv):
|
||||||
else:
|
else:
|
||||||
if journal.sequence_id:
|
if journal.sequence_id:
|
||||||
c = {'fiscalyear_id': move.period_id.fiscalyear_id.id}
|
c = {'fiscalyear_id': move.period_id.fiscalyear_id.id}
|
||||||
new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c)
|
new_name = obj_sequence.get_id(cr, uid, journal.sequence_id.id, context=c)
|
||||||
else:
|
else:
|
||||||
raise osv.except_osv(_('Error'), _('No sequence defined on the journal !'))
|
raise osv.except_osv(_('Error'), _('No sequence defined on the journal !'))
|
||||||
|
|
||||||
|
@ -1266,6 +1267,7 @@ class account_move(osv.osv):
|
||||||
|
|
||||||
def unlink(self, cr, uid, ids, context={}, check=True):
|
def unlink(self, cr, uid, ids, context={}, check=True):
|
||||||
toremove = []
|
toremove = []
|
||||||
|
obj_move_line = self.pool.get('account.move.line')
|
||||||
for move in self.browse(cr, uid, ids, context):
|
for move in self.browse(cr, uid, ids, context):
|
||||||
if move['state'] != 'draft':
|
if move['state'] != 'draft':
|
||||||
raise osv.except_osv(_('UserError'),
|
raise osv.except_osv(_('UserError'),
|
||||||
|
@ -1274,8 +1276,8 @@ class account_move(osv.osv):
|
||||||
line_ids = map(lambda x: x.id, move.line_id)
|
line_ids = map(lambda x: x.id, move.line_id)
|
||||||
context['journal_id'] = move.journal_id.id
|
context['journal_id'] = move.journal_id.id
|
||||||
context['period_id'] = move.period_id.id
|
context['period_id'] = move.period_id.id
|
||||||
self.pool.get('account.move.line')._update_check(cr, uid, line_ids, context)
|
obj_move_line._update_check(cr, uid, line_ids, context)
|
||||||
self.pool.get('account.move.line').unlink(cr, uid, line_ids, context=context)
|
obj_move_line.unlink(cr, uid, line_ids, context=context)
|
||||||
toremove.append(move.id)
|
toremove.append(move.id)
|
||||||
result = super(account_move, self).unlink(cr, uid, toremove, context)
|
result = super(account_move, self).unlink(cr, uid, toremove, context)
|
||||||
return result
|
return result
|
||||||
|
@ -1349,12 +1351,13 @@ class account_move(osv.osv):
|
||||||
del context['__last_update']
|
del context['__last_update']
|
||||||
|
|
||||||
valid_moves = [] #Maintains a list of moves which can be responsible to create analytic entries
|
valid_moves = [] #Maintains a list of moves which can be responsible to create analytic entries
|
||||||
|
obj_analytic_line = self.pool.get('account.analytic.line')
|
||||||
|
obj_move_line = self.pool.get('account.move.line')
|
||||||
for move in self.browse(cr, uid, ids, context):
|
for move in self.browse(cr, uid, ids, context):
|
||||||
# Unlink old analytic lines on move_lines
|
# Unlink old analytic lines on move_lines
|
||||||
for obj_line in move.line_id:
|
for obj_line in move.line_id:
|
||||||
for obj in obj_line.analytic_lines:
|
for obj in obj_line.analytic_lines:
|
||||||
self.pool.get('account.analytic.line').unlink(cr,uid,obj.id)
|
obj_analytic_line.unlink(cr,uid,obj.id)
|
||||||
|
|
||||||
journal = move.journal_id
|
journal = move.journal_id
|
||||||
amount = 0
|
amount = 0
|
||||||
|
@ -1388,7 +1391,7 @@ class account_move(osv.osv):
|
||||||
continue
|
continue
|
||||||
# Update the move lines (set them as valid)
|
# Update the move lines (set them as valid)
|
||||||
|
|
||||||
self.pool.get('account.move.line').write(cr, uid, line_draft_ids, {
|
obj_move_line.write(cr, uid, line_draft_ids, {
|
||||||
'journal_id': move.journal_id.id,
|
'journal_id': move.journal_id.id,
|
||||||
'period_id': move.period_id.id,
|
'period_id': move.period_id.id,
|
||||||
'state': 'valid'
|
'state': 'valid'
|
||||||
|
@ -1408,7 +1411,7 @@ class account_move(osv.osv):
|
||||||
code = account[line.account_id.id][0]
|
code = account[line.account_id.id][0]
|
||||||
amount = account[line.account_id.id][1] * (line.debit + line.credit)
|
amount = account[line.account_id.id][1] * (line.debit + line.credit)
|
||||||
if (code or amount) and not (line.tax_code_id or line.tax_amount):
|
if (code or amount) and not (line.tax_code_id or line.tax_amount):
|
||||||
self.pool.get('account.move.line').write(cr, uid, [line.id], {
|
obj_move_line.write(cr, uid, [line.id], {
|
||||||
'tax_code_id': code,
|
'tax_code_id': code,
|
||||||
'tax_amount': amount
|
'tax_amount': amount
|
||||||
}, context, check=False)
|
}, context, check=False)
|
||||||
|
@ -1424,20 +1427,20 @@ class account_move(osv.osv):
|
||||||
#
|
#
|
||||||
self._centralise(cr, uid, move, 'debit', context=context)
|
self._centralise(cr, uid, move, 'debit', context=context)
|
||||||
self._centralise(cr, uid, move, 'credit', context=context)
|
self._centralise(cr, uid, move, 'credit', context=context)
|
||||||
self.pool.get('account.move.line').write(cr, uid, line_draft_ids, {
|
obj_move_line.write(cr, uid, line_draft_ids, {
|
||||||
'state': 'valid'
|
'state': 'valid'
|
||||||
}, context, check=False)
|
}, context, check=False)
|
||||||
else:
|
else:
|
||||||
# We can't validate it (it's unbalanced)
|
# We can't validate it (it's unbalanced)
|
||||||
# Setting the lines as draft
|
# Setting the lines as draft
|
||||||
self.pool.get('account.move.line').write(cr, uid, line_ids, {
|
obj_move_line.write(cr, uid, line_ids, {
|
||||||
'journal_id': move.journal_id.id,
|
'journal_id': move.journal_id.id,
|
||||||
'period_id': move.period_id.id,
|
'period_id': move.period_id.id,
|
||||||
'state': 'draft'
|
'state': 'draft'
|
||||||
}, context, check=False)
|
}, context, check=False)
|
||||||
# Create analytic lines for the valid moves
|
# Create analytic lines for the valid moves
|
||||||
for record in valid_moves:
|
for record in valid_moves:
|
||||||
self.pool.get('account.move.line').create_analytic_lines(cr, uid, [line.id for line in record.line_id], context)
|
obj_move_line.create_analytic_lines(cr, uid, [line.id for line in record.line_id], context)
|
||||||
|
|
||||||
valid_moves = [move.id for move in valid_moves]
|
valid_moves = [move.id for move in valid_moves]
|
||||||
return len(valid_moves) > 0 and valid_moves or False
|
return len(valid_moves) > 0 and valid_moves or False
|
||||||
|
@ -1521,13 +1524,14 @@ class account_tax_code(osv.osv):
|
||||||
GROUP BY line.tax_code_id',
|
GROUP BY line.tax_code_id',
|
||||||
(parent_ids,) + where_params)
|
(parent_ids,) + where_params)
|
||||||
res=dict(cr.fetchall())
|
res=dict(cr.fetchall())
|
||||||
|
obj_precision = self.pool.get('decimal.precision')
|
||||||
for record in self.browse(cr, uid, ids, context):
|
for record in self.browse(cr, uid, ids, context):
|
||||||
def _rec_get(record):
|
def _rec_get(record):
|
||||||
amount = res.get(record.id, 0.0)
|
amount = res.get(record.id, 0.0)
|
||||||
for rec in record.child_ids:
|
for rec in record.child_ids:
|
||||||
amount += _rec_get(rec) * rec.sign
|
amount += _rec_get(rec) * rec.sign
|
||||||
return amount
|
return amount
|
||||||
res[record.id] = round(_rec_get(record), self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
|
res[record.id] = round(_rec_get(record), obj_precision.precision_get(cr, uid, 'Account'))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _sum_year(self, cr, uid, ids, name, args, context=None):
|
def _sum_year(self, cr, uid, ids, name, args, context=None):
|
||||||
|
@ -1764,9 +1768,10 @@ class account_tax(osv.osv):
|
||||||
|
|
||||||
def _applicable(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
def _applicable(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
||||||
res = []
|
res = []
|
||||||
|
obj_partener_address = self.pool.get('res.partner.address')
|
||||||
for tax in taxes:
|
for tax in taxes:
|
||||||
if tax.applicable_type=='code':
|
if tax.applicable_type=='code':
|
||||||
localdict = {'price_unit':price_unit, 'address':self.pool.get('res.partner.address').browse(cr, uid, address_id), 'product':product, 'partner':partner}
|
localdict = {'price_unit':price_unit, 'address':obj_partener_address.browse(cr, uid, address_id), 'product':product, 'partner':partner}
|
||||||
exec tax.python_applicable in localdict
|
exec tax.python_applicable in localdict
|
||||||
if localdict.get('result', False):
|
if localdict.get('result', False):
|
||||||
res.append(tax)
|
res.append(tax)
|
||||||
|
@ -1778,6 +1783,7 @@ class account_tax(osv.osv):
|
||||||
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
||||||
res = []
|
res = []
|
||||||
cur_price_unit=price_unit
|
cur_price_unit=price_unit
|
||||||
|
obj_partener_address = self.pool.get('res.partner.address')
|
||||||
for tax in taxes:
|
for tax in taxes:
|
||||||
# we compute the amount for the current tax object and append it to the result
|
# we compute the amount for the current tax object and append it to the result
|
||||||
|
|
||||||
|
@ -1806,7 +1812,7 @@ class account_tax(osv.osv):
|
||||||
data['tax_amount']=quantity
|
data['tax_amount']=quantity
|
||||||
# data['amount'] = quantity
|
# data['amount'] = quantity
|
||||||
elif tax.type=='code':
|
elif tax.type=='code':
|
||||||
address = address_id and self.pool.get('res.partner.address').browse(cr, uid, address_id) or None
|
address = address_id and obj_partener_address.browse(cr, uid, address_id) or None
|
||||||
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
|
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
|
||||||
exec tax.python_compute in localdict
|
exec tax.python_compute in localdict
|
||||||
amount = localdict['result']
|
amount = localdict['result']
|
||||||
|
@ -1902,7 +1908,7 @@ class account_tax(osv.osv):
|
||||||
|
|
||||||
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
||||||
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
||||||
|
obj_partener_address = self.pool.get('res.partner.address')
|
||||||
res = []
|
res = []
|
||||||
taxes.reverse()
|
taxes.reverse()
|
||||||
cur_price_unit = price_unit
|
cur_price_unit = price_unit
|
||||||
|
@ -1927,7 +1933,7 @@ class account_tax(osv.osv):
|
||||||
amount = tax.amount
|
amount = tax.amount
|
||||||
|
|
||||||
elif tax.type=='code':
|
elif tax.type=='code':
|
||||||
address = address_id and self.pool.get('res.partner.address').browse(cr, uid, address_id) or None
|
address = address_id and obj_partener_address.browse(cr, uid, address_id) or None
|
||||||
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
|
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
|
||||||
exec tax.python_compute_inv in localdict
|
exec tax.python_compute_inv in localdict
|
||||||
amount = localdict['result']
|
amount = localdict['result']
|
||||||
|
@ -1986,8 +1992,9 @@ class account_tax(osv.osv):
|
||||||
"""
|
"""
|
||||||
res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id, product, partner=None)
|
res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id, product, partner=None)
|
||||||
total = 0.0
|
total = 0.0
|
||||||
|
obj_precision = self.pool.get('decimal.precision')
|
||||||
for r in res:
|
for r in res:
|
||||||
prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
|
prec = obj_precision.precision_get(cr, uid, 'Account')
|
||||||
if r.get('balance',False):
|
if r.get('balance',False):
|
||||||
r['amount'] = round(r['balance'] * quantity, prec) - total
|
r['amount'] = round(r['balance'] * quantity, prec) - total
|
||||||
else:
|
else:
|
||||||
|
@ -2197,11 +2204,12 @@ class account_subscription_line(osv.osv):
|
||||||
def move_create(self, cr, uid, ids, context=None):
|
def move_create(self, cr, uid, ids, context=None):
|
||||||
tocheck = {}
|
tocheck = {}
|
||||||
all_moves = []
|
all_moves = []
|
||||||
|
obj_model = self.pool.get('account.model')
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
datas = {
|
datas = {
|
||||||
'date': line.date,
|
'date': line.date,
|
||||||
}
|
}
|
||||||
move_ids = self.pool.get('account.model').generate(cr, uid, [line.subscription_id.model_id.id], datas, context)
|
move_ids = obj_model.generate(cr, uid, [line.subscription_id.model_id.id], datas, context)
|
||||||
tocheck[line.subscription_id.id] = True
|
tocheck[line.subscription_id.id] = True
|
||||||
self.write(cr, uid, [line.id], {'move_id':move_ids[0]})
|
self.write(cr, uid, [line.id], {'move_id':move_ids[0]})
|
||||||
all_moves.extend(move_ids)
|
all_moves.extend(move_ids)
|
||||||
|
@ -2552,9 +2560,9 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
obj_acc_template = self.pool.get('account.account.template')
|
obj_acc_template = self.pool.get('account.account.template')
|
||||||
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
|
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
|
||||||
obj_fiscal_position = self.pool.get('account.fiscal.position')
|
obj_fiscal_position = self.pool.get('account.fiscal.position')
|
||||||
data_pool = self.pool.get('ir.model.data')
|
obj_data = self.pool.get('ir.model.data')
|
||||||
analytic_journal_obj = self.pool.get('account.analytic.journal')
|
analytic_journal_obj = self.pool.get('account.analytic.journal')
|
||||||
|
obj_tax_code = self.pool.get('account.tax.code')
|
||||||
# Creating Account
|
# Creating Account
|
||||||
obj_acc_root = obj_multi.chart_template_id.account_root_id
|
obj_acc_root = obj_multi.chart_template_id.account_root_id
|
||||||
tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id
|
tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id
|
||||||
|
@ -2578,7 +2586,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
'company_id': company_id,
|
'company_id': company_id,
|
||||||
'sign': tax_code_template.sign,
|
'sign': tax_code_template.sign,
|
||||||
}
|
}
|
||||||
new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals)
|
new_tax_code = obj_tax_code.create(cr, uid, vals)
|
||||||
#recording the new tax code to do the mapping
|
#recording the new tax code to do the mapping
|
||||||
tax_code_template_ref[tax_code_template.id] = new_tax_code
|
tax_code_template_ref[tax_code_template.id] = new_tax_code
|
||||||
|
|
||||||
|
@ -2662,8 +2670,8 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
|
|
||||||
# Creating Journals Sales and Purchase
|
# Creating Journals Sales and Purchase
|
||||||
vals_journal={}
|
vals_journal={}
|
||||||
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')])
|
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')])
|
||||||
data = data_pool.browse(cr, uid, data_id[0])
|
data = obj_data.browse(cr, uid, data_id[0])
|
||||||
view_id = data.res_id
|
view_id = data.res_id
|
||||||
|
|
||||||
seq_id = obj_sequence.search(cr, uid, [('name','=','Account Journal')])[0]
|
seq_id = obj_sequence.search(cr, uid, [('name','=','Account Journal')])[0]
|
||||||
|
@ -2713,12 +2721,12 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
obj_journal.create(cr,uid,vals_journal)
|
obj_journal.create(cr,uid,vals_journal)
|
||||||
|
|
||||||
# Bank Journals
|
# Bank Journals
|
||||||
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')])
|
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')])
|
||||||
data = data_pool.browse(cr, uid, data_id[0])
|
data = obj_pool.browse(cr, uid, data_id[0])
|
||||||
view_id_cash = data.res_id
|
view_id_cash = data.res_id
|
||||||
|
|
||||||
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')])
|
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')])
|
||||||
data = data_pool.browse(cr, uid, data_id[0])
|
data = obj_data.browse(cr, uid, data_id[0])
|
||||||
view_id_cur = data.res_id
|
view_id_cur = data.res_id
|
||||||
ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id
|
ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id
|
||||||
|
|
||||||
|
@ -2807,6 +2815,10 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)])
|
fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)])
|
||||||
|
|
||||||
if fp_ids:
|
if fp_ids:
|
||||||
|
|
||||||
|
obj_tax_fp = self.pool.get('account.fiscal.position.tax')
|
||||||
|
obj_ac_fp = self.pool.get('account.fiscal.position.account')
|
||||||
|
|
||||||
for position in obj_fiscal_position_template.browse(cr, uid, fp_ids):
|
for position in obj_fiscal_position_template.browse(cr, uid, fp_ids):
|
||||||
|
|
||||||
vals_fp = {
|
vals_fp = {
|
||||||
|
@ -2815,9 +2827,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
}
|
}
|
||||||
new_fp = obj_fiscal_position.create(cr, uid, vals_fp)
|
new_fp = obj_fiscal_position.create(cr, uid, vals_fp)
|
||||||
|
|
||||||
obj_tax_fp = self.pool.get('account.fiscal.position.tax')
|
|
||||||
obj_ac_fp = self.pool.get('account.fiscal.position.account')
|
|
||||||
|
|
||||||
for tax in position.tax_ids:
|
for tax in position.tax_ids:
|
||||||
vals_tax = {
|
vals_tax = {
|
||||||
'tax_src_id' : tax_template_ref[tax.tax_src_id.id],
|
'tax_src_id' : tax_template_ref[tax.tax_src_id.id],
|
||||||
|
|
Loading…
Reference in New Issue