Skip to content

Commit 92b388b

Browse files
[18.0][MIG] product_make: Migration to 18.0
1 parent 513f3c0 commit 92b388b

23 files changed

+773
-933
lines changed

product_make/__init__.py

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,2 @@
11
from . import models
22
from . import reports
3-
from odoo import api, SUPERUSER_ID
4-
5-
6-
def _put_sale_info_in_invoices(cr, registry):
7-
env = api.Environment(cr, SUPERUSER_ID, {})
8-
cond = [("invoice_ids", "!=", False)]
9-
sales = env["sale.order"].search(cond)
10-
for sale in sales:
11-
modified = False
12-
for invoice in sale.invoice_ids:
13-
if sale.team_id and not invoice.team_id:
14-
modified = True
15-
env.cr.execute(
16-
"""
17-
UPDATE account_move
18-
SET team_id = %s
19-
WHERE id = %s
20-
""",
21-
(sale.team_id.id, invoice.id),
22-
)
23-
if sale.commercial_make_id and not invoice.commercial_make_id:
24-
modified = True
25-
env.cr.execute(
26-
"""
27-
UPDATE account_move
28-
SET commercial_make_id = %s
29-
WHERE id = %s
30-
""",
31-
(sale.commercial_make_id.id, invoice.id),
32-
)
33-
if (
34-
sale.num_allowed_commercial_make
35-
and not invoice.num_allowed_commercial_make
36-
):
37-
modified = True
38-
env.cr.execute(
39-
"""
40-
UPDATE account_move
41-
SET num_allowed_commercial_make = %s
42-
WHERE id = %s
43-
""",
44-
(sale.num_allowed_commercial_make, invoice.id),
45-
)
46-
if sale.relation_id and not invoice.relation_id:
47-
modified = True
48-
env.cr.execute(
49-
"""
50-
UPDATE account_move
51-
SET relation_id = %s
52-
WHERE id = %s
53-
""",
54-
(sale.relation_id.id, invoice.id),
55-
)
56-
if sale.classification_id and not invoice.classification_id:
57-
modified = True
58-
env.cr.execute(
59-
"""
60-
UPDATE account_move
61-
SET classification_id = %s
62-
WHERE id = %s
63-
""",
64-
(sale.classification_id.id, invoice.id),
65-
)
66-
if sale.allowed_commercial_make_ids:
67-
for make in sale.allowed_commercial_make_ids:
68-
env.cr.execute(
69-
"""
70-
SELECT 1 FROM account_move_product_make_rel
71-
WHERE account_move_id = %s AND product_make_id = %s
72-
""",
73-
(invoice.id, make.id),
74-
)
75-
if not env.cr.fetchone():
76-
modified = True
77-
env.cr.execute(
78-
"""
79-
INSERT INTO account_move_product_make_rel
80-
(account_move_id, product_make_id)
81-
VALUES (%s, %s)
82-
""",
83-
(invoice.id, make.id),
84-
)
85-
if sale.market_id and not invoice.market_id:
86-
modified = True
87-
env.cr.execute(
88-
"""
89-
UPDATE account_move
90-
SET market_id = %s
91-
WHERE id = %s
92-
""",
93-
(sale.market_id.id, invoice.id),
94-
)
95-
if sale.market_sector_id and not invoice.market_sector_id:
96-
modified = True
97-
env.cr.execute(
98-
"""
99-
UPDATE account_move
100-
SET market_sector_id = %s
101-
WHERE id = %s
102-
""",
103-
(sale.market_sector_id.id, invoice.id),
104-
)
105-
if sale.global_discount_ids_readonly:
106-
for discount in sale.global_discount_ids_readonly:
107-
env.cr.execute(
108-
"""
109-
SELECT 1 FROM account_move_global_discount_rel
110-
WHERE invoice_id = %s AND global_discount_id = %s
111-
""",
112-
(invoice.id, discount.id),
113-
)
114-
if not env.cr.fetchone():
115-
modified = True
116-
env.cr.execute(
117-
"""
118-
INSERT INTO account_move_global_discount_rel
119-
(invoice_id, global_discount_id)
120-
VALUES (%s, %s)
121-
""",
122-
(invoice.id, discount.id),
123-
)
124-
for sale_line in sale.order_line:
125-
for invoice_line in sale_line.invoice_lines:
126-
if sale_line.allowed_make_ids:
127-
for make in sale_line.allowed_make_ids:
128-
env.cr.execute(
129-
"""
130-
SELECT 1 FROM account_move_line_product_make_rel
131-
WHERE account_move_line_id = %s AND product_make_id = %s
132-
""",
133-
(invoice_line.id, make.id),
134-
)
135-
if not env.cr.fetchone():
136-
modified = True
137-
env.cr.execute(
138-
"""
139-
INSERT INTO account_move_line_product_make_rel
140-
(account_move_line_id, product_make_id)
141-
VALUES (%s, %s)
142-
""",
143-
(invoice_line.id, make.id),
144-
)
145-
if sale_line.team_id and not invoice_line.team_id:
146-
modified = True
147-
env.cr.execute(
148-
"""
149-
UPDATE account_move_line
150-
SET team_id = %s
151-
WHERE id = %s
152-
""",
153-
(sale_line.team_id.id, invoice_line.id),
154-
)
155-
if sale_line.make_id and not invoice_line.make_id:
156-
modified = True
157-
env.cr.execute(
158-
"""
159-
UPDATE account_move_line
160-
SET make_id = %s
161-
WHERE id = %s
162-
""",
163-
(sale_line.make_id.id, invoice_line.id),
164-
)
165-
if modified:
166-
env.cr.commit()

