[IMP] clean test YML for point_of_sale

bzr revid: fp@tinyerp.com-20110925155050-cqkwsar8azfmis87
This commit is contained in:
Fabien Pinckaers
2011-09-25 17:50:50 +02:00
parent 007da7d0c7
commit 5e6a1ecb76
4 changed files with 11 additions and 178 deletions
+3 -2
View File
@@ -77,8 +77,9 @@ Main features :
'account_statement_demo.xml',
'test/00_register_open.yml'
],
'test': ['test/point_of_sale_test.yml',
'test/point_of_sale_report.yml',
'test': [
'test/01_order_to_payment.yml',
'test/point_of_sale_report.yml'
],
'installable': True,
'certificate' : '001156338024966477869',
+1 -2
View File
@@ -643,7 +643,7 @@ class pos_order_line(osv.osv):
_columns = {
'company_id': fields.many2one('res.company', 'Company', required=True),
'name': fields.char('Line No', size=32, required=True),
'notice': fields.char('Discount Notice', size=128, required=True),
'notice': fields.char('Discount Notice', size=128),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], required=True, change_default=True),
'price_unit': fields.float(string='Unit Price', digits=(16, 2)),
'qty': fields.float('Quantity', digits=(16, 2)),
@@ -658,7 +658,6 @@ class pos_order_line(osv.osv):
'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.order.line'),
'qty': lambda *a: 1,
'discount': lambda *a: 0.0,
'notice': lambda *a: 'No Discount',
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
@@ -1,173 +0,0 @@
-
In order to test the Point of Sale in module, I will do a full flow from the sale to the paiement and invoicing.
-
I create a PoS with 2 PC1 and 3 PC2.
-
!record {model: pos.order, id: pos_order_pos0}:
company_id: base.main_company
lines:
- name: OL/0001
product_id: product.product_product_pc1
price_unit: 450
discount: 0.0
qty: 2.0
- name: OL/0002
product_id: product.product_product_pc2
price_unit: 300
discount: 0.0
qty: 3.0
-
I check that the total of the order is equal to 450 * 2 / 300 * 3
-
!python {model: pos.order}: |
order = self.browse(cr, uid, ref('pos_order_pos0'))
assert(abs(order.amount_total - 1800.0) < 0.01), "The order has a wrong amount"
-
I want to add a global discount of 5 percent using the wizard
-
!record {model: pos.discount, id: pos_discount_0}:
discount: 5.0
-
I click the apply button to set the discount on all lines
-
!python {model: pos.discount}: |
self.apply_discount(cr, uid, [ref("pos_discount_0")], {"active_model": "pos.order",
"active_ids": [ref("pos_order_pos0")], "active_id": ref("pos_order_pos0"), })
-
I check that the total of the order is not equal to (450 * 2 / 300 * 3)*0.95
-
!python {model: pos.order}: |
order = self.browse(cr, uid, ref('pos_order_pos0'))
assert(abs(order.amount_total - (450*2+300*3)*0.95) < 0.01), "The order has a wrong amount"
#-
# I open the register.
#-
# !record {model: pos.open.statement, id: pos_open_statement_0}:
# {}
#-
# I open the statement.
#-
# !python {model: pos.open.statement}: |
# jou_obj = self.pool.get('account.journal')
# statement_obj = self.pool.get('account.bank.statement')
# cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
# "WHERE user_id = %s ORDER BY journal_id"% (uid, ))
# jou_ids = map(lambda x1: x1[0], cr.fetchall())
# journal_ids = jou_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', jou_ids)], context=context)
# ids = statement_obj.search(cr, uid, [('state', '=', 'open'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)], context=context)
# if not ids:
# self.open_statement(cr, uid, [ref("pos_open_statement_0")], {"lang": "en_US", "active_model":
# "ir.ui.menu", "active_ids": [ref("point_of_sale.menu_open_statement")], "tz":
# False, "active_id": ref("point_of_sale.menu_open_statement"), })
#-
# I click on the "Make Payment" wizard.
#-
# !record {model: pos.make.payment, id: pos_make_payment_0}:
# amount: 1615.0
# journal: 7
# payment_date: !eval time.strftime("%Y-%m-%d")
# payment_name: Payment
# product_id: product_product_hppaviliondesktoppcs0
# pricelist_id: product.list0
# partner_id: base.res_partner_agrolait
#-
# I make the payment.
#-
# !python {model: pos.make.payment}: |
# self.check(cr, uid, [ref("pos_make_payment_0")], {"lang": "en_US", "active_model":
# "pos.order", "active_ids": [ref("point_of_sale.pos_order_pos0")], "tz":
# False, "active_id": ref("point_of_sale.pos_order_pos0"), })
#-
# I check the Statement lines are created automatically when payment is done.
#-
# !python {model: pos.order}: |
# order=self.browse(cr,uid,ref("pos_order_pos0"))
# assert(order.statement_ids!=[]), "Statement lines not created"
#-
# When I click on Return picking button , I get three option.
#-
# 1. Cancel 2.Return Goods and Exchange 3.Return without Refund
#-
# When I click on Return Goods and Exchange.
#-
# Then it allows me to define the quantity of products, which will return to the stock.
#-
# I click on Return Picking button.
#-
# !record {model: pos.return, id: pos_return_0}:
# pos_moves_ids:
# - product_id: product_product_hppaviliondesktoppcs0
# quantity: 5.0
#-
# I Return the product.
#-
# !python {model: pos.return}: |
# self.create_returns(cr, uid, [ref("pos_return_0")], {"lang": "en_US", "active_model":
# "pos.order", "active_ids": [ref("point_of_sale.pos_order_pos0")], "tz":
# False, "active_id": ref("point_of_sale.pos_order_pos0"), })
#-
# Then it allows me to define the quantity of products, which will return to the stock.
#-
# I select the HP Pavilion Desktop PCs for exchange.
#-
# !record {model: pos.add.product, id: pos_add_product_0}:
# product_id: product_product_hppaviliondesktoppcs0
# quantity: 5.0
#-
# I click on close button.
#-
# !python {model: pos.add.product}: |
# return_obj = self.pool.get('pos.return')
# context['active_ids'] = [ref("pos_order_pos0")]
# return_obj.view_init(cr, uid, [],context=context)
# self.close_action(cr, uid, [ref("pos_add_product_0")], {"lang": "en_US", "active_model":
# "pos.order", "active_ids": [ref("pos_order_pos0")], "tz": False, "active_id": ref("pos_order_pos0"),
# })
#-
# I create payment.
#-
# !record {model: pos.make.payment, id: pos_make_payment_1}:
# amount: 680.0
# journal: 7
# payment_date: !eval time.strftime("%Y-%m-%d")
# payment_name: Payment
# product_id: product_product_hppaviliondesktoppcs0
# pricelist_id: product.list0
# partner_id: base.res_partner_agrolait
#-
# For payment, I click on Make Payment.
#-
# !python {model: pos.make.payment}: |
# self.check(cr, uid, [ref("pos_make_payment_1")], {"lang": "en_US", "active_model":
# "pos.order", "active_ids": [ref("pos_order_pos0")], "tz":
# False, "active_id": ref("pos_order_pos0"), })
#-
# To check the Return without Refund . I click button "Return without Refund ".
#-
# !record {model: pos.return, id: pos_return_0}:
# {}
#-
# The quantity which is selected in Return lines wizard is refunded.
#-
# !python {model: pos.return}: |
# self.create_returns2(cr, uid, [ref("pos_return_0")], {"lang": "en_US", "active_model":
# "pos.order", "active_ids": [ref("pos_order_pos0")], "tz":
# False, "active_id": ref("pos_order_pos0"), })
#-
# To Close order, I use the wizard "Sale Confirm".
#-
# !record {model: pos.confirm, id: pos_confirm_0}:
# {}
#-
# I close this order.
#-
# !python {model: pos.confirm}: |
# self.action_confirm(cr, uid, [ref("pos_confirm_0")], {"lang": "en_US", "active_model":
# "pos.order", "active_ids": [ref("pos_order_pos0")], "tz": False, "active_id": ref("pos_order_pos0"),
# })
#-
# I check order state is done.
#-
# !python {model: pos.order}: |
# order=self.browse(cr,uid,ref("pos_order_pos0"))
# assert(order.state=='done'), "Order is not done"
+7 -1
View File
@@ -43,6 +43,7 @@ class pos_make_payment(osv.osv_memory):
order = order_obj.browse(cr, uid, active_id, context=context)
amount = order.amount_total - order.amount_paid
data = self.read(cr, uid, ids, context=context)[0]
data['journal'] = data['journal'][0]
if amount != 0.0:
order_obj.add_payment(cr, uid, active_id, data, context=context)
@@ -74,6 +75,10 @@ class pos_make_payment(osv.osv_memory):
'datas': datas,
}
def _default_journal(self, cr, uid, context=None):
res = pos_box_entries.get_journal(self, cr, uid, context=context)
return len(res)>1 and res[1] or False
def _default_amount(self, cr, uid, context=None):
order_obj = self.pool.get('pos.order')
active_id = context and context.get('active_id', False)
@@ -91,7 +96,8 @@ class pos_make_payment(osv.osv_memory):
_defaults = {
'payment_date': time.strftime('%Y-%m-%d %H:%M:%S'),
'payment_name': _('Payment'),
'amount': _default_amount
'amount': _default_amount,
'journal': _default_journal
}
pos_make_payment()