Skip to content

Commit ae13f0f

Browse files
committed
[MIG] purchase_deposit: Migration to 19.0
1 parent f8833b2 commit ae13f0f

File tree

6 files changed

+52
-40
lines changed

6 files changed

+52
-40
lines changed

purchase_deposit/README.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
================
26
Purchase Deposit
37
================
@@ -13,17 +17,17 @@ Purchase Deposit
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20-
:target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_deposit
24+
:target: https://github.com/OCA/purchase-workflow/tree/19.0/purchase_deposit
2125
:alt: OCA/purchase-workflow
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_deposit
27+
:target: https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-purchase_deposit
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -59,7 +63,7 @@ Bug Tracker
5963
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
6064
In case of trouble, please check there if your issue has already been reported.
6165
If you spotted it first, help us to smash it by providing a detailed and welcomed
62-
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_deposit%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
66+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_deposit%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6367

6468
Do not contact contributors directly about support or help with technical issues.
6569

@@ -96,6 +100,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
96100
mission is to support the collaborative development of Odoo features and
97101
promote its widespread use.
98102

99-
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/18.0/purchase_deposit>`_ project on GitHub.
103+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/19.0/purchase_deposit>`_ project on GitHub.
100104

101105
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

purchase_deposit/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{
66
"name": "Purchase Deposit",
7-
"version": "18.0.1.0.0",
7+
"version": "19.0.1.0.0",
88
"summary": "Option to create deposit from purchase order",
99
"author": "Elico Corp, Ecosoft, Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/purchase-workflow",

purchase_deposit/models/account_move.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def action_post(self):
1212
for line in self.line_ids:
1313
if not line.purchase_line_id.is_deposit:
1414
continue
15-
line.purchase_line_id.taxes_id = line.tax_ids
15+
line.purchase_line_id.tax_ids = line.tax_ids
1616
line.purchase_line_id.price_unit = line.price_unit
1717
return res

purchase_deposit/static/description/index.html

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Purchase Deposit</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="purchase-deposit">
364-
<h1 class="title">Purchase Deposit</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="purchase-deposit">
370+
<h1>Purchase Deposit</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370375
!! source digest: sha256:c5cfa6ba5279681ee9c1ed57ead42fe860b04997ae268fcb3b485f14d8aa5800
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/18.0/purchase_deposit"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_deposit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/19.0/purchase_deposit"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-purchase_deposit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>This module allow purchase order to register deposit similar to that in
374379
sales order</p>
375380
<p><strong>Table of contents</strong></p>
@@ -386,7 +391,7 @@ <h1 class="title">Purchase Deposit</h1>
386391
</ul>
387392
</div>
388393
<div class="section" id="usage">
389-
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
394+
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
390395
<p>When purchase order is confirmed, a new button “Register Deposit” will
391396
appear. Normally, deposit will be used to create the 1st bill (as
392397
deposit).</p>
@@ -402,24 +407,24 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
402407
deducted.</p>
403408
</div>
404409
<div class="section" id="bug-tracker">
405-
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
410+
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
406411
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/purchase-workflow/issues">GitHub Issues</a>.
407412
In case of trouble, please check there if your issue has already been reported.
408413
If you spotted it first, help us to smash it by providing a detailed and welcomed
409-
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_deposit%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
414+
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_deposit%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
410415
<p>Do not contact contributors directly about support or help with technical issues.</p>
411416
</div>
412417
<div class="section" id="credits">
413-
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
418+
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
414419
<div class="section" id="authors">
415-
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
420+
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
416421
<ul class="simple">
417422
<li>Elico Corp</li>
418423
<li>Ecosoft</li>
419424
</ul>
420425
</div>
421426
<div class="section" id="contributors">
422-
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
427+
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
423428
<ul class="simple">
424429
<li>Dominique K. &lt;<a class="reference external" href="mailto:dominique.k&#64;elico-corp.com.sg">dominique.k&#64;elico-corp.com.sg</a>&gt;</li>
425430
<li>Kitti Upariphutthiphong &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
@@ -432,18 +437,19 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
432437
</ul>
433438
</div>
434439
<div class="section" id="maintainers">
435-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
440+
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
436441
<p>This module is maintained by the OCA.</p>
437442
<a class="reference external image-reference" href="https://odoo-community.org">
438443
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
439444
</a>
440445
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
441446
mission is to support the collaborative development of Odoo features and
442447
promote its widespread use.</p>
443-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/18.0/purchase_deposit">OCA/purchase-workflow</a> project on GitHub.</p>
448+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/19.0/purchase_deposit">OCA/purchase-workflow</a> project on GitHub.</p>
444449
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
445450
</div>
446451
</div>
447452
</div>
453+
</div>
448454
</body>
449455
</html>

purchase_deposit/tests/test_purchase_deposit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def setUpClass(cls):
4242
0,
4343
{
4444
"product_id": p1.id,
45-
"product_uom": p1.uom_id.id,
45+
"product_uom_id": p1.uom_id.id,
4646
"name": p1.name,
4747
"price_unit": 100.0,
4848
"date_planned": fields.Datetime.now(),
@@ -198,4 +198,4 @@ def test_deposit_invoice_update_price_and_taxes(self):
198198
self.po.invoice_ids.action_post()
199199
deposit_line = self.po.order_line.filtered(lambda p: p.is_deposit)
200200
self.assertEqual(deposit_line.price_unit, 500.0)
201-
self.assertEqual(deposit_line.taxes_id.id, self.tax.id)
201+
self.assertEqual(deposit_line.tax_ids.id, self.tax.id)

purchase_deposit/wizard/purchase_make_invoice_advance.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66
from datetime import datetime
77

8-
from odoo import _, api, fields, models
8+
from odoo import api, fields, models
99
from odoo.exceptions import UserError
1010
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
1111

@@ -40,7 +40,7 @@ class PurchaseAdvancePaymentInv(models.TransientModel):
4040
compute="_compute_deposit_account_id",
4141
store=True,
4242
readonly=False,
43-
domain=[("deprecated", "=", False)],
43+
domain=[("active", "=", True)],
4444
help="Account used for deposits",
4545
)
4646
deposit_taxes_id = fields.Many2many(
@@ -73,23 +73,25 @@ def _prepare_deposit_val(self, order, po_line, amount):
7373
)
7474
if not account_id:
7575
raise UserError(
76-
_(
77-
"There is no purchase account defined for this product: %s."
78-
"\nYou may have to install a chart of account from "
79-
"Accounting app, settings menu."
76+
self.env._(
77+
"There is no purchase account defined for this product: "
78+
"%(product)s.\nYou may have to install a chart of "
79+
"account from Accounting app, settings menu.",
80+
product=product.name,
8081
)
81-
% (product.name,)
8282
)
8383

8484
if self.amount <= 0:
85-
raise UserError(_("The value of the deposit must be positive."))
85+
raise UserError(self.env._("The value of the deposit must be positive."))
8686
context = {"lang": order.partner_id.lang}
8787
amount = self.amount
8888
if self.advance_payment_method == "percentage": # Case percent
8989
if self.amount > 100:
90-
raise UserError(_("The percentage of the deposit must be not over 100"))
90+
raise UserError(
91+
self.env._("The percentage of the deposit must be not over 100")
92+
)
9193
amount = self.amount / 100 * order.amount_untaxed
92-
name = _("Deposit Payment")
94+
name = self.env._("Deposit Payment")
9395
del context
9496
taxes = product.supplier_taxes_id.filtered(
9597
lambda r: not order.company_id or r.company_id == order.company_id
@@ -125,7 +127,7 @@ def _prepare_deposit_val(self, order, po_line, amount):
125127
"fiscal_position_id": order.fiscal_position_id.id
126128
or order.partner_id.property_account_position_id.id,
127129
"purchase_id": order.id,
128-
"narration": order.notes,
130+
"narration": order.note,
129131
}
130132
return deposit_val
131133

@@ -142,20 +144,20 @@ def _create_invoice(self, order, po_line, amount):
142144

143145
def _prepare_advance_purchase_line(self, order, product, tax_ids, amount):
144146
return {
145-
"name": _("Advance: %s") % (time.strftime("%m %Y"),),
147+
"name": self.env._("Advance: %(date)s", date=time.strftime("%m %Y")),
146148
"price_unit": amount,
147149
"product_qty": 0.0,
148150
"order_id": order.id,
149-
"product_uom": product.uom_id.id,
151+
"product_uom_id": product.uom_id.id,
150152
"product_id": product.id,
151-
"taxes_id": [(6, 0, tax_ids)],
153+
"tax_ids": [(6, 0, tax_ids)],
152154
"date_planned": datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
153155
"is_deposit": True,
154156
}
155157

156158
def create_invoices(self):
157159
Purchase = self.env["purchase.order"]
158-
purchases = Purchase.browse(self._context.get("active_ids", []))
160+
purchases = Purchase.browse(self.env.context.get("active_ids", []))
159161
# Create deposit product if necessary
160162
product = self.purchase_deposit_product_id
161163
if not product:
@@ -171,7 +173,7 @@ def create_invoices(self):
171173
amount = self.amount / 100 * order.amount_untaxed
172174
if product.purchase_method != "purchase":
173175
raise UserError(
174-
_(
176+
self.env._(
175177
"The product used to invoice a down payment should have "
176178
'an invoice policy set to "Ordered quantities". '
177179
"Please update your deposit product to be able to "
@@ -180,7 +182,7 @@ def create_invoices(self):
180182
)
181183
if product.type != "service":
182184
raise UserError(
183-
_(
185+
self.env._(
184186
"The product used to invoice a down payment should be "
185187
'of type "Service". Please use another product or '
186188
"update this product."
@@ -201,7 +203,7 @@ def create_invoices(self):
201203
po_line = PurchaseLine.create(adv_po_line_dict)
202204
del context
203205
self._create_invoice(order, po_line, amount)
204-
if self._context.get("open_bills", False):
206+
if self.env.context.get("open_bills", False):
205207
return purchases.action_view_invoice()
206208
return {"type": "ir.actions.act_window_close"}
207209

0 commit comments

Comments
 (0)