[IMP]: lunch: Develop Yaml test case and change category_id field type selection to many2one

bzr revid: atp@tinyerp.co.in-20100421142713-uyt4qp321a6gmotr
This commit is contained in:
atp (Open ERP)
2010-04-21 19:57:13 +05:30
parent 40555c9105
commit 9abbb104d0
4 changed files with 128 additions and 15 deletions
+4 -1
View File
@@ -47,7 +47,10 @@
'lunch_report.xml',
#'process/lunch_process.xml'
],
"demo_xml": ['lunch_demo.xml'],
"demo_xml": ['lunch_demo.xml',
],
"test": ['test/test_lunch.yml'
],
"installable": True,
}
+1 -13
View File
@@ -42,21 +42,9 @@ class lunch_product(osv.osv):
_name = 'lunch.product'
_description = "Lunch Product"
def _category_name_get(self, cr, uid, context={}):
""" Get category name
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param context: A standard dictionary for contextual values"""
obj = self.pool.get('lunch.category')
cat_ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, cat_ids, ['name', 'category'])
return [(str(r['id']), r['name']) for r in res]+ [('0','')]
_columns = {
'name': fields.char('Name', size=50, required=True),
'category_id': fields.selection(_category_name_get, 'Category', size=32),
'category_id': fields.many2one('lunch.category', 'Category'),
'description': fields.char('Description', size=128, required=False),
'price': fields.float('Price', digits=(16,2)),
'active': fields.boolean('Active'),
+1 -1
View File
@@ -195,7 +195,7 @@
<field name="arch" type="xml">
<form string="Products">
<field name="name" select="1"/>
<field name="category_id" select="1"/>
<field name="category_id" widget='selection' select="1"/>
<field name="description" select="1"/>
<field name="price" select="1"/>
<field name="active" select="1"/>
+122
View File
@@ -0,0 +1,122 @@
- |
In order to test the Lunch module in OpenERP,
I will create one lunch order and then check the effect on cashboxes and cashmoves
- |
Given that I have a category of lunch products "Sandwich".
-
!record {model: lunch.category, id: lunch_category_burger0}:
name: Burger
- |
Given that I have a product "Club1" in this category with a price of "2.75".
-
!record {model: lunch.product, id: lunch_product_club1}:
category_id: lunch_category_burger0
name: Club1
price: 2.75
- |
Given that I have a cashbox "Cashbox"
-
!record {model: lunch.cashbox, id: lunch_cashbox_cashbox0}:
manager: base.user_root
name: CashBox
- |
I create a lunch order "LU001" for the "Club1" product
- |
When I select the product "club1", the price of 2.75 is automatically proposed
-
!record {model: lunch.order, id: lunch_order_0}:
date: '2010-04-19'
product: 'lunch_product_club1'
price: 2.75
user_id: base.user_root
- |
I check that lunch order is on draft state after having created it.
-
!assert {model: lunch.order, id: lunch_order_0}:
- state == 'draft'
- |
I confirm the order "LU001" using the "Confirm Order" wizard.
-
!record {model: lunch.order.confirm, id: lunch_order_confirm_0}:
confirm_cashbox: 'lunch_cashbox_cashbox0'
-
!python {model: lunch.order.confirm}: |
self.confirm(cr, uid, [ref('lunch_order_confirm_0')], {'active_ids': [ref('lunch_order_0')]})
- |
I check that the Cash Moves have been generated with the right box
name
-
# !assert {model: lunch.order, id: lunch_order_0}:
# - cashmove != False
- |
I check that the Total on the cashbox is -2.75
-
!assert {model: lunch.cashbox, id: lunch_cashbox_cashbox0}:
- sum_remain == -2.75
- |
I create a new lunch order "LU002" for the "Club" product, at another date.
-
!record {model: lunch.order, id: lunch_order_1}:
date: '2010-04-22'
product: 'lunch_product_club1'
price: 2.75
user_id: base.user_root
- |
I confirm this order.open wizard and select cashbox.
-
!record {model: lunch.order.confirm, id: lunch_order_confirm_1}:
confirm_cashbox: 'lunch_cashbox_cashbox0'
-
Now I click on "Confirm Order" button of this wizard.
-
!python {model: lunch.order.confirm}: |
self.confirm(cr, uid, [ref('lunch_order_confirm_1')], {'active_ids': [ref('lunch_order_1')]})
- |
I check that the Total on the cashbox is -5.50
-
!assert {model: lunch.cashbox, id: lunch_cashbox_cashbox0}:
- sum_remain == -5.50
- |
I reset the cashbox to zero using the "Set CashBox to Zero" wizard.
-
!record {model: lunch.cashbox.clean, id: lunch_cashbox_clean_0}:
{}
-
!python {model: lunch.cashbox.clean, id: lunch_cashbox_clean_0}: |
self.set_to_zero(cr, uid, [ref('lunch_cashbox_clean_0')], {'active_ids': [ref('lunch_cashbox_cashbox0')]})
- |
I check that the Total on the cashbox is 0.0
-
!assert {model: lunch.cashbox, id: lunch_cashbox_cashbox0}:
- sum_remain == 0.00
- |
I cancel the order "LU002"
-
!record {model: lunch.order.cancel, id: lunch_order_cancel_0}:
{}
-
!python {model: lunch.order.cancel}: |
self.cancel(cr, uid, [ref('lunch_order_cancel_0')], {'active_ids': [ref('lunch_order_1')]})
- |
I test that the Cash Moves revord have been removed for the order LU002.
-
!assert {model: lunch.order, id: lunch_order_1}:
- cashmove == False
- |
I check that the Total on the cashbox is -2.75
-
!assert {model: lunch.cashbox, id: lunch_cashbox_cashbox0}:
- sum_remain == -2.75