add rma_repair

This commit is contained in:
Jordi Ballester
2017-09-19 13:58:49 +02:00
committed by JasminSForgeFlow
parent 37d01944c2
commit 45a30e0bbe
19 changed files with 810 additions and 0 deletions

57
rma_repair/README.rst Normal file
View File

@@ -0,0 +1,57 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:alt: License LGPL-3
========
RMA Sale
========
This module allows you to:
#. Import sales order lines into RMA lines
#. Create a sales order and/or sales order line from one or more RMA lines
Usage
=====
**Import existing sales order lines into an RMA:**
This feature is useful when you create an RMA associated to a product that
was shipped and you have as a reference the customer PO number.
#. Access to a customer RMA.
#. Fill the customer.
#. Press the button *Add from Sales Order*.
#. In the wizard add a sales order and click on *add item* to select the
lines you want to add to the RMA.
**Create a sales order and/or sales order line from RMA lines:**
#. Go to a approved RMA line.
#. Click on *Create a Sales Quotation*.
#. In the wizard, select an *Existing Quotation to update* or leave it empty
if you want to create a new one.
#. Fill the quantity to sell in the lines.
#. Hit *Create a Sales Quotation*.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/Eficent/stock-rma/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Aaron Henriquez <ahenriquez@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
Maintainer
----------
This module is maintained by Eficent

5
rma_repair/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import models
from . import wizards

22
rma_repair/__openerp__.py Normal file
View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
{
"name": "RMA Repair",
"version": "9.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Links RMA with Repairs.",
"author": "Eficent",
"website": "http://www.github.com/OCA/rma",
"depends": ["rma_account", "mrp_repair_refurbish"],
"data": ["views/rma_order_view.xml",
"views/rma_operation_view.xml",
"views/sale_order_view.xml",
"wizards/rma_order_line_make_sale_order_view.xml",
"wizards/rma_add_sale.xml",
"views/rma_order_line_view.xml"],
"installable": True,
"auto_install": True,
}

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import mrp_repair
from . import rma_order_line
from . import rma_order
from . import rma_operation

View File

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp import api, fields, models
class MrpRepair(models.Model):
_inherit = "mrp.repair"
rma_line_id = fields.Many2one(
comodel_name='rma.order.line', string='RMA', ondelete='restrict')

View File

@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp import fields, models
class RmaOperation(models.Model):
_inherit = 'rma.operation'
repair_type = fields.Selection([
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
('received', 'Based on Received Quantities')],
string="Repair Policy", default='no')

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp import api, fields, models
class RmaOrder(models.Model):
_inherit = "rma.order"
@api.multi
def _compute_repair_count(self):
for rma in self:
repairs = rma.mapped('rma_line_ids.repair_ids')
rma.rma_count = len(repairs)
repair_count = fields.Integer(
compute=_compute_repair_count, string='# of Repairs')
@api.multi
def action_view_repair_order(self):
action = self.env.ref('mrp_repair.action_repair_order_tree')
result = action.read()[0]
repair_ids = self.mapped('rma_line_ids.repair_ids').ids
result['domain'] = [('id', 'in', repair_ids)]
return result

View File

