From 5627e1e297f435a345f12af09c6bcc6d115add02 Mon Sep 17 00:00:00 2001 From: Haresh Chavda Date: Thu, 25 Jan 2018 12:37:16 +0530 Subject: [PATCH] [IMP/ADD] Add Sales and Account Test Cases and Remove sent by code in flectra --- .../account_discount/tests/discount_common.py | 19 +++-- .../tests/test_01_account_discount.py | 74 ++++++++++++++----- .../tests/test_02_account_discount_invoice.py | 7 ++ addons/auth_signup/data/auth_signup_data.xml | 9 --- addons/event/data/email_template_data.xml | 2 - .../data/hr_recruitment_data.xml | 3 - addons/mail/data/mail_data.xml | 12 --- addons/rating_project/data/project_data.xml | 1 - .../sales_discount/tests/discount_common.py | 4 + .../tests/test_01_sale_order_discount.py | 66 ++++++++++++----- .../tests/test_02_so_discount_invoice.py | 11 +++ .../website_quote/data/website_quote_data.xml | 5 -- 12 files changed, 137 insertions(+), 76 deletions(-) diff --git a/addons/account_discount/tests/discount_common.py b/addons/account_discount/tests/discount_common.py index cfb391fd..9af42c56 100644 --- a/addons/account_discount/tests/discount_common.py +++ b/addons/account_discount/tests/discount_common.py @@ -20,10 +20,11 @@ class TestDiscountCommon(TransactionCase): 'fix_amount': 3000.0, 'percentage': 20.0, }) - ir_model_data_obj = self.env['ir.model.data'] - account_acccount_obj = self.env['account.account'] - journal_obj = self.env['account.journal'] + AccountAccount = self.env['account.account'] + AccountJournal = self.env['account.journal'] + self.AccountInvoice = self.env['account.invoice'] + self.AccountInvoiceLine = self.env['account.invoice.line'] company_id = \ ir_model_data_obj.xmlid_to_res_id('base.main_company') or False user_type_payable_id = ir_model_data_obj.xmlid_to_res_id( @@ -33,13 +34,13 @@ class TestDiscountCommon(TransactionCase): self.user_type_revenue_id = ir_model_data_obj.xmlid_to_res_id( 'account.data_account_type_revenue') - self.account_type_payable_id = account_acccount_obj.create({ + self.account_type_payable_id = AccountAccount.create({ 'name': 'Test Payable Account', 'code': 'TestPA', 'reconcile': True, 'user_type_id': user_type_payable_id}) - self.account_type_receivable_id = account_acccount_obj.create({ + self.account_type_receivable_id = AccountAccount.create({ 'name': 'Test Reiceivable Account', 'code': 'TestRA', 'reconcile': True, @@ -52,8 +53,14 @@ class TestDiscountCommon(TransactionCase): 'email': 'testpartner@test.com', }) - self.journal_id = journal_obj.create({ + self.journal_id = AccountJournal.create({ 'name': 'Test Journal', 'code': 'Journal001', 'type': 'sale', 'company_id': company_id}) + + self.account_id = AccountAccount.create({ + 'name': 'Test', + 'code': 'DA', + 'user_type_id': self.user_type_revenue_id, + }) diff --git a/addons/account_discount/tests/test_01_account_discount.py b/addons/account_discount/tests/test_01_account_discount.py index b3100190..abaf6215 100644 --- a/addons/account_discount/tests/test_01_account_discount.py +++ b/addons/account_discount/tests/test_01_account_discount.py @@ -10,14 +10,7 @@ class TestInvoiceDiscount(TestDiscountCommon): super(TestInvoiceDiscount, self).setUp() def discount_01_set_fixamount(self): - - self.account_id = self.env['account.account'].create({ - 'name': 'Test', - 'code': 'DA', - 'user_type_id': self.user_type_revenue_id, - }) - - invoice_id = self.env['account.invoice'].create({ + invoice_id = self.AccountInvoice.create({ 'name': 'Discount Invoice Test Fixed', 'partner_id': self.partner_id.id, 'currency_id': self.env.ref('base.USD').id, @@ -27,7 +20,7 @@ class TestInvoiceDiscount(TestDiscountCommon): 'journal_id': self.journal_id.id, }) invoice_id.onchange_discount_method() - self.env['account.invoice.line'].create({ + self.AccountInvoiceLine.create({ 'product_id': self.env.ref("product.product_product_10").id, 'quantity': 10, 'price_unit': 400, @@ -35,7 +28,7 @@ class TestInvoiceDiscount(TestDiscountCommon): 'name': 'Mouse, Optical', 'account_id': self.account_id.id, }) - self.env['account.invoice.line'].create({ + self.AccountInvoiceLine.create({ 'product_id': self.env.ref("product.product_product_12").id, 'quantity': 30, 'price_unit': 250, @@ -56,13 +49,8 @@ class TestInvoiceDiscount(TestDiscountCommon): return invoice_id def discount_02_set_percentages(self): - self.account_id = self.env['account.account'].create({ - 'name': 'Test', - 'code': 'DA', - 'user_type_id': self.user_type_revenue_id, - }) - invoice_id = self.env['account.invoice'].create({ - 'name': 'Discount Invoice Test', + invoice_id = self.AccountInvoice.create({ + 'name': 'Discount Invoice Test Percentage', 'partner_id': self.partner_id.id, 'currency_id': self.env.ref('base.USD').id, 'account_id': self.account_id.id, @@ -72,7 +60,7 @@ class TestInvoiceDiscount(TestDiscountCommon): 'date_invoice': time.strftime('%Y') + '-03-12', 'journal_id': self.journal_id.id, }) - self.env['account.invoice.line'].create({ + self.AccountInvoiceLine.create({ 'product_id': self.env.ref("product.product_product_10").id, 'quantity': 10, 'price_unit': 400, @@ -81,7 +69,7 @@ class TestInvoiceDiscount(TestDiscountCommon): 'name': 'Mouse, Optical', 'account_id': self.account_id.id, }) - self.env['account.invoice.line'].create({ + self.AccountInvoiceLine.create({ 'product_id': self.env.ref("product.product_product_12").id, 'quantity': 30, 'price_unit': 250, @@ -91,3 +79,51 @@ class TestInvoiceDiscount(TestDiscountCommon): 'account_id': self.account_id.id, }) return invoice_id + + def account_discount_03_check_include_taxes(self): + tax_id = self.env['account.tax'].create({ + 'name': 'Tax 7.7', + 'amount': 7.7, + 'amount_type': 'percent', + 'price_include': True, + 'include_base_amount': True, + }) + + invoice_id = self.AccountInvoice.create({ + 'name': 'Discount Invoice Test Tax Included Price', + 'partner_id': self.partner_id.id, + 'currency_id': self.env.ref('base.USD').id, + 'account_id': self.account_id.id, + 'type': 'out_invoice', + 'date_invoice': time.strftime('%Y') + '-03-12', + 'journal_id': self.journal_id.id, + }) + invoice_id.onchange_discount_method() + self.AccountInvoiceLine.create({ + 'product_id': self.env.ref("product.product_product_10").id, + 'quantity': 10, + 'price_unit': 400, + 'invoice_id': invoice_id.id, + 'name': 'Mouse, Optical', + 'account_id': self.account_id.id, + 'invoice_line_tax_ids': [(6, 0, [tax_id.id])], + }) + self.AccountInvoiceLine.create({ + 'product_id': self.env.ref("product.product_product_12").id, + 'quantity': 30, + 'price_unit': 250, + 'invoice_id': invoice_id.id, + 'name': 'Mouse, Wireless', + 'account_id': self.account_id.id, + 'invoice_line_tax_ids': [(6, 0, [tax_id.id])], + }) + invoice_id.write({ + 'discount_method': 'fixed', + 'discount_amount': 10, + }) + self.assertTrue(invoice_id, 'Invoice: no invoice created') + invoice_id._check_constrains() + invoice_id.onchange_discount_per() + invoice_id.onchange_discount_amount() + logging.info('Successful: Invoice Created!') + return invoice_id diff --git a/addons/account_discount/tests/test_02_account_discount_invoice.py b/addons/account_discount/tests/test_02_account_discount_invoice.py index 9b3b1cd6..a9b2cbea 100644 --- a/addons/account_discount/tests/test_02_account_discount_invoice.py +++ b/addons/account_discount/tests/test_02_account_discount_invoice.py @@ -25,3 +25,10 @@ class TestDiscountInvoice(TestInvoiceDiscount): }) invoice_id.calculate_discount() invoice_id.action_invoice_open() + + def test_03_fixed_discount_include_taxes(self): + invoice_id = self.account_discount_03_check_include_taxes() + invoice_id.calculate_discount() + self.assertEquals(10, round(invoice_id.discount), + 'Discount Calculation error') + invoice_id.action_invoice_open() diff --git a/addons/auth_signup/data/auth_signup_data.xml b/addons/auth_signup/data/auth_signup_data.xml index c7584cd5..c3e2ccb7 100644 --- a/addons/auth_signup/data/auth_signup_data.xml +++ b/addons/auth_signup/data/auth_signup_data.xml @@ -45,9 +45,6 @@
${user.signature | safe} -

- Sent by ${user.company_id.name} using Flectra -

]]> @@ -84,9 +81,6 @@
${user.signature | safe} -

- Sent by ${user.company_id.name} using Flectra -

]]>
@@ -128,9 +122,6 @@
${user.signature | safe} -

- Sent by ${user.company_id.name} using Flectra -

diff --git a/addons/event/data/email_template_data.xml b/addons/event/data/email_template_data.xml index 31763f87..c1ef812e 100644 --- a/addons/event/data/email_template_data.xml +++ b/addons/event/data/email_template_data.xml @@ -180,7 +180,6 @@ -
Sent by ${object.company_id.name}
% if 'website_url' in object.event_id and object.event_id.website_url:
Discover all our events. @@ -348,7 +347,6 @@ -

Sent by ${object.company_id.name}

% if 'website_url' in object.event_id and object.event_id.website_url:
Discover all our events. diff --git a/addons/hr_recruitment/data/hr_recruitment_data.xml b/addons/hr_recruitment/data/hr_recruitment_data.xml index f041e111..72a24302 100644 --- a/addons/hr_recruitment/data/hr_recruitment_data.xml +++ b/addons/hr_recruitment/data/hr_recruitment_data.xml @@ -82,7 +82,6 @@ -
Sent by ${object.company_id.name}
% if 'website_url' in object.job_id and object.job_id.website_url:
Discover our others jobs. @@ -229,7 +228,6 @@ -
Sent by ${object.company_id.name}
% if 'website_url' in object.job_id and object.job_id.website_url:
Discover all our jobs. @@ -368,7 +366,6 @@ -
Sent by ${object.company_id.name}
% if 'website_url' in object.job_id and object.job_id.website_url:
Discover all our jobs. diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 26175d71..ea7a1814 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -143,18 +143,6 @@ ${ctx['signature'] | safe} % endif
-

- Sent by - % if ctx.get('website_url'): - - % endif - ${ctx.get('company_name')} - % if ctx.get('website_url'): - - % endif - using - Flectra. -

]]> diff --git a/addons/rating_project/data/project_data.xml b/addons/rating_project/data/project_data.xml index 47c21f94..49ff2144 100644 --- a/addons/rating_project/data/project_data.xml +++ b/addons/rating_project/data/project_data.xml @@ -100,7 +100,6 @@ % if object.project_id.rating_status == 'periodic':

This customer survey is sent ${object.project_id.rating_status_period} as long as the task is in the ${object.stage_id.name} stage.

% endif -

Email automatically sent by Flectra Project for ${object.project_id.company_id.name}

diff --git a/addons/sales_discount/tests/discount_common.py b/addons/sales_discount/tests/discount_common.py index fadc1fa3..9ad71c05 100644 --- a/addons/sales_discount/tests/discount_common.py +++ b/addons/sales_discount/tests/discount_common.py @@ -69,3 +69,7 @@ class TestDiscountCommon(TransactionCase): 'property_account_income_id': self.account_type_receivable_id.id}) self.product_2.write({ 'property_account_income_id': self.account_type_receivable_id.id}) + self.sale_order = self.SaleOrder.create({ + 'partner_id': self.partner_id.id, + 'pricelist_id': self.pricelist_id.id, + }) diff --git a/addons/sales_discount/tests/test_01_sale_order_discount.py b/addons/sales_discount/tests/test_01_sale_order_discount.py index f1969134..ac6de9d7 100644 --- a/addons/sales_discount/tests/test_01_sale_order_discount.py +++ b/addons/sales_discount/tests/test_01_sale_order_discount.py @@ -8,18 +8,14 @@ class TestSODiscount(TestDiscountCommon): super(TestSODiscount, self).setUp() def discount_01_set_fixamount(self): - sale_order = self.SaleOrder.create({ - 'partner_id': self.partner_id.id, - 'pricelist_id': self.pricelist_id.id, - }) - sale_order.onchange_discount_method() + self.sale_order.onchange_discount_method() self.SaleOrderLine.create({ 'name': self.product_1.name, 'product_id': self.product_1.id, 'product_uom_qty': 20, 'product_uom': self.product_1.uom_id.id, 'price_unit': self.product_1.list_price, - 'order_id': sale_order.id, + 'order_id': self.sale_order.id, }) self.SaleOrderLine.create({ 'name': self.product_2.name, @@ -27,21 +23,17 @@ class TestSODiscount(TestDiscountCommon): 'product_uom_qty': 20, 'product_uom': self.product_2.uom_id.id, 'price_unit': self.product_2.list_price, - 'order_id': sale_order.id, + 'order_id': self.sale_order.id, }) - sale_order.write({ + self.sale_order.write({ 'discount_method': 'fixed', 'discount_amount': 100, }) - return sale_order + return self.sale_order def discount_02_set_percentages(self): - sale_order = self.SaleOrder.create({ - 'partner_id': self.partner_id.id, - 'pricelist_id': self.pricelist_id.id, - }) - sale_order.onchange_discount_method() - sale_order.write({ + self.sale_order.onchange_discount_method() + self.sale_order.write({ 'discount_method': 'per', 'discount_per': 10, }) @@ -51,7 +43,7 @@ class TestSODiscount(TestDiscountCommon): 'product_uom_qty': 10, 'product_uom': self.product_1.uom_id.id, 'price_unit': self.product_1.list_price, - 'order_id': sale_order.id, + 'order_id': self.sale_order.id, 'discount': 10, }) self.SaleOrderLine.create({ @@ -60,11 +52,47 @@ class TestSODiscount(TestDiscountCommon): 'product_uom_qty': 20, 'product_uom': self.product_2.uom_id.id, 'price_unit': self.product_2.list_price, - 'order_id': sale_order.id, + 'order_id': self.sale_order.id, 'discount': 10, }) - sale_order.write({ + self.sale_order.write({ 'discount_method': 'per', 'discount_per': 20.0, }) - return sale_order + return self.sale_order + + def discount_03_check_include_taxes(self): + self.sale_order.onchange_discount_method() + + tax_id = self.env['account.tax'].create({ + 'name': 'Tax 7.7', + 'amount': 7.7, + 'amount_type': 'percent', + 'price_include': True, + 'include_base_amount': True, + }) + + self.SaleOrderLine.create({ + 'name': self.product_1.name, + 'product_id': self.product_1.id, + 'product_uom_qty': 1, + 'product_uom': self.product_1.uom_id.id, + 'price_unit': 100, + 'tax_id': [(6, 0, [tax_id.id])], + 'order_id': self.sale_order.id, + }) + self.SaleOrderLine.create({ + 'name': self.product_2.name, + 'product_id': self.product_2.id, + 'product_uom_qty': 1, + 'product_uom': self.product_2.uom_id.id, + 'price_unit': 200, + 'tax_id': [(6, 0, [tax_id.id])], + 'order_id': self.sale_order.id, + }) + + self.sale_order.write({ + 'discount_method': 'fixed', + 'discount_amount': 10, + }) + return self.sale_order diff --git a/addons/sales_discount/tests/test_02_so_discount_invoice.py b/addons/sales_discount/tests/test_02_so_discount_invoice.py index 356695f1..26ca15a9 100644 --- a/addons/sales_discount/tests/test_02_so_discount_invoice.py +++ b/addons/sales_discount/tests/test_02_so_discount_invoice.py @@ -25,3 +25,14 @@ class TestSODiscountInvoice(TestSODiscount): sale_order.order_line._compute_product_updatable() sale_order.action_confirm() sale_order.action_invoice_create() + + def test_03_so_fixed_discount_include_taxes(self): + sale_order = self.discount_03_check_include_taxes() + self.assertTrue(sale_order, 'Sale Order: no sale order created') + logging.info('Successful: Sale Order Created!') + sale_order.calculate_discount() + self.assertEquals(10, round(sale_order.discount), + 'Discount Calculation error') + sale_order.order_line._compute_product_updatable() + sale_order.action_confirm() + sale_order.action_invoice_create() diff --git a/addons/website_quote/data/website_quote_data.xml b/addons/website_quote/data/website_quote_data.xml index 1c3a032e..5e763bf3 100644 --- a/addons/website_quote/data/website_quote_data.xml +++ b/addons/website_quote/data/website_quote_data.xml @@ -137,11 +137,6 @@

${user.signature | safe}

% endif -

Sent by - - ${user.company_id.name} - using Flectra -