Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how can i create a stock move ???

By
Undan
on 12/17/15, 4:02 AM 450 views

in my custom module there is  product line .and when ever i am  creating an invoice i also need a stock move for the product line..how can i do that..

plz give me some answerss

1
Deepak Krishna
On 12/29/15, 6:05 AM

hi,

You can call stock move from invoice creation.i have created a similar stock move for membership module..just check whether it is usefull or not..

class membership_invoice(osv.osv):
...
def membership_stock_move(self,cr,uid,ids,context=None):
res = {}
vals = []
member_inv_obj = self.pool.get('membership.invoice')
member_inv_line_obj = self.pool.get('membership.invoice.line')
move_obj=self.pool.get('stock.move')

partner_id = member_inv_obj.browse(cruidids,,[0]).cust_name.id
dest_id = member_inv_obj.browse(cruidids,,[0]).cust_name.property_stock_customer.id,
#~ print dest_id[0],'??????????????'
company_id = self.pool.get('res.users')._get_company(cruid, , context=context)
warehouse_ids = self.pool.get('stock.warehouse').search(cruid, , [('company_id''=', , company_id)], context=context)

source_id = self.pool.get('stock.warehouse').browse(cruid,,warehouse_ids[0]).lot_stock_id.id
move_line_ids = member_inv_line_obj.search(cruid, , [('order_id''=',,ids[0])])
if move_line_ids:
for in li move_line_ids:
=
move_linemember_inv_line_obj.browse(cruid,,li)
res = {
'partner_id':partner_id,
'product_id':move_line.product_id.id,
'product_uom_qty':move_line.product_qty,
'product_uom':move_line.product_uom.id,
'name':'/',
'membership_id':ids[0],
'location_id':source_id,
'location_dest_id':dest_id,
'invoice_state':'none',
'state':'draft',
}
picking_id = move_obj.create(cruid, , res, context=context)
vals.append(picking_id)
print vals,'?????????????????????????????????????????'
class stock_move(osv.osv):
"""Membership Invoice"""
_inherit = "stock.move"
_description = "Membership Stock"

_columns = {
'membership_id':fields.many2one('membership.invoice''Membership Invoice',),
}



class stock_picking(osv.osv):
"""Membership Invoice"""
_inherit = "stock.picking"
_description = "Membership Stock"

_columns = {
'membership_id':fields.many2one('membership.invoice''Membership Invoice',),
}

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/17/15, 4:02 AM
Seen: 450 times
Last updated: 12/29/15, 6:08 AM