@@ -498,7 +603,6 @@
Odoo
Consultancy
diff --git a/return_invoice_bill/views/account_move_views.xml b/return_invoice_bill/views/account_move_views.xml
new file mode 100644
index 000000000..0d79619e8
--- /dev/null
+++ b/return_invoice_bill/views/account_move_views.xml
@@ -0,0 +1,14 @@
+
+
+
+
+ account.move.view.form.inherit.return.invoice.bill
+ account.move
+
+
+
+
+
+
+
+
diff --git a/return_invoice_bill/views/stock_picking_views.xml b/return_invoice_bill/views/stock_picking_views.xml
index 812173877..7adbfff71 100644
--- a/return_invoice_bill/views/stock_picking_views.xml
+++ b/return_invoice_bill/views/stock_picking_views.xml
@@ -7,16 +7,16 @@
stock.picking
-
+
+
+ type="object"
+ attrs="{'invisible': ['|',('picking_type_name', '!=', 'Delivery Orders'), ('is_paid', '=', False)]}"/>
+ type="object"
+ attrs="{'invisible': ['|',('picking_type_name', '!=', 'Receipts'), ('is_paid', '=', False)]}"/>
diff --git a/return_invoice_bill/views/stock_return_picking_views.xml b/return_invoice_bill/views/stock_return_picking_views.xml
index a31c58422..29688c1a2 100644
--- a/return_invoice_bill/views/stock_return_picking_views.xml
+++ b/return_invoice_bill/views/stock_return_picking_views.xml
@@ -3,7 +3,7 @@
- return.stock.return.picking.view.form.inherit.return.invoice.bill
+ stock.return.picking.view.form.inherit.return.invoice.bill
stock.return.picking
@@ -12,11 +12,11 @@
+ attrs="{'invisible': [('picking_type_name', '!=', 'stock.picking_type_out')]}"/>
+ attrs="{'invisible': [('picking_type_name', '!=', 'stock.picking_type_in')]}"/>
diff --git a/return_invoice_bill/wizard/return_move.py b/return_invoice_bill/wizard/return_move.py
index 6ec8dc752..4de35ecef 100644
--- a/return_invoice_bill/wizard/return_move.py
+++ b/return_invoice_bill/wizard/return_move.py
@@ -19,35 +19,59 @@
# If not, see .
#
##############################################################################
-from odoo.exceptions import ValidationError
-from odoo import models, fields
+from odoo.exceptions import ValidationError, UserError
+from odoo import fields, models, _
class ReturnMove(models.TransientModel):
"""Transient model for ,enter the cancel reason credit and debit note."""
_name = 'return.move'
_description = 'Return Move'
- _rec_name = 'reason'
reason = fields.Char(string='Reason',
help='Specify the reason for credit note',
required=True)
- def apply_reverse_entry(self):
- """Returning the invoice or bill and create credit and debit note. """
+
+ def action_apply_reverse_entry(self):
+ """Returning the invoice or bill and create credit and debit note."""
active_id = self.env.context['active_id']
return_id = self.env['stock.return.picking'].browse(active_id)
- return_id.create_returns()
+ return_data = return_id.create_returns()
+ return_picking = self.env['stock.picking'].browse(return_data.get('res_id'))
+ return_picking.action_set_quantities_to_reservation()
+ return_picking.button_validate()
if return_id.picking_id.sale_id.invoice_ids or return_id.picking_id.purchase_id.invoice_ids:
- if return_id.picking_id.picking_type_code == 'outgoing':
- reverse_move = return_id.picking_id.sale_id.invoice_ids._reverse_moves()
- reverse_move._post(soft=False)
- return
- reverse_move = return_id.picking_id.purchase_id.invoice_ids._reverse_moves()
- reverse_move.write({
- 'invoice_date': fields.date.today()
+ for invoice in (
+ return_id.picking_id.sale_id.invoice_ids + return_id.picking_id.purchase_id.invoice_ids):
+ if invoice.reversed_entry_id:
+ raise ValidationError(
+ "The selected invoice has already been reversed.")
+ move_type = 'out_refund' if return_id.picking_id.picking_type_code == 'outgoing' else 'in_refund'
+
+ reverse_move = self.env['account.move'].create({
+ 'partner_id': return_picking.partner_id.id,
+ 'move_type': move_type,
+ 'picking_id':return_id.picking_id.id,
+ 'invoice_date': return_picking.date_done,
+ 'ref': _('Reversal of Credit Notes: %s, %s') % (invoice.name,self.reason),
+ 'invoice_line_ids': [
+ (0, 0, {
+ 'product_id': rec.product_id.id,
+ 'name': rec.product_id.name,
+ 'quantity': rec.quantity_done,
+ 'price_unit': rec.product_id.list_price,
+ 'price_subtotal': rec.quantity_done * rec.product_id.list_price,
+ }) for rec in return_picking.move_ids_without_package]
})
- reverse_move._post(soft=False)
+ reverse_move.action_post()
+ return {
+ 'type': 'ir.actions.act_window',
+ 'view_mode': 'form',
+ 'res_model': 'account.move',
+ 'target': 'current',
+ 'res_id': reverse_move.id,
+ }
else:
raise ValidationError(
"The selected picking should have at least one invoice.")
diff --git a/return_invoice_bill/wizard/return_move_views.xml b/return_invoice_bill/wizard/return_move_views.xml
index 98cd9b2e9..5e43aa335 100644
--- a/return_invoice_bill/wizard/return_move_views.xml
+++ b/return_invoice_bill/wizard/return_move_views.xml
@@ -12,7 +12,7 @@
@@ -21,7 +21,7 @@
-
+
Return Moves
return.move
form