Skip to content
Open
2 changes: 1 addition & 1 deletion donation_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Donation Base",
"version": "16.0.2.0.0",
"version": "18.0.1.0.0",
"category": "Accounting",
"license": "AGPL-3",
"summary": "Base module for donations",
Expand Down
9 changes: 6 additions & 3 deletions donation_base/data/donation_mail_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
<field name="partner_to">{{object.partner_id.id}}</field>
<field name="model_id" ref="donation_base.model_donation_tax_receipt" />
<field name="auto_delete" eval="False" />
<field name="report_template" ref="report_donation_tax_receipt" />
<field
name="report_name"
>{{object.company_id.name.replace(' ', '_')}}-Tax_Receipt_{{(object.number or '').replace('/','_')}}</field>
name="report_template_ids"
eval="[(4, ref('report_donation_tax_receipt'))]"
/>
<!-- <field -->
<!-- name="report_name" -->
<!-- >{{object.company_id.name.replace(' ', '_')}}-Tax_Receipt_{{(object.number or '').replace('/','_')}}</field> -->
<field name="lang">{{object.partner_id.lang}}</field>
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
Expand Down
52 changes: 45 additions & 7 deletions donation_base/demo/donation_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,73 @@
<field name="sale_ok" eval="True" />
<field name="tax_receipt_ok" eval="True" />
<field name="list_price">0</field>
<field name="detailed_type">donation</field>
<field name="type">service</field>
<field name="is_donation" eval="True" />
<field name="in_kind" eval="False" />
<field name="taxes_id" eval="False" />
<field
name="description"
>This donation item is eligible for a tax receipt.</field>
</record>
<record id="product_product_donation_notaxreceipt" model="product.product">
<record id="product_product_donation_service_notaxreceipt" model="product.product">
<field name="name">Donation - no tax receipt</field>
<field name="default_code">DON-NOTAXR</field>
<field name="categ_id" ref="product.product_category_5" />
<field name="sale_ok" eval="True" />
<field name="tax_receipt_ok" eval="False" />
<field name="list_price">0</field>
<field name="detailed_type">donation</field>
<field name="type">service</field>
<field name="is_donation" eval="True" />
<field name="in_kind" eval="False" />
<field name="taxes_id" eval="False" />
<field
name="description"
>This donation item is not eligible for a tax receipt.</field>
</record>
<record id="product_product_inkind_donation_service" model="product.product">
<field name="name">Donation Service</field>
<field name="default_code">KIND-DON-S</field>
<field name="categ_id" ref="product.product_category_5" />
<field name="sale_ok" eval="True" />
<field name="tax_receipt_ok" eval="True" />
<field name="list_price">0</field>
<field name="type">service</field>
<field name="is_donation" eval="True" />
<field name="in_kind" eval="True" />
<field name="taxes_id" eval="False" />
<field
name="description"
>This donation item is a service eligible for a tax receipt.</field>
</record>
<record id="product_product_inkind_donation_service_notaxreceipt" model="product.product">
<field name="name">Donation Service - no tax receipt</field>
<field name="default_code">KIND-DON-S-NOTAXR</field>
<field name="categ_id" ref="product.product_category_5" />
<field name="sale_ok" eval="True" />
<field name="tax_receipt_ok" eval="False" />
<field name="list_price">0</field>
<field name="type">service</field>
<field name="is_donation" eval="True" />
<field name="in_kind" eval="True" />
<field name="taxes_id" eval="False" />
<field
name="description"
>This donation item is a service not eligible for a tax receipt.</field>
</record>
<record id="product_product_inkind_donation" model="product.product">
<field name="name">In-Kind Donation</field>
<field name="default_code">KIND-DON</field>
<field name="categ_id" ref="product.product_category_5" />
<field name="sale_ok" eval="True" />
<field name="tax_receipt_ok" eval="True" />
<field name="list_price">0</field>
<field name="detailed_type">donation_in_kind_consu</field>
<field name="type">consu</field>
<field name="is_donation" eval="True" />
<field name="in_kind" eval="True" />
<field name="taxes_id" eval="False" />
<field
name="description"
>This donation item is eligible for a tax receipt.</field>
>This donation item is a consumable good eligible for a tax receipt.</field>
</record>
<record id="product_product_inkind_donation_notaxreceipt" model="product.product">
<field name="name">In-Kind Donation - no tax receipt</field>
Expand All @@ -47,11 +83,13 @@
<field name="sale_ok" eval="True" />
<field name="tax_receipt_ok" eval="False" />
<field name="list_price">0</field>
<field name="detailed_type">donation_in_kind_consu</field>
<field name="type">consu</field>
<field name="is_donation" eval="True" />
<field name="in_kind" eval="True" />
<field name="taxes_id" eval="False" />
<field
name="description"
>This donation item is not eligible for a tax receipt.</field>
>This donation item is a consumable good not eligible for a tax receipt.</field>
</record>
<!-- PARTNERS -->
<record id="donor1" model="res.partner">
Expand Down
8 changes: 8 additions & 0 deletions donation_base/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,14 @@ msgstr ""
"Im Produkt '%s' sind Steuern (Verkauf) ausgewählt. In Spendenprodukten "
"dürfen keine Steuern definiert werden."