@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp import api, fields, models
from openerp.addons import decimal_precision as dp
class RmaOrderLine(models.Model):
_inherit = "rma.order.line"
@api.one
@api.depends('repair_ids', 'repair_ids.state')
def _compute_qty_to_repair(self):
if self.repair_type == 'no':
self.qty_to_repair = 0.0
elif self.repair_type == 'ordered':
qty = self._get_rma_repaired_qty()
self.qty_to_repair = self.product_qty - qty
elif self.repair_type == 'received':
qty = self._get_rma_repaired_qty()
self.qty_to_repair = self.qty_received - qty
else:
self.qty_to_repair = 0.0
@api.one
@api.depends('repair_ids', 'repair_type', 'repair_ids.state')
def _compute_qty_repaired(self):
self.qty_repaired = self._get_rma_repaired_qty()
@api.multi
def _compute_repair_count(self):
for line in self:
line.repair_count = len(line.repair_ids)
repair_ids = fields.One2many(
comodel_name='mrp.repair', inverse_name='rma_line_id',
string='Repair Orders', readonly=True,
states={'draft': [('readonly', False)]}, copy=False)
qty_to_repair = fields.Float(
string='Qty To Sell', copy=False,
digits=dp.get_precision('Product Unit of Measure'),
readonly=True, compute=_compute_qty_to_repair,
store=True)
qty_repaired = fields.Float(
string='Qty Sold', copy=False,
digits=dp.get_precision('Product Unit of Measure'),
readonly=True, compute=_compute_qty_repaired,
store=True)
repair_type = fields.Selection(selection=[
('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'),
('received', 'Based on Received Quantities')],
string="Repair Policy", default='no', required=True)
repair_count = fields.Integer(
compute=_compute_repair_count, string='# of Repairs')
@api.multi
def action_view_repair_order(self):
action = self.env.ref('mrp_repair.action_repair_order_tree')
result = action.read()[0]
result['domain'] = [('id', 'in', self.repair_ids.ids)]
return result
@api.multi
def _get_rma_repaired_qty(self):
self.ensure_one()
qty = 0.0
for repair in self.repair_ids.filtered(
lambda p: p.state != 'cancel'):
repair_qty = self.env['product.uom']._compute_qty_obj(
self.uom_id,
repair.product_uom_qty,
repair.product_uom,
)
qty += repair_qty
return qty

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_repair_order_form" model="ir.ui.view">
<field name="name">mrp.repair.form</field>
<field name="model">mrp.repair</field>
<field name="inherit_id" ref="mrp_repair.view_repair_order_form"/>
<field name="arch" type="xml">
<field name="guarantee_limit" position="after">
<field name="rma_line_id"/>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="rma_operation_tree" model="ir.ui.view">
<field name="name">rma.operation.tree</field>
<field name="model">rma.operation</field>
<field name="inherit_id" ref="rma.rma_operation_tree"/>
<field name="arch" type="xml">
<field name="delivery_policy" position="after">
<field name="repair_type"/>
</field>
</field>
</record>
<record id="rma_operation_form" model="ir.ui.view">
<field name="name">rma.operation.form</field>
<field name="model">rma.operation</field>
<field name="inherit_id" ref="rma.rma_operation_form"/>
<field name="arch" type="xml">
<field name="delivery_policy" position="after">
<field name="repair_type"/>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_rma_line_form" model="ir.ui.view">
<field name="name">rma.order.line.form</field>
<field name="model">rma.order.line</field>
<field name="inherit_id" ref="rma.view_rma_line_form"/>
<field name="arch" type="xml">
<div name='button_box' position="inside">
<button type="object" name="action_view_repair_order"
class="oe_stat_button"
icon="fa-strikethrough"
groups="stock.group_stock_user">
<field name="repair_count" widget="statinfo"
string="Repair Orders"/>
</button>
</div>
<group name="quantities" position="inside">
<group>
<field name="qty_to_repair"/>
<field name="qty_repaired"/>
</group>
</group>
<field name="delivery_policy" position="after">
<field name="repair_type"/>
</field>
<notebook position="inside">
<page name="repair" string="Repair Orders">
<field name="repair_ids" nolabel="1"/>
</page>
</notebook>
</field>
</record>
<record id="view_rma_line_button_repair_form" model="ir.ui.view">
<field name="name">rma.order.line.form</field>
<field name="model">rma.order.line</field>
<field name="inherit_id" ref="rma.view_rma_line_button_form"/>
<field name="arch" type="xml">
<header position="inside">
<button name="%(action_rma_order_line_make_repair_order)d"
states="approved"
string="Create Repair Order"
class="oe_highlight"
type="action"/>
</header>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_rma_form" model="ir.ui.view">
<field name="name">rma.order.form</field>
<field name="model">rma.order</field>
<field name="inherit_id" ref="rma.view_rma_form"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button type="object" name="action_view_sale_order"
class="oe_stat_button"
icon="fa-pencil-square-o"
groups="stock.group_stock_user">
<field name="repair_count" widget="statinfo"
string="Repair Orders"/>
</button>
</div>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import rma_order_line_make_sale_order
from . import rma_make_picking
from . import rma_refund
from . import rma_add_sale

View File

