From e48ae33939701e941d0cd18467001b67aa10bfc5 Mon Sep 17 00:00:00 2001 From: chien Date: Tue, 19 Mar 2024 18:08:15 +0700 Subject: [PATCH] [MIG] sale_loyalty_auto_refresh: Migration to 16.0 --- sale_coupon_auto_refresh/i18n/es.po | 99 -------------- sale_coupon_auto_refresh/i18n/fr.po | 105 --------------- sale_coupon_auto_refresh/i18n/it.po | 105 --------------- .../i18n/sale_coupon_auto_refresh.pot | 89 ------------- sale_coupon_auto_refresh/i18n/zh_CN.po | 103 -------------- sale_coupon_auto_refresh/models/sale_order.py | 126 ------------------ sale_coupon_auto_refresh/tests/__init__.py | 1 - sale_coupon_auto_refresh/wizard/__init__.py | 1 - .../wizard/sale_coupon_apply_code.py | 15 --- .../README.rst | 26 ++-- .../__init__.py | 0 .../__manifest__.py | 4 +- sale_loyalty_auto_refresh/i18n/es.po | 99 ++++++++++++++ sale_loyalty_auto_refresh/i18n/fr.po | 105 +++++++++++++++ sale_loyalty_auto_refresh/i18n/it.po | 105 +++++++++++++++ .../i18n/sale_loyalty_auto_refresh.pot | 89 +++++++++++++ sale_loyalty_auto_refresh/i18n/zh_CN.po | 103 ++++++++++++++ .../migrations/post-migration.py | 18 +++ .../models/__init__.py | 1 + .../models/res_company.py | 0 .../models/res_config_settings.py | 0 .../models/sale_coupon_refresh_mixin.py | 7 +- .../models/sale_order.py | 96 +++++++++++++ .../models/sale_order_line.py | 66 +++++++++ .../readme/CONFIGURE.rst | 6 +- .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 0 .../readme/ROADMAP.rst | 0 .../readme/USAGE.rst | 4 +- .../static/description/icon.png | Bin .../static/description/index.html | 22 +-- sale_loyalty_auto_refresh/tests/__init__.py | 1 + .../tests/test_sale_loyalty_auto_refresh.py | 88 ++++++++++-- .../views/res_config_settings_views.xml | 0 sale_loyalty_auto_refresh/wizard/__init__.py | 2 + .../wizard/sale_loyalty_coupon_wizard.py | 11 ++ .../wizard/sale_loyalty_reward_wizard.py | 11 ++ .../odoo/addons/sale_coupon_auto_refresh | 1 - .../odoo/addons/sale_loyalty_auto_refresh | 1 + .../setup.py | 0 40 files changed, 827 insertions(+), 687 deletions(-) delete mode 100644 sale_coupon_auto_refresh/i18n/es.po delete mode 100644 sale_coupon_auto_refresh/i18n/fr.po delete mode 100644 sale_coupon_auto_refresh/i18n/it.po delete mode 100644 sale_coupon_auto_refresh/i18n/sale_coupon_auto_refresh.pot delete mode 100644 sale_coupon_auto_refresh/i18n/zh_CN.po delete mode 100644 sale_coupon_auto_refresh/models/sale_order.py delete mode 100644 sale_coupon_auto_refresh/tests/__init__.py delete mode 100644 sale_coupon_auto_refresh/wizard/__init__.py delete mode 100644 sale_coupon_auto_refresh/wizard/sale_coupon_apply_code.py rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/README.rst (80%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/__init__.py (100%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/__manifest__.py (90%) create mode 100644 sale_loyalty_auto_refresh/i18n/es.po create mode 100644 sale_loyalty_auto_refresh/i18n/fr.po create mode 100644 sale_loyalty_auto_refresh/i18n/it.po create mode 100644 sale_loyalty_auto_refresh/i18n/sale_loyalty_auto_refresh.pot create mode 100644 sale_loyalty_auto_refresh/i18n/zh_CN.po create mode 100644 sale_loyalty_auto_refresh/migrations/post-migration.py rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/models/__init__.py (80%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/models/res_company.py (100%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/models/res_config_settings.py (100%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/models/sale_coupon_refresh_mixin.py (92%) create mode 100644 sale_loyalty_auto_refresh/models/sale_order.py create mode 100644 sale_loyalty_auto_refresh/models/sale_order_line.py rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/readme/CONFIGURE.rst (73%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/readme/CONTRIBUTORS.rst (65%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/readme/DESCRIPTION.rst (100%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/readme/ROADMAP.rst (100%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/readme/USAGE.rst (53%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/static/description/icon.png (100%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/static/description/index.html (88%) create mode 100644 sale_loyalty_auto_refresh/tests/__init__.py rename sale_coupon_auto_refresh/tests/test_sale_coupon_auto_refresh.py => sale_loyalty_auto_refresh/tests/test_sale_loyalty_auto_refresh.py (68%) rename {sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/views/res_config_settings_views.xml (100%) create mode 100644 sale_loyalty_auto_refresh/wizard/__init__.py create mode 100644 sale_loyalty_auto_refresh/wizard/sale_loyalty_coupon_wizard.py create mode 100644 sale_loyalty_auto_refresh/wizard/sale_loyalty_reward_wizard.py delete mode 120000 setup/sale_coupon_auto_refresh/odoo/addons/sale_coupon_auto_refresh create mode 120000 setup/sale_loyalty_auto_refresh/odoo/addons/sale_loyalty_auto_refresh rename setup/{sale_coupon_auto_refresh => sale_loyalty_auto_refresh}/setup.py (100%) diff --git a/sale_coupon_auto_refresh/i18n/es.po b/sale_coupon_auto_refresh/i18n/es.po deleted file mode 100644 index 70bb6040c..000000000 --- a/sale_coupon_auto_refresh/i18n/es.po +++ /dev/null @@ -1,99 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * sale_coupon_auto_refresh -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2023-11-08 13:38+0000\n" -"Last-Translator: Ivorra78 \n" -"Language-Team: \n" -"Language: es\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: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"" -msgstr "" -"" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data -msgid "Auto Refresh Coupon Triggers Data" -msgstr "Actualizar Automáticamente los Datos de los Activadores de Cupones" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Auto Refresh Coupons" -msgstr "Auto actualizar ofertas" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto refresh coupons" -msgstr "Auto actualizar ofertas" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto-refresh coupons" -msgstr "Auto actualizar ofertas" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Autorefresh coupon lines in the backorder" -msgstr "Auto actualizar las líneas de descuento en backorder" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_company -msgid "Companies" -msgstr "Compañías" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_config_settings -msgid "Config Settings" -msgstr "Ajustes" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_refresh_mixin -msgid "Mixin class for sale coupon auto-refresh features" -msgstr "Clase mixta de actualización automática de cupones de descuento" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_apply_code -msgid "Sales Coupon Apply Code" -msgstr "Cupón de descuento Aplicar código" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order -msgid "Sales Order" -msgstr "Orden de Venta" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order_line -msgid "Sales Order Line" -msgstr "Línea de Orden de Venta" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"When the sale order is updated, auto-refresh the promotion programs which " -"are set to auto apply" -msgstr "" -"Cuando se actualice un pedido de venta, auto actualizar los programas de " -"oferta configurados para auto aplicarse" - -#~ msgid "Sale Order" -#~ msgstr "Pedido de Venta" diff --git a/sale_coupon_auto_refresh/i18n/fr.po b/sale_coupon_auto_refresh/i18n/fr.po deleted file mode 100644 index 300762114..000000000 --- a/sale_coupon_auto_refresh/i18n/fr.po +++ /dev/null @@ -1,105 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * sale_coupon_auto_refresh -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-09-18 14:34+0000\n" -"Last-Translator: Rémi \n" -"Language-Team: none\n" -"Language: fr\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.3.2\n" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"" -msgstr "" -"" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data -msgid "Auto Refresh Coupon Triggers Data" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Auto Refresh Coupons" -msgstr "Mise à jour automatique des promotions" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto refresh coupons" -msgstr "Mise à jour automatique des promotions" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto-refresh coupons" -msgstr "Mise à jour automatique des promotions" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Autorefresh coupon lines in the backorder" -msgstr "Mise à jour automatique des promotions" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_company -msgid "Companies" -msgstr "Sociétés" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_config_settings -msgid "Config Settings" -msgstr "Configuration" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_refresh_mixin -msgid "Mixin class for sale coupon auto-refresh features" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_apply_code -msgid "Sales Coupon Apply Code" -msgstr "Utiliser le code promotionnel" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order -msgid "Sales Order" -msgstr "Commandes" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order_line -msgid "Sales Order Line" -msgstr "Ligne de Commande" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"When the sale order is updated, auto-refresh the promotion programs which " -"are set to auto apply" -msgstr "" -"Quand le devis est mis à jour, recalcule automatiquement les programmes de " -"promotions configurés pour application automatique" - -#~ msgid "Display Name" -#~ msgstr "Nom affiché" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Date de dernière modification" diff --git a/sale_coupon_auto_refresh/i18n/it.po b/sale_coupon_auto_refresh/i18n/it.po deleted file mode 100644 index 2db4ff65c..000000000 --- a/sale_coupon_auto_refresh/i18n/it.po +++ /dev/null @@ -1,105 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * sale_coupon_auto_refresh -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2022-04-28 10:05+0000\n" -"Last-Translator: Francesco Foresti \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.3.2\n" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"" -msgstr "" -"" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data -msgid "Auto Refresh Coupon Triggers Data" -msgstr "Dati trigger aggiornamento automatic coupons" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Auto Refresh Coupons" -msgstr "Aggiornamento automatico coupons" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto refresh coupons" -msgstr "Aggiornamento automatico coupons" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto-refresh coupons" -msgstr "Aggiornamento automatico coupons" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Autorefresh coupon lines in the backorder" -msgstr "Aggiorna automaticamente righe coupon nell'ordine residuo" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_company -msgid "Companies" -msgstr "Aziende" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_config_settings -msgid "Config Settings" -msgstr "Impostazioni configurazione" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_refresh_mixin -msgid "Mixin class for sale coupon auto-refresh features" -msgstr "Classe mixin per funzionalità aggiornamento automatico coupon" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_apply_code -msgid "Sales Coupon Apply Code" -msgstr "Applica codice coupon vendite" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order -msgid "Sales Order" -msgstr "Ordine di vendita" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order_line -msgid "Sales Order Line" -msgstr "Riga ordine di vendita" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"When the sale order is updated, auto-refresh the promotion programs which " -"are set to auto apply" -msgstr "" -"Quando l'ordine di vendita è aggiornato, aggiorna automaticamente le " -"promozioni che sono impostate ad \"applica automaticamente\"" - -#~ msgid "Display Name" -#~ msgstr "Nome Visualizzato" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Ultima modifica il" diff --git a/sale_coupon_auto_refresh/i18n/sale_coupon_auto_refresh.pot b/sale_coupon_auto_refresh/i18n/sale_coupon_auto_refresh.pot deleted file mode 100644 index 46d7856f1..000000000 --- a/sale_coupon_auto_refresh/i18n/sale_coupon_auto_refresh.pot +++ /dev/null @@ -1,89 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * sale_coupon_auto_refresh -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 15.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: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data -msgid "Auto Refresh Coupon Triggers Data" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Auto Refresh Coupons" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto refresh coupons" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto-refresh coupons" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Autorefresh coupon lines in the backorder" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_company -msgid "Companies" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_config_settings -msgid "Config Settings" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_refresh_mixin -msgid "Mixin class for sale coupon auto-refresh features" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_apply_code -msgid "Sales Coupon Apply Code" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order -msgid "Sales Order" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order_line -msgid "Sales Order Line" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"When the sale order is updated, auto-refresh the promotion programs which " -"are set to auto apply" -msgstr "" diff --git a/sale_coupon_auto_refresh/i18n/zh_CN.po b/sale_coupon_auto_refresh/i18n/zh_CN.po deleted file mode 100644 index befc56f65..000000000 --- a/sale_coupon_auto_refresh/i18n/zh_CN.po +++ /dev/null @@ -1,103 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * sale_coupon_auto_refresh -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-09-02 04:50+0000\n" -"Last-Translator: 黎伟杰 <674416404@qq.com>\n" -"Language-Team: none\n" -"Language: zh_CN\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.3.2\n" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"" -msgstr "" -"" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data -msgid "Auto Refresh Coupon Triggers Data" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,field_description:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Auto Refresh Coupons" -msgstr "自动刷新优惠券" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto refresh coupons" -msgstr "自动刷新优惠券" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "Auto-refresh coupons" -msgstr "自动刷新优惠券" - -#. module: sale_coupon_auto_refresh -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_company__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_res_config_settings__auto_refresh_coupon -#: model:ir.model.fields,help:sale_coupon_auto_refresh.field_sale_order__auto_refresh_coupon -msgid "Autorefresh coupon lines in the backorder" -msgstr "自动刷新延期交货中的优惠券行" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_company -msgid "Companies" -msgstr "公司" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_res_config_settings -msgid "Config Settings" -msgstr "配置设置" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_refresh_mixin -msgid "Mixin class for sale coupon auto-refresh features" -msgstr "" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_coupon_apply_code -msgid "Sales Coupon Apply Code" -msgstr "销售优惠券申请代码" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order -msgid "Sales Order" -msgstr "销售订单" - -#. module: sale_coupon_auto_refresh -#: model:ir.model,name:sale_coupon_auto_refresh.model_sale_order_line -msgid "Sales Order Line" -msgstr "销售订单行" - -#. module: sale_coupon_auto_refresh -#: model_terms:ir.ui.view,arch_db:sale_coupon_auto_refresh.res_config_settings_view_form -msgid "" -"When the sale order is updated, auto-refresh the promotion programs which " -"are set to auto apply" -msgstr "当销售订单更新时,自动刷新设置为自动应用的促销计划" - -#~ msgid "Display Name" -#~ msgstr "显示名称" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "最后修改日" diff --git a/sale_coupon_auto_refresh/models/sale_order.py b/sale_coupon_auto_refresh/models/sale_order.py deleted file mode 100644 index d963c991d..000000000 --- a/sale_coupon_auto_refresh/models/sale_order.py +++ /dev/null @@ -1,126 +0,0 @@ -# Copyright 2021 Tecnativa - David Vidal -# Copyright 2021 Camptocamp - Silvio Gregorini -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from odoo import api, fields, models - - -class SaleOrder(models.Model): - _name = "sale.order" - _inherit = ["sale.order", "sale.coupon.refresh.mixin"] - - # Used in UI to hide the manual button - auto_refresh_coupon = fields.Boolean( - related="company_id.auto_refresh_coupon", - ) - - @api.model_create_multi - def create(self, vals_list): - if self._check_skip_refresh(): - return super().create(vals_list) - - self_ctx = self.with_context(skip_auto_refresh_coupons=True) - orders = super(SaleOrder, self_ctx).create(vals_list) - orders._auto_refresh_coupons() - return orders - - def write(self, vals): - if self._check_skip_refresh(): - return super().write(vals) - - old_data = self._read_recs_data() - self_ctx = self.with_context(skip_auto_refresh_coupons=True) - res = super(SaleOrder, self_ctx).write(vals) - new_data = self._read_recs_data() - # Until we restart Odoo, we won't get new triggers from params. Once restarted - # the method will return an empty set. - new_triggers = self._new_trigger() - if old_data != new_data or any(x in new_triggers for x in vals): - self._auto_refresh_coupons() - return res - - def _auto_refresh_coupons(self): - orders = self.filtered(type(self)._allow_recompute_coupon_lines) - if orders: - orders = orders.with_context(skip_auto_refresh_coupons=True) - orders.recompute_coupon_lines() - - def _allow_recompute_coupon_lines(self): - """Returns whether reward lines in order ``self`` can be recomputed - automatically. - - Hook method, to be overridden for custom behaviours. - - :return: True if the current SO allows automatic recomputation for - reward lines, False otherwise. - """ - self.ensure_one() - return self.auto_refresh_coupon and self.state in ("draft", "sent") - - @api.model - def _get_auto_refresh_coupons_triggers(self) -> set: - triggers = super()._get_auto_refresh_coupons_triggers() - triggers.update( - { - "order_line.auto_refresh_coupon_triggers_data", - "partner_id", - } - ) - return triggers - - -class SaleOrderLine(models.Model): - _name = "sale.order.line" - _inherit = ["sale.order.line", "sale.coupon.refresh.mixin"] - - @api.model_create_multi - def create(self, vals_list): - if self._check_skip_refresh(): - return super().create(vals_list) - - self_ctx = self.with_context(skip_auto_refresh_coupons=True) - lines = super(SaleOrderLine, self_ctx).create(vals_list) - lines.mapped("order_id")._auto_refresh_coupons() - return lines - - def write(self, vals): - if self._check_skip_refresh(): - return super().write(vals) - - old_data = self._read_recs_data() - old_orders = self.mapped("order_id") - self_ctx = self.with_context(skip_auto_refresh_coupons=True) - res = super(SaleOrderLine, self_ctx).write(vals) - new_data = self._read_recs_data() - new_orders = self.mapped("order_id") - # Until we restart Odoo, we won't get new triggers from params. Once restarted - # the method will return an empty set. - new_triggers = self._new_trigger() - if old_data != new_data or any(x in new_triggers for x in vals): - (old_orders | new_orders)._auto_refresh_coupons() - return res - - def unlink(self): - if self._check_skip_refresh(): - return super().unlink() - - orders = self.mapped("order_id") - self_ctx = self.with_context(skip_auto_refresh_coupons=True) - res = super(SaleOrderLine, self_ctx).unlink() - orders._auto_refresh_coupons() - return res - - @api.model - def _get_auto_refresh_coupons_triggers(self) -> set: - triggers = super()._get_auto_refresh_coupons_triggers() - triggers.update( - { - "discount", - "product_id", - "price_unit", - "product_uom", - "product_uom_qty", - "tax_id", - } - ) - return triggers diff --git a/sale_coupon_auto_refresh/tests/__init__.py b/sale_coupon_auto_refresh/tests/__init__.py deleted file mode 100644 index 52d9c0e93..000000000 --- a/sale_coupon_auto_refresh/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_sale_coupon_auto_refresh diff --git a/sale_coupon_auto_refresh/wizard/__init__.py b/sale_coupon_auto_refresh/wizard/__init__.py deleted file mode 100644 index cfca3edcd..000000000 --- a/sale_coupon_auto_refresh/wizard/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import sale_coupon_apply_code diff --git a/sale_coupon_auto_refresh/wizard/sale_coupon_apply_code.py b/sale_coupon_auto_refresh/wizard/sale_coupon_apply_code.py deleted file mode 100644 index 1ca837645..000000000 --- a/sale_coupon_auto_refresh/wizard/sale_coupon_apply_code.py +++ /dev/null @@ -1,15 +0,0 @@ -from odoo import models - - -class SaleCouponApplyCode(models.TransientModel): - _inherit = "sale.coupon.apply.code" - - def process_coupon(self): - wiz = self.with_context(skip_auto_refresh_coupons=True) - return super(SaleCouponApplyCode, wiz).process_coupon() - - def apply_coupon(self, order, coupon_code): - """Avoid discarding the coupon before the end of the process""" - return super().apply_coupon( - order.with_context(skip_auto_refresh_coupons=True), coupon_code - ) diff --git a/sale_coupon_auto_refresh/README.rst b/sale_loyalty_auto_refresh/README.rst similarity index 80% rename from sale_coupon_auto_refresh/README.rst rename to sale_loyalty_auto_refresh/README.rst index 522e5901f..3467c2bfa 100644 --- a/sale_coupon_auto_refresh/README.rst +++ b/sale_loyalty_auto_refresh/README.rst @@ -7,7 +7,7 @@ Auto Refresh Coupons !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:7bafacae4429131fbe653c4eb1a6584833e153163a341bf484480d4cf45f0b3c + !! source digest: sha256:133096428fab5ae09fcaa35b8da33f24d667399972235fc7e8842692fbc2eb41 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png @@ -17,13 +17,13 @@ Auto Refresh Coupons :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/15.0/sale_coupon_auto_refresh + :target: https://github.com/OCA/sale-promotion/tree/16.0/sale_loyalty_auto_refresh :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-15-0/sale-promotion-15-0-sale_coupon_auto_refresh + :target: https://translation.odoo-community.org/projects/sale-promotion-16-0/sale-promotion-16-0-sale_loyalty_auto_refresh :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=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -49,20 +49,20 @@ you want to extend the list of that fields: #. Go to *Settings > Technical > Config parameters* #. Add or update the key: - - For `sale.order`: `sale_coupon_auto_refresh.sale_order_triggers` - - For `sale.order.line`: `sale_coupon_auto_refresh.sale_order_line_triggers` + - For `sale.order`: `sale_loyalty_auto_refresh.sale_order_triggers` + - For `sale.order.line`: `sale_loyalty_auto_refresh.sale_order_line_triggers` #. In every add the fields seperated by commas that you want to add to the recomputation triggers. -⚠️ After configuring or removiming a trigger a restart of Odoo is recommended so the +⚠️ After configuring or removing a trigger a restart of Odoo is recommended so the depends are reloaded properly. Anyway it isn't mandatory and the module detects the new triggers so the auto-refresh works as expected as soon as they are set. Usage ===== -You need to configure a *Promotion program* with the option *Promo Code Usage* set to -*Automatically applied*. This can be done in *Sales > Products > Promotion programs*. +You need to configure a *Promotion program* with the option *Program trigger* set to +*Automatic* (shown in Debug mode only, read-only computed field). This can be done in *Sales > Products > Discount & Loyalty*. Now, make a quotation that fulfill the promotion condition and the promotion will be automatically applied. @@ -79,7 +79,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -104,6 +104,10 @@ Contributors * Silvio Gregorini +* `Trobz `_: + + * Nguyen Minh Chien + Maintainers ~~~~~~~~~~~ @@ -128,6 +132,6 @@ Current `maintainers `__: |maintainer-chienandalu| |maintainer-SilvioC2C| -This module is part of the `OCA/sale-promotion `_ project on GitHub. +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/sale_coupon_auto_refresh/__init__.py b/sale_loyalty_auto_refresh/__init__.py similarity index 100% rename from sale_coupon_auto_refresh/__init__.py rename to sale_loyalty_auto_refresh/__init__.py diff --git a/sale_coupon_auto_refresh/__manifest__.py b/sale_loyalty_auto_refresh/__manifest__.py similarity index 90% rename from sale_coupon_auto_refresh/__manifest__.py rename to sale_loyalty_auto_refresh/__manifest__.py index cec2ed63c..159219b50 100644 --- a/sale_coupon_auto_refresh/__manifest__.py +++ b/sale_loyalty_auto_refresh/__manifest__.py @@ -4,13 +4,13 @@ { "name": "Auto Refresh Coupons", "summary": "Allows to auto-apply the coupons with no user intervention", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "development_status": "Production/Stable", "category": "Website", "website": "https://github.com/OCA/sale-promotion", "author": "Tecnativa, Camptocamp, Odoo Community Association (OCA)", "maintainers": ["chienandalu", "SilvioC2C"], "license": "AGPL-3", - "depends": ["sale_coupon"], + "depends": ["sale_loyalty"], "data": ["views/res_config_settings_views.xml"], } diff --git a/sale_loyalty_auto_refresh/i18n/es.po b/sale_loyalty_auto_refresh/i18n/es.po new file mode 100644 index 000000000..1f27edae7 --- /dev/null +++ b/sale_loyalty_auto_refresh/i18n/es.po @@ -0,0 +1,99 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_loyalty_auto_refresh +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-08 13:38+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: \n" +"Language: es\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: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"" +msgstr "" +"" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data +msgid "Auto Refresh Coupon Triggers Data" +msgstr "Actualizar Automáticamente los Datos de los Activadores de Cupones" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Auto Refresh Coupons" +msgstr "Auto actualizar ofertas" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto refresh coupons" +msgstr "Auto actualizar ofertas" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto-refresh coupons" +msgstr "Auto actualizar ofertas" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Autorefresh coupon lines in the backorder" +msgstr "Auto actualizar las líneas de descuento en backorder" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_company +msgid "Companies" +msgstr "Compañías" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_config_settings +msgid "Config Settings" +msgstr "Ajustes" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_refresh_mixin +msgid "Mixin class for sale coupon auto-refresh features" +msgstr "Clase mixta de actualización automática de cupones de descuento" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_apply_code +msgid "Sales Coupon Apply Code" +msgstr "Cupón de descuento Aplicar código" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order +msgid "Sales Order" +msgstr "Orden de Venta" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de Orden de Venta" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"When the sale order is updated, auto-refresh the promotion programs which " +"are set to auto apply" +msgstr "" +"Cuando se actualice un pedido de venta, auto actualizar los programas de " +"oferta configurados para auto aplicarse" + +#~ msgid "Sale Order" +#~ msgstr "Pedido de Venta" diff --git a/sale_loyalty_auto_refresh/i18n/fr.po b/sale_loyalty_auto_refresh/i18n/fr.po new file mode 100644 index 000000000..f1ebcde06 --- /dev/null +++ b/sale_loyalty_auto_refresh/i18n/fr.po @@ -0,0 +1,105 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_loyalty_auto_refresh +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-09-18 14:34+0000\n" +"Last-Translator: Rémi \n" +"Language-Team: none\n" +"Language: fr\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.3.2\n" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"" +msgstr "" +"" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data +msgid "Auto Refresh Coupon Triggers Data" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Auto Refresh Coupons" +msgstr "Mise à jour automatique des promotions" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto refresh coupons" +msgstr "Mise à jour automatique des promotions" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto-refresh coupons" +msgstr "Mise à jour automatique des promotions" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Autorefresh coupon lines in the backorder" +msgstr "Mise à jour automatique des promotions" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_config_settings +msgid "Config Settings" +msgstr "Configuration" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_refresh_mixin +msgid "Mixin class for sale coupon auto-refresh features" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_apply_code +msgid "Sales Coupon Apply Code" +msgstr "Utiliser le code promotionnel" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order +msgid "Sales Order" +msgstr "Commandes" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order_line +msgid "Sales Order Line" +msgstr "Ligne de Commande" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"When the sale order is updated, auto-refresh the promotion programs which " +"are set to auto apply" +msgstr "" +"Quand le devis est mis à jour, recalcule automatiquement les programmes de " +"promotions configurés pour application automatique" + +#~ msgid "Display Name" +#~ msgstr "Nom affiché" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Date de dernière modification" diff --git a/sale_loyalty_auto_refresh/i18n/it.po b/sale_loyalty_auto_refresh/i18n/it.po new file mode 100644 index 000000000..dbd0e099f --- /dev/null +++ b/sale_loyalty_auto_refresh/i18n/it.po @@ -0,0 +1,105 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_loyalty_auto_refresh +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-04-28 10:05+0000\n" +"Last-Translator: Francesco Foresti \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.3.2\n" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"" +msgstr "" +"" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data +msgid "Auto Refresh Coupon Triggers Data" +msgstr "Dati trigger aggiornamento automatic coupons" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Auto Refresh Coupons" +msgstr "Aggiornamento automatico coupons" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto refresh coupons" +msgstr "Aggiornamento automatico coupons" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto-refresh coupons" +msgstr "Aggiornamento automatico coupons" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Autorefresh coupon lines in the backorder" +msgstr "Aggiorna automaticamente righe coupon nell'ordine residuo" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_company +msgid "Companies" +msgstr "Aziende" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_refresh_mixin +msgid "Mixin class for sale coupon auto-refresh features" +msgstr "Classe mixin per funzionalità aggiornamento automatico coupon" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_apply_code +msgid "Sales Coupon Apply Code" +msgstr "Applica codice coupon vendite" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order_line +msgid "Sales Order Line" +msgstr "Riga ordine di vendita" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"When the sale order is updated, auto-refresh the promotion programs which " +"are set to auto apply" +msgstr "" +"Quando l'ordine di vendita è aggiornato, aggiorna automaticamente le " +"promozioni che sono impostate ad \"applica automaticamente\"" + +#~ msgid "Display Name" +#~ msgstr "Nome Visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/sale_loyalty_auto_refresh/i18n/sale_loyalty_auto_refresh.pot b/sale_loyalty_auto_refresh/i18n/sale_loyalty_auto_refresh.pot new file mode 100644 index 000000000..156ae77af --- /dev/null +++ b/sale_loyalty_auto_refresh/i18n/sale_loyalty_auto_refresh.pot @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_loyalty_auto_refresh +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data +msgid "Auto Refresh Coupon Triggers Data" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Auto Refresh Coupons" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto refresh coupons" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto-refresh coupons" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Autorefresh coupon lines in the backorder" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_company +msgid "Companies" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_refresh_mixin +msgid "Mixin class for sale coupon auto-refresh features" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_apply_code +msgid "Sales Coupon Apply Code" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"When the sale order is updated, auto-refresh the promotion programs which " +"are set to auto apply" +msgstr "" diff --git a/sale_loyalty_auto_refresh/i18n/zh_CN.po b/sale_loyalty_auto_refresh/i18n/zh_CN.po new file mode 100644 index 000000000..5df267863 --- /dev/null +++ b/sale_loyalty_auto_refresh/i18n/zh_CN.po @@ -0,0 +1,103 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_loyalty_auto_refresh +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-09-02 04:50+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"" +msgstr "" +"" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_coupon_refresh_mixin__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon_triggers_data +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order_line__auto_refresh_coupon_triggers_data +msgid "Auto Refresh Coupon Triggers Data" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,field_description:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Auto Refresh Coupons" +msgstr "自动刷新优惠券" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto refresh coupons" +msgstr "自动刷新优惠券" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "Auto-refresh coupons" +msgstr "自动刷新优惠券" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_company__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_res_config_settings__auto_refresh_coupon +#: model:ir.model.fields,help:sale_loyalty_auto_refresh.field_sale_order__auto_refresh_coupon +msgid "Autorefresh coupon lines in the backorder" +msgstr "自动刷新延期交货中的优惠券行" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_company +msgid "Companies" +msgstr "公司" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_res_config_settings +msgid "Config Settings" +msgstr "配置设置" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_refresh_mixin +msgid "Mixin class for sale coupon auto-refresh features" +msgstr "" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_coupon_apply_code +msgid "Sales Coupon Apply Code" +msgstr "销售优惠券申请代码" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order +msgid "Sales Order" +msgstr "销售订单" + +#. module: sale_loyalty_auto_refresh +#: model:ir.model,name:sale_loyalty_auto_refresh.model_sale_order_line +msgid "Sales Order Line" +msgstr "销售订单行" + +#. module: sale_loyalty_auto_refresh +#: model_terms:ir.ui.view,arch_db:sale_loyalty_auto_refresh.res_config_settings_view_form +msgid "" +"When the sale order is updated, auto-refresh the promotion programs which " +"are set to auto apply" +msgstr "当销售订单更新时,自动刷新设置为自动应用的促销计划" + +#~ msgid "Display Name" +#~ msgstr "显示名称" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "最后修改日" diff --git a/sale_loyalty_auto_refresh/migrations/post-migration.py b/sale_loyalty_auto_refresh/migrations/post-migration.py new file mode 100644 index 000000000..3c9a901e7 --- /dev/null +++ b/sale_loyalty_auto_refresh/migrations/post-migration.py @@ -0,0 +1,18 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +def update_parameter_key(env): + parameters = env["ir.config_parameter"].search( + [("key", "like", "sale_coupon_auto_refresh.")] + ) + for parameter in parameters: + parameter.key = (parameter.key).replace( + "sale_coupon_auto_refresh.", "sale_loyalty_auto_refresh." + ) + + +@openupgrade.migrate() +def migrate(env, version): + update_parameter_key(env) diff --git a/sale_coupon_auto_refresh/models/__init__.py b/sale_loyalty_auto_refresh/models/__init__.py similarity index 80% rename from sale_coupon_auto_refresh/models/__init__.py rename to sale_loyalty_auto_refresh/models/__init__.py index 86399a748..e9c56cd5c 100644 --- a/sale_coupon_auto_refresh/models/__init__.py +++ b/sale_loyalty_auto_refresh/models/__init__.py @@ -2,3 +2,4 @@ from . import res_company from . import sale_coupon_refresh_mixin from . import sale_order +from . import sale_order_line diff --git a/sale_coupon_auto_refresh/models/res_company.py b/sale_loyalty_auto_refresh/models/res_company.py similarity index 100% rename from sale_coupon_auto_refresh/models/res_company.py rename to sale_loyalty_auto_refresh/models/res_company.py diff --git a/sale_coupon_auto_refresh/models/res_config_settings.py b/sale_loyalty_auto_refresh/models/res_config_settings.py similarity index 100% rename from sale_coupon_auto_refresh/models/res_config_settings.py rename to sale_loyalty_auto_refresh/models/res_config_settings.py diff --git a/sale_coupon_auto_refresh/models/sale_coupon_refresh_mixin.py b/sale_loyalty_auto_refresh/models/sale_coupon_refresh_mixin.py similarity index 92% rename from sale_coupon_auto_refresh/models/sale_coupon_refresh_mixin.py rename to sale_loyalty_auto_refresh/models/sale_coupon_refresh_mixin.py index beefb785d..41e6d8a51 100644 --- a/sale_coupon_auto_refresh/models/sale_coupon_refresh_mixin.py +++ b/sale_loyalty_auto_refresh/models/sale_coupon_refresh_mixin.py @@ -21,7 +21,7 @@ def _get_auto_refresh_coupons_triggers(self) -> set: Configure additional triggers via config parameters, setting them up as list of fields separated by commas. For example, for sale.order, - the param key would be sale_coupon_auto_refresh.sale_order_triggers, + the param key would be sale_loyalty_auto_refresh.sale_order_triggers, and the value something like: "warehouse_id,carrier_id". The method is overriden in the proper modules to set some basic triggers though @@ -29,7 +29,7 @@ def _get_auto_refresh_coupons_triggers(self) -> set: additional_triggers = ( self.env["ir.config_parameter"] .sudo() - .get_param("sale_coupon_auto_refresh.%s_triggers" % (self._table), "") + .get_param("sale_loyalty_auto_refresh.%s_triggers" % (self._table), "") .replace(" ", "") .split(",") ) @@ -58,6 +58,7 @@ def _read_recs_data(self) -> list: of `self.read()`) The list is sorted by "id" key. """ + self.invalidate_recordset(["auto_refresh_coupon_triggers_data"]) return sorted( self.read(["auto_refresh_coupon_triggers_data"]), key=lambda d: d["id"] ) @@ -68,7 +69,7 @@ def _new_trigger(self) -> set: ensures that no trigger is missed in the meantime""" field_depends, _ = self._fields.get( "auto_refresh_coupon_triggers_data" - ).get_depends(self._name) + ).get_depends(self) triggers = self._get_auto_refresh_coupons_triggers() return {x for x in triggers if x not in field_depends} diff --git a/sale_loyalty_auto_refresh/models/sale_order.py b/sale_loyalty_auto_refresh/models/sale_order.py new file mode 100644 index 000000000..1eac27f87 --- /dev/null +++ b/sale_loyalty_auto_refresh/models/sale_order.py @@ -0,0 +1,96 @@ +# Copyright 2021 Tecnativa - David Vidal +# Copyright 2021 Camptocamp - Silvio Gregorini +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import logging + +from odoo import api, fields, models +from odoo.exceptions import UserError, ValidationError + +logger = logging.getLogger(__name__) + + +class SaleOrder(models.Model): + _name = "sale.order" + _inherit = ["sale.order", "sale.coupon.refresh.mixin"] + + # Used in UI to hide the manual button + auto_refresh_coupon = fields.Boolean( + related="company_id.auto_refresh_coupon", + ) + + @api.model_create_multi + def create(self, vals_list): + if self._check_skip_refresh(): + return super().create(vals_list) + + self_ctx = self.with_context(skip_auto_refresh_coupons=True) + orders = super(SaleOrder, self_ctx).create(vals_list) + orders._auto_refresh_coupons() + return orders + + def write(self, vals): + if self._check_skip_refresh(): + return super().write(vals) + + old_data = self._read_recs_data() + self_ctx = self.with_context(skip_auto_refresh_coupons=True) + res = super(SaleOrder, self_ctx).write(vals) + new_data = self._read_recs_data() + # Until we restart Odoo, we won't get new triggers from params. Once restarted + # the method will return an empty set. + new_triggers = self._new_trigger() + if old_data != new_data or any(x in new_triggers for x in vals): + self._auto_refresh_coupons() + return res + + def _auto_refresh_coupons(self): + orders = self.with_context(skip_auto_refresh_coupons=True).filtered( + type(self)._allow_recompute_coupon_lines + ) + for order in orders: + order._update_programs_and_rewards() + order.action_apply_rewards() + + def action_apply_rewards(self): + self.ensure_one() + claimable_rewards = self._get_claimable_rewards() + for coupon, reward in claimable_rewards.items(): + try: + self._apply_program_reward(reward, coupon) + self._update_programs_and_rewards() + except (UserError | ValidationError) as e: + # Ignore exception errors to unblock the user when creating/writing + logger.debug(e) + + def _allow_recompute_coupon_lines(self): + """Check if reward lines in ``self`` can be recomputed automatically. + + Hook method, to be overridden for custom behaviours. + + :return: True if the current SO allows automatic recomputation for + reward lines, False otherwise. + """ + self.ensure_one() + return self.auto_refresh_coupon and self.state in ("draft", "sent") + + @api.model + def _get_auto_refresh_coupons_triggers(self) -> set: + triggers = super()._get_auto_refresh_coupons_triggers() + triggers.update( + { + "order_line.auto_refresh_coupon_triggers_data", + "partner_id", + } + ) + return triggers + + def action_open_reward_wizard(self): + return super( + SaleOrder, self.with_context(skip_auto_refresh_coupons=True) + ).action_open_reward_wizard() + + def _update_programs_and_rewards(self): + return super( + SaleOrder, self.with_context(skip_auto_refresh_coupons=True) + )._update_programs_and_rewards() diff --git a/sale_loyalty_auto_refresh/models/sale_order_line.py b/sale_loyalty_auto_refresh/models/sale_order_line.py new file mode 100644 index 000000000..b77e343e3 --- /dev/null +++ b/sale_loyalty_auto_refresh/models/sale_order_line.py @@ -0,0 +1,66 @@ +# Copyright 2021 Tecnativa - David Vidal +# Copyright 2021 Camptocamp - Silvio Gregorini +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import logging + +from odoo import api, models + +logger = logging.getLogger(__name__) + + +class SaleOrderLine(models.Model): + _name = "sale.order.line" + _inherit = ["sale.order.line", "sale.coupon.refresh.mixin"] + + @api.model_create_multi + def create(self, vals_list): + if self._check_skip_refresh(): + return super().create(vals_list) + + self_ctx = self.with_context(skip_auto_refresh_coupons=True) + lines = super(SaleOrderLine, self_ctx).create(vals_list) + lines.order_id._auto_refresh_coupons() + return lines + + def write(self, vals): + if self._check_skip_refresh(): + return super().write(vals) + + old_data = self._read_recs_data() + old_orders = self.order_id + self_ctx = self.with_context(skip_auto_refresh_coupons=True) + res = super(SaleOrderLine, self_ctx).write(vals) + new_data = self._read_recs_data() + new_orders = self.order_id + # Until we restart Odoo, we won't get new triggers from params. Once restarted + # the method will return an empty set. + new_triggers = self._new_trigger() + if old_data != new_data or any(x in new_triggers for x in vals): + (old_orders | new_orders)._auto_refresh_coupons() + return res + + def unlink(self): + if self._check_skip_refresh(): + return super().unlink() + + orders = self.order_id + self_ctx = self.with_context(skip_auto_refresh_coupons=True) + res = super(SaleOrderLine, self_ctx).unlink() + orders._auto_refresh_coupons() + return res + + @api.model + def _get_auto_refresh_coupons_triggers(self) -> set: + triggers = super()._get_auto_refresh_coupons_triggers() + triggers.update( + { + "discount", + "product_id", + "price_unit", + "product_uom", + "product_uom_qty", + "tax_id", + } + ) + return triggers diff --git a/sale_coupon_auto_refresh/readme/CONFIGURE.rst b/sale_loyalty_auto_refresh/readme/CONFIGURE.rst similarity index 73% rename from sale_coupon_auto_refresh/readme/CONFIGURE.rst rename to sale_loyalty_auto_refresh/readme/CONFIGURE.rst index 2deba0b08..c730d72ab 100644 --- a/sale_coupon_auto_refresh/readme/CONFIGURE.rst +++ b/sale_loyalty_auto_refresh/readme/CONFIGURE.rst @@ -9,11 +9,11 @@ you want to extend the list of that fields: #. Go to *Settings > Technical > Config parameters* #. Add or update the key: - - For `sale.order`: `sale_coupon_auto_refresh.sale_order_triggers` - - For `sale.order.line`: `sale_coupon_auto_refresh.sale_order_line_triggers` + - For `sale.order`: `sale_loyalty_auto_refresh.sale_order_triggers` + - For `sale.order.line`: `sale_loyalty_auto_refresh.sale_order_line_triggers` #. In every add the fields seperated by commas that you want to add to the recomputation triggers. -⚠️ After configuring or removiming a trigger a restart of Odoo is recommended so the +⚠️ After configuring or removing a trigger a restart of Odoo is recommended so the depends are reloaded properly. Anyway it isn't mandatory and the module detects the new triggers so the auto-refresh works as expected as soon as they are set. diff --git a/sale_coupon_auto_refresh/readme/CONTRIBUTORS.rst b/sale_loyalty_auto_refresh/readme/CONTRIBUTORS.rst similarity index 65% rename from sale_coupon_auto_refresh/readme/CONTRIBUTORS.rst rename to sale_loyalty_auto_refresh/readme/CONTRIBUTORS.rst index 7e21b37df..7285fdfe6 100644 --- a/sale_coupon_auto_refresh/readme/CONTRIBUTORS.rst +++ b/sale_loyalty_auto_refresh/readme/CONTRIBUTORS.rst @@ -6,3 +6,7 @@ * `Camptocamp `_: * Silvio Gregorini + +* `Trobz `_: + + * Nguyen Minh Chien diff --git a/sale_coupon_auto_refresh/readme/DESCRIPTION.rst b/sale_loyalty_auto_refresh/readme/DESCRIPTION.rst similarity index 100% rename from sale_coupon_auto_refresh/readme/DESCRIPTION.rst rename to sale_loyalty_auto_refresh/readme/DESCRIPTION.rst diff --git a/sale_coupon_auto_refresh/readme/ROADMAP.rst b/sale_loyalty_auto_refresh/readme/ROADMAP.rst similarity index 100% rename from sale_coupon_auto_refresh/readme/ROADMAP.rst rename to sale_loyalty_auto_refresh/readme/ROADMAP.rst diff --git a/sale_coupon_auto_refresh/readme/USAGE.rst b/sale_loyalty_auto_refresh/readme/USAGE.rst similarity index 53% rename from sale_coupon_auto_refresh/readme/USAGE.rst rename to sale_loyalty_auto_refresh/readme/USAGE.rst index 7dd8eb0da..4973c425c 100644 --- a/sale_coupon_auto_refresh/readme/USAGE.rst +++ b/sale_loyalty_auto_refresh/readme/USAGE.rst @@ -1,5 +1,5 @@ -You need to configure a *Promotion program* with the option *Promo Code Usage* set to -*Automatically applied*. This can be done in *Sales > Products > Promotion programs*. +You need to configure a *Promotion program* with the option *Program trigger* set to +*Automatic* (shown in Debug mode only, read-only computed field). This can be done in *Sales > Products > Discount & Loyalty*. Now, make a quotation that fulfill the promotion condition and the promotion will be automatically applied. diff --git a/sale_coupon_auto_refresh/static/description/icon.png b/sale_loyalty_auto_refresh/static/description/icon.png similarity index 100% rename from sale_coupon_auto_refresh/static/description/icon.png rename to sale_loyalty_auto_refresh/static/description/icon.png diff --git a/sale_coupon_auto_refresh/static/description/index.html b/sale_loyalty_auto_refresh/static/description/index.html similarity index 88% rename from sale_coupon_auto_refresh/static/description/index.html rename to sale_loyalty_auto_refresh/static/description/index.html index 6ad87651d..56b34b382 100644 --- a/sale_coupon_auto_refresh/static/description/index.html +++ b/sale_loyalty_auto_refresh/static/description/index.html @@ -367,9 +367,9 @@

Auto Refresh Coupons

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:7bafacae4429131fbe653c4eb1a6584833e153163a341bf484480d4cf45f0b3c +!! source digest: sha256:133096428fab5ae09fcaa35b8da33f24d667399972235fc7e8842692fbc2eb41 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module allows to auto apply the programs without the need of the user intervention.

Table of contents

@@ -398,21 +398,21 @@

Configuration

  1. Go to Settings > Technical > Config parameters
  2. Add or update the key:
      -
    • For sale.order: sale_coupon_auto_refresh.sale_order_triggers
    • -
    • For sale.order.line: sale_coupon_auto_refresh.sale_order_line_triggers
    • +
    • For sale.order: sale_loyalty_auto_refresh.sale_order_triggers
    • +
    • For sale.order.line: sale_loyalty_auto_refresh.sale_order_line_triggers
  3. In every add the fields seperated by commas that you want to add to the recomputation triggers.
-

⚠️ After configuring or removiming a trigger a restart of Odoo is recommended so the +

⚠️ After configuring or removing a trigger a restart of Odoo is recommended so the depends are reloaded properly. Anyway it isn’t mandatory and the module detects the new triggers so the auto-refresh works as expected as soon as they are set.

Usage

-

You need to configure a Promotion program with the option Promo Code Usage set to -Automatically applied. This can be done in Sales > Products > Promotion programs.

+

You need to configure a Promotion program with the option Program trigger set to +Automatic (shown in Debug mode only, read-only computed field). This can be done in Sales > Products > Discount & Loyalty.

Now, make a quotation that fulfill the promotion condition and the promotion will be automatically applied.

@@ -428,7 +428,7 @@

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.

+feedback.

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

@@ -452,6 +452,10 @@

Contributors

  • Silvio Gregorini
  • +
  • Trobz: +
  • @@ -463,7 +467,7 @@

    Maintainers

    promote its widespread use.

    Current maintainers:

    chienandalu SilvioC2C

    -

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

    +

    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/sale_loyalty_auto_refresh/tests/__init__.py b/sale_loyalty_auto_refresh/tests/__init__.py new file mode 100644 index 000000000..02f4873d9 --- /dev/null +++ b/sale_loyalty_auto_refresh/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_loyalty_auto_refresh diff --git a/sale_coupon_auto_refresh/tests/test_sale_coupon_auto_refresh.py b/sale_loyalty_auto_refresh/tests/test_sale_loyalty_auto_refresh.py similarity index 68% rename from sale_coupon_auto_refresh/tests/test_sale_coupon_auto_refresh.py rename to sale_loyalty_auto_refresh/tests/test_sale_loyalty_auto_refresh.py index 5fd9470cb..80d593fb2 100644 --- a/sale_coupon_auto_refresh/tests/test_sale_coupon_auto_refresh.py +++ b/sale_loyalty_auto_refresh/tests/test_sale_loyalty_auto_refresh.py @@ -7,6 +7,7 @@ class TestWebsiteSaleCouponAutorefresh(common.TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() + cls.env["loyalty.program"].search([]).write({"active": False}) cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) cls.pricelist = cls.env["product.pricelist"].create( { @@ -28,21 +29,25 @@ def setUpClass(cls): {"name": "Mr. Odoo", "property_product_pricelist": cls.pricelist.id} ) cls.product = cls.env["product.product"].create({"name": "Test"}) - coupon_program_form = Form( - cls.env["coupon.program"], - view="sale_coupon.sale_coupon_program_view_promo_program_form", + loyalty_program_form = Form( + cls.env["loyalty.program"], + view="sale_loyalty.loyalty_program_view_form_inherit_sale_loyalty", ) - coupon_program_form.name = "Test Discount Program" - coupon_program_form.promo_code_usage = "no_code_needed" - coupon_program_form.discount_type = "percentage" - coupon_program_form.discount_percentage = 50 - coupon_program_form.discount_apply_on = "on_order" - coupon_program_form.rule_minimum_amount = 100 - cls.coupon_program = coupon_program_form.save() - cls.coupon_program.company_id.auto_refresh_coupon = True + loyalty_program_form.name = "Test Discount Program" + loyalty_program_form.program_type = "promotion" + cls.loyalty_program = loyalty_program_form.save() + cls.loyalty_program.applies_on = "current" + cls.loyalty_program.trigger = "auto" + reward = cls.loyalty_program.reward_ids + reward.reward_type = "discount" + reward.discount = 50 + reward.discount_mode = "percent" + reward.discount_applicability = "order" + cls.loyalty_program.rule_ids.minimum_amount = 100 + cls.loyalty_program.company_id.auto_refresh_coupon = True # Let's configure an extra trigger cls.env["ir.config_parameter"].set_param( - "sale_coupon_auto_refresh.sale_order_triggers", "note" + "sale_loyalty_auto_refresh.sale_order_triggers", "note" ) def test_01_sale_coupon_auto_refresh_on_create(self): @@ -154,3 +159,62 @@ def test_04_sale_coupon_auto_refresh_custom_triggers(self): discount_line = sale.order_line.filtered("is_reward_line") self.assertEqual(1, len(discount_line), "There should be a reward line") self.assertAlmostEqual(-100, discount_line.price_unit) + + def test_05_multi_programs(self): + promo_60 = self.loyalty_program.copy( + { + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "discount": 60, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ] + } + ) + reward_product = self.env["product.product"].create({"name": "Reward Product"}) + promo_prod = self.loyalty_program.copy( + { + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "product", + "reward_product_id": reward_product.id, + "reward_product_qty": 1, + "required_points": 1, + }, + ) + ] + } + ) + sale_form = Form(self.env["sale.order"]) + sale_form.partner_id = self.partner + # Create a product line that would trigger the reward but we disabled it by + # context + with sale_form.order_line.new() as line_form: + line_form.product_id = self.product + line_form.product_uom_qty = 10 + line_form.price_unit = 20 + sale = sale_form.save() + self.assertTrue(sale.coupon_point_ids) + line_loyalty_program = sale.order_line.filtered( + lambda line: line.reward_id == self.loyalty_program.reward_ids + ) + line_promo_60 = sale.order_line.filtered( + lambda line: line.reward_id == promo_60.reward_ids + ) + line_promo_prod = sale.order_line.filtered( + lambda line: line.reward_id == promo_prod.reward_ids + ) + self.assertFalse( + line_loyalty_program + ) # Promo 60% is better, no select promo 50% + self.assertTrue(line_promo_60) + self.assertTrue(line_promo_prod) diff --git a/sale_coupon_auto_refresh/views/res_config_settings_views.xml b/sale_loyalty_auto_refresh/views/res_config_settings_views.xml similarity index 100% rename from sale_coupon_auto_refresh/views/res_config_settings_views.xml rename to sale_loyalty_auto_refresh/views/res_config_settings_views.xml diff --git a/sale_loyalty_auto_refresh/wizard/__init__.py b/sale_loyalty_auto_refresh/wizard/__init__.py new file mode 100644 index 000000000..b52b2b279 --- /dev/null +++ b/sale_loyalty_auto_refresh/wizard/__init__.py @@ -0,0 +1,2 @@ +from . import sale_loyalty_coupon_wizard +from . import sale_loyalty_reward_wizard diff --git a/sale_loyalty_auto_refresh/wizard/sale_loyalty_coupon_wizard.py b/sale_loyalty_auto_refresh/wizard/sale_loyalty_coupon_wizard.py new file mode 100644 index 000000000..d7bcf3648 --- /dev/null +++ b/sale_loyalty_auto_refresh/wizard/sale_loyalty_coupon_wizard.py @@ -0,0 +1,11 @@ +from odoo import models + + +class SaleLoyaltyCouponWizard(models.TransientModel): + _inherit = "sale.loyalty.coupon.wizard" + + def action_apply(self): + """Avoid discarding the coupon before the end of the process""" + return super( + SaleLoyaltyCouponWizard, self.with_context(skip_auto_refresh_coupons=True) + ).action_apply() diff --git a/sale_loyalty_auto_refresh/wizard/sale_loyalty_reward_wizard.py b/sale_loyalty_auto_refresh/wizard/sale_loyalty_reward_wizard.py new file mode 100644 index 000000000..aab4a7e89 --- /dev/null +++ b/sale_loyalty_auto_refresh/wizard/sale_loyalty_reward_wizard.py @@ -0,0 +1,11 @@ +from odoo import models + + +class SaleLoyaltyRewardWizard(models.TransientModel): + _inherit = "sale.loyalty.reward.wizard" + + def action_apply(self): + """Avoid discarding the coupon before the end of the process""" + return super( + SaleLoyaltyRewardWizard, self.with_context(skip_auto_refresh_coupons=True) + ).action_apply() diff --git a/setup/sale_coupon_auto_refresh/odoo/addons/sale_coupon_auto_refresh b/setup/sale_coupon_auto_refresh/odoo/addons/sale_coupon_auto_refresh deleted file mode 120000 index 7a53427b2..000000000 --- a/setup/sale_coupon_auto_refresh/odoo/addons/sale_coupon_auto_refresh +++ /dev/null @@ -1 +0,0 @@ -../../../../sale_coupon_auto_refresh \ No newline at end of file diff --git a/setup/sale_loyalty_auto_refresh/odoo/addons/sale_loyalty_auto_refresh b/setup/sale_loyalty_auto_refresh/odoo/addons/sale_loyalty_auto_refresh new file mode 120000 index 000000000..1862b3f23 --- /dev/null +++ b/setup/sale_loyalty_auto_refresh/odoo/addons/sale_loyalty_auto_refresh @@ -0,0 +1 @@ +../../../../sale_loyalty_auto_refresh \ No newline at end of file diff --git a/setup/sale_coupon_auto_refresh/setup.py b/setup/sale_loyalty_auto_refresh/setup.py similarity index 100% rename from setup/sale_coupon_auto_refresh/setup.py rename to setup/sale_loyalty_auto_refresh/setup.py