From 8805b37c314cedce7f17661df070489001ed30c0 Mon Sep 17 00:00:00 2001 From: Anjeel Haria Date: Fri, 15 Nov 2024 19:44:59 +0530 Subject: [PATCH] [Del] Removed membership_sale_prorate module --- membership_contribution/__init__.py | 2 +- membership_contribution/models/__init__.py | 2 +- membership_sale_prorate/README.rst | 76 ---- membership_sale_prorate/__init__.py | 1 - membership_sale_prorate/__manifest__.py | 20 - membership_sale_prorate/models/__init__.py | 1 - .../models/sale_order_line.py | 59 --- .../readme/CONTRIBUTORS.rst | 1 - .../readme/DESCRIPTION.rst | 1 - .../static/description/index.html | 423 ------------------ membership_sale_prorate/tests/__init__.py | 2 - .../tests/test_membership_sale_prorate.py | 74 --- 12 files changed, 2 insertions(+), 660 deletions(-) delete mode 100644 membership_sale_prorate/README.rst delete mode 100644 membership_sale_prorate/__init__.py delete mode 100644 membership_sale_prorate/__manifest__.py delete mode 100644 membership_sale_prorate/models/__init__.py delete mode 100644 membership_sale_prorate/models/sale_order_line.py delete mode 100644 membership_sale_prorate/readme/CONTRIBUTORS.rst delete mode 100644 membership_sale_prorate/readme/DESCRIPTION.rst delete mode 100644 membership_sale_prorate/static/description/index.html delete mode 100644 membership_sale_prorate/tests/__init__.py delete mode 100644 membership_sale_prorate/tests/test_membership_sale_prorate.py diff --git a/membership_contribution/__init__.py b/membership_contribution/__init__.py index 9a7e03e..0650744 100644 --- a/membership_contribution/__init__.py +++ b/membership_contribution/__init__.py @@ -1 +1 @@ -from . import models \ No newline at end of file +from . import models diff --git a/membership_contribution/models/__init__.py b/membership_contribution/models/__init__.py index 4c58886..91fed54 100644 --- a/membership_contribution/models/__init__.py +++ b/membership_contribution/models/__init__.py @@ -1 +1 @@ -from . import res_partner \ No newline at end of file +from . import res_partner diff --git a/membership_sale_prorate/README.rst b/membership_sale_prorate/README.rst deleted file mode 100644 index dc9d9f7..0000000 --- a/membership_sale_prorate/README.rst +++ /dev/null @@ -1,76 +0,0 @@ -======================= -Membership Sale Prorate -======================= - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:481e8310c0b91adbd533f0662f28937fa890d6ca476e734e32059244e832f3fb - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png - :target: https://odoo-community.org/page/development-status - :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fvertical--association-lightgray.png?logo=github - :target: https://github.com/OCA/vertical-association/tree/16.0/membership_sale_prorate - :alt: OCA/vertical-association -.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/vertical-association-16-0/vertical-association-16-0-membership_sale_prorate - :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/vertical-association&target_branch=16.0 - :alt: Try me on Runboat - -|badge1| |badge2| |badge3| |badge4| |badge5| - -This module calculates and sets the quantity for sale order lines having prorate membership products so that the sale order line price is calculated accordingly - -**Table of contents** - -.. contents:: - :local: - -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 to smash it by providing a detailed and welcomed -`feedback `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -~~~~~~~ - -* Onestein - -Contributors -~~~~~~~~~~~~ - -* `Onestein `_ - -Maintainers -~~~~~~~~~~~ - -This module is maintained by the OCA. - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use. - -This module is part of the `OCA/vertical-association `_ project on GitHub. - -You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/membership_sale_prorate/__init__.py b/membership_sale_prorate/__init__.py deleted file mode 100644 index 0650744..0000000 --- a/membership_sale_prorate/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models diff --git a/membership_sale_prorate/__manifest__.py b/membership_sale_prorate/__manifest__.py deleted file mode 100644 index 2cafe63..0000000 --- a/membership_sale_prorate/__manifest__.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2024 Onestein () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -{ - "name": "Membership Sale Prorate", - "summary": "Calculates and sets the quantity for sale order lines having " - "prorate membership products so that the sale order line price " - "is calculated accordingly", - "version": "16.0.1.0.0", - "license": "AGPL-3", - "category": "Association", - "author": "Onestein, Odoo Community Association (OCA)", - "website": "https://github.com/OCA/vertical-association", - "depends": [ - "membership", - "membership_prorate", - "sale", - ], - "data": [], - "auto_install": True, -} diff --git a/membership_sale_prorate/models/__init__.py b/membership_sale_prorate/models/__init__.py deleted file mode 100644 index 8eb9d1d..0000000 --- a/membership_sale_prorate/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import sale_order_line diff --git a/membership_sale_prorate/models/sale_order_line.py b/membership_sale_prorate/models/sale_order_line.py deleted file mode 100644 index 3513dd3..0000000 --- a/membership_sale_prorate/models/sale_order_line.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2024 Onestein () -from datetime import timedelta - -from odoo import api, fields, models -from odoo.tests import Form - - -class SaleOrderLine(models.Model): - _inherit = "sale.order.line" - - def _prepare_sale_line_prorate_vals(self, sale_line): - product = sale_line.product_id - date_order = ( - sale_line.order_id.date_order - and sale_line.order_id.date_order.date() - or fields.Date.today() - ) - date_from, date_to = self.env["account.move.line"]._get_membership_interval( - product, date_order - ) - if not date_from: - return {"quantity": 1.0} - if date_order < date_from: - date_order = date_from - if date_order > date_to: - date_order = date_to - theoretical_duration = date_to - date_from + timedelta(1) - real_duration = date_to - date_order + timedelta(1) - if theoretical_duration != real_duration: - return { - "quantity": round( - float(real_duration.days) / theoretical_duration.days, 2 - ), - } - - @api.model_create_multi - def create(self, vals_list): - sale_lines = super().create(vals_list) - for sale_line in sale_lines.filtered( - lambda r: r.product_id.membership and r.product_id.membership_prorate - ): - # Change quantity accordingly the prorate - sale_line_vals = self._prepare_sale_line_prorate_vals(sale_line) - if sale_line_vals: - quantity = sale_line_vals["quantity"] - order = sale_line.order_id - with Form(order) as sale_form: - index = next( - ( - index - for (index, d) in enumerate(sale_form.order_line._records) - if d["id"] == sale_line.id - ), - None, - ) - if index is not None: - with sale_form.order_line.edit(index) as line_form: - line_form.product_uom_qty = quantity - return sale_lines diff --git a/membership_sale_prorate/readme/CONTRIBUTORS.rst b/membership_sale_prorate/readme/CONTRIBUTORS.rst deleted file mode 100644 index 85125ab..0000000 --- a/membership_sale_prorate/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1 +0,0 @@ -* `Onestein `_ diff --git a/membership_sale_prorate/readme/DESCRIPTION.rst b/membership_sale_prorate/readme/DESCRIPTION.rst deleted file mode 100644 index f6b4c88..0000000 --- a/membership_sale_prorate/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -This module calculates and sets the quantity for sale order lines having prorate membership products so that the sale order line price is calculated accordingly diff --git a/membership_sale_prorate/static/description/index.html b/membership_sale_prorate/static/description/index.html deleted file mode 100644 index 1be12b7..0000000 --- a/membership_sale_prorate/static/description/index.html +++ /dev/null @@ -1,423 +0,0 @@ - - - - - -Membership Sale Prorate - - - -
-

