mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 18:52:02 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests.common import TransactionCase, tagged
|
||||
|
|
@ -7,68 +6,6 @@ from odoo.tests.common import TransactionCase, tagged
|
|||
@tagged('post_install', '-at_install')
|
||||
class TestSaleOnchanges(TransactionCase):
|
||||
|
||||
def test_sale_warnings(self):
|
||||
"""Test warnings & SO/SOL updates when partner/products with sale warnings are used."""
|
||||
partner_with_warning = self.env['res.partner'].create({
|
||||
'name': 'Test', 'sale_warn': 'warning', 'sale_warn_msg': 'Highly infectious disease'})
|
||||
partner_with_block_warning = self.env['res.partner'].create({
|
||||
'name': 'Test2', 'sale_warn': 'block', 'sale_warn_msg': 'Cannot afford our services'})
|
||||
|
||||
sale_order = self.env['sale.order'].create({'partner_id': partner_with_warning.id})
|
||||
warning = sale_order._onchange_partner_id_warning()
|
||||
self.assertDictEqual(warning, {
|
||||
'warning': {
|
||||
'title': "Warning for Test",
|
||||
'message': partner_with_warning.sale_warn_msg,
|
||||
},
|
||||
})
|
||||
|
||||
sale_order.partner_id = partner_with_block_warning
|
||||
warning = sale_order._onchange_partner_id_warning()
|
||||
self.assertDictEqual(warning, {
|
||||
'warning': {
|
||||
'title': "Warning for Test2",
|
||||
'message': partner_with_block_warning.sale_warn_msg,
|
||||
},
|
||||
})
|
||||
|
||||
# Verify partner-related fields have been correctly reset
|
||||
self.assertFalse(sale_order.partner_id.id)
|
||||
self.assertFalse(sale_order.partner_invoice_id.id)
|
||||
self.assertFalse(sale_order.partner_shipping_id.id)
|
||||
self.assertFalse(sale_order.pricelist_id.id)
|
||||
|
||||
# Reuse non blocking partner for product warning tests
|
||||
sale_order.partner_id = partner_with_warning
|
||||
product_with_warning = self.env['product.product'].create({
|
||||
'name': 'Test Product', 'sale_line_warn': 'warning', 'sale_line_warn_msg': 'Highly corrosive'})
|
||||
product_with_block_warning = self.env['product.product'].create({
|
||||
'name': 'Test Product (2)', 'sale_line_warn': 'block', 'sale_line_warn_msg': 'Not produced anymore'})
|
||||
|
||||
sale_order_line = self.env['sale.order.line'].create({
|
||||
'order_id': sale_order.id,
|
||||
'product_id': product_with_warning.id,
|
||||
})
|
||||
warning = sale_order_line._onchange_product_id_warning()
|
||||
self.assertDictEqual(warning, {
|
||||
'warning': {
|
||||
'title': "Warning for Test Product",
|
||||
'message': product_with_warning.sale_line_warn_msg,
|
||||
},
|
||||
})
|
||||
|
||||
sale_order_line.product_id = product_with_block_warning
|
||||
warning = sale_order_line._onchange_product_id_warning()
|
||||
|
||||
self.assertDictEqual(warning, {
|
||||
'warning': {
|
||||
'title': "Warning for Test Product (2)",
|
||||
'message': product_with_block_warning.sale_line_warn_msg,
|
||||
},
|
||||
})
|
||||
|
||||
self.assertFalse(sale_order_line.product_id.id)
|
||||
|
||||
def test_create_products_in_different_companies(self):
|
||||
""" Ensures the product's constrain on `company_id` doesn't block the creation of multiple
|
||||
products in different companies (see `product.template` `_check_sale_product_company`.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue