Skip to Content
Menu
This question has been flagged
1 Reply
3754 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

Avatar
Discard
Best Answer

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',),
}

Avatar
Discard