Skip to content

Commit

Permalink
[MIG] shopinvader: Migration to 16.0
Browse files Browse the repository at this point in the history
Notable Odoo changes:

* plan_id (analytic plan) required on account.analytic.account
* onchange methods have been transformed into compute:
  => product_id_change() -> _compute_tax_id()
  => _onchange_discount() -> _compute_discount()
* Field 'price' removed on product
* Method _get_real_price_currency() removed on sale order lines => Not possible anymore to compute the price without a real so line
* currency_id is now required to play onchanges on sale order lines
* Price of demo data 'product_product_11' has changed (16.5 -> 33.0)
* Name of demo data 'product_product_4' has changed (Customizable Desk (CONFIG) -> Customizable Desk)
* Register payment wizard (account.payment.wizard) takes now a 'account.payment.method.line' instead of a 'account.payment.method'
  • Loading branch information
qgroulard committed Jul 28, 2023
1 parent 95a6b84 commit 8e2a5ea
Show file tree
Hide file tree
Showing 49 changed files with 179 additions and 253 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ exclude: |
# NOT INSTALLABLE ADDONS
^partner_contact_company/|
^product_online_category/|
^shopinvader/|
^shopinvader_algolia/|
^shopinvader_assortment/|
^shopinvader_auth_api_key/|
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# generated from manifests external_dependencies
cerberus
openupgradelib
python-slugify
unidecode
1 change: 1 addition & 0 deletions setup/shopinvader/odoo/addons/shopinvader
6 changes: 6 additions & 0 deletions setup/shopinvader/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
4 changes: 2 additions & 2 deletions shopinvader/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
{
"name": "Shopinvader",
"summary": "Shopinvader",
"version": "14.0.5.24.12",
"version": "16.0.1.0.0",
"category": "e-commerce",
"website": "https://github.com/shopinvader/odoo-shopinvader",
"author": "Akretion",
"license": "AGPL-3",
"application": True,
"installable": False,
"installable": True,
"external_dependencies": {"python": ["cerberus", "unidecode"], "bin": []},
"depends": [
"base_rest",
Expand Down
16 changes: 7 additions & 9 deletions shopinvader/data/mail_activity_data.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="mail_activity_review_customer" model="mail.activity.type">
<field name="name">Shop - Validate customer</field>
<field name="icon">fa-tasks</field>
<field name="sequence">3</field>
<field name="decoration_type">warning</field>
</record>
</data>
<odoo noupdate="1">
<record id="mail_activity_review_customer" model="mail.activity.type">
<field name="name">Shop - Validate customer</field>
<field name="icon">fa-tasks</field>
<field name="sequence">3</field>
<field name="decoration_type">warning</field>
</record>
</odoo>
5 changes: 5 additions & 0 deletions shopinvader/demo/account_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@
<field name="tax_dest_id" ref="tax_3" />
</record>

<record id="account_analytic_plan_0" model="account.analytic.plan">
<field name="name">ShopInvader Analytic Plan</field>
</record>

<record id="account_analytic_0" model="account.analytic.account">
<field name="name">ShopInvader Analytic</field>
<field name="plan_id" ref="shopinvader.account_analytic_plan_0" />
</record>
</odoo>
56 changes: 28 additions & 28 deletions shopinvader/demo/email_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,80 @@

<record id="email_cart_notification" model="mail.template">
<field name="name">Cart notification</field>
<field name="email_from">${(object.user_id.email or '')|safe}</field>
<field name="subject">Cart notification ${object.name}</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="email_from">{{ (object.user_id.email or '') }}</field>
<field name="subject">Cart notification {{ object.name }}</field>
<field name="partner_to">{{ object.partner_id.id }}</field>
<field name="model_id" ref="sale.model_sale_order" />
<field name="auto_delete" eval="False" />
<field name="lang">${object.partner_id.lang}</field>
<field name="lang">{{ object.partner_id.lang }}</field>
<field name="body_html"><![CDATA[ Thanks for your card ]]></field>
</record>

<record id="email_sale_notification" model="mail.template">
<field name="name">Sale notification</field>
<field name="email_from">${(object.user_id.email or '')|safe}</field>
<field name="subject">Sale notification ${object.name}</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="email_from">{{ (object.user_id.email or '') }}</field>
<field name="subject">Sale notification {{ object.name }}</field>
<field name="partner_to">{{ object.partner_id.id }}</field>
<field name="model_id" ref="sale.model_sale_order" />
<field name="auto_delete" eval="False" />
<field name="lang">${object.partner_id.lang}</field>
<field name="lang">{{ object.partner_id.lang }}</field>
<field name="body_html"><![CDATA[ We are processing your sale ]]></field>
</record>

<record id="email_invoice_notification" model="mail.template">
<field name="name">Invoice notification</field>
<field name="email_from">${(object.user_id.email or '')|safe}</field>
<field name="subject">Invoice notification ${object.number}</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="email_from">{{ (object.user_id.email or '') }}</field>
<field name="subject">Invoice notification {{ object.name }}</field>
<field name="partner_to">{{ object.partner_id.id }}</field>
<field name="model_id" ref="account.model_account_move" />
<field name="auto_delete" eval="False" />
<field name="lang">${object.partner_id.lang}</field>
<field name="lang">{{ object.partner_id.lang }}</field>
<field name="body_html"><![CDATA[ Your invoice have been generated ]]></field>
</record>

<record id="email_new_customer_welcome_notification" model="mail.template">
<field name="name">Welcome notification</field>
<field name="email_from">${(object.user_id.email or '')|safe}</field>
<field name="subject">Welcome notification ${object.name}</field>
<field name="partner_to">${object.id}</field>
<field name="email_from">{{ (object.user_id.email or '') }}</field>
<field name="subject">Welcome notification {{ object.name }}</field>
<field name="partner_to">{{ object.id }}</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="auto_delete" eval="False" />
<field name="lang">${object.lang}</field>
<field name="lang">{{ object.lang }}</field>
<field name="body_html"><![CDATA[ Welcome ]]></field>
</record>

<record id="email_customer_updated_notification" model="mail.template">
<field name="name">Customer updated notification</field>
<field name="email_from">${(object.user_id.email or '')|safe}</field>
<field name="subject">Notification ${object.name} - Customer modified</field>
<field name="partner_to">${object.id}</field>
<field name="email_from">{{ (object.user_id.email or '') }}</field>
<field name="subject">Notification {{ object.name }} - Customer modified</field>
<field name="partner_to">{{ object.id }}</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="auto_delete" eval="False" />
<field name="lang">${object.lang}</field>
<field name="lang">{{ object.lang }}</field>
<field name="body_html"><![CDATA[ Your profile has been modified]]></field>
</record>

<record id="email_address_created_notification" model="mail.template">
<field name="name">Address created notification</field>
<field name="email_from">${(object.user_id.email or '')|safe}</field>
<field name="subject">Notification ${object.name} - Address created</field>
<field name="partner_to">${object.id}</field>
<field name="email_from">{{ (object.user_id.email or '') }}</field>
<field name="subject">Notification {{ object.name }} - Address created</field>
<field name="partner_to">{{ object.id }}</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="auto_delete" eval="False" />
<field name="lang">${object.lang}</field>
<field name="lang">{{ object.lang }}</field>
<field
name="body_html"
><![CDATA[ A new address has been added to your account]]></field>
</record>

<record id="email_address_updated_notification" model="mail.template">
<field name="name">Address updated notification</field>
<field name="email_from">${(object.user_id.email or '')|safe}</field>
<field name="subject">Notification ${object.name} - Address modified</field>
<field name="partner_to">${object.id}</field>
<field name="email_from">{{ (object.user_id.email or '') }}</field>
<field name="subject">Notification {{ object.name }} - Address modified</field>
<field name="partner_to">{{ object.id }}</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="auto_delete" eval="False" />
<field name="lang">${object.lang}</field>
<field name="lang">{{ object.lang }}</field>
<field name="body_html"><![CDATA[ Your address has been modified]]></field>
</record>

Expand Down
8 changes: 0 additions & 8 deletions shopinvader/migrations/14.0.2.2.0/pre-migration.py

This file was deleted.

22 changes: 0 additions & 22 deletions shopinvader/migrations/14.0.4.0.0/post-migrate.py

This file was deleted.

40 changes: 0 additions & 40 deletions shopinvader/migrations/14.0.4.1.0/post-migrate.py

This file was deleted.

25 changes: 0 additions & 25 deletions shopinvader/migrations/14.0.5.14.1/post-migrate.py

This file was deleted.

2 changes: 1 addition & 1 deletion shopinvader/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _search_shopinvader_backend_ids(self, operator, value):
"Shopinvader binded",
compute="_compute_is_shopinvader_binded",
store=True,
index=True,
index="btree",
help="Technical field to know if this product is related by a"
"(at least one) shopinvader backend",
)
Expand Down
10 changes: 4 additions & 6 deletions shopinvader/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ def unlink(self):
record.shopinvader_bind_ids.unlink()
return super(ProductTemplate, self).unlink()

@api.model
def create(self, vals):
@api.model_create_multi
def create(self, vals_list):
"""Due to the order in which product.template, product.product,
and bindings, are created, this is to handle the case in which
a product.template + its bindings are created in one function call"""
result = super().create(vals)
bindings = result.shopinvader_bind_ids
if bindings:
bindings.active = True
result = super().create(vals_list)
result.mapped("shopinvader_bind_ids").active = True
return result
2 changes: 1 addition & 1 deletion shopinvader/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _is_partner_duplicate_prevented(self):
def _check_unique_email(self):
if not self._is_partner_duplicate_prevented():
return True
self.env["res.partner"].flush(["email", "shopinvader_bind_ids"])
self.env["res.partner"].flush_model(["email", "shopinvader_bind_ids"])
self.env.cr.execute(
"""
SELECT
Expand Down
4 changes: 2 additions & 2 deletions shopinvader/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ class SaleOrderLine(models.Model):

def reset_price_tax(self):
for line in self:
line.product_id_change()
line._onchange_discount()
line._compute_tax_id()
line._compute_discount()
8 changes: 4 additions & 4 deletions shopinvader/models/shopinvader_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ def _send_notification(self, notification, record):
("notification_type", "=", notification),
]
)
description = _("Notify %s for %s,%s") % (
notification,
record._name,
record.id,
description = _("Notify {notification} for {name},{id}").format(
notification=notification,
name=record._name,
id=record.id,
)
for notif in notifs:
notif.with_delay(description=description).send(record.id)
Expand Down
2 changes: 1 addition & 1 deletion shopinvader/models/shopinvader_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ShopinvaderBinding(models.AbstractModel):

backend_id = fields.Many2one("shopinvader.backend", string="Backend", required=True)
company_id = fields.Many2one(
related="backend_id.company_id", store=True, index=True
related="backend_id.company_id", store=True, index="btree"
)
external_id = fields.Char(string="External ID")
sync_date = fields.Datetime(string="Last synchronization date")
Expand Down
7 changes: 4 additions & 3 deletions shopinvader/models/shopinvader_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ShopinvaderCategory(models.Model):
"product.category",
required=True,
ondelete="cascade",
index=True,
index="btree",
)
sequence = fields.Integer()
meta_description = fields.Char()
Expand All @@ -36,21 +36,22 @@ class ShopinvaderCategory(models.Model):
"Shopinvader Parent",
compute="_compute_parent_category",
store=True,
index=True,
index="btree",
compute_sudo=True,
)
shopinvader_child_ids = fields.Many2many(
"shopinvader.category",
"Shopinvader Childs",
compute="_compute_child_category",
)
level = fields.Integer(compute="_compute_level")
level = fields.Integer(compute="_compute_level", recursive=True)
active = fields.Boolean(
default=True,
compute="_compute_active",
store=True,
readonly=False,
)
automatic_url_key = fields.Char(recursive=True)

_sql_constraints = [
(
Expand Down
1 change: 0 additions & 1 deletion shopinvader/models/shopinvader_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ShopinvaderNotification(models.Model):
backend_id = fields.Many2one("shopinvader.backend", "Backend", required=False)
notification_type = fields.Selection(
selection="_selection_notification_type",
string="Notification Type",
required=True,
)
model_id = fields.Many2one("ir.model", "Model", required=True, ondelete="cascade")
Expand Down
Loading

0 comments on commit 8e2a5ea

Please sign in to comment.