Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,554 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
=============================================== | ||
Membership Set | ||
=============================================== | ||
|
||
This module enable the user to define a Set of Memberships and | ||
create the summarized invoice. | ||
|
||
|
||
Usage | ||
===== | ||
|
||
The module adds a boolean field "Membership set" in model "product.template". | ||
Once it was set, the User can define the membership set by adding the normal | ||
memberships in field "Membership products". | ||
|
||
The module extends the wizard "Buy membership" for creating | ||
a summarized invoice, which contains the invoice lines for each | ||
membership in the selected Membership set. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/vertical-association/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 | ||
------------ | ||
|
||
* Yu Weng <yweng@elegosoft.com> | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2019 Yu Weng <yweng@elegosoft.com> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2019 Yu Weng <yweng@elegosoft.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Product Set for memberships', | ||
'version': '11.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'category': 'Association', | ||
'author': 'Yu Weng, ' | ||
'Odoo Community Association (OCA)', | ||
'website': 'https://github.com/OCA/vertical-association', | ||
'depends': [ | ||
'membership', | ||
], | ||
'data': [ | ||
'views/product_template_views.xml', | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * membership_product_set | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-04-18 00:20+0000\n" | ||
"PO-Revision-Date: 2019-04-18 00:20+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: membership_product_set | ||
#: model:ir.model.fields,help:membership_product_set.field_product_product_membership_set | ||
#: model:ir.model.fields,help:membership_product_set.field_product_template_membership_set | ||
msgid "Check if the product is eligible for membership set." | ||
msgstr "Überprüfen Sie, ob das Produkt als Mitgliedschaften angelegt wurde." | ||
|
||
#. module: membership_product_set | ||
#: model:ir.model.fields,field_description:membership_product_set.field_product_product_membership_set_products | ||
#: model:ir.model.fields,field_description:membership_product_set.field_product_template_membership_set_products | ||
msgid "Membership products" | ||
msgstr "Mitgliedschaft Produkte" | ||
|
||
#. module: membership_product_set | ||
#: model:ir.model.fields,field_description:membership_product_set.field_product_product_membership_set | ||
#: model:ir.model.fields,field_description:membership_product_set.field_product_template_membership_set | ||
msgid "Membership set" | ||
msgstr "Mitgliedschaften" | ||
|
||
#. module: membership_product_set | ||
#: code:addons/membership_product_set/models/res_partner.py:27 | ||
#, python-format | ||
msgid "Partner doesn't have an account to make the invoice." | ||
msgstr "Partner hat kein Debitorenkonto für Rechnung" | ||
|
||
#. module: membership_product_set | ||
#: code:addons/membership_product_set/models/res_partner.py:25 | ||
#, python-format | ||
msgid "Partner is a free Member." | ||
msgstr "Partner ist freies Mitglied" | ||
|
||
#. module: membership_product_set | ||
#: model:ir.model,name:membership_product_set.model_product_template | ||
msgid "Product Template" | ||
msgstr "Produktvorlage" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright 2019 Yu Weng <yweng@elegosoft.com> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import product_template | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2019 Yu Weng <yweng@elegosoft.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
membership_set = fields.Boolean( | ||
help="Check if the product is eligible for membership set.", | ||
string="Membership set") | ||
membership_set_products = fields.Many2many( | ||
'product.product', | ||
'membership_set_products_rel', | ||
'membership_set_id', | ||
'product_id', | ||
string="Membership products") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright 2019 Yu Weng <yweng@elegosoft.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models, _ | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
@api.multi | ||
def create_membership_invoice(self, product_id=None, datas=None): | ||
product_id = product_id or datas.get('membership_product_id') | ||
amount = datas.get('amount', 0.0) | ||
product = self.env['product.product'].browse(product_id) | ||
invoice_list = [] | ||
if product.membership_set: | ||
for partner in self: | ||
if partner.free_member: | ||
raise UserError(_("Partner is a free Member.")) | ||
account_id = partner.property_account_receivable_id.id | ||
w = _("Partner doesn't have an account to make the invoice.") | ||
if not account_id: | ||
raise UserError(w) | ||
position_id = partner.property_account_position_id.id | ||
invoice = self.env['account.invoice'].create({ | ||
'partner_id': partner.id, | ||
'account_id': account_id, | ||
'fiscal_position_id': position_id | ||
}) | ||
for p in product.membership_set_products: | ||
price_dict = p.price_compute('list_price') | ||
amount = price_dict.get(p.id) or 0 | ||
line_values = { | ||
'product_id': p.id, | ||
'price_unit': amount, | ||
'invoice_id': invoice.id, | ||
} | ||
|
||
# create a record in cache, apply onchange | ||
# then revert back to a dictionnary | ||
invoice_line = self.env['account.invoice.line']\ | ||
.new(line_values) | ||
invoice_line._onchange_product_id() | ||
line_values = invoice_line._convert_to_write({ | ||
name: invoice_line[name] | ||
for name in invoice_line._cache | ||
}) | ||
line_values['price_unit'] = amount | ||
invoice.write({'invoice_line_ids': [(0, 0, line_values)]}) | ||
invoice_list.append(invoice.id) | ||
invoice.compute_taxes() | ||
else: | ||
invoice_list = super(ResPartner, self).create_membership_invoice( | ||
product_id=product_id, | ||
datas=datas | ||
) | ||
return invoice_list |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.