mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[11.0] MIG: rma_account
This commit is contained in:
committed by
ahenriquez
parent
526b4d5dac
commit
b3f75d4348
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user