[MERGE] forward port of branch 7.0 up to 27a48f8
This commit is contained in:
commit
7613d5d499
|
@ -319,7 +319,7 @@ class hr_expense_expense(osv.osv):
|
||||||
is_price_include = tax_obj.read(cr,uid,tax['id'],['price_include'],context)['price_include']
|
is_price_include = tax_obj.read(cr,uid,tax['id'],['price_include'],context)['price_include']
|
||||||
if is_price_include:
|
if is_price_include:
|
||||||
## We need to deduce the price for the tax
|
## We need to deduce the price for the tax
|
||||||
res[-1]['price'] = res[-1]['price'] - (tax['amount'] * tax['base_sign'] or 0.0)
|
res[-1]['price'] = res[-1]['price'] - tax['amount']
|
||||||
# tax amount countains base amount without the tax
|
# tax amount countains base amount without the tax
|
||||||
base_tax_amount = (base_tax_amount - tax['amount']) * tax['base_sign']
|
base_tax_amount = (base_tax_amount - tax['amount']) * tax['base_sign']
|
||||||
else:
|
else:
|
||||||
|
@ -330,7 +330,7 @@ class hr_expense_expense(osv.osv):
|
||||||
'name':tax['name'],
|
'name':tax['name'],
|
||||||
'price_unit': tax['price_unit'],
|
'price_unit': tax['price_unit'],
|
||||||
'quantity': 1,
|
'quantity': 1,
|
||||||
'price': tax['amount'] * tax['base_sign'] or 0.0,
|
'price': tax['amount'] or 0.0,
|
||||||
'account_id': tax['account_collected_id'] or mres['account_id'],
|
'account_id': tax['account_collected_id'] or mres['account_id'],
|
||||||
'tax_code_id': tax['tax_code_id'],
|
'tax_code_id': tax['tax_code_id'],
|
||||||
'tax_amount': tax['amount'] * tax['base_sign'],
|
'tax_amount': tax['amount'] * tax['base_sign'],
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
from . import test_journal_entries
|
||||||
|
|
||||||
|
fast_suite = [
|
||||||
|
test_journal_entries
|
||||||
|
]
|
|
@ -0,0 +1,61 @@
|
||||||
|
from openerp.tests.common import TransactionCase
|
||||||
|
from openerp import netsvc
|
||||||
|
|
||||||
|
|
||||||
|
class TestCheckJournalEntry(TransactionCase):
|
||||||
|
"""
|
||||||
|
Check journal entries when the expense product is having tax which is tax included.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestCheckJournalEntry, self).setUp()
|
||||||
|
cr, uid = self.cr, self.uid
|
||||||
|
self.expense_obj = self.registry('hr.expense.expense')
|
||||||
|
self.exp_line_obj = self.registry('hr.expense.line')
|
||||||
|
self.product_obj = self.registry('product.product')
|
||||||
|
self.wf_service = netsvc.LocalService('workflow')
|
||||||
|
self.tax_obj = self.registry('account.tax')
|
||||||
|
self.code_obj = self.registry('account.tax.code')
|
||||||
|
_, self.product_id = self.registry("ir.model.data").get_object_reference(cr, uid, "hr_expense", "air_ticket")
|
||||||
|
_, self.employee_id = self.registry("ir.model.data").get_object_reference(cr, uid, "hr", "employee_mit")
|
||||||
|
self.base_code_id = self.code_obj.create(cr, uid, {'name': 'Expense Base Code'})
|
||||||
|
self.tax_id = self.tax_obj.create(cr, uid, {
|
||||||
|
'name': 'Expense 10%',
|
||||||
|
'amount': 0.10,
|
||||||
|
'type': 'percent',
|
||||||
|
'type_tax_use': 'purchase',
|
||||||
|
'price_include': True,
|
||||||
|
'base_code_id': self.base_code_id,
|
||||||
|
'base_sign': -1,
|
||||||
|
})
|
||||||
|
self.product_obj.write(cr, uid, self.product_id, {'supplier_taxes_id': [(6, 0, [self.tax_id])]})
|
||||||
|
self.expense_id = self.expense_obj.create(cr, uid, {
|
||||||
|
'name': 'Expense for Minh Tran',
|
||||||
|
'employee_id': self.employee_id,
|
||||||
|
})
|
||||||
|
self.exp_line_obj.create(cr, uid, {
|
||||||
|
'name': 'Car Travel Expenses',
|
||||||
|
'product_id': self.product_id,
|
||||||
|
'unit_amount': 700.00,
|
||||||
|
'expense_id': self.expense_id
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_journal_entry(self):
|
||||||
|
cr, uid = self.cr, self.uid
|
||||||
|
#Submit to Manager
|
||||||
|
self.wf_service.trg_validate(uid, 'hr.expense.expense', self.expense_id, 'confirm', cr)
|
||||||
|
#Approve
|
||||||
|
self.wf_service.trg_validate(uid, 'hr.expense.expense', self.expense_id, 'validate', cr)
|
||||||
|
#Create Expense Entries
|
||||||
|
self.wf_service.trg_validate(uid, 'hr.expense.expense', self.expense_id, 'done', cr)
|
||||||
|
self.expense = self.expense_obj.browse(cr, uid, self.expense_id)
|
||||||
|
self.assertEquals(self.expense.state, 'done', 'Expense is not in Waiting Payment state')
|
||||||
|
self.assertTrue(self.expense.account_move_id.id, 'Expense Journal Entry is not created')
|
||||||
|
for line in self.expense.account_move_id.line_id:
|
||||||
|
if line.credit:
|
||||||
|
self.assertEquals(line.credit, 700.00, 'Expense Payable Amount is not matched for journal item')
|
||||||
|
else:
|
||||||
|
if line.tax_code_id:
|
||||||
|
self.assertEquals(line.debit, 636.36, 'Tax Amount is not matched for journal item')
|
||||||
|
else:
|
||||||
|
self.assertEquals(line.debit, 63.64, 'Tax Base Amount is not matched for journal item')
|
|
@ -95,7 +95,7 @@
|
||||||
<img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.file_type_icon + '.png'"></img>
|
<img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.file_type_icon + '.png'"></img>
|
||||||
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
||||||
</a>
|
</a>
|
||||||
<div class='oe_delete oe_e' title="Delete this attachment" t-att-data-id="attachment.id">[</div>
|
<div t-if="!attachment.upload" class='oe_delete oe_e' title="Delete this attachment" t-att-data-id="attachment.id">[</div>
|
||||||
<div class='oe_progress_bar'>
|
<div class='oe_progress_bar'>
|
||||||
uploading
|
uploading
|
||||||
</div>
|
</div>
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
<img t-att-src="widget.attachments_resize_image(attachment.id, [100,80])"></img>
|
<img t-att-src="widget.attachments_resize_image(attachment.id, [100,80])"></img>
|
||||||
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
||||||
</a>
|
</a>
|
||||||
<div class='oe_delete oe_e' title="Delete this attachment" t-att-data-id="attachment.id">[</div>
|
<div t-if="!attachment.upload" class='oe_delete oe_e' title="Delete this attachment" t-att-data-id="attachment.id">[</div>
|
||||||
<div class='oe_progress_bar'>
|
<div class='oe_progress_bar'>
|
||||||
uploading
|
uploading
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1527,7 +1527,7 @@ class Action(http.Controller):
|
||||||
except Exception:
|
except Exception:
|
||||||
action_id = 0 # force failed read
|
action_id = 0 # force failed read
|
||||||
|
|
||||||
base_action = Actions.read([action_id], ['name', 'type'], request.context)
|
base_action = Actions.read([action_id], ['type'], request.context)
|
||||||
if base_action:
|
if base_action:
|
||||||
ctx = {}
|
ctx = {}
|
||||||
action_type = base_action[0]['type']
|
action_type = base_action[0]['type']
|
||||||
|
@ -1536,7 +1536,7 @@ class Action(http.Controller):
|
||||||
ctx.update(request.context)
|
ctx.update(request.context)
|
||||||
action = request.session.model(action_type).read([action_id], False, ctx)
|
action = request.session.model(action_type).read([action_id], False, ctx)
|
||||||
if action:
|
if action:
|
||||||
value = clean_action(dict(action[0], **base_action[0]))
|
value = clean_action(action[0])
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@http.route('/web/action/run', type='json', auth="user")
|
@http.route('/web/action/run', type='json', auth="user")
|
||||||
|
|
|
@ -1271,7 +1271,8 @@ instance.web.Sidebar = instance.web.Widget.extend({
|
||||||
|
|
||||||
self.rpc("/web/action/load", {
|
self.rpc("/web/action/load", {
|
||||||
action_id: item.action.id,
|
action_id: item.action.id,
|
||||||
context: c
|
context: new instance.web.CompoundContext(
|
||||||
|
self.dataset.get_context(), active_ids_context).eval()
|
||||||
}).done(function(result) {
|
}).done(function(result) {
|
||||||
result.context = new instance.web.CompoundContext(
|
result.context = new instance.web.CompoundContext(
|
||||||
result.context || {}, active_ids_context)
|
result.context || {}, active_ids_context)
|
||||||
|
|
Loading…
Reference in New Issue