[IMP/ADD] Add Sales and Account Test Cases and Remove sent by code in flectra

This commit is contained in:
Haresh Chavda 2018-01-25 12:37:16 +05:30
parent 778eef5b33
commit 5627e1e297
12 changed files with 137 additions and 76 deletions

View File

@ -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,
})

View File

@ -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

View File

@ -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()

View File

@ -45,9 +45,6 @@
</div>
<div style="padding:0px;width:600px;margin:auto; margin-top: 10px; background: #fff repeat top /100%;color:#777777">
${user.signature | safe}
<p style="font-size: 11px; margin-top: 10px;">
<strong>Sent by ${user.company_id.name} using <a href="www.flectra.com" style="text-decoration:none; color: #875A7B;">Flectra</a></strong>
</p>
</div>]]></field>
<field name="user_signature" eval="False"/>
</record>
@ -84,9 +81,6 @@
</div>
<div style="padding:0px;width:600px;margin:auto; margin-top: 10px; background: #fff repeat top /100%;color:#777777">
${user.signature | safe}
<p style="font-size: 11px; margin-top: 10px;">
<strong>Sent by ${user.company_id.name} using <a href="www.flectra.com" style="text-decoration:none; color: #875A7B;">Flectra</a></strong>
</p>
</div>]]></field>
<field name="user_signature" eval="False"/>
</record>
@ -128,9 +122,6 @@
</div>
<div style="padding:0px;width:600px;margin:auto; margin-top: 10px; background: #fff repeat top /100%;color:#777777">
${user.signature | safe}
<p style="font-size: 11px; margin-top: 10px;">
<strong>Sent by ${user.company_id.name} using <a href="www.flectra.com" style="text-decoration:none; color: #875A7B;">Flectra</a></strong>
</p>
</div></field>
<field name="user_signature" eval="False"/>
</record>

View File

@ -180,7 +180,6 @@
<tbody>
<tr>
<td style="padding-top:10px;font-size: 12px;">
<div>Sent by ${object.company_id.name}</div>
% if 'website_url' in object.event_id and object.event_id.website_url:
<div>
Discover <a href="/event" style="text-decoration:none;color:#717188;">all our events</a>.
@ -348,7 +347,6 @@
<tbody>
<tr>
<td style="padding-top:10px;font-size: 12px;">
<p style="margin:0px 0px 9px 0px;padding-top:10px;">Sent by ${object.company_id.name}</p>
% if 'website_url' in object.event_id and object.event_id.website_url:
<div>
Discover <a href="/event" style="text-decoration:none;color:#717188;">all our events</a>.

View File

@ -82,7 +82,6 @@
<tbody>
<tr>
<td style="padding-top:10px;font-size: 12px;">
<div>Sent by ${object.company_id.name}</div>
% if 'website_url' in object.job_id and object.job_id.website_url:
<div>
Discover <a href="/jobs" style="text-decoration:none;color:#717188;">our others jobs</a>.
@ -229,7 +228,6 @@
<tbody>
<tr>
<td style="padding-top:10px;font-size: 12px;">
<div>Sent by ${object.company_id.name}</div>
% if 'website_url' in object.job_id and object.job_id.website_url:
<div>
Discover <a href="/jobs" style="text-decoration:none;color:#717188;">all our jobs</a>.
@ -368,7 +366,6 @@
<tbody>
<tr>
<td style="padding-top:10px;font-size: 12px;">
<div>Sent by ${object.company_id.name}</div>
% if 'website_url' in object.job_id and object.job_id.website_url:
<div>
Discover <a href="/jobs" style="text-decoration:none;color:#717188;">all our jobs</a>.

View File

@ -143,18 +143,6 @@
${ctx['signature'] | safe}
% endif
<br/>
<p style="color: #555555;">
Sent by
% if ctx.get('website_url'):
<a href="${ctx['website_url']}" style="text-decoration:none; color: #875A7B;">
% endif
${ctx.get('company_name')}
% if ctx.get('website_url'):
</a>
% endif
using
<a target="_blank" href="https://www.flectra.com" style="text-decoration:none; color: #875A7B;">Flectra</a>.
</p>
</div>]]></field>
</record>

View File

@ -100,7 +100,6 @@
% if object.project_id.rating_status == 'periodic':
<p>This customer survey is sent <b>${object.project_id.rating_status_period}</b> as long as the task is in the <b>${object.stage_id.name}</b> stage.</p>
% endif
<p>Email automatically sent by <a target="_blank" href="https://www.flectra.com/page/project-management" style="color:#875A7B;text-decoration:none;">Flectra Project</a> for <a href="${object.project_id.company_id.website}" style="color:#875A7B;text-decoration:none;">${object.project_id.company_id.name}</a></p>
</td></tr>
</tbody>
</table>

View File

@ -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,
})

View File

@ -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

View File

@ -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()

View File

@ -137,11 +137,6 @@
<p style="font-size: 14px;">${user.signature | safe}
</p>
% endif
<p style="font-size: 11px;"><strong>Sent by
<a href="${user.company_id.website}" style="text-decoration:none; color: #875A7B;">
<strong>${user.company_id.name}</strong>
</a> using <a href="www.flectra.com" style="text-decoration:none; color: #875A7B;"><strong>Flectra</strong></a>
</strong></p>
</td>
</tr></tbody>
</table>