@@ -0,0 +1,115 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp import api, fields, models
from openerp.exceptions import ValidationError
class RmaAddSale(models.TransientModel):
_name = 'rma_add_sale'
_description = 'Wizard to add rma lines from SO lines'
@api.model
def default_get(self, fields):
res = super(RmaAddSale, self).default_get(fields)
rma_obj = self.env['rma.order']
rma_id = self.env.context['active_ids'] or []
active_model = self.env.context['active_model']
if not rma_id:
return res
assert active_model == 'rma.order', 'Bad context propagation'
rma = rma_obj.browse(rma_id)
res['rma_id'] = rma.id
res['partner_id'] = rma.partner_id.id
res['sale_id'] = False
res['sale_line_ids'] = False
return res
rma_id = fields.Many2one(
comodel_name='rma.order', string='RMA Order', readonly=True)
partner_id = fields.Many2one(comodel_name='res.partner', string='Partner',
readonly=True)
sale_id = fields.Many2one(comodel_name='sale.order', string='Order')
sale_line_ids = fields.Many2many('sale.order.line',
'rma_add_sale_add_line_rel',
'sale_line_id', 'rma_add_sale_id',
readonly=False,
string='Sale Lines')
def _prepare_rma_line_from_sale_order_line(self, line):
operation = line.product_id.rma_customer_operation_id
if not operation:
operation = line.product_id.categ_id.rma_customer_operation_id
if not operation:
operation = self.env['rma.operation'].search(
[('type', '=', self.rma_id.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.rma_id.company_id.id),
('lot_rma_id', '!=', False)], limit=1)
if not warehouse:
raise ValidationError("Please define a warehouse with a "
"default rma location.")
data = {
'sale_line_id': line.id,
'product_id': line.product_id.id,
'origin': line.order_id.name,
'uom_id': line.product_uom.id,
'operation_id': operation.id,
'product_qty': line.product_uom_qty,
'delivery_address_id': self.sale_id.partner_id.id,
'invoice_address_id': self.sale_id.partner_id.id,
'price_unit': line.currency_id.compute(
line.price_unit, line.currency_id, round=False),
'rma_id': self.rma_id.id,
'in_route_id': operation.in_route_id.id or route.id,
'out_route_id': operation.out_route_id.id or route.id,
'receipt_policy': operation.receipt_policy,
'location_id': (operation.location_id.id or
operation.in_warehouse_id.lot_rma_id.id or
warehouse.lot_rma_id.id),
'refund_policy': operation.refund_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,
}
return data
@api.model
def _get_rma_data(self):
data = {
'date_rma': fields.Datetime.now(),
'delivery_address_id': self.sale_id.partner_id.id,
'invoice_address_id': self.sale_id.partner_id.id
}
return data
@api.model
def _get_existing_sale_lines(self):
existing_sale_lines = []
for rma_line in self.rma_id.rma_line_ids:
existing_sale_lines.append(rma_line.sale_line_id)
return existing_sale_lines
@api.multi
def add_lines(self):
rma_line_obj = self.env['rma.order.line']
existing_sale_lines = self._get_existing_sale_lines()
for line in self.sale_line_ids:
# Load a PO line only once
if line not in existing_sale_lines:
data = self._prepare_rma_line_from_sale_order_line(line)
rma_line_obj.create(data)
rma = self.rma_id
data_rma = self._get_rma_data()
rma.write(data_rma)
return {'type': 'ir.actions.act_window_close'}

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_rma_add_sale" model="ir.ui.view">
<field name="name">rma.add.sale</field>
<field name="model">rma_add_sale</field>
<field name="arch" type="xml">
<form string="Select Sale Order from customer">
<separator string="Select Sale Order from customer"/>
<group>
<field name="partner_id"
domain="[('customer','=',True)]"
string="Customer"/>
</group>
<separator string="Select Sale Order Lines to Add"/>
<group>
<field name="sale_id"
domain="[
('partner_id','=',partner_id), (('state','not in',['draft','cancel']))]"
context="{'partner_id': partner_id}"/>
</group>
<field name="sale_line_ids"
domain="[('order_id', '=', sale_id)]"
string="Sale Order Lines">
<tree>
<field name="product_id" invisible="1"/>
<field name="order_id"/>
<field name="order_partner_id"/>
<field name="name"/>
<field name="salesman_id"/>
<field name="product_uom_qty" string="Qty"/>
<field name="qty_delivered"/>
<field name="qty_invoiced"/>
<field name="qty_to_invoice"/>
<field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>
<field name="price_subtotal" sum="Total" widget="monetary"/>
</tree>
</field>
<footer>
<button
string="Confirm"
name="add_lines" type="object"
class="oe_highlight"/>
or
<button name="action_cancel"
string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_rma_add_sale" model="ir.actions.act_window">
<field name="name">Add Sale Order</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rma_add_sale</field>
<field name="src_model">rma.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="view_rma_add_sale"/>
<field name="groups_id" eval="[(4, ref('rma.group_rma_customer_user')), (4, ref('rma.group_rma_customer_user'))]"/>
</record>
<record id="view_rma_add_sale_form" model="ir.ui.view">
<field name="name">rma.order.form - sale wizard</field>
<field name="model">rma.order</field>
<field name="inherit_id" ref="rma.view_rma_form"/>
<field name="arch" type="xml">
<button name="action_rma_done" position="after">
<button name="%(action_rma_add_sale)d"
string="Add From Sale Order"
type="action"
states="draft,to_approve"/>
</button>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp import api, fields, models
class RmaMakePicking(models.TransientModel):
_inherit = 'rma_make_picking.wizard'
@api.returns('rma.order.line')
def _prepare_item(self, line):
res = super(RmaMakePicking, self)._prepare_item(line)
res['sale_line_id'] = line.sale_line_id.id
return res
class RmaMakePickingItem(models.TransientModel):
_inherit = "rma_make_picking.wizard.item"
sale_line_id = fields.Many2one(
comodel_name='sale.order.line', string='Sale Line')

