I created a direct relationship between the invoice and the stock move by downloading the Odoo app store developed by Cybrosys called "invoice_stock_move". If anyone has already used it, then how can I use the "Transfer" button in order to validate transfers automatically when pressing on this button?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
1
Balas
3036
Tampilan
Hi,
Update the code inside models > invoice_stock.py
inside the button action 'action_stock_move'
Update the code as follows after creating picking
def action_stock_move(self):
if not self.picking_type_id:
raise UserError(_(
" Please select a picking type"))
for order in self:
if not self.invoice_picking_id:
pick = {}
if self.picking_type_id.code == 'outgoing':
pick = {
'picking_type_id': self.picking_type_id.id,
'partner_id': self.partner_id.id,
'origin': self.name,
'location_dest_id': self.partner_id.property_stock_customer.id,
'location_id': self.picking_type_id.default_location_src_id.id,
'move_type': 'direct'
}
if self.picking_type_id.code == 'incoming':
pick = {
'picking_type_id': self.picking_type_id.id,
'partner_id': self.partner_id.id,
'origin': self.name,
'location_dest_id': self.picking_type_id.default_location_dest_id.id,
'location_id': self.partner_id.property_stock_supplier.id,
'move_type': 'direct'
}
picking = self.env['stock.picking'].create(pick)
self.invoice_picking_id = picking.id
self.picking_count = len(picking)
moves = order.invoice_line_ids.filtered(
lambda r: r.product_id.type in ['product', 'consu'])._create_stock_moves(picking)
move_ids = moves._action_confirm()
move_ids._action_assign()
if picking.state == 'draft':
picking.action_confirm()
if picking.state != 'assigned':
picking.action_assign()
if picking.state != 'assigned':
raise UserError(
_("Could not reserve all requested products. Please use the \
'Mark as Todo\
' button to handle the reservation manually."))
for move in picking.move_ids.filtered(
lambda m: m.state not in ['done', 'cancel']):
for move_line in move.move_line_ids:
move_line.qty_done = move.product_uom_qty
picking.state = 'done'
Regards
Thank you, for anyone that will see it, just replace move_ids with move_lines and it should work
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
0
Mar 23
|
1737 | ||
|
0
Mar 18
|
2728 | ||
Know if Stock Picking is IN or OUT
Diselesaikan
|
|
1
Agu 24
|
1227 | |
|
3
Feb 20
|
3394 | ||
|
0
Okt 17
|
3001 |