diff --git a/donation_base/__manifest__.py b/donation_base/__manifest__.py index e713c7042..2c2557244 100644 --- a/donation_base/__manifest__.py +++ b/donation_base/__manifest__.py @@ -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", diff --git a/donation_base/data/donation_mail_template.xml b/donation_base/data/donation_mail_template.xml index 7f459c073..a34877942 100644 --- a/donation_base/data/donation_mail_template.xml +++ b/donation_base/data/donation_mail_template.xml @@ -14,10 +14,13 @@ {{object.partner_id.id}} - {{object.company_id.name.replace(' ', '_')}}-Tax_Receipt_{{(object.number or '').replace('/','_')}} + name="report_template_ids" + eval="[(4, ref('report_donation_tax_receipt'))]" + /> + + + {{object.partner_id.lang}}
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 @@