Skip to content

Commit

Permalink
Merge pull request #2847 from ForgeFlow/14.0-update-apriori-coupon
Browse files Browse the repository at this point in the history
[14.0][UPD] apriori + analysis
  • Loading branch information
pedrobaeza authored Jul 22, 2021
2 parents 5ebe51d + bc74c8a commit 33aff47
Show file tree
Hide file tree
Showing 9 changed files with 243 additions and 152 deletions.
8 changes: 8 additions & 0 deletions openupgrade_scripts/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
renamed_modules = {
# odoo
"account_facturx": "account_edi_facturx",
"sale_coupon": "coupon",
"website_rating": "portal_rating",
# OCA/account-invoice-reporting
"account_invoice_comment_template": "account_comment_template",
Expand Down Expand Up @@ -52,7 +53,14 @@
"email_template.preview": "mail.template.preview",
"event.answer": "event.question.answer",
"product.style": "product.ribbon",
"report.sale_coupon.report_coupon": "report.coupon.report_coupon",
"sale.coupon": "coupon.coupon",
"sale.coupon.generate": "coupon.generate.wizard",
"sale.coupon.program": "coupon.program",
"sale.coupon.reward": "coupon.reward",
"sale.coupon.rule": "coupon.rule",
"survey.user_input_line": "survey.user_input.line",
"survey.label": "survey.question.answer",
# OCA/server-tools
"openupgrade.analysis.wizard": "upgrade.analysis",
"openupgrade.attribute": "upgrade.attribute",
Expand Down
40 changes: 20 additions & 20 deletions openupgrade_scripts/scripts/base/14.0.1.3/upgrade_general_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ obsolete model product.price_list [module product]
obsolete model product.style (renamed to product.ribbon) [module website_sale]
obsolete model repair.cancel [module repair]
obsolete model report.account.report_agedpartnerbalance [module account]
obsolete model report.sale_coupon.report_coupon [module sale_coupon]
obsolete model sale.coupon [module sale_coupon]
obsolete model sale.coupon.generate [module sale_coupon]
obsolete model sale.coupon.program [module sale_coupon]
obsolete model sale.coupon.reward [module sale_coupon]
obsolete model sale.coupon.rule [module sale_coupon]
obsolete model report.sale_coupon.report_coupon (renamed to report.coupon.report_coupon) [module coupon]
obsolete model sale.coupon (renamed to coupon.coupon) [module coupon]
obsolete model sale.coupon.generate (renamed to coupon.generate.wizard) [module coupon]
obsolete model sale.coupon.program (renamed to coupon.program) [module coupon]
obsolete model sale.coupon.reward (renamed to coupon.reward) [module coupon]
obsolete model sale.coupon.rule (renamed to coupon.rule) [module coupon]
obsolete model stock.change.standard.price [module stock_account]
obsolete model stock.overprocessed.transfer [module stock]
obsolete model stock.picking.responsible [module stock]
obsolete model survey.label [module survey]
obsolete model survey.label (renamed to survey.question.answer) [module survey]
obsolete model survey.user_input_line (renamed to survey.user_input.line) [module survey]
obsolete model test_performance.mail [module test_mail]
new model account.automatic.entry.wizard [module account]
Expand Down Expand Up @@ -77,11 +77,11 @@ new model base.automation.linked.test [module test_base_automation]
new model calendar.recurrence [module calendar]
new model chat.room [module website_jitsi]
new model chat.room.mixin [module website_jitsi]
new model coupon.coupon [module coupon]
new model coupon.generate.wizard [module coupon]
new model coupon.program [module coupon]
new model coupon.reward [module coupon]
new model coupon.rule [module coupon]
new model coupon.coupon (renamed from sale.coupon) [module coupon]
new model coupon.generate.wizard (renamed from sale.coupon.generate) [module coupon]
new model coupon.program (renamed from sale.coupon.program) [module coupon]
new model coupon.reward (renamed from sale.coupon.reward) [module coupon]
new model coupon.rule (renamed from sale.coupon.rule) [module coupon]
new model crm.recurring.plan [module crm]
new model crm.tag (renamed from crm.lead.tag) [module sales_team]
new model decimal.precision.test [module test_new_api]
Expand Down Expand Up @@ -175,7 +175,7 @@ new model project.task.create.timesheet [module hr_timesheet]
new model project.task.recurrence [module project]
new model project.task.type.delete.wizard [module project]
new model report.account.report_invoice [module account]
new model report.coupon.report_coupon [module coupon]
new model report.coupon.report_coupon (renamed from report.sale_coupon.report_coupon) [module coupon]
new model report.l10n_ch.qr_report_main [module l10n_ch]
new model report.stock.report_product_product_replenishment [module stock]
new model report.stock.report_product_template_replenishment [module stock]
Expand All @@ -192,7 +192,7 @@ new model stock.backorder.confirmation.line [module stock]
new model stock.immediate.transfer.line [module stock]
new model stock.orderpoint.snooze [module stock]
new model stock.valuation.layer.revaluation [module stock_account]
new model survey.question.answer [module survey]
new model survey.question.answer (renamed from survey.label) [module survey]
new model survey.user_input.line (renamed from survey.user_input_line) [module survey]
new model tab.a [module test_action_bindings]
new model tab.b [module test_action_bindings]
Expand Down Expand Up @@ -351,13 +351,13 @@ new model website.robots [module website]
new model website.sale.extra.field [module website_sale]
new model website.snippet.filter [module website]
---Fields in module 'general'---
# 9739 fields matched,
# Direct match: 9622
# Found in other module: 117
# 9824 fields matched,
# Direct match: 9697
# Found in other module: 127
# Found with different type: 0
# In obsolete models: 290
# New columns: 3344
# Not matched: 645
# In obsolete models: 204
# New columns: 3259
# Not matched: 560
---XML records in module 'general'---
ERROR: module not in list of installed modules:
---Models in module 'account_bank_statement_import'---
Expand Down
101 changes: 101 additions & 0 deletions openupgrade_scripts/scripts/coupon/14.0.1.0/noupdate_changes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<record id="expire_coupon_cron" model="ir.cron">
<field name="model_id" ref="coupon.model_coupon_coupon"/>
</record>
<record id="mail_template_sale_coupon" model="mail.template">
<field name="body_html" type="html">
<table border="0" cellpadding="0" cellspacing="0" style="width:100%; margin:0px auto;">
<tbody>
<tr>
<td valign="top" style="text-align: center; font-size: 14px;">
% if object.partner_id.name:
Congratulations ${object.partner_id.name},<br/>
% endif

Here is your reward from ${object.program_id.company_id.name}.<br/>

% if object.program_id.reward_type == 'discount':
% if object.program_id.discount_type == 'fixed_amount':
<span style="font-size: 50px; color: #875A7B; font-weight: bold;">
${'%s' % format_amount(object.program_id.discount_fixed_amount, object.program_id.currency_id)}
</span><br/>
<strong style="font-size: 24px;">off on your next order</strong><br/>
%else
<span style="font-size: 50px; color: #875A7B; font-weight: bold;">
${object.program_id.discount_percentage} %
</span>
% if object.program_id.discount_apply_on == 'specific_products'
<br/>
% if len(object.program_id.discount_specific_product_ids) != 1
% set display_specific_products = True
<strong style="font-size: 24px;">
on some products*
</strong>
% else
<strong style="font-size: 24px;">
${'on %s' % object.program_id.discount_specific_product_ids.name}
</strong>
% endif
% elif object.program_id.discount_apply_on == 'cheapest_product':
<br/><strong style="font-size: 24px;">
off on the cheapest product
</strong>
% else
<br/><strong style="font-size: 24px;">
off on your next order
</strong>
% endif
<br/>
% endif
% elif object.program_id.reward_type == 'product':
<span style="font-size: 36px; color: #875A7B; font-weight: bold;">
${'get %s free %s' % (object.program_id.reward_product_quantity, object.program_id.reward_product_id.name)}
</span><br/>
<strong style="font-size: 24px;">on your next order</strong><br/>
% elif object.program_id.reward_type == 'free_shipping':
<span style="font-size: 36px; color: #875A7B; font-weight: bold;">
get free shipping
</span><br/>
<strong style="font-size: 24px;">on your next order</strong><br/>
% endif
</td>
</tr>
<tr style="margin-top: 16px">
<td valign="top" style="text-align: center; font-size: 14px;">
Use this promo code
% if object.expiration_date:
before ${object.expiration_date}
% endif
<p style="margin-top: 16px;"><strong style="padding: 16px 8px 16px 8px; border-radius: 3px; background-color: #F1F1F1;">
${object.code}
</strong></p>
% if object.program_id.rule_min_quantity not in [0, 1]
<span style="font-size: 14px;">
Minimum purchase of ${object.program_id.rule_min_quantity} products
</span><br/>
% endif
% if object.program_id.rule_minimum_amount != 0.00
<span style="font-size: 14px;">
Valid for purchase above ${object.program_id.company_id.currency_id.symbol}${'%0.2f' % object.program_id.rule_minimum_amount |float}
</span><br/>
% endif
% if display_specific_products
<span>
*Valid for following products: ${', '.join(object.program_id.discount_specific_product_ids.mapped('name'))}
</span><br/>
% endif
<br/>
Thank you,
% if object.order_id.user_id.signature:
<br/>
${object.order_id.user_id.signature | safe}
% endif
</td>
</tr>
</tbody>
</table>
</field>
<field name="model_id" ref="coupon.model_coupon_coupon"/>
</record>
</odoo>
23 changes: 23 additions & 0 deletions openupgrade_scripts/scripts/coupon/14.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

to_install = [
"sale_coupon",
]


def install_new_modules(cr):
sql = """
UPDATE ir_module_module
SET state='to install'
WHERE name = {} AND state='uninstalled'
""".format(
tuple(to_install),
)
openupgrade.logged_query(cr, sql)


@openupgrade.migrate()
def migrate(env, version):
install_new_modules(env.cr)
Loading

0 comments on commit 33aff47

Please sign in to comment.