#. module: donation_base
#. odoo-python
#: code:addons/donation_base/models/product.py:0
#, python-format
msgid "There shouldn't have any Customer Taxes on the donation product '%s'."
msgstr ""
"Ein Spendenprodukt des Typs '%s' ist immer eine Sachspende"

#. module: donation_base
#: model_terms:product.template,description:donation_base.product_product_donation_product_template
#: model_terms:product.template,description:donation_base.product_product_inkind_donation_product_template
Expand Down
7 changes: 7 additions & 0 deletions donation_base/i18n/donation_base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,13 @@ msgstr ""
msgid "There shouldn't have any Customer Taxes on the donation product '%s'."
msgstr ""

#. module: donation_base
#. odoo-python
#: code:addons/donation_base/models/product.py:0
#, python-format
msgid "A donation product of type '%s' is always an in-kind donation"
msgstr ""

#. module: donation_base
#: model_terms:product.template,description:donation_base.product_product_donation_product_template
#: model_terms:product.template,description:donation_base.product_product_inkind_donation_product_template
Expand Down
8 changes: 8 additions & 0 deletions donation_base/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,14 @@ msgid "There shouldn't have any Customer Taxes on the donation product '%s'."
msgstr ""
"No debería haber ningún Impuesto al Cliente en el producto de donación '%s'."

#. module: donation_base
#. odoo-python
#: code:addons/donation_base/models/product.py:0
#, python-format
msgid "A donation product of type '%s' is always an in-kind donation"
msgstr ""
"Un producto de donación de tipo '%s' es siempre una donación en especie"

#. module: donation_base
#: model_terms:product.template,description:donation_base.product_product_donation_product_template
#: model_terms:product.template,description:donation_base.product_product_inkind_donation_product_template
Expand Down
8 changes: 8 additions & 0 deletions donation_base/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,14 @@ msgid "There shouldn't have any Customer Taxes on the donation product '%s'."
msgstr ""
"Il ne devrait y avoir aucune taxe à la vente sur l'article de don '%s'."

#. module: donation_base
#. odoo-python
#: code:addons/donation_base/models/product.py:0
#, python-format
msgid "A donation product of type '%s' is always an in-kind donation"
msgstr ""
"Un don du type '%s' est toujours un don en nature"

#. module: donation_base
#: model_terms:product.template,description:donation_base.product_product_donation_product_template
#: model_terms:product.template,description:donation_base.product_product_inkind_donation_product_template
Expand Down
8 changes: 8 additions & 0 deletions donation_base/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,14 @@ msgstr ""
"Non dovrebbero esserci imposte a carico del cliente sul prodotto donazione "
"'%s'."

#. module: donation_base
#. odoo-python
#: code:addons/donation_base/models/product.py:0
#, python-format
msgid "A donation product of type '%s' is always an in-kind donation"
msgstr ""
"Un prodotto di donazione di tipo '%s' è sempre una donazione in natura"

#. module: donation_base
#: model_terms:product.template,description:donation_base.product_product_donation_product_template
#: model_terms:product.template,description:donation_base.product_product_inkind_donation_product_template
Expand Down
24 changes: 0 additions & 24 deletions donation_base/migrations/16.0.2.0.0/pre-migration.py

This file was deleted.

1 change: 1 addition & 0 deletions donation_base/models/donation_tax_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class DonationTaxReceipt(models.Model):
[("each", "One-Time Tax Receipt"), ("annual", "Annual Tax Receipt")],
required=True,
tracking=True,
readonly=True,
)

@api.model_create_multi
Expand Down
110 changes: 63 additions & 47 deletions donation_base/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@
class ProductTemplate(models.Model):
_inherit = "product.template"

