mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[9.0][REW] rma: workflow centralized on rma.order.line and the use of rma.order is optional.
This commit is contained in:
committed by
AaronHForgeFlow
parent
af37c90dc4
commit
be384513e7
@@ -4,7 +4,7 @@
|
|||||||
<field name="name">Customer RMA sequence</field>
|
<field name="name">Customer RMA sequence</field>
|
||||||
<field name="code">rma.order.customer</field>
|
<field name="code">rma.order.customer</field>
|
||||||
<field name="padding">5</field>
|
<field name="padding">5</field>
|
||||||
<field name="prefix">RMA/%(year)s/</field>
|
<field name="prefix">RMAG/%(year)s/</field>
|
||||||
<field eval="1" name="number_next"/>
|
<field eval="1" name="number_next"/>
|
||||||
<field eval="1" name="number_increment"/>
|
<field eval="1" name="number_increment"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<field name="name">Supplier RMA sequence</field>
|
<field name="name">Supplier RMA sequence</field>
|
||||||
<field name="code">rma.order.supplier</field>
|
<field name="code">rma.order.supplier</field>
|
||||||
<field name="padding">5</field>
|
<field name="padding">5</field>
|
||||||
<field name="prefix">RTV/%(year)s/</field>
|
<field name="prefix">RTVG/%(year)s/</field>
|
||||||
<field eval="1" name="number_next"/>
|
<field eval="1" name="number_next"/>
|
||||||
<field eval="1" name="number_increment"/>
|
<field eval="1" name="number_increment"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<field name="name">Customer RMA Line sequence</field>
|
<field name="name">Customer RMA Line sequence</field>
|
||||||
<field name="code">rma.order.line.customer</field>
|
<field name="code">rma.order.line.customer</field>
|
||||||
<field name="padding">5</field>
|
<field name="padding">5</field>
|
||||||
<field name="prefix">RMAL/%(year)s/</field>
|
<field name="prefix">RMA/%(year)s/</field>
|
||||||
<field eval="1" name="number_next"/>
|
<field eval="1" name="number_next"/>
|
||||||
<field eval="1" name="number_increment"/>
|
<field eval="1" name="number_increment"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<field name="name">Supplier RMA Line sequence</field>
|
<field name="name">Supplier RMA Line sequence</field>
|
||||||
<field name="code">rma.order.line.supplier</field>
|
<field name="code">rma.order.line.supplier</field>
|
||||||
<field name="padding">5</field>
|
<field name="padding">5</field>
|
||||||
<field name="prefix">RTVL/%(year)s/</field>
|
<field name="prefix">RTV/%(year)s/</field>
|
||||||
<field eval="1" name="number_next"/>
|
<field eval="1" name="number_next"/>
|
||||||
<field eval="1" name="number_increment"/>
|
<field eval="1" name="number_increment"/>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ from openerp import api, fields, models
|
|||||||
class ProcurementOrder(models.Model):
|
class ProcurementOrder(models.Model):
|
||||||
_inherit = 'procurement.order'
|
_inherit = 'procurement.order'
|
||||||
|
|
||||||
rma_line_id = fields.Many2one('rma.order.line', 'RMA', ondelete="set null")
|
rma_line_id = fields.Many2one(
|
||||||
|
comodel_name='rma.order.line', string='RMA line',
|
||||||
|
ondelete="set null",
|
||||||
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _run_move_create(self, procurement):
|
def _run_move_create(self, procurement):
|
||||||
@@ -26,4 +29,11 @@ class ProcurementOrder(models.Model):
|
|||||||
class ProcurementGroup(models.Model):
|
class ProcurementGroup(models.Model):
|
||||||
_inherit = 'procurement.group'
|
_inherit = 'procurement.group'
|
||||||
|
|
||||||
rma_id = fields.Many2one('rma.order', 'RMA', ondelete="set null")
|
rma_id = fields.Many2one(
|
||||||
|
comodel_name='rma.order', string='RMA',
|
||||||
|
ondelete="set null",
|
||||||
|
)
|
||||||
|
rma_line_id = fields.Many2one(
|
||||||
|
comodel_name='rma.order.line', string='RMA line',
|
||||||
|
ondelete="set null",
|
||||||
|
)
|
||||||
|
|||||||
@@ -47,30 +47,17 @@ class RmaOrder(models.Model):
|
|||||||
return datetime.now()
|
return datetime.now()
|
||||||
|
|
||||||
name = fields.Char(
|
name = fields.Char(
|
||||||
string='Order Number', index=True, readonly=True,
|
string='Group Number', index=True, copy=False)
|
||||||
states={'progress': [('readonly', False)]}, copy=False)
|
|
||||||
type = fields.Selection(
|
type = fields.Selection(
|
||||||
[('customer', 'Customer'), ('supplier', 'Supplier')],
|
[('customer', 'Customer'), ('supplier', 'Supplier')],
|
||||||
string="Type", required=True, default=_get_default_type, readonly=True)
|
string="Type", required=True, default=_get_default_type, readonly=True)
|
||||||
reference = fields.Char(string='Partner Reference',
|
reference = fields.Char(string='Partner Reference',
|
||||||
help="The partner reference of this RMA order.")
|
help="The partner reference of this RMA order.")
|
||||||
comment = fields.Text('Additional Information', readonly=True, states={
|
comment = fields.Text('Additional Information')
|
||||||
'draft': [('readonly', False)]})
|
|
||||||
|
|
||||||
state = fields.Selection([('draft', 'Draft'), ('to_approve', 'To Approve'),
|
|
||||||
('approved', 'Approved'),
|
|
||||||
('done', 'Done')], string='State', index=True,
|
|
||||||
default='draft')
|
|
||||||
date_rma = fields.Datetime(string='Order Date', index=True,
|
date_rma = fields.Datetime(string='Order Date', index=True,
|
||||||
default=_default_date_rma)
|
default=_default_date_rma)
|
||||||
partner_id = fields.Many2one('res.partner', string='Partner',
|
partner_id = fields.Many2one(
|
||||||
required=True, readonly=True,
|
comodel_name='res.partner', string='Partner', required=True)
|
||||||
states={'draft': [('readonly', False)]})
|
|
||||||
assigned_to = fields.Many2one('res.users', 'Assigned to',
|
|
||||||
track_visibility='onchange')
|
|
||||||
requested_by = fields.Many2one('res.users', 'Requested by',
|
|
||||||
track_visibility='onchange',
|
|
||||||
default=lambda self: self.env.user)
|
|
||||||
rma_line_ids = fields.One2many('rma.order.line', 'rma_id',
|
rma_line_ids = fields.One2many('rma.order.line', 'rma_id',
|
||||||
string='RMA lines')
|
string='RMA lines')
|
||||||
in_shipment_count = fields.Integer(compute=_compute_in_shipment_count,
|
in_shipment_count = fields.Integer(compute=_compute_in_shipment_count,
|
||||||
@@ -87,7 +74,8 @@ class RmaOrder(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
if self.env.context.get('supplier'):
|
if (self.env.context.get('supplier') or
|
||||||
|
vals.get('type') == 'supplier'):
|
||||||
vals['name'] = self.env['ir.sequence'].next_by_code(
|
vals['name'] = self.env['ir.sequence'].next_by_code(
|
||||||
'rma.order.supplier')
|
'rma.order.supplier')
|
||||||
else:
|
else:
|
||||||
@@ -149,32 +137,6 @@ class RmaOrder(models.Model):
|
|||||||
result['res_id'] = shipments[0]
|
result['res_id'] = shipments[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_to_approve(self):
|
|
||||||
self.write({'state': 'to_approve'})
|
|
||||||
for rec in self:
|
|
||||||
pols = rec.mapped('rma_line_ids.product_id.rma_approval_policy')
|
|
||||||
if not any(x != 'one_step' for x in pols):
|
|
||||||
rec.write({'assigned_to': self.env.uid})
|
|
||||||
rec.action_rma_approve()
|
|
||||||
return True
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_draft(self):
|
|
||||||
self.write({'state': 'draft'})
|
|
||||||
return True
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_approve(self):
|
|
||||||
# pass the supplier address in case this is a customer RMA
|
|
||||||
self.write({'state': 'approved'})
|
|
||||||
return True
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_done(self):
|
|
||||||
self.write({'state': 'done'})
|
|
||||||
return True
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_valid_lines(self):
|
def _get_valid_lines(self):
|
||||||
""":return: A recordset of rma lines.
|
""":return: A recordset of rma lines.
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
# © 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, UserError
|
||||||
from openerp.addons import decimal_precision as dp
|
from openerp.addons import decimal_precision as dp
|
||||||
import operator
|
import operator
|
||||||
ops = {'=': operator.eq,
|
ops = {'=': operator.eq,
|
||||||
@@ -11,7 +12,13 @@ ops = {'=': operator.eq,
|
|||||||
|
|
||||||
class RmaOrderLine(models.Model):
|
class RmaOrderLine(models.Model):
|
||||||
_name = "rma.order.line"
|
_name = "rma.order.line"
|
||||||
_rec_name = "rma_id"
|
_inherit = ['mail.thread']
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_default_type(self):
|
||||||
|
if 'supplier' in self.env.context:
|
||||||
|
return "supplier"
|
||||||
|
return "customer"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _default_warehouse_id(self):
|
def _default_warehouse_id(self):
|
||||||
@@ -41,7 +48,8 @@ class RmaOrderLine(models.Model):
|
|||||||
def _compute_in_shipment_count(self):
|
def _compute_in_shipment_count(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
moves = line.procurement_ids.mapped('move_ids').filtered(
|
moves = line.procurement_ids.mapped('move_ids').filtered(
|
||||||
lambda m: m.location_dest_id.usage == 'internal')
|
lambda m: m.location_dest_id.usage == 'internal' and
|
||||||
|
m.state != 'cancel')
|
||||||
pickings = moves.mapped('picking_id')
|
pickings = moves.mapped('picking_id')
|
||||||
line.in_shipment_count = len(pickings)
|
line.in_shipment_count = len(pickings)
|
||||||
|
|
||||||
@@ -49,7 +57,8 @@ class RmaOrderLine(models.Model):
|
|||||||
def _compute_out_shipment_count(self):
|
def _compute_out_shipment_count(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
moves = line.procurement_ids.mapped('move_ids').filtered(
|
moves = line.procurement_ids.mapped('move_ids').filtered(
|
||||||
lambda m: m.location_dest_id.usage != 'internal')
|
lambda m: m.location_dest_id.usage != 'internal' and
|
||||||
|
m.state != 'cancel')
|
||||||
pickings = moves.mapped('picking_id')
|
pickings = moves.mapped('picking_id')
|
||||||
line.out_shipment_count = len(pickings)
|
line.out_shipment_count = len(pickings)
|
||||||
|
|
||||||
@@ -131,7 +140,6 @@ class RmaOrderLine(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('customer_to_supplier', 'supplier_rma_line_ids',
|
@api.depends('customer_to_supplier', 'supplier_rma_line_ids',
|
||||||
'supplier_rma_line_ids.rma_id.state',
|
|
||||||
'move_ids', 'move_ids.state', 'qty_received',
|
'move_ids', 'move_ids.state', 'qty_received',
|
||||||
'receipt_policy', 'product_qty', 'type')
|
'receipt_policy', 'product_qty', 'type')
|
||||||
def _compute_qty_supplier_rma(self):
|
def _compute_qty_supplier_rma(self):
|
||||||
@@ -147,33 +155,58 @@ class RmaOrderLine(models.Model):
|
|||||||
lambda p: p.state == 'exception'))
|
lambda p: p.state == 'exception'))
|
||||||
|
|
||||||
delivery_address_id = fields.Many2one(
|
delivery_address_id = fields.Many2one(
|
||||||
'res.partner', string='Partner delivery address',
|
comodel_name='res.partner', string='Partner delivery address',
|
||||||
default=_default_delivery_address,
|
default=_default_delivery_address,
|
||||||
help="This address will be used to "
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
"deliver repaired or replacement products.")
|
help="This address will be used to deliver repaired or replacement "
|
||||||
|
"products.",
|
||||||
rma_id = fields.Many2one('rma.order', string='RMA',
|
)
|
||||||
ondelete='cascade', required=True)
|
rma_id = fields.Many2one(
|
||||||
name = fields.Char(string='Reference', required=True, default='/',
|
comodel_name='rma.order', string='RMA Group',
|
||||||
help='Add here the supplier RMA #. Otherwise an '
|
track_visibility='onchange', readonly=True,
|
||||||
'internal code is assigned.')
|
)
|
||||||
|
name = fields.Char(
|
||||||
|
string='Reference', required=True, default='/',
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
help='Add here the supplier RMA #. Otherwise an internal code is'
|
||||||
|
' assigned.',
|
||||||
|
)
|
||||||
description = fields.Text(string='Description')
|
description = fields.Text(string='Description')
|
||||||
origin = fields.Char(string='Source Document',
|
origin = fields.Char(
|
||||||
help="Reference of the document that produced "
|
string='Source Document',
|
||||||
"this rma.")
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
state = fields.Selection(related='rma_id.state')
|
help="Reference of the document that produced this rma.")
|
||||||
|
state = fields.Selection(
|
||||||
|
selection=[('draft', 'Draft'),
|
||||||
|
('to_approve', 'To Approve'),
|
||||||
|
('approved', 'Approved'),
|
||||||
|
('done', 'Done')],
|
||||||
|
string='State', default='draft',
|
||||||
|
track_visibility='onchange',
|
||||||
|
)
|
||||||
operation_id = fields.Many2one(
|
operation_id = fields.Many2one(
|
||||||
comodel_name="rma.operation", string="Operation")
|
comodel_name="rma.operation", string="Operation",
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
assigned_to = fields.Many2one('res.users', related='rma_id.assigned_to')
|
)
|
||||||
requested_by = fields.Many2one('res.users', related='rma_id.requested_by')
|
assigned_to = fields.Many2one(
|
||||||
partner_id = fields.Many2one('res.partner', related='rma_id.partner_id',
|
comodel_name='res.users', track_visibility='onchange',
|
||||||
store=True)
|
)
|
||||||
sequence = fields.Integer(default=10,
|
requested_by = fields.Many2one(
|
||||||
help="Gives the sequence of this line "
|
comodel_name='res.users', track_visibility='onchange',
|
||||||
"when displaying the rma.")
|
)
|
||||||
product_id = fields.Many2one('product.product', string='Product',
|
partner_id = fields.Many2one(
|
||||||
ondelete='restrict', required=-True)
|
comodel_name='res.partner', required=True, store=True,
|
||||||
|
track_visibility='onchange',
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
|
sequence = fields.Integer(
|
||||||
|
default=10,
|
||||||
|
help="Gives the sequence of this line when displaying the rma.")
|
||||||
|
product_id = fields.Many2one(
|
||||||
|
comodel_name='product.product', string='Product',
|
||||||
|
ondelete='restrict', required=True,
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
product_tracking = fields.Selection(related="product_id.tracking")
|
product_tracking = fields.Selection(related="product_id.tracking")
|
||||||
lot_id = fields.Many2one(
|
lot_id = fields.Many2one(
|
||||||
comodel_name="stock.production.lot", string="Lot/Serial Number",
|
comodel_name="stock.production.lot", string="Lot/Serial Number",
|
||||||
@@ -181,14 +214,18 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
product_qty = fields.Float(
|
product_qty = fields.Float(
|
||||||
string='Ordered Qty', copy=False, default=1.0,
|
string='Ordered Qty', copy=False, default=1.0,
|
||||||
digits=dp.get_precision('Product Unit of Measure'))
|
digits=dp.get_precision('Product Unit of Measure'),
|
||||||
uom_id = fields.Many2one('product.uom', string='Unit of Measure',
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
required=True)
|
)
|
||||||
price_unit = fields.Monetary(string='Price Unit', readonly=False,
|
uom_id = fields.Many2one(
|
||||||
states={'approved': [('readonly', True)],
|
comodel_name='product.uom', string='Unit of Measure',
|
||||||
'done': [('readonly', True)],
|
required=True,
|
||||||
'to_approve': [('readonly', True)]})
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
|
price_unit = fields.Monetary(
|
||||||
|
string='Price Unit',
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
procurement_count = fields.Integer(compute=_compute_procurement_count,
|
procurement_count = fields.Integer(compute=_compute_procurement_count,
|
||||||
string='# of Procurements', copy=False,
|
string='# of Procurements', copy=False,
|
||||||
default=0)
|
default=0)
|
||||||
@@ -199,48 +236,75 @@ class RmaOrderLine(models.Model):
|
|||||||
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)
|
||||||
reference_move_id = fields.Many2one(comodel_name='stock.move',
|
reference_move_id = fields.Many2one(
|
||||||
string='Originating stock move',
|
comodel_name='stock.move', string='Originating Stock Move',
|
||||||
readonly=True, copy=False)
|
copy=False,
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
procurement_ids = fields.One2many('procurement.order', 'rma_line_id',
|
procurement_ids = fields.One2many('procurement.order', 'rma_line_id',
|
||||||
string='Procurements', readonly=True,
|
string='Procurements', readonly=True,
|
||||||
states={'draft': [('readonly', False)]},
|
states={'draft': [('readonly', False)]},
|
||||||
copy=False)
|
copy=False)
|
||||||
currency_id = fields.Many2one('res.currency', string="Currency")
|
currency_id = fields.Many2one('res.currency', string="Currency")
|
||||||
company_id = fields.Many2one('res.company', string='Company',
|
company_id = fields.Many2one(
|
||||||
related='rma_id.company_id', store=True)
|
comodel_name='res.company', string='Company', required=True,
|
||||||
type = fields.Selection(related='rma_id.type')
|
default=lambda self: self.env.user.company_id)
|
||||||
|
type = fields.Selection(
|
||||||
|
selection=[('customer', 'Customer'), ('supplier', 'Supplier')],
|
||||||
|
string="Type", required=True, default=_get_default_type,
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
customer_to_supplier = fields.Boolean(
|
customer_to_supplier = fields.Boolean(
|
||||||
'The customer will send to the supplier')
|
'The customer will send to the supplier',
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
supplier_to_customer = fields.Boolean(
|
supplier_to_customer = fields.Boolean(
|
||||||
'The supplier will send to the customer')
|
'The supplier will send to the customer',
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
receipt_policy = fields.Selection([
|
receipt_policy = fields.Selection([
|
||||||
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
||||||
('delivered', 'Based on Delivered Quantities')],
|
('delivered', 'Based on Delivered Quantities')],
|
||||||
required=True, string="Receipts Policy")
|
required=True, string="Receipts Policy",
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
delivery_policy = fields.Selection([
|
delivery_policy = fields.Selection([
|
||||||
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
|
||||||
('received', 'Based on Received Quantities')], required=True,
|
('received', 'Based on Received Quantities')], required=True,
|
||||||
string="Delivery Policy")
|
string="Delivery Policy",
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
in_route_id = fields.Many2one(
|
in_route_id = fields.Many2one(
|
||||||
'stock.location.route', string='Inbound Route',
|
'stock.location.route', string='Inbound Route',
|
||||||
required=True,
|
required=True,
|
||||||
domain=[('rma_selectable', '=', True)])
|
domain=[('rma_selectable', '=', True)],
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
)
|
||||||
out_route_id = fields.Many2one(
|
out_route_id = fields.Many2one(
|
||||||
'stock.location.route', string='Outbound Route',
|
'stock.location.route', string='Outbound Route',
|
||||||
required=True,
|
required=True,
|
||||||
domain=[('rma_selectable', '=', True)])
|
domain=[('rma_selectable', '=', True)],
|
||||||
in_warehouse_id = fields.Many2one('stock.warehouse',
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
string='Inbound Warehouse',
|
)
|
||||||
required=True,
|
in_warehouse_id = fields.Many2one(
|
||||||
default=_default_warehouse_id)
|
comodel_name='stock.warehouse',
|
||||||
out_warehouse_id = fields.Many2one('stock.warehouse',
|
string='Inbound Warehouse',
|
||||||
string='Outbound Warehouse',
|
required=True,
|
||||||
required=True,
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
default=_default_warehouse_id)
|
default=_default_warehouse_id,
|
||||||
|
)
|
||||||
|
out_warehouse_id = fields.Many2one(
|
||||||
|
comodel_name='stock.warehouse', string='Outbound Warehouse',
|
||||||
|
required=True,
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
default=_default_warehouse_id,
|
||||||
|
)
|
||||||
location_id = fields.Many2one(
|
location_id = fields.Many2one(
|
||||||
'stock.location', 'Send To This Company Location', required=True,
|
comodel_name='stock.location', string='Send To This Company Location',
|
||||||
default=_default_location_id)
|
required=True,
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]},
|
||||||
|
default=_default_location_id,
|
||||||
|
)
|
||||||
customer_rma_id = fields.Many2one(
|
customer_rma_id = fields.Many2one(
|
||||||
'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(
|
||||||
@@ -290,14 +354,119 @@ class RmaOrderLine(models.Model):
|
|||||||
readonly=True, compute=_compute_qty_supplier_rma,
|
readonly=True, compute=_compute_qty_supplier_rma,
|
||||||
store=True)
|
store=True)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
||||||
|
if not self.type:
|
||||||
|
self.type = self._get_default_type()
|
||||||
|
if self.type == 'customer':
|
||||||
|
operation = sm.product_id.rma_customer_operation_id or \
|
||||||
|
sm.product_id.categ_id.rma_customer_operation_id
|
||||||
|
else:
|
||||||
|
operation = sm.product_id.rma_supplier_operation_id or \
|
||||||
|
sm.product_id.categ_id.rma_supplier_operation_id
|
||||||
|
|
||||||
|
if not operation:
|
||||||
|
operation = self.env['rma.operation'].search(
|
||||||
|
[('type', '=', self.type)], limit=1)
|
||||||
|
if not operation:
|
||||||
|
raise ValidationError("Please define an operation first.")
|
||||||
|
|
||||||
|
if not operation.in_route_id or not operation.out_route_id:
|
||||||
|
route = self.env['stock.location.route'].search(
|
||||||
|
[('rma_selectable', '=', True)], limit=1)
|
||||||
|
if not route:
|
||||||
|
raise ValidationError("Please define an RMA route.")
|
||||||
|
|
||||||
|
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||||
|
warehouse = self.env['stock.warehouse'].search(
|
||||||
|
[('company_id', '=', self.company_id.id),
|
||||||
|
('lot_rma_id', '!=', False)], limit=1)
|
||||||
|
if not warehouse:
|
||||||
|
raise ValidationError(
|
||||||
|
"Please define a warehouse with a default RMA location.")
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'product_id': sm.product_id.id,
|
||||||
|
'lot_id': lot and lot.id or False,
|
||||||
|
'origin': sm.picking_id.name or sm.name,
|
||||||
|
'uom_id': sm.product_uom.id,
|
||||||
|
'product_qty': sm.product_uom_qty,
|
||||||
|
'delivery_address_id': sm.picking_id.partner_id.id,
|
||||||
|
'operation_id': operation.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
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.onchange('reference_move_id')
|
||||||
|
def _onchange_reference_move_id(self):
|
||||||
|
self.ensure_one()
|
||||||
|
sm = self.reference_move_id
|
||||||
|
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._remove_other_data_origin('reference_move_id')
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _remove_other_data_origin(self, exception):
|
||||||
|
if not exception == 'reference_move_id':
|
||||||
|
self.reference_move_id = False
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_rma_to_approve(self):
|
||||||
|
self.write({'state': 'to_approve'})
|
||||||
|
for rec in self:
|
||||||
|
if rec.product_id.rma_approval_policy == 'one_step':
|
||||||
|
rec.write({'assigned_to': self.env.uid})
|
||||||
|
rec.action_rma_approve()
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_rma_draft(self):
|
||||||
|
if self.in_shipment_count or self.out_shipment_count:
|
||||||
|
raise UserError(_(
|
||||||
|
"You cannot reset to draft a RMA with related pickings."))
|
||||||
|
self.write({'state': 'draft'})
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_rma_approve(self):
|
||||||
|
self.write({'state': 'approved'})
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_rma_done(self):
|
||||||
|
self.write({'state': 'done'})
|
||||||
|
return True
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
if self.env.context.get('supplier'):
|
if not vals.get('name') or vals.get('name') == '/':
|
||||||
vals['name'] = self.env['ir.sequence'].next_by_code(
|
if self.env.context.get('supplier'):
|
||||||
'rma.order.line.supplier')
|
vals['name'] = self.env['ir.sequence'].next_by_code(
|
||||||
else:
|
'rma.order.line.supplier')
|
||||||
vals['name'] = self.env['ir.sequence'].next_by_code(
|
else:
|
||||||
'rma.order.line.customer')
|
vals['name'] = self.env['ir.sequence'].next_by_code(
|
||||||
|
'rma.order.line.customer')
|
||||||
return super(RmaOrderLine, self).create(vals)
|
return super(RmaOrderLine, self).create(vals)
|
||||||
|
|
||||||
@api.onchange('product_id')
|
@api.onchange('product_id')
|
||||||
|
|||||||
@@ -5,20 +5,20 @@
|
|||||||
<field name="name">rma.order.line.tree</field>
|
<field name="name">rma.order.line.tree</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">
|
||||||
<tree string="RMA Line" create="0"
|
<tree string="RMA Line"
|
||||||
decoration-muted="state in ('draft','to_approve')">
|
decoration-info="state in ('draft','to_approve')">
|
||||||
<field name="rma_id"/>
|
<field name="name"/>
|
||||||
<field name="state" invisible="1"/>
|
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||||
<field name="name"/>
|
<field name="rma_id"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
<field name="operation_id"/>
|
<field name="operation_id"/>
|
||||||
<field name="supplier_address_id"/>
|
<field name="supplier_address_id"/>
|
||||||
<field name="uom_id" groups="product.group_uom"/>
|
<field name="uom_id" groups="product.group_uom"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="price_unit"/>
|
<field name="price_unit"/>
|
||||||
|
<field name="state"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -27,19 +27,19 @@
|
|||||||
<field name="name">rma.order.line.supplier.tree</field>
|
<field name="name">rma.order.line.supplier.tree</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">
|
||||||
<tree string="RMA Line" create="0"
|
<tree string="RMA Line"
|
||||||
decoration-muted="state in ('draft','to_approve')">
|
decoration-info="state in ('draft','to_approve')">
|
||||||
<field name="rma_id"/>
|
<field name="name"/>
|
||||||
<field name="state" invisible="1"/>
|
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||||
<field name="name"/>
|
<field name="rma_id"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
<field name="operation_id" domain="[('type','=','supplier')]"/>
|
<field name="operation_id" domain="[('type','=','supplier')]"/>
|
||||||
<field name="uom_id" groups="product.group_uom"/>
|
<field name="uom_id" groups="product.group_uom"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="price_unit"/>
|
<field name="price_unit"/>
|
||||||
|
<field name="state"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -48,8 +48,25 @@
|
|||||||
<field name="name">rma.order.line.supplier.form</field>
|
<field name="name">rma.order.line.supplier.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" create="0">
|
<form string="RMA Line">
|
||||||
<header/>
|
<header>
|
||||||
|
<button name="action_rma_to_approve" type="object"
|
||||||
|
string="Request Approval"
|
||||||
|
attrs="{'invisible':[('state', '!=', 'draft')]}"
|
||||||
|
class="oe_highlight" groups="rma.group_rma_customer_user"/>
|
||||||
|
<button name="action_rma_draft" type="object"
|
||||||
|
string="Back to Draft"
|
||||||
|
attrs="{'invisible':[('state', '=', 'draft')]}" class="oe_highlight"
|
||||||
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
||||||
|
<button name="action_rma_approve" type="object"
|
||||||
|
string="Approve"
|
||||||
|
attrs="{'invisible':[('state', '!=', 'to_approve')]}" class="oe_highlight" groups="rma.group_rma_customer_user"/>
|
||||||
|
<button name="action_rma_done" type="object"
|
||||||
|
string="Done"
|
||||||
|
attrs="{'invisible':[('state', 'in', ('done', 'draft'))]}"
|
||||||
|
groups="rma.group_rma_customer_user"/>
|
||||||
|
<field name="state" widget="statusbar" nolabel="1"/>
|
||||||
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<div name="button_box" class="oe_button_box">
|
<div name="button_box" class="oe_button_box">
|
||||||
<button type="object" name="action_view_in_shipments"
|
<button type="object" name="action_view_in_shipments"
|
||||||
@@ -76,11 +93,22 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="oe_title" name="title">
|
<div class="oe_title" name="title">
|
||||||
<h1>
|
<h1>
|
||||||
<field name="rma_id" required="False"
|
<field name="name"
|
||||||
readonly="True"
|
|
||||||
invisible="context.get('hide_title',False)"/>
|
invisible="context.get('hide_title',False)"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<group name="partner">
|
||||||
|
<field name="partner_id"
|
||||||
|
domain="[('supplier','=',True)]"
|
||||||
|
string="Supplier"/>
|
||||||
|
</group>
|
||||||
|
<group name="main_info" string="Origin">
|
||||||
|
<field name="reference_move_id"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
domain="[('picking_id.partner_id', '=', partner_id),
|
||||||
|
('location_id.usage', '=', 'supplier'),
|
||||||
|
('state', '=', 'done')]"/>
|
||||||
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group name="product" string="Product">
|
<group name="product" string="Product">
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
@@ -96,12 +124,16 @@
|
|||||||
<field name="uom_id" groups="product.group_uom"/>
|
<field name="uom_id" groups="product.group_uom"/>
|
||||||
</group>
|
</group>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group name="operation" string="Operation" colspan="2">
|
<group name="operation" string="Operation">
|
||||||
<field name="operation_id"
|
<field name="operation_id"
|
||||||
domain="[('type','=','supplier')]"/>
|
domain="[('type','=','supplier')]"/>
|
||||||
<field name="receipt_policy"/>
|
<field name="receipt_policy"/>
|
||||||
<field name="delivery_policy"/>
|
<field name="delivery_policy"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group name="contact" string="Contact">
|
||||||
|
<field name="requested_by" readonly="1"/>
|
||||||
|
<field name="assigned_to" readonly="1"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="description" string="Description">
|
<page name="description" string="Description">
|
||||||
@@ -147,14 +179,9 @@
|
|||||||
</page>
|
</page>
|
||||||
<page name="other" string="Other Info">
|
<page name="other" string="Other Info">
|
||||||
<group name="general" string="General">
|
<group name="general" string="General">
|
||||||
<field name="name"/>
|
<field name="rma_id"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
<field name="reference_move_id"/>
|
|
||||||
<field name="state" invisible="1"/>
|
|
||||||
</group>
|
|
||||||
<group name="contact" string="Contact">
|
|
||||||
<field name="requested_by" readonly="1"/>
|
|
||||||
<field name="assigned_to" readonly="1"/>
|
|
||||||
</group>
|
</group>
|
||||||
<group name="company" string="Company"
|
<group name="company" string="Company"
|
||||||
groups="base.group_multi_company">
|
groups="base.group_multi_company">
|
||||||
@@ -163,6 +190,10 @@
|
|||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
|
||||||
|
<field name="message_ids" widget="mail_thread"/>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -172,7 +203,24 @@
|
|||||||
<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" create="0">
|
<form string="Rma Line" create="0">
|
||||||
<header/>
|
<header>
|
||||||
|
<button name="action_rma_to_approve" type="object"
|
||||||
|
string="Request Approval"
|
||||||
|
attrs="{'invisible':[('state', '!=', 'draft')]}"
|
||||||
|
class="oe_highlight" groups="rma.group_rma_customer_user"/>
|
||||||
|
<button name="action_rma_draft" type="object"
|
||||||
|
string="Back to Draft"
|
||||||
|
attrs="{'invisible':[('state', '=', 'draft')]}" class="oe_highlight"
|
||||||
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
||||||
|
<button name="action_rma_approve" type="object"
|
||||||
|
string="Approve"
|
||||||
|
attrs="{'invisible':[('state', '!=', 'to_approve')]}" class="oe_highlight" groups="rma.group_rma_customer_user"/>
|
||||||
|
<button name="action_rma_done" type="object"
|
||||||
|
string="Done"
|
||||||
|
attrs="{'invisible':[('state', 'in', ('done', 'draft'))]}"
|
||||||
|
groups="rma.group_rma_customer_user"/>
|
||||||
|
<field name="state" widget="statusbar" nolabel="1"/>
|
||||||
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<div name="button_box" class="oe_button_box">
|
<div name="button_box" class="oe_button_box">
|
||||||
<button type="object" name="action_view_in_shipments"
|
<button type="object" name="action_view_in_shipments"
|
||||||
@@ -204,11 +252,22 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="oe_title" name="title">
|
<div class="oe_title" name="title">
|
||||||
<h1>
|
<h1>
|
||||||
<field name="rma_id" required="False"
|
<field name="name"
|
||||||
readonly="True"
|
|
||||||
invisible="context.get('hide_title',False)"/>
|
invisible="context.get('hide_title',False)"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<group name="partner">
|
||||||
|
<field name="partner_id"
|
||||||
|
domain="[('customer','=',True)]"
|
||||||
|
string="Customer"/>
|
||||||
|
</group>
|
||||||
|
<group name="main_info" string="Origin">
|
||||||
|
<field name="reference_move_id"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
domain="[('picking_id.partner_id', '=', partner_id),
|
||||||
|
('location_dest_id.usage', '=', 'customer'),
|
||||||
|
('state', '=', 'done')]"/>
|
||||||
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group name="product" string="Product">
|
<group name="product" string="Product">
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
@@ -229,6 +288,10 @@
|
|||||||
<field name="receipt_policy"/>
|
<field name="receipt_policy"/>
|
||||||
<field name="delivery_policy"/>
|
<field name="delivery_policy"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group name="contact" string="Contact">
|
||||||
|
<field name="requested_by" readonly="1"/>
|
||||||
|
<field name="assigned_to" readonly="1"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="route" string="Routes">
|
<page name="route" string="Routes">
|
||||||
@@ -279,14 +342,8 @@
|
|||||||
</page>
|
</page>
|
||||||
<page name="other" string="Other Info">
|
<page name="other" string="Other Info">
|
||||||
<group name="general" string="General">
|
<group name="general" string="General">
|
||||||
<field name="name"/>
|
<field name="rma_id"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
<field name="reference_move_id"/>
|
|
||||||
<field name="state" invisible="1"/>
|
|
||||||
</group>
|
|
||||||
<group name="contact" string="Contact">
|
|
||||||
<field name="requested_by" readonly="1"/>
|
|
||||||
<field name="assigned_to" readonly="1"/>
|
|
||||||
</group>
|
</group>
|
||||||
<group name="company" string="Company"
|
<group name="company" string="Company"
|
||||||
groups="base.group_multi_company">
|
groups="base.group_multi_company">
|
||||||
@@ -295,6 +352,10 @@
|
|||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
|
||||||
|
<field name="message_ids" widget="mail_thread"/>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -304,6 +365,7 @@
|
|||||||
<field name="model">rma.order.line</field>
|
<field name="model">rma.order.line</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="Search RMA line">
|
<search string="Search RMA line">
|
||||||
|
<field name="name"/>
|
||||||
<field name="rma_id"/>
|
<field name="rma_id"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="requested_by"/>
|
<field name="requested_by"/>
|
||||||
@@ -313,6 +375,8 @@
|
|||||||
<separator/>
|
<separator/>
|
||||||
<filter domain="[('assigned_to','=',uid)]" help="My RMAs"/>
|
<filter domain="[('assigned_to','=',uid)]" help="My RMAs"/>
|
||||||
<group expand="0" string="Group By">
|
<group expand="0" string="Group By">
|
||||||
|
<filter name="status" string="State" domain="[]"
|
||||||
|
context="{'group_by':'state'}"/>
|
||||||
<filter name="partner" string="Partner" domain="[]"
|
<filter name="partner" string="Partner" domain="[]"
|
||||||
context="{'group_by':'partner_id'}"/>
|
context="{'group_by':'partner_id'}"/>
|
||||||
<filter name="operation" string="Operation" domain="[]"
|
<filter name="operation" string="Operation" domain="[]"
|
||||||
@@ -329,11 +393,9 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_customer_lines" model="ir.actions.act_window">
|
<record id="action_rma_customer_lines" model="ir.actions.act_window">
|
||||||
<field name="name">Customer RMA Lines</field>
|
<field name="name">Customer RMA</field>
|
||||||
<field name="res_model">rma.order.line</field>
|
<field name="res_model">rma.order.line</field>
|
||||||
<field name="domain">[('state','in', ['approved', 'done']),
|
<field name="domain">[('type','=', 'customer')]</field>
|
||||||
('type','=', 'customer')
|
|
||||||
]</field>
|
|
||||||
<field name="context">{"search_default_assigned_to":uid}</field>
|
<field name="context">{"search_default_assigned_to":uid}</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>
|
||||||
@@ -341,10 +403,9 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_supplier_lines" model="ir.actions.act_window">
|
<record id="action_rma_supplier_lines" model="ir.actions.act_window">
|
||||||
<field name="name">Supplier RMA Lines</field>
|
<field name="name">Supplier RMA</field>
|
||||||
<field name="res_model">rma.order.line</field>
|
<field name="res_model">rma.order.line</field>
|
||||||
<field name="domain">[('state','in', ['approved', 'done']),
|
<field name="domain">[('type','=', 'supplier')]</field>
|
||||||
('type','=', 'supplier')]</field>
|
|
||||||
<field name="context">{"search_default_assigned_to":uid, "supplier":1}</field>
|
<field name="context">{"search_default_assigned_to":uid, "supplier":1}</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>
|
||||||
|
|||||||
@@ -6,16 +6,11 @@
|
|||||||
<field name="name">rma.order.tree</field>
|
<field name="name">rma.order.tree</field>
|
||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree decoration-info="state == 'draft'"
|
<tree string="RMA">
|
||||||
decoration-muted="state== 'done'" string="RMA">
|
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="state" invisible="1"/>
|
|
||||||
<field name="reference"/>
|
<field name="reference"/>
|
||||||
<field name="partner_id" groups="base.group_user" string="Customer"/>
|
<field name="partner_id" groups="base.group_user" string="Customer"/>
|
||||||
<field name="requested_by" groups="base.group_user"/>
|
|
||||||
<field name="assigned_to" groups="base.group_user"/>
|
|
||||||
<field name="date_rma"/>
|
<field name="date_rma"/>
|
||||||
<field name="state"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -24,17 +19,12 @@
|
|||||||
<field name="name">rma.order.supplier.tree</field>
|
<field name="name">rma.order.supplier.tree</field>
|
||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree decoration-info="state == 'draft'"
|
<tree string="RMA">
|
||||||
decoration-muted="state== 'done'" string="RMA">
|
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="state" invisible="1"/>
|
|
||||||
<field name="reference"/>
|
<field name="reference"/>
|
||||||
<field name="partner_id" groups="base.group_user"
|
<field name="partner_id" groups="base.group_user"
|
||||||
string="Supplier"/>
|
string="Supplier"/>
|
||||||
<field name="requested_by" groups="base.group_user"/>
|
|
||||||
<field name="assigned_to" groups="base.group_user"/>
|
|
||||||
<field name="date_rma"/>
|
<field name="date_rma"/>
|
||||||
<field name="state"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -44,25 +34,7 @@
|
|||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="RMA">
|
<form string="RMA">
|
||||||
<field name="state" invisible="True"/>
|
<header/>
|
||||||
<header>
|
|
||||||
<button name="action_rma_to_approve" type="object"
|
|
||||||
string="Request Approval"
|
|
||||||
attrs="{'invisible':[('state', '!=', 'draft')]}"
|
|
||||||
class="oe_highlight" groups="rma.group_rma_customer_user"/>
|
|
||||||
<button name="action_rma_draft" type="object"
|
|
||||||
string="Back to Draft"
|
|
||||||
attrs="{'invisible':[('state', '=', 'draft')]}" class="oe_highlight"
|
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"/>
|
|
||||||
<button name="action_rma_approve" type="object"
|
|
||||||
string="Approve"
|
|
||||||
attrs="{'invisible':[('state', '!=', 'to_approve')]}" class="oe_highlight" groups="rma.group_rma_customer_user"/>
|
|
||||||
<button name="action_rma_done" type="object"
|
|
||||||
string="Done"
|
|
||||||
attrs="{'invisible':[('state', 'in', ('done', 'draft'))]}"
|
|
||||||
groups="rma.group_rma_customer_user"/>
|
|
||||||
<field name="state" widget="statusbar" nolabel="1"/>
|
|
||||||
</header>
|
|
||||||
<sheet name='rma' string="RMA">
|
<sheet name='rma' string="RMA">
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
<button type="object" name="action_view_in_shipments"
|
<button type="object" name="action_view_in_shipments"
|
||||||
@@ -109,15 +81,8 @@
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group col="4">
|
<group col="4">
|
||||||
<field name="assigned_to"
|
|
||||||
groups="base.group_user"
|
|
||||||
context="{'default_groups_ref': ['rma.rma_user']}"/>
|
|
||||||
<field name="reference"/>
|
<field name="reference"/>
|
||||||
<field name="requested_by"
|
|
||||||
groups="base.group_user"
|
|
||||||
context="{'default_groups_ref': ['rma.rma_user']}"/>
|
|
||||||
<field name="date_rma"/>
|
<field name="date_rma"/>
|
||||||
<field name="type" invisible="1"/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
@@ -145,6 +110,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<group name="comments">
|
<group name="comments">
|
||||||
<field name="comment"/>
|
<field name="comment"/>
|
||||||
|
<field name="type" readonly="1"/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
@@ -162,26 +128,7 @@
|
|||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="RMA">
|
<form string="RMA">
|
||||||
<field name="state" invisible="True"/>
|
<header/>
|
||||||
<header>
|
|
||||||
<button name="action_rma_to_approve" type="object"
|
|
||||||
string="Request Approval"
|
|
||||||
attrs="{'invisible':[('state', '!=', 'draft')]}"
|
|
||||||
class="oe_highlight"
|
|
||||||
groups="rma.group_rma_supplier_user"/>
|
|
||||||
<button name="action_rma_draft" type="object"
|
|
||||||
string="Back to Draft"
|
|
||||||
attrs="{'invisible':[('state', '=', 'draft')]}" class="oe_highlight"
|
|
||||||
groups="rma.group_rma_supplier_user"/>
|
|
||||||
<button name="action_rma_approve" type="object"
|
|
||||||
string="Approve"
|
|
||||||
attrs="{'invisible':[('state', '!=', 'to_approve')]}" class="oe_highlight" groups="rma.group_rma_supplier_user"/>
|
|
||||||
<button name="action_rma_done" type="object"
|
|
||||||
string="Done"
|
|
||||||
attrs="{'invisible':[('state', 'in', ('done', 'draft'))]}"
|
|
||||||
groups="rma.group_rma_manager"/>
|
|
||||||
<field name="state" widget="statusbar" nolabel="1"/>
|
|
||||||
</header>
|
|
||||||
<sheet string="RMA">
|
<sheet string="RMA">
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
<button type="object" name="action_view_in_shipments"
|
<button type="object" name="action_view_in_shipments"
|
||||||
@@ -218,15 +165,8 @@
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group col="4">
|
<group col="4">
|
||||||
<field name="assigned_to"
|
|
||||||
groups="base.group_user"
|
|
||||||
context="{'default_groups_ref': ['rma.rma_user']}"/>
|
|
||||||
<field name="reference"/>
|
<field name="reference"/>
|
||||||
<field name="requested_by"
|
|
||||||
groups="base.group_user"
|
|
||||||
context="{'default_groups_ref': ['rma.rma_user']}"/>
|
|
||||||
<field name="date_rma"/>
|
<field name="date_rma"/>
|
||||||
<field name="type" invisible="1"/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
@@ -258,6 +198,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<group name="comments">
|
<group name="comments">
|
||||||
<field name="comment"/>
|
<field name="comment"/>
|
||||||
|
<field name="type" readonly="1"/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
@@ -278,10 +219,7 @@
|
|||||||
<field name="reference"/>
|
<field name="reference"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="requested_by"/>
|
|
||||||
<field name="assigned_to"/>
|
|
||||||
<separator/>
|
<separator/>
|
||||||
<filter domain="[('assigned_to','=',uid)]" help="My RMAs"/>
|
|
||||||
<group expand="0" string="Group By">
|
<group expand="0" string="Group By">
|
||||||
<filter name="partner" string="Partner" domain="[]"
|
<filter name="partner" string="Partner" domain="[]"
|
||||||
context="{'group_by':'partner_id'}"/>
|
context="{'group_by':'partner_id'}"/>
|
||||||
@@ -293,23 +231,21 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_customer" model="ir.actions.act_window">
|
<record id="action_rma_customer" model="ir.actions.act_window">
|
||||||
<field name="name">Customer RMA</field>
|
<field name="name">Customer RMA Group</field>
|
||||||
<field name="res_model">rma.order</field>
|
<field name="res_model">rma.order</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="domain">[('type','=', 'customer')]</field>
|
<field name="domain">[('type','=', 'customer')]</field>
|
||||||
<field name="context">{"search_default_assigned_to":uid,
|
<field name="context">{'customer':1}</field>
|
||||||
'customer':1}</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_rma_tree"/>
|
<field name="view_id" ref="view_rma_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_supplier" model="ir.actions.act_window">
|
<record id="action_rma_supplier" model="ir.actions.act_window">
|
||||||
<field name="name">Supplier RMA</field>
|
<field name="name">Supplier RMA Group</field>
|
||||||
<field name="res_model">rma.order</field>
|
<field name="res_model">rma.order</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="domain">[('type','=', 'supplier')]</field>
|
<field name="domain">[('type','=', 'supplier')]</field>
|
||||||
<field name="context">{"search_default_assigned_to":uid,
|
<field name="context">{'supplier':1}</field>
|
||||||
'supplier':1}</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_rma_supplier_tree"/>
|
<field name="view_id" ref="view_rma_supplier_tree"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -343,14 +279,14 @@
|
|||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
id="menu_rma_act_customer"
|
id="menu_rma_act_customer"
|
||||||
sequence="10"
|
sequence="50"
|
||||||
parent="menu_customer_rma"
|
parent="menu_customer_rma"
|
||||||
groups="rma.group_rma_customer_user"
|
groups="rma.group_rma_customer_user"
|
||||||
action="action_rma_customer"/>
|
action="action_rma_customer"/>
|
||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
id="menu_rma_act_supplier"
|
id="menu_rma_act_supplier"
|
||||||
sequence="10"
|
sequence="50"
|
||||||
parent="menu_supplier_rma"
|
parent="menu_supplier_rma"
|
||||||
groups="rma.group_rma_supplier_user"
|
groups="rma.group_rma_supplier_user"
|
||||||
action="action_rma_supplier"/>
|
action="action_rma_supplier"/>
|
||||||
|
|||||||
@@ -61,12 +61,11 @@
|
|||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="inherit_id" ref="rma.view_rma_form"/>
|
<field name="inherit_id" ref="rma.view_rma_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<button name="action_rma_done" position="after">
|
<xpath expr="//header" position="inside">
|
||||||
<button name="%(action_rma_add_stock_move_customer)d"
|
<button name="%(action_rma_add_stock_move_customer)d"
|
||||||
string="Add From Stock Move"
|
string="Add From Stock Move"
|
||||||
type="action"
|
type="action"/>
|
||||||
states="draft,to_approve"/>
|
</xpath>
|
||||||
</button>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<separator string="Select Stock Moves to add"/>
|
<separator string="Select Stock Moves to add"/>
|
||||||
<field name="move_ids"
|
<field name="move_ids"
|
||||||
domain="[('picking_id.partner_id', '=', partner_id), ('location_dest_id.usage', '=', 'supplier')]"/>
|
domain="[('picking_id.partner_id', '=', partner_id), ('location_id.usage', '=', 'supplier')]"/>
|
||||||
<footer>
|
<footer>
|
||||||
<button
|
<button
|
||||||
string="Confirm"
|
string="Confirm"
|
||||||
@@ -116,12 +115,11 @@
|
|||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="inherit_id" ref="rma.view_rma_supplier_form"/>
|
<field name="inherit_id" ref="rma.view_rma_supplier_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<button name="action_rma_done" position="after">
|
<xpath expr="//header" position="inside">
|
||||||
<button name="%(action_rma_add_stock_move_supplier)d"
|
<button name="%(action_rma_add_stock_move_supplier)d"
|
||||||
string="Add From Stock Move"
|
string="Add From Stock Move"
|
||||||
type="action"
|
type="action"/>
|
||||||
states="draft,to_approve"/>
|
</xpath>
|
||||||
</button>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
'qty_to_receive': line.qty_to_receive,
|
'qty_to_receive': line.qty_to_receive,
|
||||||
'qty_to_deliver': line.qty_to_deliver,
|
'qty_to_deliver': line.qty_to_deliver,
|
||||||
'line_id': line.id,
|
'line_id': line.id,
|
||||||
'rma_id': line.rma_id.id,
|
'rma_id': line.rma_id and line.rma_id.id or False,
|
||||||
'wiz_id': self.env.context['active_id'],
|
'wiz_id': self.env.context['active_id'],
|
||||||
}
|
}
|
||||||
return values
|
return values
|
||||||
@@ -58,13 +58,19 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
'wiz_id', string='Items')
|
'wiz_id', string='Items')
|
||||||
|
|
||||||
def find_procurement_group(self, item):
|
def find_procurement_group(self, item):
|
||||||
return self.env['procurement.group'].search([('rma_id', '=',
|
if item.line_id.rma_id:
|
||||||
item.line_id.rma_id.id)])
|
return self.env['procurement.group'].search([
|
||||||
|
('rma_id', '=', item.line_id.rma_id.id)])
|
||||||
|
else:
|
||||||
|
return self.env['procurement.group'].search([
|
||||||
|
('rma_line_id', '=', item.line_id.id)])
|
||||||
|
|
||||||
def _get_procurement_group_data(self, item):
|
def _get_procurement_group_data(self, item):
|
||||||
group_data = {
|
group_data = {
|
||||||
'name': item.line_id.rma_id.name,
|
'name': item.line_id.rma_id.name or item.line_id.name,
|
||||||
'rma_id': item.line_id.rma_id.id,
|
'rma_id': item.line_id.rma_id and item.line_id.rma_id.id or False,
|
||||||
|
'rma_line_id': item.line_id.id if not item.line_id.rma_id else
|
||||||
|
False,
|
||||||
}
|
}
|
||||||
return group_data
|
return group_data
|
||||||
|
|
||||||
@@ -80,6 +86,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
raise ValidationError('Unknown delivery address')
|
raise ValidationError('Unknown delivery address')
|
||||||
return delivery_address
|
return delivery_address
|
||||||
|
|
||||||
|
@api.model
|
||||||
def _get_address_location(self, delivery_address_id, type):
|
def _get_address_location(self, delivery_address_id, type):
|
||||||
if type == 'supplier':
|
if type == 'supplier':
|
||||||
return delivery_address_id.property_stock_supplier
|
return delivery_address_id.property_stock_supplier
|
||||||
@@ -99,8 +106,8 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
warehouse = line.in_warehouse_id
|
warehouse = line.in_warehouse_id
|
||||||
route = line.in_route_id
|
route = line.in_route_id
|
||||||
else:
|
else:
|
||||||
location = self._get_address_location(delivery_address_id,
|
location = self._get_address_location(
|
||||||
line.rma_id.type)
|
delivery_address_id, line.type)
|
||||||
warehouse = line.out_warehouse_id
|
warehouse = line.out_warehouse_id
|
||||||
route = line.out_route_id
|
route = line.out_route_id
|
||||||
if not route:
|
if not route:
|
||||||
@@ -108,9 +115,9 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
if not warehouse:
|
if not warehouse:
|
||||||
raise ValidationError("No warehouse specified")
|
raise ValidationError("No warehouse specified")
|
||||||
procurement_data = {
|
procurement_data = {
|
||||||
'name': line.rma_id.name,
|
'name': line.rma_id and line.rma_id.name or line.name,
|
||||||
'group_id': group.id,
|
'group_id': group.id,
|
||||||
'origin': line.rma_id.name,
|
'origin': line.name,
|
||||||
'warehouse_id': warehouse.id,
|
'warehouse_id': warehouse.id,
|
||||||
'date_planned': time.strftime(DT_FORMAT),
|
'date_planned': time.strftime(DT_FORMAT),
|
||||||
'product_id': item.product_id.id,
|
'product_id': item.product_id.id,
|
||||||
@@ -127,8 +134,8 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
def _create_procurement(self, item, picking_type):
|
def _create_procurement(self, item, picking_type):
|
||||||
group = self.find_procurement_group(item)
|
group = self.find_procurement_group(item)
|
||||||
if not group:
|
if not group:
|
||||||
procurement_group = self._get_procurement_group_data(item)
|
pg_data = self._get_procurement_group_data(item)
|
||||||
group = self.env['procurement.group'].create(procurement_group)
|
group = self.env['procurement.group'].create(pg_data)
|
||||||
if picking_type == 'incoming':
|
if picking_type == 'incoming':
|
||||||
qty = item.qty_to_receive
|
qty = item.qty_to_receive
|
||||||
else:
|
else:
|
||||||
@@ -150,7 +157,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
if line.state != 'approved':
|
if line.state != 'approved':
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_('RMA %s is not approved') %
|
_('RMA %s is not approved') %
|
||||||
line.rma_id.name)
|
line.name)
|
||||||
if line.receipt_policy == 'no' and picking_type == \
|
if line.receipt_policy == 'no' and picking_type == \
|
||||||
'incoming':
|
'incoming':
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
@@ -216,7 +223,7 @@ class RmaMakePickingItem(models.TransientModel):
|
|||||||
ondelete='cascade')
|
ondelete='cascade')
|
||||||
rma_id = fields.Many2one('rma.order',
|
rma_id = fields.Many2one('rma.order',
|
||||||
related='line_id.rma_id',
|
related='line_id.rma_id',
|
||||||
string='RMA',
|
string='RMA Group',
|
||||||
readonly=True)
|
readonly=True)
|
||||||
product_id = fields.Many2one('product.product', string='Product',
|
product_id = fields.Many2one('product.product', string='Product',
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user