diff --git a/addons/delivery/__openerp__.py b/addons/delivery/__openerp__.py index 9b0949e07e1..684547e0a89 100644 --- a/addons/delivery/__openerp__.py +++ b/addons/delivery/__openerp__.py @@ -39,6 +39,7 @@ 'partner_view.xml' ], 'demo_xml': ['delivery_demo.xml'], + 'test':['test/delivery_test.yml',], 'installable': True, 'active': False, 'certificate': '0033981912253', diff --git a/addons/delivery/test/delivery_test.yml b/addons/delivery/test/delivery_test.yml new file mode 100644 index 00000000000..700ff046a0e --- /dev/null +++ b/addons/delivery/test/delivery_test.yml @@ -0,0 +1,167 @@ +- + In order to test the delivery module, I will do Configuration -> Delivery -> Delivery Method + And there are two methods for doing that + Delivery based on order quantities, + Delivery based on delivered quantities. + +- + I create the partner associated with the transport +- + Creating a res.partner record +- + !record {model: res.partner, id: res_partner_thepost0}: + address: + - country_id: base.in + name: Micro Link + credit_limit: 0.0 + name: The Post + property_account_payable: account.a_pay + property_account_receivable: account.a_recv + + +- + + I create associated product for delivery. +- + !record {model: product.product, id: product_product_deliverybypost0}: + categ_id: product.product_category_services + cost_method: standard + mes_type: fixed + name: Delivery Product + procure_method: make_to_stock + supply_method: buy + type: service + uom_id: product.product_uom_unit + uom_po_id: product.product_uom_unit + warranty: 0.0 + +- + + I create the Delivery Method +- + !record {model: delivery.carrier, id: delivery_carrier_theopenerpexperss0}: + name: The OpenERP Experss + partner_id: res_partner_thepost0 + product_id: product_product_deliverybypost0 +- + I create a delivery grid record and define the region for which the tariffs in the grid will be applicable. + Then set the condition for which this rule is applicable +- + !record {model: delivery.grid, id: delivery_grid_weight0}: + carrier_id: delivery_carrier_theopenerpexperss0 + line_ids: + - list_price: 120.0 + max_value: 250.0 + name: Weight of product + operator: <= + standard_price: 60.0 + type: weight + price_type: fixed + variable_factor: weight + - list_price: 0.0 + max_value: 500.0 + name: Price >= 500 + operator: <= + standard_price: 20.0 + type: price + price_type: fixed + variable_factor: weight + country_ids: + - base.id + - base.be + - base.in + - base.io + + name: Weight + sequence: 1 + +- + To check the Delivery based on order quantities , I have created sale order and picking_policy is direct +- + !record {model: sale.order, id: sale_order_so0}: + date_order: '2010-05-11' + invoice_quantity: order + name: Test/delivery + order_line: + - name: '[PC1] Basic PC' + price_unit: 450.0 + product_uom: product.product_uom_unit + product_uom_qty: 10.0 + state: draft + delay: 2.0 + product_id: product.product_product_pc1 + product_uos_qty: 10.0 + th_weight: 0.0 + type: make_to_stock + order_policy: manual + partner_id: base.res_partner_agrolait + partner_invoice_id: base.res_partner_address_8 + partner_order_id: base.res_partner_address_8 + partner_shipping_id: base.res_partner_address_8 + picking_policy: direct + pricelist_id: product.list0 + shop_id: sale.shop + +- + Creating a delivery.sale.order record +- + !record {model: delivery.sale.order, id: delivery_sale_order_0}: + carrier_id: delivery_carrier_theopenerpexperss0 +- + To add the delivery charges on the quotation, I click on Delivery costs button and select the carrier. +- + !python {model: delivery.sale.order}: | + self.delivery_set(cr, uid, [ref("delivery_sale_order_0")], {"lang": "en_US", "active_model": + "sale.order", "tz": False, "order_id": 8, "active_ids": [ref("sale_order_so0")], + "active_id": ref("sale_order_so0"), }) +- + I confirm the sale order. +- + !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0} + +- + To check the Invoicing based on deliveries.I create new sale order and picking_policy is Complete Delivery. +- + !record {model: sale.order, id: sale_order_test_complete0}: + name: Test/Complete Deliver + carrier_id: delivery.delivery_carrier_theopenerpexperss0 + invoice_quantity: procurement + order_line: + - name: '[PC1] Basic PC' + price_unit: 450.0 + product_uom: product.product_uom_unit + product_uom_qty: 10.0 + state: draft + delay: 2.0 + product_id: product.product_product_pc1 + product_uos_qty: 10.0 + th_weight: 0.0 + type: make_to_stock + partner_id: base.res_partner_4 + partner_order_id: base.res_partner_address_7 + partner_invoice_id: base.res_partner_address_7 + partner_shipping_id: base.res_partner_address_7 + pricelist_id: product.list0 + order_policy: picking + + +- + I confirm the sale order. +- + !workflow {model: sale.order, action: order_confirm, ref: sale_order_test_complete0} +- + Creating a stock.invoice.onshipping record +- + !record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_0}: + journal_id: account.sales_journal + type: out_invoice +- + Create a Invoice form picking. +- + !python {model: stock.invoice.onshipping}: | + so=self.pool.get('sale.order').browse(cr,uid,ref('sale_order_test_complete0')) + self.create_invoice(cr, uid, [ref("stock_invoice_onshipping_0")], {"lang": "en_US", + "tz": False, "active_model": "stock.picking", "contact_display": "partner", + "active_ids": [so.picking_ids[0].id], "active_id": so.picking_ids[0].id }) + + diff --git a/addons/purchase_requisition/__openerp__.py b/addons/purchase_requisition/__openerp__.py index c5a9435379c..d707af0e50d 100644 --- a/addons/purchase_requisition/__openerp__.py +++ b/addons/purchase_requisition/__openerp__.py @@ -34,8 +34,10 @@ "update_xml" : ["wizard/purchase_requisition_partner_view.xml", "purchase_requisition_view.xml", "security/ir.model.access.csv","purchase_requisition_sequence.xml"], - "active": False, + "test":[ +# 'test/purchase_requisition.yml','test/purchase_requisition_exclusive.yml' + ], "installable": True } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 14ff085a4c4..e7b1f09aa90 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -78,7 +78,7 @@ class purchase_requisition_line(osv.osv): _description="Purchase Requisition Line" _rec_name = 'product_id' _columns = { - 'product_id': fields.many2one('product.product', 'Product' , domain=[('purchase_requisition', '=', True)]), + 'product_id': fields.many2one('product.product', 'Product' ), 'product_uom_id': fields.many2one('product.uom', 'Product UoM'), 'product_qty': fields.float('Quantity', digits=(16,2)), 'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade'), @@ -86,7 +86,7 @@ class purchase_requisition_line(osv.osv): 'requisition_id' : fields.many2one('purchase.requisition','Purchase Requisition', ondelete='cascade') } - def onchange_product_id(self, cr, uid, ids, product_id, context={}): + def onchange_product_id(self, cr, uid, ids, product_id,product_uom_id, context={}): """ Changes UoM and name if product_id changes. @param name: Name of the field @@ -94,13 +94,14 @@ class purchase_requisition_line(osv.osv): @return: Dictionary of changed values """ value = {} - + if product_id: prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0] - value = {'product_uom_id': prod.uom_id.id} - + if product_uom_id != prod.uom_id.id: + value = {'product_uom_id': prod.uom_id.id} return {'value': value} + _defaults = { 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml index 5ce49ec3693..1df006ec3ab 100644 --- a/addons/purchase_requisition/purchase_requisition_view.xml +++ b/addons/purchase_requisition/purchase_requisition_view.xml @@ -46,18 +46,26 @@ - +
- + - + + + + +