From 68a43b8bf053adab6f2f215ecd8cae5e5524965c Mon Sep 17 00:00:00 2001 From: ahenriquez Date: Mon, 9 Mar 2020 11:23:53 +0100 Subject: [PATCH] [MIG]rma_sale v13 --- rma_sale/__init__.py | 2 +- rma_sale/__manifest__.py | 6 +++--- rma_sale/models/__init__.py | 2 +- rma_sale/models/rma_operation.py | 2 +- rma_sale/models/rma_order.py | 3 +-- rma_sale/models/rma_order_line.py | 21 ++++++++----------- rma_sale/models/sale_order_line.py | 4 +--- rma_sale/tests/__init__.py | 2 +- rma_sale/tests/test_rma_sale.py | 2 +- rma_sale/wizards/__init__.py | 2 +- rma_sale/wizards/rma_add_sale.py | 16 +++++++------- rma_sale/wizards/rma_add_sale.xml | 2 -- rma_sale/wizards/rma_make_picking.py | 2 +- .../wizards/rma_order_line_make_sale_order.py | 9 ++------ .../rma_order_line_make_sale_order_view.xml | 1 - rma_sale/wizards/rma_refund.py | 2 +- 16 files changed, 31 insertions(+), 47 deletions(-) diff --git a/rma_sale/__init__.py b/rma_sale/__init__.py index 44815ecb..41d70b8d 100644 --- a/rma_sale/__init__.py +++ b/rma_sale/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import models from . import wizards diff --git a/rma_sale/__manifest__.py b/rma_sale/__manifest__.py index 12ecabfe..565a729f 100644 --- a/rma_sale/__manifest__.py +++ b/rma_sale/__manifest__.py @@ -1,13 +1,13 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) { "name": "RMA Sale", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "license": "LGPL-3", "category": "RMA", "summary": "Links RMA with Sales Orders", - "author": "Eficent, Odoo Community Association (OCA)", + "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/Eficent/stock-rma", "depends": ["rma_account", "sale_stock"], "data": [ diff --git a/rma_sale/models/__init__.py b/rma_sale/models/__init__.py index 6108253c..c0f8b897 100644 --- a/rma_sale/models/__init__.py +++ b/rma_sale/models/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import sale_order_line from . import rma_order_line diff --git a/rma_sale/models/rma_operation.py b/rma_sale/models/rma_operation.py index b981bc02..00c886c7 100644 --- a/rma_sale/models/rma_operation.py +++ b/rma_sale/models/rma_operation.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import fields, models diff --git a/rma_sale/models/rma_order.py b/rma_sale/models/rma_order.py index 383f93b4..4de2e614 100644 --- a/rma_sale/models/rma_order.py +++ b/rma_sale/models/rma_order.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models @@ -30,7 +30,6 @@ class RmaOrder(models.Model): domain = super(RmaOrder, self)._get_line_domain(rma_id, line) return domain - @api.multi def action_view_sale_order(self): action = self.env.ref("sale.action_quotations") result = action.read()[0] diff --git a/rma_sale/models/rma_order_line.py b/rma_sale/models/rma_order_line.py index c92d20f8..caf332d7 100644 --- a/rma_sale/models/rma_order_line.py +++ b/rma_sale/models/rma_order_line.py @@ -1,10 +1,8 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import _, api, fields, models from odoo.exceptions import ValidationError -from odoo.addons import decimal_precision as dp - class RmaOrderLine(models.Model): _inherit = "rma.order.line" @@ -61,7 +59,7 @@ class RmaOrderLine(models.Model): qty_to_sell = fields.Float( string="Qty To Sell", copy=False, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, compute="_compute_qty_to_sell", store=True, @@ -69,7 +67,7 @@ class RmaOrderLine(models.Model): qty_sold = fields.Float( string="Qty Sold", copy=False, - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", readonly=True, compute="_compute_qty_sold", store=True, @@ -111,7 +109,6 @@ class RmaOrderLine(models.Model): self.sale_policy = self.operation_id.sale_policy or "no" return res - @api.multi def _prepare_rma_line_from_sale_order_line(self, line): self.ensure_one() if not self.type: @@ -148,8 +145,12 @@ class RmaOrderLine(models.Model): "product_qty": line.product_uom_qty, "delivery_address_id": line.order_id.partner_id.id, "invoice_address_id": line.order_id.partner_id.id, - "price_unit": line.currency_id.compute( - line.price_unit, line.currency_id, round=False + "price_unit": line.currency_id._convert( + line.price_unit, + line.currency_id, + line.company_id, + line.order_id.date_order, + round=False, ), "in_route_id": operation.in_route_id.id or route.id, "out_route_id": operation.out_route_id.id or route.id, @@ -175,14 +176,12 @@ class RmaOrderLine(models.Model): self.update(data) self._remove_other_data_origin("sale_line_id") - @api.multi def _remove_other_data_origin(self, exception): res = super(RmaOrderLine, self)._remove_other_data_origin(exception) if not exception == "sale_line_id": self.sale_line_id = False return res - @api.multi @api.constrains("sale_line_id", "partner_id") def _check_sale_partner(self): for rec in self: @@ -198,7 +197,6 @@ class RmaOrderLine(models.Model): ) ) - @api.multi def action_view_sale_order(self): action = self.env.ref("sale.action_quotations") result = action.read()[0] @@ -206,7 +204,6 @@ class RmaOrderLine(models.Model): result["domain"] = [("id", "in", order_ids)] return result - @api.multi def _get_rma_sold_qty(self): self.ensure_one() qty = 0.0 diff --git a/rma_sale/models/sale_order_line.py b/rma_sale/models/sale_order_line.py index 811521a4..2a6e1632 100644 --- a/rma_sale/models/sale_order_line.py +++ b/rma_sale/models/sale_order_line.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models @@ -33,7 +33,6 @@ class SaleOrderLine(models.Model): name_get_uid=name_get_uid, ) - @api.multi def name_get(self): res = [] if self.env.context.get("rma"): @@ -66,7 +65,6 @@ class SaleOrderLine(models.Model): comodel_name="rma.order.line", string="RMA", ondelete="restrict" ) - @api.multi def _prepare_order_line_procurement(self, group_id=False): vals = super(SaleOrderLine, self)._prepare_order_line_procurement( group_id=group_id diff --git a/rma_sale/tests/__init__.py b/rma_sale/tests/__init__.py index fae781a4..a4340678 100644 --- a/rma_sale/tests/__init__.py +++ b/rma_sale/tests/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import test_rma_sale diff --git a/rma_sale/tests/test_rma_sale.py b/rma_sale/tests/test_rma_sale.py index 57a469b8..7cd40421 100644 --- a/rma_sale/tests/test_rma_sale.py +++ b/rma_sale/tests/test_rma_sale.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo.tests import common diff --git a/rma_sale/wizards/__init__.py b/rma_sale/wizards/__init__.py index 631e0330..57786ac8 100644 --- a/rma_sale/wizards/__init__.py +++ b/rma_sale/wizards/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import rma_order_line_make_sale_order diff --git a/rma_sale/wizards/rma_add_sale.py b/rma_sale/wizards/rma_add_sale.py index d8198640..9d4d356f 100644 --- a/rma_sale/wizards/rma_add_sale.py +++ b/rma_sale/wizards/rma_add_sale.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import _, api, fields, models @@ -80,8 +80,11 @@ class RmaAddSale(models.TransientModel): "product_qty": line.product_uom_qty, "delivery_address_id": self.sale_id.partner_id.id, "invoice_address_id": self.sale_id.partner_id.id, - "price_unit": line.currency_id.compute( - line.price_unit, line.currency_id, round=False + "price_unit": line.currency_id._convert( + line.price_unit, + line.currency_id, + line.company_id, + line.order_id.date_order, ), "rma_id": self.rma_id.id, "in_route_id": operation.in_route_id.id or route.id, @@ -101,11 +104,7 @@ class RmaAddSale(models.TransientModel): @api.model def _get_rma_data(self): - data = { - "date_rma": fields.Datetime.now(), - "delivery_address_id": self.sale_id.partner_id.id, - "invoice_address_id": self.sale_id.partner_id.id, - } + data = {"date_rma": fields.Datetime.now()} return data @api.model @@ -115,7 +114,6 @@ class RmaAddSale(models.TransientModel): existing_sale_lines.append(rma_line.sale_line_id) return existing_sale_lines - @api.multi def add_lines(self): rma_line_obj = self.env["rma.order.line"] existing_sale_lines = self._get_existing_sale_lines() diff --git a/rma_sale/wizards/rma_add_sale.xml b/rma_sale/wizards/rma_add_sale.xml index 1f0bd4d8..ada0af02 100644 --- a/rma_sale/wizards/rma_add_sale.xml +++ b/rma_sale/wizards/rma_add_sale.xml @@ -54,8 +54,6 @@ Add Sale Order ir.actions.act_window rma_add_sale - rma.order - form form new diff --git a/rma_sale/wizards/rma_make_picking.py b/rma_sale/wizards/rma_make_picking.py index e05bdd13..80dc4579 100644 --- a/rma_sale/wizards/rma_make_picking.py +++ b/rma_sale/wizards/rma_make_picking.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models diff --git a/rma_sale/wizards/rma_order_line_make_sale_order.py b/rma_sale/wizards/rma_order_line_make_sale_order.py index 84859c06..b8f2c420 100644 --- a/rma_sale/wizards/rma_order_line_make_sale_order.py +++ b/rma_sale/wizards/rma_order_line_make_sale_order.py @@ -1,10 +1,8 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import _, api, exceptions, fields, models -import odoo.addons.decimal_precision as dp - class RmaLineMakeSaleOrder(models.TransientModel): _name = "rma.order.line.make.sale.order" @@ -96,7 +94,6 @@ class RmaLineMakeSaleOrder(models.TransientModel): vals["price_unit"] = 0.0 return vals - @api.multi def make_sale_order(self): res = [] sale_obj = self.env["sale.order"] @@ -139,9 +136,7 @@ class RmaLineMakeSaleOrderItem(models.TransientModel): ) product_id = fields.Many2one(comodel_name="product.product", string="Product") name = fields.Char(string="Description") - product_qty = fields.Float( - string="Quantity to sell", digits=dp.get_precision("Product UoS") - ) + product_qty = fields.Float(string="Quantity to sell", digits="Product UoS") product_uom_id = fields.Many2one(comodel_name="uom.uom", string="UoM") out_warehouse_id = fields.Many2one( comodel_name="stock.warehouse", string="Outbound Warehouse" diff --git a/rma_sale/wizards/rma_order_line_make_sale_order_view.xml b/rma_sale/wizards/rma_order_line_make_sale_order_view.xml index 065059a6..56d987ca 100644 --- a/rma_sale/wizards/rma_order_line_make_sale_order_view.xml +++ b/rma_sale/wizards/rma_order_line_make_sale_order_view.xml @@ -53,7 +53,6 @@ Create Sales Quotation ir.actions.act_window rma.order.line.make.sale.order - form form new diff --git a/rma_sale/wizards/rma_refund.py b/rma_sale/wizards/rma_refund.py index 26e2a855..4c9b5e33 100644 --- a/rma_sale/wizards/rma_refund.py +++ b/rma_sale/wizards/rma_refund.py @@ -1,4 +1,4 @@ -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models