Membership Sale Prorate

- - -

Beta License: AGPL-3 OCA/vertical-association Translate me on Weblate Try me on Runboat

-

This module calculates and sets the quantity for sale order lines having prorate membership products so that the sale order line price is calculated accordingly

-

Table of contents

- -
-

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 to smash it by providing a detailed and welcomed -feedback.

-

Do not contact contributors directly about support or help with technical issues.

-
-
-

Credits

-
-

Authors

-
    -
  • Onestein
  • -
-
- -
-

Maintainers

-

This module is maintained by the OCA.

- -Odoo Community Association - -

OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use.

-

This module is part of the OCA/vertical-association project on GitHub.

-

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

-
-
-
- - diff --git a/membership_sale_prorate/tests/__init__.py b/membership_sale_prorate/tests/__init__.py deleted file mode 100644 index 6ca1c1e..0000000 --- a/membership_sale_prorate/tests/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from . import test_membership_sale_prorate diff --git a/membership_sale_prorate/tests/test_membership_sale_prorate.py b/membership_sale_prorate/tests/test_membership_sale_prorate.py deleted file mode 100644 index de825e3..0000000 --- a/membership_sale_prorate/tests/test_membership_sale_prorate.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2024 Onestein () -# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from datetime import date -from unittest.mock import patch - -from odoo import fields -from odoo.tests.common import TransactionCase - -from odoo.addons.membership_prorate.models.account_move_line import AccountMoveLine - - -class TestMembershipProrate(TransactionCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.product = cls.env["product.product"].create( - { - "name": "Membership product with prorate", - "membership": True, - "membership_prorate": True, - "membership_date_from": "2017-01-01", - "membership_date_to": "2017-12-31", - } - ) - cls.partner = cls.env["res.partner"].create( - { - "name": "Test", - } - ) - - def create_membership_sale(self, date_order=False): - vals = { - "partner_id": self.partner.id, - "date_order": date_order or fields.Date.today(), - "order_line": [ - ( - 0, - None, - { - "product_id": self.product.id, - "product_uom_qty": 1, - }, - ) - ], - } - return self.env["sale.order"].create(vals) - - def test_create_sale_membership_product_wo_prorate(self): - self.product.membership_prorate = False - sale = self.create_membership_sale() - self.assertEqual(sale.order_line[0].product_uom_qty, 1.0) - - def test_create_sale_membership_product_prorate(self): - sale = self.create_membership_sale(date_order=date(2017, 7, 1)) - self.assertAlmostEqual(sale.order_line[0].product_uom_qty, 0.50, 2) - sale = self.create_membership_sale(date_order=date(2016, 7, 1)) - self.assertAlmostEqual(sale.order_line[0].product_uom_qty, 1.0, 2) - sale = self.create_membership_sale(date_order=date(2018, 7, 1)) - self.assertAlmostEqual(sale.order_line[0].product_uom_qty, 0, 2) - - def test_create_sale_membership_prorate_variable_period(self): - """It is a test for case where membership type is set to variable - on product with membership_prorate_variable_period not installed""" - - def _get_membership_interval(self, product, date): - return False, False - - with patch.object( - AccountMoveLine, - "_get_membership_interval", - _get_membership_interval, - ): - sale = self.create_membership_sale(date_order=date(2017, 7, 1)) - self.assertEqual(sale.order_line[0].product_uom_qty, 1.0)