robin.keunen
5 years ago
5 changed files with 215 additions and 18 deletions
-
39easy_my_coop/__manifest__.py
-
122easy_my_coop/demo/coop.xml
-
1easy_my_coop/models/operation_request.py
-
1easy_my_coop/tests/__init__.py
-
70easy_my_coop/tests/test_coop.py
@ -0,0 +1,122 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- |
||||
|
Copyright 2019 Coop IT Easy |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
--> |
||||
|
<odoo> |
||||
|
|
||||
|
<record id="res_partner_cooperator_1_demo" model="res.partner"> |
||||
|
<field name="name">Virginie Leloup</field> |
||||
|
<field name="customer" eval="True"/> |
||||
|
<field name="is_company" eval="False"/> |
||||
|
<field name="email">virginie@demo.net</field> |
||||
|
<field name="street">Avenue des Dessus-de-Livres, 2</field> |
||||
|
<field name="city">Namur (Loyers)</field> |
||||
|
<field name="zip">5101</field> |
||||
|
<field name="country_id" ref="base.be"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="res_partner_cooperator_2_demo" model="res.partner"> |
||||
|
<field name="name">Houssine Intégrale</field> |
||||
|
<field name="customer" eval="True"/> |
||||
|
<field name="is_company" eval="False"/> |
||||
|
<field name="email">houssine@demo.net</field> |
||||
|
<field name="street">Avenue des Dessous-de-Livres, 3</field> |
||||
|
<field name="city">Namur (Loyers)</field> |
||||
|
<field name="zip">5101</field> |
||||
|
<field name="country_id" ref="base.be"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="res_partner_cooperator_3_demo" model="res.partner"> |
||||
|
<field name="name">Vincent Bixolon</field> |
||||
|
<field name="customer" eval="True"/> |
||||
|
<field name="is_company" eval="False"/> |
||||
|
<field name="email">vincent@demo.net</field> |
||||
|
<field name="street">Rue de la colocation, 23</field> |
||||
|
<field name="city">Namur (Loyers)</field> |
||||
|
<field name="zip">5101</field> |
||||
|
<field name="country_id" ref="base.be"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="res_partner_cooperator_4_demo" model="res.partner"> |
||||
|
<field name="name">Rémy Commit</field> |
||||
|
<field name="customer" eval="True"/> |
||||
|
<field name="is_company" eval="False"/> |
||||
|
<field name="email">remy@demo.net</field> |
||||
|
<field name="street">Rue Guido Van Rossum, 2</field> |
||||
|
<field name="city">Evere</field> |
||||
|
<field name="zip">5101</field> |
||||
|
<field name="country_id" ref="base.be"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="account_cooperator_demo" model="account.account"> |
||||
|
<field name="code">416000</field> |
||||
|
<field name="name">Cooperators</field> |
||||
|
<field name="user_type_id" ref="account.data_account_type_receivable"/> |
||||
|
<field name="reconcile" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="product_template_share_type_1_demo" model="product.template"> |
||||
|
<field name="name">Part A - Founder</field> |
||||
|
<field name="short_name">Part A</field> |
||||
|
<field name="is_share" eval="True"/> |
||||
|
<field name="default_share_product" eval="True"/> |
||||
|
<field name="force_min_qty" eval="True"/> |
||||
|
<field name="minimum_quantity">2</field> |
||||
|
<field name="by_individual" eval="True"/> |
||||
|
<field name="by_company" eval="True"/> |
||||
|
<field name="list_price">50</field> |
||||
|
<field name="display_on_website" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="product_product_share_type_1_demo" model="product.product"> |
||||
|
<field name="product_tmpl_id" ref="product_template_share_type_1_demo"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="product_template_share_type_2_demo" model="product.template"> |
||||
|
<field name="name">Part B - Worker</field> |
||||
|
<field name="short_name">Part B</field> |
||||
|
<field name="is_share" eval="True"/> |
||||
|
<field name="default_share_product" eval="True"/> |
||||
|
<field name="force_min_qty" eval="True"/> |
||||
|
<field name="minimum_quantity">2</field> |
||||
|
<field name="by_individual" eval="True"/> |
||||
|
<field name="by_company" eval="False"/> |
||||
|
<field name="list_price">25</field> |
||||
|
<field name="display_on_website" eval="True"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="product_product_share_type_2_demo" model="product.product"> |
||||
|
<field name="product_tmpl_id" ref="product_template_share_type_2_demo"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="subscription_request_1_demo" model="subscription.request"> |
||||
|
<field name="name">Manuel Dublues</field> |
||||
|
<field name="email">manuel@demo.net</field> |
||||
|
<field name="address">schaerbeekstraat</field> |
||||
|
<field name="zip_code">1111</field> |
||||
|
<field name="city">Brussels</field> |
||||
|
<field name="country_id" ref="base.be"/> |
||||
|
<field name="date" eval="datetime.now() - timedelta(days=12)"/> |
||||
|
<field name="source">manual</field> |
||||
|
<field name="ordered_parts">3</field> |
||||
|
<field name="share_product_id" ref="product_product_share_type_2_demo"/> |
||||
|
<field name="lang">en_US</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="share_line_1_demo" model="share.line"> |
||||
|
<field name="share_product_id" ref="product_product_share_type_1_demo"/> |
||||
|
<field name="share_number">2</field> |
||||
|
<field name="share_unit_price">50</field> |
||||
|
<field name="partner_id" ref="res_partner_cooperator_1_demo"/> |
||||
|
<field name="effective_date" eval="datetime.now() - timedelta(days=120)"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="share_line_2_demo" model="share.line"> |
||||
|
<field name="share_product_id" ref="product_product_share_type_1_demo"/> |
||||
|
<field name="share_number">4</field> |
||||
|
<field name="share_unit_price">50</field> |
||||
|
<field name="partner_id" ref="res_partner_cooperator_2_demo"/> |
||||
|
<field name="effective_date" eval="datetime.now() - timedelta(days=120)"/> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1 @@ |
|||||
|
from . import test_coop |
@ -0,0 +1,70 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Copyright 2019 Coop IT Easy SCRL fs |
||||
|
# Robin Keunen <robin@coopiteasy.be> |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import odoo.tests.common as common |
||||
|
from odoo.fields import Date |
||||
|
|
||||
|
|
||||
|
class TestCoop(common.TransactionCase): |
||||
|
def setUp(self): |
||||
|
super(TestCoop, self).setUp() |
||||
|
|
||||
|
self.request = self.browse_ref( |
||||
|
"easy_my_coop.subscription_request_1_demo" |
||||
|
) |
||||
|
self.bank_journal_euro = self.env["account.journal"].create( |
||||
|
{"name": "Bank", "type": "bank", "code": "BNK67"} |
||||
|
) |
||||
|
self.payment_method_manual_in = self.env.ref( |
||||
|
"account.account_payment_method_manual_in" |
||||
|
) |
||||
|
|
||||
|
def test_put_on_waiting_list(self): |
||||
|
self.request.put_on_waiting_list() |
||||
|
self.assertEquals(self.request.state, "waiting") |
||||
|
|
||||
|
def test_validate_subscription_request(self): |
||||
|
self.request.validate_subscription_request() |
||||
|
|
||||
|
self.assertEquals(self.request.state, "done") |
||||
|
self.assertTrue(self.request.partner_id) |
||||
|
self.assertTrue(self.request.partner_id.coop_candidate) |
||||
|
self.assertFalse(self.request.partner_id.member) |
||||
|
self.assertEquals(self.request.type, "new") |
||||
|
self.assertTrue(len(self.request.capital_release_request) >= 1) |
||||
|
self.assertEquals(self.request.capital_release_request.state, "open") |
||||
|
self.assertTrue(self.request.capital_release_request.sent) |
||||
|
|
||||
|
def test_register_payment_for_capital_release(self): |
||||
|
self.request.validate_subscription_request() |
||||
|
invoice = self.request.capital_release_request |
||||
|
|
||||
|
ctx = {"active_model": "account.invoice", "active_ids": [invoice.id]} |
||||
|
register_payments = ( |
||||
|
self.env["account.register.payments"] |
||||
|
.with_context(ctx) |
||||
|
.create( |
||||
|
{ |
||||
|
"payment_date": Date.today(), |
||||
|
"journal_id": self.bank_journal_euro.id, |
||||
|
"payment_method_id": self.payment_method_manual_in.id, |
||||
|
} |
||||
|
) |
||||
|
) |
||||
|
register_payments.create_payments() |
||||
|
self.assertEquals(self.request.capital_release_request.state, "paid") |
||||
|
|
||||
|
partner = self.request.partner_id |
||||
|
self.assertFalse(partner.coop_candidate) |
||||
|
self.assertTrue(partner.member) |
||||
|
self.assertTrue(partner.share_ids) |
||||
|
self.assertEquals(self.request.partner_id.effective_date, Date.today()) |
||||
|
|
||||
|
share = partner.share_ids[0] |
||||
|
self.assertEquals(share.share_number, self.request.ordered_parts) |
||||
|
self.assertEquals( |
||||
|
share.share_product_id, self.request.share_product_id |
||||
|
) |
||||
|
self.assertEquals(share.effective_date, Date.today()) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue