From e77128b9718e36b1b8aa36489fd7061fb981c076 Mon Sep 17 00:00:00 2001 From: aheficent Date: Wed, 3 Jan 2018 15:20:45 +0100 Subject: [PATCH] [ADD]rma_purchase_analytic [FIX]various --- rma_purchase_analytic/README.rst | 32 +++++++++++++++++++ rma_purchase_analytic/__init__.py | 5 +++ rma_purchase_analytic/__manifest__.py | 17 ++++++++++ rma_purchase_analytic/models/__init__.py | 4 +++ .../models/purchase_order_line.py | 18 +++++++++++ rma_purchase_analytic/wizards/__init__.py | 5 +++ .../wizards/rma_add_purchase.py | 15 +++++++++ 7 files changed, 96 insertions(+) create mode 100644 rma_purchase_analytic/README.rst create mode 100644 rma_purchase_analytic/__init__.py create mode 100644 rma_purchase_analytic/__manifest__.py create mode 100644 rma_purchase_analytic/models/__init__.py create mode 100644 rma_purchase_analytic/models/purchase_order_line.py create mode 100644 rma_purchase_analytic/wizards/__init__.py create mode 100644 rma_purchase_analytic/wizards/rma_add_purchase.py diff --git a/rma_purchase_analytic/README.rst b/rma_purchase_analytic/README.rst new file mode 100644 index 00000000..927c8203 --- /dev/null +++ b/rma_purchase_analytic/README.rst @@ -0,0 +1,32 @@ +.. 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 PO line. + +* 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_purchase_analytic/__init__.py b/rma_purchase_analytic/__init__.py new file mode 100644 index 00000000..380a9053 --- /dev/null +++ b/rma_purchase_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 wizards diff --git a/rma_purchase_analytic/__manifest__.py b/rma_purchase_analytic/__manifest__.py new file mode 100644 index 00000000..b1742e52 --- /dev/null +++ b/rma_purchase_analytic/__manifest__.py @@ -0,0 +1,17 @@ +# -*- 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 purchase", + "version": "10.0.1.0.0", + "author": "Eficent," + "Odoo Community Association (OCA)", + "license": "LGPL-3", + "website": "http://www.eficent.com", + "category": "Analytic", + "depends": ["rma_account", "rma_analytic", "purchase_analytic"], + "data": [ + ], + 'installable': True, +} diff --git a/rma_purchase_analytic/models/__init__.py b/rma_purchase_analytic/models/__init__.py new file mode 100644 index 00000000..7ea713ef --- /dev/null +++ b/rma_purchase_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 purchase_order_line diff --git a/rma_purchase_analytic/models/purchase_order_line.py b/rma_purchase_analytic/models/purchase_order_line.py new file mode 100644 index 00000000..4d42752b --- /dev/null +++ b/rma_purchase_analytic/models/purchase_order_line.py @@ -0,0 +1,18 @@ +# -*- 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 PurchaseOrderLine(models.Model): + _inherit = "purchase.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 PO line it's not the same" + " as in the rma line")) diff --git a/rma_purchase_analytic/wizards/__init__.py b/rma_purchase_analytic/wizards/__init__.py new file mode 100644 index 00000000..c23b3717 --- /dev/null +++ b/rma_purchase_analytic/wizards/__init__.py @@ -0,0 +1,5 @@ +# -*- 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_purchase diff --git a/rma_purchase_analytic/wizards/rma_add_purchase.py b/rma_purchase_analytic/wizards/rma_add_purchase.py new file mode 100644 index 00000000..db0459f1 --- /dev/null +++ b/rma_purchase_analytic/wizards/rma_add_purchase.py @@ -0,0 +1,15 @@ +# -*- 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 RmaAddPurchase(models.TransientModel): + _inherit = 'rma_add_purchase' + + @api.model + def _prepare_rma_line_from_po_line(self, line): + data = super(RmaAddPurchase, self)._prepare_rma_line_from_po_line(line) + data.update(analytic_account_id=line.analytic_account_id.id) + return data