mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[9.0][FIX] rma: wizard
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# © 2017 Eficent Business and IT Consulting Services S.L.
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from openerp import api, fields, models
|
from openerp import api, fields, models, _
|
||||||
from openerp.exceptions import ValidationError
|
from openerp.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
@@ -27,17 +27,18 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
res['move_ids'] = False
|
res['move_ids'] = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
rma_id = fields.Many2one('rma.order',
|
rma_id = fields.Many2one(
|
||||||
string='RMA Order',
|
comodel_name='rma.order', string='RMA Order',
|
||||||
readonly=True,
|
readonly=True, ondelete='cascade',
|
||||||
ondelete='cascade')
|
)
|
||||||
|
partner_id = fields.Many2one(
|
||||||
partner_id = fields.Many2one(comodel_name='res.partner', string='Partner',
|
comodel_name='res.partner', string='Partner',
|
||||||
readonly=True)
|
readonly=True,
|
||||||
|
)
|
||||||
move_ids = fields.Many2many('stock.move',
|
move_ids = fields.Many2many(
|
||||||
string='Stock Moves',
|
comodel_name='stock.move', string='Stock Moves',
|
||||||
domain="[('state', '=', 'done')]")
|
domain="[('state', '=', 'done')]",
|
||||||
|
)
|
||||||
|
|
||||||
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
||||||
if self.env.context.get('customer'):
|
if self.env.context.get('customer'):
|
||||||
@@ -46,48 +47,46 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
operation = sm.product_id.rma_supplier_operation_id or \
|
operation = sm.product_id.rma_supplier_operation_id or \
|
||||||
sm.product_id.categ_id.rma_supplier_operation_id
|
sm.product_id.categ_id.rma_supplier_operation_id
|
||||||
data = {
|
|
||||||
'reference_move_id': sm.id,
|
|
||||||
'product_id': sm.product_id.id,
|
|
||||||
'lot_id': lot and lot.id or False,
|
|
||||||
'name': sm.product_id.name_template,
|
|
||||||
'origin': sm.picking_id.name or sm.name,
|
|
||||||
'uom_id': sm.product_uom.id,
|
|
||||||
'operation_id': operation.id,
|
|
||||||
'product_qty': sm.product_uom_qty,
|
|
||||||
'delivery_address_id': sm.picking_id.partner_id.id,
|
|
||||||
'rma_id': self.rma_id.id
|
|
||||||
}
|
|
||||||
if not operation:
|
if not operation:
|
||||||
operation = self.env['rma.operation'].search(
|
operation = self.env['rma.operation'].search(
|
||||||
[('type', '=', self.rma_id.type)], limit=1)
|
[('type', '=', self.rma_id.type)], limit=1)
|
||||||
if not operation:
|
if not operation:
|
||||||
raise ValidationError("Please define an operation first")
|
raise ValidationError(_("Please define an operation first"))
|
||||||
|
|
||||||
if not operation.in_route_id or not operation.out_route_id:
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
route = self.env['stock.location.route'].search(
|
route = self.env['stock.location.route'].search(
|
||||||
[('rma_selectable', '=', True)], limit=1)
|
[('rma_selectable', '=', True)], limit=1)
|
||||||
if not route:
|
if not route:
|
||||||
raise ValidationError("Please define an rma route")
|
raise ValidationError(_("Please define an RMA route"))
|
||||||
|
|
||||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||||
warehouse = self.env['stock.warehouse'].search(
|
warehouse = self.env['stock.warehouse'].search(
|
||||||
[('company_id', '=', self.rma_id.company_id.id),
|
[('company_id', '=', self.rma_id.company_id.id),
|
||||||
('lot_rma_id', '!=', False)], limit=1)
|
('lot_rma_id', '!=', False)], limit=1)
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError("Please define a warehouse with a "
|
raise ValidationError(_(
|
||||||
"default rma location")
|
"Please define a warehouse with a default RMA location"))
|
||||||
data.update(
|
data = {
|
||||||
{'receipt_policy': operation.receipt_policy,
|
'partner_id': self.partner_id.id,
|
||||||
'operation_id': operation.id,
|
'reference_move_id': sm.id,
|
||||||
'delivery_policy': operation.delivery_policy,
|
'product_id': sm.product_id.id,
|
||||||
'in_warehouse_id': operation.in_warehouse_id.id or warehouse.id,
|
'lot_id': lot and lot.id or False,
|
||||||
'out_warehouse_id': operation.out_warehouse_id.id or warehouse.id,
|
'origin': sm.picking_id.name or sm.name,
|
||||||
'in_route_id': operation.in_route_id.id or route.id,
|
'uom_id': sm.product_uom.id,
|
||||||
'out_route_id': operation.out_route_id.id or route.id,
|
'operation_id': operation.id,
|
||||||
'location_id': (operation.location_id.id or
|
'product_qty': sm.product_uom_qty,
|
||||||
operation.in_warehouse_id.lot_rma_id.id or
|
'delivery_address_id': sm.picking_id.partner_id.id,
|
||||||
warehouse.lot_rma_id.id)
|
'rma_id': self.rma_id.id,
|
||||||
})
|
'receipt_policy': operation.receipt_policy,
|
||||||
|
'delivery_policy': operation.delivery_policy,
|
||||||
|
'in_warehouse_id': operation.in_warehouse_id.id or warehouse.id,
|
||||||
|
'out_warehouse_id': operation.out_warehouse_id.id or warehouse.id,
|
||||||
|
'in_route_id': operation.in_route_id.id or route.id,
|
||||||
|
'out_route_id': operation.out_route_id.id or route.id,
|
||||||
|
'location_id': (operation.location_id.id or
|
||||||
|
operation.in_warehouse_id.lot_rma_id.id or
|
||||||
|
warehouse.lot_rma_id.id)
|
||||||
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
Reference in New Issue
Block a user