product_make/__manifest__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
33
{
44
"name": "Product Make",
5-
"version": "16.0.1.0.0",
5+
"version": "18.0.1.0.0",
66
"category": "Sales/Sales",
77
"license": "AGPL-3",
88
"author": "AvanzOSC",
@@ -40,5 +40,4 @@
4040
"reports/sale_report_views.xml",
4141
],
4242
"installable": True,
43-
"post_init_hook": "_put_sale_info_in_invoices",
4443
}

product_make/models/account_move.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _compute_makes_on_invoice(self):
1717
if not makes:
1818
makes = line.make_id.name
1919
else:
20-
makes = f"{makes}, {line.make_id.name}"
20+
makes = "{}, {}".format(makes, line.make_id.name)
2121
invoice.makes_on_invoice = makes
2222

2323
makes_on_invoice = fields.Char(

product_make/models/sale_order.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _compute_makes_in_orders(self):
5757
if not makes:
5858
makes = line.make_id.name
5959
else:
60-
makes = f"{makes}, {line.make_id.name}"
60+
makes = "{}, {}".format(makes, line.make_id.name)
6161
sale.makes_in_orders = makes
6262

6363
def action_makes_in_lines(self):

product_make/models/stock_picking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _compute_makes_in_lines(self):
8282
if not makes:
8383
makes = line.make_id.name
8484
else:
85-
makes = f"{makes}, {line.make_id.name}"
85+
makes = "{}, {}".format(makes, line.make_id.name)
8686
picking.makes_in_lines = makes
8787

8888
def action_makes_in_lines(self):

product_make/pyproject.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 65 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,75 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
<template id="report_partner_make_amount_document">
4-
<t t-call="web.html_container">
5-
<t t-call="web.external_layout">
6-
<t t-set="o" t-value="o.with_context(lang=o.lang)" />
7-
<t t-set="partner" t-value="o" />
8-
<t t-if="partner" name="partner_header">
9-
<t t-set="address">
10-
<div
3+
<template id="report_partner_make_amount_document">
4+
<t t-call="web.html_container">
5+
<t t-call="web.external_layout">
6+
<t t-set="o" t-value="o.with_context(lang=o.lang)" />
7+
<t t-set="partner" t-value="o" />
8+
<t t-if="partner" name="partner_header">
9+
<t t-set="address">
10+
<div
1111
t-esc="partner"
1212
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True}'
1313
/>
14-
</t>
15-
</t>
16-
<div class="page">
17-
<br />
18-
<br />
19-
<strong>Tariff: </strong>
20-
<span t-field="o.property_product_pricelist" />
21-
<table class="table table-sm mt48">
22-
<thead>
23-
<tr>
24-
<th>
25-
<strong>Make</strong>
26-
</th>
27-
<th>
28-
<strong>State</strong>
29-
</th>
30-
<th>
31-
<strong>Commercial</strong>
32-
</th>
33-
<th>
34-
<strong>Amount</strong>
35-
</th>
36-
</tr>
37-
</thead>
38-
<tbody>
39-
<t t-set="lines" t-value="o.make_amount_ids" />
40-
<tr t-foreach="lines" t-as="line">
41-
<td>
42-
<span t-field="line.make_id" />
43-
</td>
44-
<td>
45-
<span t-field="line.partner_state_id" />
46-
</td>
47-
<td>
48-
<span t-field="line.commercial_id" />
49-
</td>
50-
<td>
51-
<span t-field="line.debit" />
52-
</td>
53-
</tr>
54-
</tbody>
55-
</table>
56-
</div>
57-
</t>
58-
</t>
59-
</template>
14+
</t>
15+
</t>
16+
<div class="page">
17+
<br />
18+
<br />
19+
<strong>Tariff: </strong><span
20+
t-field="o.property_product_pricelist"
21+
/>
22+
<table class="table table-sm mt48">
23+
<thead>
24+
<tr>
25+
<th><strong>Make</strong></th>
26+
<th><strong>State</strong></th>
27+
<th><strong>Commercial</strong></th>
28+
<th><strong>Amount</strong></th>
29+
</tr>
30+
</thead>
31+
<tbody>
32+
<t t-set="lines" t-value="o.make_amount_ids" />
33+
<tr t-foreach="lines" t-as="line">
34+
<td>
35+
<span t-field="line.make_id" />
36+
</td>
37+
<td>
38+
<span t-field="line.partner_state_id" />
39+
</td>
40+
<td>
41+
<span t-field="line.commercial_id" />
42+
</td>
43+
<td>
44+
<span t-field="line.debit" />
45+
</td>
46+
</tr>
47+
</tbody>
48+
</table>
49+
</div>
50+
</t>
51+
</t>
52+
</template>
6053

