mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG]rma_sale v13
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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 . import models
|
from . import models
|
||||||
from . import wizards
|
from . import wizards
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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)
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "RMA Sale",
|
"name": "RMA Sale",
|
||||||
"version": "12.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"category": "RMA",
|
"category": "RMA",
|
||||||
"summary": "Links RMA with Sales Orders",
|
"summary": "Links RMA with Sales Orders",
|
||||||
"author": "Eficent, Odoo Community Association (OCA)",
|
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/Eficent/stock-rma",
|
"website": "https://github.com/Eficent/stock-rma",
|
||||||
"depends": ["rma_account", "sale_stock"],
|
"depends": ["rma_account", "sale_stock"],
|
||||||
"data": [
|
"data": [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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 . import sale_order_line
|
from . import sale_order_line
|
||||||
from . import rma_order_line
|
from . import rma_order_line
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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 fields, models
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ class RmaOrder(models.Model):
|
|||||||
domain = super(RmaOrder, self)._get_line_domain(rma_id, line)
|
domain = super(RmaOrder, self)._get_line_domain(rma_id, line)
|
||||||
return domain
|
return domain
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_sale_order(self):
|
def action_view_sale_order(self):
|
||||||
action = self.env.ref("sale.action_quotations")
|
action = self.env.ref("sale.action_quotations")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
from odoo.addons import decimal_precision as dp
|
|
||||||
|
|
||||||
|
|
||||||
class RmaOrderLine(models.Model):
|
class RmaOrderLine(models.Model):
|
||||||
_inherit = "rma.order.line"
|
_inherit = "rma.order.line"
|
||||||
@@ -61,7 +59,7 @@ class RmaOrderLine(models.Model):
|
|||||||
qty_to_sell = fields.Float(
|
qty_to_sell = fields.Float(
|
||||||
string="Qty To Sell",
|
string="Qty To Sell",
|
||||||
copy=False,
|
copy=False,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
compute="_compute_qty_to_sell",
|
compute="_compute_qty_to_sell",
|
||||||
store=True,
|
store=True,
|
||||||
@@ -69,7 +67,7 @@ class RmaOrderLine(models.Model):
|
|||||||
qty_sold = fields.Float(
|
qty_sold = fields.Float(
|
||||||
string="Qty Sold",
|
string="Qty Sold",
|
||||||
copy=False,
|
copy=False,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
compute="_compute_qty_sold",
|
compute="_compute_qty_sold",
|
||||||
store=True,
|
store=True,
|
||||||
@@ -111,7 +109,6 @@ class RmaOrderLine(models.Model):
|
|||||||
self.sale_policy = self.operation_id.sale_policy or "no"
|
self.sale_policy = self.operation_id.sale_policy or "no"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _prepare_rma_line_from_sale_order_line(self, line):
|
def _prepare_rma_line_from_sale_order_line(self, line):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if not self.type:
|
if not self.type:
|
||||||
@@ -148,8 +145,12 @@ class RmaOrderLine(models.Model):
|
|||||||
"product_qty": line.product_uom_qty,
|
"product_qty": line.product_uom_qty,
|
||||||
"delivery_address_id": line.order_id.partner_id.id,
|
"delivery_address_id": line.order_id.partner_id.id,
|
||||||
"invoice_address_id": line.order_id.partner_id.id,
|
"invoice_address_id": line.order_id.partner_id.id,
|
||||||
"price_unit": line.currency_id.compute(
|
"price_unit": line.currency_id._convert(
|
||||||
line.price_unit, line.currency_id, round=False
|
line.price_unit,
|
||||||
|
line.currency_id,
|
||||||
|
line.company_id,
|
||||||
|
line.order_id.date_order,
|
||||||
|
round=False,
|
||||||
),
|
),
|
||||||
"in_route_id": operation.in_route_id.id or route.id,
|
"in_route_id": operation.in_route_id.id or route.id,
|
||||||
"out_route_id": operation.out_route_id.id or route.id,
|
"out_route_id": operation.out_route_id.id or route.id,
|
||||||
@@ -175,14 +176,12 @@ class RmaOrderLine(models.Model):
|
|||||||
self.update(data)
|
self.update(data)
|
||||||
self._remove_other_data_origin("sale_line_id")
|
self._remove_other_data_origin("sale_line_id")
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _remove_other_data_origin(self, exception):
|
def _remove_other_data_origin(self, exception):
|
||||||
res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
|
res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
|
||||||
if not exception == "sale_line_id":
|
if not exception == "sale_line_id":
|
||||||
self.sale_line_id = False
|
self.sale_line_id = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("sale_line_id", "partner_id")
|
@api.constrains("sale_line_id", "partner_id")
|
||||||
def _check_sale_partner(self):
|
def _check_sale_partner(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -198,7 +197,6 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_sale_order(self):
|
def action_view_sale_order(self):
|
||||||
action = self.env.ref("sale.action_quotations")
|
action = self.env.ref("sale.action_quotations")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
@@ -206,7 +204,6 @@ class RmaOrderLine(models.Model):
|
|||||||
result["domain"] = [("id", "in", order_ids)]
|
result["domain"] = [("id", "in", order_ids)]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _get_rma_sold_qty(self):
|
def _get_rma_sold_qty(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
qty = 0.0
|
qty = 0.0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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
|
||||||
|
|
||||||
@@ -33,7 +33,6 @@ class SaleOrderLine(models.Model):
|
|||||||
name_get_uid=name_get_uid,
|
name_get_uid=name_get_uid,
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
res = []
|
res = []
|
||||||
if self.env.context.get("rma"):
|
if self.env.context.get("rma"):
|
||||||
@@ -66,7 +65,6 @@ class SaleOrderLine(models.Model):
|
|||||||
comodel_name="rma.order.line", string="RMA", ondelete="restrict"
|
comodel_name="rma.order.line", string="RMA", ondelete="restrict"
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _prepare_order_line_procurement(self, group_id=False):
|
def _prepare_order_line_procurement(self, group_id=False):
|
||||||
vals = super(SaleOrderLine, self)._prepare_order_line_procurement(
|
vals = super(SaleOrderLine, self)._prepare_order_line_procurement(
|
||||||
group_id=group_id
|
group_id=group_id
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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 . import test_rma_sale
|
from . import test_rma_sale
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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.tests import common
|
from odoo.tests import common
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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 . import rma_order_line_make_sale_order
|
from . import rma_order_line_make_sale_order
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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
|
||||||
@@ -80,8 +80,11 @@ class RmaAddSale(models.TransientModel):
|
|||||||
"product_qty": line.product_uom_qty,
|
"product_qty": line.product_uom_qty,
|
||||||
"delivery_address_id": self.sale_id.partner_id.id,
|
"delivery_address_id": self.sale_id.partner_id.id,
|
||||||
"invoice_address_id": self.sale_id.partner_id.id,
|
"invoice_address_id": self.sale_id.partner_id.id,
|
||||||
"price_unit": line.currency_id.compute(
|
"price_unit": line.currency_id._convert(
|
||||||
line.price_unit, line.currency_id, round=False
|
line.price_unit,
|
||||||
|
line.currency_id,
|
||||||
|
line.company_id,
|
||||||
|
line.order_id.date_order,
|
||||||
),
|
),
|
||||||
"rma_id": self.rma_id.id,
|
"rma_id": self.rma_id.id,
|
||||||
"in_route_id": operation.in_route_id.id or route.id,
|
"in_route_id": operation.in_route_id.id or route.id,
|
||||||
@@ -101,11 +104,7 @@ class RmaAddSale(models.TransientModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_rma_data(self):
|
def _get_rma_data(self):
|
||||||
data = {
|
data = {"date_rma": fields.Datetime.now()}
|
||||||
"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
|
return data
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -115,7 +114,6 @@ class RmaAddSale(models.TransientModel):
|
|||||||
existing_sale_lines.append(rma_line.sale_line_id)
|
existing_sale_lines.append(rma_line.sale_line_id)
|
||||||
return existing_sale_lines
|
return existing_sale_lines
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def add_lines(self):
|
def add_lines(self):
|
||||||
rma_line_obj = self.env["rma.order.line"]
|
rma_line_obj = self.env["rma.order.line"]
|
||||||
existing_sale_lines = self._get_existing_sale_lines()
|
existing_sale_lines = self._get_existing_sale_lines()
|
||||||
|
|||||||
@@ -54,8 +54,6 @@
|
|||||||
<field name="name">Add Sale Order</field>
|
<field name="name">Add Sale Order</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma_add_sale</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="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="view_id" ref="view_rma_add_sale"/>
|
<field name="view_id" ref="view_rma_add_sale"/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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, exceptions, fields, models
|
from odoo import _, api, exceptions, fields, models
|
||||||
|
|
||||||
import odoo.addons.decimal_precision as dp
|
|
||||||
|
|
||||||
|
|
||||||
class RmaLineMakeSaleOrder(models.TransientModel):
|
class RmaLineMakeSaleOrder(models.TransientModel):
|
||||||
_name = "rma.order.line.make.sale.order"
|
_name = "rma.order.line.make.sale.order"
|
||||||
@@ -96,7 +94,6 @@ class RmaLineMakeSaleOrder(models.TransientModel):
|
|||||||
vals["price_unit"] = 0.0
|
vals["price_unit"] = 0.0
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def make_sale_order(self):
|
def make_sale_order(self):
|
||||||
res = []
|
res = []
|
||||||
sale_obj = self.env["sale.order"]
|
sale_obj = self.env["sale.order"]
|
||||||
@@ -139,9 +136,7 @@ class RmaLineMakeSaleOrderItem(models.TransientModel):
|
|||||||
)
|
)
|
||||||
product_id = fields.Many2one(comodel_name="product.product", string="Product")
|
product_id = fields.Many2one(comodel_name="product.product", string="Product")
|
||||||
name = fields.Char(string="Description")
|
name = fields.Char(string="Description")
|
||||||
product_qty = fields.Float(
|
product_qty = fields.Float(string="Quantity to sell", digits="Product UoS")
|
||||||
string="Quantity to sell", digits=dp.get_precision("Product UoS")
|
|
||||||
)
|
|
||||||
product_uom_id = fields.Many2one(comodel_name="uom.uom", string="UoM")
|
product_uom_id = fields.Many2one(comodel_name="uom.uom", string="UoM")
|
||||||
out_warehouse_id = fields.Many2one(
|
out_warehouse_id = fields.Many2one(
|
||||||
comodel_name="stock.warehouse", string="Outbound Warehouse"
|
comodel_name="stock.warehouse", string="Outbound Warehouse"
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
<field name="name">Create Sales Quotation</field>
|
<field name="name">Create Sales Quotation</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma.order.line.make.sale.order</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_mode">form</field>
|
||||||
<field name="view_id" ref="view_rma_order_line_make_sale_order"/>
|
<field name="view_id" ref="view_rma_order_line_make_sale_order"/>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2020 ForgeFlow 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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user