From a94bc219dc8c5a6e4be8787490d1497d19a5a274 Mon Sep 17 00:00:00 2001
From: mreficent
Date: Wed, 20 Mar 2019 17:10:44 +0100
Subject: [PATCH] [MIG] stock_warehouse_calendar: Migration to 12.0
---
stock_warehouse_calendar/README.rst | 18 +++++++++---------
stock_warehouse_calendar/__init__.py | 1 +
stock_warehouse_calendar/__manifest__.py | 6 +++---
stock_warehouse_calendar/models/__init__.py | 3 ++-
.../{procurement_rule.py => stock_rule.py} | 8 ++++----
.../models/stock_warehouse.py | 6 ++++--
stock_warehouse_calendar/readme/CONFIGURE.rst | 2 +-
.../static/description/index.html | 6 +++---
stock_warehouse_calendar/tests/__init__.py | 2 +-
.../tests/test_stock_warehouse_calendar.py | 12 ++++++------
10 files changed, 34 insertions(+), 30 deletions(-)
rename stock_warehouse_calendar/models/{procurement_rule.py => stock_rule.py} (81%)
diff --git a/stock_warehouse_calendar/README.rst b/stock_warehouse_calendar/README.rst
index c3b48de6d..160e057b8 100644
--- a/stock_warehouse_calendar/README.rst
+++ b/stock_warehouse_calendar/README.rst
@@ -10,17 +10,17 @@ Stock Warehouse Calendar
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
-.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
- :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
- :alt: License: AGPL-3
+.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
+ :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
- :target: https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_warehouse_calendar
+ :target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_warehouse_calendar
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-11-0/stock-logistics-warehouse-11-0-stock_warehouse_calendar
+ :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_warehouse_calendar
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/153/11.0
+ :target: https://runbot.odoo-community.org/runbot/153/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -53,7 +53,7 @@ Configuration
'Multi-Step Routes option'.
* Go to *Inventory > Configuration > Warehouse Management > Routes* and
- set up the proper delays in the procurement rules where 'action'
+ set up the proper delays in the stock rules where 'action'
is 'Move From Another Location'.
Usage
@@ -72,7 +72,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -110,6 +110,6 @@ Current `maintainer `__:
|maintainer-jbeficent|
-This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub.
+This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/stock_warehouse_calendar/__init__.py b/stock_warehouse_calendar/__init__.py
index 0650744f6..133f68732 100644
--- a/stock_warehouse_calendar/__init__.py
+++ b/stock_warehouse_calendar/__init__.py
@@ -1 +1,2 @@
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models
diff --git a/stock_warehouse_calendar/__manifest__.py b/stock_warehouse_calendar/__manifest__.py
index 5b31625f2..0b3a5bc9e 100644
--- a/stock_warehouse_calendar/__manifest__.py
+++ b/stock_warehouse_calendar/__manifest__.py
@@ -4,15 +4,15 @@
{
"name": "Stock Warehouse Calendar",
"summary": "Adds a calendar to the Warehouse",
- "version": "11.0.1.0.0",
- "license": "AGPL-3",
+ "version": "12.0.1.0.0",
+ "license": "LGPL-3",
"website": "https://github.com/stock-logistics-warehouse",
"author": "Eficent, "
"Odoo Community Association (OCA)",
"category": "Warehouse Management",
"depends": [
"stock",
- "resource"
+ "resource",
],
"data": [
"views/stock_warehouse_views.xml",
diff --git a/stock_warehouse_calendar/models/__init__.py b/stock_warehouse_calendar/models/__init__.py
index e41660708..200eddbf2 100644
--- a/stock_warehouse_calendar/models/__init__.py
+++ b/stock_warehouse_calendar/models/__init__.py
@@ -1,2 +1,3 @@
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import stock_warehouse
-from . import procurement_rule
+from . import stock_rule
diff --git a/stock_warehouse_calendar/models/procurement_rule.py b/stock_warehouse_calendar/models/stock_rule.py
similarity index 81%
rename from stock_warehouse_calendar/models/procurement_rule.py
rename to stock_warehouse_calendar/models/stock_rule.py
index ebe166203..896a6faae 100644
--- a/stock_warehouse_calendar/models/procurement_rule.py
+++ b/stock_warehouse_calendar/models/stock_rule.py
@@ -5,15 +5,15 @@ from odoo import fields, models
from datetime import datetime
-class ProcurementRule(models.Model):
- _inherit = 'procurement.rule'
+class StockRule(models.Model):
+ _inherit = 'stock.rule'
def _get_stock_move_values(self, product_id, product_qty, product_uom,
location_id, name, origin, values, group_id):
- res = super(ProcurementRule, self)._get_stock_move_values(
+ res = super(StockRule, self)._get_stock_move_values(
product_id, product_qty, product_uom,
location_id, name, origin, values, group_id)
- dt_planned = fields.Datetime.from_string(values['date_planned'])
+ dt_planned = fields.Datetime.to_datetime(values['date_planned'])
warehouse = self.propagate_warehouse_id or self.warehouse_id
if warehouse.calendar_id and self.delay:
date_expected = warehouse.calendar_id.plan_days(
diff --git a/stock_warehouse_calendar/models/stock_warehouse.py b/stock_warehouse_calendar/models/stock_warehouse.py
index 9cfb899be..b14104db6 100644
--- a/stock_warehouse_calendar/models/stock_warehouse.py
+++ b/stock_warehouse_calendar/models/stock_warehouse.py
@@ -7,5 +7,7 @@ from odoo import fields, models
class StockWarehouse(models.Model):
_inherit = 'stock.warehouse'
- calendar_id = fields.Many2one('resource.calendar',
- 'Working Hours')
+ calendar_id = fields.Many2one(
+ comodel_name='resource.calendar',
+ string='Working Hours',
+ )
diff --git a/stock_warehouse_calendar/readme/CONFIGURE.rst b/stock_warehouse_calendar/readme/CONFIGURE.rst
index b77834e5b..2c97aad45 100644
--- a/stock_warehouse_calendar/readme/CONFIGURE.rst
+++ b/stock_warehouse_calendar/readme/CONFIGURE.rst
@@ -10,5 +10,5 @@
'Multi-Step Routes option'.
* Go to *Inventory > Configuration > Warehouse Management > Routes* and
- set up the proper delays in the procurement rules where 'action'
+ set up the proper delays in the stock rules where 'action'
is 'Move From Another Location'.
diff --git a/stock_warehouse_calendar/static/description/index.html b/stock_warehouse_calendar/static/description/index.html
index 33fa8e61b..aa771c361 100644
--- a/stock_warehouse_calendar/static/description/index.html
+++ b/stock_warehouse_calendar/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module adds a Calendar to the Warehouse. This calendar can then used as
the basis of the proper computation of start/end dates based on lead times in
this and other modules.
@@ -417,7 +417,7 @@ if the warehouse operates under a Mo-Fri working calendar.
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
diff --git a/stock_warehouse_calendar/tests/__init__.py b/stock_warehouse_calendar/tests/__init__.py
index faa5afbf1..5a6c657ff 100644
--- a/stock_warehouse_calendar/tests/__init__.py
+++ b/stock_warehouse_calendar/tests/__init__.py
@@ -1,2 +1,2 @@
-# -*- coding: utf-8 -*-
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_stock_warehouse_calendar
diff --git a/stock_warehouse_calendar/tests/test_stock_warehouse_calendar.py b/stock_warehouse_calendar/tests/test_stock_warehouse_calendar.py
index 3335abdf7..b2e3951d7 100644
--- a/stock_warehouse_calendar/tests/test_stock_warehouse_calendar.py
+++ b/stock_warehouse_calendar/tests/test_stock_warehouse_calendar.py
@@ -1,5 +1,5 @@
-# -*- coding: utf-8 -*-
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
+# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields
from odoo.tests.common import TransactionCase
@@ -36,7 +36,7 @@ class TestStockWarehouseCalendar(TransactionCase):
rule_vals = {
'location_id': self.warehouse.lot_stock_id.id,
'location_src_id': self.warehouse_2.lot_stock_id.id,
- 'action': 'move',
+ 'action': 'pull_push',
'warehouse_id': self.warehouse.id,
'propagate_warehouse_id': self.warehouse_2.id,
'picking_type_id': self.env.ref('stock.picking_type_internal').id,
@@ -44,7 +44,7 @@ class TestStockWarehouseCalendar(TransactionCase):
'route_id': self.transfer_route.id,
'delay': 1,
}
- self.transfer_rule = self.env['procurement.rule'].create(rule_vals)
+ self.transfer_rule = self.env['stock.rule'].create(rule_vals)
self.product.route_ids = [(6, 0, self.transfer_route.ids)]
def test_procurement_with_calendar(self):
@@ -61,8 +61,8 @@ class TestStockWarehouseCalendar(TransactionCase):
'Test', values)
move = self.env['stock.move'].search(
[('product_id', '=', self.product.id)], limit=1)
- date_expected = fields.Datetime.from_string(move.date_expected).date()
+ date_expected = fields.Date.to_date(move.date_expected)
# Friday 4th Jan 2017
- friday = fields.Datetime.from_string('2097-01-04 09:00:00').date()
+ friday = fields.Date.to_date('2097-01-04 09:00:00')
self.assertEquals(date_expected, friday)