Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions loyalty_margin_computation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
==========================
Loyalty Margin Computation
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:99ca6b7832e6b29fbbc6489547855ed99bb1650c68af1eb284981177f7e6c422
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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%2Fmargin--analysis-lightgray.png?logo=github
:target: https://github.com/OCA/margin-analysis/tree/18.0/loyalty_margin_computation
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/margin-analysis-18-0/margin-analysis-18-0-loyalty_margin_computation
: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/margin-analysis&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to configure a formula (Python code to use in sales,
pos). It's a technical base to be extended with top level functionality
(see *sale_loyalty_margin_computation*).

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/margin-analysis/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 <https://github.com/OCA/margin-analysis/issues/new?body=module:%20loyalty_margin_computation%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Pedro M. Baeza
- Andrii Kompaniiets

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.

This module is part of the `OCA/margin-analysis <https://github.com/OCA/margin-analysis/tree/18.0/loyalty_margin_computation>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions loyalty_margin_computation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions loyalty_margin_computation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Tecnativa - Andrii Kompaniiets
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Loyalty Margin Computation",
"summary": "Allows setting a formula to calculate the margin",
"version": "18.0.1.0.0",
"category": "Sale",
"website": "https://github.com/OCA/margin-analysis",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["loyalty"],
"data": ["views/loyalty_reward_views.xml"],
}
63 changes: 63 additions & 0 deletions loyalty_margin_computation/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * loyalty_margin_computation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-04-30 14:11+0000\n"
"PO-Revision-Date: 2026-04-30 16:14+0200\n"
"Last-Translator: Andrii Kompaniiets <andrii.kompaniiets@tecnativa.com>\n"
"Language-Team: \n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.9\n"

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "<code>env</code>: The Sale Order Line environment"
msgstr "<code>env</code>: El entorno de la línea de pedido de venta"

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "<code>reward</code>: The reward record"
msgstr "<code>reward</code>: El registro de recompensas"

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "Example of Python code:"
msgstr "Ejemplo de código en Python:"

#. module: loyalty_margin_computation
#: model:ir.model,name:loyalty_margin_computation.model_loyalty_reward
msgid "Loyalty Reward"
msgstr "Recompensa"

#. module: loyalty_margin_computation
#: model:ir.model.fields,field_description:loyalty_margin_computation.field_loyalty_reward__margin_price_formula
msgid "Margin Price Formula"
msgstr "Fórmula del precio de margen"

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "Margin's Formulas"
msgstr "Fórmulas de margen"

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "The following variables can be used:"
msgstr "Se pueden utilizar las siguientes variables:"

#. module: loyalty_margin_computation
#: model:ir.model.fields,help:loyalty_margin_computation.field_loyalty_reward__margin_price_formula
msgid "This formula is used to calculate the margin"
msgstr "Esta fórmula se utiliza para calcular el margen"

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "result = 10 if list_price &gt; 100 else 5"
msgstr ""
61 changes: 61 additions & 0 deletions loyalty_margin_computation/i18n/loyalty_margin_computation.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * loyalty_margin_computation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-04-30 14:11+0000\n"
"PO-Revision-Date: 2026-04-30 14:11+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_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "<code>env</code>: The Sale Order Line environment"
msgstr ""

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "<code>reward</code>: The reward record"
msgstr ""

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "Example of Python code:"
msgstr ""

#. module: loyalty_margin_computation
#: model:ir.model,name:loyalty_margin_computation.model_loyalty_reward
msgid "Loyalty Reward"
msgstr ""

#. module: loyalty_margin_computation
#: model:ir.model.fields,field_description:loyalty_margin_computation.field_loyalty_reward__margin_price_formula
msgid "Margin Price Formula"
msgstr ""

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "Margin's Formulas"
msgstr ""

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "The following variables can be used:"
msgstr ""

#. module: loyalty_margin_computation
#: model:ir.model.fields,help:loyalty_margin_computation.field_loyalty_reward__margin_price_formula
msgid "This formula is used to calculate the margin"
msgstr ""

#. module: loyalty_margin_computation
#: model_terms:ir.ui.view,arch_db:loyalty_margin_computation.margin_product_loyalty_reward_form_view
msgid "result = 10 if list_price &gt; 100 else 5"
msgstr ""
1 change: 1 addition & 0 deletions loyalty_margin_computation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import loyalty_reward
25 changes: 25 additions & 0 deletions loyalty_margin_computation/models/loyalty_reward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2026 Tecnativa - Andrii Kompaniiets
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.exceptions import ValidationError


class LoyaltyReward(models.Model):
_inherit = "loyalty.reward"

sale_margin_formula = fields.Text(
help="This formula is used to calculate the margin"
)

@api.constrains("sale_margin_formula")
def _check_sale_margin_formula(self):
# To be extended by other modules
for reward in self:
if not reward.sale_margin_formula:
continue
try:
compile(
str(reward.sale_margin_formula).strip(), "<string>", mode="exec"
)
except SyntaxError as e:
raise ValidationError(f"Syntax error {e.lineno}: {e.msg}") from e
3 changes: 3 additions & 0 deletions loyalty_margin_computation/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions loyalty_margin_computation/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Tecnativa](https://www.tecnativa.com):
- Pedro M. Baeza
- Andrii Kompaniiets
3 changes: 3 additions & 0 deletions loyalty_margin_computation/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module allows to configure a formula (Python code to use in sales, pos).
It's a technical base to be extended with top level functionality
(see *sale_loyalty_margin_computation*).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading