Skip to content

Commit

Permalink
[ADD] automated test for part of the current behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
gurneyalex authored and yvaucher committed Mar 13, 2014
2 parents df14d60 + 9903ac8 commit d03d40b
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sale_dropshipping/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
##############################################################################
{"name": "Sale Dropshipping",
"version": "1.0",
"version": "1.1",
"author": "Akretion",
"website": "http://www.openerp.com",
"category": "Generic Modules/Purchase",
Expand Down Expand Up @@ -55,7 +55,8 @@
""",
"init_xml": [],
"demo_xml": [],
"test": [],
"test": ['test/test_sale_policy_procurement.yml',
],
"update_xml": ["purchase_view.xml", "sale_view.xml", "product_view.xml", "stock_view.xml"],
'images': ['images/purchase_to_sale.png'],
'installable': True,
Expand Down
4 changes: 3 additions & 1 deletion sale_dropshipping/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def is_direct_delivery_from_suppliers(product):
return False

for product in self.browse(cr, uid, ids):
if 'qty' in context:
if product.procure_method == 'make_to_order':
res[product.id] = is_direct_delivery_from_suppliers(product)
elif 'qty' in context:
# TODO deal with partial availability?
if product.virtual_available < context['qty']:
res[product.id] = is_direct_delivery_from_suppliers(product)
Expand Down
3 changes: 2 additions & 1 deletion sale_dropshipping/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
if product:
context2 = {'lang': lang,
'partner_id': partner_id,
'qty': qty}
'qty': qty,
}
product_obj = self.pool.get('product.product').browse(cr, uid, product,
context=context2)
if product_obj.is_direct_delivery_from_product:
Expand Down
111 changes: 111 additions & 0 deletions sale_dropshipping/test/test_sale_policy_procurement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
-
I create a product with procure method MTS
-
!record {model: product.product, id: prod_mts}:
name: testproduct mts
procure_method: make_to_stock
supply_method: buy
seller_ids:
- name: base.res_partner_1
min_qty: 1
product_uom: 1
direct_delivery_flag: True
-
I create a product with procure method MTO
-
!record {model: product.product, id: prod_mto}:
name: testproduct mto
procure_method: make_to_order
supply_method: buy
seller_ids:
- name: base.res_partner_1
min_qty: 1
product_uom: 1
direct_delivery_flag: True
-
I create SO for 3xMTS Product
-
!record {model: sale.order, id: so_mts}:
partner_id: base.res_partner_2
order_line:
- product_id: prod_mts
product_uom_qty: 3
-
The so line should have sale_flow set to dropshipping
-
!assert {model: sale.order, id: so_mts, string: wrong so line sale_flow state}:
- order_line[0].sale_flow == 'direct_delivery'
-
I create SO for 3xMT0 Product
-
!record {model: sale.order, id: so_mto}:
partner_id: base.res_partner_2
order_line:
- product_id: prod_mto
product_uom_qty: 3
-
The so line should have sale_flow set to dropshipping
-
!assert {model: sale.order, id: so_mto, string: wrong so line sale_flow state}:
- order_line[0].sale_flow == 'direct_delivery'
-
I create some stock (5 units) for each product
-
!record {model: stock.picking.in, id: in_pick}:
type: in
move_lines:
- product_id: prod_mto
product_qty: 5
product_uom: 1
location_id: stock.stock_location_suppliers
location_dest_id: stock.stock_location_stock
- product_id: prod_mts
product_qty: 5
product_uom: 1
location_id: stock.stock_location_suppliers
location_dest_id: stock.stock_location_stock
-
!python {model: stock.picking.in}: |
self.action_move(cr, uid, [ref("in_pick")])
-
!assert {model: product.product, id: prod_mto, string: wrong so stock_level}:
- qty_available == 5
-
I create SO for 3xMTS Product
-
!record {model: sale.order, id: so_mts2}:
partner_id: base.res_partner_2
order_line:
- product_id: prod_mts
product_uom_qty: 3
-
The so line should have sale_flow set to normal
-
!assert {model: sale.order, id: so_mts2, string: wrong so line sale_flow state}:
- order_line[0].sale_flow == 'normal'
-
I create SO for 10xMTS Product
-
!record {model: sale.order, id: so_mts3}:
partner_id: base.res_partner_2
order_line:
- product_id: prod_mts
product_uom_qty: 10
-
The so line should have sale_flow set to drop shipping
-
!assert {model: sale.order, id: so_mts3, string: wrong so line sale_flow state}:
- order_line[0].sale_flow == 'direct_delivery'
-
I create SO for 3xMT0 Product
-
!record {model: sale.order, id: so_mto2}:
partner_id: base.res_partner_2
order_line:
- product_id: prod_mto
product_uom_qty: 3
-
The so line should have sale_flow set to dropshipping
-
!assert {model: sale.order, id: so_mto2, string: wrong so line sale_flow state}:
- order_line[0].sale_flow == 'direct_delivery'

0 comments on commit d03d40b

Please sign in to comment.