61-
<template id="report_partner_make_amount">
62-
<t t-foreach="docs" t-as="o">
63-
<t t-call="product_make.report_partner_make_amount_document" t-lang="o.lang" />
64-
</t>
65-
</template>
54+
<template id="report_partner_make_amount">
55+
<t t-foreach="docs" t-as="o">
56+
<t
57+
t-call="product_make.report_partner_make_amount_document"
58+
t-lang="o.lang"
59+
/>
60+
</t>
61+
</template>
6662

67-
<record id="action_report_partner_make_amount" model="ir.actions.report">
68-
<field name="name">Tariff and amount by makes</field>
69-
<field name="model">res.partner</field>
70-
<field name="report_type">qweb-pdf</field>
71-
<field name="report_name">product_make.report_partner_make_amount</field>
72-
<field name="report_file">product_make.report_partner_make_amount</field>
73-
<field
63+
<record id="action_report_partner_make_amount" model="ir.actions.report">
64+
<field name="name">Tariff and amount by makes</field>
65+
<field name="model">res.partner</field>
66+
<field name="report_type">qweb-pdf</field>
67+
<field name="report_name">product_make.report_partner_make_amount</field>
68+
<field name="report_file">product_make.report_partner_make_amount</field>
69+
<field
7470
name="print_report_name"
7571
>'Tariff and amoutn by makes for customer - %s ' % (object.name or '')</field>
76-
<field name="binding_model_id" ref="base.model_res_partner" />
77-
<field name="binding_type">report</field>
78-
</record>
72+
<field name="binding_model_id" ref="base.model_res_partner" />
73+
<field name="binding_type">report</field>
74+
</record>
7975
</odoo>
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<odoo>
3-
<record id="view_order_product_search" model="ir.ui.view">
4-
<field name="model">sale.report</field>
5-
<field name="inherit_id" ref="sale.view_order_product_search" />
6-
<field name="arch" type="xml">
7-
<field name="country_id" position="after">
8-
<field name="make_id" />
9-
</field>
10-
<filter name="country_id" position="after">
11-
<filter string="Make" name="make" context="{'group_by':'make_id'}" />
12-
</filter>
13-
</field>
14-
</record>
3+
<record id="view_order_product_search" model="ir.ui.view">
4+
<field name="model">sale.report</field>
5+
<field name="inherit_id" ref="sale.view_order_product_search" />
6+
<field name="arch" type="xml">
7+
<field name="country_id" position="after">
8+
<field name="make_id" />
9+
</field>
10+
<filter name="country_id" position="after">
11+
<filter string="Make" name="make" context="{'group_by':'make_id'}" />
12+
</filter>
13+
</field>
14+
</record>
1515
</odoo>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<odoo noupdate="1">
3-
<record id="make_amount_user" model="res.groups">
4-
<field name="name">Amounts by makes</field>
5-
<field name="users" eval="[(4, ref('base.user_admin'))]" />
6-
</record>
3+
<record id="make_amount_user" model="res.groups">
4+
<field name="name">Amounts by makes</field>
5+
<field name="users" eval="[(4, ref('base.user_admin'))]" />
6+
</record>
77
</odoo>

0 commit comments

Comments
 (0)