diff --git a/loyalty_limit/README.rst b/loyalty_limit/README.rst new file mode 100644 index 000000000..3d874be93 --- /dev/null +++ b/loyalty_limit/README.rst @@ -0,0 +1,94 @@ +============= +Loyalty Limit +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c1badaa74b82a3331c9b943affe0cd31f7fffd24e1815aea5cacb0db04390fcf + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github + :target: https://github.com/OCA/sale-promotion/tree/17.0/loyalty_limit + :alt: OCA/sale-promotion +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-promotion-17-0/sale-promotion-17-0-loyalty_limit + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to configure a limit on the times a promotion can be +applied. It's a technical base to be extended with top level +functionality (sales, pos). + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Pedro M. Baeza + - David Vidal + - Pilar Vargas + +- `Akretion `__: + + - Florian Mounier + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-chienandalu| image:: https://github.com/chienandalu.png?size=40px + :target: https://github.com/chienandalu + :alt: chienandalu + +Current `maintainer `__: + +|maintainer-chienandalu| + +This module is part of the `OCA/sale-promotion `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/loyalty_limit/__init__.py b/loyalty_limit/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/loyalty_limit/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/loyalty_limit/__manifest__.py b/loyalty_limit/__manifest__.py new file mode 100644 index 000000000..dfbc223a9 --- /dev/null +++ b/loyalty_limit/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2021 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Loyalty Limit", + "summary": "Restrict number of promotions per customer or salesman", + "version": "17.0.1.0.0", + "development_status": "Production/Stable", + "category": "Sale", + "website": "https://github.com/OCA/sale-promotion", + "author": "Tecnativa, Odoo Community Association (OCA)", + "maintainers": ["chienandalu"], + "license": "AGPL-3", + "depends": ["loyalty"], + "data": ["views/loyalty_program_views.xml", "security/ir.model.access.csv"], +} diff --git a/loyalty_limit/i18n/es.po b/loyalty_limit/i18n/es.po new file mode 100644 index 000000000..6aa7a7f69 --- /dev/null +++ b/loyalty_limit/i18n/es.po @@ -0,0 +1,162 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * loyalty_limit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-01-17 09:19+0000\n" +"PO-Revision-Date: 2025-01-17 09:19+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: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__id +msgid "ID" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__salesmen_strict_limit +msgid "" +"If marked, promotion will only be allowed for the list of salesmen with " +"their quantities" +msgstr "" +"Si se marca, la promoción sólo se permitirá para la lista de vendedores con " +"sus cantidades" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__write_uid +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__write_date +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_loyalty_program +msgid "Loyalty Program" +msgstr "Programa de fidelización" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_loyalty_salesmen_limit +msgid "Loyalty Salesmen limits" +msgstr "Límites de los vendedores fieles" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max. Customer Applications" +msgstr "Max. Aplicaciones del cliente" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max. Salesmen Applications" +msgstr "Max. Vendedores Aplicaciones" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__max_customer_application +msgid "Maximum Customer Applications" +msgstr "Máximas aplicaciones para el cliente" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__max_salesman_application +msgid "Maximum Salesman Applications" +msgstr "Máximas aplicaciones para el vendedor" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_salesmen_limit__max_salesman_application +msgid "Maximum times a salesman can apply a program. 0 for no limit." +msgstr "Máximo de veces que un vendedor puede aplicar un programa. 0 para ningún límite." + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__salesmen_limit_ids +msgid "Maximum times salesmen can apply a program. Empty for no limit." +msgstr "Máximo de veces que los vendedores pueden aplicar un programa. Vacío para sin límite." + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__max_customer_application +msgid "" +"Maximum times that a program can be applied to a customer. 0 for no limit." +msgstr "" +"Máximo de veces que se puede aplicar un programa a un cliente. 0 para ningún límite." + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__program_id +msgid "Program" +msgstr "Programa" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__user_id +msgid "Salesman" +msgstr "Vendedor" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_ids +msgid "Salesmen Limits" +msgstr "Límites para vendedores" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_count +msgid "Salesmen maximum promotions" +msgstr "Promociones máximas de vendedores" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_used_count +msgid "Salesmen promotions used" +msgstr "Promociones de vendedores utilizadas" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_strict_limit +msgid "Strict limit" +msgstr "Limite estricto" + +#. module: loyalty_limit +#: model:ir.model.constraint,message:loyalty_limit.constraint_loyalty_salesmen_limit_user_id_uniq +msgid "This salesman limit is already configured" +msgstr "Este límite de vendedor ya está configurado" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Total limit" +msgstr "Limite total" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Total used" +msgstr "Total utilizado" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__times_used +msgid "Uses" +msgstr "Utiliza" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "used already)" +msgstr "ya utilizado)" diff --git a/loyalty_limit/i18n/it.po b/loyalty_limit/i18n/it.po new file mode 100644 index 000000000..8888cb605 --- /dev/null +++ b/loyalty_limit/i18n/it.po @@ -0,0 +1,173 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * loyalty_limit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-06 17:33+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__id +msgid "ID" +msgstr "ID" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__salesmen_strict_limit +msgid "" +"If marked, promotion will only be allowed for the list of salesmen with " +"their quantities" +msgstr "" +"Se abilitato, la promozione sarà ammessa solo per gli addetti alla vendita " +"indicati per le loro relative quantità" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_loyalty_salesmen_limit +msgid "Loyalty Salesmen limits" +msgstr "Limiti programma fedeltà venditore" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_loyalty_program +msgid "Loyalty display on a website" +msgstr "Programma fedeltà visualizzato su sito web" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max" +msgstr "Massimo" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max. Customer Applications" +msgstr "Usi massimi per cliente" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max. Salesmen Applications" +msgstr "Usi massimi per addetto alle vendite" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__max_customer_application +msgid "Maximum Customer Applications" +msgstr "Usi massimi per cliente" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__max_salesman_application +msgid "Maximum Salesman Applications" +msgstr "Usi massimi per addetto alle vendite" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_salesmen_limit__max_salesman_application +msgid "Maximum times a salesman can apply a program. 0 for no limit." +msgstr "" +"Numero massimo di volte un addetto alle vendite può applicare un programma. " +"0 se illimitato." + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__salesmen_limit_ids +msgid "Maximum times salesmen can apply a program. Empty for no limit." +msgstr "" +"Numero massimo di volte un addetto alle vendite può applicare un programma. " +"Vuoto se illimitato." + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__max_customer_application +msgid "" +"Maximum times that a program can be applied to a customer. 0 for no limit." +msgstr "" +"Numero massimo di volte che un programma può essere applicato ad un cliente. " +"0 se illimitato." + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__program_id +msgid "Program" +msgstr "Programma" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__user_id +msgid "Salesman" +msgstr "Addetto alle vendite" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_ids +msgid "Salesmen Limits" +msgstr "Limiti addetto alle vendite" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_count +msgid "Salesmen maximum promotions" +msgstr "Massimo promozioni per addetto alle vendite" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_used_count +msgid "Salesmen promotions used" +msgstr "Promozioni usate addetto alle vendite" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_strict_limit +msgid "Strict limit" +msgstr "Limite rigido" + +#. module: loyalty_limit +#: model:ir.model.constraint,message:loyalty_limit.constraint_loyalty_salesmen_limit_user_id_uniq +msgid "This salesman limit is already configured" +msgstr "Il limite per questo addetto alle vendite è già configurato" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Total limit" +msgstr "Limite totale" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Total used" +msgstr "Totale utilizzati" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__times_used +msgid "Uses" +msgstr "Usi" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "used already)" +msgstr "già usati)" diff --git a/loyalty_limit/i18n/loyalty_limit.pot b/loyalty_limit/i18n/loyalty_limit.pot new file mode 100644 index 000000000..89f93e608 --- /dev/null +++ b/loyalty_limit/i18n/loyalty_limit.pot @@ -0,0 +1,162 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * loyalty_limit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \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: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__create_uid +msgid "Created by" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__create_date +msgid "Created on" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__display_name +msgid "Display Name" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__id +msgid "ID" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__salesmen_strict_limit +msgid "" +"If marked, promotion will only be allowed for the list of salesmen with " +"their quantities" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit____last_update +msgid "Last Modified on" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__write_date +msgid "Last Updated on" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_loyalty_salesmen_limit +msgid "Loyalty Salesmen limits" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_loyalty_program +msgid "Loyalty display on a website" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max. Customer Applications" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Max. Salesmen Applications" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__max_customer_application +msgid "Maximum Customer Applications" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__max_salesman_application +msgid "Maximum Salesman Applications" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_salesmen_limit__max_salesman_application +msgid "Maximum times a salesman can apply a program. 0 for no limit." +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__salesmen_limit_ids +msgid "Maximum times salesmen can apply a program. Empty for no limit." +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_loyalty_program__max_customer_application +msgid "" +"Maximum times that a program can be applied to a customer. 0 for no limit." +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__program_id +msgid "Program" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__user_id +msgid "Salesman" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_ids +msgid "Salesmen Limits" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_count +msgid "Salesmen maximum promotions" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_limit_used_count +msgid "Salesmen promotions used" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_program__salesmen_strict_limit +msgid "Strict limit" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.constraint,message:loyalty_limit.constraint_loyalty_salesmen_limit_user_id_uniq +msgid "This salesman limit is already configured" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Total limit" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "Total used" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_loyalty_salesmen_limit__times_used +msgid "Uses" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.loyalty_program_view_form +msgid "used already)" +msgstr "" diff --git a/loyalty_limit/models/__init__.py b/loyalty_limit/models/__init__.py new file mode 100644 index 000000000..9afd49560 --- /dev/null +++ b/loyalty_limit/models/__init__.py @@ -0,0 +1 @@ +from . import loyalty_program diff --git a/loyalty_limit/models/loyalty_program.py b/loyalty_limit/models/loyalty_program.py new file mode 100644 index 000000000..7b0ca43b5 --- /dev/null +++ b/loyalty_limit/models/loyalty_program.py @@ -0,0 +1,83 @@ +# Copyright 2021 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class LoyaltyProgram(models.Model): + _inherit = "loyalty.program" + + max_customer_application = fields.Integer( + string="Maximum Customer Applications", + default=0, + help="Maximum times that a program can be applied to a customer. " + "0 for no limit.", + ) + salesmen_limit_ids = fields.One2many( + string="Salesmen Limits", + comodel_name="loyalty.salesmen.limit", + inverse_name="program_id", + help="Maximum times salesmen can apply a program. Empty for no limit.", + ) + salesmen_strict_limit = fields.Boolean( + default=False, + string="Strict limit", + help="If marked, promotion will only be allowed for the list of salesmen with " + "their quantities", + ) + salesmen_limit_count = fields.Integer( + string="Salesmen maximum promotions", + compute="_compute_salesmen_limit_count", + ) + salesmen_limit_used_count = fields.Integer( + string="Salesmen promotions used", + compute="_compute_salesmen_limit_count", + ) + + @api.depends( + "salesmen_limit_ids.max_salesman_application", + "salesmen_limit_ids.times_used", + ) + def _compute_salesmen_limit_count(self): + """To be overriden""" + self.salesmen_limit_count = 0 + self.salesmen_limit_used_count = 0 + + +class LoyaltySalesmenLimit(models.Model): + _name = "loyalty.salesmen.limit" + _description = "Loyalty Salesmen limits" + + program_id = fields.Many2one( + comodel_name="loyalty.program", + auto_join=True, + required=True, + ondelete="cascade", + ) + user_id = fields.Many2one( + comodel_name="res.users", + string="Salesman", + required=True, + ondelete="cascade", + ) + max_salesman_application = fields.Integer( + string="Maximum Salesman Applications", + default=0, + help="Maximum times a salesman can apply a program. 0 for no limit.", + ) + times_used = fields.Integer( + string="Uses", + compute="_compute_times_used", + ) + + _sql_constraints = [ + ( + "user_id_uniq", + "unique(program_id, user_id)", + "This salesman limit is already configured", + ), + ] + + @api.depends("user_id", "max_salesman_application") + def _compute_times_used(self): + """To be overriden""" + self.times_used = 0 diff --git a/loyalty_limit/pyproject.toml b/loyalty_limit/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/loyalty_limit/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/loyalty_limit/readme/CONTRIBUTORS.md b/loyalty_limit/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..b8b1b8688 --- /dev/null +++ b/loyalty_limit/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- [Tecnativa](https://www.tecnativa.com): + - Pedro M. Baeza + - David Vidal + - Pilar Vargas +- [Akretion](https://www.akretion.com): + - Florian Mounier diff --git a/loyalty_limit/readme/DESCRIPTION.md b/loyalty_limit/readme/DESCRIPTION.md new file mode 100644 index 000000000..86250e745 --- /dev/null +++ b/loyalty_limit/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module allows to configure a limit on the times a promotion can be +applied. It's a technical base to be extended with top level +functionality (sales, pos). diff --git a/loyalty_limit/security/ir.model.access.csv b/loyalty_limit/security/ir.model.access.csv new file mode 100644 index 000000000..30895d182 --- /dev/null +++ b/loyalty_limit/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_salesmen_limit_manager,salesmen_limit manager,model_loyalty_salesmen_limit,base.group_system,1,1,1,1 diff --git a/loyalty_limit/static/description/icon.png b/loyalty_limit/static/description/icon.png new file mode 100644 index 000000000..07f27584a Binary files /dev/null and b/loyalty_limit/static/description/icon.png differ diff --git a/loyalty_limit/static/description/icon.svg b/loyalty_limit/static/description/icon.svg new file mode 100644 index 000000000..e6b472ccf --- /dev/null +++ b/loyalty_limit/static/description/icon.svg @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/loyalty_limit/static/description/index.html b/loyalty_limit/static/description/index.html new file mode 100644 index 000000000..5e819d9d8 --- /dev/null +++ b/loyalty_limit/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +Loyalty Limit + + + +
+

