mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG]rma v110.0.2.0.0
This commit is contained in:
committed by
Florian da Costa
parent
b3cf59538c
commit
29e30d5ec9
@@ -86,6 +86,14 @@ Create an RMA:
|
|||||||
Order".
|
Order".
|
||||||
#. Go back to the RMA. Set the RMA to done if not further action is required.
|
#. Go back to the RMA. Set the RMA to done if not further action is required.
|
||||||
|
|
||||||
|
Known issues and Roadmap
|
||||||
|
========================
|
||||||
|
|
||||||
|
* Picking operations report in customer RMA dropshipping case is showing
|
||||||
|
"Vendor Address" while it should be "Customer Address".
|
||||||
|
* Dropshipping always counted as a delivery on the smart buttons.
|
||||||
|
* Uninstall hook.
|
||||||
|
* Constraints instead of required fields on rma.order.line.
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'RMA (Return Merchandise Authorization)',
|
'name': 'RMA (Return Merchandise Authorization)',
|
||||||
'version': '11.0.1.0.0',
|
'version': '11.0.2.0.0',
|
||||||
'license': 'LGPL-3',
|
'license': 'LGPL-3',
|
||||||
'category': 'RMA',
|
'category': 'RMA',
|
||||||
'summary': 'Introduces the return merchandise authorization (RMA) process '
|
'summary': 'Introduces the return merchandise authorization (RMA) process '
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<odoo noupdate="0">
|
<odoo noupdate="1">
|
||||||
<record id="rma_operation_customer_replace" model="rma.operation">
|
<record id="rma_operation_customer_replace" model="rma.operation">
|
||||||
<field name="name">Replace After Receive</field>
|
<field name="name">Replace After Receive</field>
|
||||||
<field name="code">RPLC</field>
|
<field name="code">RPL-C</field>
|
||||||
<field name="receipt_policy">ordered</field>
|
<field name="receipt_policy">ordered</field>
|
||||||
<field name="delivery_policy">received</field>
|
<field name="delivery_policy">received</field>
|
||||||
<field name="type">customer</field>
|
<field name="type">customer</field>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<record id="rma_operation_supplier_replace" model="rma.operation">
|
<record id="rma_operation_supplier_replace" model="rma.operation">
|
||||||
<field name="name">Replace</field>
|
<field name="name">Replace</field>
|
||||||
<field name="code">RPLS</field>
|
<field name="code">RPL-S</field>
|
||||||
<field name="receipt_policy">ordered</field>
|
<field name="receipt_policy">ordered</field>
|
||||||
<field name="delivery_policy">ordered</field>
|
<field name="delivery_policy">ordered</field>
|
||||||
<field name="type">supplier</field>
|
<field name="type">supplier</field>
|
||||||
@@ -21,25 +21,25 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="rma_operation_ds_replace" model="rma.operation">
|
<record id="rma_operation_ds_replace" model="rma.operation">
|
||||||
<field name="name">Drop Ship - Replace deliver to vendor</field>
|
<field name="name">Dropship - Deliver to vendor</field>
|
||||||
<field name="code">DSRPLB</field>
|
<field name="code">DS-RPL-C</field>
|
||||||
<field name="receipt_policy">ordered</field>
|
<field name="receipt_policy">ordered</field>
|
||||||
<field name="delivery_policy">no</field>
|
<field name="delivery_policy">no</field>
|
||||||
<field name="type">customer</field>
|
<field name="type">customer</field>
|
||||||
<field name="customer_to_supplier">True</field>
|
<field name="customer_to_supplier" eval="True"/>
|
||||||
<field name="in_route_id" ref="rma.route_rma_dropship"/>
|
|
||||||
<field name="out_route_id" ref="rma.route_rma_dropship"/>
|
<field name="out_route_id" ref="rma.route_rma_dropship"/>
|
||||||
|
<field name="in_route_id" ref="rma.route_rma_dropship"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="rma_operation_ds_replace_supplier" model="rma.operation">
|
<record id="rma_operation_ds_replace_supplier" model="rma.operation">
|
||||||
<field name="name">Drop Ship - Replace deliver to customer</field>
|
<field name="name">Dropship - Deliver to customer</field>
|
||||||
<field name="code">DSRPC</field>
|
<field name="code">DS-RPL-S</field>
|
||||||
<field name="receipt_policy">ordered</field>
|
<field name="receipt_policy">no</field>
|
||||||
<field name="delivery_policy">no</field>
|
<field name="delivery_policy">ordered</field>
|
||||||
<field name="type">supplier</field>
|
<field name="type">supplier</field>
|
||||||
<field name="supplier_to_customer">True</field>
|
<field name="supplier_to_customer" eval="True"/>
|
||||||
<field name="in_route_id" ref="rma.route_rma_dropship"/>
|
|
||||||
<field name="out_route_id" ref="rma.route_rma_dropship"/>
|
<field name="out_route_id" ref="rma.route_rma_dropship"/>
|
||||||
|
<field name="in_route_id" ref="rma.route_rma_dropship"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -188,7 +188,6 @@
|
|||||||
<record id="rule_rma_dropship_return" model="procurement.rule">
|
<record id="rule_rma_dropship_return" model="procurement.rule">
|
||||||
<field name="name">Customer → Supplier</field>
|
<field name="name">Customer → Supplier</field>
|
||||||
<field name="action">move</field>
|
<field name="action">move</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0"/>
|
|
||||||
<field name="location_id" ref="stock.stock_location_suppliers"/>
|
<field name="location_id" ref="stock.stock_location_suppliers"/>
|
||||||
<field name="location_src_id" ref="stock.stock_location_customers"/>
|
<field name="location_src_id" ref="stock.stock_location_customers"/>
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
@@ -200,7 +199,6 @@
|
|||||||
<record id="rule_rma_dropship" model="procurement.rule">
|
<record id="rule_rma_dropship" model="procurement.rule">
|
||||||
<field name="name">Supplier → Customer</field>
|
<field name="name">Supplier → Customer</field>
|
||||||
<field name="action">move</field>
|
<field name="action">move</field>
|
||||||
<field name="warehouse_id" ref="stock.warehouse0"/>
|
|
||||||
<field name="location_id" ref="stock.stock_location_customers"/>
|
<field name="location_id" ref="stock.stock_location_customers"/>
|
||||||
<field name="location_src_id" ref="stock.stock_location_suppliers"/>
|
<field name="location_src_id" ref="stock.stock_location_suppliers"/>
|
||||||
<field name="procure_method">make_to_stock</field>
|
<field name="procure_method">make_to_stock</field>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2017-18 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 odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
@@ -23,6 +23,14 @@ class RmaOperation(models.Model):
|
|||||||
def _default_supplier_location_id(self):
|
def _default_supplier_location_id(self):
|
||||||
return self.env.ref('stock.stock_location_suppliers') or False
|
return self.env.ref('stock.stock_location_suppliers') or False
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _default_routes(self):
|
||||||
|
op_type = self.env.context.get('default_type')
|
||||||
|
if op_type == 'customer':
|
||||||
|
return self.env.ref('rma.route_rma_customer')
|
||||||
|
elif op_type == 'supplier':
|
||||||
|
return self.env.ref('rma.route_rma_supplier')
|
||||||
|
|
||||||
name = fields.Char('Description', required=True)
|
name = fields.Char('Description', required=True)
|
||||||
code = fields.Char('Code', required=True)
|
code = fields.Char('Code', required=True)
|
||||||
active = fields.Boolean(string='Active', default=True)
|
active = fields.Boolean(string='Active', default=True)
|
||||||
@@ -35,15 +43,21 @@ class RmaOperation(models.Model):
|
|||||||
('received', 'Based on Received Quantities')],
|
('received', 'Based on Received Quantities')],
|
||||||
string="Delivery Policy", default='no')
|
string="Delivery Policy", default='no')
|
||||||
in_route_id = fields.Many2one(
|
in_route_id = fields.Many2one(
|
||||||
'stock.location.route', string='Inbound Route',
|
comodel_name='stock.location.route', string='Inbound Route',
|
||||||
domain=[('rma_selectable', '=', True)])
|
domain=[('rma_selectable', '=', True)],
|
||||||
|
default=_default_routes,
|
||||||
|
)
|
||||||
out_route_id = fields.Many2one(
|
out_route_id = fields.Many2one(
|
||||||
'stock.location.route', string='Outbound Route',
|
comodel_name='stock.location.route', string='Outbound Route',
|
||||||
domain=[('rma_selectable', '=', True)])
|
domain=[('rma_selectable', '=', True)],
|
||||||
|
default=_default_routes,
|
||||||
|
)
|
||||||
customer_to_supplier = fields.Boolean(
|
customer_to_supplier = fields.Boolean(
|
||||||
'The customer will send to the supplier', default=False)
|
string='The customer will send to the supplier',
|
||||||
|
)
|
||||||
supplier_to_customer = fields.Boolean(
|
supplier_to_customer = fields.Boolean(
|
||||||
'The supplier will send to the customer', default=False)
|
string='The supplier will send to the customer',
|
||||||
|
)
|
||||||
in_warehouse_id = fields.Many2one(
|
in_warehouse_id = fields.Many2one(
|
||||||
comodel_name='stock.warehouse', string='Inbound Warehouse',
|
comodel_name='stock.warehouse', string='Inbound Warehouse',
|
||||||
default=_default_warehouse_id)
|
default=_default_warehouse_id)
|
||||||
@@ -55,5 +69,7 @@ class RmaOperation(models.Model):
|
|||||||
type = fields.Selection([
|
type = fields.Selection([
|
||||||
('customer', 'Customer'), ('supplier', 'Supplier')],
|
('customer', 'Customer'), ('supplier', 'Supplier')],
|
||||||
string="Used in RMA of this type", required=True)
|
string="Used in RMA of this type", required=True)
|
||||||
rma_line_ids = fields.One2many('rma.order.line', 'operation_id',
|
rma_line_ids = fields.One2many(
|
||||||
'RMA lines')
|
comodel_name='rma.order.line', inverse_name='operation_id',
|
||||||
|
string='RMA lines',
|
||||||
|
)
|
||||||
|
|||||||
@@ -46,18 +46,26 @@ class RmaOrderLine(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _compute_in_shipment_count(self):
|
def _compute_in_shipment_count(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
moves = self.env['stock.move'].search([
|
picking_ids = []
|
||||||
('rma_line_id', '=', line.id)])
|
for move in line.move_ids:
|
||||||
line.in_shipment_count = len(moves.mapped('picking_id').filtered(
|
if move.location_dest_id.usage == 'internal':
|
||||||
lambda p: p.picking_type_code == 'incoming').ids)
|
picking_ids.append(move.picking_id.id)
|
||||||
|
else:
|
||||||
|
if line.customer_to_supplier:
|
||||||
|
picking_ids.append(move.picking_id.id)
|
||||||
|
shipments = list(set(picking_ids))
|
||||||
|
line.in_shipment_count = len(shipments)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _compute_out_shipment_count(self):
|
def _compute_out_shipment_count(self):
|
||||||
|
picking_ids = []
|
||||||
for line in self:
|
for line in self:
|
||||||
moves = self.env['stock.move'].search([
|
for move in line.move_ids:
|
||||||
('rma_line_id', '=', line.id)])
|
if move.location_dest_id.usage in ('supplier', 'customer'):
|
||||||
line.out_shipment_count = len(moves.mapped('picking_id').filtered(
|
if not line.customer_to_supplier:
|
||||||
lambda p: p.picking_type_code == 'outgoing').ids)
|
picking_ids.append(move.picking_id.id)
|
||||||
|
shipments = list(set(picking_ids))
|
||||||
|
line.out_shipment_count = len(shipments)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_rma_move_qty(self, states, direction='in'):
|
def _get_rma_move_qty(self, states, direction='in'):
|
||||||
@@ -82,9 +90,11 @@ class RmaOrderLine(models.Model):
|
|||||||
for rec in self:
|
for rec in self:
|
||||||
rec.qty_to_receive = 0.0
|
rec.qty_to_receive = 0.0
|
||||||
if rec.receipt_policy == 'ordered':
|
if rec.receipt_policy == 'ordered':
|
||||||
rec.qty_to_receive = rec.product_qty - rec.qty_received
|
rec.qty_to_receive = \
|
||||||
|
rec.product_qty - rec.qty_incoming - rec.qty_received
|
||||||
elif rec.receipt_policy == 'delivered':
|
elif rec.receipt_policy == 'delivered':
|
||||||
rec.qty_to_receive = rec.qty_delivered - rec.qty_received
|
rec.qty_to_receive = \
|
||||||
|
rec.qty_delivered - rec.qty_incoming - rec.qty_received
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('move_ids', 'move_ids.state',
|
@api.depends('move_ids', 'move_ids.state',
|
||||||
@@ -110,7 +120,10 @@ class RmaOrderLine(models.Model):
|
|||||||
@api.depends('move_ids', 'move_ids.state', 'type')
|
@api.depends('move_ids', 'move_ids.state', 'type')
|
||||||
def _compute_qty_received(self):
|
def _compute_qty_received(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
qty = rec._get_rma_move_qty('done', direction='in')
|
if rec.supplier_to_customer:
|
||||||
|
qty = rec._get_rma_move_qty('done', direction='out')
|
||||||
|
else:
|
||||||
|
qty = rec._get_rma_move_qty('done', direction='in')
|
||||||
rec.qty_received = qty
|
rec.qty_received = qty
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -125,7 +138,10 @@ class RmaOrderLine(models.Model):
|
|||||||
@api.depends('move_ids', 'move_ids.state', 'type')
|
@api.depends('move_ids', 'move_ids.state', 'type')
|
||||||
def _compute_qty_delivered(self):
|
def _compute_qty_delivered(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
qty = rec._get_rma_move_qty('done', direction='out')
|
if rec.supplier_to_customer:
|
||||||
|
qty = rec._get_rma_move_qty('done', direction='in')
|
||||||
|
else:
|
||||||
|
qty = rec._get_rma_move_qty('done', direction='out')
|
||||||
rec.qty_delivered = qty
|
rec.qty_delivered = qty
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -140,9 +156,26 @@ class RmaOrderLine(models.Model):
|
|||||||
'receipt_policy', 'product_qty', 'type')
|
'receipt_policy', 'product_qty', 'type')
|
||||||
def _compute_qty_supplier_rma(self):
|
def _compute_qty_supplier_rma(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
qty = rec._get_supplier_rma_qty()
|
if rec.customer_to_supplier:
|
||||||
rec.qty_to_supplier_rma = rec.product_qty - qty
|
supplier_rma_qty = rec._get_supplier_rma_qty()
|
||||||
rec.qty_in_supplier_rma = qty
|
rec.qty_to_supplier_rma = rec.product_qty - supplier_rma_qty
|
||||||
|
rec.qty_in_supplier_rma = supplier_rma_qty
|
||||||
|
else:
|
||||||
|
rec.qty_to_supplier_rma = 0.0
|
||||||
|
rec.qty_in_supplier_rma = 0.0
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _compute_procurement_count(self):
|
||||||
|
for rec in self:
|
||||||
|
rec.procurement_count = len(rec.procurement_ids.filtered(
|
||||||
|
lambda p: p.state == 'exception'))
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _compute_rma_line_count(self):
|
||||||
|
for rec in self.filtered(lambda r: r.type == 'customer'):
|
||||||
|
rec.rma_line_count = len(rec.supplier_rma_line_ids)
|
||||||
|
for rec in self.filtered(lambda r: r.type == 'supplier'):
|
||||||
|
rec.rma_line_count = len(rec.customer_rma_id)
|
||||||
|
|
||||||
delivery_address_id = fields.Many2one(
|
delivery_address_id = fields.Many2one(
|
||||||
comodel_name='res.partner', string='Partner delivery address',
|
comodel_name='res.partner', string='Partner delivery address',
|
||||||
@@ -180,9 +213,11 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
assigned_to = fields.Many2one(
|
assigned_to = fields.Many2one(
|
||||||
comodel_name='res.users', track_visibility='onchange',
|
comodel_name='res.users', track_visibility='onchange',
|
||||||
|
default=lambda self: self.env.uid,
|
||||||
)
|
)
|
||||||
requested_by = fields.Many2one(
|
requested_by = fields.Many2one(
|
||||||
comodel_name='res.users', track_visibility='onchange',
|
comodel_name='res.users', track_visibility='onchange',
|
||||||
|
default=lambda self: self.env.uid,
|
||||||
)
|
)
|
||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
comodel_name='res.partner', required=True, store=True,
|
comodel_name='res.partner', required=True, store=True,
|
||||||
@@ -217,10 +252,12 @@ class RmaOrderLine(models.Model):
|
|||||||
string='Price Unit',
|
string='Price Unit',
|
||||||
readonly=True, states={'draft': [('readonly', False)]},
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
)
|
)
|
||||||
|
procurement_count = fields.Integer(compute=_compute_procurement_count,
|
||||||
|
string='# of Procurements', copy=False)
|
||||||
in_shipment_count = fields.Integer(compute=_compute_in_shipment_count,
|
in_shipment_count = fields.Integer(compute=_compute_in_shipment_count,
|
||||||
string='# of Shipments', default=0)
|
string='# of Shipments')
|
||||||
out_shipment_count = fields.Integer(compute=_compute_out_shipment_count,
|
out_shipment_count = fields.Integer(compute=_compute_out_shipment_count,
|
||||||
string='# of Deliveries', default=0)
|
string='# of Deliveries')
|
||||||
move_ids = fields.One2many('stock.move', 'rma_line_id',
|
move_ids = fields.One2many('stock.move', 'rma_line_id',
|
||||||
string='Stock Moves', readonly=True,
|
string='Stock Moves', readonly=True,
|
||||||
copy=False)
|
copy=False)
|
||||||
@@ -293,11 +330,21 @@ class RmaOrderLine(models.Model):
|
|||||||
'rma.order.line', string='Customer RMA line', ondelete='cascade')
|
'rma.order.line', string='Customer RMA line', ondelete='cascade')
|
||||||
supplier_rma_line_ids = fields.One2many(
|
supplier_rma_line_ids = fields.One2many(
|
||||||
'rma.order.line', 'customer_rma_id')
|
'rma.order.line', 'customer_rma_id')
|
||||||
|
rma_line_count = fields.Integer(
|
||||||
|
compute='_compute_rma_line_count',
|
||||||
|
string='# of RMA lines associated',
|
||||||
|
)
|
||||||
supplier_address_id = fields.Many2one(
|
supplier_address_id = fields.Many2one(
|
||||||
'res.partner', readonly=True,
|
comodel_name='res.partner', readonly=True,
|
||||||
states={'draft': [('readonly', False)]},
|
states={'draft': [('readonly', False)]},
|
||||||
string='Supplier Address',
|
string='Supplier Address',
|
||||||
help="This address of the supplier in case of Customer RMA operation "
|
help="Address of the supplier in case of Customer RMA operation "
|
||||||
|
"dropship.")
|
||||||
|
customer_address_id = fields.Many2one(
|
||||||
|
comodel_name='res.partner', readonly=True,
|
||||||
|
states={'draft': [('readonly', False)]},
|
||||||
|
string='Customer Address',
|
||||||
|
help="Address of the customer in case of Supplier RMA operation "
|
||||||
"dropship.")
|
"dropship.")
|
||||||
qty_to_receive = fields.Float(
|
qty_to_receive = fields.Float(
|
||||||
string='Qty To Receive',
|
string='Qty To Receive',
|
||||||
@@ -370,8 +417,9 @@ class RmaOrderLine(models.Model):
|
|||||||
[('company_id', '=', self.company_id.id),
|
[('company_id', '=', self.company_id.id),
|
||||||
('lot_rma_id', '!=', False)], limit=1)
|
('lot_rma_id', '!=', False)], limit=1)
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError(_(
|
raise ValidationError(
|
||||||
"Please define a warehouse with a default RMA location."))
|
_("Please define a warehouse with a default RMA "
|
||||||
|
"location."))
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'product_id': sm.product_id.id,
|
'product_id': sm.product_id.id,
|
||||||
@@ -397,26 +445,32 @@ class RmaOrderLine(models.Model):
|
|||||||
@api.onchange('reference_move_id')
|
@api.onchange('reference_move_id')
|
||||||
def _onchange_reference_move_id(self):
|
def _onchange_reference_move_id(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
for move in self.reference_move_id:
|
sm = self.reference_move_id
|
||||||
data = self._prepare_rma_line_from_stock_move(move, lot=False)
|
if not sm:
|
||||||
|
return
|
||||||
|
if sm.lot_ids:
|
||||||
|
if len(sm.lot_ids) > 1:
|
||||||
|
raise UserError(_('To manage lots use RMA groups.'))
|
||||||
|
else:
|
||||||
|
data = self._prepare_rma_line_from_stock_move(
|
||||||
|
sm, lot=sm.lot_ids[0])
|
||||||
|
self.update(data)
|
||||||
|
else:
|
||||||
|
data = self._prepare_rma_line_from_stock_move(
|
||||||
|
sm, lot=False)
|
||||||
self.update(data)
|
self.update(data)
|
||||||
self._remove_other_data_origin('reference_move_id')
|
self._remove_other_data_origin('reference_move_id')
|
||||||
lot_ids = [x.lot_id.id for x in move.move_line_ids if x.lot_id]
|
|
||||||
return {'domain': {'lot_id': [('id', 'in', lot_ids)]}}
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('reference_move_id', 'partner_id')
|
@api.constrains('reference_move_id', 'partner_id')
|
||||||
def _check_move_partner(self):
|
def _check_move_partner(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if (rec.reference_move_id and
|
if (rec.reference_move_id and
|
||||||
(rec.reference_move_id.partner_id != rec.partner_id) and
|
rec.reference_move_id.picking_id.partner_id !=
|
||||||
(rec.reference_move_id.picking_id.partner_id !=
|
rec.partner_id):
|
||||||
rec.partner_id)):
|
raise ValidationError(_(
|
||||||
raise ValidationError(_(
|
"RMA customer and originating stock move customer "
|
||||||
"RMA customer (%s) and originating stock move customer"
|
"doesn't match."))
|
||||||
" (%s) doesn't match." % (
|
|
||||||
rec.reference_move_id.partner_id.name,
|
|
||||||
rec.partner_id.name)))
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _remove_other_data_origin(self, exception):
|
def _remove_other_data_origin(self, exception):
|
||||||
@@ -429,7 +483,6 @@ class RmaOrderLine(models.Model):
|
|||||||
self.write({'state': 'to_approve'})
|
self.write({'state': 'to_approve'})
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.product_id.rma_approval_policy == 'one_step':
|
if rec.product_id.rma_approval_policy == 'one_step':
|
||||||
rec.write({'assigned_to': self.env.uid})
|
|
||||||
rec.action_rma_approve()
|
rec.action_rma_approve()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -467,16 +520,20 @@ class RmaOrderLine(models.Model):
|
|||||||
result = {}
|
result = {}
|
||||||
if not self.product_id:
|
if not self.product_id:
|
||||||
return result
|
return result
|
||||||
self.product_qty = 1
|
|
||||||
self.uom_id = self.product_id.uom_id.id
|
self.uom_id = self.product_id.uom_id.id
|
||||||
self.price_unit = self.product_id.standard_price
|
self.price_unit = self.product_id.standard_price
|
||||||
|
if not self.type:
|
||||||
|
self.type = self._get_default_type()
|
||||||
if self.type == 'customer':
|
if self.type == 'customer':
|
||||||
self.operation_id = self.product_id.rma_customer_operation_id or \
|
self.operation_id = self.product_id.rma_customer_operation_id or \
|
||||||
self.product_id.categ_id.rma_customer_operation_id
|
self.product_id.categ_id.rma_customer_operation_id
|
||||||
else:
|
else:
|
||||||
self.operation_id = self.product_id.rma_supplier_operation_id or \
|
self.operation_id = self.product_id.rma_supplier_operation_id or \
|
||||||
self.product_id.categ_id.rma_supplier_operation_id
|
self.product_id.categ_id.rma_supplier_operation_id
|
||||||
return result
|
if self.lot_id.product_id != self.product_id:
|
||||||
|
self.lot_id = False
|
||||||
|
return {'domain': {
|
||||||
|
'lot_id': [('product_id', '=', self.product_id.id)]}}
|
||||||
|
|
||||||
@api.onchange('operation_id')
|
@api.onchange('operation_id')
|
||||||
def _onchange_operation_id(self):
|
def _onchange_operation_id(self):
|
||||||
@@ -491,10 +548,8 @@ class RmaOrderLine(models.Model):
|
|||||||
self.in_warehouse_id.lot_rma_id
|
self.in_warehouse_id.lot_rma_id
|
||||||
self.customer_to_supplier = self.operation_id.customer_to_supplier
|
self.customer_to_supplier = self.operation_id.customer_to_supplier
|
||||||
self.supplier_to_customer = self.operation_id.supplier_to_customer
|
self.supplier_to_customer = self.operation_id.supplier_to_customer
|
||||||
if self.operation_id.in_route_id:
|
self.in_route_id = self.operation_id.in_route_id
|
||||||
self.in_route_id = self.operation_id.in_route_id
|
self.out_route_id = self.operation_id.out_route_id
|
||||||
if self.operation_id.out_route_id:
|
|
||||||
self.out_route_id = self.operation_id.out_route_id
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.onchange('customer_to_supplier', 'type')
|
@api.onchange('customer_to_supplier', 'type')
|
||||||
@@ -506,43 +561,92 @@ class RmaOrderLine(models.Model):
|
|||||||
|
|
||||||
@api.onchange("lot_id")
|
@api.onchange("lot_id")
|
||||||
def _onchange_lot_id(self):
|
def _onchange_lot_id(self):
|
||||||
if self.lot_id and self.reference_move_id:
|
product = self.lot_id.product_id
|
||||||
data = self._prepare_rma_line_from_stock_move(
|
if product:
|
||||||
self.reference_move_id, lot=self.lot_id)
|
self.product_id = product
|
||||||
self.update(data)
|
self.uom_id = product.uom_id
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_view_in_shipments(self):
|
def action_view_in_shipments(self):
|
||||||
action = self.env.ref('stock.action_picking_tree_all')
|
action = self.env.ref('stock.action_picking_tree_all')
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
moves = self.env['stock.move'].search([
|
picking_ids = []
|
||||||
('rma_line_id', 'in', self.ids)])
|
for line in self:
|
||||||
picking_ids = moves.mapped('picking_id').filtered(
|
for move in line.move_ids:
|
||||||
lambda p: p.picking_type_code == 'incoming').ids
|
if move.location_dest_id.usage == 'internal':
|
||||||
if picking_ids:
|
picking_ids.append(move.picking_id.id)
|
||||||
# choose the view_mode accordingly
|
else:
|
||||||
if len(picking_ids) > 1:
|
if line.customer_to_supplier:
|
||||||
result['domain'] = [('id', 'in', picking_ids)]
|
picking_ids.append(move.picking_id.id)
|
||||||
else:
|
|
||||||
res = self.env.ref('stock.view_picking_form', False)
|
shipments = list(set(picking_ids))
|
||||||
result['views'] = [(res and res.id or False, 'form')]
|
# choose the view_mode accordingly
|
||||||
result['res_id'] = picking_ids and picking_ids[0]
|
if len(shipments) != 1:
|
||||||
|
result['domain'] = "[('id', 'in', " + \
|
||||||
|
str(shipments) + ")]"
|
||||||
|
elif len(shipments) == 1:
|
||||||
|
res = self.env.ref('stock.view_picking_form', False)
|
||||||
|
result['views'] = [(res and res.id or False, 'form')]
|
||||||
|
result['res_id'] = shipments[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_view_out_shipments(self):
|
def action_view_out_shipments(self):
|
||||||
action = self.env.ref('stock.action_picking_tree_all')
|
action = self.env.ref('stock.action_picking_tree_all')
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
moves = self.env['stock.move'].search([
|
picking_ids = []
|
||||||
('rma_line_id', 'in', self.ids)])
|
for line in self:
|
||||||
picking_ids = moves.mapped('picking_id').filtered(
|
for move in line.move_ids:
|
||||||
lambda p: p.picking_type_code == 'outgoing').ids
|
if move.location_dest_id.usage in ('supplier', 'customer'):
|
||||||
if picking_ids:
|
if not line.customer_to_supplier:
|
||||||
# choose the view_mode accordingly
|
picking_ids.append(move.picking_id.id)
|
||||||
if len(picking_ids) > 1:
|
shipments = list(set(picking_ids))
|
||||||
result['domain'] = [('id', 'in', picking_ids)]
|
# choose the view_mode accordingly
|
||||||
else:
|
if len(shipments) != 1:
|
||||||
res = self.env.ref('stock.view_picking_form', False)
|
result['domain'] = "[('id', 'in', " + \
|
||||||
result['views'] = [(res and res.id or False, 'form')]
|
str(shipments) + ")]"
|
||||||
result['res_id'] = picking_ids and picking_ids[0]
|
elif len(shipments) == 1:
|
||||||
|
res = self.env.ref('stock.view_picking_form', False)
|
||||||
|
result['views'] = [(res and res.id or False, 'form')]
|
||||||
|
result['res_id'] = shipments[0]
|
||||||
|
return result
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_view_procurements(self):
|
||||||
|
action = self.env.ref(
|
||||||
|
'procurement.procurement_order_action_exceptions')
|
||||||
|
result = action.read()[0]
|
||||||
|
procurements = self.procurement_ids.filtered(
|
||||||
|
lambda p: p.state == 'exception').ids
|
||||||
|
# choose the view_mode accordingly
|
||||||
|
if len(procurements) != 1:
|
||||||
|
result['domain'] = "[('id', 'in', " + \
|
||||||
|
str(procurements) + ")]"
|
||||||
|
elif len(procurements) == 1:
|
||||||
|
res = self.env.ref('procurement.procurement_form_view', False)
|
||||||
|
result['views'] = [(res and res.id or False, 'form')]
|
||||||
|
result['res_id'] = procurements[0]
|
||||||
|
return result
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_view_rma_lines(self):
|
||||||
|
if self.type == 'customer':
|
||||||
|
# from customer we link to supplier rma
|
||||||
|
action = self.env.ref(
|
||||||
|
'rma.action_rma_supplier_lines')
|
||||||
|
rma_lines = self.supplier_rma_line_ids.ids
|
||||||
|
res = self.env.ref('rma.view_rma_line_supplier_form', False)
|
||||||
|
else:
|
||||||
|
# from supplier we link to customer rma
|
||||||
|
action = self.env.ref(
|
||||||
|
'rma.action_rma_customer_lines')
|
||||||
|
rma_lines = self.customer_rma_id.ids
|
||||||
|
res = self.env.ref('rma.view_rma_line_form', False)
|
||||||
|
result = action.read()[0]
|
||||||
|
# choose the view_mode accordingly
|
||||||
|
if rma_lines and len(rma_lines) != 1:
|
||||||
|
result['domain'] = rma_lines.ids
|
||||||
|
elif len(rma_lines) == 1:
|
||||||
|
result['views'] = [(res and res.id or False, 'form')]
|
||||||
|
result['res_id'] = rma_lines[0]
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -34,3 +34,10 @@ class StockMove(models.Model):
|
|||||||
if group.rma_line_id:
|
if group.rma_line_id:
|
||||||
vals['rma_line_id'] = group.rma_line_id.id
|
vals['rma_line_id'] = group.rma_line_id.id
|
||||||
return super(StockMove, self).create(vals)
|
return super(StockMove, self).create(vals)
|
||||||
|
|
||||||
|
def _action_assign(self):
|
||||||
|
res = super(StockMove, self)._action_assign()
|
||||||
|
for move in self:
|
||||||
|
if move.rma_line_id:
|
||||||
|
move.partner_id = move.rma_line_id.partner_id.id or False
|
||||||
|
return res
|
||||||
|
|||||||
@@ -1,21 +1,255 @@
|
|||||||
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright (C) 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 odoo import fields, models
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class StockWarehouse(models.Model):
|
class StockWarehouse(models.Model):
|
||||||
_inherit = "stock.warehouse"
|
_inherit = "stock.warehouse"
|
||||||
|
|
||||||
lot_rma_id = fields.Many2one('stock.location', 'RMA Location')
|
lot_rma_id = fields.Many2one(
|
||||||
rma_cust_out_type_id = fields.Many2one('stock.picking.type',
|
comodel_name='stock.location', string='RMA Location',
|
||||||
'RMA Customer out Type')
|
) # not readonly to have the possibility to edit location and
|
||||||
rma_sup_out_type_id = fields.Many2one('stock.picking.type',
|
# propagate to rma rules (add a auto-update when writing this field?)
|
||||||
'RMA Supplier out Type')
|
rma_cust_out_type_id = fields.Many2one(
|
||||||
rma_cust_in_type_id = fields.Many2one('stock.picking.type',
|
comodel_name='stock.picking.type', string='RMA Customer out Type',
|
||||||
'RMA Customer in Type')
|
readonly=True,
|
||||||
rma_sup_in_type_id = fields.Many2one('stock.picking.type',
|
)
|
||||||
'RMA Supplier in Type')
|
rma_sup_out_type_id = fields.Many2one(
|
||||||
|
comodel_name='stock.picking.type', string='RMA Supplier out Type',
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
|
rma_cust_in_type_id = fields.Many2one(
|
||||||
|
comodel_name='stock.picking.type', string='RMA Customer in Type',
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
|
rma_sup_in_type_id = fields.Many2one(
|
||||||
|
comodel_name='stock.picking.type', string='RMA Supplier in Type',
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
|
rma_in_this_wh = fields.Boolean(
|
||||||
|
string='RMA in this Warehouse',
|
||||||
|
help="If set, it will create RMA location, picking types and routes "
|
||||||
|
"for this warehouse.",
|
||||||
|
)
|
||||||
|
rma_customer_in_pull_id = fields.Many2one(
|
||||||
|
comodel_name='procurement.rule', string="RMA Customer In Rule",
|
||||||
|
)
|
||||||
|
rma_customer_out_pull_id = fields.Many2one(
|
||||||
|
comodel_name='procurement.rule', string="RMA Customer Out Rule",
|
||||||
|
)
|
||||||
|
rma_supplier_in_pull_id = fields.Many2one(
|
||||||
|
comodel_name='procurement.rule', string="RMA Supplier In Rule",
|
||||||
|
)
|
||||||
|
rma_supplier_out_pull_id = fields.Many2one(
|
||||||
|
comodel_name='procurement.rule', string="RMA Supplier Out Rule",
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _get_rma_types(self):
|
||||||
|
return [
|
||||||
|
self.rma_cust_out_type_id,
|
||||||
|
self.rma_sup_out_type_id,
|
||||||
|
self.rma_cust_in_type_id,
|
||||||
|
self.rma_sup_in_type_id]
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _rma_types_available(self):
|
||||||
|
self.ensure_one()
|
||||||
|
rma_types = self._get_rma_types()
|
||||||
|
for type in rma_types:
|
||||||
|
if not type:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def write(self, vals):
|
||||||
|
if 'rma_in_this_wh' in vals:
|
||||||
|
if vals.get("rma_in_this_wh"):
|
||||||
|
for wh in self:
|
||||||
|
# RMA location:
|
||||||
|
if not wh.lot_rma_id:
|
||||||
|
wh.lot_rma_id = self.env['stock.location'].create({
|
||||||
|
'name': 'RMA',
|
||||||
|
'usage': 'internal',
|
||||||
|
'location_id': wh.lot_stock_id.id,
|
||||||
|
})
|
||||||
|
# RMA types
|
||||||
|
if not wh._rma_types_available():
|
||||||
|
wh._create_rma_picking_types()
|
||||||
|
else:
|
||||||
|
for type in wh._get_rma_types():
|
||||||
|
if type:
|
||||||
|
type.active = True
|
||||||
|
# RMA rules:
|
||||||
|
wh._create_or_update_rma_pull()
|
||||||
|
else:
|
||||||
|
for wh in self:
|
||||||
|
for type in wh._get_rma_types():
|
||||||
|
if type:
|
||||||
|
type.active = False
|
||||||
|
# Unlink rules:
|
||||||
|
self.mapped('rma_customer_in_pull_id').unlink()
|
||||||
|
self.mapped('rma_customer_out_pull_id').unlink()
|
||||||
|
self.mapped('rma_supplier_in_pull_id').unlink()
|
||||||
|
self.mapped('rma_supplier_out_pull_id').unlink()
|
||||||
|
return super(StockWarehouse, self).write(vals)
|
||||||
|
|
||||||
|
def _create_rma_picking_types(self):
|
||||||
|
picking_type_obj = self.env['stock.picking.type']
|
||||||
|
customer_loc, supplier_loc = self._get_partner_locations()
|
||||||
|
for wh in self:
|
||||||
|
other_pick_type = picking_type_obj.search(
|
||||||
|
[('warehouse_id', '=', wh.id)], order='sequence desc',
|
||||||
|
limit=1)
|
||||||
|
color = other_pick_type.color if other_pick_type else 0
|
||||||
|
max_sequence = other_pick_type and other_pick_type.sequence or 0
|
||||||
|
# create rma_cust_out_type_id:
|
||||||
|
rma_cust_out_type_id = picking_type_obj.create({
|
||||||
|
'name': _('Customer RMA Deliveries'),
|
||||||
|
'warehouse_id': wh.id,
|
||||||
|
'code': 'outgoing',
|
||||||
|
'use_create_lots': True,
|
||||||
|
'use_existing_lots': False,
|
||||||
|
'sequence_id': self.env.ref(
|
||||||
|
'rma.seq_picking_type_rma_cust_out').id,
|
||||||
|
'default_location_src_id': wh.lot_rma_id.id,
|
||||||
|
'default_location_dest_id': customer_loc.id,
|
||||||
|
'sequence': max_sequence,
|
||||||
|
'color': color,
|
||||||
|
})
|
||||||
|
# create rma_sup_out_type_id:
|
||||||
|
rma_sup_out_type_id = picking_type_obj.create({
|
||||||
|
'name': _('Supplier RMA Deliveries'),
|
||||||
|
'warehouse_id': wh.id,
|
||||||
|
'code': 'outgoing',
|
||||||
|
'use_create_lots': True,
|
||||||
|
'use_existing_lots': False,
|
||||||
|
'sequence_id': self.env.ref(
|
||||||
|
'rma.seq_picking_type_rma_sup_out').id,
|
||||||
|
'default_location_src_id': wh.lot_rma_id.id,
|
||||||
|
'default_location_dest_id': supplier_loc.id,
|
||||||
|
'sequence': max_sequence,
|
||||||
|
'color': color,
|
||||||
|
})
|
||||||
|
# create rma_cust_in_type_id:
|
||||||
|
rma_cust_in_type_id = picking_type_obj.create({
|
||||||
|
'name': _('Customer RMA Receipts'),
|
||||||
|
'warehouse_id': wh.id,
|
||||||
|
'code': 'incoming',
|
||||||
|
'use_create_lots': True,
|
||||||
|
'use_existing_lots': False,
|
||||||
|
'sequence_id': self.env.ref(
|
||||||
|
'rma.seq_picking_type_rma_cust_in').id,
|
||||||
|
'default_location_src_id': customer_loc.id,
|
||||||
|
'default_location_dest_id': wh.lot_rma_id.id,
|
||||||
|
'sequence': max_sequence,
|
||||||
|
'color': color,
|
||||||
|
})
|
||||||
|
# create rma_sup_in_type_id:
|
||||||
|
rma_sup_in_type_id = picking_type_obj.create({
|
||||||
|
'name': _('Supplier RMA Receipts'),
|
||||||
|
'warehouse_id': wh.id,
|
||||||
|
'code': 'incoming',
|
||||||
|
'use_create_lots': True,
|
||||||
|
'use_existing_lots': False,
|
||||||
|
'sequence_id': self.env.ref(
|
||||||
|
'rma.seq_picking_type_rma_sup_in').id,
|
||||||
|
'default_location_src_id': supplier_loc.id,
|
||||||
|
'default_location_dest_id': wh.lot_rma_id.id,
|
||||||
|
'sequence': max_sequence,
|
||||||
|
'color': color,
|
||||||
|
})
|
||||||
|
wh.write({
|
||||||
|
'rma_cust_out_type_id': rma_cust_out_type_id.id,
|
||||||
|
'rma_sup_out_type_id': rma_sup_out_type_id.id,
|
||||||
|
'rma_cust_in_type_id': rma_cust_in_type_id.id,
|
||||||
|
'rma_sup_in_type_id': rma_sup_in_type_id.id,
|
||||||
|
})
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_rma_rules_dict(self):
|
||||||
|
self.ensure_one()
|
||||||
|
rma_rules = dict()
|
||||||
|
customer_loc, supplier_loc = self._get_partner_locations()
|
||||||
|
# TODO: company_id?
|
||||||
|
rma_rules['rma_customer_in'] = {
|
||||||
|
'name': self._format_rulename(self, customer_loc, self.lot_rma_id),
|
||||||
|
'action': 'move',
|
||||||
|
'warehouse_id': self.id,
|
||||||
|
'location_src_id': customer_loc.id,
|
||||||
|
'location_id': self.lot_rma_id.id,
|
||||||
|
'procure_method': 'make_to_stock',
|
||||||
|
'route_id': self.env.ref('rma.route_rma_customer').id,
|
||||||
|
'picking_type_id': self.rma_cust_in_type_id.id,
|
||||||
|
'active': True,
|
||||||
|
}
|
||||||
|
rma_rules['rma_customer_out'] = {
|
||||||
|
'name': self._format_rulename(self, self.lot_rma_id, customer_loc),
|
||||||
|
'action': 'move',
|
||||||
|
'warehouse_id': self.id,
|
||||||
|
'location_src_id': self.lot_rma_id.id,
|
||||||
|
'location_id': customer_loc.id,
|
||||||
|
'procure_method': 'make_to_stock',
|
||||||
|
'route_id': self.env.ref('rma.route_rma_customer').id,
|
||||||
|
'picking_type_id': self.rma_cust_out_type_id.id,
|
||||||
|
'active': True,
|
||||||
|
}
|
||||||
|
rma_rules['rma_supplier_in'] = {
|
||||||
|
'name': self._format_rulename(self, supplier_loc, self.lot_rma_id),
|
||||||
|
'action': 'move',
|
||||||
|
'warehouse_id': self.id,
|
||||||
|
'location_src_id': supplier_loc.id,
|
||||||
|
'location_id': self.lot_rma_id.id,
|
||||||
|
'procure_method': 'make_to_stock',
|
||||||
|
'route_id': self.env.ref('rma.route_rma_supplier').id,
|
||||||
|
'picking_type_id': self.rma_sup_in_type_id.id,
|
||||||
|
'active': True,
|
||||||
|
}
|
||||||
|
rma_rules['rma_supplier_out'] = {
|
||||||
|
'name': self._format_rulename(self, self.lot_rma_id, supplier_loc),
|
||||||
|
'action': 'move',
|
||||||
|
'warehouse_id': self.id,
|
||||||
|
'location_src_id': self.lot_rma_id.id,
|
||||||
|
'location_id': supplier_loc.id,
|
||||||
|
'procure_method': 'make_to_stock',
|
||||||
|
'route_id': self.env.ref('rma.route_rma_supplier').id,
|
||||||
|
'picking_type_id': self.rma_sup_out_type_id.id,
|
||||||
|
'active': True,
|
||||||
|
}
|
||||||
|
return rma_rules
|
||||||
|
|
||||||
|
def _create_or_update_rma_pull(self):
|
||||||
|
rule_obj = self.env['procurement.rule']
|
||||||
|
for wh in self:
|
||||||
|
rules_dict = wh.get_rma_rules_dict()
|
||||||
|
if wh.rma_customer_in_pull_id:
|
||||||
|
wh.rma_customer_in_pull_id.write(rules_dict['rma_customer_in'])
|
||||||
|
else:
|
||||||
|
wh.rma_customer_in_pull_id = rule_obj.create(
|
||||||
|
rules_dict['rma_customer_in'])
|
||||||
|
|
||||||
|
if wh.rma_customer_out_pull_id:
|
||||||
|
wh.rma_customer_out_pull_id.write(
|
||||||
|
rules_dict['rma_customer_out'])
|
||||||
|
else:
|
||||||
|
wh.rma_customer_out_pull_id = rule_obj.create(
|
||||||
|
rules_dict['rma_customer_out'])
|
||||||
|
|
||||||
|
if wh.rma_supplier_in_pull_id:
|
||||||
|
wh.rma_supplier_in_pull_id.write(rules_dict['rma_supplier_in'])
|
||||||
|
else:
|
||||||
|
wh.rma_supplier_in_pull_id = rule_obj.create(
|
||||||
|
rules_dict['rma_supplier_in'])
|
||||||
|
|
||||||
|
if wh.rma_supplier_out_pull_id:
|
||||||
|
wh.rma_supplier_out_pull_id.write(
|
||||||
|
rules_dict['rma_supplier_out'])
|
||||||
|
else:
|
||||||
|
wh.rma_supplier_out_pull_id = rule_obj.create(
|
||||||
|
rules_dict['rma_supplier_out'])
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class StockLocationRoute(models.Model):
|
class StockLocationRoute(models.Model):
|
||||||
|
|||||||
@@ -5,16 +5,17 @@
|
|||||||
<field name="model">product.category</field>
|
<field name="model">product.category</field>
|
||||||
<field name="inherit_id" ref="stock.product_category_form_view_inherit"/>
|
<field name="inherit_id" ref="stock.product_category_form_view_inherit"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="removal_strategy_id" position="after">
|
<field name="removal_strategy_id" position="after">
|
||||||
<group name="rma">
|
<group name="rma">
|
||||||
<field name="rma_approval_policy"
|
<field name="rma_approval_policy" groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
<field name="rma_customer_operation_id"
|
||||||
<field name="rma_customer_operation_id"
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
domain="[('type','=','customer')]"/>
|
||||||
<field name="rma_supplier_operation_id"
|
<field name="rma_supplier_operation_id"
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"
|
||||||
</group>
|
domain="[('type','=','supplier')]"/>
|
||||||
</field>
|
</group>
|
||||||
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -22,16 +23,18 @@
|
|||||||
<field name="name">product.template.stock.property.form.inherit</field>
|
<field name="name">product.template.stock.property.form.inherit</field>
|
||||||
<field name="model">product.template</field>
|
<field name="model">product.template</field>
|
||||||
<field name="inherit_id" ref="product.product_template_form_view"/>
|
<field name="inherit_id" ref="product.product_template_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<group name="inventory" position="inside">
|
<group name="inventory" position="inside">
|
||||||
<group name="rma" groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
|
<group name="rma" groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
|
||||||
<field name="rma_approval_policy"/>
|
<field name="rma_approval_policy"/>
|
||||||
<field name="rma_customer_operation_id"
|
<field name="rma_customer_operation_id"
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"
|
||||||
<field name="rma_supplier_operation_id"
|
domain="[('type','=','customer')]"/>
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
<field name="rma_supplier_operation_id"
|
||||||
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"
|
||||||
|
domain="[('type','=','supplier')]"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</field>
|
||||||
</field>
|
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,87 +1,90 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="rma_operation_tree" model="ir.ui.view">
|
<data>
|
||||||
<field name="name">rma.operation.tree</field>
|
<record id="rma_operation_tree" model="ir.ui.view">
|
||||||
<field name="model">rma.operation</field>
|
<field name="name">rma.operation.tree</field>
|
||||||
<field name="arch" type="xml">
|
<field name="model">rma.operation</field>
|
||||||
<tree string="RMA Operations">
|
<field name="arch" type="xml">
|
||||||
<field name="active" invisible="1"/>
|
<tree string="RMA Operations">
|
||||||
<field name="code"/>
|
<field name="active" invisible="1"/>
|
||||||
<field name="name"/>
|
<field name="code"/>
|
||||||
<field name="receipt_policy"/>
|
<field name="name"/>
|
||||||
<field name="delivery_policy"/>
|
<field name="receipt_policy"/>
|
||||||
</tree>
|
<field name="delivery_policy"/>
|
||||||
</field>
|
</tree>
|
||||||
</record>
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="rma_operation_form" model="ir.ui.view">
|
<record id="rma_operation_form" model="ir.ui.view">
|
||||||
<field name="name">rma.operation.form</field>
|
<field name="name">rma.operation.form</field>
|
||||||
<field name="model">rma.operation</field>
|
<field name="model">rma.operation</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="RMA Operations">
|
<form string="RMA Operations">
|
||||||
<group colspan="4" col="2">
|
<group colspan="4" col="2">
|
||||||
<group name="description"
|
<group name="description"
|
||||||
string="Description">
|
string="Description">
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
|
</group>
|
||||||
|
<group name="policies"
|
||||||
|
string="Policies">
|
||||||
|
<field name="receipt_policy"/>
|
||||||
|
<field name="delivery_policy"/>
|
||||||
|
</group>
|
||||||
|
<group name="inbound" string="Inbound">
|
||||||
|
<field name="in_route_id"/>
|
||||||
|
<field name="in_warehouse_id"/>
|
||||||
|
<field name="location_id"
|
||||||
|
domain="[('usage', '=', 'internal')]"/>
|
||||||
|
<field name="customer_to_supplier"
|
||||||
|
attrs="{'invisible':[('type', '=', 'supplier')]}"/>
|
||||||
|
</group>
|
||||||
|
<group name="outbound" string="Outbound">
|
||||||
|
<field name="out_route_id"/>
|
||||||
|
<field name="out_warehouse_id"/>
|
||||||
|
<field name="supplier_to_customer"
|
||||||
|
attrs="{'invisible':[('type', '=', 'customer')]}"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group name="policies"
|
</form>
|
||||||
string="Policies">
|
</field>
|
||||||
<field name="receipt_policy"/>
|
</record>
|
||||||
<field name="delivery_policy"/>
|
|
||||||
</group>
|
|
||||||
<group name="inbound" string="Inbound">
|
|
||||||
<field name="in_route_id"/>
|
|
||||||
<field name="in_warehouse_id"/>
|
|
||||||
<field name="location_id"
|
|
||||||
domain="[('usage', '=', 'internal')]"/>
|
|
||||||
<field name="customer_to_supplier"
|
|
||||||
attrs="{'invisible':[('type', '=', 'supplier')]}"/>
|
|
||||||
<field name="supplier_to_customer"
|
|
||||||
attrs="{'invisible':[('type', '=', 'customer')]}"/>
|
|
||||||
</group>
|
|
||||||
<group name="outbound" string="Outbound">
|
|
||||||
<field name="out_route_id"/>
|
|
||||||
<field name="out_warehouse_id"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="action_rma_operation_customer" model="ir.actions.act_window">
|
<record id="action_rma_operation_customer" model="ir.actions.act_window">
|
||||||
<field name="name">Customer Operations</field>
|
<field name="name">Customer Operations</field>
|
||||||
<field name="res_model">rma.operation</field>
|
<field name="res_model">rma.operation</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="context">{'default_type': "customer"}</field>
|
<field name="context">{'default_type': "customer"}</field>
|
||||||
<field name="domain">[('type','=', 'customer')]</field>
|
<field name="domain">[('type','=', 'customer')]</field>
|
||||||
<field name="view_id" ref="rma_operation_tree"/>
|
<field name="view_id" ref="rma_operation_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_operation_supplier" model="ir.actions.act_window">
|
<record id="action_rma_operation_supplier" model="ir.actions.act_window">
|
||||||
<field name="name">Supplier Operations</field>
|
<field name="name">Supplier Operations</field>
|
||||||
<field name="res_model">rma.operation</field>
|
<field name="res_model">rma.operation</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="context">{'default_type': "supplier"}</field>
|
<field name="context">{'default_type': "supplier"}</field>
|
||||||
<field name="domain">[('type','=', 'supplier')]</field>
|
<field name="domain">[('type','=', 'supplier')]</field>
|
||||||
<field name="view_id" ref="rma_operation_tree"/>
|
<field name="view_id" ref="rma_operation_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_rma_operation_customer"
|
<menuitem id="menu_rma_operation_customer"
|
||||||
name="Customer Operations"
|
name="Customer Operations"
|
||||||
groups="rma.group_rma_manager"
|
groups="rma.group_rma_manager"
|
||||||
sequence="35"
|
sequence="35"
|
||||||
parent="rma.menu_rma_config"
|
parent="rma.menu_rma_config"
|
||||||
action="action_rma_operation_customer"/>
|
action="action_rma_operation_customer"/>
|
||||||
|
|
||||||
<menuitem id="menu_rma_operation_supplier"
|
<menuitem id="menu_rma_operation_supplier"
|
||||||
name="Supplier Operations"
|
name="Supplier Operations"
|
||||||
groups="rma.group_rma_manager"
|
groups="rma.group_rma_manager"
|
||||||
sequence="40"
|
sequence="40"
|
||||||
parent="rma.menu_rma_config"
|
parent="rma.menu_rma_config"
|
||||||
action="action_rma_operation_supplier"/>
|
action="action_rma_operation_supplier"/>
|
||||||
|
|
||||||
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -83,6 +83,13 @@
|
|||||||
<field name="out_shipment_count" widget="statinfo"
|
<field name="out_shipment_count" widget="statinfo"
|
||||||
string="Deliveries"/>
|
string="Deliveries"/>
|
||||||
</button>
|
</button>
|
||||||
|
<button type="object" name="action_view_rma_lines"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-link"
|
||||||
|
groups="stock.group_stock_user">
|
||||||
|
<field name="rma_line_count" widget="statinfo"
|
||||||
|
string="Customer RMA"/>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="oe_title" name="title">
|
<div class="oe_title" name="title">
|
||||||
<h1>
|
<h1>
|
||||||
@@ -109,7 +116,8 @@
|
|||||||
<field name="product_tracking" invisible="1"/>
|
<field name="product_tracking" invisible="1"/>
|
||||||
<field name="lot_id"
|
<field name="lot_id"
|
||||||
groups="stock.group_production_lot"
|
groups="stock.group_production_lot"
|
||||||
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"/>
|
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"
|
||||||
|
domain="[('product_id', '=', product_id)]"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="product_qty" string="Quantity">
|
<group name="product_qty" string="Quantity">
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
@@ -125,32 +133,36 @@
|
|||||||
</group>
|
</group>
|
||||||
<group name="contact" string="Contact">
|
<group name="contact" string="Contact">
|
||||||
<field name="requested_by" readonly="1"/>
|
<field name="requested_by" readonly="1"/>
|
||||||
<field name="assigned_to" readonly="1"/>
|
<field name="assigned_to"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="description" string="Description">
|
<page name="description" string="Description">
|
||||||
<field name="description" nolabel="1"/>
|
<field name="description" nolabel="1"/>
|
||||||
</page>
|
</page>
|
||||||
<page name="route" string="Routes" groups="stock.group_adv_location">
|
<page name="route" string="Routes">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group name="inbound" string="Inbound">
|
||||||
<group name="inbound" string="Inbound">
|
<field name="in_warehouse_id"/>
|
||||||
<field name="in_warehouse_id"/>
|
<field name="location_id"
|
||||||
<field name="location_id"
|
domain="[('usage', '=', 'internal')]"/>
|
||||||
domain="[('usage', '=', 'internal')]"/>
|
<field name="in_route_id" groups="stock.group_adv_location"/>
|
||||||
<field name="in_route_id"/>
|
</group>
|
||||||
<field name="supplier_to_customer"/>
|
<group name="outbound" string="Outbound">
|
||||||
</group>
|
<field name="out_warehouse_id"/>
|
||||||
<group name="outbound" string="Outbound">
|
<field name="delivery_address_id"
|
||||||
<field name="out_warehouse_id"/>
|
domain="['|', ('parent_id', '=', partner_id),
|
||||||
<field name="out_route_id"/>
|
('id', '=', partner_id)]"
|
||||||
</group>
|
context="{'show_address': 1}"
|
||||||
<group name="delivery_address"
|
options="{'always_reload': 1}"
|
||||||
string="Delivery Address (drop ship">
|
groups='rma.group_rma_delivery_invoice_address'/>
|
||||||
<field name="delivery_address_id"
|
<field name="out_route_id" groups="stock.group_adv_location"/>
|
||||||
groups='rma.group_rma_delivery_invoice_address'/>
|
<field name="supplier_to_customer"/>
|
||||||
</group>
|
<field name="customer_address_id"
|
||||||
|
context="{'show_address': 1}"
|
||||||
|
options="{'always_reload': 1}"
|
||||||
|
attrs="{'required':[('supplier_to_customer', '=', True)],
|
||||||
|
'invisible':[('supplier_to_customer', '=', False)]}"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
@@ -198,7 +210,7 @@
|
|||||||
<field name="name">rma.order.line.form</field>
|
<field name="name">rma.order.line.form</field>
|
||||||
<field name="model">rma.order.line</field>
|
<field name="model">rma.order.line</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Rma Line">
|
<form string="RMA Line">
|
||||||
<header>
|
<header>
|
||||||
<button name="action_rma_to_approve" type="object"
|
<button name="action_rma_to_approve" type="object"
|
||||||
string="Request Approval"
|
string="Request Approval"
|
||||||
@@ -238,6 +250,13 @@
|
|||||||
icon="fa-pencil-square-o"
|
icon="fa-pencil-square-o"
|
||||||
string="Origin Inv">
|
string="Origin Inv">
|
||||||
</button>
|
</button>
|
||||||
|
<button type="object" name="action_view_rma_lines"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-link"
|
||||||
|
groups="stock.group_stock_user">
|
||||||
|
<field name="rma_line_count" widget="statinfo"
|
||||||
|
string="Supplier RMA"/>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="oe_title" name="title">
|
<div class="oe_title" name="title">
|
||||||
<h1>
|
<h1>
|
||||||
@@ -284,37 +303,39 @@
|
|||||||
</group>
|
</group>
|
||||||
<group name="contact" string="Contact">
|
<group name="contact" string="Contact">
|
||||||
<field name="requested_by" readonly="1"/>
|
<field name="requested_by" readonly="1"/>
|
||||||
<field name="assigned_to" readonly="1"/>
|
<field name="assigned_to"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="route" string="Routes">
|
<page name="route" string="Routes">
|
||||||
|
<group name="inbound" string="Inbound">
|
||||||
<group>
|
<field name="in_warehouse_id"/>
|
||||||
<group name="inbound" string="Inbound">
|
<field name="location_id"
|
||||||
<field name="in_warehouse_id"/>
|
domain="[('usage', '=', 'internal')]"/>
|
||||||
<field name="location_id"
|
<field name="in_route_id" groups="stock.group_adv_location"/>
|
||||||
domain="[('usage', '=', 'internal')]"/>
|
<field name="customer_to_supplier"/>
|
||||||
<field name="in_route_id"/>
|
<field name="supplier_address_id"
|
||||||
<field name="customer_to_supplier"/>
|
context="{'show_address': 1}"
|
||||||
<field name="supplier_address_id"
|
options="{'always_reload': 1}"
|
||||||
attrs="{'required':[('customer_to_supplier', '=', True)],
|
attrs="{'required':[('customer_to_supplier', '=', True)],
|
||||||
'invisible':[('customer_to_supplier', '=', False)]}"/>
|
'invisible':[('customer_to_supplier', '=', False)]}"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="outbound" string="Outbound">
|
<group name="outbound" string="Outbound">
|
||||||
<field name="out_warehouse_id"/>
|
<field name="out_warehouse_id"/>
|
||||||
<field name="delivery_address_id"
|
<field name="delivery_address_id"
|
||||||
groups='rma.group_rma_delivery_invoice_address'/>
|
domain="['|', ('parent_id', '=', partner_id),
|
||||||
<field name="out_route_id"/>
|
('id', '=', partner_id)]"
|
||||||
</group>
|
context="{'show_address': 1}"
|
||||||
</group>
|
options="{'always_reload': 1}"
|
||||||
|
groups='rma.group_rma_delivery_invoice_address'/>
|
||||||
|
<field name="out_route_id" groups="stock.group_adv_location"/>
|
||||||
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page name="stock" string="Stock Moves">
|
<page name="stock" string="Stock Moves">
|
||||||
<field name="move_ids" nolabel="1" readonly="1"/>
|
<field name="move_ids" nolabel="1" readonly="1"/>
|
||||||
</page>
|
</page>
|
||||||
<page name="quantities" string="Quantities">
|
<page name="quantities" string="Quantities">
|
||||||
<group name="quantities" string="Quantities">
|
<group name="quantities" col="4" string="Quantities">
|
||||||
<group name="receive">
|
<group name="receive">
|
||||||
<field name="qty_to_receive"/>
|
<field name="qty_to_receive"/>
|
||||||
<field name="qty_incoming"/>
|
<field name="qty_incoming"/>
|
||||||
@@ -366,6 +387,14 @@
|
|||||||
<field name="lot_id"/>
|
<field name="lot_id"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<filter domain="[('assigned_to','=',uid)]" help="My RMAs"/>
|
<filter domain="[('assigned_to','=',uid)]" help="My RMAs"/>
|
||||||
|
<separator/>
|
||||||
|
<group name="stock_quantities" groups="stock.group_stock_user">
|
||||||
|
<filter domain="[('state','!=', 'done'),('qty_to_receive','>',0.0)]" help="To Receive"/>
|
||||||
|
<filter domain="[('state','!=', 'done'),('qty_to_deliver','>',0.0)]" help="To Deliver"/>
|
||||||
|
</group>
|
||||||
|
<group name="rma_supplier_quantities">
|
||||||
|
<filter domain="[('state','!=', 'done'),('qty_to_supplier_rma','>',0.0)]" help="To Send to Supplier RMA"/>
|
||||||
|
</group>
|
||||||
<group expand="0" string="Group By">
|
<group expand="0" string="Group By">
|
||||||
<filter name="status" string="State" domain="[]"
|
<filter name="status" string="State" domain="[]"
|
||||||
context="{'group_by':'state'}"/>
|
context="{'group_by':'state'}"/>
|
||||||
|
|||||||
@@ -78,10 +78,12 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_address(self, item):
|
def _get_address(self, item):
|
||||||
if item.line_id.delivery_address_id:
|
if item.line_id.customer_to_supplier:
|
||||||
delivery_address = item.line_id.delivery_address_id
|
|
||||||
elif item.line_id.customer_to_supplier:
|
|
||||||
delivery_address = item.line_id.supplier_address_id
|
delivery_address = item.line_id.supplier_address_id
|
||||||
|
elif item.line_id.supplier_to_customer:
|
||||||
|
delivery_address = item.line_id.customer_address_id
|
||||||
|
elif item.line_id.delivery_address_id:
|
||||||
|
delivery_address = item.line_id.delivery_address_id
|
||||||
elif item.line_id.partner_id:
|
elif item.line_id.partner_id:
|
||||||
delivery_address = item.line_id.partner_id
|
delivery_address = item.line_id.partner_id
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 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)
|
||||||
|
|
||||||
import odoo.addons.decimal_precision as dp
|
import odoo.addons.decimal_precision as dp
|
||||||
@@ -22,14 +22,28 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
comodel_name='rma.order', string='Supplier RMA Order Group',
|
comodel_name='rma.order', string='Supplier RMA Order Group',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_default_operation(self):
|
||||||
|
"""Dropshipping is the most common use case of this wizard, thus
|
||||||
|
trying to default to a dropshipping operation first."""
|
||||||
|
operation = self.env['rma.operation'].search([
|
||||||
|
('type', '=', 'supplier'),
|
||||||
|
('supplier_to_customer', '=', True)], limit=1)
|
||||||
|
if not operation:
|
||||||
|
operation = self.env['rma.operation'].search(
|
||||||
|
[('type', '=', 'supplier')], limit=1)
|
||||||
|
return operation
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_item(self, line):
|
def _prepare_item(self, line):
|
||||||
|
operation = self._get_default_operation()
|
||||||
return {
|
return {
|
||||||
'line_id': line.id,
|
'line_id': line.id,
|
||||||
'product_id': line.product_id.id,
|
'product_id': line.product_id.id,
|
||||||
'name': line.name,
|
'name': line.name,
|
||||||
'product_qty': line.qty_to_supplier_rma,
|
'product_qty': line.qty_to_supplier_rma,
|
||||||
'uom_id': line.uom_id.id,
|
'uom_id': line.uom_id.id,
|
||||||
|
'operation_id': operation.id if operation else False,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -48,15 +62,13 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
lines = rma_line_obj.browse(rma_line_ids)
|
lines = rma_line_obj.browse(rma_line_ids)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
items.append([0, 0, self._prepare_item(line)])
|
items.append([0, 0, self._prepare_item(line)])
|
||||||
suppliers = lines.mapped('supplier_address_id')
|
suppliers = lines.mapped(
|
||||||
if len(suppliers) == 0:
|
lambda r: r.supplier_address_id.parent_id or r.supplier_address_id)
|
||||||
pass
|
if len(suppliers) > 1:
|
||||||
elif len(suppliers) == 1:
|
|
||||||
res['partner_id'] = suppliers.id
|
|
||||||
else:
|
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_('Only RMA lines from the same supplier address can be '
|
_('Only RMA lines from the same supplier can be '
|
||||||
'processed at the same time'))
|
'processed at the same time'))
|
||||||
|
res['partner_id'] = suppliers.id
|
||||||
res['item_ids'] = items
|
res['item_ids'] = items
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -66,16 +78,17 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
raise ValidationError(_('Enter a supplier.'))
|
raise ValidationError(_('Enter a supplier.'))
|
||||||
return {
|
return {
|
||||||
'partner_id': self.partner_id.id,
|
'partner_id': self.partner_id.id,
|
||||||
|
'delivery_address_id': self.partner_id.id,
|
||||||
'type': 'supplier',
|
'type': 'supplier',
|
||||||
'company_id': company.id,
|
'company_id': company.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_supplier_rma_line(self, rma, item):
|
def _prepare_supplier_rma_line(self, rma, item):
|
||||||
operation = item.line_id.product_id.rma_supplier_operation_id
|
if item.operation_id:
|
||||||
if not operation:
|
operation = item.operation_id
|
||||||
operation = self.env['rma.operation'].search(
|
else:
|
||||||
[('type', '=', 'supplier')], limit=1)
|
operation = self._get_default_operation()
|
||||||
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)
|
||||||
@@ -92,12 +105,13 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
'partner_id': self.partner_id.id,
|
'partner_id': self.partner_id.id,
|
||||||
'type': 'supplier',
|
'type': 'supplier',
|
||||||
'origin': item.line_id.rma_id.name,
|
'origin': item.line_id.rma_id.name,
|
||||||
'delivery_address_id':
|
'customer_address_id':
|
||||||
item.line_id.delivery_address_id.id,
|
item.line_id.delivery_address_id.id or
|
||||||
|
item.line_id.partner_id.id,
|
||||||
'product_id': item.line_id.product_id.id,
|
'product_id': item.line_id.product_id.id,
|
||||||
'customer_rma_id': item.line_id.id,
|
'customer_rma_id': item.line_id.id,
|
||||||
'product_qty': item.product_qty,
|
'product_qty': item.product_qty,
|
||||||
'rma_id': rma.id,
|
'rma_id': rma.id if rma else False,
|
||||||
'uom_id': item.line_id.uom_id.id,
|
'uom_id': item.line_id.uom_id.id,
|
||||||
'operation_id': operation.id,
|
'operation_id': operation.id,
|
||||||
'receipt_policy': operation.receipt_policy,
|
'receipt_policy': operation.receipt_policy,
|
||||||
@@ -128,23 +142,34 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
|
|
||||||
if self.supplier_rma_id:
|
if self.supplier_rma_id:
|
||||||
rma = self.supplier_rma_id
|
rma = self.supplier_rma_id
|
||||||
if not rma:
|
if not rma and len(self.item_ids) > 1:
|
||||||
rma_data = self._prepare_supplier_rma(line.company_id)
|
rma_data = self._prepare_supplier_rma(line.company_id)
|
||||||
rma = rma_obj.create(rma_data)
|
rma = rma_obj.create(rma_data)
|
||||||
|
|
||||||
rma_line_data = self._prepare_supplier_rma_line(rma, item)
|
rma_line_data = self._prepare_supplier_rma_line(rma, item)
|
||||||
rma_line_obj.create(rma_line_data)
|
rma_line = rma_line_obj.create(rma_line_data)
|
||||||
|
if rma:
|
||||||
return {
|
return {
|
||||||
'name': _('Supplier RMA'),
|
'name': _('Supplier RMA'),
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'res_model': 'rma.order',
|
'res_model': 'rma.order',
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'res_id': rma.id,
|
'res_id': rma.id,
|
||||||
'context': {'supplier': True, 'customer': False},
|
'context': {'supplier': True, 'customer': False},
|
||||||
'type': 'ir.actions.act_window'
|
'type': 'ir.actions.act_window'
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
'name': _('Supplier RMA Line'),
|
||||||
|
'view_type': 'form',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'rma.order.line',
|
||||||
|
'view_id': False,
|
||||||
|
'res_id': rma_line.id,
|
||||||
|
'context': {'supplier': True, 'customer': False},
|
||||||
|
'type': 'ir.actions.act_window'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class RmaLineMakeRmaOrderItem(models.TransientModel):
|
class RmaLineMakeRmaOrderItem(models.TransientModel):
|
||||||
@@ -167,3 +192,7 @@ class RmaLineMakeRmaOrderItem(models.TransientModel):
|
|||||||
uom_id = fields.Many2one('product.uom', string='UoM', readonly=True)
|
uom_id = fields.Many2one('product.uom', string='UoM', readonly=True)
|
||||||
product_qty = fields.Float(string='Quantity',
|
product_qty = fields.Float(string='Quantity',
|
||||||
digits=dp.get_precision('Product UoS'))
|
digits=dp.get_precision('Product UoS'))
|
||||||
|
operation_id = fields.Many2one(
|
||||||
|
comodel_name="rma.operation", string="Operation",
|
||||||
|
domain=[('type', '=', 'supplier')],
|
||||||
|
)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
options="{'no_open': true}"/>
|
options="{'no_open': true}"/>
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
<field name="operation_id"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="uom_id"
|
<field name="uom_id"
|
||||||
groups="product.group_uom"/>
|
groups="product.group_uom"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user