[FIX] sale_mrp, stock_dropshipping: suppress warnings

* create product correctly (via form) & enable crossdock route
  otherwise no purchase order is created (surprise!)
* silence logger when creating SO as apparently stock warning can not
  be disabled even when it makes no sense
* suppress warning about cost methods when creating a product
  category, that's apparently normal (happens every time on runbot)
This commit is contained in:
Xavier Morel
2017-12-04 13:11:57 +01:00
parent 346d770291
commit 3c4c192cae
4 changed files with 39 additions and 27 deletions
@@ -4,6 +4,7 @@
import time
from odoo.tests.common import TransactionCase, Form
from odoo.tools import mute_logger
class TestSaleMrpProcurement(TransactionCase):
@@ -13,7 +14,10 @@ class TestSaleMrpProcurement(TransactionCase):
# In order to test the sale_mrp module in OpenERP, I start by creating a new product 'Slider Mobile'
# I define product category Mobile Products Sellable.
pc = Form(self.env['product.category'])
with mute_logger('odoo.tests.common.onchange'):
# Suppress warning on "Changing your cost method" when creating a
# product category
pc = Form(self.env['product.category'])
pc.name = 'Mobile Products Sellable'
product_category_allproductssellable0 = pc.save()
@@ -34,7 +38,6 @@ class TestSaleMrpProcurement(TransactionCase):
product.route_ids.clear()
product.route_ids.add(warehouse0.manufacture_pull_id.route_id)
product.route_ids.add(warehouse0.mto_pull_id.route_id)
product_template_slidermobile0 = product.save()
with Form(self.env['mrp.bom']) as bom:
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import common, Form
from odoo.tools import mute_logger
class TestCrossdock(common.TransactionCase):
@@ -23,28 +24,29 @@ class TestCrossdock(common.TransactionCase):
self.assertTrue(wh_pps.crossdock_route_id.active,
"Crossdock route should be active when reception_steps is not in 'single_step'")
# Create new product without any routes
cross_shop_product = self.env['product.product'].create({
'name': "PCE",
'type': 'product',
'categ_id': self.env.ref('product.product_category_1').id,
'list_price': 100.0,
'standard_price': 70.0,
'seller_ids': [(0, 0, {
'delay': 1,
'name': supplier_crossdock.id,
'min_qty': 2.0
})]
})
p_f = Form(self.env['product.template'])
p_f.name = 'PCE'
p_f.type = 'product'
p_f.categ_id = self.env.ref('product.product_category_1')
p_f.list_price = 100.0
p_f.standard_price = 70.0
with p_f.seller_ids.new() as seller:
seller.name = supplier_crossdock
p_f.route_ids.add(wh_pps.crossdock_route_id)
cross_shop_product = p_f.save()
# Create a sales order with a line of 100 PCE incoming shipment with route_id crossdock shipping
so_form = Form(self.env['sale.order'])
so_form.partner_id = self.env.ref('base.res_partner_4')
so_form.warehouse_id = wh_pps
with so_form.order_line.new() as line:
line.product_id = cross_shop_product
line.product_uom_qty = 100.0
sale_order_crossdock = so_form.save()
with mute_logger('odoo.tests.common.onchange'):
# otherwise complains that there's not enough inventory and
# apparently that's normal according to @jco and @sle
with so_form.order_line.new() as line:
line.product_id = cross_shop_product.product_variant_ids
line.product_uom_qty = 100.0
sale_order_crossdock = so_form.save()
# Confirm sales order
sale_order_crossdock.action_confirm()
@@ -53,7 +55,9 @@ class TestCrossdock(common.TransactionCase):
self.env['procurement.group'].run_scheduler()
# Check a quotation was created for the created supplier and confirm it
self.env['purchase.order'].search([
po = self.env['purchase.order'].search([
('partner_id', '=', supplier_crossdock.id),
('state', '=', 'draft')
]).button_confirm()
])
self.assertTrue(po, "an RFQ should have been created by the scheduler")
po.button_confirm()
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import common, Form
from odoo.tools import mute_logger
class TestDropship(common.TransactionCase):
@@ -31,11 +32,14 @@ class TestDropship(common.TransactionCase):
so_form = Form(self.env['sale.order'])
so_form.partner_id = self.env.ref('base.res_partner_2')
so_form.payment_term_id = self.env.ref('account.account_payment_term')
with so_form.order_line.new() as line:
line.product_id = drop_shop_product
line.product_uom_qty = 200
line.price_unit = 1.00
line.route_id = self.env.ref('stock_dropshipping.route_drop_shipping')
with mute_logger('odoo.tests.common.onchange'):
# otherwise complains that there's not enough inventory and
# apparently that's normal according to @jco and @sle
with so_form.order_line.new() as line:
line.product_id = drop_shop_product
line.product_uom_qty = 200
line.price_unit = 1.00
line.route_id = self.env.ref('stock_dropshipping.route_drop_shipping')
sale_order_drp_shpng = so_form.save()
# Confirm sales order
@@ -46,6 +50,7 @@ class TestDropship(common.TransactionCase):
# Check a quotation was created to a certain vendor and confirm so it becomes a confirmed purchase order
purchase = self.env['purchase.order'].search([('partner_id', '=', supplier_dropship.id)])
self.assertTrue(purchase, "an RFQ should have been created by the scheduler")
purchase.button_confirm()
self.assertEquals(purchase.state, 'purchase', 'Purchase order should be in the approved state')
self.assertEquals(len(purchase.ids), 1, 'There should be one picking')
+1 -1
View File
@@ -860,7 +860,7 @@ class Form(object):
self._view['onchange'],
)
if result.get('warning'):
_logger.warn("%(title)s: %(message)s" % result.get('warning'))
_logger.getChild('onchange').warn("%(title)s %(message)s" % result.get('warning'))
values = result.get('value', {})
# mark onchange output as changed
self._changed.update(values.keys())