mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
- Now it's possible to open several RMAs in a sale order from the portal - A new comment button has been added to allow the portal user to enter relevant information like serial numbers o issue description. - If the requested operation isn't set no RMA will be opened - The RMA product qty is now a numeric control with limits according to the qty available to return [FIX] rma,rma_sale: fix linter errors
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class StockPicking(models.Model):
|
|
_inherit = 'stock.picking'
|
|
|
|
rma_count = fields.Integer(
|
|
string='RMA count',
|
|
compute='_compute_rma_count',
|
|
)
|
|
|
|
def _compute_rma_count(self):
|
|
for rec in self:
|
|
rec.rma_count = len(rec.move_lines.mapped('rma_ids'))
|
|
|
|
@api.multi
|
|
def copy(self, default=None):
|
|
self.ensure_one()
|
|
if self.env.context.get('set_rma_picking_type'):
|
|
location_dest_id = default['location_dest_id']
|
|
warehouse = self.env['stock.warehouse'].search(
|
|
[('rma_loc_id', 'parent_of', location_dest_id)], limit=1)
|
|
if warehouse:
|
|
default['picking_type_id'] = warehouse.rma_in_type_id.id
|
|
return super().copy(default)
|
|
|
|
def action_view_rma(self):
|
|
self.ensure_one()
|
|
action = self.env.ref('rma.rma_action').read()[0]
|
|
rma = self.move_lines.mapped('rma_ids')
|
|
if len(rma) == 1:
|
|
action.update(
|
|
res_id=rma.id,
|
|
view_mode="form",
|
|
view_id=False,
|
|
views=False,
|
|
)
|
|
else:
|
|
action['domain'] = [('id', 'in', rma.ids)]
|
|
return action
|