Browse Source

added test

pull/775/head
Atchuthan, Sodexis 9 years ago
parent
commit
92aa98db35
  1. 10
      README.rst
  2. 2
      __openerp__.py
  3. 5
      tests/__init__.py
  4. 62
      tests/test_sale_exception.py

10
README.rst

@ -14,19 +14,12 @@ with the base_sale_multi_channels module, because it's likely some orders have
errors when you import them (like product not found in Odoo, wrong line errors when you import them (like product not found in Odoo, wrong line
format etc.) format etc.)
Usage
=====
To use this module, you need to:
* Go to ... * Go to ...
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/167/9.0 :target: https://runbot.odoo-community.org/runbot/167/9.0
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
Bug Tracker Bug Tracker
=========== ===========
@ -40,9 +33,6 @@ sale-workflow/issues/new?body=module:%20
sale_exception%0Aversion:%20 sale_exception%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. 9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Images Images
------ ------

2
__openerp__.py

@ -2,7 +2,7 @@
# © 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis # © 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{'name': 'Sale Exceptions',
{'name': 'Sale Exception',
'summary': 'Custom exceptions on sale order', 'summary': 'Custom exceptions on sale order',
'version': '9.0.1.0.0', 'version': '9.0.1.0.0',
'category': 'Generic Modules/Sale', 'category': 'Generic Modules/Sale',

5
tests/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# (c) 2015 Oihane Crucelaegui - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import test_sale_exception

62
tests/test_sale_exception.py

@ -0,0 +1,62 @@
from openerp.exceptions import ValidationError
from openerp.addons.sale.tests.test_sale_order import TestSaleOrder
class TestSaleException(TestSaleOrder):
def test_sale_order_exception(self):
exception = self.env.ref('sale_exception.excep_no_zip')
exception.active = True
partner = self.env.ref('base.res_partner_1')
partner.zip = False
p = self.env.ref('product.product_product_6')
so = self.env['sale.order'].create({
'partner_id': partner.id,
'partner_invoice_id': partner.id,
'partner_shipping_id': partner.id,
'order_line': [(0, 0, {'name': p.name,
'product_id': p.id,
'product_uom_qty': 2,
'product_uom': p.uom_id.id,
'price_unit': p.list_price})],
'pricelist_id': self.env.ref('product.list0').id,
})
# confirm quotation
so.action_confirm()
self.assertTrue(so.state == 'draft')
# Set ignore_exception flag (Done after ignore is selected at wizard)
so.ignore_exception = True
so.action_confirm()
self.assertTrue(so.state == 'sale')
# Add a order line to test after SO is confirmed
p = self.env.ref('product.product_product_7')
# set ignore_exception = False (Done by onchange of order_line)
self.assertRaises(
ValidationError,
so.write,
{
'ignore_exception': False,
'order_line': [(0, 0, {'name': p.name,
'product_id': p.id,
'product_uom_qty': 2,
'product_uom': p.uom_id.id,
'price_unit': p.list_price})]
},
)
p = self.env.ref('product.product_product_7')
# Set ignore exception True (Done manually by user)
so.write({
'ignore_exception': True,
'order_line': [(0, 0, {'name': p.name,
'product_id': p.id,
'product_uom_qty': 2,
'product_uom': p.uom_id.id,
'price_unit': p.list_price})]
})
exception.active = False
Loading…
Cancel
Save