diff --git a/cooperator/README.rst b/cooperator/README.rst index 261cff0eb..e4161aa38 100644 --- a/cooperator/README.rst +++ b/cooperator/README.rst @@ -7,7 +7,7 @@ Cooperators !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:fc9abf44c53ec9ed50ac717e7fa26489ddc8765fd713c8db92f40bc077d5b1ce + !! source digest: sha256:4adbd8d94496075c68a7aa4ac052869f770abfc54315cb337d0d77536d4980ea !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -267,6 +267,10 @@ Contributors * Carmen Bianca Bakker * hugues de keyzer +* 'Som IT Cooperatiu SCCL' + + * Nicolás Ramos + Maintainers ~~~~~~~~~~~ diff --git a/cooperator/__manifest__.py b/cooperator/__manifest__.py index 593a7100f..851103ff6 100644 --- a/cooperator/__manifest__.py +++ b/cooperator/__manifest__.py @@ -40,6 +40,7 @@ "views/operation_request_view.xml", "views/account_move_views.xml", "views/product_view.xml", + "views/product_category_view.xml", "views/res_company_view.xml", "views/account_journal_views.xml", "views/cooperative_membership_view.xml", diff --git a/cooperator/models/__init__.py b/cooperator/models/__init__.py index f1b70f3ff..e450515fe 100644 --- a/cooperator/models/__init__.py +++ b/cooperator/models/__init__.py @@ -16,3 +16,4 @@ from . import share_line from . import subscription_register from . import subscription_request +from . import product_category diff --git a/cooperator/models/product_category.py b/cooperator/models/product_category.py new file mode 100644 index 000000000..dc7288ba2 --- /dev/null +++ b/cooperator/models/product_category.py @@ -0,0 +1,12 @@ +from odoo import fields, models + +class ProductCategory(models.Model): + _inherit = 'product.category' + + property_account_income_increase_categ_id = fields.Many2one( + 'account.account', + company_dependent=True, + string="Income Account for Share Increase", + domain="[('deprecated', '=', False), ('company_id', '=', current_company_id)]", + help="This account will be used when validating a share increase subscription request instead of the default income account" + ) diff --git a/cooperator/models/product_template.py b/cooperator/models/product_template.py index 976cea340..59090a8c3 100644 --- a/cooperator/models/product_template.py +++ b/cooperator/models/product_template.py @@ -18,6 +18,13 @@ class ProductTemplate(models.Model): by_company = fields.Boolean(string="Can be subscribed by companies?") by_individual = fields.Boolean(string="Can be subscribed by individuals?") mail_template = fields.Many2one("mail.template", string="Mail template") + property_account_income_increase_id = fields.Many2one( + 'account.account', + company_dependent=True, + string="Income Account for Share Increase", + domain="[('deprecated', '=', False), ('company_id', '=', current_company_id)]", + help="This account will be used when validating a share increase subscription request instead of the default income account" + ) def get_web_share_products(self, is_company): if is_company is True: diff --git a/cooperator/models/subscription_request.py b/cooperator/models/subscription_request.py index afa646ffd..26935cf7c 100644 --- a/cooperator/models/subscription_request.py +++ b/cooperator/models/subscription_request.py @@ -531,10 +531,20 @@ def _prepare_invoice_line(self, move_id, product, partner, qty): # request for a company other than the current one, which can happen # when a user is "logged in" to multiple companies. product = product.with_company(self.company_id) - account = ( - product.property_account_income_id - or product.categ_id.property_account_income_categ_id - ) + + if self.type == 'increase': + account = ( + product.property_account_income_increase_id + or product.categ_id.property_account_income_increase_categ_id + or product.property_account_income_id + or product.categ_id.property_account_income_categ_id + ) + else: + account = ( + product.property_account_income_id + or product.categ_id.property_account_income_categ_id + ) + if not account: raise UserError( _( diff --git a/cooperator/readme/CONTRIBUTORS.rst b/cooperator/readme/CONTRIBUTORS.rst index c3e148a98..5c97a79d8 100644 --- a/cooperator/readme/CONTRIBUTORS.rst +++ b/cooperator/readme/CONTRIBUTORS.rst @@ -8,3 +8,7 @@ * Manuel Claeys Bouuaert * Carmen Bianca Bakker * hugues de keyzer + +* 'Som IT Cooperatiu SCCL' + + * Nicolás Ramos diff --git a/cooperator/static/description/index.html b/cooperator/static/description/index.html index 8da67eeaa..911778159 100644 --- a/cooperator/static/description/index.html +++ b/cooperator/static/description/index.html @@ -367,7 +367,7 @@

