Browse Source

[12.0][IMP] - Improve unit tests

pull/208/head
sbejaoui 5 years ago
committed by Thomas Binsfeld
parent
commit
9d44088707
  1. 1
      contract_sale_payment_mode/__init__.py
  2. 1
      contract_sale_payment_mode/tests/__init__.py
  3. 19
      contract_sale_payment_mode/tests/test_sale_order.py
  4. 2
      product_contract/__manifest__.py
  5. 18
      product_contract/migrations/12.0.2.0.0/pre-migration.py
  6. 2
      product_contract/models/sale_order.py
  7. 8
      product_contract/tests/test_sale_order.py
  8. 2
      product_contract/views/contract.xml

1
contract_sale_payment_mode/__init__.py

@ -1 +1,2 @@
from . import models
from . import tests

1
contract_sale_payment_mode/tests/__init__.py

@ -0,0 +1 @@
from . import test_sale_order

19
contract_sale_payment_mode/tests/test_sale_order.py

@ -0,0 +1,19 @@
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.addons.product_contract.tests.test_sale_order import TestSaleOrder
class TestSaleOrderPaymentMode(TestSaleOrder):
def setUp(self):
super(TestSaleOrderPaymentMode, self).setUp()
self.payment_mode = self.env['account.payment.mode'].search([], limit=1)
self.sale.payment_mode_id = self.payment_mode
def test_action_confirm_with_payment_mode(self):
self.test_action_confirm()
self.assertEqual(
self.sale.order_line.mapped('contract_id.payment_mode_id'),
self.payment_mode,
)

2
product_contract/__manifest__.py

@ -4,7 +4,7 @@
{
'name': 'Recurring - Product Contract',
'version': '12.0.1.0.0',
'version': '12.0.2.0.0',
'category': 'Contract Management',
'license': 'AGPL-3',
'author': "LasLabs, "

18
product_contract/migrations/12.0.2.0.0/pre-migration.py

@ -0,0 +1,18 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
from openupgradelib import openupgrade
_logger = logging.getLogger(__name__)
def migrate(cr, version):
xmlids_to_rename = [
(
'product_contract.account_analytic_account_recurring_form_form',
'product_contract.contract_contract_customer_form_view',
)
]
openupgrade.rename_xmlids(cr, xmlids_to_rename)

2
product_contract/models/sale_order.py

@ -107,7 +107,7 @@ class SaleOrder(models.Model):
def action_show_contracts(self):
self.ensure_one()
action = self.env.ref(
"contract.action_account_analytic_sale_overdue_all"
"contract.contract_contract_customer_form_view"
).read()[0]
contracts = (
self.env['contract.line']

8
product_contract/tests/test_sale_order.py

@ -294,3 +294,11 @@ class TestSaleOrder(TransactionCase):
self.assertEqual(
self.contract_line.termination_notice_rule_type, 'weekly'
)
def test_action_show_contracts(self):
self.sale.action_confirm()
action = self.sale.action_show_contracts()
self.assertEqual(
self.env['contract.contract'].search(action['domain']),
self.sale.order_line.mapped('contract_id'),
)

2
product_contract/views/contract.xml

@ -5,7 +5,7 @@
-->
<odoo>
<record id="account_analytic_account_recurring_form_form"
<record id="contract_contract_customer_form_view"
model="ir.ui.view">
<field name="model">contract.contract</field>
<field name="inherit_id"

Loading…
Cancel
Save