Skip to content

Commit

Permalink
[16.0] fix typo, plint & add temp migration script &
Browse files Browse the repository at this point in the history
  • Loading branch information
mourad-ehm committed May 30, 2024
1 parent 3db6673 commit 0e8cd7a
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 100 deletions.
6 changes: 3 additions & 3 deletions account_ecotax_sale/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===================
France sale Ecotaxe
===================
======================
sale Ecotax Management
======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
6 changes: 3 additions & 3 deletions account_ecotax_sale/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "France sale Ecotaxe",
"summary": "Sale Ecotaxe used in French localisation contexte",
"name": "sale Ecotax Management",
"summary": "Sale Ecotaxe",
"version": "16.0.2.0.0",
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-fiscal-rule",
"category": "Localization/Account Taxes",
"license": "AGPL-3",
"depends": ["l10n_fr_ecotaxe", "sale"],
"depends": ["account_ecotax", "sale"],
"data": [
"views/sale_view.xml",
"security/ir.model.access.csv",
Expand Down
137 changes: 122 additions & 15 deletions account_ecotax_sale/migrations/16.0.2.0.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,132 @@ def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_ui_view set
active = True
WHERE id in (
SELECT "ir_ui_view".id FROM "ir_ui_view"
WHERE (("ir_ui_view"."active" = False)
AND (unaccent(COALESCE("ir_ui_view"."arch_db"->>'fr_FR',
"ir_ui_view"."arch_db"->>'en_US')) ilike unaccent('%classification_id%')))
)
TRUNCATE TABLE account_ecotax_category RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_ui_view set
active = False WHERE id in (
SELECT "ir_ui_view".id FROM "ir_ui_view"
WHERE (("ir_ui_view"."active" = true)
AND (unaccent(COALESCE("ir_ui_view"."arch_db"->>'fr_FR',
"ir_ui_view"."arch_db"->>'en_US')) ilike unaccent('%ecotaxe_classification_id%')))
ORDER BY "ir_ui_view"."priority" ASC LIMIT 80)
TRUNCATE TABLE ecotax_sector RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE ecotax_collector RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE account_ecotax_classification RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE account_move_line_ecotax RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE ecotax_line_product RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_ecotax_category (name, code, description, active)
SELECT name, code, description, active FROM account_ecotaxe_category order by id;
""",
)

openupgrade.logged_query(
env.cr,
"""
INSERT INTO ecotax_sector (name, description, active)
SELECT name, description, active FROM ecotaxe_sector order by id;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO ecotax_collector (name, partner_id, active)
SELECT name, partner_id, active FROM ecotaxe_collector order by id;
""",
)
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_ecotax_classification ADD COLUMN old_id INTEGER;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_ecotax_classification (name, code, ecotax_type, ecotax_coef, default_fixed_ecotax,
categ_id, sector_id, collector_id, active, company_id,
product_status, supplier_status, emebi_code, scale_code, old_id)
SELECT name, code, ecotaxe_type, ecotaxe_coef, default_fixed_ecotaxe,
categ_id, sector_id, collector_id, active, company_id,
product_status, supplier_status, emebi_code, scale_code, id FROM account_ecotaxe_classification order by id;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move SET amount_ecotax = amount_ecotaxe;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move_line SET subtotal_ecotax = subtotal_ecotaxe, ecotax_amount_unit = ecotaxe_amount_unit;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_move_line_ecotax (classification_id, account_move_line_id, amount_unit, force_amount_unit, amount_total)
SELECT cls.id, account_move_line_id, amount_unit, force_amount_unit, amount_total FROM account_move_line_ecotaxe mle
INNER JOIN account_ecotax_classification cls on mle.classification_id = cls.old_id order by id;
""",
)

openupgrade.logged_query(
env.cr,
"""
INSERT INTO ecotax_line_product (product_tmpl_id, product_id, classification_id, force_amount, amount)
SELECT product_tmplt_id, product_id, cls.id, force_amount, amount FROM ecotaxe_line_product lp
INNER JOIN account_ecotax_classification cls on lp.classification_id = cls.old_id
order by id;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE product_product SET ecotax_amount = ecotaxe_amount;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE product_template SET ecotax_amount = ecotaxe_amount;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO sale_order_line_ecotax (classification_id, sale_order_line_id, amount_unit, force_amount_unit, amount_total)
SELECT cls.id, sale_order_line_id, amount_unit, force_amount_unit, amount_total FROM sale_order_line_ecotaxe ole
INNER JOIN account_ecotax_classification cls on ole.classification_id = cls.old_id order by id;
""",
)

openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_ecotax_classification DROP COLUMN old_id;
""",
)
61 changes: 0 additions & 61 deletions account_ecotax_sale/migrations/16.0.2.0.0/pre-migration.py

This file was deleted.

16 changes: 8 additions & 8 deletions account_ecotax_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def _compute_ecotax(self):
if (line.display_type and line.display_type != "product") or not ecotax_ids:
continue
amount_currency = line.price_unit * (1 - line.discount / 100)
handle_price_include = True
quantity = line.product_uom_qty
compute_all_currency = ecotax_ids.compute_all(
amount_currency,
currency=line.currency_id,
quantity=quantity,
product=line.product_id,
partner=line.order_id.partner_shipping_id)
amount_currency,
currency=line.currency_id,
quantity=quantity,
product=line.product_id,
partner=line.order_id.partner_shipping_id,
)
subtotal_ecotax = 0.0
for tax in compute_all_currency["taxes"]:
subtotal_ecotax += tax["amount"]
Expand All @@ -51,7 +51,7 @@ def _compute_ecotax(self):
line.ecotax_amount_unit = unit
line.subtotal_ecotax = subtotal_ecotax

@api.depends('product_id', 'company_id')
@api.depends("product_id", "company_id")
def _compute_tax_id(self):
super()._compute_tax_id()
for line in self:
Expand Down Expand Up @@ -100,7 +100,7 @@ def edit_ecotax_lines(self):
"view_mode": "form",
"res_model": "sale.order.line",
"view_id": self.env.ref(
"l10n_fr_ecotax_sale.view_sale_line_ecotax_form"
"account_ecotax_sale.view_sale_line_ecotax_form"
).id,
"type": "ir.actions.act_window",
"target": "new",
Expand Down
6 changes: 3 additions & 3 deletions account_ecotax_sale/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_ecotaxe_line_product_sale_readonly,ecotaxe.line.product readonly,l10n_fr_ecotaxe.model_ecotaxe_line_product,sales_team.group_sale_salesman,1,0,0,0
access_account_move_line_ecotaxe_readonly_sale_user,account.move.line.ecotaxe readonly sale user,l10n_fr_ecotaxe.model_account_move_line_ecotaxe,sales_team.group_sale_salesman,1,0,0,0
ir_model_access_sale_order_line_ecotaxe_group_sale_salesman,Read Full acess to model_sale_order_line_ecotaxe to group sale_salesman,model_sale_order_line_ecotaxe,sales_team.group_sale_salesman,1,1,1,1
access_ecotax_line_product_sale_readonly,ecotax.line.product readonly,account_ecotax.model_ecotax_line_product,sales_team.group_sale_salesman,1,0,0,0
access_account_move_line_ecotax_readonly_sale_user,account.move.line.ecotax readonly sale user,account_ecotax.model_account_move_line_ecotax,sales_team.group_sale_salesman,1,0,0,0
ir_model_access_sale_order_line_ecotax_group_sale_salesman,Read Full acess to model_sale_order_line_ecotax to group sale_salesman,model_sale_order_line_ecotax,sales_team.group_sale_salesman,1,1,1,1
6 changes: 3 additions & 3 deletions account_ecotax_sale/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>France sale Ecotaxe</title>
<title>sale Ecotax Management</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,8 +360,8 @@
</style>
</head>
<body>
<div class="document" id="france-sale-ecotaxe">
<h1 class="title">France sale Ecotaxe</h1>
<div class="document" id="sale-ecotax-management">
<h1 class="title">sale Ecotax Management</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
Expand Down
5 changes: 1 addition & 4 deletions account_ecotax_sale/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@
<field name="classification_id" />
<field name="force_amount_unit" />
<field name="amount_unit" />
<field
name="amount_total"
sum="Total Ecotax"
/>
<field name="amount_total" sum="Total Ecotax" />
</tree>
</field>
</page>
Expand Down

0 comments on commit 0e8cd7a

Please sign in to comment.