Cooperators

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:fc9abf44c53ec9ed50ac717e7fa26489ddc8765fd713c8db92f40bc077d5b1ce +!! source digest: sha256:4adbd8d94496075c68a7aa4ac052869f770abfc54315cb337d0d77536d4980ea !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

Manage cooperators of a cooperative.

@@ -611,6 +611,10 @@

Contributors

  • hugues de keyzer
  • +
  • ‘Som IT Cooperatiu SCCL’ +
  • diff --git a/cooperator/tests/test_cooperator.py b/cooperator/tests/test_cooperator.py index a628a3b3f..943393303 100644 --- a/cooperator/tests/test_cooperator.py +++ b/cooperator/tests/test_cooperator.py @@ -743,7 +743,6 @@ def test_create_cooperator_and_user_for_multiple_companies(self): self.validate_subscription_request_and_pay(subscription_request_2) partner_2 = subscription_request_2.partner_id self.assertEqual(partner_1, partner_2) - user = self.env["res.users"].search([("partner_id", "=", partner_1.id)]) self.assertEqual(user.company_id, self.company) self.assertEqual(user.company_ids, self.company | company_2) @@ -1584,3 +1583,43 @@ def test_create_user_multiple_users(self): self.assertEqual(inactive_user.company_ids, self.env.company) self.assertEqual(inactive_user.company_id, self.env.company) self.assertTrue(inactive_user.active) + + def test_capital_release_request_income_account_new(self): + """ + Test that the income account of capital release requests for new subscriptions + uses the standard income account. + """ + self.subscription_request_1.validate_subscription_request() + invoice = self.subscription_request_1.capital_release_request + income_line = invoice.invoice_line_ids.filtered(lambda l: l.credit == 0) + self.assertEqual( + income_line.account_id, + self.share_y.property_account_income_id + or self.share_y.categ_id.property_account_income_categ_id, + ) + + def test_capital_release_request_income_account_increase(self): + """ + Test that the income account of capital release requests for increase subscriptions + uses the increase income account. + """ + self.subscription_request_1.validate_subscription_request() + self.pay_invoice(self.subscription_request_1.capital_release_request) + + subscription_request_2 = self.create_dummy_subscription_from_partner( + self.subscription_request_1.partner_id + ) + + increase_account = self.env["account.account"].create( + { + "name": "Test Increase Income Account", + "code": "TINC", + "account_type": "income", + } + ) + + self.share_y.property_account_income_increase_id = increase_account.id + subscription_request_2.validate_subscription_request() + invoice = subscription_request_2.capital_release_request + income_line = invoice.invoice_line_ids.filtered(lambda l: l.credit == 0) + self.assertEqual(income_line.account_id, increase_account) diff --git a/cooperator/views/product_category_view.xml b/cooperator/views/product_category_view.xml new file mode 100644 index 000000000..0af13d91f --- /dev/null +++ b/cooperator/views/product_category_view.xml @@ -0,0 +1,14 @@ + + + + product.category.form.account.inherit + product.category + + + + + + + + diff --git a/cooperator/views/product_view.xml b/cooperator/views/product_view.xml index deed1a3cd..6988ed66a 100644 --- a/cooperator/views/product_view.xml +++ b/cooperator/views/product_view.xml @@ -30,6 +30,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
    + + + --> -