View File

@@ -0,0 +1,153 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
import openerp.addons.decimal_precision as dp
from openerp import _, api, exceptions, fields, models
class RmaLineMakeSaleOrder(models.TransientModel):
_name = "rma.order.line.make.sale.order"
_description = "Make Sales Order from RMA Line"
partner_id = fields.Many2one(
comodel_name='res.partner', string='Customer', required=False,
domain=[('supplier', '=', True)])
item_ids = fields.One2many(
comodel_name='rma.order.line.make.sale.order.item',
inverse_name='wiz_id', string='Items')
sale_order_id = fields.Many2one(
comodel_name='sale.order', string='Sales Order', required=False,
domain=[('state', '=', 'draft')])
@api.model
def _prepare_item(self, line):
return {
'line_id': line.id,
'rma_line_id': line.id,
'product_id': line.product_id.id,
'name': line.product_id.name,
'product_qty': line.qty_to_sell,
'rma_id': line.rma_id.id,
'out_warehouse_id': line.out_warehouse_id.id,
'out_route_id': line.out_route_id.id,
'product_uom_id': line.uom_id.id,
}
@api.model
def default_get(self, fields):
res = super(RmaLineMakeSaleOrder, self).default_get(
fields)
rma_line_obj = self.env['rma.order.line']
rma_line_ids = self.env.context['active_ids'] or []
active_model = self.env.context['active_model']
if not rma_line_ids:
return res
assert active_model == 'rma.order.line', 'Bad context propagation'
items = []
lines = rma_line_obj.browse(rma_line_ids)
for line in lines:
items.append([0, 0, self._prepare_item(line)])
customers = lines.mapped('partner_id')
if len(customers) == 1:
res['partner_id'] = customers.id
else:
raise exceptions.Warning(
_('Only RMA lines from the same partner can be processed at '
'the same time'))
res['item_ids'] = items
return res
@api.model
def _prepare_sale_order(self, out_warehouse, company):
if not self.partner_id:
raise exceptions.Warning(
_('Enter a customer.'))
customer = self.partner_id
data = {
'origin': '',
'partner_id': customer.id,
'warehouse_id': out_warehouse.id,
'company_id': company.id,
}
return data
@api.model
def _prepare_sale_order_line(self, so, item):
product = item.product_id
vals = {
'name': product.name,
'order_id': so.id,
'product_id': product.id,
'product_uom': product.uom_po_id.id,
'route_id': item.out_route_id.id,
'product_uom_qty': item.product_qty,
'rma_line_id': item.line_id.id
}
if item.free_of_charge:
vals['price_unit'] = 0.0
return vals
@api.multi
def make_sale_order(self):
res = []
sale_obj = self.env['sale.order']
so_line_obj = self.env['sale.order.line']
sale = False
for item in self.item_ids:
line = item.line_id
if item.product_qty <= 0.0:
raise exceptions.Warning(
_('Enter a positive quantity.'))
if self.sale_order_id:
sale = self.sale_order_id
if not sale:
po_data = self._prepare_sale_order(line.out_warehouse_id,
line.company_id)
sale = sale_obj.create(po_data)
so_line_data = self._prepare_sale_order_line(sale, item)
so_line_obj.create(so_line_data)
res.append(sale.id)
return {
'domain': "[('id','in', ["+','.join(map(str, res))+"])]",
'name': _('Quotations'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'sale.order',
'view_id': False,
'context': False,
'type': 'ir.actions.act_window'
}
class RmaLineMakeSaleOrderItem(models.TransientModel):
_name = "rma.order.line.make.sale.order.item"
_description = "RMA Line Make Sale Order Item"
wiz_id = fields.Many2one(
comodel_name='rma.order.line.make.sale.order', string='Wizard',
required=True, readonly=True)
line_id = fields.Many2one(
comodel_name='rma.order.line', string='RMA Line', required=True)
rma_id = fields.Many2one(
comodel_name='rma.order', related='line_id.rma_id',
string='RMA Order', readonly=True)
product_id = fields.Many2one(
comodel_name='product.product', string='Product', readonly=True)
name = fields.Char(string='Description', required=True, readonly=True)
product_qty = fields.Float(
string='Quantity to sell', digits=dp.get_precision('Product UoS'))
product_uom_id = fields.Many2one(
comodel_name='product.uom', string='UoM', readonly=True)
out_warehouse_id = fields.Many2one(
comodel_name='stock.warehouse', string='Outbound Warehouse')
free_of_charge = fields.Boolean(string='Free of Charge')
out_route_id = fields.Many2one(
comodel_name='stock.location.route', string='Outbound Route',
domain=[('rma_selectable', '=', True)])

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Eficent Business and IT Consulting Services S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<openerp>
<data>
<record id="view_rma_order_line_make_sale_order" model="ir.ui.view">
<field name="name">RMA Line Make Sale Order</field>
<field name="model">rma.order.line.make.sale.order</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create Quotation">
<separator string="Existing Quotation to update:"/>
<newline/>
<group>
<field name="sale_order_id"
domain="[('partner_id','=',partner_id)]"
context="{'partner_id': partner_id}"/>/>
</group>
<newline/>
<separator
string="New Sales Order details:"/>
<newline/>
<group>
<field name="partner_id"/>
</group>
<newline/>
<group>
<field name="item_ids" nolabel="1" colspan="2">
<tree string="Details" editable="bottom" create="false">
<field name="line_id"
options="{'no_open': true}"/>
<field name="product_id"/>
<field name="name"/>
<field name="product_qty"/>
<field name="product_uom_id"
groups="product.group_uom"/>
<field name="free_of_charge"/>
</tree>
</field>
</group>
<newline/>
<group colspan="2">
<button name="make_sale_order"
string="Create Sales Quotation" type="object"
class="oe_highlight"/>
<button special="cancel" string="Cancel" class="oe_link"/>
</group>
</form>
</field>
</record>
<record id="action_rma_order_line_make_sale_order"
model="ir.actions.act_window">
<field name="name">Create Sales Quotation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rma.order.line.make.sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_rma_order_line_make_sale_order"/>
<field name="target">new</field>
</record>
<record model="ir.values" id="rma_order_line_make_sale_order">
<field name="model_id" ref="model_rma_order_line" />
<field name="name">Create RFQ</field>
<field name="key2">client_action_multi</field>
<field name="value"
eval="'ir.actions.act_window,' + str(ref('action_rma_order_line_make_sale_order'))" />
<field name="key">action</field>
<field name="model">rma.order.line</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from openerp import api, fields, models
class RmaRefund(models.TransientModel):
_inherit = "rma.refund"
@api.returns('rma.order.line')
def _prepare_item(self, line):
res = super(RmaRefund, self)._prepare_item(line)
res['sale_line_id'] = line.sale_line_id.id
return res
class RmaRefundItem(models.TransientModel):
_inherit = "rma.refund.item"
sale_line_id = fields.Many2one(
comodel_name='sale.order.line', string='Sale Order Line')