detailed_type = fields.Selection(
selection_add=[
("donation", "Donation"),
("donation_in_kind_consu", "In-Kind Donation Consummable"),
("donation_in_kind_service", "In-Kind Donation Service"),
],
ondelete={
"donation": "set service",
"donation_in_kind_consu": "set consu",
"donation_in_kind_service": "set service",
},
is_donation = fields.Boolean(
string="Is a donation",
tracking=True,
readonly=False,
store=True,
help="Specify if the product is a donation",
)
in_kind = fields.Boolean(
string="Is an in-kind donation",
tracking=True,
compute="_compute_is_inkind",
readonly=False,
store=True,
precompute=True,
help="Specify if the donation item is of type in-kind (a good or a service rather than a monetary donation)"
)
tax_receipt_ok = fields.Boolean(
string="Is Eligible for a Tax Receipt",
Expand All @@ -29,61 +33,73 @@ class ProductTemplate(models.Model):
readonly=False,
store=True,
precompute=True,
help="Specify if the product is eligible for a tax receipt",
help="Specify if the donation item is eligible for a tax receipt",
)

@api.depends("detailed_type")
@api.depends("is_donation")
def _compute_is_inkind(self):
for product in self:
if not product.is_donation:
product.in_kind = False
elif product.is_donation and product.type in ["consu", "combo"]:
product.in_kind = True

@api.depends("is_donation")
def _compute_tax_receipt_ok(self):
for product in self:
if product.detailed_type and not product.detailed_type.startswith(
"donation"
):
if not product.is_donation:
product.tax_receipt_ok = False

def _detailed_type_mapping(self):
res = super()._detailed_type_mapping()
res.update(
{
"donation": "service",
"donation_in_kind_consu": "consu",
"donation_in_kind_service": "service",
}
)
return res

@api.onchange("detailed_type")
@api.onchange("is_donation")
def _donation_change(self):
for product in self:
if product.detailed_type == "donation":
product.taxes_id = False
product.supplier_taxes_id = False
product.purchase_ok = False
if self.is_donation:
self.taxes_id = False
self.supplier_taxes_id = False
self.purchase_ok = False
self.sale_ok = False
if "can_be_expensed" in self._fields:
self.can_be_expensed = False

@api.constrains("detailed_type", "taxes_id")
def donation_check(self):
@api.constrains("type", "in_kind")
def inkind_check(self):
for product in self:
# The check below is to make sure that we don't forget to remove
# the default sale VAT tax on the donation product, particularly
# for users of donation_sale. If there are countries that have
# sale tax on donations (!), please tell us and we can remove this
# constraint
if product.detailed_type == "donation" and product.taxes_id:
if product.is_donation and product.type in ["consu", "combo"] and product.in_kind == False:
raise ValidationError(
_(
"There shouldn't have any Customer Taxes on the "
"donation product '%s'."
"A donation product of type '%s' "
"is always an in-kind donation"
)
% product.display_name
% product.type
)


# @api.constrains("is_donation", "taxes_id")
# def donation_check(self):
# for product in self:
# # The check below is to make sure that we don't forget to remove
# # the default sale VAT tax on the donation product, particularly
# # for users of donation_sale. If there are countries that have
# # sale tax on donations (!), please tell us and we can remove this
# # constraint
# _logger.debug(f"in donation constrains, len taxes_id: {len(product.taxes_id)}")
# if product.is_donation and len(product.taxes_id) > 0:
# raise ValidationError(
# _(
# "There shouldn't have any Customer Taxes on the "
# "donation product '%s'."
# )
# % product.display_name
# )

class ProductProduct(models.Model):
_inherit = "product.product"

@api.onchange("detailed_type")
@api.onchange("is_donation")
def _donation_change(self):
for product in self:
if product.detailed_type == "donation":
if product.is_donation:
product.taxes_id = False
product.supplier_taxes_id = False
product.purchase_ok = False
product.sale_ok = False
if "can_be_expensed" in product._fields:
product.can_be_expensed = False
6 changes: 2 additions & 4 deletions donation_base/report/report_donationtax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<!-- This is just a very basic tax receipt report
You should customize the style and layout in a custom module -->
<template id="donation_base.report_donationtaxreceipt_document">
<t t-foreach="docs" t-as="o">
<t t-call="web.internal_layout">
<div class="page">
<h1>Donation Tax Receipt <span t-field="o.number" /></h1>
Expand All @@ -22,14 +21,13 @@
<h3>Amount Total: <span t-field="o.amount" /></h3>
</div>
</t>
</t>
</template>
<template id="report_donationtaxreceipt">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-foreach="docs" t-as="o">
<t
t-call="donation_base.report_donationtaxreceipt_document"
t-lang="doc.partner_id.lang"
t-lang="o.partner_id.lang"
/>
</t>
</t>
Expand Down
Loading