Browse Source

Sep 24: [FIX] Bug Fixed 'invoice_stock_move'

18.0
Risvana Cybro 2 days ago
parent
commit
0274a4ce3a
  1. 135
      invoice_stock_move/models/account_move.py
  2. BIN
      invoice_stock_move/static/description/assets/screenshots/Gif.gif
  3. BIN
      invoice_stock_move/static/description/assets/screenshots/Screenshot5.png
  4. BIN
      invoice_stock_move/static/description/assets/screenshots/Screenshot6.png
  5. BIN
      invoice_stock_move/static/description/assets/screenshots/Screenshot7.png
  6. 210
      invoice_stock_move/static/description/index.html

135
invoice_stock_move/models/account_move.py

@ -53,43 +53,104 @@ class AccountMove(models.Model):
rec.picking_type_id = type
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'
}
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())
"""Create or link a stock picking from the invoice for deliveries or credit note returns."""
for invoice in self:
# Determine picking type
if invoice.move_type == 'out_refund':
# Credit note → use incoming picking type
picking_type = self.env['stock.picking.type'].search(
[('code', '=', 'incoming')], limit=1)
if not picking_type:
raise UserError(
_("No incoming picking type configured. Please configure one."))
else:
# Customer invoice → use outgoing picking type
picking_type = self.env['stock.picking.type'].search(
[('code', '=', 'outgoing')], limit=1)
if not picking_type:
raise UserError(
_("No outgoing picking type configured. Please configure one."))
invoice.picking_type_id = picking_type
# Create picking if it does not exist
if not invoice.invoice_picking_id:
picking_vals = {
'picking_type_id': picking_type.id,
'partner_id': invoice.partner_id.id,
'origin': invoice.name,
'move_type': 'direct',
}
# Set locations based on picking type
if picking_type.code == 'outgoing':
picking_vals.update({
'location_id': picking_type.default_location_src_id.id,
'location_dest_id': invoice.partner_id.property_stock_customer.id,
})
else: # incoming
picking_vals.update({
'location_id': invoice.partner_id.property_stock_customer.id,
'location_dest_id': picking_type.default_location_dest_id.id,
})
picking = self.env['stock.picking'].create(picking_vals)
invoice.invoice_picking_id = picking.id
invoice.picking_count = 1
# Create stock moves for stockable and consumable products
stock_lines = invoice.invoice_line_ids.filtered(
lambda l: l.product_id.type in ['product', 'consu'])
for line in stock_lines:
self.env['stock.move'].create({
'name': line.name,
'product_id': line.product_id.id,
'product_uom_qty': line.quantity,
'product_uom': line.product_id.uom_id.id,
'picking_id': picking.id,
'location_id': picking_vals['location_id'],
'location_dest_id': picking_vals['location_dest_id'],
})
# Confirm and assign the picking
picking.action_confirm()
picking.action_assign()
# For credit notes, create a separate return picking
if invoice.move_type == 'out_refund':
original_picking = invoice.invoice_picking_id
# Create a new incoming picking for the return
return_picking = self.env['stock.picking'].create({
'origin': invoice.name,
'picking_type_id': picking_type.id,
'location_id': invoice.partner_id.property_stock_customer.id,
# source = customer
'location_dest_id': picking_type.default_location_dest_id.id,
# dest = stock
'partner_id': invoice.partner_id.id,
'move_type': 'direct',
})
# Create stock moves for returned products
for line in invoice.invoice_line_ids.filtered(
lambda l: l.product_id.type in ['product', 'consu']):
self.env['stock.move'].create({
'name': line.name,
'product_id': line.product_id.id,
'product_uom_qty': line.quantity,
'product_uom': line.product_id.uom_id.id,
'picking_id': return_picking.id,
'location_id': invoice.partner_id.property_stock_customer.id,
'location_dest_id': picking_type.default_location_dest_id.id,
})
# Confirm and assign the return picking
return_picking.action_confirm()
return_picking.action_assign()
# Link the return picking to the credit note
invoice.invoice_picking_id = return_picking.id
def action_view_picking(self):
"""Function to view moves while clicking shipment smart button"""

BIN
invoice_stock_move/static/description/assets/screenshots/Gif.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 332 KiB

BIN
invoice_stock_move/static/description/assets/screenshots/Screenshot5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

BIN
invoice_stock_move/static/description/assets/screenshots/Screenshot6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

BIN
invoice_stock_move/static/description/assets/screenshots/Screenshot7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

210
invoice_stock_move/static/description/index.html

