mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG] rma: Migration to 13.0
This commit is contained in:
committed by
AaronHForgeFlow
parent
c4c1a4ea1a
commit
db6a348e40
@@ -100,7 +100,7 @@ Bug Tracker
|
|||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues
|
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,
|
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.
|
help us smashing it by providing a detailed and welcomed feedback.
|
||||||
|
|
||||||
@@ -111,9 +111,9 @@ Credits
|
|||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
* Jordi Ballester Alomar <jordi.ballester@ForgeFlow.com>
|
||||||
* Aaron Henriquez <ahenriquez@eficent.com>
|
* Aaron Henriquez <ahenriquez@ForgeFlow.com>
|
||||||
* Lois Rilo <lois.rilo@eficent.com>
|
* Lois Rilo <lois.rilo@ForgeFlow.com>
|
||||||
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||||
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
||||||
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
|
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
|
||||||
@@ -122,4 +122,4 @@ Contributors
|
|||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
||||||
This module is maintained by Eficent.
|
This module is maintained by ForgeFlow.
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "RMA (Return Merchandise Authorization)",
|
"name": "RMA (Return Merchandise Authorization)",
|
||||||
"version": "12.0.2.3.0",
|
"version": "13.0.1.0.0",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"category": "RMA",
|
"category": "RMA",
|
||||||
"summary": "Introduces the return merchandise authorization (RMA) process "
|
"summary": "Introduces the return merchandise authorization (RMA) process "
|
||||||
"in odoo",
|
"in odoo",
|
||||||
"author": "Eficent, Odoo Community Association (OCA)",
|
"author": "ForgeFlow",
|
||||||
"website": "https://github.com/Eficent/stock-rma",
|
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||||
"depends": ["stock", "mail", "web"],
|
"depends": ["stock", "mail", "web"],
|
||||||
"demo": ["demo/stock_demo.xml"],
|
"demo": ["demo/stock_demo.xml"],
|
||||||
"data": [
|
"data": [
|
||||||
@@ -33,5 +33,4 @@
|
|||||||
"wizards/rma_order_line_make_supplier_rma_view.xml",
|
"wizards/rma_order_line_make_supplier_rma_view.xml",
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"auto_install": False,
|
|
||||||
}
|
}
|
||||||
|
|||||||
0
rma/data/rma_operation.xml
Executable file → Normal file
0
rma/data/rma_operation.xml
Executable file → Normal file
0
rma/data/rma_sequence.xml
Executable file → Normal file
0
rma/data/rma_sequence.xml
Executable file → Normal file
9
rma/data/stock_data.xml
Executable file → Normal file
9
rma/data/stock_data.xml
Executable file → Normal file
@@ -44,6 +44,7 @@
|
|||||||
<record id="picking_type_rma_cust_out" model="stock.picking.type">
|
<record id="picking_type_rma_cust_out" model="stock.picking.type">
|
||||||
<field name="name">RMA → Customer</field>
|
<field name="name">RMA → Customer</field>
|
||||||
<field name="sequence_id" ref="seq_picking_type_rma_cust_out"/>
|
<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_src_id" ref="rma.location_rma"/>
|
||||||
<field name="default_location_dest_id"
|
<field name="default_location_dest_id"
|
||||||
ref="stock.stock_location_customers"/>
|
ref="stock.stock_location_customers"/>
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
<record id="picking_type_rma_cust_in" model="stock.picking.type">
|
<record id="picking_type_rma_cust_in" model="stock.picking.type">
|
||||||
<field name="name">Customer → RMA</field>
|
<field name="name">Customer → RMA</field>
|
||||||
<field name="sequence_id" ref="seq_picking_type_rma_cust_in"/>
|
<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_src_id" ref="stock.stock_location_customers"/>
|
||||||
<field name="default_location_dest_id"
|
<field name="default_location_dest_id"
|
||||||
ref="rma.location_rma"/>
|
ref="rma.location_rma"/>
|
||||||
@@ -64,6 +66,7 @@
|
|||||||
<record id="picking_type_rma_sup_out" model="stock.picking.type">
|
<record id="picking_type_rma_sup_out" model="stock.picking.type">
|
||||||
<field name="name">RMA -> Supplier</field>
|
<field name="name">RMA -> Supplier</field>
|
||||||
<field name="sequence_id" ref="seq_picking_type_rma_sup_out"/>
|
<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_src_id" ref="rma.location_rma"/>
|
||||||
<field name="default_location_dest_id"
|
<field name="default_location_dest_id"
|
||||||
ref="stock.stock_location_suppliers"/>
|
ref="stock.stock_location_suppliers"/>
|
||||||
@@ -74,6 +77,7 @@
|
|||||||
<record id="picking_type_rma_sup_in" model="stock.picking.type">
|
<record id="picking_type_rma_sup_in" model="stock.picking.type">
|
||||||
<field name="name">Supplier -> RMA</field>
|
<field name="name">Supplier -> RMA</field>
|
||||||
<field name="sequence_id" ref="seq_picking_type_rma_sup_in"/>
|
<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_src_id" ref="stock.stock_location_suppliers"/>
|
||||||
<field name="default_location_dest_id"
|
<field name="default_location_dest_id"
|
||||||
ref="rma.location_rma"/>
|
ref="rma.location_rma"/>
|
||||||
@@ -84,6 +88,7 @@
|
|||||||
<record id="picking_type_rma_dropship_return" model="stock.picking.type">
|
<record id="picking_type_rma_dropship_return" model="stock.picking.type">
|
||||||
<field name="name">Customer -> Supplier</field>
|
<field name="name">Customer -> Supplier</field>
|
||||||
<field name="sequence_id" ref="seq_picking_type_rma_dropship"/>
|
<field name="sequence_id" ref="seq_picking_type_rma_dropship"/>
|
||||||
|
<field name="sequence_code">Customer -> Supplier</field>
|
||||||
<field name="default_location_src_id"
|
<field name="default_location_src_id"
|
||||||
ref="stock.stock_location_customers"/>
|
ref="stock.stock_location_customers"/>
|
||||||
<field name="default_location_dest_id"
|
<field name="default_location_dest_id"
|
||||||
@@ -95,6 +100,7 @@
|
|||||||
<record id="picking_type_rma_dropship" model="stock.picking.type">
|
<record id="picking_type_rma_dropship" model="stock.picking.type">
|
||||||
<field name="name">Supplier -> Customer</field>
|
<field name="name">Supplier -> Customer</field>
|
||||||
<field name="sequence_id" ref="seq_picking_type_rma_dropship"/>
|
<field name="sequence_id" ref="seq_picking_type_rma_dropship"/>
|
||||||
|
<field name="sequence_code">Supplier -> Customer</field>
|
||||||
<field name="default_location_src_id"
|
<field name="default_location_src_id"
|
||||||
ref="stock.stock_location_suppliers"/>
|
ref="stock.stock_location_suppliers"/>
|
||||||
<field name="default_location_dest_id"
|
<field name="default_location_dest_id"
|
||||||
@@ -115,7 +121,6 @@
|
|||||||
<field name="name">RMA Customer</field>
|
<field name="name">RMA Customer</field>
|
||||||
<field name="company_id" eval="0"/>
|
<field name="company_id" eval="0"/>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="sale_selectable" eval="False"/>
|
|
||||||
<field name="product_selectable" eval="False"/>
|
<field name="product_selectable" eval="False"/>
|
||||||
<field name="product_categ_selectable" eval="False"/>
|
<field name="product_categ_selectable" eval="False"/>
|
||||||
<field name="warehouse_selectable" eval="False"/>
|
<field name="warehouse_selectable" eval="False"/>
|
||||||
@@ -126,7 +131,6 @@
|
|||||||
<field name="name">RMA Supplier</field>
|
<field name="name">RMA Supplier</field>
|
||||||
<field name="company_id" eval="0"/>
|
<field name="company_id" eval="0"/>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="sale_selectable" eval="False"/>
|
|
||||||
<field name="product_selectable" eval="False"/>
|
<field name="product_selectable" eval="False"/>
|
||||||
<field name="product_categ_selectable" eval="False"/>
|
<field name="product_categ_selectable" eval="False"/>
|
||||||
<field name="warehouse_selectable" eval="False"/>
|
<field name="warehouse_selectable" eval="False"/>
|
||||||
@@ -137,7 +141,6 @@
|
|||||||
<field name="name">RMA Dropship</field>
|
<field name="name">RMA Dropship</field>
|
||||||
<field name="company_id" eval="0"/>
|
<field name="company_id" eval="0"/>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="sale_selectable" eval="False"/>
|
|
||||||
<field name="product_selectable" eval="False"/>
|
<field name="product_selectable" eval="False"/>
|
||||||
<field name="product_categ_selectable" eval="False"/>
|
<field name="product_categ_selectable" eval="False"/>
|
||||||
<field name="warehouse_selectable" eval="False"/>
|
<field name="warehouse_selectable" eval="False"/>
|
||||||
|
|||||||
3
rma/demo/stock_demo.xml
Executable file → Normal file
3
rma/demo/stock_demo.xml
Executable file → Normal file
@@ -64,7 +64,6 @@
|
|||||||
<record id="route_rma_customer" model="stock.location.route">
|
<record id="route_rma_customer" model="stock.location.route">
|
||||||
<field name="name">RMA Customer</field>
|
<field name="name">RMA Customer</field>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="sale_selectable" eval="False"/>
|
|
||||||
<field name="product_selectable" eval="False"/>
|
<field name="product_selectable" eval="False"/>
|
||||||
<field name="product_categ_selectable" eval="False"/>
|
<field name="product_categ_selectable" eval="False"/>
|
||||||
<field name="warehouse_selectable" eval="False"/>
|
<field name="warehouse_selectable" eval="False"/>
|
||||||
@@ -74,7 +73,6 @@
|
|||||||
<record id="route_rma_supplier" model="stock.location.route">
|
<record id="route_rma_supplier" model="stock.location.route">
|
||||||
<field name="name">RMA Supplier</field>
|
<field name="name">RMA Supplier</field>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="sale_selectable" eval="False"/>
|
|
||||||
<field name="product_selectable" eval="False"/>
|
<field name="product_selectable" eval="False"/>
|
||||||
<field name="product_categ_selectable" eval="False"/>
|
<field name="product_categ_selectable" eval="False"/>
|
||||||
<field name="warehouse_selectable" eval="False"/>
|
<field name="warehouse_selectable" eval="False"/>
|
||||||
@@ -84,7 +82,6 @@
|
|||||||
<record id="route_rma_dropship" model="stock.location.route">
|
<record id="route_rma_dropship" model="stock.location.route">
|
||||||
<field name="name">RMA Dropship</field>
|
<field name="name">RMA Dropship</field>
|
||||||
<field name="sequence">10</field>
|
<field name="sequence">10</field>
|
||||||
<field name="sale_selectable" eval="False"/>
|
|
||||||
<field name="product_selectable" eval="False"/>
|
<field name="product_selectable" eval="False"/>
|
||||||
<field name="product_categ_selectable" eval="False"/>
|
<field name="product_categ_selectable" eval="False"/>
|
||||||
<field name="warehouse_selectable" eval="False"/>
|
<field name="warehouse_selectable" eval="False"/>
|
||||||
|
|||||||
@@ -9,3 +9,4 @@ from . import product
|
|||||||
from . import product_category
|
from . import product_category
|
||||||
from . import procurement
|
from . import procurement
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
|
from . import res_company
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import fields, models
|
||||||
@@ -7,10 +7,6 @@ from odoo import fields, models
|
|||||||
class StockRule(models.Model):
|
class StockRule(models.Model):
|
||||||
_inherit = "stock.rule"
|
_inherit = "stock.rule"
|
||||||
|
|
||||||
rma_line_id = fields.Many2one(
|
|
||||||
comodel_name="rma.order.line", string="RMA line", ondelete="set null"
|
|
||||||
)
|
|
||||||
|
|
||||||
def _get_stock_move_values(
|
def _get_stock_move_values(
|
||||||
self,
|
self,
|
||||||
product_id,
|
product_id,
|
||||||
@@ -19,8 +15,8 @@ class StockRule(models.Model):
|
|||||||
location_id,
|
location_id,
|
||||||
name,
|
name,
|
||||||
origin,
|
origin,
|
||||||
|
company_id,
|
||||||
values,
|
values,
|
||||||
group_id,
|
|
||||||
):
|
):
|
||||||
res = super(StockRule, self)._get_stock_move_values(
|
res = super(StockRule, self)._get_stock_move_values(
|
||||||
product_id,
|
product_id,
|
||||||
@@ -29,11 +25,11 @@ class StockRule(models.Model):
|
|||||||
location_id,
|
location_id,
|
||||||
name,
|
name,
|
||||||
origin,
|
origin,
|
||||||
|
company_id,
|
||||||
values,
|
values,
|
||||||
group_id,
|
|
||||||
)
|
)
|
||||||
if "rma_line_id" in values:
|
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
|
res["rma_line_id"] = line.id
|
||||||
if line.delivery_address_id:
|
if line.delivery_address_id:
|
||||||
res["partner_id"] = line.delivery_address_id.id
|
res["partner_id"] = line.delivery_address_id.id
|
||||||
|
|||||||
@@ -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)
|
# 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 2017 ForgeFlow
|
||||||
# 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
|
||||||
|
|||||||
14
rma/models/res_company.py
Normal file
14
rma/models/res_company.py
Normal 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"
|
||||||
|
)
|
||||||
@@ -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).
|
# 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):
|
class ResPartner(models.Model):
|
||||||
_inherit = "res.partner"
|
_inherit = "res.partner"
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_rma_line_count(self):
|
def _compute_rma_line_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.rma_line_count = len(rec.rma_line_ids)
|
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")
|
rma_line_count = fields.Integer(compute="_compute_rma_line_count")
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_open_partner_rma(self):
|
def action_open_partner_rma(self):
|
||||||
action = self.env.ref("rma.action_rma_customer_lines")
|
action = self.env.ref("rma.action_rma_customer_lines")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
|
|||||||
@@ -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)
|
# 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,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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -18,10 +18,12 @@ class RmaOrder(models.Model):
|
|||||||
return "supplier"
|
return "supplier"
|
||||||
return "customer"
|
return "customer"
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_in_shipment_count(self):
|
def _compute_in_shipment_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
picking_ids = []
|
picking_ids = []
|
||||||
|
if not rec.rma_line_ids:
|
||||||
|
rec.in_shipment_count = 0
|
||||||
|
continue
|
||||||
for line in rec.rma_line_ids:
|
for line in rec.rma_line_ids:
|
||||||
for move in line.move_ids:
|
for move in line.move_ids:
|
||||||
if move.location_dest_id.usage == "internal":
|
if move.location_dest_id.usage == "internal":
|
||||||
@@ -30,33 +32,32 @@ class RmaOrder(models.Model):
|
|||||||
if line.customer_to_supplier:
|
if line.customer_to_supplier:
|
||||||
picking_ids.append(move.picking_id.id)
|
picking_ids.append(move.picking_id.id)
|
||||||
shipments = list(set(picking_ids))
|
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):
|
def _compute_out_shipment_count(self):
|
||||||
picking_ids = []
|
picking_ids = []
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
if not rec.rma_line_ids:
|
||||||
|
rec.out_shipment_count = 0
|
||||||
|
continue
|
||||||
for line in rec.rma_line_ids:
|
for line in rec.rma_line_ids:
|
||||||
for move in line.move_ids:
|
for move in line.move_ids:
|
||||||
if move.location_dest_id.usage in ("supplier", "customer"):
|
if move.location_dest_id.usage in ("supplier", "customer"):
|
||||||
if not line.customer_to_supplier:
|
if not line.customer_to_supplier:
|
||||||
picking_ids.append(move.picking_id.id)
|
picking_ids.append(move.picking_id.id)
|
||||||
shipments = list(set(picking_ids))
|
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):
|
def _compute_supplier_line_count(self):
|
||||||
self.supplier_line_count = len(
|
self.supplier_line_count = len(
|
||||||
self.rma_line_ids.filtered(lambda r: r.supplier_rma_line_ids)
|
self.rma_line_ids.filtered(lambda r: r.supplier_rma_line_ids)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_line_count(self):
|
def _compute_line_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.line_count = len(rec._get_valid_lines())
|
rec.line_count = len(rec._get_valid_lines())
|
||||||
|
|
||||||
@api.depends("rma_line_ids", "rma_line_ids.state")
|
@api.depends("rma_line_ids", "rma_line_ids.state")
|
||||||
@api.multi
|
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rma_line_done = self.env["rma.order.line"].search_count(
|
rma_line_done = self.env["rma.order.line"].search_count(
|
||||||
@@ -114,9 +115,7 @@ class RmaOrder(models.Model):
|
|||||||
out_shipment_count = fields.Integer(
|
out_shipment_count = fields.Integer(
|
||||||
compute="_compute_out_shipment_count", string="# of Outgoing Shipments"
|
compute="_compute_out_shipment_count", string="# of Outgoing Shipments"
|
||||||
)
|
)
|
||||||
line_count = fields.Integer(
|
line_count = fields.Integer(compute="_compute_line_count", string="# of RMA lines")
|
||||||
compute="_compute_line_count", string="# of Outgoing Shipments"
|
|
||||||
)
|
|
||||||
supplier_line_count = fields.Integer(
|
supplier_line_count = fields.Integer(
|
||||||
compute="_compute_supplier_line_count", string="# of Supplier RMAs"
|
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")
|
vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.customer")
|
||||||
return super(RmaOrder, self).create(vals)
|
return super(RmaOrder, self).create(vals)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_in_shipments(self):
|
def action_view_in_shipments(self):
|
||||||
action = self.env.ref("stock.action_picking_tree_all")
|
action = self.env.ref("stock.action_picking_tree_all")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
@@ -207,7 +205,6 @@ class RmaOrder(models.Model):
|
|||||||
result["res_id"] = shipments[0]
|
result["res_id"] = shipments[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_out_shipments(self):
|
def action_view_out_shipments(self):
|
||||||
action = self.env.ref("stock.action_picking_tree_all")
|
action = self.env.ref("stock.action_picking_tree_all")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
@@ -228,14 +225,12 @@ class RmaOrder(models.Model):
|
|||||||
result["res_id"] = shipments[0]
|
result["res_id"] = shipments[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _get_valid_lines(self):
|
def _get_valid_lines(self):
|
||||||
""":return: A recordset of rma lines.
|
""":return: A recordset of rma lines.
|
||||||
"""
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return self.rma_line_ids
|
return self.rma_line_ids
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_lines(self):
|
def action_view_lines(self):
|
||||||
if self.type == "customer":
|
if self.type == "customer":
|
||||||
action = self.env.ref("rma.action_rma_customer_lines")
|
action = self.env.ref("rma.action_rma_customer_lines")
|
||||||
@@ -254,7 +249,6 @@ class RmaOrder(models.Model):
|
|||||||
result["context"] = {}
|
result["context"] = {}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_supplier_lines(self):
|
def action_view_supplier_lines(self):
|
||||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
import operator
|
import operator
|
||||||
@@ -6,8 +6,6 @@ import operator
|
|||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
|
|
||||||
from odoo.addons import decimal_precision as dp
|
|
||||||
|
|
||||||
ops = {"=": operator.eq, "!=": operator.ne}
|
ops = {"=": operator.eq, "!=": operator.ne}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,16 +36,12 @@ class RmaOrderLine(models.Model):
|
|||||||
wh = self._default_warehouse_id()
|
wh = self._default_warehouse_id()
|
||||||
return wh.lot_rma_id
|
return wh.lot_rma_id
|
||||||
|
|
||||||
@api.model
|
@api.onchange("partner_id")
|
||||||
def _default_delivery_address(self):
|
def _onchange_delivery_address(self):
|
||||||
partner_id = self.env.context.get("partner_id", False)
|
self.delivery_address_id = self.env["res.partner"].browse(
|
||||||
if partner_id:
|
self.partner_id.address_get(["delivery"])["delivery"]
|
||||||
partner = self.env["res.partner"].browse(partner_id)
|
)
|
||||||
addr = partner.address_get(["delivery"])
|
|
||||||
return self.env["res.partner"].browse(addr["delivery"])
|
|
||||||
return False
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_in_shipment_count(self):
|
def _compute_in_shipment_count(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
picking_ids = []
|
picking_ids = []
|
||||||
@@ -60,7 +54,6 @@ class RmaOrderLine(models.Model):
|
|||||||
shipments = list(set(picking_ids))
|
shipments = list(set(picking_ids))
|
||||||
line.in_shipment_count = len(shipments)
|
line.in_shipment_count = len(shipments)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_out_shipment_count(self):
|
def _compute_out_shipment_count(self):
|
||||||
picking_ids = []
|
picking_ids = []
|
||||||
for line in self:
|
for line in self:
|
||||||
@@ -71,7 +64,6 @@ class RmaOrderLine(models.Model):
|
|||||||
shipments = list(set(picking_ids))
|
shipments = list(set(picking_ids))
|
||||||
line.out_shipment_count = len(shipments)
|
line.out_shipment_count = len(shipments)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _get_rma_move_qty(self, states, direction="in"):
|
def _get_rma_move_qty(self, states, direction="in"):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
product_obj = self.env["uom.uom"]
|
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)
|
qty += product_obj._compute_quantity(move.product_uom_qty, rec.uom_id)
|
||||||
return qty
|
return qty
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"move_ids",
|
"move_ids",
|
||||||
"move_ids.state",
|
"move_ids.state",
|
||||||
@@ -103,7 +94,6 @@ class RmaOrderLine(models.Model):
|
|||||||
elif rec.receipt_policy == "delivered":
|
elif rec.receipt_policy == "delivered":
|
||||||
rec.qty_to_receive = rec.qty_delivered - rec.qty_received
|
rec.qty_to_receive = rec.qty_delivered - rec.qty_received
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"move_ids",
|
"move_ids",
|
||||||
"move_ids.state",
|
"move_ids.state",
|
||||||
@@ -121,7 +111,6 @@ class RmaOrderLine(models.Model):
|
|||||||
elif rec.delivery_policy == "received":
|
elif rec.delivery_policy == "received":
|
||||||
rec.qty_to_deliver = rec.qty_received - rec.qty_delivered
|
rec.qty_to_deliver = rec.qty_received - rec.qty_delivered
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends("move_ids", "move_ids.state", "type")
|
@api.depends("move_ids", "move_ids.state", "type")
|
||||||
def _compute_qty_incoming(self):
|
def _compute_qty_incoming(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -130,14 +119,12 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
rec.qty_incoming = qty
|
rec.qty_incoming = qty
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends("move_ids", "move_ids.state", "type")
|
@api.depends("move_ids", "move_ids.state", "type")
|
||||||
def _compute_qty_received(self):
|
def _compute_qty_received(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
qty = rec._get_rma_move_qty("done", direction="in")
|
qty = rec._get_rma_move_qty("done", direction="in")
|
||||||
rec.qty_received = qty
|
rec.qty_received = qty
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends("move_ids", "move_ids.state", "type")
|
@api.depends("move_ids", "move_ids.state", "type")
|
||||||
def _compute_qty_outgoing(self):
|
def _compute_qty_outgoing(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -146,7 +133,6 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
rec.qty_outgoing = qty
|
rec.qty_outgoing = qty
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends("move_ids", "move_ids.state", "type")
|
@api.depends("move_ids", "move_ids.state", "type")
|
||||||
def _compute_qty_delivered(self):
|
def _compute_qty_delivered(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -161,7 +147,6 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"customer_to_supplier",
|
"customer_to_supplier",
|
||||||
"supplier_rma_line_ids",
|
"supplier_rma_line_ids",
|
||||||
@@ -182,7 +167,6 @@ class RmaOrderLine(models.Model):
|
|||||||
rec.qty_to_supplier_rma = 0.0
|
rec.qty_to_supplier_rma = 0.0
|
||||||
rec.qty_in_supplier_rma = 0.0
|
rec.qty_in_supplier_rma = 0.0
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_rma_line_count(self):
|
def _compute_rma_line_count(self):
|
||||||
for rec in self.filtered(lambda r: r.type == "customer"):
|
for rec in self.filtered(lambda r: r.type == "customer"):
|
||||||
rec.rma_line_count = len(rec.supplier_rma_line_ids)
|
rec.rma_line_count = len(rec.supplier_rma_line_ids)
|
||||||
@@ -192,7 +176,6 @@ class RmaOrderLine(models.Model):
|
|||||||
delivery_address_id = fields.Many2one(
|
delivery_address_id = fields.Many2one(
|
||||||
comodel_name="res.partner",
|
comodel_name="res.partner",
|
||||||
string="Partner delivery address",
|
string="Partner delivery address",
|
||||||
default=lambda self: self._default_delivery_address(),
|
|
||||||
readonly=True,
|
readonly=True,
|
||||||
states={"draft": [("readonly", False)]},
|
states={"draft": [("readonly", False)]},
|
||||||
help="This address will be used to deliver repaired or replacement "
|
help="This address will be used to deliver repaired or replacement "
|
||||||
@@ -279,7 +262,7 @@ class RmaOrderLine(models.Model):
|
|||||||
string="Return Qty",
|
string="Return Qty",
|
||||||
copy=False,
|
copy=False,
|
||||||
default=1.0,
|
default=1.0,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
states={"draft": [("readonly", False)]},
|
states={"draft": [("readonly", False)]},
|
||||||
)
|
)
|
||||||
@@ -309,7 +292,11 @@ class RmaOrderLine(models.Model):
|
|||||||
readonly=True,
|
readonly=True,
|
||||||
states={"draft": [("readonly", False)]},
|
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(
|
company_id = fields.Many2one(
|
||||||
comodel_name="res.company",
|
comodel_name="res.company",
|
||||||
string="Company",
|
string="Company",
|
||||||
@@ -420,7 +407,7 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
qty_to_receive = fields.Float(
|
qty_to_receive = fields.Float(
|
||||||
string="Qty To Receive",
|
string="Qty To Receive",
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
compute="_compute_qty_to_receive",
|
compute="_compute_qty_to_receive",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
@@ -428,21 +415,21 @@ class RmaOrderLine(models.Model):
|
|||||||
string="Incoming Qty",
|
string="Incoming Qty",
|
||||||
copy=False,
|
copy=False,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
compute="_compute_qty_incoming",
|
compute="_compute_qty_incoming",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
qty_received = fields.Float(
|
qty_received = fields.Float(
|
||||||
string="Qty Received",
|
string="Qty Received",
|
||||||
copy=False,
|
copy=False,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
compute="_compute_qty_received",
|
compute="_compute_qty_received",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
qty_to_deliver = fields.Float(
|
qty_to_deliver = fields.Float(
|
||||||
string="Qty To Deliver",
|
string="Qty To Deliver",
|
||||||
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_deliver",
|
compute="_compute_qty_to_deliver",
|
||||||
store=True,
|
store=True,
|
||||||
@@ -451,28 +438,28 @@ class RmaOrderLine(models.Model):
|
|||||||
string="Outgoing Qty",
|
string="Outgoing Qty",
|
||||||
copy=False,
|
copy=False,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
compute="_compute_qty_outgoing",
|
compute="_compute_qty_outgoing",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
qty_delivered = fields.Float(
|
qty_delivered = fields.Float(
|
||||||
string="Qty Delivered",
|
string="Qty Delivered",
|
||||||
copy=False,
|
copy=False,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
compute="_compute_qty_delivered",
|
compute="_compute_qty_delivered",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
qty_to_supplier_rma = fields.Float(
|
qty_to_supplier_rma = fields.Float(
|
||||||
string="Qty to send to Supplier RMA",
|
string="Qty to send to Supplier RMA",
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
compute="_compute_qty_supplier_rma",
|
compute="_compute_qty_supplier_rma",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
qty_in_supplier_rma = fields.Float(
|
qty_in_supplier_rma = fields.Float(
|
||||||
string="Qty in Supplier RMA",
|
string="Qty in Supplier RMA",
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
compute="_compute_qty_supplier_rma",
|
compute="_compute_qty_supplier_rma",
|
||||||
store=True,
|
store=True,
|
||||||
@@ -481,7 +468,6 @@ class RmaOrderLine(models.Model):
|
|||||||
string="Under Warranty?", readonly=True, states={"draft": [("readonly", False)]}
|
string="Under Warranty?", readonly=True, states={"draft": [("readonly", False)]}
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
||||||
if not self.type:
|
if not self.type:
|
||||||
self.type = self._get_default_type()
|
self.type = self._get_default_type()
|
||||||
@@ -542,7 +528,6 @@ class RmaOrderLine(models.Model):
|
|||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.onchange("reference_move_id")
|
@api.onchange("reference_move_id")
|
||||||
def _onchange_reference_move_id(self):
|
def _onchange_reference_move_id(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
@@ -562,7 +547,6 @@ class RmaOrderLine(models.Model):
|
|||||||
self.update(data)
|
self.update(data)
|
||||||
self._remove_other_data_origin("reference_move_id")
|
self._remove_other_data_origin("reference_move_id")
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("reference_move_id", "partner_id")
|
@api.constrains("reference_move_id", "partner_id")
|
||||||
def _check_move_partner(self):
|
def _check_move_partner(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -577,13 +561,11 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _remove_other_data_origin(self, exception):
|
def _remove_other_data_origin(self, exception):
|
||||||
if not exception == "reference_move_id":
|
if not exception == "reference_move_id":
|
||||||
self.reference_move_id = False
|
self.reference_move_id = False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_to_approve(self):
|
def action_rma_to_approve(self):
|
||||||
self.write({"state": "to_approve"})
|
self.write({"state": "to_approve"})
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -591,19 +573,16 @@ class RmaOrderLine(models.Model):
|
|||||||
rec.action_rma_approve()
|
rec.action_rma_approve()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_draft(self):
|
def action_rma_draft(self):
|
||||||
if self.in_shipment_count or self.out_shipment_count:
|
if self.in_shipment_count or self.out_shipment_count:
|
||||||
raise UserError(_("You cannot reset to draft a RMA with related pickings."))
|
raise UserError(_("You cannot reset to draft a RMA with related pickings."))
|
||||||
self.write({"state": "draft"})
|
self.write({"state": "draft"})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_approve(self):
|
def action_rma_approve(self):
|
||||||
self.write({"state": "approved"})
|
self.write({"state": "approved"})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_rma_done(self):
|
def action_rma_done(self):
|
||||||
self.write({"state": "done"})
|
self.write({"state": "done"})
|
||||||
return True
|
return True
|
||||||
@@ -676,7 +655,6 @@ class RmaOrderLine(models.Model):
|
|||||||
self.product_id = product
|
self.product_id = product
|
||||||
self.uom_id = product.uom_id
|
self.uom_id = product.uom_id
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_in_shipments(self):
|
def action_view_in_shipments(self):
|
||||||
action = self.env.ref("stock.action_picking_tree_all")
|
action = self.env.ref("stock.action_picking_tree_all")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
@@ -699,7 +677,6 @@ class RmaOrderLine(models.Model):
|
|||||||
result["res_id"] = shipments[0]
|
result["res_id"] = shipments[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_out_shipments(self):
|
def action_view_out_shipments(self):
|
||||||
action = self.env.ref("stock.action_picking_tree_all")
|
action = self.env.ref("stock.action_picking_tree_all")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
@@ -719,7 +696,6 @@ class RmaOrderLine(models.Model):
|
|||||||
result["res_id"] = shipments[0]
|
result["res_id"] = shipments[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_rma_lines(self):
|
def action_view_rma_lines(self):
|
||||||
if self.type == "customer":
|
if self.type == "customer":
|
||||||
# from customer we link to supplier rma
|
# from customer we link to supplier rma
|
||||||
|
|||||||
@@ -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)
|
# 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
|
||||||
@@ -7,7 +7,6 @@ from odoo import api, fields, models
|
|||||||
class StockPicking(models.Model):
|
class StockPicking(models.Model):
|
||||||
_inherit = "stock.picking"
|
_inherit = "stock.picking"
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_assign(self):
|
def action_assign(self):
|
||||||
"""When you try to bring back a product from a customer location,
|
"""When you try to bring back a product from a customer location,
|
||||||
it may happen that there is no quants available to perform the
|
it may happen that there is no quants available to perform the
|
||||||
|
|||||||
@@ -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)
|
# 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):
|
class StockWarehouse(models.Model):
|
||||||
@@ -41,7 +41,6 @@ class StockWarehouse(models.Model):
|
|||||||
comodel_name="stock.rule", string="RMA Supplier Out Rule"
|
comodel_name="stock.rule", string="RMA Supplier Out Rule"
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _get_rma_types(self):
|
def _get_rma_types(self):
|
||||||
return [
|
return [
|
||||||
self.rma_cust_out_type_id,
|
self.rma_cust_out_type_id,
|
||||||
@@ -50,16 +49,14 @@ class StockWarehouse(models.Model):
|
|||||||
self.rma_sup_in_type_id,
|
self.rma_sup_in_type_id,
|
||||||
]
|
]
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _rma_types_available(self):
|
def _rma_types_available(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
rma_types = self._get_rma_types()
|
rma_types = self._get_rma_types()
|
||||||
for type in rma_types:
|
for r_type in rma_types:
|
||||||
if not type:
|
if not r_type:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if "rma_in_this_wh" in vals:
|
if "rma_in_this_wh" in vals:
|
||||||
if vals.get("rma_in_this_wh"):
|
if vals.get("rma_in_this_wh"):
|
||||||
@@ -78,16 +75,16 @@ class StockWarehouse(models.Model):
|
|||||||
if not wh._rma_types_available():
|
if not wh._rma_types_available():
|
||||||
wh._create_rma_picking_types()
|
wh._create_rma_picking_types()
|
||||||
else:
|
else:
|
||||||
for type in wh._get_rma_types():
|
for r_type in wh._get_rma_types():
|
||||||
if type:
|
if r_type:
|
||||||
type.active = True
|
r_type.active = True
|
||||||
# RMA rules:
|
# RMA rules:
|
||||||
wh._create_or_update_rma_pull()
|
wh._create_or_update_rma_pull()
|
||||||
else:
|
else:
|
||||||
for wh in self:
|
for wh in self:
|
||||||
for type in wh._get_rma_types():
|
for r_type in wh._get_rma_types():
|
||||||
if type:
|
if r_type:
|
||||||
type.active = False
|
r_type.active = False
|
||||||
# Unlink rules:
|
# Unlink rules:
|
||||||
self.mapped("rma_customer_in_pull_id").unlink()
|
self.mapped("rma_customer_in_pull_id").unlink()
|
||||||
self.mapped("rma_customer_out_pull_id").unlink()
|
self.mapped("rma_customer_out_pull_id").unlink()
|
||||||
@@ -174,7 +171,6 @@ class StockWarehouse(models.Model):
|
|||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def get_rma_rules_dict(self):
|
def get_rma_rules_dict(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
rma_rules = dict()
|
rma_rules = dict()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="oe_structure"/>
|
<div class="oe_structure"/>
|
||||||
<div class="row">
|
<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')">
|
<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>
|
<strong>Shipping address:</strong>
|
||||||
<div class="mt8">
|
<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>
|
<p t-if="doc.customer_address_id.vat">VAT: <span t-field="doc.customer_address_id.vat"/></p>
|
||||||
</div>
|
</div>
|
||||||
</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=='customer'">Customer:</strong>
|
||||||
<strong t-if="doc.type=='supplier'">Supplier:</strong>
|
<strong t-if="doc.type=='supplier'">Supplier:</strong>
|
||||||
<div t-field="doc.partner_id"
|
<div t-field="doc.partner_id"
|
||||||
@@ -36,24 +36,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>
|
<h2 class="mt32">
|
||||||
<span t-field="doc.name"/>
|
<span t-field="doc.name"/>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class="row mt32 mb32" id="informations">
|
<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>
|
<strong>Origin Reference:</strong>
|
||||||
<p t-field="doc.origin"/>
|
<p t-field="doc.origin"/>
|
||||||
</div>
|
</div>
|
||||||
<div t-if="doc.create_date" class="col-xs-3">
|
<div t-if="doc.create_date" class="col-3">
|
||||||
<strong>Date Ordered:</strong>
|
<strong>Date Ordered:</strong>
|
||||||
<p t-field="doc.create_date"/>
|
<p t-field="doc.create_date"/>
|
||||||
</div>
|
</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>
|
<strong>Contact Person:</strong>
|
||||||
<p t-field="doc.requested_by.name"/>
|
<p t-field="doc.requested_by.name"/>
|
||||||
</div>
|
</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>
|
<strong>Operation:</strong>
|
||||||
<p t-field="doc.operation_id.name"/>
|
<p t-field="doc.operation_id.name"/>
|
||||||
</div>
|
</div>
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="oe_structure"/>
|
<div class="oe_structure"/>
|
||||||
<div class="row">
|
<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')">
|
<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>
|
<strong>Shipping address:</strong>
|
||||||
<div class="mt8">
|
<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>
|
<p t-if="doc.customer_address_id.vat">VAT: <span t-field="doc.customer_address_id.vat"/></p>
|
||||||
</div>
|
</div>
|
||||||
</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=='customer'">Customer:</strong>
|
||||||
<strong t-if="doc.type=='supplier'">Supplier:</strong>
|
<strong t-if="doc.type=='supplier'">Supplier:</strong>
|
||||||
<div t-field="doc.partner_id"
|
<div t-field="doc.partner_id"
|
||||||
@@ -138,20 +138,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>
|
<h2 class="mt32">
|
||||||
<span t-field="doc.name"/>
|
<span t-field="doc.name"/>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class="row mt32 mb32" id="informations">
|
<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>
|
<strong>Reference:</strong>
|
||||||
<p t-field="doc.reference"/>
|
<p t-field="doc.reference"/>
|
||||||
</div>
|
</div>
|
||||||
<div t-if="doc.date_rma" class="col-xs-3">
|
<div t-if="doc.date_rma" class="col-3">
|
||||||
<strong>Date Ordered:</strong>
|
<strong>Date Ordered:</strong>
|
||||||
<p t-field="doc.date_rma"/>
|
<p t-field="doc.date_rma"/>
|
||||||
</div>
|
</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>
|
<strong>Contact Person:</strong>
|
||||||
<p t-field="doc.requested_by.name"/>
|
<p t-field="doc.requested_by.name"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
0
rma/security/ir.model.access.csv
Executable file → Normal file
0
rma/security/ir.model.access.csv
Executable file → Normal file
2
rma/security/rma.xml
Executable file → Normal file
2
rma/security/rma.xml
Executable file → Normal file
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<record model="ir.module.category" id="module_category_rma">
|
<record model="ir.module.category" id="module_category_rma">
|
||||||
<field name="name">RMA</field>
|
<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>
|
<field name="sequence">30</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from . import test_rma
|
from . import test_rma
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
@@ -19,33 +19,21 @@ class TestRma(common.SavepointCase):
|
|||||||
cls.rma = cls.env["rma.order"]
|
cls.rma = cls.env["rma.order"]
|
||||||
cls.rma_line = cls.env["rma.order.line"]
|
cls.rma_line = cls.env["rma.order.line"]
|
||||||
cls.rma_op = cls.env["rma.operation"]
|
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_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_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.rma_ds_replace_op_id = cls.env.ref("rma.rma_operation_ds_replace")
|
||||||
cls.product_id = cls.env.ref("product.product_product_4")
|
cls.category = cls._create_product_category(
|
||||||
cls.product_1 = cls.env.ref("product.product_product_25")
|
"one_step", cls.rma_cust_replace_op_id, cls.rma_sup_replace_op_id
|
||||||
cls.product_2 = cls.env.ref("product.product_product_22")
|
)
|
||||||
cls.product_3 = cls.env.ref("product.product_product_20")
|
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")
|
cls.uom_unit = cls.env.ref("uom.product_uom_unit")
|
||||||
# assign an operation
|
cls.env.user.company_id.group_rma_delivery_address = True
|
||||||
cls.product_1.write(
|
cls.env.user.company_id.group_rma_lines = True
|
||||||
{
|
|
||||||
"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.partner_id = cls.env.ref("base.res_partner_2")
|
cls.partner_id = cls.env.ref("base.res_partner_2")
|
||||||
cls.stock_location = cls.env.ref("stock.stock_location_stock")
|
cls.stock_location = cls.env.ref("stock.stock_location_stock")
|
||||||
wh = cls.env.ref("stock.warehouse0")
|
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
|
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
|
@classmethod
|
||||||
def _create_picking(cls, partner):
|
def _create_picking(cls, partner):
|
||||||
return cls.stockpicking.create(
|
return cls.stockpicking.create(
|
||||||
@@ -84,12 +91,12 @@ class TestRma(common.SavepointCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _create_rma_from_move(
|
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)
|
picking_in = cls._create_picking(partner)
|
||||||
|
|
||||||
moves = []
|
moves = []
|
||||||
if type == "customer":
|
if r_type == "customer":
|
||||||
for item in products2move:
|
for item in products2move:
|
||||||
move_values = cls._prepare_move(
|
move_values = cls._prepare_move(
|
||||||
item[0],
|
item[0],
|
||||||
@@ -113,26 +120,24 @@ class TestRma(common.SavepointCase):
|
|||||||
rma_id = cls.rma.create(
|
rma_id = cls.rma.create(
|
||||||
{
|
{
|
||||||
"reference": "0001",
|
"reference": "0001",
|
||||||
"type": type,
|
"type": r_type,
|
||||||
"partner_id": partner.id,
|
"partner_id": partner.id,
|
||||||
"company_id": cls.env.ref("base.main_company").id,
|
"company_id": cls.env.ref("base.main_company").id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
for move in moves:
|
for move in moves:
|
||||||
if type == "customer":
|
if r_type == "customer":
|
||||||
wizard = cls.rma_add_stock_move.new(
|
wizard = cls.rma_add_stock_move.new(
|
||||||
{
|
{
|
||||||
"stock_move_id": move.id,
|
"move_ids": [(4, move.id)],
|
||||||
"customer": True,
|
|
||||||
"active_ids": rma_id.id,
|
|
||||||
"rma_id": rma_id.id,
|
"rma_id": rma_id.id,
|
||||||
"partner_id": move.partner_id.id,
|
"partner_id": move.partner_id.id,
|
||||||
"active_model": "rma.order",
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
{
|
{
|
||||||
"stock_move_id": move.id,
|
"move_ids": [(4, move.id)],
|
||||||
|
"reference_move_id": move.id,
|
||||||
"customer": True,
|
"customer": True,
|
||||||
"active_ids": rma_id.id,
|
"active_ids": rma_id.id,
|
||||||
"partner_id": move.partner_id.id,
|
"partner_id": move.partner_id.id,
|
||||||
@@ -142,45 +147,26 @@ class TestRma(common.SavepointCase):
|
|||||||
data = wizard.with_context(
|
data = wizard.with_context(
|
||||||
customer=1
|
customer=1
|
||||||
)._prepare_rma_line_from_stock_move(move)
|
)._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:
|
else:
|
||||||
wizard = cls.rma_add_stock_move.new(
|
wizard = cls.rma_add_stock_move.new(
|
||||||
{
|
{
|
||||||
"stock_move_id": move.id,
|
"move_ids": [(4, move.id)],
|
||||||
"supplier": True,
|
|
||||||
"active_ids": rma_id.id,
|
|
||||||
"rma_id": rma_id.id,
|
"rma_id": rma_id.id,
|
||||||
"partner_id": move.partner_id.id,
|
"partner_id": move.partner_id.id,
|
||||||
"active_model": "rma.order",
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
wizard.with_context(
|
wizard.with_context(
|
||||||
{
|
{
|
||||||
"stock_move_id": move.id,
|
"move_ids": [(4, move.id)],
|
||||||
"supplier": True,
|
"reference_move_id": move.id,
|
||||||
"active_ids": rma_id.id,
|
"active_ids": rma_id.id,
|
||||||
"partner_id": move.partner_id.id,
|
"partner_id": move.partner_id.id,
|
||||||
"active_model": "rma.order",
|
"active_model": "rma.order",
|
||||||
}
|
}
|
||||||
).default_get([str(move.id), str(cls.partner_id.id)])
|
).default_get([str(move.id), str(cls.partner_id.id)])
|
||||||
data = wizard.with_context(
|
data = wizard._prepare_rma_line_from_stock_move(move)
|
||||||
customer=1
|
data["type"] = "supplier"
|
||||||
)._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)
|
|
||||||
|
|
||||||
if dropship:
|
if dropship:
|
||||||
data.update(
|
data.update(
|
||||||
customer_to_supplier=dropship,
|
customer_to_supplier=dropship,
|
||||||
@@ -188,8 +174,9 @@ class TestRma(common.SavepointCase):
|
|||||||
supplier_address_id=supplier_address_id.id,
|
supplier_address_id=supplier_address_id.id,
|
||||||
)
|
)
|
||||||
cls.line = cls.rma_line.create(data)
|
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_to_approve()
|
||||||
cls.line.action_rma_approve()
|
|
||||||
rma_id._get_default_type()
|
rma_id._get_default_type()
|
||||||
rma_id._compute_in_shipment_count()
|
rma_id._compute_in_shipment_count()
|
||||||
rma_id._compute_out_shipment_count()
|
rma_id._compute_out_shipment_count()
|
||||||
@@ -205,19 +192,40 @@ class TestRma(common.SavepointCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _prepare_move(cls, product, qty, src, dest, picking_in):
|
def _prepare_move(cls, product, qty, src, dest, picking_in):
|
||||||
res = {
|
location_id = src.id
|
||||||
"partner_id": cls.partner_id.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,
|
"product_id": product.id,
|
||||||
"name": product.partner_ref,
|
"product_uom": product.uom_id.id,
|
||||||
"state": "confirmed",
|
"state": "draft",
|
||||||
"product_uom": cls.product_uom_id.id or product.uom_id.id,
|
|
||||||
"product_uom_qty": qty,
|
"product_uom_qty": qty,
|
||||||
"origin": "Test RMA",
|
"location_id": location_id,
|
||||||
"location_id": src.id,
|
|
||||||
"location_dest_id": dest.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,
|
"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):
|
def test_01_rma_order_line(self):
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
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_rma_id": line.rma_id.id}
|
||||||
)._default_warehouse_id()
|
)._default_warehouse_id()
|
||||||
line._default_location_id()
|
line._default_location_id()
|
||||||
line.with_context(
|
line._onchange_delivery_address()
|
||||||
{"partner_id": line.rma_id.partner_id.id}
|
|
||||||
)._default_delivery_address()
|
|
||||||
line._compute_in_shipment_count()
|
line._compute_in_shipment_count()
|
||||||
line._compute_out_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
|
# 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(
|
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(
|
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)
|
line._onchange_product_id()
|
||||||
self.assertEquals(
|
line._onchange_operation_id()
|
||||||
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()
|
|
||||||
|
|
||||||
# check assert if call operation_id onchange
|
# 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}
|
data = {"customer_to_supplier": line.customer_to_supplier}
|
||||||
new_line = self.rma_line.new(data)
|
line = self.rma_line.new(data)
|
||||||
new_line._onchange_receipt_policy()
|
line._onchange_receipt_policy()
|
||||||
|
|
||||||
data = {"lot_id": line.lot_id.id}
|
data = {"lot_id": line.lot_id.id}
|
||||||
new_line = self.rma_line.new(data)
|
line = self.rma_line.new(data)
|
||||||
new_line._onchange_lot_id()
|
line._onchange_lot_id()
|
||||||
|
|
||||||
line.action_view_in_shipments()
|
line.action_view_in_shipments()
|
||||||
line.action_view_out_shipments()
|
line.action_view_out_shipments()
|
||||||
@@ -285,6 +274,7 @@ class TestRma(common.SavepointCase):
|
|||||||
self.rma_customer_id.action_view_supplier_lines()
|
self.rma_customer_id.action_view_supplier_lines()
|
||||||
|
|
||||||
def test_02_customer_rma(self):
|
def test_02_customer_rma(self):
|
||||||
|
self.rma_customer_id.rma_line_ids.action_rma_to_approve()
|
||||||
wizard = self.rma_make_picking.with_context(
|
wizard = self.rma_make_picking.with_context(
|
||||||
{
|
{
|
||||||
"active_ids": self.rma_customer_id.rma_line_ids.ids,
|
"active_ids": self.rma_customer_id.rma_line_ids.ids,
|
||||||
@@ -295,45 +285,104 @@ class TestRma(common.SavepointCase):
|
|||||||
).create({})
|
).create({})
|
||||||
wizard._create_picking()
|
wizard._create_picking()
|
||||||
res = self.rma_customer_id.rma_line_ids.action_view_in_shipments()
|
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"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
self.assertEquals(len(picking), 1, "Incorrect number of pickings created")
|
self.assertEquals(len(picking), 1, "Incorrect number of pickings created")
|
||||||
moves = picking.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
|
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
# common qtys for all products
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_received, 0, "Wrong qty received")
|
list(set(lines.mapped("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(
|
||||||
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
|
list(set(lines.mapped("qty_to_deliver"))), [0], "Wrong qty to deliver"
|
||||||
# product specific
|
)
|
||||||
if line.product_id == self.product_1:
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
|
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty outgoing"
|
||||||
self.assertEquals(line.qty_incoming, 3, "Wrong qty incoming")
|
)
|
||||||
if line.product_id == self.product_2:
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive")
|
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
|
||||||
self.assertEquals(line.qty_incoming, 5, "Wrong qty incoming")
|
)
|
||||||
if line.product_id == self.product_3:
|
# product specific
|
||||||
self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive")
|
self._check_equal_quantity(
|
||||||
self.assertEquals(line.qty_incoming, 2, "Wrong qty incoming")
|
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()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_lines:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking.action_done()
|
picking.action_done()
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
self.assertEquals(line.qty_to_receive, 0, "Wrong qty to_receive")
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
|
list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive"
|
||||||
self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing")
|
)
|
||||||
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
|
self.assertEquals(
|
||||||
if line.product_id == self.product_1:
|
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming"
|
||||||
self.assertEquals(line.qty_received, 3, "Wrong qty received")
|
)
|
||||||
self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to_deliver")
|
self.assertEquals(
|
||||||
if line.product_id == self.product_2:
|
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty outgoing"
|
||||||
self.assertEquals(line.qty_received, 5, "Wrong qty received")
|
)
|
||||||
self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to_deliver")
|
self.assertEquals(
|
||||||
if line.product_id == self.product_3:
|
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
|
||||||
self.assertEquals(line.qty_received, 2, "Wrong qty received")
|
)
|
||||||
self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to_deliver")
|
# 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(
|
wizard = self.rma_make_picking.with_context(
|
||||||
{
|
{
|
||||||
@@ -345,46 +394,102 @@ class TestRma(common.SavepointCase):
|
|||||||
).create({})
|
).create({})
|
||||||
wizard._create_picking()
|
wizard._create_picking()
|
||||||
res = self.rma_customer_id.rma_line_ids.action_view_out_shipments()
|
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"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
moves = picking.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
|
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
self.assertEquals(line.qty_to_receive, 0, "Wrong qty to receive")
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
|
list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive"
|
||||||
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
|
)
|
||||||
if line.product_id == self.product_1:
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver")
|
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming"
|
||||||
self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing")
|
)
|
||||||
self.assertEquals(line.qty_received, 3, "Wrong qty received")
|
self.assertEquals(
|
||||||
if line.product_id == self.product_2:
|
list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered"
|
||||||
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")
|
# product specific
|
||||||
if line.product_id == self.product_3:
|
self._check_equal_quantity(
|
||||||
self.assertEquals(line.qty_received, 2, "Wrong qty received")
|
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver,
|
||||||
self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to deliver")
|
3,
|
||||||
self.assertEquals(line.qty_outgoing, 2, "Wrong qty outgoing")
|
"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()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_lines:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking.action_done()
|
picking.action_done()
|
||||||
for line in self.rma_customer_id.rma_line_ids:
|
lines = self.rma_customer_id.rma_line_ids
|
||||||
self.assertEquals(line.qty_to_receive, 0, "Wrong qty to receive")
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
|
list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive"
|
||||||
self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver")
|
)
|
||||||
self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing")
|
self.assertEquals(
|
||||||
if line.product_id == self.product_1:
|
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming"
|
||||||
self.assertEquals(line.qty_received, 3, "Wrong qty received")
|
)
|
||||||
self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered")
|
self.assertEquals(
|
||||||
if line.product_id == self.product_2:
|
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
|
||||||
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:
|
# product specific
|
||||||
self.assertEquals(line.qty_received, 2, "Wrong qty received")
|
self._check_equal_quantity(
|
||||||
self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered")
|
lines.filtered(lambda l: l.product_id == self.product_1).qty_received,
|
||||||
self.line.action_rma_done()
|
3,
|
||||||
self.assertEquals(self.line.state, "done", "Wrong State")
|
"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()
|
self.rma_customer_id.action_view_in_shipments()
|
||||||
self.rma_customer_id.action_view_out_shipments()
|
self.rma_customer_id.action_view_out_shipments()
|
||||||
self.rma_customer_id.action_view_lines()
|
self.rma_customer_id.action_view_lines()
|
||||||
@@ -392,9 +497,11 @@ class TestRma(common.SavepointCase):
|
|||||||
# DROPSHIP
|
# DROPSHIP
|
||||||
def test_03_dropship(self):
|
def test_03_dropship(self):
|
||||||
for line in self.rma_droship_id.rma_line_ids:
|
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_to_approve()
|
||||||
line.action_rma_approve()
|
line.action_rma_approve()
|
||||||
line._onchange_operation_id()
|
|
||||||
wizard = self.rma_make_picking.with_context(
|
wizard = self.rma_make_picking.with_context(
|
||||||
{
|
{
|
||||||
"active_id": 1,
|
"active_id": 1,
|
||||||
@@ -405,7 +512,7 @@ class TestRma(common.SavepointCase):
|
|||||||
).create({})
|
).create({})
|
||||||
wizard._create_picking()
|
wizard._create_picking()
|
||||||
res = self.rma_droship_id.rma_line_ids.action_view_in_shipments()
|
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"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
self.assertEquals(len(picking), 1, "Incorrect number of pickings created")
|
self.assertEquals(len(picking), 1, "Incorrect number of pickings created")
|
||||||
moves = picking.move_lines
|
moves = picking.move_lines
|
||||||
@@ -419,96 +526,184 @@ class TestRma(common.SavepointCase):
|
|||||||
).create({})
|
).create({})
|
||||||
res = wizard.make_supplier_rma()
|
res = wizard.make_supplier_rma()
|
||||||
supplier_rma = self.rma.browse(res["res_id"])
|
supplier_rma = self.rma.browse(res["res_id"])
|
||||||
for line in supplier_rma.rma_line_ids:
|
lines = supplier_rma.rma_line_ids
|
||||||
# common qtys for all products
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_received, 0, "Wrong qty received")
|
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
|
||||||
self.assertEquals(line.qty_outgoing, 0, "Wrong qty incoming")
|
)
|
||||||
self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered")
|
self.assertEquals(
|
||||||
# product specific
|
list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing"
|
||||||
if line.product_id == self.product_1:
|
)
|
||||||
self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver")
|
self.assertEquals(
|
||||||
if line.product_id == self.product_2:
|
list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered"
|
||||||
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")
|
# 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_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:
|
for line in self.rma_droship_id.rma_line_ids:
|
||||||
line.action_rma_done()
|
line.action_rma_done()
|
||||||
self.assertEquals(line.state, "done", "Wrong State")
|
|
||||||
|
self.assertEquals(line.mapped("state"), ["done"], "Wrong State")
|
||||||
|
|
||||||
# Supplier RMA
|
# Supplier RMA
|
||||||
def test_04_supplier_rma(self):
|
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(
|
wizard = self.rma_make_picking.with_context(
|
||||||
{
|
{
|
||||||
"active_ids": self.rma_supplier_id.rma_line_ids.ids,
|
"active_ids": self.rma_supplier_id.rma_line_ids.ids,
|
||||||
"active_model": "rma.order.line",
|
"active_model": "rma.order.line",
|
||||||
"picking_type": "outgoing",
|
"picking_type": "outgoing",
|
||||||
"active_id": 1,
|
"active_id": 2,
|
||||||
}
|
}
|
||||||
).create({})
|
).create({})
|
||||||
wizard._create_picking()
|
wizard._create_picking()
|
||||||
res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments()
|
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"])
|
picking = self.env["stock.picking"].browse(res["res_id"])
|
||||||
moves = picking.move_lines
|
moves = picking.move_lines
|
||||||
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
|
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()
|
picking.action_assign()
|
||||||
for mv in picking.move_lines:
|
for mv in picking.move_lines:
|
||||||
mv.quantity_done = mv.product_uom_qty
|
mv.quantity_done = mv.product_uom_qty
|
||||||
picking.action_done()
|
picking.action_done()
|
||||||
for line in self.rma_supplier_id.rma_line_ids:
|
|
||||||
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_received, 0, "Wrong qty received")
|
list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming"
|
||||||
if line.product_id == self.product_1:
|
)
|
||||||
self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered")
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
|
list(set(lines.mapped("qty_to_deliver"))), [0], "Wrong qty_to_deliver"
|
||||||
if line.product_id == self.product_2:
|
)
|
||||||
self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered")
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive")
|
list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received"
|
||||||
if line.product_id == self.product_3:
|
)
|
||||||
self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered")
|
self.assertEquals(list(set(lines.mapped("qty_outgoing"))), [0], "qty_outgoing")
|
||||||
self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive")
|
|
||||||
|
# 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(
|
wizard = self.rma_make_picking.with_context(
|
||||||
{
|
{
|
||||||
"active_id": 1,
|
"active_id": 1,
|
||||||
@@ -519,41 +714,81 @@ class TestRma(common.SavepointCase):
|
|||||||
).create({})
|
).create({})
|
||||||
wizard._create_picking()
|
wizard._create_picking()
|
||||||
res = self.rma_supplier_id.rma_line_ids.action_view_in_shipments()
|
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"])
|
pickings = self.env["stock.picking"].browse(res["res_id"])
|
||||||
self.assertEquals(len(pickings), 1, "Incorrect number of pickings created")
|
self.assertEquals(len(pickings), 1, "Incorrect number of pickings created")
|
||||||
picking_out = pickings[0]
|
picking_in = pickings[0]
|
||||||
moves = picking_out.move_lines
|
moves = picking_in.move_lines
|
||||||
self.assertEquals(len(moves), 3, "Incorrect number of moves created")
|
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")
|
lines = self.rma_supplier_id.rma_line_ids
|
||||||
self.assertEquals(line.qty_received, 0, "Wrong qty received")
|
self.assertEquals(
|
||||||
self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver")
|
list(set(lines.mapped("qty_to_deliver"))), [0], "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")
|
# product specific
|
||||||
if line.product_id == self.product_2:
|
self._check_equal_quantity(
|
||||||
self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive")
|
lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive,
|
||||||
if line.product_id == self.product_3:
|
3,
|
||||||
self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive")
|
"Wrong qty_to_receive",
|
||||||
picking_out.action_assign()
|
)
|
||||||
for mv in picking.move_lines:
|
self._check_equal_quantity(
|
||||||
mv.quantity_done = mv.product_uom_qty
|
lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive,
|
||||||
picking_out.action_done()
|
5,
|
||||||
for line in self.rma_supplier_id.rma_line_ids[0]:
|
"Wrong qty_to_receive",
|
||||||
self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive")
|
)
|
||||||
self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming")
|
self._check_equal_quantity(
|
||||||
self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver")
|
lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive,
|
||||||
self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing")
|
2,
|
||||||
if line.product_id == self.product_1:
|
"Wrong qty_to_receive",
|
||||||
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:
|
picking_in.action_confirm()
|
||||||
self.assertEquals(line.qty_received, 0, "Wrong qty received")
|
picking_in.action_assign()
|
||||||
self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered")
|
for mv in picking_in.move_line_ids:
|
||||||
if line.product_id == self.product_3:
|
mv.qty_done = mv.product_uom_qty
|
||||||
self.assertEquals(line.qty_received, 2, "Wrong qty received")
|
picking_in.action_done()
|
||||||
self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered")
|
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:
|
for line in self.rma_supplier_id.rma_line_ids:
|
||||||
line.action_rma_done()
|
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
0
rma/views/product_view.xml
Executable file → Normal file
2
rma/views/res_partner_view.xml
Executable file → Normal file
2
rma/views/res_partner_view.xml
Executable file → Normal file
@@ -11,7 +11,7 @@
|
|||||||
name="action_open_partner_rma"
|
name="action_open_partner_rma"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-eject"
|
icon="fa-eject"
|
||||||
attrs="{'invisible':[('customer', '=', False)]}"
|
context="{'res_partner_search_mode': 'customer'}"
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
|
||||||
<field name="rma_line_count" widget="statinfo"
|
<field name="rma_line_count" widget="statinfo"
|
||||||
string="RMAs"/>
|
string="RMAs"/>
|
||||||
|
|||||||
2
rma/views/rma_operation_view.xml
Executable file → Normal file
2
rma/views/rma_operation_view.xml
Executable file → Normal file
@@ -63,7 +63,6 @@
|
|||||||
<record id="action_rma_operation_customer" model="ir.actions.act_window">
|
<record id="action_rma_operation_customer" model="ir.actions.act_window">
|
||||||
<field name="name">Customer Operations</field>
|
<field name="name">Customer Operations</field>
|
||||||
<field name="res_model">rma.operation</field>
|
<field name="res_model">rma.operation</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="context">{'default_type': "customer"}</field>
|
<field name="context">{'default_type': "customer"}</field>
|
||||||
<field name="domain">[('type','=', 'customer')]</field>
|
<field name="domain">[('type','=', 'customer')]</field>
|
||||||
@@ -73,7 +72,6 @@
|
|||||||
<record id="action_rma_operation_supplier" model="ir.actions.act_window">
|
<record id="action_rma_operation_supplier" model="ir.actions.act_window">
|
||||||
<field name="name">Supplier Operations</field>
|
<field name="name">Supplier Operations</field>
|
||||||
<field name="res_model">rma.operation</field>
|
<field name="res_model">rma.operation</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="context">{'default_type': "supplier"}</field>
|
<field name="context">{'default_type': "supplier"}</field>
|
||||||
<field name="domain">[('type','=', 'supplier')]</field>
|
<field name="domain">[('type','=', 'supplier')]</field>
|
||||||
|
|||||||
69
rma/views/rma_order_line_view.xml
Executable file → Normal file
69
rma/views/rma_order_line_view.xml
Executable file → Normal file
@@ -97,10 +97,17 @@
|
|||||||
invisible="context.get('hide_title',False)"/>
|
invisible="context.get('hide_title',False)"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<group name="partner">
|
<group>
|
||||||
<field name="partner_id"
|
<group name="partner">
|
||||||
domain="[('supplier','=',True)]"
|
<field name="partner_id"
|
||||||
string="Supplier"/>
|
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>
|
<group>
|
||||||
<group name="product" string="Product">
|
<group name="product" string="Product">
|
||||||
@@ -126,21 +133,21 @@
|
|||||||
('state', '=', 'done')]"/>
|
('state', '=', 'done')]"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group name="contact" string="Contact">
|
|
||||||
<field name="requested_by" readonly="1"/>
|
|
||||||
<field name="assigned_to"/>
|
|
||||||
</group>
|
|
||||||
<group name="operation" string="Operation">
|
<group name="operation" string="Operation">
|
||||||
<field name="operation_id"
|
<field name="operation_id"
|
||||||
domain="[('type','=','supplier')]"/>
|
domain="[('type','=','supplier')]"/>
|
||||||
<field name="receipt_policy"/>
|
<field name="receipt_policy"/>
|
||||||
<field name="delivery_policy"/>
|
<field name="delivery_policy"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group name="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>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="description" string="Description">
|
|
||||||
<field name="description" nolabel="1"/>
|
|
||||||
</page>
|
|
||||||
<page name="route" string="Routes">
|
<page name="route" string="Routes">
|
||||||
<group>
|
<group>
|
||||||
<group name="inbound" string="Inbound">
|
<group name="inbound" string="Inbound">
|
||||||
@@ -151,12 +158,6 @@
|
|||||||
</group>
|
</group>
|
||||||
<group name="outbound" string="Outbound">
|
<group name="outbound" string="Outbound">
|
||||||
<field name="out_warehouse_id"/>
|
<field name="out_warehouse_id"/>
|
||||||
<field name="delivery_address_id"
|
|
||||||
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="out_route_id" groups="stock.group_adv_location"/>
|
||||||
<field name="supplier_to_customer"/>
|
<field name="supplier_to_customer"/>
|
||||||
<field name="customer_address_id"
|
<field name="customer_address_id"
|
||||||
@@ -269,10 +270,14 @@
|
|||||||
<group name="partner">
|
<group name="partner">
|
||||||
<group name="partner">
|
<group name="partner">
|
||||||
<field name="partner_id"
|
<field name="partner_id"
|
||||||
domain="[('customer','=',True)]"
|
context="{'res_partner_search_mode': 'customer'}"
|
||||||
string="Customer"/>
|
string="Customer"/>
|
||||||
</group>
|
<field name="delivery_address_id"
|
||||||
<group name="warranty">
|
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"/>
|
<field name="under_warranty"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
@@ -299,20 +304,22 @@
|
|||||||
('state', '=', 'done')]"/>
|
('state', '=', 'done')]"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group name="contact" string="Contact">
|
|
||||||
<field name="requested_by" readonly="1"/>
|
|
||||||
<field name="assigned_to"/>
|
|
||||||
</group>
|
|
||||||
<group name="operation" string="Operation">
|
<group name="operation" string="Operation">
|
||||||
<field name="operation_id" domain="[('type','=','customer')]"/>
|
<field name="operation_id" domain="[('type','=','customer')]"/>
|
||||||
<field name="receipt_policy"/>
|
<field name="receipt_policy"/>
|
||||||
<field name="delivery_policy"/>
|
<field name="delivery_policy"/>
|
||||||
</group>
|
</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>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page name="description" string="Description">
|
|
||||||
<field name="description" nolabel="1"/>
|
|
||||||
</page>
|
|
||||||
<page name="route" string="Routes">
|
<page name="route" string="Routes">
|
||||||
<group name="inbound" string="Inbound">
|
<group name="inbound" string="Inbound">
|
||||||
<field name="in_warehouse_id"/>
|
<field name="in_warehouse_id"/>
|
||||||
@@ -328,12 +335,6 @@
|
|||||||
</group>
|
</group>
|
||||||
<group name="outbound" string="Outbound">
|
<group name="outbound" string="Outbound">
|
||||||
<field name="out_warehouse_id"/>
|
<field name="out_warehouse_id"/>
|
||||||
<field name="delivery_address_id"
|
|
||||||
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="out_route_id" groups="stock.group_adv_location"/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
@@ -425,7 +426,6 @@
|
|||||||
<field name="res_model">rma.order.line</field>
|
<field name="res_model">rma.order.line</field>
|
||||||
<field name="domain">[('type','=', 'customer')]</field>
|
<field name="domain">[('type','=', 'customer')]</field>
|
||||||
<field name="context">{"search_default_assigned_to":uid}</field>
|
<field name="context">{"search_default_assigned_to":uid}</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_rma_line_tree"/>
|
<field name="view_id" ref="view_rma_line_tree"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -435,7 +435,6 @@
|
|||||||
<field name="res_model">rma.order.line</field>
|
<field name="res_model">rma.order.line</field>
|
||||||
<field name="domain">[('type','=', 'supplier')]</field>
|
<field name="domain">[('type','=', 'supplier')]</field>
|
||||||
<field name="context">{"search_default_assigned_to":uid, "supplier":1}</field>
|
<field name="context">{"search_default_assigned_to":uid, "supplier":1}</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_rma_line_supplier_tree"/>
|
<field name="view_id" ref="view_rma_line_supplier_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
125
rma/views/rma_order_view.xml
Executable file → Normal file
125
rma/views/rma_order_view.xml
Executable file → Normal file
@@ -67,26 +67,24 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="oe_title" name="title">
|
<div class="oe_title" name="title">
|
||||||
<h1>
|
<h1>
|
||||||
<field name="name"/>
|
<field name="name" readonly="1"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<group name="partner">
|
<group>
|
||||||
<field name="partner_id"
|
<group name="info">
|
||||||
domain="[('customer','=',True)]"
|
<field name="partner_id"
|
||||||
string="Customer"
|
context="{'res_partner_search_mode': 'customer'}"
|
||||||
colspan="4"
|
string="Customer"
|
||||||
/>
|
colspan="4"
|
||||||
</group>
|
/>
|
||||||
<group name="info">
|
<field name="date_rma" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
<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>
|
|
||||||
</group>
|
</group>
|
||||||
|
<group name="comments">
|
||||||
|
<field name="comment"/>
|
||||||
|
<field name="type" readonly="1" invisible="1"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
<group name="inbound_route" string="Inbound">
|
<group name="inbound_route" string="Inbound">
|
||||||
<field name="in_warehouse_id" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
<field name="in_warehouse_id" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
<field name="customer_to_supplier" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
<field name="customer_to_supplier" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
@@ -98,6 +96,15 @@
|
|||||||
'invisible':[('customer_to_supplier', '=', False)],
|
'invisible':[('customer_to_supplier', '=', False)],
|
||||||
'readonly':[('state', '!=', 'draft')]}"/>
|
'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
</group>
|
</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">
|
<notebook colspan="4">
|
||||||
<page string="RMA Lines" name="lines">
|
<page string="RMA Lines" name="lines">
|
||||||
<field name="rma_line_ids" context="{'default_rma_id': active_id,
|
<field name="rma_line_ids" context="{'default_rma_id': active_id,
|
||||||
@@ -116,16 +123,6 @@
|
|||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</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>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
<div class="oe_chatter">
|
<div class="oe_chatter">
|
||||||
@@ -168,38 +165,44 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="oe_title" name="title">
|
<div class="oe_title" name="title">
|
||||||
<h1>
|
<h1>
|
||||||
<field name="name"/>
|
<field name="name" readonly="1"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<group name="partner">
|
<group>
|
||||||
<field name="state" invisible="1"/>
|
<group name="partner">
|
||||||
<field name="partner_id"
|
<field name="state" invisible="1"/>
|
||||||
domain="[('supplier','=',True)]"
|
<field name="partner_id"
|
||||||
string="Supplier"
|
context="{'res_partner_search_mode': 'supplier'}"
|
||||||
attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
string="Supplier"
|
||||||
|
attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
|
<field name="reference"/>
|
||||||
|
<field name="date_rma" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="comment"/>
|
||||||
|
<field name="type" readonly="1" invisible="1"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group name="route">
|
||||||
|
<group name="inbound_route" string="Inbound">
|
||||||
|
<field name="in_warehouse_id" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
|
</group>
|
||||||
|
<group name="outbound_route" string="Outbound">
|
||||||
|
<field name="supplier_to_customer" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
|
<field name="customer_address_id"
|
||||||
|
context="{'show_address': 1}"
|
||||||
|
options="{'always_reload': 1}"
|
||||||
|
attrs="{'required':[('supplier_to_customer', '=', True)],
|
||||||
|
'invisible':[('supplier_to_customer', '=', False)],
|
||||||
|
'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group col="4">
|
<group name="contact" string="Contact">
|
||||||
<field name="reference"/>
|
<field name="requested_by" readonly="1"/>
|
||||||
<field name="date_rma" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
<field name="assigned_to" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||||
</group>
|
<field name="company_id"
|
||||||
<group name="contact" string="Contact">
|
groups="base.group_multi_company"/>
|
||||||
<field name="requested_by" readonly="1"/>
|
|
||||||
<field name="assigned_to" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
<group name="route">
|
|
||||||
<group name="inbound_route" string="Inbound">
|
|
||||||
<field name="in_warehouse_id" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
|
||||||
</group>
|
|
||||||
<group name="outbound_route" string="Outbound">
|
|
||||||
<field name="supplier_to_customer" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
|
||||||
<field name="customer_address_id"
|
|
||||||
context="{'show_address': 1}"
|
|
||||||
options="{'always_reload': 1}"
|
|
||||||
attrs="{'required':[('supplier_to_customer', '=', True)],
|
|
||||||
'invisible':[('supplier_to_customer', '=', False)],
|
|
||||||
'readonly':[('state', '!=', 'draft')]}"/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
@@ -224,16 +227,6 @@
|
|||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</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>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
<div class="oe_chatter">
|
<div class="oe_chatter">
|
||||||
@@ -266,7 +259,6 @@
|
|||||||
<record id="action_rma_customer" model="ir.actions.act_window">
|
<record id="action_rma_customer" model="ir.actions.act_window">
|
||||||
<field name="name">Customer RMA Group</field>
|
<field name="name">Customer RMA Group</field>
|
||||||
<field name="res_model">rma.order</field>
|
<field name="res_model">rma.order</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="domain">[('type','=', 'customer')]</field>
|
<field name="domain">[('type','=', 'customer')]</field>
|
||||||
<field name="context">{'customer':1}</field>
|
<field name="context">{'customer':1}</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
@@ -276,7 +268,6 @@
|
|||||||
<record id="action_rma_supplier" model="ir.actions.act_window">
|
<record id="action_rma_supplier" model="ir.actions.act_window">
|
||||||
<field name="name">Supplier RMA Group</field>
|
<field name="name">Supplier RMA Group</field>
|
||||||
<field name="res_model">rma.order</field>
|
<field name="res_model">rma.order</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="domain">[('type','=', 'supplier')]</field>
|
<field name="domain">[('type','=', 'supplier')]</field>
|
||||||
<field name="context">{'supplier':1}</field>
|
<field name="context">{'supplier':1}</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
|
|||||||
13
rma/views/stock_view.xml
Executable file → Normal file
13
rma/views/stock_view.xml
Executable file → Normal file
@@ -13,19 +13,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</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">
|
<record id="stock_location_route_form_view_inherit_rma_stock" model="ir.ui.view">
|
||||||
<field name="name">stock.location.route.form</field>
|
<field name="name">stock.location.route.form</field>
|
||||||
<field name="inherit_id" ref="stock.stock_location_route_form_view"/>
|
<field name="inherit_id" ref="stock.stock_location_route_form_view"/>
|
||||||
|
|||||||
0
rma/views/stock_warehouse.xml
Executable file → Normal file
0
rma/views/stock_warehouse.xml
Executable file → Normal 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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from . import rma_add_stock_move
|
from . import rma_add_stock_move
|
||||||
|
|||||||
@@ -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)
|
# 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
|
||||||
@@ -106,7 +106,6 @@ class RmaAddStockMove(models.TransientModel):
|
|||||||
existing_move_lines.append(rma_line.reference_move_id)
|
existing_move_lines.append(rma_line.reference_move_id)
|
||||||
return existing_move_lines
|
return existing_move_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_stock_moves = self._get_existing_stock_moves()
|
existing_stock_moves = self._get_existing_stock_moves()
|
||||||
|
|||||||
5
rma/wizards/rma_add_stock_move_view.xml
Executable file → Normal file
5
rma/wizards/rma_add_stock_move_view.xml
Executable file → Normal file
@@ -18,7 +18,6 @@
|
|||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="product_uom_qty"/>
|
<field name="product_uom_qty"/>
|
||||||
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom"/>
|
<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="picking_id"/>
|
||||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||||
<field name="location_dest_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="name">Add from Stock Move</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma_add_stock_move</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="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="view_id" ref="view_rma_add_stock_move_customer"/>
|
<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="name">Add from Stock Move</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma_add_stock_move</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="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="view_id" ref="view_rma_add_stock_move_supplier"/>
|
<field name="view_id" ref="view_rma_add_stock_move_supplier"/>
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@@ -7,8 +7,6 @@ from odoo import _, api, fields, models
|
|||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT
|
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT
|
||||||
|
|
||||||
import odoo.addons.decimal_precision as dp
|
|
||||||
|
|
||||||
|
|
||||||
class RmaMakePicking(models.TransientModel):
|
class RmaMakePicking(models.TransientModel):
|
||||||
_name = "rma_make_picking.wizard"
|
_name = "rma_make_picking.wizard"
|
||||||
@@ -95,10 +93,10 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
return delivery_address
|
return delivery_address
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_address_location(self, delivery_address_id, type):
|
def _get_address_location(self, delivery_address_id, a_type):
|
||||||
if type == "supplier":
|
if a_type == "supplier":
|
||||||
return delivery_address_id.property_stock_supplier
|
return delivery_address_id.property_stock_supplier
|
||||||
elif type == "customer":
|
elif a_type == "customer":
|
||||||
return delivery_address_id.property_stock_customer
|
return delivery_address_id.property_stock_customer
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -150,27 +148,33 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
qty = item.qty_to_deliver
|
qty = item.qty_to_deliver
|
||||||
values = self._get_procurement_data(item, group, qty, picking_type)
|
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
|
# create picking
|
||||||
|
procurements = []
|
||||||
try:
|
try:
|
||||||
self.env["procurement.group"].run(
|
procurement = group.Procurement(
|
||||||
item.line_id.product_id,
|
item.line_id.product_id,
|
||||||
qty,
|
qty,
|
||||||
item.line_id.product_id.product_tmpl_id.uom_id,
|
item.line_id.product_id.product_tmpl_id.uom_id,
|
||||||
values.get("location_id"),
|
values.get("location_id"),
|
||||||
values.get("origin"),
|
values.get("origin"),
|
||||||
values.get("origin"),
|
values.get("origin"),
|
||||||
|
self.env.company,
|
||||||
values,
|
values,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
procurements.append(procurement)
|
||||||
|
self.env["procurement.group"].run(procurements)
|
||||||
except UserError as error:
|
except UserError as error:
|
||||||
errors.append(error.name)
|
errors.append(error.name)
|
||||||
if errors:
|
if errors:
|
||||||
raise UserError("\n".join(errors))
|
raise UserError("\n".join(errors))
|
||||||
return values.get("origin")
|
return procurements
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _create_picking(self):
|
def _create_picking(self):
|
||||||
"""Method called when the user clicks on create picking"""
|
"""Method called when the user clicks on create picking"""
|
||||||
picking_type = self.env.context.get("picking_type")
|
picking_type = self.env.context.get("picking_type")
|
||||||
|
procurements = []
|
||||||
for item in self.item_ids:
|
for item in self.item_ids:
|
||||||
line = item.line_id
|
line = item.line_id
|
||||||
if line.state != "approved":
|
if line.state != "approved":
|
||||||
@@ -180,43 +184,18 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
if line.delivery_policy == "no" and picking_type == "outgoing":
|
if line.delivery_policy == "no" and picking_type == "outgoing":
|
||||||
raise ValidationError(_("No deliveries needed for this operation"))
|
raise ValidationError(_("No deliveries needed for this operation"))
|
||||||
procurement = self._create_procurement(item, picking_type)
|
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):
|
def action_create_picking(self):
|
||||||
procurement = self._create_picking()
|
self._create_picking()
|
||||||
action = self.env.ref("stock.do_view_pickings")
|
picking_type = self.env.context.get("picking_type")
|
||||||
action = action.read()[0]
|
if picking_type == "outgoing":
|
||||||
if procurement:
|
action = self.item_ids.line_id.action_view_out_shipments()
|
||||||
pickings = (
|
else:
|
||||||
self.env["stock.picking"].search([("origin", "=", procurement)]).ids
|
action = self.item_ids.line_id.action_view_in_shipments()
|
||||||
)
|
|
||||||
if len(pickings) > 1:
|
|
||||||
action["domain"] = [("id", "in", pickings)]
|
|
||||||
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]
|
|
||||||
return action
|
return action
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
return {"type": "ir.actions.act_window_close"}
|
return {"type": "ir.actions.act_window_close"}
|
||||||
|
|
||||||
@@ -237,13 +216,13 @@ class RmaMakePickingItem(models.TransientModel):
|
|||||||
related="line_id.product_qty",
|
related="line_id.product_qty",
|
||||||
string="Quantity Ordered",
|
string="Quantity Ordered",
|
||||||
copy=False,
|
copy=False,
|
||||||
digits=dp.get_precision("Product Unit of Measure"),
|
digits="Product Unit of Measure",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
qty_to_receive = fields.Float(
|
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(
|
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)
|
uom_id = fields.Many2one("uom.uom", string="Unit of Measure", readonly=True)
|
||||||
|
|||||||
2
rma/wizards/rma_make_picking_view.xml
Executable file → Normal file
2
rma/wizards/rma_make_picking_view.xml
Executable file → Normal file
@@ -61,7 +61,6 @@
|
|||||||
<field name="name">Create Incoming Shipment</field>
|
<field name="name">Create Incoming Shipment</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma_make_picking.wizard</field>
|
<field name="res_model">rma_make_picking.wizard</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_picking"/>
|
<field name="view_id" ref="view_rma_picking"/>
|
||||||
@@ -74,7 +73,6 @@
|
|||||||
<field name="name">Create Delivery</field>
|
<field name="name">Create Delivery</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma_make_picking.wizard</field>
|
<field name="res_model">rma_make_picking.wizard</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_picking_out"/>
|
<field name="view_id" ref="view_rma_picking_out"/>
|
||||||
|
|||||||
@@ -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)
|
# 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
|
||||||
|
|
||||||
import odoo.addons.decimal_precision as dp
|
|
||||||
|
|
||||||
|
|
||||||
class RmaLineMakeSupplierRma(models.TransientModel):
|
class RmaLineMakeSupplierRma(models.TransientModel):
|
||||||
_name = "rma.order.line.make.supplier.rma"
|
_name = "rma.order.line.make.supplier.rma"
|
||||||
@@ -86,7 +84,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
raise ValidationError(_("Enter a supplier."))
|
raise ValidationError(_("Enter a supplier."))
|
||||||
return {
|
return {
|
||||||
"partner_id": self.partner_id.id,
|
"partner_id": self.partner_id.id,
|
||||||
"delivery_address_id": self.partner_id.id,
|
|
||||||
"type": "supplier",
|
"type": "supplier",
|
||||||
"company_id": company.id,
|
"company_id": company.id,
|
||||||
}
|
}
|
||||||
@@ -121,6 +118,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
"origin": item.line_id.rma_id.name,
|
"origin": item.line_id.rma_id.name,
|
||||||
"customer_address_id": item.line_id.delivery_address_id.id
|
"customer_address_id": item.line_id.delivery_address_id.id
|
||||||
or item.line_id.partner_id.id,
|
or item.line_id.partner_id.id,
|
||||||
|
"delivery_address_id": self.partner_id.id,
|
||||||
"product_id": item.line_id.product_id.id,
|
"product_id": item.line_id.product_id.id,
|
||||||
"customer_rma_id": item.line_id.id,
|
"customer_rma_id": item.line_id.id,
|
||||||
"product_qty": item.product_qty,
|
"product_qty": item.product_qty,
|
||||||
@@ -142,7 +140,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def make_supplier_rma(self):
|
def make_supplier_rma(self):
|
||||||
self = self.with_context(supplier=True, customer=False)
|
self = self.with_context(supplier=True, customer=False)
|
||||||
rma_obj = self.env["rma.order"]
|
rma_obj = self.env["rma.order"]
|
||||||
@@ -165,7 +162,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
if rma:
|
if rma:
|
||||||
return {
|
return {
|
||||||
"name": _("Supplier RMA"),
|
"name": _("Supplier RMA"),
|
||||||
"view_type": "form",
|
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"res_model": "rma.order",
|
"res_model": "rma.order",
|
||||||
"view_id": False,
|
"view_id": False,
|
||||||
@@ -176,7 +172,6 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
"name": _("Supplier RMA Line"),
|
"name": _("Supplier RMA Line"),
|
||||||
"view_type": "form",
|
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"res_model": "rma.order.line",
|
"res_model": "rma.order.line",
|
||||||
"view_id": False,
|
"view_id": False,
|
||||||
@@ -208,9 +203,7 @@ class RmaLineMakeRmaOrderItem(models.TransientModel):
|
|||||||
)
|
)
|
||||||
name = fields.Char(related="line_id.name", readonly=True)
|
name = fields.Char(related="line_id.name", readonly=True)
|
||||||
uom_id = fields.Many2one("uom.uom", string="UoM", readonly=True)
|
uom_id = fields.Many2one("uom.uom", string="UoM", readonly=True)
|
||||||
product_qty = fields.Float(
|
product_qty = fields.Float(string="Quantity", digits="Product UoS")
|
||||||
string="Quantity", digits=dp.get_precision("Product UoS")
|
|
||||||
)
|
|
||||||
operation_id = fields.Many2one(
|
operation_id = fields.Many2one(
|
||||||
comodel_name="rma.operation",
|
comodel_name="rma.operation",
|
||||||
string="Operation",
|
string="Operation",
|
||||||
|
|||||||
3
rma/wizards/rma_order_line_make_supplier_rma_view.xml
Executable file → Normal file
3
rma/wizards/rma_order_line_make_supplier_rma_view.xml
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?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) -->
|
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0) -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_rma_order_line_make_supplier_rma"
|
<record id="view_rma_order_line_make_supplier_rma"
|
||||||
@@ -53,7 +53,6 @@
|
|||||||
<field name="name">Create Supplier RMA</field>
|
<field name="name">Create Supplier RMA</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.supplier.rma</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_mode">form</field>
|
||||||
<field name="view_id" ref="view_rma_order_line_make_supplier_rma"/>
|
<field name="view_id" ref="view_rma_order_line_make_supplier_rma"/>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
|
|||||||
@@ -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)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import fields, models
|
||||||
@@ -7,25 +7,14 @@ from odoo import fields, models
|
|||||||
class StockConfigSettings(models.TransientModel):
|
class StockConfigSettings(models.TransientModel):
|
||||||
_inherit = "res.config.settings"
|
_inherit = "res.config.settings"
|
||||||
|
|
||||||
group_rma_delivery_address = fields.Selection(
|
group_rma_delivery_address = fields.Boolean(
|
||||||
[
|
related="company_id.group_rma_delivery_address",
|
||||||
(
|
|
||||||
0,
|
|
||||||
"Invoicing and shipping addresses are always the same "
|
|
||||||
"(Example: services companies)",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
1,
|
|
||||||
"Display 3 fields on rma: partner, invoice address, delivery "
|
|
||||||
"address",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
"Addresses",
|
|
||||||
implied_group="rma.group_rma_delivery_invoice_address",
|
implied_group="rma.group_rma_delivery_invoice_address",
|
||||||
|
readonly=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
group_rma_lines = fields.Selection(
|
group_rma_lines = fields.Boolean(
|
||||||
[(0, "Do not group RMA lines"), (1, "Group RMA lines in one RMA group")],
|
related="company_id.group_rma_lines",
|
||||||
"Grouping",
|
readonly=False,
|
||||||
implied_group="rma.group_rma_groups",
|
implied_group="rma.group_rma_groups",
|
||||||
)
|
)
|
||||||
|
|||||||
24
rma/wizards/stock_config_settings.xml
Executable file → Normal file
24
rma/wizards/stock_config_settings.xml
Executable file → Normal file
@@ -8,13 +8,25 @@
|
|||||||
<div id="production_lot_info" position="after">
|
<div id="production_lot_info" position="after">
|
||||||
<h2>Return Merchandise Authorization</h2>
|
<h2>Return Merchandise Authorization</h2>
|
||||||
<div class="row mt16 o_settings_container">
|
<div class="row mt16 o_settings_container">
|
||||||
<div class="col-xs-12 col-md-12 o_setting_box">
|
<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">
|
<div class="o_setting_right_pane">
|
||||||
<div class="content-group">
|
<label for="group_rma_delivery_address"/>
|
||||||
<div class="mt16">
|
<div class="text-muted">
|
||||||
<field name="group_rma_delivery_address" class="o_light_label" widget="radio"/>
|
Display 3 fields on rma: partner, invoice address, delivery address.
|
||||||
<field name="group_rma_lines" widget="radio"/>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user