[MIG] sale_order_dates: converted yml test to python
This commit is contained in:
@@ -19,5 +19,4 @@ You can add the following additional dates to a sales order:
|
||||
'website': 'https://www.odoo.com/page/crm',
|
||||
'depends': ['sale_stock'],
|
||||
'data': ['views/sale_order_views.xml'],
|
||||
'test': ['test/requested_date.yml'],
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
-
|
||||
In order to test the Requested Date feature in Sale Orders in OpenERP,
|
||||
I copy a demo Sale Order with Requested Date on 2010-12-17
|
||||
Then I verify that the Procurements and Stock Moves have been generated with the
|
||||
correct date
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
from datetime import datetime, timedelta
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from openerp.osv import fields
|
||||
|
||||
new_id = self.copy(cr, uid, ref("sale.sale_order_6"))
|
||||
self.write(cr, uid, [new_id], {'requested_date': '2010-07-12'})
|
||||
self.action_confirm(cr, uid, [new_id], context=context)
|
||||
|
||||
so = self.browse(cr, uid, new_id)
|
||||
security_delay = timedelta(days=so.company_id.security_lead)
|
||||
requested_date = datetime.strptime(so.requested_date, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
right_date = (requested_date - security_delay).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
for line in so.order_line:
|
||||
assert line.procurement_ids, "No Procurement was created"
|
||||
assert line.procurement_ids[0].date_planned == right_date, "The planned date for the Procurement Order is wrong"
|
||||
assert line.procurement_ids[0].move_ids and line.procurement_ids[0].move_ids[0].date_expected == right_date, "The expected date for the Stock Move is wrong"
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import test_requested_date
|
||||
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import timedelta
|
||||
from odoo.tests import common
|
||||
from odoo import fields
|
||||
|
||||
|
||||
class TestSaleOrderDates(common.TransactionCase):
|
||||
|
||||
def test_sale_order_requested_date(self):
|
||||
|
||||
# In order to test the Requested Date feature in Sale Orders in Odoo,
|
||||
# I copy a demo Sale Order with Requested Date on 2010-07-12
|
||||
new_order = self.env.ref('sale.sale_order_6').copy({'requested_date': '2010-07-12'})
|
||||
# I confirm the Sale Order.
|
||||
new_order.action_confirm()
|
||||
# I verify that the Procurements and Stock Moves have been generated with the correct date
|
||||
security_delay = timedelta(days=new_order.company_id.security_lead)
|
||||
requested_date = fields.Datetime.from_string(new_order.requested_date)
|
||||
right_date = fields.Datetime.to_string(requested_date - security_delay)
|
||||
for line in new_order.order_line:
|
||||
self.assertNotEqual(len(line.procurement_ids), 0, "No Procurement was created")
|
||||
procurement = line.procurement_ids[0]
|
||||
self.assertEqual(procurement.date_planned, right_date, "The planned date for the Procurement Order is wrong")
|
||||
self.assertNotEqual(len(procurement.move_ids), 0, "No Move was created")
|
||||
self.assertEqual(procurement.move_ids[0].date_expected, right_date, "The expected date for the Stock Move is wrong")
|
||||
Reference in New Issue
Block a user