From b3f75d4348fbf5b7c9488c58a13e91ac0d60e0d9 Mon Sep 17 00:00:00 2001 From: Bhavesh Odedra Date: Fri, 9 Feb 2018 22:47:33 +0530 Subject: [PATCH] [11.0] MIG: rma_account --- rma_account/README.rst | 1 + rma_account/__init__.py | 2 +- rma_account/__manifest__.py | 5 +- rma_account/demo/rma_operation.xml | 8 +- rma_account/models/__init__.py | 2 +- rma_account/models/invoice.py | 35 ++-- rma_account/models/rma_operation.py | 2 +- rma_account/models/rma_order.py | 20 +-- rma_account/models/rma_order_line.py | 8 +- rma_account/tests/__init__.py | 2 +- rma_account/tests/test_rma.py | 52 +++--- rma_account/tests/test_rma_dropship.py | 13 +- rma_account/tests/test_supplier_rma.py | 75 +++----- rma_account/views/invoice_view.xml | 6 +- rma_account/views/rma_operation_view.xml | 40 ++--- rma_account/views/rma_order_line_view.xml | 167 +++++++++--------- rma_account/views/rma_order_view.xml | 122 +++++++------ rma_account/wizards/__init__.py | 1 - rma_account/wizards/rma_add_invoice.py | 5 - .../rma_order_line_make_supplier_rma.py | 1 - rma_account/wizards/rma_refund.py | 17 +- rma_account/wizards/rma_refund.xml | 141 +++++++-------- 22 files changed, 339 insertions(+), 386 deletions(-) diff --git a/rma_account/README.rst b/rma_account/README.rst index 56f20fd3..c8003352 100644 --- a/rma_account/README.rst +++ b/rma_account/README.rst @@ -43,6 +43,7 @@ Contributors * Jordi Ballester Alomar * Aaron Henriquez * Lois Rilo +* Bhavesh Odedra Maintainer ---------- diff --git a/rma_account/__init__.py b/rma_account/__init__.py index 4105ff51..f3284a96 100644 --- a/rma_account/__init__.py +++ b/rma_account/__init__.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + from . import models from . import wizards diff --git a/rma_account/__manifest__.py b/rma_account/__manifest__.py index 07fadf99..dfd00108 100644 --- a/rma_account/__manifest__.py +++ b/rma_account/__manifest__.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) { 'name': 'RMA Account', - 'version': '9.0.1.0.0', + 'version': '11.0.1.0.0', 'license': 'LGPL-3', 'category': 'RMA', 'summary': 'Integrates RMA with Invoice Processing', @@ -21,6 +20,6 @@ 'wizards/rma_add_invoice.xml', 'wizards/rma_refund.xml', ], - 'installable': False, + 'installable': True, 'auto_install': True, } diff --git a/rma_account/demo/rma_operation.xml b/rma_account/demo/rma_operation.xml index be6fd118..9a4e5738 100644 --- a/rma_account/demo/rma_operation.xml +++ b/rma_account/demo/rma_operation.xml @@ -1,5 +1,5 @@ - - + + no @@ -35,10 +35,6 @@ no - - no - - no diff --git a/rma_account/models/__init__.py b/rma_account/models/__init__.py index 90fbe336..bdd70de6 100644 --- a/rma_account/models/__init__.py +++ b/rma_account/models/__init__.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + from . import rma_order from . import rma_order_line from . import rma_operation diff --git a/rma_account/models/invoice.py b/rma_account/models/invoice.py index b7309659..18eeeda7 100644 --- a/rma_account/models/invoice.py +++ b/rma_account/models/invoice.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) @@ -72,28 +71,30 @@ class AccountInvoice(models.Model): def action_view_rma_supplier(self): action = self.env.ref('rma.action_rma_supplier_lines') result = action.read()[0] - rma_list = self.mapped('invoice_line_ids.rma_line_ids').ids - # choose the view_mode accordingly - if len(rma_list) != 1: - result['domain'] = [('id', 'in', rma_list)] - elif len(rma_list) == 1: - res = self.env.ref('rma.view_rma_line_supplier_form', False) - result['views'] = [(res and res.id or False, 'form')] - result['res_id'] = rma_list[0] + rma_ids = self.mapped('invoice_line_ids.rma_line_ids').ids + if rma_ids: + # choose the view_mode accordingly + if len(rma_ids) > 1: + result['domain'] = [('id', 'in', rma_ids)] + else: + res = self.env.ref('rma.view_rma_line_supplier_form', False) + result['views'] = [(res and res.id or False, 'form')] + result['res_id'] = rma_ids[0] return result @api.multi def action_view_rma_customer(self): action = self.env.ref('rma.action_rma_customer_lines') result = action.read()[0] - rma_list = self.mapped('invoice_line_ids.rma_line_ids').ids - # choose the view_mode accordingly - if len(rma_list) != 1: - result['domain'] = [('id', 'in', rma_list)] - elif len(rma_list) == 1: - res = self.env.ref('rma.view_rma_line_form', False) - result['views'] = [(res and res.id or False, 'form')] - result['res_id'] = rma_list[0] + rma_ids = self.mapped('invoice_line_ids.rma_line_ids').ids + if rma_ids: + # choose the view_mode accordingly + if len(rma_ids) > 1: + result['domain'] = [('id', 'in', rma_ids)] + else: + res = self.env.ref('rma.view_rma_line_form', False) + result['views'] = [(res and res.id or False, 'form')] + result['res_id'] = rma_ids[0] return result diff --git a/rma_account/models/rma_operation.py b/rma_account/models/rma_operation.py index 55aeea40..043826c6 100644 --- a/rma_account/models/rma_operation.py +++ b/rma_account/models/rma_operation.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + from odoo import fields, models diff --git a/rma_account/models/rma_order.py b/rma_account/models/rma_order.py index 7b710b47..e16f4ca3 100644 --- a/rma_account/models/rma_order.py +++ b/rma_account/models/rma_order.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + from odoo import api, fields, models @@ -94,30 +94,28 @@ class RmaOrder(models.Model): invoice_ids = self.mapped( 'rma_line_ids.refund_line_ids.invoice_id').ids # choose the view_mode accordingly - if len(invoice_ids) != 1: + if len(invoice_ids) > 1: result['domain'] = [('id', 'in', invoice_ids)] - elif len(invoice_ids) == 1: + else: res = self.env.ref('account.invoice_supplier_form', False) result['views'] = [(res and res.id or False, 'form')] - result['res_id'] = invoice_ids[0] + result['res_id'] = invoice_ids and invoice_ids[0] return result @api.multi def action_view_invoice(self): if self.type == "supplier": action = self.env.ref('account.action_invoice_tree2') + res = self.env.ref('account.invoice_supplier_form', False) else: action = self.env.ref('account.action_invoice_tree') + res = self.env.ref('account.invoice_form', False) result = action.read()[0] invoice_ids = self.mapped('rma_line_ids.invoice_id').ids # choose the view_mode accordingly - if len(invoice_ids) != 1: + if len(invoice_ids) > 1: result['domain'] = [('id', 'in', invoice_ids)] - elif len(invoice_ids) == 1: - if self.type == "supplier": - res = self.env.ref('account.invoice_supplier_form', False) - else: - res = self.env.ref('account.invoice_form', False) + else: result['views'] = [(res and res.id or False, 'form')] - result['res_id'] = invoice_ids[0] + result['res_id'] = invoice_ids and invoice_ids[0] return result diff --git a/rma_account/models/rma_order_line.py b/rma_account/models/rma_order_line.py index 2d49f855..dc1eb29e 100644 --- a/rma_account/models/rma_order_line.py +++ b/rma_account/models/rma_order_line.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + from odoo import _, api, fields, models from odoo.exceptions import ValidationError, UserError from odoo.addons import decimal_precision as dp @@ -211,12 +211,12 @@ class RmaOrderLine(models.Model): result = action.read()[0] invoice_ids = self.mapped('refund_line_ids.invoice_id').ids # choose the view_mode accordingly - if len(invoice_ids) != 1: + if len(invoice_ids) > 1: result['domain'] = [('id', 'in', invoice_ids)] - elif len(invoice_ids) == 1: + else: res = self.env.ref('account.invoice_supplier_form', False) result['views'] = [(res and res.id or False, 'form')] - result['res_id'] = invoice_ids[0] + result['res_id'] = invoice_ids and invoice_ids[0] return result @api.multi diff --git a/rma_account/tests/__init__.py b/rma_account/tests/__init__.py index dfa77946..fd0efa32 100644 --- a/rma_account/tests/__init__.py +++ b/rma_account/tests/__init__.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + from . import test_rma from . import test_supplier_rma from . import test_rma_dropship diff --git a/rma_account/tests/test_rma.py b/rma_account/tests/test_rma.py index d57c0090..78b96232 100644 --- a/rma_account/tests/test_rma.py +++ b/rma_account/tests/test_rma.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) @@ -275,13 +274,11 @@ class TestRma(common.TransactionCase): 'picking_type': 'incoming', 'active_id': 1 }).create({}) - procurements = wizard._create_picking() - group_ids = set([proc.group_id.id for proc in procurements if - proc.group_id]) - domain = [('group_id', 'in', list(group_ids))] - picking = self.stockpicking.search(domain) - self.assertEquals(len(picking), 1, - "Incorrect number of pickings created") + wizard._create_picking() + res = self.rma_customer_id.rma_line_ids.action_view_in_shipments() + self.assertTrue('res_id' in res, + "Incorrect number of pickings created") + picking = self.env['stock.picking'].browse(res['res_id']) moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") @@ -297,22 +294,31 @@ class TestRma(common.TransactionCase): "Wrong qty delivered") # product specific if line.product_id == self.product_1: + self.assertEquals(line.qty_to_deliver, 0, + "Wrong qty to deliver") self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") self.assertEquals(line.qty_incoming, 3, "Wrong qty incoming") if line.product_id == self.product_2: + self.assertEquals(line.qty_to_deliver, 0, + "Wrong qty to deliver") self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive") self.assertEquals(line.qty_incoming, 5, "Wrong qty incoming") if line.product_id == self.product_3: + self.assertEquals(line.qty_to_deliver, 0, + "Wrong qty to deliver") self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive") self.assertEquals(line.qty_incoming, 2, "Wrong qty incoming") picking.action_assign() - picking.do_transfer() + picking.action_assign() + for line in picking.move_line_ids: + line.qty_done = line.product_uom_qty + picking.action_done() for line in self.rma_customer_id.rma_line_ids: self.assertEquals(line.qty_to_receive, 0, "Wrong qty to_receive") @@ -344,15 +350,12 @@ class TestRma(common.TransactionCase): 'active_model': 'rma.order.line', 'picking_type': 'outgoing', }).create({}) - procurements = wizard._create_picking() - group_ids = set([proc.group_id.id for proc in procurements if - proc.group_id]) - domain = [('group_id', 'in', list(group_ids))] - pickings = self.stockpicking.search(domain) - self.assertEquals(len(pickings), 2, - "Incorrect number of pickings created") - picking_out = pickings[1] - moves = picking_out.move_lines + wizard._create_picking() + res = self.rma_customer_id.rma_line_ids.action_view_out_shipments() + self.assertTrue('res_id' in res, + "Incorrect number of pickings created") + picking = self.env['stock.picking'].browse(res['res_id']) + moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") for line in self.rma_customer_id.rma_line_ids: @@ -383,13 +386,12 @@ class TestRma(common.TransactionCase): "Wrong qty to deliver") self.assertEquals(line.qty_outgoing, 2, "Wrong qty outgoing") - picking_out.action_assign() - picking_out.do_transfer() - for line in self.rma_customer_id.rma_line_ids: - self.assertEquals(line.qty_to_receive, 0, - "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 0, - "Wrong qty incoming") + picking.action_confirm() + picking.action_assign() + for line in picking.move_line_ids: + line.qty_done = line.product_uom_qty + picking.action_done() + for line in self.rma_customer_id.rma_line_ids[0]: self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver") self.assertEquals(line.qty_outgoing, 0, diff --git a/rma_account/tests/test_rma_dropship.py b/rma_account/tests/test_rma_dropship.py index abe07221..c469252d 100644 --- a/rma_account/tests/test_rma_dropship.py +++ b/rma_account/tests/test_rma_dropship.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) @@ -45,13 +44,11 @@ class TestRmaDropship(test_rma.TestRma): 'active_model': 'rma.order.line', 'picking_type': 'incoming', }).create({}) - procurements = wizard._create_picking() - group_ids = set([proc.group_id.id for proc in procurements if - proc.group_id]) - domain = [('group_id', 'in', list(group_ids))] - picking = self.stockpicking.search(domain) - self.assertEquals(len(picking), 1, - "Incorrect number of pickings created") + wizard._create_picking() + res = supplier_rma.rma_line_ids.action_view_in_shipments() + self.assertTrue('res_id' in res, + "Incorrect number of pickings created") + picking = self.env['stock.picking'].browse(res['res_id']) moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") diff --git a/rma_account/tests/test_supplier_rma.py b/rma_account/tests/test_supplier_rma.py index 321b46e1..8da1bd0c 100644 --- a/rma_account/tests/test_supplier_rma.py +++ b/rma_account/tests/test_supplier_rma.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) @@ -22,13 +21,11 @@ class TestSupplierRma(test_rma.TestRma): 'picking_type': 'outgoing', 'active_id': 1 }).create({}) - procurements = wizard._create_picking() - group_ids = set([proc.group_id.id for proc in procurements if - proc.group_id]) - domain = [('group_id', 'in', list(group_ids))] - picking = self.stockpicking.search(domain) - self.assertEquals(len(picking), 1, - "Incorrect number of pickings created") + wizard._create_picking() + res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments() + self.assertTrue('res_id' in res, + "Incorrect number of pickings created") + picking = self.env['stock.picking'].browse(res['res_id']) moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") @@ -62,9 +59,10 @@ class TestSupplierRma(test_rma.TestRma): "Wrong qty to deliver") self.assertEquals(line.qty_outgoing, 2, "Wrong qty outgoing") - - picking.action_assign() - picking.do_transfer() + picking.force_assign() + for line in picking.move_lines: + line.quantity_done = line.product_uom_qty + picking.button_validate() for line in self.rma_supplier_id.rma_line_ids: self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") @@ -76,12 +74,12 @@ class TestSupplierRma(test_rma.TestRma): self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") if line.product_id == self.product_2: - self.assertEquals(line.qty_outgoing, 0, + self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered") self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive") if line.product_id == self.product_3: - self.assertEquals(line.qty_outgoing, 0, + self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered") self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive") @@ -91,65 +89,48 @@ class TestSupplierRma(test_rma.TestRma): 'active_model': 'rma.order.line', 'picking_type': 'incoming', }).create({}) - procurements = wizard._create_picking() - group_ids = set([proc.group_id.id for proc in procurements if - proc.group_id]) - domain = [('group_id', 'in', list(group_ids))] - pickings = self.stockpicking.search(domain) - self.assertEquals(len(pickings), 2, - "Incorrect number of pickings created") - picking_out = pickings[1] - moves = picking_out.move_lines + wizard._create_picking() + res = self.rma_supplier_id.rma_line_ids.action_view_in_shipments() + self.assertTrue('res_id' in res, + "Incorrect number of pickings created") + picking = self.env['stock.picking'].browse(res['res_id']) + moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") for line in self.rma_supplier_id.rma_line_ids: - self.assertEquals(line.qty_incoming, 0, - "Wrong qty incoming") self.assertEquals(line.qty_received, 0, "Wrong qty received") if line.product_id == self.product_1: self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 0, + self.assertEquals(line.qty_incoming, 3, "Wrong qty incoming") - self.assertEquals(line.qty_delivered, 3, - "Wrong qty delivered") if line.product_id == self.product_2: self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive") - self.assertEquals(line.qty_to_deliver, 0, - "Wrong qty to deliver") + self.assertEquals(line.qty_incoming, 5, + "Wrong qty incoming") if line.product_id == self.product_3: self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive") - self.assertEquals(line.qty_to_deliver, 0, - "Wrong qty to deliver") - picking_out.action_assign() - picking_out.do_transfer() + self.assertEquals(line.qty_incoming, 2, + "Wrong qty incoming") + picking.action_assign() + for line in picking.move_line_ids: + line.qty_done = line.product_uom_qty + picking.action_done() for line in self.rma_supplier_id.rma_line_ids[0]: - self.assertEquals(line.qty_to_receive, 3, - "Wrong qty to receive") self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_delivered, 6, - "Wrong qty deliver") - self.assertEquals(line.qty_outgoing, 0, - "Wrong qty outgoing") if line.product_id == self.product_1: - self.assertEquals(line.qty_received, 0, + self.assertEquals(line.qty_received, 3, "Wrong qty received") - self.assertEquals(line.qty_delivered, 6, - "Wrong qty delivered") if line.product_id == self.product_2: - self.assertEquals(line.qty_received, 0, + self.assertEquals(line.qty_received, 5, "Wrong qty received") - self.assertEquals(line.qty_delivered, 5, - "Wrong qty delivered") if line.product_id == self.product_3: self.assertEquals(line.qty_received, 2, "Wrong qty received") - self.assertEquals(line.qty_delivered, 2, - "Wrong qty delivered") for line in self.rma_supplier_id.rma_line_ids: line.action_rma_done() self.assertEquals(line.state, 'done', diff --git a/rma_account/views/invoice_view.xml b/rma_account/views/invoice_view.xml index 8b24a07d..e984b90e 100644 --- a/rma_account/views/invoice_view.xml +++ b/rma_account/views/invoice_view.xml @@ -1,7 +1,5 @@ - + - - account.invoice.form account.invoice @@ -60,7 +58,6 @@ - account.invoice.supplier.rma @@ -105,5 +102,4 @@ form - diff --git a/rma_account/views/rma_operation_view.xml b/rma_account/views/rma_operation_view.xml index 671a2a0e..6f9c4062 100644 --- a/rma_account/views/rma_operation_view.xml +++ b/rma_account/views/rma_operation_view.xml @@ -1,26 +1,24 @@ - + - - - rma.operation.tree - rma.operation - - - - - + + rma.operation.tree + rma.operation + + + + - + + - - rma.operation.form - rma.operation - - - - - + + rma.operation.form + rma.operation + + + + - - + + diff --git a/rma_account/views/rma_order_line_view.xml b/rma_account/views/rma_order_line_view.xml index f686e5d5..883559ce 100644 --- a/rma_account/views/rma_order_line_view.xml +++ b/rma_account/views/rma_order_line_view.xml @@ -1,47 +1,40 @@ - + - - - rma.order.line.supplier.form - rma.order.line - - - - - - - - - - - - - - - - - - - - - - - - + + rma.order.line.supplier.form + rma.order.line + + + + + + + + + - + + + + + + + + + + rma.order.line.form @@ -69,47 +62,61 @@ ('invoice_id.partner_id', '=', partner_id), ('invoice_id.partner_id', 'child_of', partner_id)]"/> - - - - - - - + + + + + + rma.order.line.form + rma.order.line + + + + + + + + + + + + + - - - - - - - - - + + + - - - - rma.order.line.select - rma.order.line - - - - - - - - - + + + + - - + + + + + rma.order.line.select + rma.order.line + + + + - - - - + + diff --git a/rma_account/views/rma_order_view.xml b/rma_account/views/rma_order_view.xml index dbbe0658..270b1058 100644 --- a/rma_account/views/rma_order_view.xml +++ b/rma_account/views/rma_order_view.xml @@ -1,68 +1,64 @@ - + - - - - rma.order.form - rma_account - rma.order - - - - + + rma.order.form - rma_account + rma.order + + + - - - - - - rma.order.supplier.form - rma.order - - - - + - - - + + + + - + + rma.order.supplier.form + rma.order + + + + + + + + diff --git a/rma_account/wizards/__init__.py b/rma_account/wizards/__init__.py index 0e1ebd69..e3832b10 100644 --- a/rma_account/wizards/__init__.py +++ b/rma_account/wizards/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) diff --git a/rma_account/wizards/rma_add_invoice.py b/rma_account/wizards/rma_add_invoice.py index db087c61..8c44205d 100644 --- a/rma_account/wizards/rma_add_invoice.py +++ b/rma_account/wizards/rma_add_invoice.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) @@ -90,10 +89,6 @@ class RmaAddInvoice(models.TransientModel): def _get_rma_data(self): data = { 'date_rma': fields.Datetime.now(), - 'delivery_address_id': - self.invoice_line_ids[0].invoice_id.partner_id.id, - 'invoice_address_id': - self.invoice_line_ids[0].invoice_id.partner_id.id } return data diff --git a/rma_account/wizards/rma_order_line_make_supplier_rma.py b/rma_account/wizards/rma_order_line_make_supplier_rma.py index ead4574d..bbd94cd1 100644 --- a/rma_account/wizards/rma_order_line_make_supplier_rma.py +++ b/rma_account/wizards/rma_order_line_make_supplier_rma.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). diff --git a/rma_account/wizards/rma_refund.py b/rma_account/wizards/rma_refund.py index d0b1ad76..57491a76 100644 --- a/rma_account/wizards/rma_refund.py +++ b/rma_account/wizards/rma_refund.py @@ -1,10 +1,8 @@ -# -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import _, api, fields, models from odoo.exceptions import ValidationError -from odoo.tools.safe_eval import safe_eval as eval import odoo.addons.decimal_precision as dp @@ -38,6 +36,7 @@ class RmaRefund(models.TransientModel): lines the supplier field is empty otherwise is the unique line supplier. """ + context = self._context.copy() res = super(RmaRefund, self).default_get(fields) rma_line_obj = self.env['rma.order.line'] rma_line_ids = self.env.context['active_ids'] or [] @@ -55,6 +54,7 @@ class RmaRefund(models.TransientModel): for line in lines: items.append([0, 0, self._prepare_item(line)]) res['item_ids'] = items + context.update({'items_ids': items}) return res date_invoice = fields.Date( @@ -96,11 +96,11 @@ class RmaRefund(models.TransientModel): new_invoice = self.compute_refund() action = 'action_invoice_tree1' if ( new_invoice.type in ['out_refund', 'out_invoice']) \ - else 'action_invoice_tree2' + else 'action_invoice_in_refund' result = self.env.ref('account.%s' % action).read()[0] - invoice_domain = eval(result['domain']) - invoice_domain.append(('id', '=', new_invoice.id)) - result['domain'] = invoice_domain + form_view = self.env.ref('account.invoice_supplier_form', False) + result['views'] = [(form_view and form_view.id or False, 'form')] + result['res_id'] = new_invoice.id return result @api.model @@ -189,8 +189,9 @@ class RmaRefundItem(models.TransientModel): related='line_id.rma_id', string='RMA', readonly=True) - product_id = fields.Many2one('product.product', string='Product', - readonly=True) + product_id = fields.Many2one('product.product', string='Product') + product = fields.Many2one('product.product', string='Product', + readonly=True) name = fields.Char(string='Description', required=True) product_qty = fields.Float( string='Quantity Ordered', copy=False, diff --git a/rma_account/wizards/rma_refund.xml b/rma_account/wizards/rma_refund.xml index 52efcd46..df4c548a 100644 --- a/rma_account/wizards/rma_refund.xml +++ b/rma_account/wizards/rma_refund.xml @@ -1,85 +1,72 @@ - - - - rma.refund.form - rma.refund - -
- - - - - - - - - - - - - - - - - - - -
-
-
-
-
- - - Create Refund - rma.refund - form - tree,form - - - new - - - - rma.order.line.form - rma.order.line - - - -