From 39be5588cf7a64c82ef938e408ce7bfb41893515 Mon Sep 17 00:00:00 2001 From: aheficent Date: Wed, 3 Jan 2018 15:13:16 +0100 Subject: [PATCH] [ADD]rma_sale_analytic --- rma_sale_analytic/README.rst | 34 +++++++++++++++++++ rma_sale_analytic/__init__.py | 5 +++ rma_sale_analytic/__manifest__.py | 16 +++++++++ rma_sale_analytic/models/__init__.py | 4 +++ rma_sale_analytic/models/sale_order_line.py | 17 ++++++++++ rma_sale_analytic/wizards/__init__.py | 6 ++++ rma_sale_analytic/wizards/rma_add_sale.py | 16 +++++++++ .../wizards/rma_order_line_make_sale_order.py | 17 ++++++++++ 8 files changed, 115 insertions(+) create mode 100644 rma_sale_analytic/README.rst create mode 100644 rma_sale_analytic/__init__.py create mode 100644 rma_sale_analytic/__manifest__.py create mode 100644 rma_sale_analytic/models/__init__.py create mode 100644 rma_sale_analytic/models/sale_order_line.py create mode 100644 rma_sale_analytic/wizards/__init__.py create mode 100644 rma_sale_analytic/wizards/rma_add_sale.py create mode 100644 rma_sale_analytic/wizards/rma_order_line_make_sale_order.py diff --git a/rma_sale_analytic/README.rst b/rma_sale_analytic/README.rst new file mode 100644 index 00000000..35d7b787 --- /dev/null +++ b/rma_sale_analytic/README.rst @@ -0,0 +1,34 @@ +.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg + :target: https://www.gnu.org/licenses/lgpl.html + :alt: License: LGPL-3 + +========================== +RMA with Analytic Accounts +========================== + +This module introduces the following features: + +* Adds the analytic account to the RMA order lines from the origin sale. + +* Propagates the analytic account to the SO created + +* Introduce rules to ensure consistency + + +Usage +===== + +* Add the analytic information in the rma line or let the system fill it + from origin + + +Contributors +------------ + +* Aaron Henriquez + + +Maintainer +---------- + +This module is maintained by Eficent. \ No newline at end of file diff --git a/rma_sale_analytic/__init__.py b/rma_sale_analytic/__init__.py new file mode 100644 index 00000000..c5d44257 --- /dev/null +++ b/rma_sale_analytic/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import models +from . import tests diff --git a/rma_sale_analytic/__manifest__.py b/rma_sale_analytic/__manifest__.py new file mode 100644 index 00000000..56f4fbd4 --- /dev/null +++ b/rma_sale_analytic/__manifest__.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# © 2017 Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Analytic Account in RMA", + "version": "10.0.1.0.0", + "author": "Eficent", + "license": "LGPL-3", + "website": "http://www.eficent.com", + "category": "Analytic", + "depends": ["rma_account", "rma_analytic", "stock_analytic_account"], + "data": [ + ], + 'installable': True, +} diff --git a/rma_sale_analytic/models/__init__.py b/rma_sale_analytic/models/__init__.py new file mode 100644 index 00000000..1f0d3fde --- /dev/null +++ b/rma_sale_analytic/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import sale_order_line diff --git a/rma_sale_analytic/models/sale_order_line.py b/rma_sale_analytic/models/sale_order_line.py new file mode 100644 index 00000000..6446a672 --- /dev/null +++ b/rma_sale_analytic/models/sale_order_line.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# © 2018 Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import _, api, exceptions, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + @api.constrains('analytic_account_id') + def check_analytic(self): + for line in self: + if line.analytic_account_id != line.rma_line_id.analytic_account_id: + raise exceptions.ValidationError( + _("The analytic account in the sale line it's not the same" + " as in the rma line")) diff --git a/rma_sale_analytic/wizards/__init__.py b/rma_sale_analytic/wizards/__init__.py new file mode 100644 index 00000000..44cb5e0c --- /dev/null +++ b/rma_sale_analytic/wizards/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2018 Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from . import rma_add_sale +from . import rma_order_line_make_sale_order diff --git a/rma_sale_analytic/wizards/rma_add_sale.py b/rma_sale_analytic/wizards/rma_add_sale.py new file mode 100644 index 00000000..dbf794ff --- /dev/null +++ b/rma_sale_analytic/wizards/rma_add_sale.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# © 2018 Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, models + + +class RmaAddSale(models.TransientModel): + _inherit = 'rma_add_sale' + + @api.model + def _prepare_rma_line_from_sale_order_line(self, line): + data = super(RmaAddInvoice, self).\ + _prepare_rma_line_from_sale_order_line(line) + data.update(analytic_account_id=line.analytic_account_id.id) + return data diff --git a/rma_sale_analytic/wizards/rma_order_line_make_sale_order.py b/rma_sale_analytic/wizards/rma_order_line_make_sale_order.py new file mode 100644 index 00000000..d7a3990d --- /dev/null +++ b/rma_sale_analytic/wizards/rma_order_line_make_sale_order.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# © 2018 Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import models, api + + +class RmaLineMakeSaleOrder(models.TransientModel): + _inherit = "rma.order.line.make.sale.order" + + @api.model + def _prepare_sale_order_line(self, so, item): + sale_line = super( + RmaLineMakeSaleOrder, self)._prepare_sale_order_line(so, item) + sale_line.update( + analytic_account_id=item.line_id.analytic_account_id.id) + return sale_line