From 0286a8cf0e0b757a56a22efbcdfd75e258678194 Mon Sep 17 00:00:00 2001 From: Andhitia Rama Date: Sun, 17 Nov 2024 20:37:33 +0700 Subject: [PATCH] [ADD] ssi_rma_sale --- ssi_rma_sale/README.rst | 46 ++++++++++++++++++++++ ssi_rma_sale/__init__.py | 7 ++++ ssi_rma_sale/__manifest__.py | 18 +++++++++ ssi_rma_sale/models/__init__.py | 8 ++++ ssi_rma_sale/models/rma_customer_line.py | 48 +++++++++++++++++++++++ ssi_rma_sale/models/stock_rule.py | 19 +++++++++ ssi_rma_sale/views/rma_customer_views.xml | 19 +++++++++ 7 files changed, 165 insertions(+) create mode 100644 ssi_rma_sale/README.rst create mode 100644 ssi_rma_sale/__init__.py create mode 100644 ssi_rma_sale/__manifest__.py create mode 100644 ssi_rma_sale/models/__init__.py create mode 100644 ssi_rma_sale/models/rma_customer_line.py create mode 100644 ssi_rma_sale/models/stock_rule.py create mode 100644 ssi_rma_sale/views/rma_customer_views.xml diff --git a/ssi_rma_sale/README.rst b/ssi_rma_sale/README.rst new file mode 100644 index 0000000..81208be --- /dev/null +++ b/ssi_rma_sale/README.rst @@ -0,0 +1,46 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================== +RMA + Sale Integration +====================== + + +Installation +============ + +To install this module, you need to: + +1. Clone the branch 14.0 of the repository https://github.com/open-synergy/ssi-rma +2. Add the path to this repository in your configuration (addons-path) +3. Update the module list (Must be on developer mode) +4. Go to menu *Apps -> Apps -> Main Apps* +5. Search For *RMA + Sale Integration* +6. Install the module + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + + +Credits +======= + +Contributors +------------ + +* Andhitia Rama + +Maintainer +---------- + +.. image:: https://simetri-sinergi.id/logo.png + :alt: PT. Simetri Sinergi Indonesia + :target: https://simetri-sinergi.id.com + +This module is maintained by the PT. Simetri Sinergi Indonesia. diff --git a/ssi_rma_sale/__init__.py b/ssi_rma_sale/__init__.py new file mode 100644 index 0000000..07013e9 --- /dev/null +++ b/ssi_rma_sale/__init__.py @@ -0,0 +1,7 @@ +# Copyright 2023 OpenSynergy Indonesia +# Copyright 2023 PT. Simetri Sinergi Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import ( + models, +) diff --git a/ssi_rma_sale/__manifest__.py b/ssi_rma_sale/__manifest__.py new file mode 100644 index 0000000..289a48b --- /dev/null +++ b/ssi_rma_sale/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2023 OpenSynergy Indonesia +# Copyright 2023 PT. Simetri Sinergi Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "RMA + Sale Integration", + "version": "14.0.1.0.0", + "website": "https://simetri-sinergi.id", + "author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia", + "license": "AGPL-3", + "installable": True, + "depends": ["ssi_rma_account", "ssi_sale"], + "data": [ + "views/rma_customer_views.xml", + ], + "demo": [], + "images": [], +} diff --git a/ssi_rma_sale/models/__init__.py b/ssi_rma_sale/models/__init__.py new file mode 100644 index 0000000..90d688d --- /dev/null +++ b/ssi_rma_sale/models/__init__.py @@ -0,0 +1,8 @@ +# Copyright 2023 OpenSynergy Indonesia +# Copyright 2023 PT. Simetri Sinergi Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import ( + rma_customer_line, + stock_rule, +) diff --git a/ssi_rma_sale/models/rma_customer_line.py b/ssi_rma_sale/models/rma_customer_line.py new file mode 100644 index 0000000..4ff15d4 --- /dev/null +++ b/ssi_rma_sale/models/rma_customer_line.py @@ -0,0 +1,48 @@ +# Copyright 2023 OpenSynergy Indonesia +# Copyright 2023 PT. Simetri Sinergi Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class RMACustomerLine(models.Model): + _name = "rma_customer_line" + _inherit = [ + "rma_line_mixin", + "rma_customer_line", + ] + + sale_line_id = fields.Many2one( + related="source_stock_move_id.sale_line_id", + store=False, + ) + + def _get_receipt_procurement_data(self): + _super = super(RMACustomerLine, self) + result = _super._get_receipt_procurement_data() + sale_line_id = self.sale_line_id and self.sale_line_id.id or False + to_refund = sale_line_id and True or False + result.update( + { + "sale_line_id": sale_line_id, + "to_refund": to_refund, + } + ) + return result + + def _get_delivery_procurement_data(self): + _super = super(RMACustomerLine, self) + result = _super._get_delivery_procurement_data() + sale_line_id = self.sale_line_id and self.sale_line_id.id or False + source_stock_move_id = ( + self.source_stock_move_id and self.source_stock_move_id.id or False + ) + to_refund = sale_line_id and True or False + result.update( + { + "sale_line_id": sale_line_id, + "origin_returned_move_id": source_stock_move_id, + "to_refund": to_refund, + } + ) + return result diff --git a/ssi_rma_sale/models/stock_rule.py b/ssi_rma_sale/models/stock_rule.py new file mode 100644 index 0000000..6cdb26a --- /dev/null +++ b/ssi_rma_sale/models/stock_rule.py @@ -0,0 +1,19 @@ +# Copyright 2023 OpenSynergy Indonesia +# Copyright 2023 PT. Simetri Sinergi Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockRule(models.Model): + _name = "stock.rule" + _inherit = ["stock.rule"] + + def _get_custom_move_fields(self): + _super = super(StockRule, self) + result = _super._get_custom_move_fields() + result += [ + "to_refund", + "origin_returned_move_id", + ] + return result diff --git a/ssi_rma_sale/views/rma_customer_views.xml b/ssi_rma_sale/views/rma_customer_views.xml new file mode 100644 index 0000000..9a8ff32 --- /dev/null +++ b/ssi_rma_sale/views/rma_customer_views.xml @@ -0,0 +1,19 @@ + + + + + + + + RMA Customers - Form + rma_customer + + + + + + + + + +