diff --git a/donation_base/demo/donation_demo.xml b/donation_base/demo/donation_demo.xml
index 861a2b7ca..389cfc58d 100644
--- a/donation_base/demo/donation_demo.xml
+++ b/donation_base/demo/donation_demo.xml
@@ -8,25 +8,59 @@
0
-
donation
+
service
+
+
This donation item is eligible for a tax receipt.
-
+
Donation - no tax receipt
DON-NOTAXR
0
- donation
+ service
+
+
This donation item is not eligible for a tax receipt.
+
+ Donation Service
+ KIND-DON-S
+
+
+
+ 0
+ service
+
+
+
+ This donation item is a service eligible for a tax receipt.
+
+
+ Donation Service - no tax receipt
+ KIND-DON-S-NOTAXR
+
+
+
+ 0
+ service
+
+
+
+ This donation item is a service not eligible for a tax receipt.
+
In-Kind Donation
KIND-DON
@@ -34,11 +68,13 @@
0
- donation_in_kind_consu
+ consu
+
+
This donation item is eligible for a tax receipt.
+ >This donation item is a consumable good eligible for a tax receipt.
In-Kind Donation - no tax receipt
@@ -47,11 +83,13 @@
0
- donation_in_kind_consu
+ consu
+
+
This donation item is not eligible for a tax receipt.
+ >This donation item is a consumable good not eligible for a tax receipt.
diff --git a/donation_base/i18n/de.po b/donation_base/i18n/de.po
index 7ba949d9b..d52c99ca7 100644
--- a/donation_base/i18n/de.po
+++ b/donation_base/i18n/de.po
@@ -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
diff --git a/donation_base/i18n/donation_base.pot b/donation_base/i18n/donation_base.pot
index f69aae9fa..865c0fda8 100644
--- a/donation_base/i18n/donation_base.pot
+++ b/donation_base/i18n/donation_base.pot
@@ -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
diff --git a/donation_base/i18n/es.po b/donation_base/i18n/es.po
index dd32854d0..74152a5a8 100644
--- a/donation_base/i18n/es.po
+++ b/donation_base/i18n/es.po
@@ -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
diff --git a/donation_base/i18n/fr.po b/donation_base/i18n/fr.po
index 4c61c2fd6..c31fc42b2 100644
--- a/donation_base/i18n/fr.po
+++ b/donation_base/i18n/fr.po
@@ -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
diff --git a/donation_base/i18n/it.po b/donation_base/i18n/it.po
index 78d578ff3..486d9d43f 100644
--- a/donation_base/i18n/it.po
+++ b/donation_base/i18n/it.po
@@ -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
diff --git a/donation_base/migrations/16.0.2.0.0/pre-migration.py b/donation_base/migrations/16.0.2.0.0/pre-migration.py
deleted file mode 100644
index c07da1568..000000000
--- a/donation_base/migrations/16.0.2.0.0/pre-migration.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2023 Akretion France (http://www.akretion.com/)
-# @author: Alexis de Lattre
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-
-
-def migrate(cr, version):
- if not version:
- return
-
- cr.execute(
- """UPDATE product_template
- SET detailed_type='donation_in_kind_service'
- WHERE donation IS true AND in_kind_donation IS true AND type = 'service'"""
- )
- cr.execute(
- """UPDATE product_template
- SET detailed_type='donation_in_kind_consu'
- WHERE donation IS true AND in_kind_donation IS true AND type = 'consu'"""
- )
- cr.execute(
- """UPDATE product_template
- SET detailed_type='donation'
- WHERE donation IS true AND in_kind_donation IS NOT true"""
- )
diff --git a/donation_base/models/donation_tax_receipt.py b/donation_base/models/donation_tax_receipt.py
index 6bb19b148..065ed23d1 100644
--- a/donation_base/models/donation_tax_receipt.py
+++ b/donation_base/models/donation_tax_receipt.py
@@ -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
diff --git a/donation_base/models/product.py b/donation_base/models/product.py
index 6bce84c23..f768e0cc9 100644
--- a/donation_base/models/product.py
+++ b/donation_base/models/product.py
@@ -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",
@@ -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
\ No newline at end of file
diff --git a/donation_base/report/report_donationtax.xml b/donation_base/report/report_donationtax.xml
index 95f5464e4..4bef04704 100644
--- a/donation_base/report/report_donationtax.xml
+++ b/donation_base/report/report_donationtax.xml
@@ -9,7 +9,6 @@
-
Donation Tax Receipt
@@ -22,14 +21,13 @@
Amount Total:
-
-
+
diff --git a/donation_base/tests/test_donation_tax_receipt.py b/donation_base/tests/test_donation_tax_receipt.py
index 2ae314997..40e1329e1 100644
--- a/donation_base/tests/test_donation_tax_receipt.py
+++ b/donation_base/tests/test_donation_tax_receipt.py
@@ -36,9 +36,6 @@ def test_donation(self):
with self.assertRaises(UserError):
self.dt_receipt_rec.action_send_tax_receipt()
- def test_donation_type(self):
- self.assertEqual(self.product_id.type, "service")
-
class TestTaxReceiptAnnualCreate(TransactionCase):
def setUp(self):
diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml
index 30fcc8399..122ac4a96 100644
--- a/donation_base/views/donation_tax_receipt.xml
+++ b/donation_base/views/donation_tax_receipt.xml
@@ -43,19 +43,15 @@
-
-
-
-
-
+
- donation.tax.receipt.tree
+ donation.tax.receipt.list
donation.tax.receipt
-
+
@@ -75,7 +71,7 @@
groups="base.group_multi_company"
optional="show"
/>
-
+
@@ -153,6 +149,6 @@
Donation Tax Receipts
donation.tax.receipt
- tree,form,graph,pivot
+ list,form,graph,pivot
diff --git a/donation_base/views/product.xml b/donation_base/views/product.xml
index d2c0c3cde..b2dc201c6 100644
--- a/donation_base/views/product.xml
+++ b/donation_base/views/product.xml
@@ -11,11 +11,11 @@
product.template
-
+
@@ -32,12 +32,10 @@
product.template
-
-
-
+
+
+
+
diff --git a/donation_base/views/res_partner.xml b/donation_base/views/res_partner.xml
index fead18309..7aa984608 100644
--- a/donation_base/views/res_partner.xml
+++ b/donation_base/views/res_partner.xml
@@ -9,7 +9,7 @@
Donation Tax Receipts
donation.tax.receipt
- tree,form,graph,pivot
+ list,form,graph,pivot
{'search_default_partner_id': active_id}
@@ -21,10 +21,7 @@
expr="//group[@name='fiscal_information']/field[@name='property_account_position_id']"
position="after"
>
-
+
@@ -33,7 +30,7 @@
class="oe_stat_button"
type="action"
name="%(donation_base.partner_tax_receipt_action)d"
- attrs="{'invisible': [('parent_id', '!=', False)]}"
+ invisible="parent_id != False"
icon="fa-file-text"
groups="account.group_account_invoice,account.group_account_readonly"
>
@@ -59,7 +56,7 @@
Donors
res.partner
- kanban,tree,form
+ kanban,list,form
{'search_default_donor': 1, 'res_partner_search_mode': 'donor', 'default_is_company': False, 'default_donor_rank': 1}
diff --git a/donation_base/wizard/tax_receipt_annual_create.py b/donation_base/wizard/tax_receipt_annual_create.py
index 670ce76fa..5220cfa58 100644
--- a/donation_base/wizard/tax_receipt_annual_create.py
+++ b/donation_base/wizard/tax_receipt_annual_create.py
@@ -83,7 +83,7 @@ def generate_annual_receipts(self):
raise UserError(
_(
"The Donor '%(partner)s' already has an annual tax receipt "
- "in this timeframe: %(receipt)s dated %(number)s.",
+ "in this timeframe: %(receipt)s dated %(date)s.",
partner=partner.display_name,
receipt=existing_receipt.number,
date=format_date(self.env, existing_receipt.date),