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. 83
      invoice_stock_move/models/account_move.py

2
invoice_stock_move/__manifest__.py

@ -21,7 +21,7 @@
################################################################################ ################################################################################
{ {
'name': "Stock Picking From Invoice", 'name': "Stock Picking From Invoice",
'version': '17.0.1.0.1', 'version': '17.0.1.0.2',
'category': 'Accounting', 'category': 'Accounting',
'summary': """Stock Picking From Customer/Supplier Invoice""", 'summary': """Stock Picking From Customer/Supplier Invoice""",
'description': """This Module Enables To Create Stocks Picking From '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 #### Version 17.0.1.0.1
#### Bugfix #### Bugfix
-An issue was mentioned that picking type value is missing , updated the code -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

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

Loading…
Cancel
Save