Skip to content

Commit 4d0a609

Browse files
committed
[MIG] purchase_date_planned_manual: Migration to 16.0
1 parent 4a8715a commit 4d0a609

File tree

10 files changed

+161
-118
lines changed

10 files changed

+161
-118
lines changed

purchase_date_planned_manual/README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ Contributors
8080
~~~~~~~~~~~~
8181

8282
* Lois Rilo <lois.rilo@eficent.com>
83+
* Chau Le <chaulb@trobz.com>
84+
85+
86+
Other credits
87+
~~~~~~~~~~~~~
88+
89+
The migration of this module from 12.0 to 16.0 was financially supported by Camptocamp
8390

8491
Maintainers
8592
~~~~~~~~~~~

purchase_date_planned_manual/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"name": "Purchase Date Planned Manual",
77
"summary": "This module makes the system to always respect the planned "
88
"(or scheduled) date in PO lines.",
9-
"version": "12.0.1.0.0",
9+
"version": "16.0.1.0.0",
1010
"development_status": "Mature",
1111
"author": "Eficent, " "Odoo Community Association (OCA)",
1212
"maintainers": ["lreficent"],

purchase_date_planned_manual/models/purchase_order.py

+38-35
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,27 @@ class PurchaseOrderLine(models.Model):
2020
"for lead times.",
2121
)
2222

23-
@api.multi
2423
@api.depends("order_id.state")
2524
def _compute_predicted_arrival_late(self):
2625
"""Colour the lines in red if the products are predicted to arrive
2726
late."""
2827
for line in self:
29-
seller = line.product_id._select_seller(
30-
partner_id=line.partner_id,
31-
quantity=line.product_qty,
32-
date=line.order_id.date_order.date(),
33-
uom_id=line.product_uom,
34-
)
35-
order_date = line.order_id.date_order
36-
po_lead = line.order_id.company_id.po_lead
37-
delta = po_lead + seller.delay if seller else po_lead
38-
date_expected = order_date + relativedelta(days=delta)
39-
line.predicted_arrival_late = (
40-
date_expected > line.date_planned and line.order_id.state == "draft"
41-
)
28+
if line.product_id:
29+
seller = line.product_id._select_seller(
30+
partner_id=line.partner_id,
31+
quantity=line.product_qty,
32+
date=line.order_id.date_order.date(),
33+
uom_id=line.product_uom,
34+
)
35+
order_date = line.order_id.date_order
36+
po_lead = line.order_id.company_id.po_lead
37+
delta = po_lead + seller.delay if seller else po_lead
38+
date_expected = order_date + relativedelta(days=delta)
39+
line.predicted_arrival_late = (
40+
date_expected > line.date_planned and line.order_id.state == "draft"
41+
)
42+
else:
43+
line.predicted_arrival_late = False
4244

4345
@api.model
4446
def _get_date_planned(self, seller, po=False):
@@ -48,7 +50,6 @@ def _get_date_planned(self, seller, po=False):
4850
else:
4951
return super(PurchaseOrderLine, self)._get_date_planned(seller, po)
5052

51-
@api.multi
5253
def action_delayed_line(self):
5354
raise UserError(
5455
_(
@@ -58,25 +59,27 @@ def action_delayed_line(self):
5859
% Dt.to_string(Dt.context_timestamp(self, self.date_planned))
5960
)
6061

61-
def _merge_in_existing_line(
62-
self, product_id, product_qty, product_uom, location_id, name, origin, values
63-
):
64-
if self.date_planned == values.get("date_planned"):
65-
return super(PurchaseOrderLine, self)._merge_in_existing_line(
66-
product_id, product_qty, product_uom, location_id, name, origin, values
67-
)
68-
return False
69-
70-
71-
class StockRule(models.Model):
72-
_inherit = "stock.rule"
73-
74-
def _prepare_purchase_order_line(
75-
self, product_id, product_qty, product_uom, values, po, supplier
62+
def _find_candidate(
63+
self,
64+
product_id,
65+
product_qty,
66+
product_uom,
67+
location_id,
68+
name,
69+
origin,
70+
company_id,
71+
values,
7672
):
77-
res = super(StockRule, self)._prepare_purchase_order_line(
78-
product_id, product_qty, product_uom, values, po, supplier
73+
date_planned = values.get("date_planned")
74+
if date_planned:
75+
self = self.filtered(lambda line: line.date_planned == date_planned)
76+
return super()._find_candidate(
77+
product_id,
78+
product_qty,
79+
product_uom,
80+
location_id,
81+
name,
82+
origin,
83+
company_id,
84+
values,
7985
)
80-
if values.get("date_planned"):
81-
res["date_planned"] = values.get("date_planned")
82-
return res
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
* Lois Rilo <lois.rilo@eficent.com>
2+
* Chau Le <chaulb@trobz.com>
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The migration of this module from 12.0 to 16.0 was financially supported by Camptocamp

purchase_date_planned_manual/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=["setuptools-odoo"],
5+
odoo_addon=True,
6+
)

purchase_date_planned_manual/static/description/index.html

+8-2
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ <h1 class="title">Purchase Date Planned Manual</h1>
383383
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
384384
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
385385
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
386-
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
386+
<li><a class="reference internal" href="#other-credits" id="toc-entry-6">Other credits</a></li>
387+
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
387388
</ul>
388389
</li>
389390
</ul>
@@ -426,10 +427,15 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
426427
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
427428
<ul class="simple">
428429
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li>
430+
<li>Chau Le &lt;<a class="reference external" href="mailto:chaulb&#64;trobz.com">chaulb&#64;trobz.com</a>&gt;</li>
429431
</ul>
430432
</div>
433+
<div class="section" id="other-credits">
434+
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
435+
<p>The migration of this module from 12.0 to 16.0 was financially supported by Camptocamp</p>
436+
</div>
431437
<div class="section" id="maintainers">
432-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
438+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
433439
<p>This module is maintained by the OCA.</p>
434440
<a class="reference external image-reference" href="https://odoo-community.org">
435441
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />

0 commit comments

Comments
 (0)