Loyalty Limit

+ + +

Production/Stable License: AGPL-3 OCA/sale-promotion Translate me on Weblate Try me on Runboat

+

This module allows to configure a limit on the times a promotion can be +applied. It’s a technical base to be extended with top level +functionality (sales, pos).

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Pedro M. Baeza
    • +
    • David Vidal
    • +
    • Pilar Vargas
    • +
    +
  • +
  • Akretion:
      +
    • Florian Mounier
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

chienandalu

+

This module is part of the OCA/sale-promotion project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/loyalty_limit/tests/__init__.py b/loyalty_limit/tests/__init__.py new file mode 100644 index 000000000..22da88f20 --- /dev/null +++ b/loyalty_limit/tests/__init__.py @@ -0,0 +1 @@ +from . import test_loyalty_limit diff --git a/loyalty_limit/tests/test_loyalty_limit.py b/loyalty_limit/tests/test_loyalty_limit.py new file mode 100644 index 000000000..bb0f037e9 --- /dev/null +++ b/loyalty_limit/tests/test_loyalty_limit.py @@ -0,0 +1,285 @@ +# Copyright 2021 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import TransactionCase + + +class LoyaltyLimitCase(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + product_obj = cls.env["product.product"] + cls.pricelist = cls.env["product.pricelist"].create( + { + "name": "Test pricelist", + "item_ids": [ + ( + 0, + 0, + { + "applied_on": "3_global", + "compute_price": "formula", + "base": "list_price", + }, + ) + ], + } + ) + cls.partner_1 = cls.env["res.partner"].create( + {"name": "Mr. Odoo", "property_product_pricelist": cls.pricelist.id} + ) + cls.partner_2 = cls.env["res.partner"].create( + {"name": "Mrs. Odoo", "property_product_pricelist": cls.pricelist.id} + ) + cls.salesman_1 = cls.env["res.users"].create( + {"name": "Salesman 1", "login": "test_salesman_1"} + ) + cls.salesman_2 = cls.env["res.users"].create( + {"name": "Salesman 2", "login": "test_salesman_2"} + ) + cls.product_a = product_obj.create({"name": "Product A", "list_price": 50}) + cls.promotion_with_customer_limit = cls.env["loyalty.program"].create( + { + "name": "Test Loyalty Limit Promotion With Customer Limit", + "program_type": "promotion", + "trigger": "auto", + "applies_on": "current", + "max_customer_application": 2, + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + }, + ), + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "required_points": 1, + "discount": 10, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ], + } + ) + cls.promotion_with_salesman_limit = cls.env["loyalty.program"].create( + { + "name": "Test Loyalty Limit Promotion With Salesman Limit", + "program_type": "promotion", + "trigger": "auto", + "applies_on": "current", + "salesmen_limit_ids": [ + ( + 0, + 0, + { + "user_id": cls.salesman_1.id, + "max_salesman_application": 2, + }, + ), + ( + 0, + 0, + { + "user_id": cls.salesman_2.id, + "max_salesman_application": 2, + }, + ), + ], + "salesmen_strict_limit": False, + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + }, + ), + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "required_points": 1, + "discount": 10, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ], + } + ) + cls.coupon_program_with_customer_limit = cls.env["loyalty.program"].create( + { + "name": "Test Loyalty Limit Coupon With Customer Limit", + "trigger": "with_code", + "program_type": "coupons", + "applies_on": "current", + "max_customer_application": 2, + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + }, + ), + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "required_points": 1, + "discount": 10, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ], + } + ) + cls.coupon_program_with_salesman_limit = cls.env["loyalty.program"].create( + { + "name": "Test Loyalty Limit Coupon With Salesman Limit", + "trigger": "with_code", + "program_type": "coupons", + "applies_on": "current", + "salesmen_limit_ids": [ + ( + 0, + 0, + { + "user_id": cls.salesman_1.id, + "max_salesman_application": 2, + }, + ), + ( + 0, + 0, + { + "user_id": cls.salesman_2.id, + "max_salesman_application": 2, + }, + ), + ], + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + }, + ), + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "required_points": 1, + "discount": 10, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ], + } + ) + cls.next_order_coupon_with_customer_limit = cls.env["loyalty.program"].create( + { + "name": "Test Loyalty Limit Next Order Coupons With Customer Limit", + "program_type": "next_order_coupons", + "trigger": "auto", + "applies_on": "future", + "max_customer_application": 2, + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + "minimum_amount": 20, + }, + ) + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "required_points": 1, + "discount": 10, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ], + } + ) + cls.next_order_coupon_with_salesman_limit = cls.env["loyalty.program"].create( + { + "name": "Test Loyalty Limit Next Order Coupons With Salesman Limit", + "program_type": "next_order_coupons", + "trigger": "auto", + "applies_on": "future", + "salesmen_limit_ids": [ + ( + 0, + 0, + { + "user_id": cls.salesman_1.id, + "max_salesman_application": 2, + }, + ), + ( + 0, + 0, + { + "user_id": cls.salesman_2.id, + "max_salesman_application": 2, + }, + ), + ], + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + "minimum_amount": 20, + }, + ) + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "required_points": 1, + "discount": 10, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ], + } + ) diff --git a/loyalty_limit/views/loyalty_program_views.xml b/loyalty_limit/views/loyalty_program_views.xml new file mode 100644 index 000000000..07e19b0fa --- /dev/null +++ b/loyalty_limit/views/loyalty_program_views.xml @@ -0,0 +1,41 @@ + + + + + loyalty.program + + + + + +