'partner_view.xml'
],
'demo_xml': ['delivery_demo.xml'],
+ 'test':['test/delivery_test.yml',],
'installable': True,
'active': False,
'certificate': '0033981912253',
--- /dev/null
+-
+ 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 })
+
+
"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:
_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'),
'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
@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,
}
<page string="Products">
<field name="line_ids" colspan="4" nolabel="1">
<tree string="Products" editable="bottom">
- <field name="product_id" on_change="onchange_product_id(product_id)"/>
+ <field name="product_id" on_change="onchange_product_id(product_id,product_uom_id)"/>
<field name="product_qty"/>
<field name="product_uom_id"/>
</tree>
<form string="Products" editable="bottom">
- <field name="product_id"/>
+ <field name="product_id" />
<field name="product_qty"/>
- <field name="product_uom_id"/>
+ <field name="product_uom_id" />
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</form>
</field>
+ <separator colspan="4"/>
+ <group col="8" colspan="4">
+ <field name="state" select="1" readonly ="1"/>
+ <button name="tender_in_progress" states="draft" string="Confirm" type="object" icon="gtk-apply" />
+ <button name="tender_reset" states="done,cancel" string="Reset to Draft" type="object" icon="gtk-convert" />
+ <button name="tender_done" states="in_progress" string="Done" type="object" icon="gtk-jump-to" />
+ <button name="tender_cancel" states="draft,in_progress" string="Cancel" type="object" icon="gtk-cancel" />
+ </group>
</page>
<page string="Notes">
<field name="description" colspan="4" nolabel="1"/>
<field name="purchase_ids" nolabel="1" colspan="4"/>
</page>
</notebook>
- <separator colspan="4"/>
- <group col="8" colspan="4">
- <field name="state" readonly ="1"/>
- <button name="tender_in_progress" states="draft" string="Confirm" type="object" icon="gtk-apply" />
- <button name="tender_reset" states="done,cancel" string="Reset to Draft" type="object" icon="gtk-convert" />
- <button name="tender_done" states="in_progress" string="Done" type="object" icon="gtk-jump-to" />
- <button name="tender_cancel" states="draft,in_progress" string="Cancel" type="object" icon="gtk-cancel" />
- </group>
-
-
</form>
</field>
</record>
<tree string="Purchase Requisition">
<field name="name"/>
<field name="user_id"/>
+ <field name="purchase_ids"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="origin"/>
<field name="arch" type="xml">
<search string="Search Purchase Requisition">
<group col='10' colspan='4'>
- <filter icon="terp-purchase" string=" Current" domain="[('state','=','draft,in_progress')]" separator="1" help="Current Purchaes Requisition"/>
+ <filter icon="terp-purchase" string="Current" domain="[('state','=','draft,in_progress')]" separator="1" help="Current Purchaes Requisition"/>
+ <filter icon="terp-purchase" string="Done" domain="[('state','=','done')]" separator="1" help="Current Purchaes Requisition"/>
<separator orientation="vertical"/>
<field name="name" string="Requisition Reference"/>
<field name="purchase_ids"/>
<newline/>
<group expand="1" string="Group By..." colspan="4" col="10">
<filter string="State" icon="terp-sale" domain="[]" context="{'group_by':'state'}"/>
+ <separator orientation="vertical"/>
<filter string="Date Start" icon="terp-purchase" domain="[]" context="{'group_by':'date_start'}"/>
<filter string="Date End" icon="terp-purchase" domain="[]" context="{'group_by':'date_end'}"/>
+ <separator orientation="vertical"/>
+ <filter string="Origin" icon="terp-purchase" domain="[]" context="{'group_by':'origin'}"/>
</group>
</search>
</field>
--- /dev/null
+
+-
+ In order to test the purchase requisition module, I will do a sale order -> purchase_requisition ->
+ purchase flow and I will buy the required products at two different suppliers.
+-
+ I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
+ with the generation of purchase requisitions.
+-
+ !record {model: product.product, id: product_product_laptopacer0}:
+ categ_id: product.product_category_3
+ cost_method: standard
+ mes_type: fixed
+ name: Laptop ACER
+ procure_method: make_to_order
+ purchase_requisition: 1
+ seller_ids:
+ - delay: 1
+ name: base.res_partner_asus
+ qty: 5.0
+ supply_method: buy
+ type: product
+ uom_id: product.product_uom_unit
+ uom_po_id: product.product_uom_unit
+ volume: 0.0
+ warranty: 0.0
+ weight: 0.0
+ weight_net: 0.0
+ list_price: 100.0
+-
+ Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0001
+-
+ !record {model: sale.order, id: sale_order_testtender0}:
+ date_order: '2010-05-10'
+ invoice_quantity: order
+ name: TEST/TENDER/0001
+ order_line:
+ - name: Laptop ACER
+ price_unit: 100.0
+ product_uom: product.product_uom_unit
+ product_uom_qty: 5.0
+ state: draft
+ delay: 7.0
+ product_id: product_product_laptopacer0
+ product_uos_qty: 5.0
+ th_weight: 0.0
+ type: make_to_order
+ 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
+
+-
+ Performing a workflow action order_confirm on module sale.order
+-
+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender0}
+
+-
+ I launch he scheduler to compute all procurements, and planify all requisitions orders.
+-
+ !python {model: mrp.procurement.compute.all}: |
+ proc_obj = self.pool.get('mrp.procurement')
+ proc_obj._procure_confirm(cr,uid)
+-
+ On the purchase tender, I create a new purchase order for the supplier 'DistriPC' by clicking on
+
+-
+ Creating a purchase.requisition.partner record
+
+-
+ !record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
+ partner_address_id: base.res_partner_address_7
+ partner_id: base.res_partner_4
+
+-
+ Performing an osv_memory action create_order on module purchase.requisition.partner
+
+-
+ !python {model: purchase.requisition.partner}: |
+ req_obj = self.pool.get('purchase.requisition')
+ ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
+ self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"lang":
+ 'en_US', "active_model": "purchase.requisition", "tz": False, "record_id":
+ 1, "active_ids": ids, "active_id": ids[0], })
+
+-
+ I check that I have two purchase orders on the purchase tender
+
+-
+ !python {model: purchase.order}: |
+ order_ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
+ ids=len(order_ids)
+ assert (ids==2), "Purchase order hasn't Created"
+-
+ I set the purchase requisition as 'Not Exclusive'
+
+-
+ !python {model: purchase.requisition}: |
+ ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
+ self.write(cr,uid,ids[0],{'exclusive': 'multiple' })
+-
+ I change the quantities so that the purchase order for DistriPC includes 3 pieces and the
+ purchase order for Asustek includes 2 pieces.
+
+-
+ !python {model: purchase.order}: |
+ line_obj=self.pool.get('purchase.order.line')
+ partner_obj=self.pool.get('res.partner')
+ requistion_obj=self.pool.get('purchase.requisition')
+ requistion_ids =requistion_obj.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
+ partner_id1=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
+ partner_id2=partner_obj.search(cr,uid,[('name','=','Distrib PC')])[0]
+ purchase_id1= self.search(cr, uid, [('partner_id','=',partner_id1),('requisition_id','in',requistion_ids)])
+ purchase_id2= self.search(cr, uid, [('partner_id','=',partner_id2),('requisition_id','in',requistion_ids)])
+ order_line1=self.browse(cr, uid, purchase_id1, context)[0].order_line[0].id
+ order_line2=self.browse(cr, uid, purchase_id2, context)[0].order_line[0].id
+ line_obj.write(cr, uid, order_line1, {'product_qty':2})
+ line_obj.write(cr, uid, order_line2, {'product_qty':3})
+-
+ I confirm and validate both purchase orders
+
+-
+ !python {model: purchase.order}: |
+ order_ids= self.search(cr, uid, [])
+ import netsvc
+ wf_service = netsvc.LocalService("workflow")
+ for id in order_ids:
+ wf_service.trg_validate(uid, 'purchase.order',id,'purchase_confirm', cr)
+ wf_service.trg_validate(uid, 'purchase.order',id,'purchase_approve', cr)
+
+-
+ I check that the delivery order of the customer is in state 'Waiting Goods'
+
+-
+ !python {model: stock.picking }: |
+ picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001'),('type','=','delivery')])
+ if picking_id:
+ pick=self.browse(cr,uid,picking_id[0])
+ assert (pick.state) =='confirmed'," Order is not confirm"
+ assert(pick.move_lines[0].state=='wating'),'Order is not wating"'
+
+-
+ I receive the order of the supplier Asustek from the Incoming Products menu
+
+-
+ !python {model: stock.picking }: |
+ import time
+ partner_obj=self.pool.get('res.partner')
+ order_obj=self.pool.get('purchase.order')
+ partner_id=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
+ picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
+ if picking_id:
+ pick=self.browse(cr,uid,picking_id[0])
+ move =pick.move_lines[0]
+ partial_datas = {
+ 'partner_id': 2,
+ 'address_id': 6,
+ 'delivery_date' : time.strftime('%Y-%m-%d'),
+ }
+ partial_datas['move%s'%(move.id)]= {
+ 'product_id': move.product_id,
+ 'product_qty': move.product_qty,
+ 'product_uom': move.product_uom.id,
+ }
+ self.do_partial(cr, uid, picking_id,partial_datas)
+-
+ I receive the order of the supplier DistriPC from the Incoming Shipments menu
+
+-
+ !python {model: stock.picking }: |
+ import time
+ partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
+ picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
+ if picking_id:
+ pick=self.browse(cr,uid,picking_id[0])
+ move =pick.move_lines[0]
+ partial_datas = {
+ 'partner_id':pick.address_id.partner_id.id,
+ 'address_id': pick.address_id.id,
+ 'delivery_date' : time.strftime('%Y-%m-%d'),
+ }
+ partial_datas['move%s'%(move.id)]= {
+ 'product_id': move.product_id,
+ 'product_qty': move.product_qty,
+ 'product_uom': move.product_uom.id,
+ }
+ self.do_partial(cr, uid, picking_id,partial_datas)
+-
+ Now, I can check that the delivery order of the customer is in the state Available
+
+-
+ !python {model: stock.picking }: |
+ picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001'),('type','=','out')])
+ if picking_id:
+ pick=self.browse(cr,uid,picking_id[0])
+ assert (pick.state) =='available'," Order is not available"
+
--- /dev/null
+-
+ In order to test the purchase requisition module, I will do a sale order -> purchase_requisition ->
+ purchase flow and I will buy the required products at two different suppliers.
+
+-
+ I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
+ with the generation of purchase requisitions.
+
+-
+ !record {model: product.product, id: product_product_laptopacer1}:
+ categ_id: product.product_category_3
+ cost_method: standard
+ list_price: 1000.0
+ mes_type: fixed
+ name: Laptop ACER1
+ procure_method: make_to_order
+ purchase_requisition: 1
+ seller_ids:
+ - delay: 1
+ name: base.res_partner_asus
+ qty: 5.0
+ supply_method: buy
+ type: product
+ uom_id: product.product_uom_unit
+ uom_po_id: product.product_uom_unit
+
+-
+ Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0002
+
+-
+ !record {model: sale.order, id: sale_order_testtender1}:
+ date_order: '2010-04-20'
+ invoice_quantity: order
+ name: TEST/TENDER/0002
+ order_line:
+ - name: Laptop ACER1
+ price_unit: 1000.0
+ product_uom: product.product_uom_unit
+ product_uom_qty: 5.0
+ state: draft
+ 'delay': 7.0
+ 'product_id': product_product_laptopacer1
+ 'type': make_to_order
+ 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
+-
+ Performing a workflow action order_confirm on module sale.order
+-
+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender1}
+
+-
+ I launch he scheduler to compute all procurements, and planify all requisitions orders
+-
+ !python {model: mrp.procurement.compute.all}: |
+ proc_obj = self.pool.get('mrp.procurement')
+ proc_obj._procure_confirm(cr,uid)
+-
+ I should find a purchase requisition with the origin 'TEST/TENDER/0002', that includes a request for
+ 5 Laptop ACER, and a purchase order on the default supplier for this product
+-
+ !python {model: purchase.requisition}: |
+ requisition_ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
+ ids=len(requisition_ids)
+ assert len(requisition_ids), "Purchase requisition hasn't Created"
+-
+ On the purchase tender, I create a new purchase order for the supplier 'DistriPC' by clicking on
+ the button 'New RfQ'. This opens a window to ask me the supplier and I set DistriPC
+-
+ Creating a purchase.requisition.partner record
+-
+ !record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
+ partner_address_id: base.res_partner_address_7
+ partner_id: base.res_partner_4
+
+-
+ Performing an osv_memory action create_order on module purchase.requisition.partner
+-
+ !python {model: purchase.requisition.partner}: |
+ req_obj = self.pool.get('purchase.requisition')
+ ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
+ self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"lang":
+ 'en_US', "active_model": "purchase.requisition", "tz": False, "record_id":
+ 1, "active_ids": ids, "active_id": ids[0], })
+
+-
+ I set the purchase tender as 'Exclusive'
+-
+ !python {model: purchase.requisition}: |
+ ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
+ self.write(cr,uid,ids[0],{'exclusive': 'exclusive' })
+-
+ I confirm and validate the RfQ of ASUStek
+-
+ !python {model: purchase.order}: |
+ partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','ASUStek')])[0]
+ req_obj = self.pool.get('purchase.requisition')
+ ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
+ purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','in',ids)])[0]
+ import netsvc
+ wf_service = netsvc.LocalService("workflow")
+ if purchase_id:
+ wf_service.trg_validate(uid, 'purchase.order',purchase_id,'purchase_confirm', cr)
+ wf_service.trg_validate(uid, 'purchase.order',purchase_id,'purchase_approve', cr)
+-
+ I check that RfQ of DistriPC is cancelled.
+-
+ !python {model: purchase.order}: |
+ partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
+ req_obj = self.pool.get('purchase.requisition')
+ ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
+ purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','in',ids)])[0]
+ state=self.browse(cr,uid,purchase_id).state
+ assert (state=='cancel')
\ No newline at end of file
})
list_line.append(purchase_order_line)
purchase_id = order_obj.create(cr, uid, {
- 'origin': tender.name,
+ 'origin': tender.purchase_ids and tender.purchase_ids[0].origin or tender.name,
'partner_id': partner_id,
'partner_address_id': address_id,
'pricelist_id': pricelist_id,
- 'location_id': line.product_id.product_tmpl_id.property_stock_production.id,
+ 'location_id': tender.purchase_ids and tender.purchase_ids[0].location_id.id or line.product_id.product_tmpl_id.property_stock_production.id,
'company_id': tender.company_id.id,
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
'requisition_id':tender.id,
"security/stock_security.xml",
"security/ir.model.access.csv",
],
- 'demo_xml': ['stock_demo.xml'],
+ 'test': ['test/stock_test.yml'],
'installable': True,
'active': False,
'certificate': '0055421559965',
delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)
delivery_id = delivery_obj.create(cr, uid, {
- 'name': delivered_pack.name,
+ 'name': delivered_pack.name or move.name,
'partner_id': partner_id,
'address_id': address_id,
'date': delivery_date,
--- /dev/null
+
+-
+ In order to test the stock module, I will create product,
+ create physical inventory ,fill inventory lines from location,split inventory line into production lot
+
+-
+ Creating a account.account.type record
+-
+ !record {model: account.account.type, id: account_account_type_asset0}:
+ close_method: balance
+ code: asset
+ name: Asset
+ sign: 1
+
+
+-
+ Creating a account.account.type record
+-
+ !record {model: account.account.type, id: account_account_type_liability0}:
+ close_method: balance
+ code: liability
+ name: Liability
+ sign: 1
+
+-
+ Creating a account.account.type record
+-
+ !record {model: account.account.type, id: account_account_type_income0}:
+ close_method: unreconciled
+ code: income
+ name: Income
+ sign: 1
+
+
+-
+ Creating a account.account.type record
+-
+ !record {model: account.account.type, id: account_account_type_expense0}:
+ close_method: unreconciled
+ code: expense
+ name: Expense
+ sign: 1
+-
+ Creating a account.account.type record
+-
+ !record {model: account.account.type, id: account_account_type_cash0}:
+ close_method: balance
+ code: cash
+ name: Cash
+ sign: 1
+
+
+-
+ Creating a account.account.type record
+-
+ !record {model: account.account.type, id: account_account_type_receivable0}:
+ close_method: balance
+ code: receivable
+ name: Receivable
+ sign: 1
+-
+
+ Creating a account.account record
+-
+ !record {model: account.account, id: account_account_receivable0}:
+ code: '40000'
+ company_id: base.main_company
+ currency_mode: current
+ name: Receivable
+ parent_left: 1
+ parent_right: 2
+ type: receivable
+ user_type: account_account_type_receivable0
+-
+ Creating a account.account record
+-
+ !record {model: account.account, id: account_account_payable0}:
+ code: '440000'
+ company_id: base.main_company
+ currency_mode: current
+ name: Payable
+ parent_left: 3
+ parent_right: 4
+ type: payable
+ user_type: account_account_type_expense0
+-
+ Creating a account.journal record
+-
+ !record {model: account.journal, id: account_journal_purchasejournal0}:
+ code: pur
+ company_id: base.main_company
+ name: Purchase Journal
+ sequence_id: account.sequence_purchase_journal
+ type: purchase
+ view_id: account.account_journal_bank_view
+
+-
+ Creating a account.journal record
+-
+ !record {model: account.journal, id: account_journal_salejouran0}:
+ code: sal
+ company_id: base.main_company
+ name: Sale Jouran
+ sequence_id: account.sequence_sale_journal
+ type: sale
+ view_id: account.account_journal_view
+
+-
+ Creating a account.account record
+-
+ !record {model: account.account, id: account_account_expenseaccount0}:
+ code: Expe
+ company_id: base.main_company
+ currency_mode: current
+ name: Expense Account
+ parent_left: 5
+ parent_right: 6
+ type: consolidation
+ user_type: account_account_type_asset0
+-
+ Creating a account.account record
+-
+ !record {model: account.account, id: account_account_productsale0}:
+ code: '001'
+ company_id: base.main_company
+ currency_mode: current
+ name: Product Sale
+ type: other
+ user_type: stock.account_account_type_income0
+
+
+-
+ Creating a account.account record
+-
+ !record {model: account.account, id: account_account_productpurchase0}:
+ code: '0002'
+ company_id: base.main_company
+ currency_mode: current
+ name: Product Purchase
+ type: other
+ user_type: account_account_type_expense0
+
+-
+ Creating a res.partner record
+-
+ !record {model: res.partner, id: res_partner_shawtrust0}:
+ address:
+ - country_id: base.in
+ - street: St James House, Vicar Lane, Sheffield
+ lang: en_US
+ name: 'Shaw Trust '
+ property_account_payable: account_account_payable0
+ property_account_receivable: account_account_receivable0
+-
+ Creating a res.partner record
+-
+ !record {model: res.partner, id: res_partner_diasorinltd0}:
+ address:
+ - country_id: base.in
+ street: Ash House, Ash Road
+ name: DiaSorin Ltd
+ supplier: true
+
+
+-
+ Creating a res.partner record
+-
+ !record {model: res.partner, id: res_partner_microlinktechnologies0}:
+ address:
+ - street: Kailash Vaibhav, Parksite
+ name: Micro Link Technologies
+ property_account_payable: account_account_payable0
+ property_account_receivable: account_account_receivable0
+ supplier: true
+
+-
+ Creating a res.partner.address record
+-
+ !record {model: res.partner.address, id: res_partner_address_0}:
+ country_id: base.in
+ partner_id: stock.res_partner_diasorinltd0
+ street: Ash House, Ash Road
+ title: Ms.
+
+
+-
+ Creating a product.category record
+-
+ !record {model: product.category, id: product_category_computer0}:
+ name: Computer
+
+-
+ Creating a product.product record
+-
+ !record {model: product.product, id: product_product_hppaviliondesktoppcs0}:
+ categ_id: stock.product_category_computer0
+ cost_method: standard
+ mes_type: fixed
+ list_price: 1000.0
+ name: HP Pavilion Desktop PCs
+ procure_method: make_to_stock
+ seller_ids:
+ - delay: 1
+ name: stock.res_partner_shawtrust0
+ qty: 5.0
+ supply_method: buy
+ type: product
+ uom_id: product.product_uom_unit
+ uom_po_id: product.product_uom_unit
+ property_account_expense: account_account_productsale0
+ property_account_income: account_account_productsale0
+
+-
+ Creating a product.product record
+-
+ !record {model: product.product, id: product_product_hpcdwriters0}:
+ categ_id: stock.product_category_computer0
+ cost_method: standard
+ list_price: 1000.0
+ mes_type: fixed
+ name: HP CD writers
+ procure_method: make_to_stock
+ seller_ids:
+ - delay: 1
+ name: res_partner_shawtrust0
+ qty: 5.0
+ supply_method: buy
+ type: product
+ uom_id: product.product_uom_unit
+ uom_po_id: product.product_uom_unit
+ property_account_expense: account_account_productpurchase0
+ property_account_income: account_account_productsale0
+
+-
+ I create Physical Inventory for the products.
+-
+ !record {model: stock.inventory, id: stock_inventory_physicalinventoy0}:
+ company_id: base.main_company
+ date: '2010-05-10 18:19:13'
+ date_done: '2010-05-10 18:19:59'
+ inventory_line_id:
+ - company_id: base.main_company
+ location_id: stock.stock_location_stock
+ product_id: stock.product_product_hpcdwriters0
+ product_qty: 10.0
+ product_uom: product.product_uom_unit
+ - company_id: base.main_company
+ location_id: stock.stock_location_stock
+ product_id: stock.product_product_hppaviliondesktoppcs0
+ product_qty: 10.0
+ product_uom: product.product_uom_unit
+ name: Physical inventory
+ state: draft
+
+
+-
+ I confirm the Inventory for HP CD writers.
+-
+ !python {model: stock.inventory}: |
+ self.action_done(cr,uid,[ref('stock_inventory_physicalinventoy0')])
+-
+ Creating a stock.fill.inventory record
+-
+ !record {model: stock.fill.inventory, id: stock_fill_inventory_0}:
+ location_id: stock.stock_location_stock
+
+-
+ I fill inventory for HP CD writers.
+-
+ !python {model: stock.fill.inventory}: |
+ self.fill_inventory(cr, uid, [ref("stock_fill_inventory_0")], {"lang": 'en_US',
+ "full": "1", "tz": False, "active_model": "stock.inventory", "active_ids":
+ [ref("stock_inventory_physicalinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0"), })
+
+-
+ Creating a stock.move.split record.
+-
+ !record {model: stock.move.split, id: stock_move_split_0}:
+ line_ids:
+ - name: '00001'
+ quantity: 5
+ product_id: stock.product_product_hpcdwriters0
+
+
+-
+ Split into production line.
+-
+ !python {model: stock.move.split}: |
+ move_obj=self.pool.get('stock.move')
+ product_obj=self.pool.get('product.product')
+ product_id=product_obj.search(cr,uid,[('name','=','HP CD writers')])
+ move_ids=move_obj.search(cr,uid,[('product_id','in',product_id)])
+ self.split_lot(cr, uid, [ref("stock_move_split_0")], {"lang": 'en_US', "active_model":
+ "stock.move", "active_ids": move_ids, "tz": False, "active_id":move_ids[0]
+ })
+-
+
+ In Order to test the picking I create picking with move lines.
+-
+ !record {model: stock.picking, id: stock_picking_0}:
+ address_id: res_partner_address_0
+ company_id: base.main_company
+ date: '2010-05-11 15:18:52'
+ invoice_state: none
+ move_lines:
+ - company_id: base.main_company
+ date_planned: '2010-05-11 15:18:57'
+ location_dest_id: stock.stock_location_customers
+ location_id: stock.stock_location_stock
+ name: HP CD writers
+ product_id: stock.product_product_hpcdwriters0
+ product_qty: 3.0
+ product_uom: product.product_uom_unit
+ date: '2010-05-11 15:18:57'
+ product_uos_qty: 3.0
+ move_type: direct
+ type: internal
+
+
+-
+ I click on draft_force_assign on picking.
+-
+ !python {model: stock.picking}: |
+ self.draft_force_assign(cr, uid, [ref("stock_picking_0")], {"lang": "en_US", "active_model":
+ "ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display":
+ "partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id":
+ ref("stock.menu_action_picking_tree6"), })
+
+
+-
+ I click on force_assign on picking.
+-
+ !python {model: stock.picking}: |
+ self.force_assign(cr, uid, [ref("stock_picking_0")], {"lang": "en_US", "active_model":
+ "ir.ui.menu", "tz": False, "search_default_confirmed": 1, "contact_display":
+ "partner", "active_ids": [ref("stock.menu_action_picking_tree6")], "active_id":
+ ref("stock.menu_action_picking_tree6"), })
+
+
+-
+ I confirm the picking.
+-
+ !python {model: stock.picking }: |
+ import time
+ pick=self.browse(cr,uid,ref('stock_picking_0'))
+ move =pick.move_lines[0]
+ partial_datas = {
+ 'partner_id':pick.address_id.partner_id.id,
+ 'address_id': pick.address_id.id,
+ 'delivery_date' : time.strftime('%Y-%m-%d')
+ }
+ partial_datas['move%s'%(move.id)]= {
+ 'product_id': move.product_id,
+ 'product_qty': move.product_qty,
+ 'product_uom': move.product_uom.id,
+ }
+ self.do_partial(cr, uid, [ref('stock_picking_0')],partial_datas)
\ No newline at end of file