[MIG] rma: Migration to 13.0

This commit is contained in:
ahenriquez
2020-01-14 16:42:55 +01:00
committed by hveficent
parent 6971c69959
commit f3c1a1c438
39 changed files with 746 additions and 599 deletions

View File

@@ -100,7 +100,7 @@ Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/Eficent/stock-rma/issues>`_. In case of trouble, please
<https://github.com/ForgeFlow/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.
@@ -111,9 +111,9 @@ Credits
Contributors
------------
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Aaron Henriquez <ahenriquez@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
* Jordi Ballester Alomar <jordi.ballester@ForgeFlow.com>
* Aaron Henriquez <ahenriquez@ForgeFlow.com>
* Lois Rilo <lois.rilo@ForgeFlow.com>
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
@@ -122,4 +122,4 @@ Contributors
Maintainer
----------
This module is maintained by Eficent.
This module is maintained by ForgeFlow.

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import models

View File

@@ -1,15 +1,15 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
{
"name": "RMA (Return Merchandise Authorization)",
"version": "12.0.2.3.0",
"version": "13.0.1.0.0",
"license": "LGPL-3",
"category": "RMA",
"summary": "Introduces the return merchandise authorization (RMA) process "
"in odoo",
"author": "Eficent, Odoo Community Association (OCA)",
"website": "https://github.com/Eficent/stock-rma",
"author": "ForgeFlow",
"website": "https://github.com/ForgeFlow/stock-rma",
"depends": ["stock", "mail", "web"],
"demo": ["demo/stock_demo.xml"],
"data": [
@@ -33,5 +33,4 @@
"wizards/rma_order_line_make_supplier_rma_view.xml",
],
"installable": True,
"auto_install": False,
}

0
rma/data/rma_operation.xml Executable file → Normal file
View File

0
rma/data/rma_sequence.xml Executable file → Normal file
View File

9
rma/data/stock_data.xml Executable file → Normal file
View File

@@ -44,6 +44,7 @@
<record id="picking_type_rma_cust_out" model="stock.picking.type">
<field name="name">RMA → Customer</field>
<field name="sequence_id" ref="seq_picking_type_rma_cust_out"/>
<field name="sequence_code">RMA → Customer</field>
<field name="default_location_src_id" ref="rma.location_rma"/>
<field name="default_location_dest_id"
ref="stock.stock_location_customers"/>
@@ -54,6 +55,7 @@
<record id="picking_type_rma_cust_in" model="stock.picking.type">
<field name="name">Customer → RMA</field>
<field name="sequence_id" ref="seq_picking_type_rma_cust_in"/>
<field name="sequence_code">Customer → RMA</field>
<field name="default_location_src_id" ref="stock.stock_location_customers"/>
<field name="default_location_dest_id"
ref="rma.location_rma"/>
@@ -64,6 +66,7 @@
<record id="picking_type_rma_sup_out" model="stock.picking.type">
<field name="name">RMA -> Supplier</field>
<field name="sequence_id" ref="seq_picking_type_rma_sup_out"/>
<field name="sequence_code">RMA -> Supplier</field>
<field name="default_location_src_id" ref="rma.location_rma"/>
<field name="default_location_dest_id"
ref="stock.stock_location_suppliers"/>
@@ -74,6 +77,7 @@
<record id="picking_type_rma_sup_in" model="stock.picking.type">
<field name="name">Supplier -> RMA</field>
<field name="sequence_id" ref="seq_picking_type_rma_sup_in"/>
<field name="sequence_code">Supplier -> RMA</field>
<field name="default_location_src_id" ref="stock.stock_location_suppliers"/>
<field name="default_location_dest_id"
ref="rma.location_rma"/>
@@ -84,6 +88,7 @@
<record id="picking_type_rma_dropship_return" model="stock.picking.type">
<field name="name">Customer -> Supplier</field>
<field name="sequence_id" ref="seq_picking_type_rma_dropship"/>
<field name="sequence_code">Customer -> Supplier</field>
<field name="default_location_src_id"
ref="stock.stock_location_customers"/>
<field name="default_location_dest_id"
@@ -95,6 +100,7 @@
<record id="picking_type_rma_dropship" model="stock.picking.type">
<field name="name">Supplier -> Customer</field>
<field name="sequence_id" ref="seq_picking_type_rma_dropship"/>
<field name="sequence_code">Supplier -> Customer</field>
<field name="default_location_src_id"
ref="stock.stock_location_suppliers"/>
<field name="default_location_dest_id"
@@ -115,7 +121,6 @@
<field name="name">RMA Customer</field>
<field name="company_id" eval="0"/>
<field name="sequence">10</field>
<field name="sale_selectable" eval="False"/>
<field name="product_selectable" eval="False"/>
<field name="product_categ_selectable" eval="False"/>
<field name="warehouse_selectable" eval="False"/>
@@ -126,7 +131,6 @@
<field name="name">RMA Supplier</field>
<field name="company_id" eval="0"/>
<field name="sequence">10</field>
<field name="sale_selectable" eval="False"/>
<field name="product_selectable" eval="False"/>
<field name="product_categ_selectable" eval="False"/>
<field name="warehouse_selectable" eval="False"/>
@@ -137,7 +141,6 @@
<field name="name">RMA Dropship</field>
<field name="company_id" eval="0"/>
<field name="sequence">10</field>
<field name="sale_selectable" eval="False"/>
<field name="product_selectable" eval="False"/>
<field name="product_categ_selectable" eval="False"/>
<field name="warehouse_selectable" eval="False"/>

3
rma/demo/stock_demo.xml Executable file → Normal file
View File

@@ -64,7 +64,6 @@
<record id="route_rma_customer" model="stock.location.route">
<field name="name">RMA Customer</field>
<field name="sequence">10</field>
<field name="sale_selectable" eval="False"/>
<field name="product_selectable" eval="False"/>
<field name="product_categ_selectable" eval="False"/>
<field name="warehouse_selectable" eval="False"/>
@@ -74,7 +73,6 @@
<record id="route_rma_supplier" model="stock.location.route">
<field name="name">RMA Supplier</field>
<field name="sequence">10</field>
<field name="sale_selectable" eval="False"/>
<field name="product_selectable" eval="False"/>
<field name="product_categ_selectable" eval="False"/>
<field name="warehouse_selectable" eval="False"/>
@@ -84,7 +82,6 @@
<record id="route_rma_dropship" model="stock.location.route">
<field name="name">RMA Dropship</field>
<field name="sequence">10</field>
<field name="sale_selectable" eval="False"/>
<field name="product_selectable" eval="False"/>
<field name="product_categ_selectable" eval="False"/>
<field name="warehouse_selectable" eval="False"/>

View File

@@ -9,3 +9,4 @@ from . import product
from . import product_category
from . import procurement
from . import res_partner
from . import res_company

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models
@@ -7,10 +7,6 @@ from odoo import fields, models
class StockRule(models.Model):
_inherit = "stock.rule"
rma_line_id = fields.Many2one(
comodel_name="rma.order.line", string="RMA line", ondelete="set null"
)
def _get_stock_move_values(
self,
product_id,
@@ -19,8 +15,8 @@ class StockRule(models.Model):
location_id,
name,
origin,
company_id,
values,
group_id,
):
res = super(StockRule, self)._get_stock_move_values(
product_id,
@@ -29,11 +25,11 @@ class StockRule(models.Model):
location_id,
name,
origin,
company_id,
values,
group_id,
)
if "rma_line_id" in values:
line = self.env["rma.order.line"].browse(values.get("rma_line_id"))
line = values.get("rma_line_id")
res["rma_line_id"] = line.id
if line.delivery_address_id:
res["partner_id"] = line.delivery_address_id.id

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models

View File

@@ -1,4 +1,4 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models

14
rma/models/res_company.py Normal file
View File

@@ -0,0 +1,14 @@
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
group_rma_delivery_address = fields.Boolean(
string="RMA addresses",
help="Display 3 fields on rma: partner, invoice address, delivery address",
)
group_rma_lines = fields.Boolean(
string="Use RMA groups", help="Group RMA lines in one RMA group"
)

View File

@@ -1,13 +1,12 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 ForgeFlow
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
from odoo import fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
@api.multi
def _compute_rma_line_count(self):
for rec in self:
rec.rma_line_count = len(rec.rma_line_ids)
@@ -17,7 +16,6 @@ class ResPartner(models.Model):
)
rma_line_count = fields.Integer(compute="_compute_rma_line_count")
@api.multi
def action_open_partner_rma(self):
action = self.env.ref("rma.action_rma_customer_lines")
result = action.read()[0]

View File

@@ -1,4 +1,4 @@
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
# Copyright 2017-18 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import api, fields, models

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from datetime import datetime
@@ -18,10 +18,12 @@ class RmaOrder(models.Model):
return "supplier"
return "customer"
@api.multi
def _compute_in_shipment_count(self):
for rec in self:
picking_ids = []
if not rec.rma_line_ids:
rec.in_shipment_count = 0
continue
for line in rec.rma_line_ids:
for move in line.move_ids:
if move.location_dest_id.usage == "internal":
@@ -30,33 +32,32 @@ class RmaOrder(models.Model):
if line.customer_to_supplier:
picking_ids.append(move.picking_id.id)
shipments = list(set(picking_ids))
line.in_shipment_count = len(shipments)
rec.in_shipment_count = len(shipments)
@api.multi
def _compute_out_shipment_count(self):
picking_ids = []
for rec in self:
if not rec.rma_line_ids:
rec.out_shipment_count = 0
continue
for line in rec.rma_line_ids:
for move in line.move_ids:
if move.location_dest_id.usage in ("supplier", "customer"):
if not line.customer_to_supplier:
picking_ids.append(move.picking_id.id)
shipments = list(set(picking_ids))
line.out_shipment_count = len(shipments)
rec.out_shipment_count = len(shipments)
@api.multi
def _compute_supplier_line_count(self):
self.supplier_line_count = len(
self.rma_line_ids.filtered(lambda r: r.supplier_rma_line_ids)
)
@api.multi
def _compute_line_count(self):
for rec in self:
rec.line_count = len(rec._get_valid_lines())
@api.depends("rma_line_ids", "rma_line_ids.state")
@api.multi
def _compute_state(self):
for rec in self:
rma_line_done = self.env["rma.order.line"].search_count(
@@ -114,9 +115,7 @@ class RmaOrder(models.Model):
out_shipment_count = fields.Integer(
compute="_compute_out_shipment_count", string="# of Outgoing Shipments"
)
line_count = fields.Integer(
compute="_compute_line_count", string="# of Outgoing Shipments"
)
line_count = fields.Integer(compute="_compute_line_count", string="# of RMA lines")
supplier_line_count = fields.Integer(
compute="_compute_supplier_line_count", string="# of Supplier RMAs"
)
@@ -184,7 +183,6 @@ class RmaOrder(models.Model):
vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.customer")
return super(RmaOrder, self).create(vals)
@api.multi
def action_view_in_shipments(self):
action = self.env.ref("stock.action_picking_tree_all")
result = action.read()[0]
@@ -207,7 +205,6 @@ class RmaOrder(models.Model):
result["res_id"] = shipments[0]
return result
@api.multi
def action_view_out_shipments(self):
action = self.env.ref("stock.action_picking_tree_all")
result = action.read()[0]
@@ -228,14 +225,12 @@ class RmaOrder(models.Model):
result["res_id"] = shipments[0]
return result
@api.multi
def _get_valid_lines(self):
""":return: A recordset of rma lines.
"""
self.ensure_one()
return self.rma_line_ids
@api.multi
def action_view_lines(self):
if self.type == "customer":
action = self.env.ref("rma.action_rma_customer_lines")
@@ -254,7 +249,6 @@ class RmaOrder(models.Model):
result["context"] = {}
return result
@api.multi
def action_view_supplier_lines(self):
action = self.env.ref("rma.action_rma_supplier_lines")
result = action.read()[0]

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
import operator
@@ -6,8 +6,6 @@ import operator
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.addons import decimal_precision as dp
ops = {"=": operator.eq, "!=": operator.ne}
@@ -38,16 +36,12 @@ class RmaOrderLine(models.Model):
wh = self._default_warehouse_id()
return wh.lot_rma_id
@api.model
def _default_delivery_address(self):
partner_id = self.env.context.get("partner_id", False)
if partner_id:
partner = self.env["res.partner"].browse(partner_id)
addr = partner.address_get(["delivery"])
return self.env["res.partner"].browse(addr["delivery"])
return False
@api.onchange("partner_id")
def _onchange_delivery_address(self):
self.delivery_address_id = self.env["res.partner"].browse(
self.partner_id.address_get(["delivery"])["delivery"]
)
@api.multi
def _compute_in_shipment_count(self):
for line in self:
picking_ids = []
@@ -60,7 +54,6 @@ class RmaOrderLine(models.Model):
shipments = list(set(picking_ids))
line.in_shipment_count = len(shipments)
@api.multi
def _compute_out_shipment_count(self):
picking_ids = []
for line in self:
@@ -71,7 +64,6 @@ class RmaOrderLine(models.Model):
shipments = list(set(picking_ids))
line.out_shipment_count = len(shipments)
@api.multi
def _get_rma_move_qty(self, states, direction="in"):
for rec in self:
product_obj = self.env["uom.uom"]
@@ -86,7 +78,6 @@ class RmaOrderLine(models.Model):
qty += product_obj._compute_quantity(move.product_uom_qty, rec.uom_id)
return qty
@api.multi
@api.depends(
"move_ids",
"move_ids.state",
@@ -103,7 +94,6 @@ class RmaOrderLine(models.Model):
elif rec.receipt_policy == "delivered":
rec.qty_to_receive = rec.qty_delivered - rec.qty_received
@api.multi
@api.depends(
"move_ids",
"move_ids.state",
@@ -121,7 +111,6 @@ class RmaOrderLine(models.Model):
elif rec.delivery_policy == "received":
rec.qty_to_deliver = rec.qty_received - rec.qty_delivered
@api.multi
@api.depends("move_ids", "move_ids.state", "type")
def _compute_qty_incoming(self):
for rec in self:
@@ -130,14 +119,12 @@ class RmaOrderLine(models.Model):
)
rec.qty_incoming = qty
@api.multi
@api.depends("move_ids", "move_ids.state", "type")
def _compute_qty_received(self):
for rec in self:
qty = rec._get_rma_move_qty("done", direction="in")
rec.qty_received = qty
@api.multi
@api.depends("move_ids", "move_ids.state", "type")
def _compute_qty_outgoing(self):
for rec in self:
@@ -146,7 +133,6 @@ class RmaOrderLine(models.Model):
)
rec.qty_outgoing = qty
@api.multi
@api.depends("move_ids", "move_ids.state", "type")
def _compute_qty_delivered(self):
for rec in self:
@@ -161,7 +147,6 @@ class RmaOrderLine(models.Model):
)
)
@api.multi
@api.depends(
"customer_to_supplier",
"supplier_rma_line_ids",
@@ -182,7 +167,6 @@ class RmaOrderLine(models.Model):
rec.qty_to_supplier_rma = 0.0
rec.qty_in_supplier_rma = 0.0
@api.multi
def _compute_rma_line_count(self):
for rec in self.filtered(lambda r: r.type == "customer"):
rec.rma_line_count = len(rec.supplier_rma_line_ids)
@@ -192,7 +176,6 @@ class RmaOrderLine(models.Model):
delivery_address_id = fields.Many2one(
comodel_name="res.partner",
string="Partner delivery address",
default=lambda self: self._default_delivery_address(),
readonly=True,
states={"draft": [("readonly", False)]},
help="This address will be used to deliver repaired or replacement "
@@ -279,7 +262,7 @@ class RmaOrderLine(models.Model):
string="Return Qty",
copy=False,
default=1.0,
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
readonly=True,
states={"draft": [("readonly", False)]},
)
@@ -309,7 +292,11 @@ class RmaOrderLine(models.Model):
readonly=True,
states={"draft": [("readonly", False)]},
)
currency_id = fields.Many2one("res.currency", string="Currency")
currency_id = fields.Many2one(
"res.currency",
string="Currency",
default=lambda self: self.env.user.company_id.currency_id,
)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
@@ -420,7 +407,7 @@ class RmaOrderLine(models.Model):
)
qty_to_receive = fields.Float(
string="Qty To Receive",
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
compute="_compute_qty_to_receive",
store=True,
)
@@ -428,21 +415,21 @@ class RmaOrderLine(models.Model):
string="Incoming Qty",
copy=False,
readonly=True,
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
compute="_compute_qty_incoming",
store=True,
)
qty_received = fields.Float(
string="Qty Received",
copy=False,
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
compute="_compute_qty_received",
store=True,
)
qty_to_deliver = fields.Float(
string="Qty To Deliver",
copy=False,
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
readonly=True,
compute="_compute_qty_to_deliver",
store=True,
@@ -451,28 +438,28 @@ class RmaOrderLine(models.Model):
string="Outgoing Qty",
copy=False,
readonly=True,
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
compute="_compute_qty_outgoing",
store=True,
)
qty_delivered = fields.Float(
string="Qty Delivered",
copy=False,
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
readonly=True,
compute="_compute_qty_delivered",
store=True,
)
qty_to_supplier_rma = fields.Float(
string="Qty to send to Supplier RMA",
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
readonly=True,
compute="_compute_qty_supplier_rma",
store=True,
)
qty_in_supplier_rma = fields.Float(
string="Qty in Supplier RMA",
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
readonly=True,
compute="_compute_qty_supplier_rma",
store=True,
@@ -481,7 +468,6 @@ class RmaOrderLine(models.Model):
string="Under Warranty?", readonly=True, states={"draft": [("readonly", False)]}
)
@api.multi
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
if not self.type:
self.type = self._get_default_type()
@@ -542,7 +528,6 @@ class RmaOrderLine(models.Model):
}
return data
@api.multi
@api.onchange("reference_move_id")
def _onchange_reference_move_id(self):
self.ensure_one()
@@ -562,7 +547,6 @@ class RmaOrderLine(models.Model):
self.update(data)
self._remove_other_data_origin("reference_move_id")
@api.multi
@api.constrains("reference_move_id", "partner_id")
def _check_move_partner(self):
for rec in self:
@@ -577,13 +561,11 @@ class RmaOrderLine(models.Model):
)
)
@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:
@@ -591,19 +573,16 @@ class RmaOrderLine(models.Model):
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
@@ -676,7 +655,6 @@ class RmaOrderLine(models.Model):
self.product_id = product
self.uom_id = product.uom_id
@api.multi
def action_view_in_shipments(self):
action = self.env.ref("stock.action_picking_tree_all")
result = action.read()[0]
@@ -699,7 +677,6 @@ class RmaOrderLine(models.Model):
result["res_id"] = shipments[0]
return result
@api.multi
def action_view_out_shipments(self):
action = self.env.ref("stock.action_picking_tree_all")
result = action.read()[0]
@@ -719,7 +696,6 @@ class RmaOrderLine(models.Model):
result["res_id"] = shipments[0]
return result
@api.multi
def action_view_rma_lines(self):
if self.type == "customer":
# from customer we link to supplier rma

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import api, fields, models
@@ -7,7 +7,6 @@ from odoo import api, fields, models
class StockPicking(models.Model):
_inherit = "stock.picking"
@api.multi
def action_assign(self):
"""When you try to bring back a product from a customer location,
it may happen that there is no quants available to perform the

View File

@@ -1,7 +1,7 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import _, api, fields, models
from odoo import _, fields, models
class StockWarehouse(models.Model):
@@ -41,7 +41,6 @@ class StockWarehouse(models.Model):
comodel_name="stock.rule", string="RMA Supplier Out Rule"
)
@api.multi
def _get_rma_types(self):
return [
self.rma_cust_out_type_id,
@@ -50,16 +49,14 @@ class StockWarehouse(models.Model):
self.rma_sup_in_type_id,
]
@api.multi
def _rma_types_available(self):
self.ensure_one()
rma_types = self._get_rma_types()
for type in rma_types:
if not type:
for r_type in rma_types:
if not r_type:
return False
return True
@api.multi
def write(self, vals):
if "rma_in_this_wh" in vals:
if vals.get("rma_in_this_wh"):
@@ -78,16 +75,16 @@ class StockWarehouse(models.Model):
if not wh._rma_types_available():
wh._create_rma_picking_types()
else:
for type in wh._get_rma_types():
if type:
type.active = True
for r_type in wh._get_rma_types():
if r_type:
r_type.active = True
# RMA rules:
wh._create_or_update_rma_pull()
else:
for wh in self:
for type in wh._get_rma_types():
if type:
type.active = False
for r_type in wh._get_rma_types():
if r_type:
r_type.active = False
# Unlink rules:
self.mapped("rma_customer_in_pull_id").unlink()
self.mapped("rma_customer_out_pull_id").unlink()
@@ -174,7 +171,6 @@ class StockWarehouse(models.Model):
)
return True
@api.multi
def get_rma_rules_dict(self):
self.ensure_one()
rma_rules = dict()

View File

@@ -6,7 +6,7 @@
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-6">
<div class="col-6">
<t t-if="(doc.customer_to_supplier==False and doc.type=='customer') or (doc.supplier_to_customer==False and doc.type=='supplier')">
<strong>Shipping address:</strong>
<div class="mt8">
@@ -28,7 +28,7 @@
<p t-if="doc.customer_address_id.vat">VAT: <span t-field="doc.customer_address_id.vat"/></p>
</div>
</div>
<div class="col-xs-3 col-xs-offset-1">
<div class="col-3 offset-1">
<strong t-if="doc.type=='customer'">Customer:</strong>
<strong t-if="doc.type=='supplier'">Supplier:</strong>
<div t-field="doc.partner_id"
@@ -36,24 +36,24 @@
</div>
</div>
<h2>
<h2 class="mt32">
<span t-field="doc.name"/>
</h2>
<div class="row mt32 mb32" id="informations">
<div t-if="doc.origin" class="col-xs-3">
<div t-if="doc.origin" class="col-3">
<strong>Origin Reference:</strong>
<p t-field="doc.origin"/>
</div>
<div t-if="doc.create_date" class="col-xs-3">
<div t-if="doc.create_date" class="col-3">
<strong>Date Ordered:</strong>
<p t-field="doc.create_date"/>
</div>
<div t-if="doc.requested_by.name" class="col-xs-3">
<div t-if="doc.requested_by.name" class="col-3">
<strong>Contact Person:</strong>
<p t-field="doc.requested_by.name"/>
</div>
<div name="operation_id" t-if="doc.operation_id" class="col-xs-3">
<div name="operation_id" t-if="doc.operation_id" class="col-3">
<strong>Operation:</strong>
<p t-field="doc.operation_id.name"/>
</div>
@@ -108,7 +108,7 @@
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-6">
<div class="col-6">
<t t-if="(doc.customer_to_supplier==False and doc.type=='customer') or (doc.supplier_to_customer==False and doc.type=='supplier')">
<strong>Shipping address:</strong>
<div class="mt8">
@@ -130,7 +130,7 @@
<p t-if="doc.customer_address_id.vat">VAT: <span t-field="doc.customer_address_id.vat"/></p>
</div>
</div>
<div class="col-xs-3 col-xs-offset-1">
<div class="col-3 offset-1">
<strong t-if="doc.type=='customer'">Customer:</strong>
<strong t-if="doc.type=='supplier'">Supplier:</strong>
<div t-field="doc.partner_id"
@@ -138,20 +138,20 @@
</div>
</div>
<h2>
<h2 class="mt32">
<span t-field="doc.name"/>
</h2>
<div class="row mt32 mb32" id="informations">
<div t-if="doc.reference" class="col-xs-3">
<div t-if="doc.reference" class="col-3">
<strong>Reference:</strong>
<p t-field="doc.reference"/>
</div>
<div t-if="doc.date_rma" class="col-xs-3">
<div t-if="doc.date_rma" class="col-3">
<strong>Date Ordered:</strong>
<p t-field="doc.date_rma"/>
</div>
<div t-if="doc.requested_by.name" class="col-xs-3">
<div t-if="doc.requested_by.name" class="col-3">
<strong>Contact Person:</strong>
<p t-field="doc.requested_by.name"/>
</div>

0
rma/security/ir.model.access.csv Executable file → Normal file
View File

2
rma/security/rma.xml Executable file → Normal file
View File

@@ -4,7 +4,7 @@
<record model="ir.module.category" id="module_category_rma">
<field name="name">RMA</field>
<field name="parent_id" ref="base.module_category_sales_management"/>
<field name="parent_id" ref="base.module_category_sales"/>
<field name="sequence">30</field>
</record>

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import test_rma

View File

@@ -1,4 +1,4 @@
# © 2017 Eficent Business and IT Consulting Services S.L.
# © 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo.exceptions import ValidationError
@@ -19,33 +19,21 @@ class TestRma(common.SavepointCase):
cls.rma = cls.env["rma.order"]
cls.rma_line = cls.env["rma.order.line"]
cls.rma_op = cls.env["rma.operation"]
cls.product_product_model = cls.env["product.product"]
cls.rma_cust_replace_op_id = cls.env.ref("rma.rma_operation_customer_replace")
cls.rma_sup_replace_op_id = cls.env.ref("rma.rma_operation_supplier_replace")
cls.rma_ds_replace_op_id = cls.env.ref("rma.rma_operation_ds_replace")
cls.product_id = cls.env.ref("product.product_product_4")
cls.product_1 = cls.env.ref("product.product_product_25")
cls.product_2 = cls.env.ref("product.product_product_22")
cls.product_3 = cls.env.ref("product.product_product_20")
cls.category = cls._create_product_category(
"one_step", cls.rma_cust_replace_op_id, cls.rma_sup_replace_op_id
)
cls.product_id = cls._create_product("PT0")
cls.product_1 = cls._create_product("PT1")
cls.product_2 = cls._create_product("PT2")
cls.product_3 = cls._create_product("PT3")
cls.uom_unit = cls.env.ref("uom.product_uom_unit")
# assign an operation
cls.product_1.write(
{
"rma_customer_operation_id": cls.rma_cust_replace_op_id.id,
"rma_supplier_operation_id": cls.rma_sup_replace_op_id.id,
}
)
cls.product_2.write(
{
"rma_customer_operation_id": cls.rma_cust_replace_op_id.id,
"rma_supplier_operation_id": cls.rma_sup_replace_op_id.id,
}
)
cls.product_3.write(
{
"rma_customer_operation_id": cls.rma_cust_replace_op_id.id,
"rma_supplier_operation_id": cls.rma_sup_replace_op_id.id,
}
)
cls.env.user.company_id.group_rma_delivery_address = True
cls.env.user.company_id.group_rma_lines = True
cls.partner_id = cls.env.ref("base.res_partner_2")
cls.stock_location = cls.env.ref("stock.stock_location_stock")
wh = cls.env.ref("stock.warehouse0")
@@ -71,6 +59,25 @@ class TestRma(common.SavepointCase):
products2move, "supplier", cls.env.ref("base.res_partner_2"), dropship=False
)
@classmethod
def _create_product_category(
cls, rma_approval_policy, rma_customer_operation_id, rma_supplier_operation_id
):
return cls.env["product.category"].create(
{
"name": "Test category",
"rma_approval_policy": rma_approval_policy,
"rma_customer_operation_id": rma_customer_operation_id.id,
"rma_supplier_operation_id": rma_supplier_operation_id.id,
}
)
@classmethod
def _create_product(cls, name):
return cls.product_product_model.create(
{"name": name, "categ_id": cls.category.id, "type": "product"}
)
@classmethod
def _create_picking(cls, partner):
return cls.stockpicking.create(
@@ -84,12 +91,12 @@ class TestRma(common.SavepointCase):
@classmethod
def _create_rma_from_move(
cls, products2move, type, partner, dropship, supplier_address_id=None
cls, products2move, r_type, partner, dropship, supplier_address_id=None
):
picking_in = cls._create_picking(partner)
moves = []
if type == "customer":
if r_type == "customer":
for item in products2move:
move_values = cls._prepare_move(
item[0],
@@ -113,26 +120,24 @@ class TestRma(common.SavepointCase):
rma_id = cls.rma.create(
{
"reference": "0001",
"type": type,
"type": r_type,
"partner_id": partner.id,
"company_id": cls.env.ref("base.main_company").id,
}
)
for move in moves:
if type == "customer":
if r_type == "customer":
wizard = cls.rma_add_stock_move.new(
{
"stock_move_id": move.id,
"customer": True,
"active_ids": rma_id.id,
"move_ids": [(4, move.id)],
"rma_id": rma_id.id,
"partner_id": move.partner_id.id,
"active_model": "rma.order",
}
)
wizard.with_context(
{
"stock_move_id": move.id,
"move_ids": [(4, move.id)],
"reference_move_id": move.id,
"customer": True,
"active_ids": rma_id.id,
"partner_id": move.partner_id.id,
@@ -142,45 +147,26 @@ class TestRma(common.SavepointCase):
data = wizard.with_context(
customer=1
)._prepare_rma_line_from_stock_move(move)
wizard.add_lines()
if move.product_id.rma_customer_operation_id:
move.product_id.rma_customer_operation_id.in_route_id = False
move.product_id.categ_id.rma_customer_operation_id = False
move.product_id.rma_customer_operation_id = False
wizard._prepare_rma_line_from_stock_move(move)
else:
wizard = cls.rma_add_stock_move.new(
{
"stock_move_id": move.id,
"supplier": True,
"active_ids": rma_id.id,
"move_ids": [(4, move.id)],
"rma_id": rma_id.id,
"partner_id": move.partner_id.id,
"active_model": "rma.order",
}
)
wizard.with_context(
{
"stock_move_id": move.id,
"supplier": True,
"move_ids": [(4, move.id)],
"reference_move_id": move.id,
"active_ids": rma_id.id,
"partner_id": move.partner_id.id,
"active_model": "rma.order",
}
).default_get([str(move.id), str(cls.partner_id.id)])
data = wizard.with_context(
customer=1
)._prepare_rma_line_from_stock_move(move)
wizard.add_lines()
if move.product_id.rma_customer_operation_id:
move.product_id.rma_customer_operation_id.in_route_id = False
move.product_id.categ_id.rma_supplier_operation_id = False
move.product_id.rma_supplier_operation_id = False
wizard._prepare_rma_line_from_stock_move(move)
data = wizard._prepare_rma_line_from_stock_move(move)
data["type"] = "supplier"
if dropship:
data.update(
customer_to_supplier=dropship,
@@ -188,8 +174,9 @@ class TestRma(common.SavepointCase):
supplier_address_id=supplier_address_id.id,
)
cls.line = cls.rma_line.create(data)
cls.line._onchange_product_id()
cls.line._onchange_operation_id()
cls.line.action_rma_to_approve()
cls.line.action_rma_approve()
rma_id._get_default_type()
rma_id._compute_in_shipment_count()
rma_id._compute_out_shipment_count()
@@ -205,19 +192,40 @@ class TestRma(common.SavepointCase):
@classmethod
def _prepare_move(cls, product, qty, src, dest, picking_in):
res = {
"partner_id": cls.partner_id.id,
location_id = src.id
return {
"name": product.name,
"partner_id": picking_in.partner_id.id,
"origin": picking_in.name,
"company_id": picking_in.picking_type_id.warehouse_id.company_id.id,
"product_id": product.id,
"name": product.partner_ref,
"state": "confirmed",
"product_uom": cls.product_uom_id.id or product.uom_id.id,
"product_uom": product.uom_id.id,
"state": "draft",
"product_uom_qty": qty,
"origin": "Test RMA",
"location_id": src.id,
"location_id": location_id,
"location_dest_id": dest.id,
"move_line_ids": [
(
0,
0,
{
"product_id": product.id,
"product_uom_id": product.uom_id.id,
"qty_done": qty,
"location_id": location_id,
"location_dest_id": dest.id,
"package_id": False,
"owner_id": False,
"lot_id": False,
},
)
],
"picking_id": picking_in.id,
}
return res
def _check_equal_quantity(self, qty1, qty2, msg):
self.assertEquals(qty1, qty2, msg)
def test_01_rma_order_line(self):
for line in self.rma_customer_id.rma_line_ids:
@@ -225,54 +233,35 @@ class TestRma(common.SavepointCase):
{"default_rma_id": line.rma_id.id}
)._default_warehouse_id()
line._default_location_id()
line.with_context(
{"partner_id": line.rma_id.partner_id.id}
)._default_delivery_address()
line._onchange_delivery_address()
line._compute_in_shipment_count()
line._compute_out_shipment_count()
data = {"reference_move_id": line.reference_move_id.id}
new_line = self.rma_line.new(data)
new_line._onchange_reference_move_id()
# check assert if call reference_move_id onchange
self.assertEquals(new_line.product_id, line.reference_move_id.product_id)
self.assertEquals(line.product_id, line.reference_move_id.product_id)
self.assertEquals(line.product_qty, line.reference_move_id.product_uom_qty)
self.assertEquals(
new_line.product_qty, line.reference_move_id.product_uom_qty
line.location_id.location_id, line.reference_move_id.location_id
)
self.assertEquals(line.origin, line.reference_move_id.picking_id.name)
self.assertEquals(
line.delivery_address_id, line.reference_move_id.picking_partner_id
)
self.assertEquals(
new_line.location_id.location_id, line.reference_move_id.location_id
line.qty_to_receive, line.reference_move_id.product_uom_qty
)
self.assertEquals(new_line.origin, line.reference_move_id.picking_id.name)
self.assertEquals(
new_line.delivery_address_id, line.reference_move_id.picking_partner_id
)
self.assertEquals(
new_line.qty_to_receive, line.reference_move_id.product_uom_qty
)
line.action_rma_to_approve()
line.action_rma_draft()
line.action_rma_done()
data = {"product_id": line.product_id.id}
new_line = self.rma_line.new(data)
new_line._onchange_product_id()
data = {"operation_id": line.operation_id.id}
new_line = self.rma_line.new(data)
new_line._onchange_operation_id()
line._onchange_product_id()
line._onchange_operation_id()
# check assert if call operation_id onchange
self.assertEquals(new_line.operation_id.receipt_policy, line.receipt_policy)
self.assertEquals(line.operation_id.receipt_policy, line.receipt_policy)
data = {"customer_to_supplier": line.customer_to_supplier}
new_line = self.rma_line.new(data)
new_line._onchange_receipt_policy()
line = self.rma_line.new(data)
line._onchange_receipt_policy()
data = {"lot_id": line.lot_id.id}
new_line = self.rma_line.new(data)
new_line._onchange_lot_id()
line = self.rma_line.new(data)
line._onchange_lot_id()
line.action_view_in_shipments()
line.action_view_out_shipments()
@@ -285,6 +274,7 @@ class TestRma(common.SavepointCase):
self.rma_customer_id.action_view_supplier_lines()
def test_02_customer_rma(self):
self.rma_customer_id.rma_line_ids.action_rma_to_approve()
wizard = self.rma_make_picking.with_context(
{
"active_ids": self.rma_customer_id.rma_line_ids.ids,
@@ -295,45 +285,104 @@ class TestRma(common.SavepointCase):
).create({})
wizard._create_picking()
res = self.rma_customer_id.rma_line_ids.action_view_in_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
picking = self.env["stock.picking"].browse(res["res_id"])
self.assertEquals(len(picking), 1, "Incorrect number of pickings created")
moves = picking.move_lines
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
for line in self.rma_customer_id.rma_line_ids:
# common qtys for all products
self.assertEquals(line.qty_received, 0, "Wrong qty received")
self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing")
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
lines = self.rma_customer_id.rma_line_ids
self.assertEquals(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty received"
)
self.assertEquals(
list(set(lines.mapped("qty_to_deliver"))), [0], "Wrong qty to deliver"
)
self.assertEquals(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty outgoing"
)
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
)
# product specific
if line.product_id == self.product_1:
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
self.assertEquals(line.qty_incoming, 3, "Wrong qty incoming")
if line.product_id == self.product_2:
self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive")
self.assertEquals(line.qty_incoming, 5, "Wrong qty incoming")
if line.product_id == self.product_3:
self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive")
self.assertEquals(line.qty_incoming, 2, "Wrong qty incoming")
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty to receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_incoming,
3,
"Wrong qty incoming",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive,
5,
"Wrong qty to receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_incoming,
5,
"Wrong qty incoming",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive,
2,
"Wrong qty to receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_incoming,
2,
"Wrong qty incoming",
)
picking.action_assign()
for mv in picking.move_lines:
mv.quantity_done = mv.product_uom_qty
picking.action_done()
for line in self.rma_customer_id.rma_line_ids:
self.assertEquals(line.qty_to_receive, 0, "Wrong qty to_receive")
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing")
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
if line.product_id == self.product_1:
self.assertEquals(line.qty_received, 3, "Wrong qty received")
self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to_deliver")
if line.product_id == self.product_2:
self.assertEquals(line.qty_received, 5, "Wrong qty received")
self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to_deliver")
if line.product_id == self.product_3:
self.assertEquals(line.qty_received, 2, "Wrong qty received")
self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to_deliver")
lines = self.rma_customer_id.rma_line_ids
self.assertEquals(
list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive"
)
self.assertEquals(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming"
)
self.assertEquals(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty outgoing"
)
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
3,
"Wrong qty received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
5,
"Wrong qty received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
2,
"Wrong qty received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty to_deliver",
)
wizard = self.rma_make_picking.with_context(
{
@@ -345,44 +394,100 @@ class TestRma(common.SavepointCase):
).create({})
wizard._create_picking()
res = self.rma_customer_id.rma_line_ids.action_view_out_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
picking = self.env["stock.picking"].browse(res["res_id"])
moves = picking.move_lines
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
for line in self.rma_customer_id.rma_line_ids:
self.assertEquals(line.qty_to_receive, 0, "Wrong qty to receive")
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
if line.product_id == self.product_1:
self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing")
self.assertEquals(line.qty_received, 3, "Wrong qty received")
if line.product_id == self.product_2:
self.assertEquals(line.qty_received, 5, "Wrong qty received")
self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 5, "Wrong qty outgoing")
if line.product_id == self.product_3:
self.assertEquals(line.qty_received, 2, "Wrong qty received")
self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 2, "Wrong qty outgoing")
lines = self.rma_customer_id.rma_line_ids
self.assertEquals(
list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive"
)
self.assertEquals(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming"
)
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_outgoing,
3,
"Wrong qty outgoing",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_outgoing,
5,
"Wrong qty outgoing",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_outgoing,
2,
"Wrong qty outgoing",
)
picking.action_assign()
for mv in picking.move_lines:
mv.quantity_done = mv.product_uom_qty
picking.action_done()
for line in self.rma_customer_id.rma_line_ids:
self.assertEquals(line.qty_to_receive, 0, "Wrong qty to receive")
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing")
if line.product_id == self.product_1:
self.assertEquals(line.qty_received, 3, "Wrong qty received")
self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered")
if line.product_id == self.product_2:
self.assertEquals(line.qty_received, 5, "Wrong qty received")
self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered")
if line.product_id == self.product_3:
self.assertEquals(line.qty_received, 2, "Wrong qty received")
self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered")
lines = self.rma_customer_id.rma_line_ids
self.assertEquals(
list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive"
)
self.assertEquals(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming"
)
self.assertEquals(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
3,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered,
3,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
5,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered,
5,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
2,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered,
2,
"Wrong qty_delivered",
)
self.line.action_rma_done()
self.assertEquals(self.line.state, "done", "Wrong State")
self.rma_customer_id.action_view_in_shipments()
@@ -392,9 +497,11 @@ class TestRma(common.SavepointCase):
# DROPSHIP
def test_03_dropship(self):
for line in self.rma_droship_id.rma_line_ids:
line.operation_id = self.rma_ds_replace_op_id
line._onchange_operation_id()
line._onchange_delivery_address()
line.action_rma_to_approve()
line.action_rma_approve()
line._onchange_operation_id()
wizard = self.rma_make_picking.with_context(
{
"active_id": 1,
@@ -405,7 +512,7 @@ class TestRma(common.SavepointCase):
).create({})
wizard._create_picking()
res = self.rma_droship_id.rma_line_ids.action_view_in_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
picking = self.env["stock.picking"].browse(res["res_id"])
self.assertEquals(len(picking), 1, "Incorrect number of pickings created")
moves = picking.move_lines
@@ -419,96 +526,184 @@ class TestRma(common.SavepointCase):
).create({})
res = wizard.make_supplier_rma()
supplier_rma = self.rma.browse(res["res_id"])
for line in supplier_rma.rma_line_ids:
# common qtys for all products
self.assertEquals(line.qty_received, 0, "Wrong qty received")
self.assertEquals(line.qty_outgoing, 0, "Wrong qty incoming")
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
lines = supplier_rma.rma_line_ids
self.assertEquals(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
)
self.assertEquals(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
)
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered"
)
# product specific
if line.product_id == self.product_1:
self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver")
if line.product_id == self.product_2:
self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to deliver")
if line.product_id == self.product_3:
self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to deliver")
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty_to_deliver",
)
lines = self.rma_droship_id.rma_line_ids
self._check_equal_quantity(
lines.filtered(
lambda l: l.product_id == self.product_1
).qty_in_supplier_rma,
3,
"Wrong qty_in_supplier_rma",
)
self._check_equal_quantity(
lines.filtered(
lambda l: l.product_id == self.product_2
).qty_in_supplier_rma,
5,
"Wrong qty_in_supplier_rma",
)
self._check_equal_quantity(
lines.filtered(
lambda l: l.product_id == self.product_3
).qty_in_supplier_rma,
2,
"Wrong qty_in_supplier_rma",
)
self.assertEquals(
list(set(lines.mapped("qty_to_supplier_rma"))),
[0],
"Wrong qty_to_supplier_rma",
)
for line in self.rma_droship_id.rma_line_ids:
if line.product_id == self.product_1:
self.assertEquals(
line.qty_to_supplier_rma, 0, "Wrong qty to supplier rma"
)
self.assertEquals(
line.qty_in_supplier_rma, 3, "Wrong qty in supplier rma"
)
if line.product_id == self.product_2:
self.assertEquals(
line.qty_to_supplier_rma, 0, "Wrong qty to supplier rma"
)
self.assertEquals(
line.qty_in_supplier_rma, 5, "Wrong qty in supplier rma"
)
if line.product_id == self.product_3:
self.assertEquals(
line.qty_to_supplier_rma, 0, "Wrong qty to supplier rma"
)
self.assertEquals(
line.qty_in_supplier_rma, 2, "Wrong qty in supplier rma"
)
for line in self.rma_droship_id.rma_line_ids:
line.action_rma_done()
self.assertEquals(line.state, "done", "Wrong State")
self.assertEquals(line.mapped("state"), ["done"], "Wrong State")
# Supplier RMA
def test_04_supplier_rma(self):
self.rma_supplier_id.rma_line_ids.action_rma_to_approve()
self.rma_supplier_id.rma_line_ids.operation_id = self.rma_sup_replace_op_id
self.rma_supplier_id.rma_line_ids._onchange_operation_id()
self.rma_supplier_id.rma_line_ids._onchange_delivery_address()
wizard = self.rma_make_picking.with_context(
{
"active_ids": self.rma_supplier_id.rma_line_ids.ids,
"active_model": "rma.order.line",
"picking_type": "outgoing",
"active_id": 1,
"active_id": 2,
}
).create({})
wizard._create_picking()
res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
picking = self.env["stock.picking"].browse(res["res_id"])
moves = picking.move_lines
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
for line in self.rma_supplier_id.rma_line_ids:
# common qtys for all products
self.assertEquals(line.qty_received, 0, "Wrong qty received")
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
# product specific
if line.product_id == self.product_1:
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing")
if line.product_id == self.product_2:
self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive")
self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 5, "Wrong qty outgoing")
if line.product_id == self.product_3:
self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive")
self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 2, "Wrong qty outgoing")
lines = self.rma_supplier_id.rma_line_ids
self.assertEquals(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
)
self.assertEquals(
list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
3,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive,
5,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver,
5,
"Wrong qty_to_deliver",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive,
2,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver,
2,
"Wrong qty_to_deliver",
)
self.assertEquals(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
)
picking.action_assign()
for mv in picking.move_lines:
mv.quantity_done = mv.product_uom_qty
picking.action_done()
for line in self.rma_supplier_id.rma_line_ids:
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
self.assertEquals(line.qty_received, 0, "Wrong qty received")
if line.product_id == self.product_1:
self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered")
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
if line.product_id == self.product_2:
self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered")
self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive")
if line.product_id == self.product_3:
self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered")
self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive")
self.assertEquals(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
)
self.assertEquals(
list(set(lines.mapped("qty_to_deliver"))), [0], "Wrong qty_to_deliver"
)
self.assertEquals(
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
)
self.assertEquals(list(set(lines.mapped("qty_outgoing"))), [0], "qty_outgoing")
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered,
3,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
0,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered,
5,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
0,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered,
2,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
0,
"Wrong qty_received",
)
wizard = self.rma_make_picking.with_context(
{
"active_id": 1,
@@ -519,41 +714,81 @@ class TestRma(common.SavepointCase):
).create({})
wizard._create_picking()
res = self.rma_supplier_id.rma_line_ids.action_view_in_shipments()
self.assertTrue("res_id" in res, "Incorrect number of pickings created")
self.assertTrue("res_id" in res, "Incorrect number of pickings" "created")
pickings = self.env["stock.picking"].browse(res["res_id"])
self.assertEquals(len(pickings), 1, "Incorrect number of pickings created")
picking_out = pickings[0]
moves = picking_out.move_lines
picking_in = pickings[0]
moves = picking_in.move_lines
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
for line in self.rma_supplier_id.rma_line_ids:
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
self.assertEquals(line.qty_received, 0, "Wrong qty received")
self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver")
if line.product_id == self.product_1:
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
if line.product_id == self.product_2:
self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive")
if line.product_id == self.product_3:
self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive")
picking_out.action_assign()
for mv in picking.move_lines:
mv.quantity_done = mv.product_uom_qty
picking_out.action_done()
for line in self.rma_supplier_id.rma_line_ids[0]:
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver")
self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing")
if line.product_id == self.product_1:
self.assertEquals(line.qty_received, 0, "Wrong qty received")
self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered")
if line.product_id == self.product_2:
self.assertEquals(line.qty_received, 0, "Wrong qty received")
self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered")
if line.product_id == self.product_3:
self.assertEquals(line.qty_received, 2, "Wrong qty received")
self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered")
lines = self.rma_supplier_id.rma_line_ids
self.assertEquals(
list(set(lines.mapped("qty_to_deliver"))), [0], "qty_to_deliver"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
3,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive,
5,
"Wrong qty_to_receive",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive,
2,
"Wrong qty_to_receive",
)
picking_in.action_confirm()
picking_in.action_assign()
for mv in picking_in.move_line_ids:
mv.qty_done = mv.product_uom_qty
picking_in.action_done()
self.assertEquals(
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
)
self.assertEquals(
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
)
self.assertEquals(
list(set(lines.mapped("qty_to_deliver"))), [0], "qty_to_deliver"
)
# product specific
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered,
3,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
3,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered,
5,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_2).qty_received,
5,
"Wrong qty_received",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered,
2,
"Wrong qty_delivered",
)
self._check_equal_quantity(
lines.filtered(lambda l: l.product_id == self.product_3).qty_received,
2,
"Wrong qty_received",
)
for line in self.rma_supplier_id.rma_line_ids:
line.action_rma_done()
self.assertEquals(line.state, "done", "Wrong State")
self.assertEquals(line.mapped("state"), ["done"], "Wrong State")

0
rma/views/product_view.xml Executable file → Normal file
View File

2
rma/views/res_partner_view.xml Executable file → Normal file
View File

@@ -11,7 +11,7 @@
name="action_open_partner_rma"
class="oe_stat_button"
icon="fa-eject"
attrs="{'invisible':[('customer', '=', False)]}"
context="{'res_partner_search_mode': 'customer'}"
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
<field name="rma_line_count" widget="statinfo"
string="RMAs"/>

2
rma/views/rma_operation_view.xml Executable file → Normal file
View File

@@ -63,7 +63,6 @@
<record id="action_rma_operation_customer" model="ir.actions.act_window">
<field name="name">Customer Operations</field>
<field name="res_model">rma.operation</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'default_type': "customer"}</field>
<field name="domain">[('type','=', 'customer')]</field>
@@ -73,7 +72,6 @@
<record id="action_rma_operation_supplier" model="ir.actions.act_window">
<field name="name">Supplier Operations</field>
<field name="res_model">rma.operation</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'default_type': "supplier"}</field>
<field name="domain">[('type','=', 'supplier')]</field>

63
rma/views/rma_order_line_view.xml Executable file → Normal file
View File

@@ -97,10 +97,17 @@
invisible="context.get('hide_title',False)"/>
</h1>
</div>
<group>
<group name="partner">
<field name="partner_id"
domain="[('supplier','=',True)]"
context="{'res_partner_search_mode': 'supplier'}"
string="Supplier"/>
<field name="delivery_address_id"
domain="['|', ('parent_id', '=', partner_id),('id', '=', partner_id)]"
context="{'show_address': 1}"
options="{'always_reload': 1}"
groups='rma.group_rma_delivery_invoice_address'/>
</group>
</group>
<group>
<group name="product" string="Product">
@@ -126,21 +133,21 @@
('state', '=', 'done')]"/>
</group>
<group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to"/>
</group>
<group name="operation" string="Operation">
<field name="operation_id"
domain="[('type','=','supplier')]"/>
<field name="receipt_policy"/>
<field name="delivery_policy"/>
</group>
<group name="description" string="Description">
<field name="description" nolabel="1"/>
</group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to"/>
</group>
</group>
<notebook>
<page name="description" string="Description">
<field name="description" nolabel="1"/>
</page>
<page name="route" string="Routes">
<group>
<group name="inbound" string="Inbound">
@@ -151,12 +158,6 @@
</group>
<group name="outbound" string="Outbound">
<field name="out_warehouse_id"/>
<field name="delivery_address_id"
domain="['|', ('parent_id', '=', partner_id),
('id', '=', partner_id)]"
context="{'show_address': 1}"
options="{'always_reload': 1}"
groups='rma.group_rma_delivery_invoice_address'/>
<field name="out_route_id" groups="stock.group_adv_location"/>
<field name="supplier_to_customer"/>
<field name="customer_address_id"
@@ -269,10 +270,14 @@
<group name="partner">
<group name="partner">
<field name="partner_id"
domain="[('customer','=',True)]"
context="{'res_partner_search_mode': 'customer'}"
string="Customer"/>
</group>
<group name="warranty">
<field name="delivery_address_id"
domain="['|', ('parent_id', '=', partner_id),
('id', '=', partner_id)]"
context="{'show_address': 1}"
options="{'always_reload': 1}"
groups='rma.group_rma_delivery_invoice_address'/>
<field name="under_warranty"/>
</group>
</group>
@@ -299,20 +304,22 @@
('state', '=', 'done')]"/>
</group>
<group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to"/>
</group>
<group name="operation" string="Operation">
<field name="operation_id" domain="[('type','=','customer')]"/>
<field name="receipt_policy"/>
<field name="delivery_policy"/>
</group>
<group name="description" string="Description">
<field name="description" nolabel="1"/>
</group>
</group>
<group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to"/>
</group>
</group>
<notebook>
<page name="description" string="Description">
<field name="description" nolabel="1"/>
</page>
<page name="route" string="Routes">
<group name="inbound" string="Inbound">
<field name="in_warehouse_id"/>
@@ -328,12 +335,6 @@
</group>
<group name="outbound" string="Outbound">
<field name="out_warehouse_id"/>
<field name="delivery_address_id"
domain="['|', ('parent_id', '=', partner_id),
('id', '=', partner_id)]"
context="{'show_address': 1}"
options="{'always_reload': 1}"
groups='rma.group_rma_delivery_invoice_address'/>
<field name="out_route_id" groups="stock.group_adv_location"/>
</group>
</page>
@@ -425,7 +426,6 @@
<field name="res_model">rma.order.line</field>
<field name="domain">[('type','=', 'customer')]</field>
<field name="context">{"search_default_assigned_to":uid}</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_rma_line_tree"/>
</record>
@@ -435,7 +435,6 @@
<field name="res_model">rma.order.line</field>
<field name="domain">[('type','=', 'supplier')]</field>
<field name="context">{"search_default_assigned_to":uid, "supplier":1}</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_rma_line_supplier_tree"/>
</record>

71
rma/views/rma_order_view.xml Executable file → Normal file
View File

@@ -67,26 +67,24 @@
</div>
<div class="oe_title" name="title">
<h1>
<field name="name"/>
<field name="name" readonly="1"/>
</h1>
</div>
<group name="partner">
<group>
<group name="info">
<field name="partner_id"
domain="[('customer','=',True)]"
context="{'res_partner_search_mode': 'customer'}"
string="Customer"
colspan="4"
/>
</group>
<group name="info">
<group>
<field name="reference"/>
<field name="date_rma" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
</group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
<group name="comments">
<field name="comment"/>
<field name="type" readonly="1" invisible="1"/>
</group>
</group>
<group>
<group name="inbound_route" string="Inbound">
<field name="in_warehouse_id" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
<field name="customer_to_supplier" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
@@ -98,6 +96,15 @@
'invisible':[('customer_to_supplier', '=', False)],
'readonly':[('state', '!=', 'draft')]}"/>
</group>
</group>
<group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
<field name="company_id"
groups="base.group_multi_company"/>
</group>
</group>
<notebook colspan="4">
<page string="RMA Lines" name="lines">
<field name="rma_line_ids" context="{'default_rma_id': active_id,
@@ -116,16 +123,6 @@
</tree>
</field>
</page>
<page name="other_info" string="Other Info">
<group name="company">
<field name="company_id"
groups="base.group_multi_company"/>
</group>
<group name="comments">
<field name="comment"/>
<field name="type" readonly="1"/>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
@@ -168,24 +165,22 @@
</div>
<div class="oe_title" name="title">
<h1>
<field name="name"/>
<field name="name" readonly="1"/>
</h1>
</div>
<group>
<group name="partner">
<field name="state" invisible="1"/>
<field name="partner_id"
domain="[('supplier','=',True)]"
context="{'res_partner_search_mode': 'supplier'}"
string="Supplier"
attrs="{'readonly':[('state', '!=', 'draft')]}"/>
</group>
<group>
<group col="4">
<field name="reference"/>
<field name="date_rma" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
</group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
<group>
<field name="comment"/>
<field name="type" readonly="1" invisible="1"/>
</group>
</group>
<group name="route">
@@ -202,6 +197,14 @@
'readonly':[('state', '!=', 'draft')]}"/>
</group>
</group>
<group>
<group name="contact" string="Contact">
<field name="requested_by" readonly="1"/>
<field name="assigned_to" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
<field name="company_id"
groups="base.group_multi_company"/>
</group>
</group>
<notebook colspan="4">
<page string="RMA Lines" name="lines">
<field name="rma_line_ids"
@@ -224,16 +227,6 @@
</tree>
</field>
</page>
<page name="other_info" string="Other Info">
<group name="company">
<field name="company_id"
groups="base.group_multi_company"/>
</group>
<group name="comments">
<field name="comment"/>
<field name="type" readonly="1"/>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
@@ -266,7 +259,6 @@
<record id="action_rma_customer" model="ir.actions.act_window">
<field name="name">Customer RMA Group</field>
<field name="res_model">rma.order</field>
<field name="view_type">form</field>
<field name="domain">[('type','=', 'customer')]</field>
<field name="context">{'customer':1}</field>
<field name="view_mode">tree,form</field>
@@ -276,7 +268,6 @@
<record id="action_rma_supplier" model="ir.actions.act_window">
<field name="name">Supplier RMA Group</field>
<field name="res_model">rma.order</field>
<field name="view_type">form</field>
<field name="domain">[('type','=', 'supplier')]</field>
<field name="context">{'supplier':1}</field>
<field name="view_mode">tree,form</field>

13
rma/views/stock_view.xml Executable file → Normal file
View File

@@ -13,19 +13,6 @@
</field>
</record>
<record id="view_move_picking_form" model="ir.ui.view" >
<field name="name">stock.move.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_picking_form" />
<field name="arch" type="xml">
<xpath expr="//group[1]" position="inside">
<group name="rma" colspan="4">
<field name="rma_line_id"/>
</group>
</xpath>
</field>
</record>
<record id="stock_location_route_form_view_inherit_rma_stock" model="ir.ui.view">
<field name="name">stock.location.route.form</field>
<field name="inherit_id" ref="stock.stock_location_route_form_view"/>

0
rma/views/stock_warehouse.xml Executable file → Normal file
View File

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import rma_add_stock_move

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import _, api, fields, models
@@ -106,7 +106,6 @@ class RmaAddStockMove(models.TransientModel):
existing_move_lines.append(rma_line.reference_move_id)
return existing_move_lines
@api.multi
def add_lines(self):
rma_line_obj = self.env["rma.order.line"]
existing_stock_moves = self._get_existing_stock_moves()

5
rma/wizards/rma_add_stock_move_view.xml Executable file → Normal file
View File

@@ -18,7 +18,6 @@
<field name="product_id"/>
<field name="product_uom_qty"/>
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom"/>
<field name="product_packaging" domain="[('product_id','=',product_id)]" groups="product.group_stock_packaging"/>
<field name="picking_id"/>
<field name="location_id" groups="stock.group_stock_multi_locations"/>
<field name="location_dest_id" groups="stock.group_stock_multi_locations"/>
@@ -46,8 +45,6 @@
<field name="name">Add from Stock Move</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rma_add_stock_move</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_stock_move_customer"/>
@@ -100,8 +97,6 @@
<field name="name">Add from Stock Move</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rma_add_stock_move</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_stock_move_supplier"/>

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
import time
@@ -7,8 +7,6 @@ from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT
import odoo.addons.decimal_precision as dp
class RmaMakePicking(models.TransientModel):
_name = "rma_make_picking.wizard"
@@ -95,10 +93,10 @@ class RmaMakePicking(models.TransientModel):
return delivery_address
@api.model
def _get_address_location(self, delivery_address_id, type):
if type == "supplier":
def _get_address_location(self, delivery_address_id, a_type):
if a_type == "supplier":
return delivery_address_id.property_stock_supplier
elif type == "customer":
elif a_type == "customer":
return delivery_address_id.property_stock_customer
@api.model
@@ -150,27 +148,33 @@ class RmaMakePicking(models.TransientModel):
else:
qty = item.qty_to_deliver
values = self._get_procurement_data(item, group, qty, picking_type)
values = dict(values, rma_line_id=item.line_id, rma_id=item.line_id.rma_id)
# create picking
procurements = []
try:
self.env["procurement.group"].run(
procurement = group.Procurement(
item.line_id.product_id,
qty,
item.line_id.product_id.product_tmpl_id.uom_id,
values.get("location_id"),
values.get("origin"),
values.get("origin"),
self.env.company,
values,
)
procurements.append(procurement)
self.env["procurement.group"].run(procurements)
except UserError as error:
errors.append(error.name)
if errors:
raise UserError("\n".join(errors))
return values.get("origin")
return procurements
@api.multi
def _create_picking(self):
"""Method called when the user clicks on create picking"""
picking_type = self.env.context.get("picking_type")
procurements = []
for item in self.item_ids:
line = item.line_id
if line.state != "approved":
@@ -180,43 +184,18 @@ class RmaMakePicking(models.TransientModel):
if line.delivery_policy == "no" and picking_type == "outgoing":
raise ValidationError(_("No deliveries needed for this operation"))
procurement = self._create_procurement(item, picking_type)
return procurement
procurements.extend(procurement)
return procurements
@api.model
def _get_action(self, pickings, procurements):
if pickings and procurements:
action = procurements.do_view_pickings()
else:
action = self.env.ref("procurement.procurement_order_action_exceptions")
action = action.read()[0]
if procurements:
# choose the view_mode accordingly
if len(procurements.ids) <= 1:
res = self.env.ref("procurement.procurement_form_view", False)
action["views"] = [(res and res.id or False, "form")]
action["res_id"] = procurements.ids[0]
else:
action["domain"] = [("id", "in", procurements.ids)]
return action
@api.multi
def action_create_picking(self):
procurement = self._create_picking()
action = self.env.ref("stock.do_view_pickings")
action = action.read()[0]
if procurement:
pickings = (
self.env["stock.picking"].search([("origin", "=", procurement)]).ids
)
if len(pickings) > 1:
action["domain"] = [("id", "in", pickings)]
self._create_picking()
picking_type = self.env.context.get("picking_type")
if picking_type == "outgoing":
action = self.item_ids.line_id.action_view_out_shipments()
else:
form = self.env.ref("stock.view_picking_form", False)
action["views"] = [(form and form.id or False, "form")]
action["res_id"] = pickings and pickings[0]
action = self.item_ids.line_id.action_view_in_shipments()
return action
@api.multi
def action_cancel(self):
return {"type": "ir.actions.act_window_close"}
@@ -237,13 +216,13 @@ class RmaMakePickingItem(models.TransientModel):
related="line_id.product_qty",
string="Quantity Ordered",
copy=False,
digits=dp.get_precision("Product Unit of Measure"),
digits="Product Unit of Measure",
readonly=True,
)
qty_to_receive = fields.Float(
string="Quantity to Receive", digits=dp.get_precision("Product Unit of Measure")
string="Quantity to Receive", digits="Product Unit of Measure"
)
qty_to_deliver = fields.Float(
string="Quantity To Deliver", digits=dp.get_precision("Product Unit of Measure")
string="Quantity To Deliver", digits="Product Unit of Measure"
)
uom_id = fields.Many2one("uom.uom", string="Unit of Measure", readonly=True)

2
rma/wizards/rma_make_picking_view.xml Executable file → Normal file
View File

@@ -61,7 +61,6 @@
<field name="name">Create Incoming Shipment</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rma_make_picking.wizard</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_picking"/>
@@ -74,7 +73,6 @@
<field name="name">Create Delivery</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rma_make_picking.wizard</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_picking_out"/>

View File

@@ -1,11 +1,9 @@
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
import odoo.addons.decimal_precision as dp
class RmaLineMakeSupplierRma(models.TransientModel):
_name = "rma.order.line.make.supplier.rma"
@@ -86,7 +84,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
raise ValidationError(_("Enter a supplier."))
return {
"partner_id": self.partner_id.id,
"delivery_address_id": self.partner_id.id,
"type": "supplier",
"company_id": company.id,
}
@@ -121,6 +118,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
"origin": item.line_id.rma_id.name,
"customer_address_id": item.line_id.delivery_address_id.id
or item.line_id.partner_id.id,
"delivery_address_id": self.partner_id.id,
"product_id": item.line_id.product_id.id,
"customer_rma_id": item.line_id.id,
"product_qty": item.product_qty,
@@ -142,7 +140,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
}
return data
@api.multi
def make_supplier_rma(self):
self = self.with_context(supplier=True, customer=False)
rma_obj = self.env["rma.order"]
@@ -165,7 +162,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
if rma:
return {
"name": _("Supplier RMA"),
"view_type": "form",
"view_mode": "form",
"res_model": "rma.order",
"view_id": False,
@@ -176,7 +172,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
else:
return {
"name": _("Supplier RMA Line"),
"view_type": "form",
"view_mode": "form",
"res_model": "rma.order.line",
"view_id": False,
@@ -208,9 +203,7 @@ class RmaLineMakeRmaOrderItem(models.TransientModel):
)
name = fields.Char(related="line_id.name", readonly=True)
uom_id = fields.Many2one("uom.uom", string="UoM", readonly=True)
product_qty = fields.Float(
string="Quantity", digits=dp.get_precision("Product UoS")
)
product_qty = fields.Float(string="Quantity", digits="Product UoS")
operation_id = fields.Many2one(
comodel_name="rma.operation",
string="Operation",

3
rma/wizards/rma_order_line_make_supplier_rma_view.xml Executable file → Normal file
View File

@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!-- Copyright 2016 Eficent Business and IT Consulting Services S.L.
<!-- Copyright 2016 ForgeFlow
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record id="view_rma_order_line_make_supplier_rma"
@@ -53,7 +53,6 @@
<field name="name">Create Supplier RMA</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">rma.order.line.make.supplier.rma</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_rma_order_line_make_supplier_rma"/>
<field name="target">new</field>

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L.
# Copyright (C) 2017 ForgeFlow
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models
@@ -7,25 +7,14 @@ from odoo import fields, models
class StockConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
group_rma_delivery_address = fields.Selection(
[
(
0,
"Invoicing and shipping addresses are always the same "
"(Example: services companies)",
),
(
1,
"Display 3 fields on rma: partner, invoice address, delivery "
"address",
),
],
"Addresses",
group_rma_delivery_address = fields.Boolean(
related="company_id.group_rma_delivery_address",
implied_group="rma.group_rma_delivery_invoice_address",
readonly=False,
)
group_rma_lines = fields.Selection(
[(0, "Do not group RMA lines"), (1, "Group RMA lines in one RMA group")],
"Grouping",
group_rma_lines = fields.Boolean(
related="company_id.group_rma_lines",
readonly=False,
implied_group="rma.group_rma_groups",
)

24
rma/wizards/stock_config_settings.xml Executable file → Normal file
View File

@@ -8,13 +8,25 @@
<div id="production_lot_info" position="after">
<h2>Return Merchandise Authorization</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-12 o_setting_box">
<div class="o_setting_right_pane">
<div class="content-group">
<div class="mt16">
<field name="group_rma_delivery_address" class="o_light_label" widget="radio"/>
<field name="group_rma_lines" widget="radio"/>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_rma_delivery_address"/>
</div>
<div class="o_setting_right_pane">
<label for="group_rma_delivery_address"/>
<div class="text-muted">
Display 3 fields on rma: partner, invoice address, delivery address.
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_rma_lines"/>
</div>
<div class="o_setting_right_pane">
<label for="group_rma_lines"/>
<div class="text-muted">
Group RMA lines in one RMA group.
</div>
</div>
</div>