diff --git a/website_sale_installment_plans/README.rst b/website_sale_installment_plans/README.rst new file mode 100644 index 00000000..a529f1ea --- /dev/null +++ b/website_sale_installment_plans/README.rst @@ -0,0 +1,73 @@ +.. |company| replace:: ADHOC SA + +.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png + :alt: ADHOC SA + :target: https://www.adhoc.com.ar + +.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png + +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +============================== +Website Sale Installment Plans +============================== + +This module adds a feature in card installment to show installment plans on the website. + +Installation +============ + +To install this module, you need to: + +#. Just install ... + +Configuration +============= + +To configure this module, you need to: + +#. Go to Card installment. +#. Choose a Card installment plan. +#. Set the installment plan to be shown on the website. + +Usage +===== + +To use this module, you need to: + + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: http://runbot.adhoc.com.ar/ + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +.. image:: https://github.com/ingadhoc/website/raw/16.0/website_sale_installment_plans/static/description/feature_img.png + +* |company| |icon| + +Contributors +------------ + +Maintainer +---------- + +|company_logo| + +This module is maintained by the |company|. + +To contribute to this module, please visit https://www.adhoc.com.ar. diff --git a/website_sale_installment_plans/__init__.py b/website_sale_installment_plans/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/website_sale_installment_plans/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/website_sale_installment_plans/__manifest__.py b/website_sale_installment_plans/__manifest__.py new file mode 100644 index 00000000..96d89009 --- /dev/null +++ b/website_sale_installment_plans/__manifest__.py @@ -0,0 +1,18 @@ +{ + "name": "Website Sale Installment Plan", + "category": "Website/Website", + "version": "17.0.1.0.0", + "author": "ADHOC SA", + "website": "www.adhoc.com.ar", + "license": "AGPL-3", + "depends": [ + "product", + "website_sale", + "card_installment", + ], + "data": [ + "views/account_card_installment_views.xml", + "views/website_templates.xml", + ], + "installable": True, +} diff --git a/website_sale_installment_plans/i18n/es.po b/website_sale_installment_plans/i18n/es.po new file mode 100644 index 00000000..a998ef59 --- /dev/null +++ b/website_sale_installment_plans/i18n/es.po @@ -0,0 +1,70 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_installment_plans +# +# Translators: +# Juan José Scarafía , 2025 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-08-20 21:21+0000\n" +"PO-Revision-Date: 2025-08-20 21:21+0000\n" +"Last-Translator: Juan José Scarafía , 2025\n" +"Language-Team: Spanish (https://app.transifex.com/adhoc/teams/46451/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" + +#. module: website_sale_installment_plans +#: model:ir.model.fields,field_description:website_sale_installment_plans.field_account_card_installment__can_publish +msgid "Can Publish" +msgstr "" + +#. module: website_sale_installment_plans +#: model:ir.model.fields,field_description:website_sale_installment_plans.field_account_card_installment__is_published +msgid "Is Published" +msgstr "Publicado" + +#. module: website_sale_installment_plans +#: model:ir.model.fields,help:website_sale_installment_plans.field_account_card_installment__message +msgid "Mensaje que se muestra al final de la leyenda de cuotas" +msgstr "Message shown at the end of installments text" + +#. module: website_sale_installment_plans +#: model:ir.model.fields,field_description:website_sale_installment_plans.field_account_card_installment__message +msgid "Message" +msgstr "Mensaje" + +#. module: website_sale_installment_plans +#: model:ir.model,name:website_sale_installment_plans.model_product_template +msgid "Product" +msgstr "Producto" + +#. module: website_sale_installment_plans +#: model_terms:ir.ui.view,arch_db:website_sale_installment_plans.account_card_form_installment_plan +msgid "Published in website" +msgstr "Publicado en website" + +#. module: website_sale_installment_plans +#: model:ir.model.fields,help:website_sale_installment_plans.field_account_card_installment__website_url +msgid "The full URL to access the document through the website." +msgstr "URL completa para acceder al documento a través del sitio web" + +#. module: website_sale_installment_plans +#: model:ir.model.fields,field_description:website_sale_installment_plans.field_account_card_installment__website_published +msgid "Visible on current website" +msgstr "Visible en el website actual" + +#. module: website_sale_installment_plans +#: model:ir.model.fields,field_description:website_sale_installment_plans.field_account_card_installment__website_url +msgid "Website URL" +msgstr "URL del Sitio Web" + +#. module: website_sale_installment_plans +#: model:ir.model,name:website_sale_installment_plans.model_account_card_installment +msgid "amount to add for collection in installments" +msgstr "Cantidad a añadir para cobro en cuotas" diff --git a/website_sale_installment_plans/models/__init__.py b/website_sale_installment_plans/models/__init__.py new file mode 100644 index 00000000..11afd830 --- /dev/null +++ b/website_sale_installment_plans/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_card_installment +from . import product_template diff --git a/website_sale_installment_plans/models/account_card_installment.py b/website_sale_installment_plans/models/account_card_installment.py new file mode 100644 index 00000000..15592fcd --- /dev/null +++ b/website_sale_installment_plans/models/account_card_installment.py @@ -0,0 +1,30 @@ +from odoo import fields, models + + +class AccountCardInstallment(models.Model): + _name = "account.card.installment" + _inherit = ["account.card.installment", "website.published.mixin"] + + message = fields.Char(help="Mensaje que se muestra al final de la leyenda de cuotas") + + def map_installment_values(self, amount_total): + self.ensure_one() + + result = super().map_installment_values(amount_total) + + divisor = self.divisor if self.divisor else 1 + installment = self.installment if self.installment else 1 + amount = result["amount"] + description = ( + "En %s cuota de $%.2f" % (divisor, amount) + if divisor == 1 + else "En %s cuotas de $%.2f (Total $%.2f)" % (installment, amount / installment, amount) + ) + + result.update( + { + "description": description, + } + ) + + return result diff --git a/website_sale_installment_plans/models/product_template.py b/website_sale_installment_plans/models/product_template.py new file mode 100644 index 00000000..ada880c7 --- /dev/null +++ b/website_sale_installment_plans/models/product_template.py @@ -0,0 +1,43 @@ +from odoo import models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + def _get_published_installments(self): + return self.env["account.card.installment"].sudo().search([("is_published", "=", True)]) + + def _get_installment_plans(self, price): + plans = [] + for cuota in self._get_published_installments(): + values = cuota.map_installment_values(price) + plans.append( + { + "installments": cuota.installment, + "description": values["description"], + "message": cuota.message or "", + } + ) + return plans + + def _get_combination_info( + self, combination=False, product_id=False, add_qty=1, parent_combination=False, only_template=False + ): + combination_info = super()._get_combination_info( + combination=combination, + product_id=product_id, + add_qty=add_qty, + parent_combination=parent_combination, + only_template=only_template, + ) + + product_price = combination_info.get("price", 0) + installment_plans = self._get_installment_plans(product_price) + combination_info.update({"installment_plans": installment_plans}) + + return combination_info + + def _get_card_installments_for_shop(self, context_price): + installment_plans = self._get_installment_plans(context_price) + + return installment_plans diff --git a/website_sale_installment_plans/static/description/feature_img.png b/website_sale_installment_plans/static/description/feature_img.png new file mode 100644 index 00000000..a742bc54 Binary files /dev/null and b/website_sale_installment_plans/static/description/feature_img.png differ diff --git a/website_sale_installment_plans/views/account_card_installment_views.xml b/website_sale_installment_plans/views/account_card_installment_views.xml new file mode 100644 index 00000000..e695c8d9 --- /dev/null +++ b/website_sale_installment_plans/views/account_card_installment_views.xml @@ -0,0 +1,15 @@ + + + account_card.form.view.installment.plan + account.card + + + + + + + + + + + diff --git a/website_sale_installment_plans/views/website_templates.xml b/website_sale_installment_plans/views/website_templates.xml new file mode 100644 index 00000000..1b698801 --- /dev/null +++ b/website_sale_installment_plans/views/website_templates.xml @@ -0,0 +1,39 @@ + + + + + +