Browse Source

Aug 07: [FIX] Bug Fixed 'return_invoice_bill'

pull/332/merge
Cybrosys Technologies 9 months ago
parent
commit
c0d32548e8
  1. 6
      return_invoice_bill/README.rst
  2. 4
      return_invoice_bill/__manifest__.py
  3. 9
      return_invoice_bill/doc/RELEASE_NOTES.md
  4. 6
      return_invoice_bill/models/stock_return_picking.py
  5. BIN
      return_invoice_bill/static/description/banner.png
  6. 2
      return_invoice_bill/static/description/index.html
  7. 4
      return_invoice_bill/views/stock_return_picking_views.xml
  8. 38
      return_invoice_bill/wizard/return_move.py

6
return_invoice_bill/README.rst

@ -2,9 +2,9 @@
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
Return Invoices And Bills Automated Credit/Debit Note Generation from Return Picking
========================= ==========================================================
This module allow to return the invoice or bill while picking the product in Odoo15. This module allow to return the invoice or bill while picking the product in Odoo16.
Company Company
------- -------

4
return_invoice_bill/__manifest__.py

@ -20,8 +20,8 @@
# #
############################################################################## ##############################################################################
{ {
"name": "Returning Invoices And Bills", "name": "Automated Credit/Debit Note Generation from Return Picking",
"version": "16.0.1.0.0", "version": "16.0.1.1.0",
"category": "Sales", "category": "Sales",
"summary": "For creating credit note and debit note while picking.", "summary": "For creating credit note and debit note while picking.",
"description": "We can create credit note or debit note while return the" "description": "We can create credit note or debit note while return the"

9
return_invoice_bill/doc/RELEASE_NOTES.md

@ -3,4 +3,11 @@
#### 27.02.2024 #### 27.02.2024
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
- Initial commit for Return Invoices And Bills - Initial commit for Automated Credit/Debit Note Generation from Return Picking
#### 05.08.2024
#### Version 16.0.1.1.0
#### UPDT
- Updated the return invoice line based on the return quantity.
- Fixed the issues while changing the language.

6
return_invoice_bill/models/stock_return_picking.py

@ -38,7 +38,11 @@ class StockReturnPicking(models.TransientModel):
active_id = self.env.context['active_id'] active_id = self.env.context['active_id']
if active_model == 'stock.picking' and active_id: if active_model == 'stock.picking' and active_id:
stock_picking = self.env[active_model].browse(active_id) stock_picking = self.env[active_model].browse(active_id)
result['picking_type_name'] = stock_picking.picking_type_id.name picking_type = stock_picking.picking_type_id
result['picking_type_name'] = self.env['ir.model.data'].search([
('model', '=', 'stock.picking.type'),
('res_id', '=', picking_type.id)
]).complete_name
return result return result
def _update_stock_picking(self): def _update_stock_picking(self):

BIN
return_invoice_bill/static/description/banner.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 84 KiB

2
return_invoice_bill/static/description/index.html

@ -28,7 +28,7 @@
<div class="col-sm-12 col-md-12 col-lg-12"> <div class="col-sm-12 col-md-12 col-lg-12">
<!-- APP HERO --> <!-- APP HERO -->
<h1 style="color: #FFFFFF; font-weight: bolder; font-size: 50px; text-align: center; margin-top: 50px;"> <h1 style="color: #FFFFFF; font-weight: bolder; font-size: 50px; text-align: center; margin-top: 50px;">
Return Invoices And Bills</h1> Automated Credit/Debit Note Generation from Return Picking</h1>
<p style="color:#FFFFFF; padding: 8px 15px; text-align: center; font-size: 24px;"> <p style="color:#FFFFFF; padding: 8px 15px; text-align: center; font-size: 24px;">
Allows Us To Return The Credit Note And Debit Note From The Allows Us To Return The Credit Note And Debit Note From The
Corresponding Return Form .</p> Corresponding Return Form .</p>

4
return_invoice_bill/views/stock_return_picking_views.xml

@ -12,11 +12,11 @@
<field name="picking_type_name" invisible="1"/> <field name="picking_type_name" invisible="1"/>
<button name="action_returns_with_credit_note" <button name="action_returns_with_credit_note"
string="Return With Credit Note" type="object" string="Return With Credit Note" type="object"
attrs="{'invisible': [('picking_type_name', '!=', 'Delivery Orders')]}"/> attrs="{'invisible': [('picking_type_name', '!=', 'stock.picking_type_out')]}"/>
<button name="action_returns_with_debit_note" <button name="action_returns_with_debit_note"
string="Return With Debit Note" string="Return With Debit Note"
type="object" type="object"
attrs="{'invisible': [('picking_type_name', '!=', 'Receipts')]}"/> attrs="{'invisible': [('picking_type_name', '!=', 'stock.picking_type_in')]}"/>
</xpath> </xpath>
</field> </field>
</record> </record>

38
return_invoice_bill/wizard/return_move.py

@ -38,16 +38,40 @@ class ReturnMove(models.TransientModel):
if not active_id: if not active_id:
raise ValidationError("No active_id found in the context.") raise ValidationError("No active_id found in the context.")
return_id = self.env['stock.return.picking'].browse(active_id) return_id = self.env['stock.return.picking'].browse(active_id)
return_id.create_returns() new_picking_id = return_id.create_returns()
new_picking = self.env['stock.picking'].browse(
int(new_picking_id['res_id']))
picking_id = return_id.picking_id picking_id = return_id.picking_id
sale_invoice_ids = picking_id.sale_id.invoice_ids sale_invoice_ids = picking_id.sale_id.invoice_ids
purchase_invoice_ids = picking_id.purchase_id.invoice_ids purchase_invoice_ids = picking_id.purchase_id.invoice_ids
if sale_invoice_ids and sale_invoice_ids.state == 'posted' or \ sale_all_posted = all(element == 'posted' for element in
purchase_invoice_ids and purchase_invoice_ids.state == 'posted': sale_invoice_ids.mapped(
invoice_ids = sale_invoice_ids if picking_id.picking_type_code == 'outgoing' else purchase_invoice_ids 'state')) if sale_invoice_ids else False
reverse_moves = invoice_ids._reverse_moves() purchase_all_posted = all(element == 'posted' for element in
reverse_moves.write({'invoice_date': fields.date.today()}) purchase_invoice_ids.mapped(
reverse_moves._post(soft=False) 'state')) if purchase_invoice_ids else False
if sale_all_posted or purchase_all_posted:
new_picking.action_set_quantities_to_reservation()
new_picking.button_validate()
if picking_id.sale_id:
action = self.env['sale.advance.payment.inv'].create(
{'sale_order_ids': [
fields.Command.link(
picking_id.sale_id.id)]})
invoice = action._create_invoices(picking_id.sale_id)
move_id = self.env['account.move'].browse(invoice.id)
else:
invoice = picking_id.purchase_id.action_create_invoice()
move_id = self.env['account.move'].browse(invoice.get('res_id'))
move_id.invoice_date = fields.Date.today()
move_id.action_post()
return {
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'account.move',
'target': 'current',
'res_id': move_id.id,
}
else: else:
raise ValidationError( raise ValidationError(
"The selected picking should have at least one posted invoice.") "The selected picking should have at least one posted invoice.")

Loading…
Cancel
Save