Browse Source

[FIX] : Apr 10 Bug Fixed 'invoice_stock_move'

pull/376/head
AjmalCybro 2 weeks ago
parent
commit
177be61bd6
  1. 2
      invoice_stock_move/__manifest__.py
  2. 5
      invoice_stock_move/doc/RELEASE_NOTES.md
  3. 81
      invoice_stock_move/models/account_move.py

2
invoice_stock_move/__manifest__.py

@ -21,7 +21,7 @@
################################################################################
{
'name': "Stock Picking From Invoice",
'version': '17.0.1.0.1',
'version': '17.0.1.0.2',
'category': 'Accounting',
'summary': """Stock Picking From Customer/Supplier Invoice""",
'description': """This Module Enables To Create Stocks Picking From

5
invoice_stock_move/doc/RELEASE_NOTES.md

@ -10,3 +10,8 @@ Initial Commit for Stock Picking From Invoice
#### Version 17.0.1.0.1
#### Bugfix
-An issue was mentioned that picking type value is missing , updated the code
#### 06.03.2025
#### Version 17.0.1.0.2
#### Bugfix
-An issue was mentioned that picking type selection and user access , updated the code

81
invoice_stock_move/models/account_move.py

@ -37,66 +37,53 @@ class AccountMove(models.Model):
picking_type_id = fields.Many2one(comodel_name='stock.picking.type',
string='Picking Type',
compute='compute_stock_type',
store=True, readonly=False,
help="This will determine the picking type "
"of incoming/outgoing shipment")
@api.depends('move_type')
def compute_stock_type(self):
"""Computes the picking type based on the move type."""
for rec in self:
type = ''
data = self.env['stock.picking.type'].search([])
print('self._context.get', self._context.get('default_move_type'))
if self._context.get('default_move_type') == 'out_invoice':
for line in data:
if line.code == 'outgoing':
type = line
if self._context.get('default_move_type') == 'in_invoice':
for line in data:
if line.code == 'incoming':
type = line
rec.picking_type_id = type
rec.picking_type_id = False
picking_types = self.env['stock.picking.type'].search([])
if rec.move_type == 'out_invoice':
rec.picking_type_id = picking_types.filtered(lambda p: p.code == 'outgoing')[:1]
elif rec.move_type == 'in_invoice':
rec.picking_type_id = picking_types.filtered(lambda p: p.code == 'incoming')[:1]
def action_stock_move(self):
"""Function to create transfer from invoice"""
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'
if not order.picking_type_id:
raise UserError(_("Please select a picking type"))
if not order.invoice_picking_id:
pick_vals = {
'picking_type_id': order.picking_type_id.id,
'partner_id': order.partner_id.id,
'origin': order.name,
'move_type': 'direct',
}
picking = self.env['stock.picking'].create(pick)
self.invoice_picking_id = picking.id
self.picking_count = len(picking)
order = order.invoice_line_ids.filtered(lambda item:
item.product_id.type in
['product', 'consu'])
(order._create_stock_moves(picking)._action_confirm().
_action_assign())
if order.picking_type_id.code == 'outgoing':
pick_vals.update({
'location_dest_id': order.partner_id.property_stock_customer.id,
'location_id': order.picking_type_id.default_location_src_id.id,
})
elif order.picking_type_id.code == 'incoming':
pick_vals.update({
'location_dest_id': order.picking_type_id.default_location_dest_id.id,
'location_id': order.partner_id.property_stock_supplier.id,
})
picking = self.env['stock.picking'].create(pick_vals)
order.invoice_picking_id = picking.id
order.picking_count = 1
stock_moves = order.invoice_line_ids.filtered(lambda line: line.product_id.type in ['product', 'consu'])
if stock_moves:
stock_moves._create_stock_moves(picking)._action_confirm()._action_assign()
def action_view_picking(self):
"""Function to view moves while clicking shipment smart button"""
action = self.env.ref('stock.action_picking_tree_ready')
action = self.env.ref('stock.action_picking_tree_ready').sudo()
result = action.read()[0]
result.pop('id', None)
result['context'] = {}

Loading…
Cancel
Save