From fc6ac83608e7b55f6206afe91377840788a5cd79 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 17 Feb 2015 15:35:08 +0100 Subject: [PATCH 1/4] [FIX] mail: hide delete button when uploading attachment This is not possible to interrupt the uploading of an attachment. We therefore hide the 'delete' button during the upload --- addons/mail/static/src/xml/mail.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 1e52105c739..1ec8e0bf879 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -93,7 +93,7 @@
-
[
+
[
uploading
@@ -105,7 +105,7 @@
-
[
+
[
uploading
From 7f5bc3fdf0a5d40bcaec8f5170e04a8191a95499 Mon Sep 17 00:00:00 2001 From: Somesh Khare Date: Tue, 2 Dec 2014 15:54:56 +0530 Subject: [PATCH 2/4] [Fix] hr_expense: correct amount for included tax with negative sign Setting an expense with a tax included with a negative base code sign was getting the wrong amount (tax line as a credit instead of debit). So leading to a total for the accounting entry superior of the total of the expense (should not happend as the tax is included). Add test to verify this scenario. Fixes #4260, opw 618531 --- addons/hr_expense/hr_expense.py | 4 +- addons/hr_expense/tests/__init__.py | 5 ++ .../hr_expense/tests/test_journal_entries.py | 61 +++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 addons/hr_expense/tests/__init__.py create mode 100644 addons/hr_expense/tests/test_journal_entries.py diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index e14e79aaa32..e744ead5544 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -317,7 +317,7 @@ class hr_expense_expense(osv.osv): is_price_include = tax_obj.read(cr,uid,tax['id'],['price_include'],context)['price_include'] if is_price_include: ## 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 base_tax_amount = (base_tax_amount - tax['amount']) * tax['base_sign'] else: @@ -328,7 +328,7 @@ class hr_expense_expense(osv.osv): 'name':tax['name'], 'price_unit': tax['price_unit'], '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'], 'tax_code_id': tax['tax_code_id'], 'tax_amount': tax['amount'] * tax['base_sign'], diff --git a/addons/hr_expense/tests/__init__.py b/addons/hr_expense/tests/__init__.py new file mode 100644 index 00000000000..8c94d56e555 --- /dev/null +++ b/addons/hr_expense/tests/__init__.py @@ -0,0 +1,5 @@ +from . import test_journal_entries + +fast_suite = [ + test_journal_entries +] \ No newline at end of file diff --git a/addons/hr_expense/tests/test_journal_entries.py b/addons/hr_expense/tests/test_journal_entries.py new file mode 100644 index 00000000000..55251486607 --- /dev/null +++ b/addons/hr_expense/tests/test_journal_entries.py @@ -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') From 27a48f8026f824f62955d5bf2a83b2799ad98db1 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 20 Feb 2015 15:24:18 +0100 Subject: [PATCH 3/4] [FIX] web: action translation (menuitems & more menu) This rev. reverts partially 1d76586a1b0fff766581871cd277332bbfec030a This rev. is related to #3462 Regarding addons/web/controllers/main.py --- name of model ir.actions.actions is not translated it's the name of server actions, client actions and window actions that are translated. Meaning the name of the ir.actions.actions will always be in English, even when passing the user language within the context. Regarding addons/web/static/src/js/views.js --- There is no reason to pass the field values within the context of the /web/action/load call: The read methods of actions are not overidden to use the field values. Besides, it pollutes the context of the action, leading to unwanted behavior, such as the translation of the action name within the lang available in the fields of the form view (e.g. the partner form). Initially, the field values added in the context has been added within the rev. 542928adde6f74269f51d24e18896b2e8bb44fc2 Indeed, sidebar_context (or sidebar_eval_context nowadays), contains the field values, and the additional_context passed to /web/action/load is an extension of this sidebar_context. We are not sure the reasons why the sidebar_context was passed to the /web/action/load, but we believe it was to pass the session/user context containing the lang, timezone, and so on, not to pass the fields values. --- addons/web/controllers/main.py | 4 ++-- addons/web/static/src/js/views.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index f5c31b2d1bf..b3acbbe5119 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1422,7 +1422,7 @@ class Action(openerpweb.Controller): except Exception: action_id = 0 # force failed read - base_action = Actions.read([action_id], ['name', 'type'], req.session.get_context()) + base_action = Actions.read([action_id], ['type'], req.context) if base_action: ctx = {} action_type = base_action[0]['type'] @@ -1431,7 +1431,7 @@ class Action(openerpweb.Controller): ctx.update(req.context) action = req.session.model(action_type).read([action_id], False, ctx) if action: - value = clean_action(req, dict(action[0], **base_action[0])) + value = clean_action(req, action[0]) return value @openerpweb.jsonrequest diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 5fa3c8fb290..5ae8bfc79fc 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1220,7 +1220,8 @@ instance.web.Sidebar = instance.web.Widget.extend({ sidebar_eval_context, active_ids_context)); self.rpc("/web/action/load", { action_id: item.action.id, - context: c + context: new instance.web.CompoundContext( + self.dataset.get_context(), active_ids_context).eval() }).done(function(result) { result.context = new instance.web.CompoundContext( result.context || {}, active_ids_context) From aae75f1e297cb6b370bac7341f54f310923fe5dc Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 20 Feb 2015 16:19:44 +0100 Subject: [PATCH 4/4] [FIX] hr_expense: deprecated use of LocalService() Introduced in a test, during the forward port 7613d5d49915b2257c9730dc0483ce0df2828b9f --- addons/hr_expense/tests/test_journal_entries.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/hr_expense/tests/test_journal_entries.py b/addons/hr_expense/tests/test_journal_entries.py index 55251486607..4df277c3f49 100644 --- a/addons/hr_expense/tests/test_journal_entries.py +++ b/addons/hr_expense/tests/test_journal_entries.py @@ -1,5 +1,5 @@ from openerp.tests.common import TransactionCase -from openerp import netsvc +from openerp import netsvc, workflow class TestCheckJournalEntry(TransactionCase): @@ -13,7 +13,6 @@ class TestCheckJournalEntry(TransactionCase): 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") @@ -43,11 +42,11 @@ class TestCheckJournalEntry(TransactionCase): 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) + workflow.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) + workflow.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) + workflow.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')