@ -132,7 +132,8 @@
line-height: 15.96px;
text-transform: uppercase;
">
This Module Enables To Stock Pickings From Customer/Supplier Invoice.
This Module Enables To Stock Pickings From
Customer/Supplier Invoice.
</p>
<h1 class="text-center text-uppercase my-0"
style="
@ -238,7 +239,8 @@
</div>
<h5 class="m-0"
style="color:#000 !important; font-weight:bold">
Automatically creates stock picking from customer invoice.
Automatically creates stock picking from
customer invoice.
</h5>
</div>
</div>
@ -259,6 +261,23 @@
</h5>
</div>
</div>
<div class="col-lg-4">
<div class="mb-4 d-flex flex-column justify-content-center gap-3"
style="border-radius: 12px; border: 1px solid #B6BCCD;
background: #FFF;padding:32px ">
<div class="d-flex justify-content-center align-items-center"
style="background-color:#7847D9 !important; border-radius:8px !important; height:42px; width:42px">
<img src="./assets/icons/feature-icon.svg"
class="img-responsive" height="26px"
width="26px">
</div>
<h5 class="m-0"
style="color:#000 !important; font-weight:bold">
Creates incoming stock (WH/IN) from credit
note using the shipment button.
</h5>
</div>
</div>
</div>
</div>
<!--code -->
@ -403,7 +422,8 @@
</div>
<div class="col-md-12 mb-4">
<p style="font-weight:400; font-size:16px; line-height:150%; text-align:center; color:#64728f">
Transfer button to transfer the product.
Transfer button to transfer the
product.
</p>
</div>
<div class="col-md-12 text-center">
@ -431,7 +451,8 @@
</div>
<div class="col-md-12 mb-4">
<p style="font-weight:400; font-size:16px; line-height:150%; text-align:center; color:#64728f">
Shipment smart button to view the transfer in inventory.
Shipment smart button to view
the transfer in inventory.
</p>
</div>
<div class="col-md-12 text-center">
@ -469,6 +490,85 @@
</div>
</div>
</div>
<div class="position-relative mb-4"
style="border-radius:10px; background-color:#f4f4f4">
<div class="p-md-5 p-3 position-relative">
<div class="row">
<div class="col-md-12">
<h1 style="font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size: 40px;
font-weight: 700;">
<span
style="color:#121212; font-size:calc(1.1rem + 1vw)">Transfer Button in </span>
<span
style="color: #7f54b3; font-size:calc(1.1rem + 1vw)">Credit Note</span>
</h1>
</div>
<div class="col-md-12 mb-4">
<p style="font-weight:400; font-size:16px; line-height:150%; text-align:center; color:#64728f">
Transfer button shows the
Shipment smart button which
creates a WH/IN for returned
products.
</p>
</div>
<div class="col-md-12 text-center">
<div class="d-inline-block p-3 shadow-sm"
style="background-color:#fff; border-radius:10px">
<img alt=""
class="img-fluid"
loading="lazy"
src="./assets/screenshots/Screenshot5.png"
style="min-height: 1px;">
</div>
</div>
</div>
</div>
</div>
<div class="p-md-5 p-3 position-relative">
<div class="row">
<div class="col-md-12">
<h1 style="font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size: 40px;
font-weight: 700;">
<span
style="color:#121212; font-size:calc(1.1rem + 1vw)">Shipment </span>
<span
style="color: #7f54b3; font-size:calc(1.1rem + 1vw)">Smart Button</span>
</h1>
</div>
<div class="col-md-12 text-center">
<div class="d-inline-block p-3 shadow-sm"
style="background-color:#fff; border-radius:10px">
<img alt="" class="img-fluid"
loading="lazy"
src="./assets/screenshots/Screenshot6.png"
style="min-height: 1px;">
</div>
</div>
</div>
</div>
<div class="p-md-5 p-3 position-relative">
<div class="row">
<div class="col-md-12">
<h1 style="font-weight:bold; font-size:calc(1.1rem + 1vw); line-height:120%; text-align:center; text-transform:capitalize; font-size: 40px;
font-weight: 700;">
<span
style="color:#121212; font-size:calc(1.1rem + 1vw)">Corresponding </span>
<span
style="color: #7f54b3; font-size:calc(1.1rem + 1vw)">Transfer</span>
</h1>
</div>
<div class="col-md-12 text-center">
<div class="d-inline-block p-3 shadow-sm"
style="background-color:#fff; border-radius:10px">
<img alt="" class="img-fluid"
loading="lazy"
src="./assets/screenshots/Screenshot7.png"
style="min-height: 1px;">
</div>
</div>
</div>
</div>
</div>
<div aria-labelledby="feature-tab"
class="tab-pane fade show py-1" id="feature"
@ -485,7 +585,8 @@
style="color:#fff; font-size:14px"></i>
</div>
<p style="color:#1A202C; font-weight:600; font-size:1.2rem; margin-bottom:2px">
Stock Picking from Customer Invoice.</p>
Stock Picking from Customer
Invoice.</p>
</div>
</div>
</div>
@ -499,7 +600,8 @@
style="color:#fff; font-size:14px"></i>
</div>
<p style="color:#1A202C; font-weight:600; font-size:1.2rem; margin-bottom:2px">
Stock Picking from Supplier bill.</p>
Stock Picking from Supplier
bill.</p>
</div>
</div>
</div>
@ -529,8 +631,10 @@
style="cursor: pointer; background-color:#f8f8f8; border:none; border-top-right-radius:10px; border-top-left-radius:10px; padding: 12px 24px;">
<a class="card-title text-decoration-none"
style=" font-size:18px; line-height:30px; font-weight:500; color:#040f3a">
Can stock pickings be created
from invoices with this module?
Can stock pickings
be created
from invoices with
this module?
<img alt=""
class="float-end"
src="//apps.odoocdn.com/apps/assets/16.0/index_test_odoo/assets/icons/down.svg?6ef7fd7"
@ -543,8 +647,10 @@
id="collapseFAQOne"
style=" box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px; border: 1px solid #f8f8f8; border-bottom-right-radius:10px; border-bottom-left-radius:10px">
<p style=" padding:0.75rem 1.25rem; font-size:16px; line-height:27px; color:#888; font-weight:normal; border-bottom-right-radius:10px; border-bottom-left-radius:10px">
Yes, it allows stock pickings to
be generated from customer and
Yes, it allows stock
pickings to
be generated from
customer and
supplier invoices.
</div>
</div>
@ -558,8 +664,10 @@
style="cursor: pointer; background-color:#f8f8f8; border:1px solid #f8f8f8; border-top-right-radius:10px; border-top-left-radius:10px; padding: 12px 24px">
<a class="card-title text-decoration-none"
style=" font-size:18px; line-height:30px; font-weight:500; color:#040f3a">
Does this module connect
invoices to inventory movements?
Does this module
connect
invoices to
inventory movements?
<img alt=""
class="float-end"
src="//apps.odoocdn.com/apps/assets/16.0/index_test_odoo/assets/icons/down.svg?6ef7fd7"
@ -572,9 +680,12 @@
id="collapseFAQThree"
style="box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px; border: 1px solid #f8f8f8; border-bottom-right-radius:10px; border-bottom-left-radius:10px">
<p style="padding:0.75rem 1.25rem; font-size:16px; line-height:27px; color:#888; font-weight:normal; border-bottom-right-radius:10px; border-bottom-left-radius:10px">
Yes, it links invoices with
the corresponding stock
operations automatically.
Yes, it links
invoices with
the corresponding
stock
operations
automatically.
</p>
</div>
</div>
@ -629,16 +740,20 @@
class="oe_slogan">
<b>Related Products</b>
</h2>
<div id="demo" class="row carousel slide mt64 mb32" data-bs-ride="carousel">
<div id="demo" class="row carousel slide mt64 mb32"
data-bs-ride="carousel">
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16" style="float: left; padding: 10px;">
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/pos_receipt_extend"
target="_blank" style="color: #000; text-decoration: none;">
target="_blank"
style="color: #000; text-decoration: none;">
<div style="border-radius: 6px; padding: 16px; border: 1px solid #cbcbcb;"
class="shadow-sm">
<img class="img img-responsive center-block" style=" max-width: 100%;"
<img class="img img-responsive center-block"
style=" max-width: 100%;"
src="./assets/modules/k1.png"/>
<h4 class="mt0 text-truncate"
style="text-align:center;width:100&#37; margin-bottom: 8px; font-weight: 600; padding-top: 16px; text-decoration:none;font-size: 18px; padding-bottom: 8px; margin-bottom: 0px">
@ -646,40 +761,51 @@
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16" style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/barcode_scanning_sale_purchase" target="_blank"
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/barcode_scanning_sale_purchase"
target="_blank"
style="color: #000; text-decoration: none;">
<div style="border-radius: 6px; padding: 16px; border: 1px solid #cbcbcb;"
class="shadow-sm">
<img class="img img-responsive center-block" style=" max-width: 100%;"
<img class="img img-responsive center-block"
style=" max-width: 100%;"
src="./assets/modules/k2.png"/>
<h4 class="mt0 text-truncate"
style="text-align:center;width:100&#37; margin-bottom: 8px; font-weight: 600; padding-top: 16px; text-decoration:none;font-size: 18px; padding-bottom: 8px; margin-bottom: 0px">
Barcode Scanning Support For Sale and Purchase</h4>
Barcode Scanning Support For
Sale and Purchase</h4>
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16" style="float: left; padding: 10px;">
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/user_login_alert"
target="_blank" style="color: #000; text-decoration: none;">
target="_blank"
style="color: #000; text-decoration: none;">
<div style="border-radius: 6px;padding: 16px; border: 1px solid #cbcbcb;"
class="shadow-sm">
<img class="img img-responsive center-block" style=" max-width: 100%;"
<img class="img img-responsive center-block"
style=" max-width: 100%;"
src="./assets/modules/k3.png"/>
<h4 class="mt0 text-truncate"
style="text-align:center;width:100&#37; margin-bottom: 8px; font-weight: 600; padding-top: 16px; text-decoration:none;font-size: 18px; padding-bottom: 8px; margin-bottom: 0px">
Amount In Words In Invoice, Sale Order And Purchase Order</h4>
Amount In Words In Invoice, Sale
Order And Purchase Order</h4>
</div>
</a>
</div>
</div>
<div class="carousel-item">
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16" style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/storage_dashboard" target="_blank"
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/storage_dashboard"
target="_blank"
style="color: #000; text-decoration: none;">
<div style="border-radius: 6px; padding: 16px; border: 1px solid #cbcbcb;"
class="shadow-sm">
<img class="img img-responsive center-block" style=" max-width: 100%;"
<img class="img img-responsive center-block"
style=" max-width: 100%;"
src="./assets/modules/k4.png"/>
<h4 class="mt0 text-truncate"
style="text-align:center;width:100&#37; margin-bottom: 8px; font-weight: 600; padding-top: 16px; text-decoration:none;font-size: 18px; padding-bottom: 8px; margin-bottom: 0px">
@ -687,12 +813,15 @@
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16" style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/pdf_report_password_protection" target="_blank"
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/pdf_report_password_protection"
target="_blank"
style="color: #000; text-decoration: none;">
<div style="border-radius: 6px; padding: 16px; border: 1px solid #cbcbcb;"
class="shadow-sm">
<img class="img img-responsive center-block" style=" max-width: 100%;"
<img class="img img-responsive center-block"
style=" max-width: 100%;"
src="./assets/modules/k5.png"/>
<h4 class="mt0 text-truncate"
style="text-align:center;width:100&#37; margin-bottom: 8px; font-weight: 600; padding-top: 16px; text-decoration:none;font-size: 18px; padding-bottom: 8px; margin-bottom: 0px">
@ -700,12 +829,15 @@
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16" style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/custom_gantt_view" target="_blank"
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float: left; padding: 10px;">
<a href="https://apps.odoo.com/apps/modules/18.0/custom_gantt_view"
target="_blank"
style="color: #000; text-decoration: none;">
<div style="border-radius: 6px; padding: 16px; border: 1px solid #cbcbcb;"
class="shadow-sm">
<img class="img img-responsive center-block" style=" max-width: 100%;"
<img class="img img-responsive center-block"
style=" max-width: 100%;"
src="./assets/modules/k6.png"/>
<h4 class="mt0 text-truncate"
style="text-align:center;width:100&#37; margin-bottom: 8px; font-weight: 600; padding-top: 16px; text-decoration:none;font-size: 18px; padding-bottom: 8px; margin-bottom: 0px">
@ -716,13 +848,15 @@
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#demo" data-bs-slide="prev"
<a class="carousel-control-prev" href="#demo"
data-bs-slide="prev"
style="margin-left: -30px;width: 35px;color: #000;">
<span class="carousel-control-prev-icon">
<i class="fa fa-chevron-left" style="font-size:24px"></i>
</span>
</a>
<a class="carousel-control-next" href="#demo" data-bs-slide="next"
<a class="carousel-control-next" href="#demo"
data-bs-slide="next"
style="margin-right: -30px;width: 35px;color: #000;">
<span class="carousel-control-next-icon">
<i class="fa fa-chevron-right" style="font-size:24px"></i>

Loading…
Cancel
Save