我想从客户发票退款中创建收货,当客户想要退货时,我会为退款创建贷记凭证。
问题,我可以创建传入货物,类型等于in和州等于草稿 但是当我按下按钮确认。它更改类型等于输出并移至交货订单。
我如何解决它。 请帮帮我。
代码..
def _prepare_order_picking(self, cr, uid, order, context=None):
return {
'origin': order.number,
'date': self.date_to_datetime(cr, uid, order.date_invoice, context),
'type': 'in',
'move_type': 'direct',
'partner_id': order.partner_id.id,
'note': order.comment,
'invoice_state': 'none',
'company_id': order.company_id.id,
'move_lines' : [],
}
def _prepare_order_line_move(self, cr, uid, order, line, picking_id, context=None):
warehouse = self.pool.get('stock.warehouse').search(cr, uid,[('company_id','=',order.company_id.id)],context=context)
location = self.pool.get('stock.warehouse').browse(cr, uid,warehouse[0],context=context)
location_id = location.lot_stock_id.id
output_id = location.lot_output_id.id
return {
'name': line.name or '',
'picking_id': picking_id,
'product_id': line.product_id.id,
'product_qty': line.quantity,
'product_uom': line.uos_id.id,
'product_uos': line.uos_id.id,
'date': self.date_to_datetime(cr, uid, order.date_invoice, context),
'date_expected': self.date_to_datetime(cr, uid, order.date_due, context),
'partner_id': order.partner_id.id,
'location_id': location_id,
'location_dest_id': output_id,
'tracking_id': False,
'state': 'draft',
'type':'in',
'company_id': order.company_id.id,
'price_unit': line.price_unit
}
def create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None):
if not picking_id:
picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
stock_move = self.pool.get('stock.move')
wf_service = netsvc.LocalService("workflow")
for order_line in order_lines:
if not order_line.product_id:
continue
if order_line.product_id.type in ('product', 'consu'):
move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context=context))
return picking_id
答案 0 :(得分:0)
对于传入货件,移动的源位置是供应商位置,目标位置是库存位置。但是在这里你已经完成了从库存位置到客户位置的逆过程,这与交货订单完全相同。更改库存移动的来源和目的地位置