odoo-addon-openupgrade-scripts 16.0.1.0.5.5__py3-none-any.whl → 16.0.1.0.5.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,9 @@
1
- # Copyright 2024 Tecnativa - Pedro M. Baeza
1
+ # Copyright 2024,2025 Tecnativa - Pedro M. Baeza
2
2
  # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3
3
  from openupgradelib import openupgrade
4
4
 
5
5
 
6
6
  def fill_purchase_order_group_from_tenders(env):
7
- tender_type = env.ref("purchase_requisition.type_multi")
8
7
  openupgrade.logged_query(
9
8
  env.cr,
10
9
  """
@@ -12,60 +11,33 @@ def fill_purchase_order_group_from_tenders(env):
12
11
  ADD COLUMN IF NOT EXISTS old_purchase_requisition_id INTEGER
13
12
  """,
14
13
  )
14
+ # Create a group if there is more than one PO per requisition
15
15
  openupgrade.logged_query(
16
16
  env.cr,
17
- f"""
18
- INSERT INTO purchase_order_group (old_purchase_requisition_id,
19
- create_date, create_uid, write_date, write_uid)
20
- SELECT DISTINCT ON (pr.id) pr.id,
21
- pr.create_date, pr.create_uid, pr.write_date, pr.write_uid
22
- FROM purchase_requisition pr
23
- JOIN purchase_order po1 ON po1.requisition_id = pr.id
24
- JOIN purchase_order po2 ON po2.requisition_id = pr.id AND po1.id != po2.id
25
- -- only create group if there is more than one purchase
26
- WHERE pr.type_id = {tender_type.id}
27
- RETURNING old_purchase_requisition_id
17
+ """
18
+ INSERT INTO purchase_order_group
19
+ (old_purchase_requisition_id, create_date, create_uid, write_date, write_uid)
20
+ SELECT
21
+ t.requisition_id, pr.create_date, pr.create_uid, pr.write_date, pr.write_uid
22
+ FROM (
23
+ SELECT *, row_number()
24
+ over (partition BY requisition_id ORDER BY id) AS rnum
25
+ FROM purchase_order
26
+ ) t
27
+ JOIN purchase_requisition pr ON pr.id = t.requisition_id
28
+ WHERE t.rnum = 2;
28
29
  """,
29
30
  )
30
- tender_requisition_ids = [x[0] for x in env.cr.fetchall()]
31
- if tender_requisition_ids:
32
- openupgrade.logged_query(
33
- env.cr,
34
- """
35
- UPDATE purchase_order po
36
- SET purchase_group_id = pog.id
37
- FROM purchase_order_group pog
38
- WHERE po.requisition_id = pog.old_purchase_requisition_id
39
- """,
40
- )
31
+ # Assign it to the purchase orders
41
32
  openupgrade.logged_query(
42
33
  env.cr,
43
- f"""
44
- SELECT pr.id
45
- FROM purchase_requisition pr
46
- WHERE pr.type_id = {tender_type.id}
47
- """,
34
+ """
35
+ UPDATE purchase_order po
36
+ SET purchase_group_id = pog.id
37
+ FROM purchase_order_group pog
38
+ WHERE po.requisition_id = pog.old_purchase_requisition_id
39
+ """,
48
40
  )
49
- obsolete_requisition_ids = [x[0] for x in env.cr.fetchall()]
50
- if obsolete_requisition_ids:
51
- openupgrade.logged_query(
52
- env.cr,
53
- f"""
54
- UPDATE purchase_order po
55
- SET requisition_id = NULL
56
- FROM purchase_requisition pr
57
- WHERE po.requisition_id = pr.id AND pr.type_id = {tender_type.id}
58
- """,
59
- )
60
- openupgrade.logged_query(
61
- env.cr,
62
- """
63
- UPDATE purchase_requisition pr
64
- SET state = 'draft'
65
- WHERE pr.state not in ('draft', 'cancel')
66
- """,
67
- )
68
- env["purchase.requisition"].browse(obsolete_requisition_ids).unlink()
69
41
 
70
42
 
71
43
  @openupgrade.migrate()
@@ -1,7 +1,7 @@
1
1
  new model purchase.order.group
2
2
  purchase_requisition / purchase.order / purchase_group_id (many2one) : NEW relation: purchase.order.group
3
3
  purchase_requisition / purchase.order.group / order_ids (one2many) : NEW relation: purchase.order
4
- # DONE: post-migration: group purchases by their requisition if it has the deleted type "purchase_requisition.type_multi"
4
+ # DONE: post-migration: group purchases by their requisition if there's more than one PO per requisition
5
5
 
6
6
  new model purchase.requisition.alternative.warning [transient]
7
7
  new model purchase.requisition.create.alternative [transient]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: odoo-addon-openupgrade_scripts
3
- Version: 16.0.1.0.5.5
3
+ Version: 16.0.1.0.5.6
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: odoo>=16.0a,<16.1dev
6
6
  Requires-Dist: openupgradelib
@@ -567,10 +567,10 @@ odoo/addons/openupgrade_scripts/scripts/purchase_mrp/16.0.1.0/upgrade_analysis_w
567
567
  odoo/addons/openupgrade_scripts/scripts/purchase_price_diff/16.0.1.1/upgrade_analysis.txt,sha256=2l0XlbqnoZrzqOSlmOs454g9chxTfBePihRGTtRDVFM,675
568
568
  odoo/addons/openupgrade_scripts/scripts/purchase_product_matrix/16.0.1.0/upgrade_analysis.txt,sha256=ziZfZQGATL_2VPdgw-7hgS7661nkDbbYuT_SgMrpFmw,192
569
569
  odoo/addons/openupgrade_scripts/scripts/purchase_product_matrix/16.0.1.0/upgrade_analysis_work.txt,sha256=sIszLO8a-iwZxbi3KvMV4JOfs1YB1u-lVC8XGB_Ef9k,208
570
- odoo/addons/openupgrade_scripts/scripts/purchase_requisition/16.0.0.1/post-migration.py,sha256=vIlR87WWDD6cM7AGg0odwwwRx5rjV8VgMSTmXEvwl8c,2639
570
+ odoo/addons/openupgrade_scripts/scripts/purchase_requisition/16.0.0.1/post-migration.py,sha256=9soc9mwgKC8Vu3uOsam0VUPvU8fWtSPYUVdTbXRQ9IY,1570
571
571
  odoo/addons/openupgrade_scripts/scripts/purchase_requisition/16.0.0.1/pre-migration.py,sha256=Hk9x4_Ac4Fq3VCSbg7TJv0k_8w3I-sCV_pfZBYg3OFA,508
572
572
  odoo/addons/openupgrade_scripts/scripts/purchase_requisition/16.0.0.1/upgrade_analysis.txt,sha256=hu4bNoVAuOmaDuK0IQDQV5y3J0lg4r58gCoH6fYrLEM,2295
573
- odoo/addons/openupgrade_scripts/scripts/purchase_requisition/16.0.0.1/upgrade_analysis_work.txt,sha256=SKoXzFl7RvH_8-v7iAHAiD05V2HA4x04jmXKYoDgF3I,2618
573
+ odoo/addons/openupgrade_scripts/scripts/purchase_requisition/16.0.0.1/upgrade_analysis_work.txt,sha256=2fMt9PAN7qeUdJ8CeUerCIVOvYKxlHuAd6l8pHyPOXk,2601
574
574
  odoo/addons/openupgrade_scripts/scripts/purchase_requisition_stock/16.0.1.2/upgrade_analysis.txt,sha256=dmjMOLEfLnKWEfqynh-dOtbg8CmU1sLEE4gsZcsZ-ks,491
575
575
  odoo/addons/openupgrade_scripts/scripts/purchase_requisition_stock/16.0.1.2/upgrade_analysis_work.txt,sha256=9YAXG1LLqe3RkqfoNkCTYlMDsdfaT0i7RJArIR-0u6E,624
576
576
  odoo/addons/openupgrade_scripts/scripts/purchase_stock/16.0.1.2/pre-migration.py,sha256=gDGPEvpqn2TY0U1qKin7w5JY2p6CokhTIq3tk-ddWfM,1539
@@ -790,7 +790,7 @@ odoo/addons/openupgrade_scripts/scripts/website_twitter/16.0.1.0/upgrade_analysi
790
790
  odoo/addons/openupgrade_scripts/static/description/banner.png,sha256=KTIBu4gfxeZVw9zjs_fivTgFEOeaAorlBxajmCA1p6k,26859
791
791
  odoo/addons/openupgrade_scripts/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
792
792
  odoo/addons/openupgrade_scripts/static/description/index.html,sha256=T3CGCNUVysVD8ysCfwpbPWR5z8x_9vbYNoS4TLHDYOQ,12940
793
- odoo_addon_openupgrade_scripts-16.0.1.0.5.5.dist-info/METADATA,sha256=WYO1dpNUrYwHzUx9qQ-PJeajgzdm6l_ZIY2xHZhiZWg,3985
794
- odoo_addon_openupgrade_scripts-16.0.1.0.5.5.dist-info/WHEEL,sha256=ZhOvUsYhy81Dx67gN3TV0RchQWBIIzutDZaJODDg2Vo,81
795
- odoo_addon_openupgrade_scripts-16.0.1.0.5.5.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
796
- odoo_addon_openupgrade_scripts-16.0.1.0.5.5.dist-info/RECORD,,
793
+ odoo_addon_openupgrade_scripts-16.0.1.0.5.6.dist-info/METADATA,sha256=Bctnar-XTxQlgiYseXqYZ8iBVE9gKdvysZkWn4TJ3i8,3985
794
+ odoo_addon_openupgrade_scripts-16.0.1.0.5.6.dist-info/WHEEL,sha256=ZhOvUsYhy81Dx67gN3TV0RchQWBIIzutDZaJODDg2Vo,81
795
+ odoo_addon_openupgrade_scripts-16.0.1.0.5.6.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
796
+ odoo_addon_openupgrade_scripts-16.0.1.0.5.6.dist-info/RECORD,,