diff --git a/sale_dropshipping/__openerp__.py b/sale_dropshipping/__openerp__.py index 318d7f74780..14546b29157 100755 --- a/sale_dropshipping/__openerp__.py +++ b/sale_dropshipping/__openerp__.py @@ -20,7 +20,7 @@ # ############################################################################## {"name": "Sale Dropshipping", - "version": "1.0", + "version": "1.1", "author": "Akretion", "website": "http://www.openerp.com", "category": "Generic Modules/Purchase", @@ -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, diff --git a/sale_dropshipping/product.py b/sale_dropshipping/product.py index 44685329495..b37e3e3bc38 100644 --- a/sale_dropshipping/product.py +++ b/sale_dropshipping/product.py @@ -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) diff --git a/sale_dropshipping/sale.py b/sale_dropshipping/sale.py index 2f8b947a185..02e1e13947a 100644 --- a/sale_dropshipping/sale.py +++ b/sale_dropshipping/sale.py @@ -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: diff --git a/sale_dropshipping/test/test_sale_policy_procurement.yml b/sale_dropshipping/test/test_sale_policy_procurement.yml new file mode 100644 index 00000000000..b27586d207a --- /dev/null +++ b/sale_dropshipping/test/test_sale_policy_procurement.yml @@ -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'