diff --git a/rma/README.rst b/rma/README.rst index ce5a2aca..bc583e48 100644 --- a/rma/README.rst +++ b/rma/README.rst @@ -100,7 +100,7 @@ Bug Tracker =========== Bugs are tracked on `GitHub Issues -`_. In case of trouble, please +`_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback. @@ -111,9 +111,9 @@ Credits Contributors ------------ -* Jordi Ballester Alomar -* Aaron Henriquez -* Lois Rilo +* Jordi Ballester Alomar +* Aaron Henriquez +* Lois Rilo * Bhavesh Odedra * Akim Juillerat * Alexandre Fayolle @@ -122,4 +122,4 @@ Contributors Maintainer ---------- -This module is maintained by Eficent. +This module is maintained by ForgeFlow. diff --git a/rma/__init__.py b/rma/__init__.py index 4733391a..4d1a3fe7 100644 --- a/rma/__init__.py +++ b/rma/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import models diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 346fe5b4..0f15dd07 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -1,15 +1,15 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) { "name": "RMA (Return Merchandise Authorization)", - "version": "12.0.2.3.0", + "version": "13.0.1.0.0", "license": "LGPL-3", "category": "RMA", "summary": "Introduces the return merchandise authorization (RMA) process " "in odoo", - "author": "Eficent, Odoo Community Association (OCA)", - "website": "https://github.com/Eficent/stock-rma", + "author": "ForgeFlow", + "website": "https://github.com/ForgeFlow/stock-rma", "depends": ["stock", "mail", "web"], "demo": ["demo/stock_demo.xml"], "data": [ @@ -33,5 +33,4 @@ "wizards/rma_order_line_make_supplier_rma_view.xml", ], "installable": True, - "auto_install": False, } diff --git a/rma/data/rma_operation.xml b/rma/data/rma_operation.xml old mode 100755 new mode 100644 diff --git a/rma/data/rma_sequence.xml b/rma/data/rma_sequence.xml old mode 100755 new mode 100644 diff --git a/rma/data/stock_data.xml b/rma/data/stock_data.xml old mode 100755 new mode 100644 index 120c3c02..08d4e687 --- a/rma/data/stock_data.xml +++ b/rma/data/stock_data.xml @@ -44,6 +44,7 @@ RMA → Customer + RMA → Customer @@ -54,6 +55,7 @@ Customer → RMA + Customer → RMA @@ -64,6 +66,7 @@ RMA -> Supplier + RMA -> Supplier @@ -74,6 +77,7 @@ Supplier -> RMA + Supplier -> RMA @@ -84,6 +88,7 @@ Customer -> Supplier + Customer -> Supplier Supplier -> Customer + Supplier -> Customer RMA Customer 10 - @@ -126,7 +131,6 @@ RMA Supplier 10 - @@ -137,7 +141,6 @@ RMA Dropship 10 - diff --git a/rma/demo/stock_demo.xml b/rma/demo/stock_demo.xml old mode 100755 new mode 100644 index 1c37eefb..0c22b4df --- a/rma/demo/stock_demo.xml +++ b/rma/demo/stock_demo.xml @@ -64,7 +64,6 @@ RMA Customer 10 - @@ -74,7 +73,6 @@ RMA Supplier 10 - @@ -84,7 +82,6 @@ RMA Dropship 10 - diff --git a/rma/models/__init__.py b/rma/models/__init__.py index 4e9429ad..1a7cbc3c 100644 --- a/rma/models/__init__.py +++ b/rma/models/__init__.py @@ -9,3 +9,4 @@ from . import product from . import product_category from . import procurement from . import res_partner +from . import res_company diff --git a/rma/models/procurement.py b/rma/models/procurement.py index 5083841d..bfe1821b 100644 --- a/rma/models/procurement.py +++ b/rma/models/procurement.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import fields, models @@ -7,10 +7,6 @@ from odoo import fields, models class StockRule(models.Model): _inherit = "stock.rule" - rma_line_id = fields.Many2one( - comodel_name="rma.order.line", string="RMA line", ondelete="set null" - ) - def _get_stock_move_values( self, product_id, @@ -19,8 +15,8 @@ class StockRule(models.Model): location_id, name, origin, + company_id, values, - group_id, ): res = super(StockRule, self)._get_stock_move_values( product_id, @@ -29,11 +25,11 @@ class StockRule(models.Model): location_id, name, origin, + company_id, values, - group_id, ) if "rma_line_id" in values: - line = self.env["rma.order.line"].browse(values.get("rma_line_id")) + line = values.get("rma_line_id") res["rma_line_id"] = line.id if line.delivery_address_id: res["partner_id"] = line.delivery_address_id.id diff --git a/rma/models/product.py b/rma/models/product.py index 4330b3d1..112e1c16 100644 --- a/rma/models/product.py +++ b/rma/models/product.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import fields, models diff --git a/rma/models/product_category.py b/rma/models/product_category.py index 7ac3ae1c..b528731c 100644 --- a/rma/models/product_category.py +++ b/rma/models/product_category.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import fields, models diff --git a/rma/models/res_company.py b/rma/models/res_company.py new file mode 100644 index 00000000..1ed19e1d --- /dev/null +++ b/rma/models/res_company.py @@ -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" + ) diff --git a/rma/models/res_partner.py b/rma/models/res_partner.py index 9eed65ae..4fad21cc 100644 --- a/rma/models/res_partner.py +++ b/rma/models/res_partner.py @@ -1,13 +1,12 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2017 ForgeFlow # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models +from odoo import fields, models class ResPartner(models.Model): _inherit = "res.partner" - @api.multi def _compute_rma_line_count(self): for rec in self: rec.rma_line_count = len(rec.rma_line_ids) @@ -17,7 +16,6 @@ class ResPartner(models.Model): ) rma_line_count = fields.Integer(compute="_compute_rma_line_count") - @api.multi def action_open_partner_rma(self): action = self.env.ref("rma.action_rma_customer_lines") result = action.read()[0] diff --git a/rma/models/rma_operation.py b/rma/models/rma_operation.py index 04285d6d..104dc9bf 100644 --- a/rma/models/rma_operation.py +++ b/rma/models/rma_operation.py @@ -1,4 +1,4 @@ -# Copyright 2017-18 Eficent Business and IT Consulting Services S.L. +# Copyright 2017-18 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models diff --git a/rma/models/rma_order.py b/rma/models/rma_order.py index 015dc536..3dbb31f6 100644 --- a/rma/models/rma_order.py +++ b/rma/models/rma_order.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from datetime import datetime @@ -18,10 +18,12 @@ class RmaOrder(models.Model): return "supplier" return "customer" - @api.multi def _compute_in_shipment_count(self): for rec in self: picking_ids = [] + if not rec.rma_line_ids: + rec.in_shipment_count = 0 + continue for line in rec.rma_line_ids: for move in line.move_ids: if move.location_dest_id.usage == "internal": @@ -30,33 +32,32 @@ class RmaOrder(models.Model): if line.customer_to_supplier: picking_ids.append(move.picking_id.id) shipments = list(set(picking_ids)) - line.in_shipment_count = len(shipments) + rec.in_shipment_count = len(shipments) - @api.multi def _compute_out_shipment_count(self): picking_ids = [] for rec in self: + if not rec.rma_line_ids: + rec.out_shipment_count = 0 + continue for line in rec.rma_line_ids: for move in line.move_ids: if move.location_dest_id.usage in ("supplier", "customer"): if not line.customer_to_supplier: picking_ids.append(move.picking_id.id) shipments = list(set(picking_ids)) - line.out_shipment_count = len(shipments) + rec.out_shipment_count = len(shipments) - @api.multi def _compute_supplier_line_count(self): self.supplier_line_count = len( self.rma_line_ids.filtered(lambda r: r.supplier_rma_line_ids) ) - @api.multi def _compute_line_count(self): for rec in self: rec.line_count = len(rec._get_valid_lines()) @api.depends("rma_line_ids", "rma_line_ids.state") - @api.multi def _compute_state(self): for rec in self: rma_line_done = self.env["rma.order.line"].search_count( @@ -114,9 +115,7 @@ class RmaOrder(models.Model): out_shipment_count = fields.Integer( compute="_compute_out_shipment_count", string="# of Outgoing Shipments" ) - line_count = fields.Integer( - compute="_compute_line_count", string="# of Outgoing Shipments" - ) + line_count = fields.Integer(compute="_compute_line_count", string="# of RMA lines") supplier_line_count = fields.Integer( compute="_compute_supplier_line_count", string="# of Supplier RMAs" ) @@ -184,7 +183,6 @@ class RmaOrder(models.Model): vals["name"] = self.env["ir.sequence"].next_by_code("rma.order.customer") return super(RmaOrder, self).create(vals) - @api.multi def action_view_in_shipments(self): action = self.env.ref("stock.action_picking_tree_all") result = action.read()[0] @@ -207,7 +205,6 @@ class RmaOrder(models.Model): result["res_id"] = shipments[0] return result - @api.multi def action_view_out_shipments(self): action = self.env.ref("stock.action_picking_tree_all") result = action.read()[0] @@ -228,14 +225,12 @@ class RmaOrder(models.Model): result["res_id"] = shipments[0] return result - @api.multi def _get_valid_lines(self): """:return: A recordset of rma lines. """ self.ensure_one() return self.rma_line_ids - @api.multi def action_view_lines(self): if self.type == "customer": action = self.env.ref("rma.action_rma_customer_lines") @@ -254,7 +249,6 @@ class RmaOrder(models.Model): result["context"] = {} return result - @api.multi def action_view_supplier_lines(self): action = self.env.ref("rma.action_rma_supplier_lines") result = action.read()[0] diff --git a/rma/models/rma_order_line.py b/rma/models/rma_order_line.py index da083544..045fd340 100644 --- a/rma/models/rma_order_line.py +++ b/rma/models/rma_order_line.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) import operator @@ -6,8 +6,6 @@ import operator from odoo import _, api, fields, models from odoo.exceptions import UserError, ValidationError -from odoo.addons import decimal_precision as dp - ops = {"=": operator.eq, "!=": operator.ne} @@ -38,16 +36,12 @@ class RmaOrderLine(models.Model): wh = self._default_warehouse_id() return wh.lot_rma_id - @api.model - def _default_delivery_address(self): - partner_id = self.env.context.get("partner_id", False) - if partner_id: - partner = self.env["res.partner"].browse(partner_id) - addr = partner.address_get(["delivery"]) - return self.env["res.partner"].browse(addr["delivery"]) - return False + @api.onchange("partner_id") + def _onchange_delivery_address(self): + self.delivery_address_id = self.env["res.partner"].browse( + self.partner_id.address_get(["delivery"])["delivery"] + ) - @api.multi def _compute_in_shipment_count(self): for line in self: picking_ids = [] @@ -60,7 +54,6 @@ class RmaOrderLine(models.Model): shipments = list(set(picking_ids)) line.in_shipment_count = len(shipments) - @api.multi def _compute_out_shipment_count(self): picking_ids = [] for line in self: @@ -71,7 +64,6 @@ class RmaOrderLine(models.Model): shipments = list(set(picking_ids)) line.out_shipment_count = len(shipments) - @api.multi def _get_rma_move_qty(self, states, direction="in"): for rec in self: product_obj = self.env["uom.uom"] @@ -86,7 +78,6 @@ class RmaOrderLine(models.Model): qty += product_obj._compute_quantity(move.product_uom_qty, rec.uom_id) return qty - @api.multi @api.depends( "move_ids", "move_ids.state", @@ -103,7 +94,6 @@ class RmaOrderLine(models.Model): elif rec.receipt_policy == "delivered": rec.qty_to_receive = rec.qty_delivered - rec.qty_received - @api.multi @api.depends( "move_ids", "move_ids.state", @@ -121,7 +111,6 @@ class RmaOrderLine(models.Model): elif rec.delivery_policy == "received": rec.qty_to_deliver = rec.qty_received - rec.qty_delivered - @api.multi @api.depends("move_ids", "move_ids.state", "type") def _compute_qty_incoming(self): for rec in self: @@ -130,14 +119,12 @@ class RmaOrderLine(models.Model): ) rec.qty_incoming = qty - @api.multi @api.depends("move_ids", "move_ids.state", "type") def _compute_qty_received(self): for rec in self: qty = rec._get_rma_move_qty("done", direction="in") rec.qty_received = qty - @api.multi @api.depends("move_ids", "move_ids.state", "type") def _compute_qty_outgoing(self): for rec in self: @@ -146,7 +133,6 @@ class RmaOrderLine(models.Model): ) rec.qty_outgoing = qty - @api.multi @api.depends("move_ids", "move_ids.state", "type") def _compute_qty_delivered(self): for rec in self: @@ -161,7 +147,6 @@ class RmaOrderLine(models.Model): ) ) - @api.multi @api.depends( "customer_to_supplier", "supplier_rma_line_ids", @@ -182,7 +167,6 @@ class RmaOrderLine(models.Model): rec.qty_to_supplier_rma = 0.0 rec.qty_in_supplier_rma = 0.0 - @api.multi def _compute_rma_line_count(self): for rec in self.filtered(lambda r: r.type == "customer"): rec.rma_line_count = len(rec.supplier_rma_line_ids) @@ -192,7 +176,6 @@ class RmaOrderLine(models.Model): delivery_address_id = fields.Many2one( comodel_name="res.partner", string="Partner delivery address", - default=lambda self: self._default_delivery_address(), readonly=True, states={"draft": [("readonly", False)]}, help="This address will be used to deliver repaired or replacement " @@ -279,7 +262,7 @@ class RmaOrderLine(models.Model): string="Return Qty", copy=False, default=1.0, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, states={"draft": [("readonly", False)]}, ) @@ -309,7 +292,11 @@ class RmaOrderLine(models.Model): readonly=True, states={"draft": [("readonly", False)]}, ) - currency_id = fields.Many2one("res.currency", string="Currency") + currency_id = fields.Many2one( + "res.currency", + string="Currency", + default=lambda self: self.env.user.company_id.currency_id, + ) company_id = fields.Many2one( comodel_name="res.company", string="Company", @@ -420,7 +407,7 @@ class RmaOrderLine(models.Model): ) qty_to_receive = fields.Float( string="Qty To Receive", - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", compute="_compute_qty_to_receive", store=True, ) @@ -428,21 +415,21 @@ class RmaOrderLine(models.Model): string="Incoming Qty", copy=False, readonly=True, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", compute="_compute_qty_incoming", store=True, ) qty_received = fields.Float( string="Qty Received", copy=False, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", compute="_compute_qty_received", store=True, ) qty_to_deliver = fields.Float( string="Qty To Deliver", copy=False, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, compute="_compute_qty_to_deliver", store=True, @@ -451,28 +438,28 @@ class RmaOrderLine(models.Model): string="Outgoing Qty", copy=False, readonly=True, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", compute="_compute_qty_outgoing", store=True, ) qty_delivered = fields.Float( string="Qty Delivered", copy=False, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, compute="_compute_qty_delivered", store=True, ) qty_to_supplier_rma = fields.Float( string="Qty to send to Supplier RMA", - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, compute="_compute_qty_supplier_rma", store=True, ) qty_in_supplier_rma = fields.Float( string="Qty in Supplier RMA", - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, compute="_compute_qty_supplier_rma", store=True, @@ -481,7 +468,6 @@ class RmaOrderLine(models.Model): string="Under Warranty?", readonly=True, states={"draft": [("readonly", False)]} ) - @api.multi def _prepare_rma_line_from_stock_move(self, sm, lot=False): if not self.type: self.type = self._get_default_type() @@ -542,7 +528,6 @@ class RmaOrderLine(models.Model): } return data - @api.multi @api.onchange("reference_move_id") def _onchange_reference_move_id(self): self.ensure_one() @@ -562,7 +547,6 @@ class RmaOrderLine(models.Model): self.update(data) self._remove_other_data_origin("reference_move_id") - @api.multi @api.constrains("reference_move_id", "partner_id") def _check_move_partner(self): for rec in self: @@ -577,13 +561,11 @@ class RmaOrderLine(models.Model): ) ) - @api.multi def _remove_other_data_origin(self, exception): if not exception == "reference_move_id": self.reference_move_id = False return True - @api.multi def action_rma_to_approve(self): self.write({"state": "to_approve"}) for rec in self: @@ -591,19 +573,16 @@ class RmaOrderLine(models.Model): rec.action_rma_approve() return True - @api.multi def action_rma_draft(self): if self.in_shipment_count or self.out_shipment_count: raise UserError(_("You cannot reset to draft a RMA with related pickings.")) self.write({"state": "draft"}) return True - @api.multi def action_rma_approve(self): self.write({"state": "approved"}) return True - @api.multi def action_rma_done(self): self.write({"state": "done"}) return True @@ -676,7 +655,6 @@ class RmaOrderLine(models.Model): self.product_id = product self.uom_id = product.uom_id - @api.multi def action_view_in_shipments(self): action = self.env.ref("stock.action_picking_tree_all") result = action.read()[0] @@ -699,7 +677,6 @@ class RmaOrderLine(models.Model): result["res_id"] = shipments[0] return result - @api.multi def action_view_out_shipments(self): action = self.env.ref("stock.action_picking_tree_all") result = action.read()[0] @@ -719,7 +696,6 @@ class RmaOrderLine(models.Model): result["res_id"] = shipments[0] return result - @api.multi def action_view_rma_lines(self): if self.type == "customer": # from customer we link to supplier rma diff --git a/rma/models/stock.py b/rma/models/stock.py index 38dc6243..e7ece0b7 100644 --- a/rma/models/stock.py +++ b/rma/models/stock.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models @@ -7,7 +7,6 @@ from odoo import api, fields, models class StockPicking(models.Model): _inherit = "stock.picking" - @api.multi def action_assign(self): """When you try to bring back a product from a customer location, it may happen that there is no quants available to perform the diff --git a/rma/models/stock_warehouse.py b/rma/models/stock_warehouse.py index d69506fd..238def19 100644 --- a/rma/models/stock_warehouse.py +++ b/rma/models/stock_warehouse.py @@ -1,7 +1,7 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from odoo import _, api, fields, models +from odoo import _, fields, models class StockWarehouse(models.Model): @@ -41,7 +41,6 @@ class StockWarehouse(models.Model): comodel_name="stock.rule", string="RMA Supplier Out Rule" ) - @api.multi def _get_rma_types(self): return [ self.rma_cust_out_type_id, @@ -50,16 +49,14 @@ class StockWarehouse(models.Model): self.rma_sup_in_type_id, ] - @api.multi def _rma_types_available(self): self.ensure_one() rma_types = self._get_rma_types() - for type in rma_types: - if not type: + for r_type in rma_types: + if not r_type: return False return True - @api.multi def write(self, vals): if "rma_in_this_wh" in vals: if vals.get("rma_in_this_wh"): @@ -78,16 +75,16 @@ class StockWarehouse(models.Model): if not wh._rma_types_available(): wh._create_rma_picking_types() else: - for type in wh._get_rma_types(): - if type: - type.active = True + for r_type in wh._get_rma_types(): + if r_type: + r_type.active = True # RMA rules: wh._create_or_update_rma_pull() else: for wh in self: - for type in wh._get_rma_types(): - if type: - type.active = False + for r_type in wh._get_rma_types(): + if r_type: + r_type.active = False # Unlink rules: self.mapped("rma_customer_in_pull_id").unlink() self.mapped("rma_customer_out_pull_id").unlink() @@ -174,7 +171,6 @@ class StockWarehouse(models.Model): ) return True - @api.multi def get_rma_rules_dict(self): self.ensure_one() rma_rules = dict() diff --git a/rma/report/rma_report_templates.xml b/rma/report/rma_report_templates.xml index 9771691c..39617ee4 100644 --- a/rma/report/rma_report_templates.xml +++ b/rma/report/rma_report_templates.xml @@ -6,7 +6,7 @@
-
+
Shipping address:
@@ -28,7 +28,7 @@

VAT:

-
+
Customer: Supplier:
-

+

-
+
Origin Reference:

-
+
Date Ordered:

-
+
Contact Person:

-
+
Operation:

@@ -108,7 +108,7 @@
-
+
Shipping address:
@@ -130,7 +130,7 @@

VAT:

-
+
Customer: Supplier:
-

+

-
+
Reference:

-
+
Date Ordered:

-
+
Contact Person:

diff --git a/rma/security/ir.model.access.csv b/rma/security/ir.model.access.csv old mode 100755 new mode 100644 diff --git a/rma/security/rma.xml b/rma/security/rma.xml old mode 100755 new mode 100644 index 340a019f..d0ea0ffc --- a/rma/security/rma.xml +++ b/rma/security/rma.xml @@ -4,7 +4,7 @@ RMA - + 30 diff --git a/rma/tests/__init__.py b/rma/tests/__init__.py index a708954b..f0f79f13 100644 --- a/rma/tests/__init__.py +++ b/rma/tests/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import test_rma diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 27e5d827..d85b670b 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -1,4 +1,4 @@ -# © 2017 Eficent Business and IT Consulting Services S.L. +# © 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo.exceptions import ValidationError @@ -19,33 +19,21 @@ class TestRma(common.SavepointCase): cls.rma = cls.env["rma.order"] cls.rma_line = cls.env["rma.order.line"] cls.rma_op = cls.env["rma.operation"] + cls.product_product_model = cls.env["product.product"] cls.rma_cust_replace_op_id = cls.env.ref("rma.rma_operation_customer_replace") cls.rma_sup_replace_op_id = cls.env.ref("rma.rma_operation_supplier_replace") cls.rma_ds_replace_op_id = cls.env.ref("rma.rma_operation_ds_replace") - cls.product_id = cls.env.ref("product.product_product_4") - cls.product_1 = cls.env.ref("product.product_product_25") - cls.product_2 = cls.env.ref("product.product_product_22") - cls.product_3 = cls.env.ref("product.product_product_20") + cls.category = cls._create_product_category( + "one_step", cls.rma_cust_replace_op_id, cls.rma_sup_replace_op_id + ) + cls.product_id = cls._create_product("PT0") + cls.product_1 = cls._create_product("PT1") + cls.product_2 = cls._create_product("PT2") + cls.product_3 = cls._create_product("PT3") cls.uom_unit = cls.env.ref("uom.product_uom_unit") - # assign an operation - cls.product_1.write( - { - "rma_customer_operation_id": cls.rma_cust_replace_op_id.id, - "rma_supplier_operation_id": cls.rma_sup_replace_op_id.id, - } - ) - cls.product_2.write( - { - "rma_customer_operation_id": cls.rma_cust_replace_op_id.id, - "rma_supplier_operation_id": cls.rma_sup_replace_op_id.id, - } - ) - cls.product_3.write( - { - "rma_customer_operation_id": cls.rma_cust_replace_op_id.id, - "rma_supplier_operation_id": cls.rma_sup_replace_op_id.id, - } - ) + cls.env.user.company_id.group_rma_delivery_address = True + cls.env.user.company_id.group_rma_lines = True + cls.partner_id = cls.env.ref("base.res_partner_2") cls.stock_location = cls.env.ref("stock.stock_location_stock") wh = cls.env.ref("stock.warehouse0") @@ -71,6 +59,25 @@ class TestRma(common.SavepointCase): products2move, "supplier", cls.env.ref("base.res_partner_2"), dropship=False ) + @classmethod + def _create_product_category( + cls, rma_approval_policy, rma_customer_operation_id, rma_supplier_operation_id + ): + return cls.env["product.category"].create( + { + "name": "Test category", + "rma_approval_policy": rma_approval_policy, + "rma_customer_operation_id": rma_customer_operation_id.id, + "rma_supplier_operation_id": rma_supplier_operation_id.id, + } + ) + + @classmethod + def _create_product(cls, name): + return cls.product_product_model.create( + {"name": name, "categ_id": cls.category.id, "type": "product"} + ) + @classmethod def _create_picking(cls, partner): return cls.stockpicking.create( @@ -84,12 +91,12 @@ class TestRma(common.SavepointCase): @classmethod def _create_rma_from_move( - cls, products2move, type, partner, dropship, supplier_address_id=None + cls, products2move, r_type, partner, dropship, supplier_address_id=None ): picking_in = cls._create_picking(partner) moves = [] - if type == "customer": + if r_type == "customer": for item in products2move: move_values = cls._prepare_move( item[0], @@ -113,26 +120,24 @@ class TestRma(common.SavepointCase): rma_id = cls.rma.create( { "reference": "0001", - "type": type, + "type": r_type, "partner_id": partner.id, "company_id": cls.env.ref("base.main_company").id, } ) for move in moves: - if type == "customer": + if r_type == "customer": wizard = cls.rma_add_stock_move.new( { - "stock_move_id": move.id, - "customer": True, - "active_ids": rma_id.id, + "move_ids": [(4, move.id)], "rma_id": rma_id.id, "partner_id": move.partner_id.id, - "active_model": "rma.order", } ) wizard.with_context( { - "stock_move_id": move.id, + "move_ids": [(4, move.id)], + "reference_move_id": move.id, "customer": True, "active_ids": rma_id.id, "partner_id": move.partner_id.id, @@ -142,45 +147,26 @@ class TestRma(common.SavepointCase): data = wizard.with_context( customer=1 )._prepare_rma_line_from_stock_move(move) - wizard.add_lines() - - if move.product_id.rma_customer_operation_id: - move.product_id.rma_customer_operation_id.in_route_id = False - move.product_id.categ_id.rma_customer_operation_id = False - move.product_id.rma_customer_operation_id = False - wizard._prepare_rma_line_from_stock_move(move) else: wizard = cls.rma_add_stock_move.new( { - "stock_move_id": move.id, - "supplier": True, - "active_ids": rma_id.id, + "move_ids": [(4, move.id)], "rma_id": rma_id.id, "partner_id": move.partner_id.id, - "active_model": "rma.order", } ) wizard.with_context( { - "stock_move_id": move.id, - "supplier": True, + "move_ids": [(4, move.id)], + "reference_move_id": move.id, "active_ids": rma_id.id, "partner_id": move.partner_id.id, "active_model": "rma.order", } ).default_get([str(move.id), str(cls.partner_id.id)]) - data = wizard.with_context( - customer=1 - )._prepare_rma_line_from_stock_move(move) - wizard.add_lines() - - if move.product_id.rma_customer_operation_id: - move.product_id.rma_customer_operation_id.in_route_id = False - move.product_id.categ_id.rma_supplier_operation_id = False - move.product_id.rma_supplier_operation_id = False - wizard._prepare_rma_line_from_stock_move(move) - + data = wizard._prepare_rma_line_from_stock_move(move) + data["type"] = "supplier" if dropship: data.update( customer_to_supplier=dropship, @@ -188,8 +174,9 @@ class TestRma(common.SavepointCase): supplier_address_id=supplier_address_id.id, ) cls.line = cls.rma_line.create(data) + cls.line._onchange_product_id() + cls.line._onchange_operation_id() cls.line.action_rma_to_approve() - cls.line.action_rma_approve() rma_id._get_default_type() rma_id._compute_in_shipment_count() rma_id._compute_out_shipment_count() @@ -205,19 +192,40 @@ class TestRma(common.SavepointCase): @classmethod def _prepare_move(cls, product, qty, src, dest, picking_in): - res = { - "partner_id": cls.partner_id.id, + location_id = src.id + + return { + "name": product.name, + "partner_id": picking_in.partner_id.id, + "origin": picking_in.name, + "company_id": picking_in.picking_type_id.warehouse_id.company_id.id, "product_id": product.id, - "name": product.partner_ref, - "state": "confirmed", - "product_uom": cls.product_uom_id.id or product.uom_id.id, + "product_uom": product.uom_id.id, + "state": "draft", "product_uom_qty": qty, - "origin": "Test RMA", - "location_id": src.id, + "location_id": location_id, "location_dest_id": dest.id, + "move_line_ids": [ + ( + 0, + 0, + { + "product_id": product.id, + "product_uom_id": product.uom_id.id, + "qty_done": qty, + "location_id": location_id, + "location_dest_id": dest.id, + "package_id": False, + "owner_id": False, + "lot_id": False, + }, + ) + ], "picking_id": picking_in.id, } - return res + + def _check_equal_quantity(self, qty1, qty2, msg): + self.assertEquals(qty1, qty2, msg) def test_01_rma_order_line(self): for line in self.rma_customer_id.rma_line_ids: @@ -225,54 +233,35 @@ class TestRma(common.SavepointCase): {"default_rma_id": line.rma_id.id} )._default_warehouse_id() line._default_location_id() - line.with_context( - {"partner_id": line.rma_id.partner_id.id} - )._default_delivery_address() + line._onchange_delivery_address() line._compute_in_shipment_count() line._compute_out_shipment_count() - data = {"reference_move_id": line.reference_move_id.id} - new_line = self.rma_line.new(data) - new_line._onchange_reference_move_id() - # check assert if call reference_move_id onchange - self.assertEquals(new_line.product_id, line.reference_move_id.product_id) + self.assertEquals(line.product_id, line.reference_move_id.product_id) + self.assertEquals(line.product_qty, line.reference_move_id.product_uom_qty) self.assertEquals( - new_line.product_qty, line.reference_move_id.product_uom_qty + line.location_id.location_id, line.reference_move_id.location_id + ) + self.assertEquals(line.origin, line.reference_move_id.picking_id.name) + self.assertEquals( + line.delivery_address_id, line.reference_move_id.picking_partner_id ) self.assertEquals( - new_line.location_id.location_id, line.reference_move_id.location_id + line.qty_to_receive, line.reference_move_id.product_uom_qty ) - self.assertEquals(new_line.origin, line.reference_move_id.picking_id.name) - self.assertEquals( - new_line.delivery_address_id, line.reference_move_id.picking_partner_id - ) - self.assertEquals( - new_line.qty_to_receive, line.reference_move_id.product_uom_qty - ) - - line.action_rma_to_approve() - line.action_rma_draft() - line.action_rma_done() - - data = {"product_id": line.product_id.id} - new_line = self.rma_line.new(data) - new_line._onchange_product_id() - - data = {"operation_id": line.operation_id.id} - new_line = self.rma_line.new(data) - new_line._onchange_operation_id() - + line._onchange_product_id() + line._onchange_operation_id() # check assert if call operation_id onchange - self.assertEquals(new_line.operation_id.receipt_policy, line.receipt_policy) + self.assertEquals(line.operation_id.receipt_policy, line.receipt_policy) data = {"customer_to_supplier": line.customer_to_supplier} - new_line = self.rma_line.new(data) - new_line._onchange_receipt_policy() + line = self.rma_line.new(data) + line._onchange_receipt_policy() data = {"lot_id": line.lot_id.id} - new_line = self.rma_line.new(data) - new_line._onchange_lot_id() + line = self.rma_line.new(data) + line._onchange_lot_id() line.action_view_in_shipments() line.action_view_out_shipments() @@ -285,6 +274,7 @@ class TestRma(common.SavepointCase): self.rma_customer_id.action_view_supplier_lines() def test_02_customer_rma(self): + self.rma_customer_id.rma_line_ids.action_rma_to_approve() wizard = self.rma_make_picking.with_context( { "active_ids": self.rma_customer_id.rma_line_ids.ids, @@ -295,45 +285,104 @@ class TestRma(common.SavepointCase): ).create({}) wizard._create_picking() res = self.rma_customer_id.rma_line_ids.action_view_in_shipments() - self.assertTrue("res_id" in res, "Incorrect number of pickings created") + self.assertTrue("res_id" in res, "Incorrect number of pickings" "created") picking = self.env["stock.picking"].browse(res["res_id"]) self.assertEquals(len(picking), 1, "Incorrect number of pickings created") moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") - for line in self.rma_customer_id.rma_line_ids: - # common qtys for all products - self.assertEquals(line.qty_received, 0, "Wrong qty received") - self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing") - self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered") - # product specific - if line.product_id == self.product_1: - self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 3, "Wrong qty incoming") - if line.product_id == self.product_2: - self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 5, "Wrong qty incoming") - if line.product_id == self.product_3: - self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 2, "Wrong qty incoming") + lines = self.rma_customer_id.rma_line_ids + self.assertEquals( + list(set(lines.mapped("qty_received"))), [0], "Wrong qty received" + ) + self.assertEquals( + list(set(lines.mapped("qty_to_deliver"))), [0], "Wrong qty to deliver" + ) + self.assertEquals( + list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty outgoing" + ) + self.assertEquals( + list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered" + ) + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive, + 3, + "Wrong qty to receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_incoming, + 3, + "Wrong qty incoming", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive, + 5, + "Wrong qty to receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_incoming, + 5, + "Wrong qty incoming", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive, + 2, + "Wrong qty to receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_incoming, + 2, + "Wrong qty incoming", + ) + picking.action_assign() for mv in picking.move_lines: mv.quantity_done = mv.product_uom_qty picking.action_done() - for line in self.rma_customer_id.rma_line_ids: - self.assertEquals(line.qty_to_receive, 0, "Wrong qty to_receive") - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing") - self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered") - if line.product_id == self.product_1: - self.assertEquals(line.qty_received, 3, "Wrong qty received") - self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to_deliver") - if line.product_id == self.product_2: - self.assertEquals(line.qty_received, 5, "Wrong qty received") - self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to_deliver") - if line.product_id == self.product_3: - self.assertEquals(line.qty_received, 2, "Wrong qty received") - self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to_deliver") + lines = self.rma_customer_id.rma_line_ids + self.assertEquals( + list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive" + ) + self.assertEquals( + list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming" + ) + self.assertEquals( + list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty outgoing" + ) + self.assertEquals( + list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered" + ) + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_received, + 3, + "Wrong qty received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver, + 3, + "Wrong qty to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_received, + 5, + "Wrong qty received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver, + 5, + "Wrong qty to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_received, + 2, + "Wrong qty received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver, + 2, + "Wrong qty to_deliver", + ) wizard = self.rma_make_picking.with_context( { @@ -345,46 +394,102 @@ class TestRma(common.SavepointCase): ).create({}) wizard._create_picking() res = self.rma_customer_id.rma_line_ids.action_view_out_shipments() - self.assertTrue("res_id" in res, "Incorrect number of pickings created") + self.assertTrue("res_id" in res, "Incorrect number of pickings" "created") picking = self.env["stock.picking"].browse(res["res_id"]) moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") - for line in self.rma_customer_id.rma_line_ids: - self.assertEquals(line.qty_to_receive, 0, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered") - if line.product_id == self.product_1: - self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing") - self.assertEquals(line.qty_received, 3, "Wrong qty received") - if line.product_id == self.product_2: - self.assertEquals(line.qty_received, 5, "Wrong qty received") - self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 5, "Wrong qty outgoing") - if line.product_id == self.product_3: - self.assertEquals(line.qty_received, 2, "Wrong qty received") - self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 2, "Wrong qty outgoing") + lines = self.rma_customer_id.rma_line_ids + self.assertEquals( + list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive" + ) + self.assertEquals( + list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming" + ) + self.assertEquals( + list(set(lines.mapped("qty_delivered"))), [0], "Wrong qty delivered" + ) + + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver, + 3, + "Wrong qty to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_outgoing, + 3, + "Wrong qty outgoing", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver, + 5, + "Wrong qty to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_outgoing, + 5, + "Wrong qty outgoing", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver, + 2, + "Wrong qty to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_outgoing, + 2, + "Wrong qty outgoing", + ) + picking.action_assign() for mv in picking.move_lines: mv.quantity_done = mv.product_uom_qty picking.action_done() - for line in self.rma_customer_id.rma_line_ids: - self.assertEquals(line.qty_to_receive, 0, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 0, "Wrong qty outgoing") - if line.product_id == self.product_1: - self.assertEquals(line.qty_received, 3, "Wrong qty received") - self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered") - if line.product_id == self.product_2: - self.assertEquals(line.qty_received, 5, "Wrong qty received") - self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered") - if line.product_id == self.product_3: - self.assertEquals(line.qty_received, 2, "Wrong qty received") - self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered") - self.line.action_rma_done() - self.assertEquals(self.line.state, "done", "Wrong State") + lines = self.rma_customer_id.rma_line_ids + self.assertEquals( + list(set(lines.mapped("qty_to_receive"))), [0], "Wrong qty to_receive" + ) + self.assertEquals( + list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty incoming" + ) + self.assertEquals( + list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing" + ) + + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_received, + 3, + "Wrong qty_received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered, + 3, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_received, + 5, + "Wrong qty_received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered, + 5, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_received, + 2, + "Wrong qty_received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered, + 2, + "Wrong qty_delivered", + ) + + self.line.action_rma_done() + self.assertEquals(self.line.state, "done", "Wrong State") self.rma_customer_id.action_view_in_shipments() self.rma_customer_id.action_view_out_shipments() self.rma_customer_id.action_view_lines() @@ -392,9 +497,11 @@ class TestRma(common.SavepointCase): # DROPSHIP def test_03_dropship(self): for line in self.rma_droship_id.rma_line_ids: + line.operation_id = self.rma_ds_replace_op_id + line._onchange_operation_id() + line._onchange_delivery_address() line.action_rma_to_approve() line.action_rma_approve() - line._onchange_operation_id() wizard = self.rma_make_picking.with_context( { "active_id": 1, @@ -405,7 +512,7 @@ class TestRma(common.SavepointCase): ).create({}) wizard._create_picking() res = self.rma_droship_id.rma_line_ids.action_view_in_shipments() - self.assertTrue("res_id" in res, "Incorrect number of pickings created") + self.assertTrue("res_id" in res, "Incorrect number of pickings" "created") picking = self.env["stock.picking"].browse(res["res_id"]) self.assertEquals(len(picking), 1, "Incorrect number of pickings created") moves = picking.move_lines @@ -419,96 +526,184 @@ class TestRma(common.SavepointCase): ).create({}) res = wizard.make_supplier_rma() supplier_rma = self.rma.browse(res["res_id"]) - for line in supplier_rma.rma_line_ids: - # common qtys for all products - self.assertEquals(line.qty_received, 0, "Wrong qty received") - self.assertEquals(line.qty_outgoing, 0, "Wrong qty incoming") - self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered") - # product specific - if line.product_id == self.product_1: - self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver") - if line.product_id == self.product_2: - self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to deliver") - if line.product_id == self.product_3: - self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to deliver") + lines = supplier_rma.rma_line_ids + self.assertEquals( + list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received" + ) + self.assertEquals( + list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing" + ) + self.assertEquals( + list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered" + ) + + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver, + 3, + "Wrong qty_to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver, + 5, + "Wrong qty_to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver, + 2, + "Wrong qty_to_deliver", + ) + + lines = self.rma_droship_id.rma_line_ids + self._check_equal_quantity( + lines.filtered( + lambda l: l.product_id == self.product_1 + ).qty_in_supplier_rma, + 3, + "Wrong qty_in_supplier_rma", + ) + self._check_equal_quantity( + lines.filtered( + lambda l: l.product_id == self.product_2 + ).qty_in_supplier_rma, + 5, + "Wrong qty_in_supplier_rma", + ) + self._check_equal_quantity( + lines.filtered( + lambda l: l.product_id == self.product_3 + ).qty_in_supplier_rma, + 2, + "Wrong qty_in_supplier_rma", + ) + + self.assertEquals( + list(set(lines.mapped("qty_to_supplier_rma"))), + [0], + "Wrong qty_to_supplier_rma", + ) - for line in self.rma_droship_id.rma_line_ids: - if line.product_id == self.product_1: - self.assertEquals( - line.qty_to_supplier_rma, 0, "Wrong qty to supplier rma" - ) - self.assertEquals( - line.qty_in_supplier_rma, 3, "Wrong qty in supplier rma" - ) - if line.product_id == self.product_2: - self.assertEquals( - line.qty_to_supplier_rma, 0, "Wrong qty to supplier rma" - ) - self.assertEquals( - line.qty_in_supplier_rma, 5, "Wrong qty in supplier rma" - ) - if line.product_id == self.product_3: - self.assertEquals( - line.qty_to_supplier_rma, 0, "Wrong qty to supplier rma" - ) - self.assertEquals( - line.qty_in_supplier_rma, 2, "Wrong qty in supplier rma" - ) for line in self.rma_droship_id.rma_line_ids: line.action_rma_done() - self.assertEquals(line.state, "done", "Wrong State") + + self.assertEquals(line.mapped("state"), ["done"], "Wrong State") # Supplier RMA def test_04_supplier_rma(self): + self.rma_supplier_id.rma_line_ids.action_rma_to_approve() + self.rma_supplier_id.rma_line_ids.operation_id = self.rma_sup_replace_op_id + self.rma_supplier_id.rma_line_ids._onchange_operation_id() + self.rma_supplier_id.rma_line_ids._onchange_delivery_address() wizard = self.rma_make_picking.with_context( { "active_ids": self.rma_supplier_id.rma_line_ids.ids, "active_model": "rma.order.line", "picking_type": "outgoing", - "active_id": 1, + "active_id": 2, } ).create({}) wizard._create_picking() res = self.rma_supplier_id.rma_line_ids.action_view_out_shipments() - self.assertTrue("res_id" in res, "Incorrect number of pickings created") + self.assertTrue("res_id" in res, "Incorrect number of pickings" "created") picking = self.env["stock.picking"].browse(res["res_id"]) moves = picking.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") - for line in self.rma_supplier_id.rma_line_ids: - # common qtys for all products - self.assertEquals(line.qty_received, 0, "Wrong qty received") - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_delivered, 0, "Wrong qty delivered") - # product specific - if line.product_id == self.product_1: - self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") - self.assertEquals(line.qty_to_deliver, 3, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing") - if line.product_id == self.product_2: - self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive") - self.assertEquals(line.qty_to_deliver, 5, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 5, "Wrong qty outgoing") - if line.product_id == self.product_3: - self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive") - self.assertEquals(line.qty_to_deliver, 2, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 2, "Wrong qty outgoing") + lines = self.rma_supplier_id.rma_line_ids + self.assertEquals( + list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received" + ) + self.assertEquals( + list(set(lines.mapped("qty_delivered"))), [0], "qty_delivered" + ) + + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive, + 3, + "Wrong qty_to_receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_deliver, + 3, + "Wrong qty_to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive, + 5, + "Wrong qty_to_receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_to_deliver, + 5, + "Wrong qty_to_deliver", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive, + 2, + "Wrong qty_to_receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_to_deliver, + 2, + "Wrong qty_to_deliver", + ) + self.assertEquals( + list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming" + ) picking.action_assign() for mv in picking.move_lines: mv.quantity_done = mv.product_uom_qty picking.action_done() - for line in self.rma_supplier_id.rma_line_ids: - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_received, 0, "Wrong qty received") - if line.product_id == self.product_1: - self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered") - self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") - if line.product_id == self.product_2: - self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered") - self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive") - if line.product_id == self.product_3: - self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered") - self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive") + + self.assertEquals( + list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming" + ) + self.assertEquals( + list(set(lines.mapped("qty_to_deliver"))), [0], "Wrong qty_to_deliver" + ) + self.assertEquals( + list(set(lines.mapped("qty_received"))), [0], "Wrong qty_received" + ) + self.assertEquals(list(set(lines.mapped("qty_outgoing"))), [0], "qty_outgoing") + + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered, + 3, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive, + 3, + "Wrong qty_to_receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_received, + 0, + "Wrong qty_received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered, + 5, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_received, + 0, + "Wrong qty_received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered, + 2, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_received, + 0, + "Wrong qty_received", + ) + wizard = self.rma_make_picking.with_context( { "active_id": 1, @@ -519,41 +714,81 @@ class TestRma(common.SavepointCase): ).create({}) wizard._create_picking() res = self.rma_supplier_id.rma_line_ids.action_view_in_shipments() - self.assertTrue("res_id" in res, "Incorrect number of pickings created") + self.assertTrue("res_id" in res, "Incorrect number of pickings" "created") pickings = self.env["stock.picking"].browse(res["res_id"]) self.assertEquals(len(pickings), 1, "Incorrect number of pickings created") - picking_out = pickings[0] - moves = picking_out.move_lines + picking_in = pickings[0] + moves = picking_in.move_lines self.assertEquals(len(moves), 3, "Incorrect number of moves created") - for line in self.rma_supplier_id.rma_line_ids: - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_received, 0, "Wrong qty received") - self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver") - if line.product_id == self.product_1: - self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - if line.product_id == self.product_2: - self.assertEquals(line.qty_to_receive, 5, "Wrong qty to receive") - if line.product_id == self.product_3: - self.assertEquals(line.qty_to_receive, 2, "Wrong qty to receive") - picking_out.action_assign() - for mv in picking.move_lines: - mv.quantity_done = mv.product_uom_qty - picking_out.action_done() - for line in self.rma_supplier_id.rma_line_ids[0]: - self.assertEquals(line.qty_to_receive, 3, "Wrong qty to receive") - self.assertEquals(line.qty_incoming, 0, "Wrong qty incoming") - self.assertEquals(line.qty_to_deliver, 0, "Wrong qty to deliver") - self.assertEquals(line.qty_outgoing, 3, "Wrong qty outgoing") - if line.product_id == self.product_1: - self.assertEquals(line.qty_received, 0, "Wrong qty received") - self.assertEquals(line.qty_delivered, 3, "Wrong qty delivered") - if line.product_id == self.product_2: - self.assertEquals(line.qty_received, 0, "Wrong qty received") - self.assertEquals(line.qty_delivered, 5, "Wrong qty delivered") - if line.product_id == self.product_3: - self.assertEquals(line.qty_received, 2, "Wrong qty received") - self.assertEquals(line.qty_delivered, 2, "Wrong qty delivered") + + lines = self.rma_supplier_id.rma_line_ids + self.assertEquals( + list(set(lines.mapped("qty_to_deliver"))), [0], "qty_to_deliver" + ) + + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_to_receive, + 3, + "Wrong qty_to_receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_to_receive, + 5, + "Wrong qty_to_receive", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_to_receive, + 2, + "Wrong qty_to_receive", + ) + + picking_in.action_confirm() + picking_in.action_assign() + for mv in picking_in.move_line_ids: + mv.qty_done = mv.product_uom_qty + picking_in.action_done() + self.assertEquals( + list(set(lines.mapped("qty_outgoing"))), [0], "Wrong qty_outgoing" + ) + self.assertEquals( + list(set(lines.mapped("qty_incoming"))), [0], "Wrong qty_incoming" + ) + self.assertEquals( + list(set(lines.mapped("qty_to_deliver"))), [0], "qty_to_deliver" + ) + + # product specific + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_delivered, + 3, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_1).qty_received, + 3, + "Wrong qty_received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_delivered, + 5, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_2).qty_received, + 5, + "Wrong qty_received", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_delivered, + 2, + "Wrong qty_delivered", + ) + self._check_equal_quantity( + lines.filtered(lambda l: l.product_id == self.product_3).qty_received, + 2, + "Wrong qty_received", + ) for line in self.rma_supplier_id.rma_line_ids: line.action_rma_done() - self.assertEquals(line.state, "done", "Wrong State") + self.assertEquals(line.mapped("state"), ["done"], "Wrong State") diff --git a/rma/views/product_view.xml b/rma/views/product_view.xml old mode 100755 new mode 100644 diff --git a/rma/views/res_partner_view.xml b/rma/views/res_partner_view.xml old mode 100755 new mode 100644 index 19b34670..64ad3fa6 --- a/rma/views/res_partner_view.xml +++ b/rma/views/res_partner_view.xml @@ -11,7 +11,7 @@ name="action_open_partner_rma" class="oe_stat_button" icon="fa-eject" - attrs="{'invisible':[('customer', '=', False)]}" + context="{'res_partner_search_mode': 'customer'}" groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"> diff --git a/rma/views/rma_operation_view.xml b/rma/views/rma_operation_view.xml old mode 100755 new mode 100644 index e3fa2c54..46f0f840 --- a/rma/views/rma_operation_view.xml +++ b/rma/views/rma_operation_view.xml @@ -63,7 +63,6 @@ Customer Operations rma.operation - form tree,form {'default_type': "customer"} [('type','=', 'customer')] @@ -73,7 +72,6 @@ Supplier Operations rma.operation - form tree,form {'default_type': "supplier"} [('type','=', 'supplier')] diff --git a/rma/views/rma_order_line_view.xml b/rma/views/rma_order_line_view.xml old mode 100755 new mode 100644 index 49de1218..3d008831 --- a/rma/views/rma_order_line_view.xml +++ b/rma/views/rma_order_line_view.xml @@ -97,10 +97,17 @@ invisible="context.get('hide_title',False)"/>
- - + + + + + @@ -126,21 +133,21 @@ ('state', '=', 'done')]"/> - - - - + + + + + + + - - - @@ -151,12 +158,6 @@ - - - + @@ -299,20 +304,22 @@ ('state', '=', 'done')]"/> - - - - + + + + + + + + + - - - @@ -328,12 +335,6 @@ - @@ -425,7 +426,6 @@ rma.order.line [('type','=', 'customer')] {"search_default_assigned_to":uid} - form tree,form @@ -435,7 +435,6 @@ rma.order.line [('type','=', 'supplier')] {"search_default_assigned_to":uid, "supplier":1} - form tree,form diff --git a/rma/views/rma_order_view.xml b/rma/views/rma_order_view.xml old mode 100755 new mode 100644 index 6f089e84..9307f952 --- a/rma/views/rma_order_view.xml +++ b/rma/views/rma_order_view.xml @@ -67,26 +67,24 @@

- +

- - - - - - - - - - - - + + + + + + + + + + @@ -98,6 +96,15 @@ 'invisible':[('customer_to_supplier', '=', False)], 'readonly':[('state', '!=', 'draft')]}"/> + + + + + + + + - - - - - - - -
@@ -168,38 +165,44 @@

- +

- - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + @@ -224,16 +227,6 @@ - - - - - - - - -
@@ -266,7 +259,6 @@ Customer RMA Group rma.order - form [('type','=', 'customer')] {'customer':1} tree,form @@ -276,7 +268,6 @@ Supplier RMA Group rma.order - form [('type','=', 'supplier')] {'supplier':1} tree,form diff --git a/rma/views/stock_view.xml b/rma/views/stock_view.xml old mode 100755 new mode 100644 index 831a82d1..e8d4655f --- a/rma/views/stock_view.xml +++ b/rma/views/stock_view.xml @@ -13,19 +13,6 @@ - - stock.move.form - stock.move - - - - - - - - - - stock.location.route.form diff --git a/rma/views/stock_warehouse.xml b/rma/views/stock_warehouse.xml old mode 100755 new mode 100644 diff --git a/rma/wizards/__init__.py b/rma/wizards/__init__.py index 7fa8500f..9d547fa8 100644 --- a/rma/wizards/__init__.py +++ b/rma/wizards/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import rma_add_stock_move diff --git a/rma/wizards/rma_add_stock_move.py b/rma/wizards/rma_add_stock_move.py index 810a8bdb..6813a22e 100644 --- a/rma/wizards/rma_add_stock_move.py +++ b/rma/wizards/rma_add_stock_move.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import _, api, fields, models @@ -106,7 +106,6 @@ class RmaAddStockMove(models.TransientModel): existing_move_lines.append(rma_line.reference_move_id) return existing_move_lines - @api.multi def add_lines(self): rma_line_obj = self.env["rma.order.line"] existing_stock_moves = self._get_existing_stock_moves() diff --git a/rma/wizards/rma_add_stock_move_view.xml b/rma/wizards/rma_add_stock_move_view.xml old mode 100755 new mode 100644 index 84e6f9d2..f7512c4a --- a/rma/wizards/rma_add_stock_move_view.xml +++ b/rma/wizards/rma_add_stock_move_view.xml @@ -18,7 +18,6 @@ - @@ -46,8 +45,6 @@ Add from Stock Move ir.actions.act_window rma_add_stock_move - rma.order - form form new @@ -100,8 +97,6 @@ Add from Stock Move ir.actions.act_window rma_add_stock_move - rma.order - form form new diff --git a/rma/wizards/rma_make_picking.py b/rma/wizards/rma_make_picking.py index 0d53cb7c..d07101ce 100644 --- a/rma/wizards/rma_make_picking.py +++ b/rma/wizards/rma_make_picking.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) import time @@ -7,8 +7,6 @@ from odoo import _, api, fields, models from odoo.exceptions import UserError, ValidationError from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT -import odoo.addons.decimal_precision as dp - class RmaMakePicking(models.TransientModel): _name = "rma_make_picking.wizard" @@ -95,10 +93,10 @@ class RmaMakePicking(models.TransientModel): return delivery_address @api.model - def _get_address_location(self, delivery_address_id, type): - if type == "supplier": + def _get_address_location(self, delivery_address_id, a_type): + if a_type == "supplier": return delivery_address_id.property_stock_supplier - elif type == "customer": + elif a_type == "customer": return delivery_address_id.property_stock_customer @api.model @@ -150,27 +148,33 @@ class RmaMakePicking(models.TransientModel): else: qty = item.qty_to_deliver values = self._get_procurement_data(item, group, qty, picking_type) + values = dict(values, rma_line_id=item.line_id, rma_id=item.line_id.rma_id) # create picking + procurements = [] try: - self.env["procurement.group"].run( + procurement = group.Procurement( item.line_id.product_id, qty, item.line_id.product_id.product_tmpl_id.uom_id, values.get("location_id"), values.get("origin"), values.get("origin"), + self.env.company, values, ) + + procurements.append(procurement) + self.env["procurement.group"].run(procurements) except UserError as error: errors.append(error.name) if errors: raise UserError("\n".join(errors)) - return values.get("origin") + return procurements - @api.multi def _create_picking(self): """Method called when the user clicks on create picking""" picking_type = self.env.context.get("picking_type") + procurements = [] for item in self.item_ids: line = item.line_id if line.state != "approved": @@ -180,43 +184,18 @@ class RmaMakePicking(models.TransientModel): if line.delivery_policy == "no" and picking_type == "outgoing": raise ValidationError(_("No deliveries needed for this operation")) procurement = self._create_procurement(item, picking_type) - return procurement + procurements.extend(procurement) + return procurements - @api.model - def _get_action(self, pickings, procurements): - if pickings and procurements: - action = procurements.do_view_pickings() - else: - action = self.env.ref("procurement.procurement_order_action_exceptions") - action = action.read()[0] - if procurements: - # choose the view_mode accordingly - if len(procurements.ids) <= 1: - res = self.env.ref("procurement.procurement_form_view", False) - action["views"] = [(res and res.id or False, "form")] - action["res_id"] = procurements.ids[0] - else: - action["domain"] = [("id", "in", procurements.ids)] - return action - - @api.multi def action_create_picking(self): - procurement = self._create_picking() - action = self.env.ref("stock.do_view_pickings") - action = action.read()[0] - if procurement: - pickings = ( - self.env["stock.picking"].search([("origin", "=", procurement)]).ids - ) - if len(pickings) > 1: - action["domain"] = [("id", "in", pickings)] - 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] + self._create_picking() + picking_type = self.env.context.get("picking_type") + if picking_type == "outgoing": + action = self.item_ids.line_id.action_view_out_shipments() + else: + action = self.item_ids.line_id.action_view_in_shipments() return action - @api.multi def action_cancel(self): return {"type": "ir.actions.act_window_close"} @@ -237,13 +216,13 @@ class RmaMakePickingItem(models.TransientModel): related="line_id.product_qty", string="Quantity Ordered", copy=False, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, ) qty_to_receive = fields.Float( - string="Quantity to Receive", digits=dp.get_precision("Product Unit of Measure") + string="Quantity to Receive", digits="Product Unit of Measure" ) qty_to_deliver = fields.Float( - string="Quantity To Deliver", digits=dp.get_precision("Product Unit of Measure") + string="Quantity To Deliver", digits="Product Unit of Measure" ) uom_id = fields.Many2one("uom.uom", string="Unit of Measure", readonly=True) diff --git a/rma/wizards/rma_make_picking_view.xml b/rma/wizards/rma_make_picking_view.xml old mode 100755 new mode 100644 index dbb2dc5d..b9aee580 --- a/rma/wizards/rma_make_picking_view.xml +++ b/rma/wizards/rma_make_picking_view.xml @@ -61,7 +61,6 @@ Create Incoming Shipment ir.actions.act_window rma_make_picking.wizard - form form new @@ -74,7 +73,6 @@ Create Delivery ir.actions.act_window rma_make_picking.wizard - form form new diff --git a/rma/wizards/rma_order_line_make_supplier_rma.py b/rma/wizards/rma_order_line_make_supplier_rma.py index 7ecc2877..eba6ea0c 100644 --- a/rma/wizards/rma_order_line_make_supplier_rma.py +++ b/rma/wizards/rma_order_line_make_supplier_rma.py @@ -1,11 +1,9 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import _, api, fields, models from odoo.exceptions import ValidationError -import odoo.addons.decimal_precision as dp - class RmaLineMakeSupplierRma(models.TransientModel): _name = "rma.order.line.make.supplier.rma" @@ -86,7 +84,6 @@ class RmaLineMakeSupplierRma(models.TransientModel): raise ValidationError(_("Enter a supplier.")) return { "partner_id": self.partner_id.id, - "delivery_address_id": self.partner_id.id, "type": "supplier", "company_id": company.id, } @@ -121,6 +118,7 @@ class RmaLineMakeSupplierRma(models.TransientModel): "origin": item.line_id.rma_id.name, "customer_address_id": item.line_id.delivery_address_id.id or item.line_id.partner_id.id, + "delivery_address_id": self.partner_id.id, "product_id": item.line_id.product_id.id, "customer_rma_id": item.line_id.id, "product_qty": item.product_qty, @@ -142,7 +140,6 @@ class RmaLineMakeSupplierRma(models.TransientModel): } return data - @api.multi def make_supplier_rma(self): self = self.with_context(supplier=True, customer=False) rma_obj = self.env["rma.order"] @@ -165,7 +162,6 @@ class RmaLineMakeSupplierRma(models.TransientModel): if rma: return { "name": _("Supplier RMA"), - "view_type": "form", "view_mode": "form", "res_model": "rma.order", "view_id": False, @@ -176,7 +172,6 @@ class RmaLineMakeSupplierRma(models.TransientModel): else: return { "name": _("Supplier RMA Line"), - "view_type": "form", "view_mode": "form", "res_model": "rma.order.line", "view_id": False, @@ -208,9 +203,7 @@ class RmaLineMakeRmaOrderItem(models.TransientModel): ) name = fields.Char(related="line_id.name", readonly=True) uom_id = fields.Many2one("uom.uom", string="UoM", readonly=True) - product_qty = fields.Float( - string="Quantity", digits=dp.get_precision("Product UoS") - ) + product_qty = fields.Float(string="Quantity", digits="Product UoS") operation_id = fields.Many2one( comodel_name="rma.operation", string="Operation", diff --git a/rma/wizards/rma_order_line_make_supplier_rma_view.xml b/rma/wizards/rma_order_line_make_supplier_rma_view.xml old mode 100755 new mode 100644 index 4670bbc2..bc9cc547 --- a/rma/wizards/rma_order_line_make_supplier_rma_view.xml +++ b/rma/wizards/rma_order_line_make_supplier_rma_view.xml @@ -1,5 +1,5 @@ - Create Supplier RMA ir.actions.act_window rma.order.line.make.supplier.rma - form form new diff --git a/rma/wizards/stock_config_settings.py b/rma/wizards/stock_config_settings.py index 5c6654aa..b2668d1a 100644 --- a/rma/wizards/stock_config_settings.py +++ b/rma/wizards/stock_config_settings.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Eficent Business and IT Consulting Services S.L. +# Copyright (C) 2017 ForgeFlow # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import fields, models @@ -7,25 +7,14 @@ from odoo import fields, models class StockConfigSettings(models.TransientModel): _inherit = "res.config.settings" - group_rma_delivery_address = fields.Selection( - [ - ( - 0, - "Invoicing and shipping addresses are always the same " - "(Example: services companies)", - ), - ( - 1, - "Display 3 fields on rma: partner, invoice address, delivery " - "address", - ), - ], - "Addresses", + group_rma_delivery_address = fields.Boolean( + related="company_id.group_rma_delivery_address", implied_group="rma.group_rma_delivery_invoice_address", + readonly=False, ) - group_rma_lines = fields.Selection( - [(0, "Do not group RMA lines"), (1, "Group RMA lines in one RMA group")], - "Grouping", + group_rma_lines = fields.Boolean( + related="company_id.group_rma_lines", + readonly=False, implied_group="rma.group_rma_groups", ) diff --git a/rma/wizards/stock_config_settings.xml b/rma/wizards/stock_config_settings.xml old mode 100755 new mode 100644 index 74c942c2..b05bdbbf --- a/rma/wizards/stock_config_settings.xml +++ b/rma/wizards/stock_config_settings.xml @@ -8,13 +8,25 @@

Return Merchandise Authorization

-
+
+
+ +
-
-
- - -
+
+
+
+
+ +
+
+