[12.0] mrp_warehouse_calendar:

* fix error calculating the planned date depending on the hour.
* relicense to lgpl to allow broader use in customizations.
This commit is contained in:
Lois Rilo
2019-07-31 12:22:13 +02:00
committed by Lois Rilo
parent aa201e188d
commit ce7dffa3d1
6 changed files with 38 additions and 13 deletions

View File

@@ -10,9 +10,9 @@ MRP 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%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/12.0/mrp_warehouse_calendar
:alt: OCA/manufacture

View File

@@ -1,11 +1,11 @@
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "MRP Warehouse Calendar",
"summary": "Considers the warehouse calendars in manufacturing",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"license": "LGPL-3",
"website": "https://github.com/stock-logistics-warehouse",
"author": "Eficent, "
"Odoo Community Association (OCA)",

View File

@@ -1,5 +1,5 @@
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, models

View File

@@ -1,5 +1,5 @@
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# Copyright 2018-19 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, models
@@ -12,12 +12,15 @@ class StockRule(models.Model):
product_id, values)
picking_type = self.picking_type_id or \
values['warehouse_id'].manu_type_id
dt_planned = fields.Datetime.to_datetime(values['date_planned'])
# We force the date planned to be at the beginning of the day.
# So no work intervals are found in planned date.
dt_planned = fields.Datetime.to_datetime(
values['date_planned']).replace(hour=0)
warehouse = picking_type.warehouse_id
if warehouse.calendar_id and product_id.produce_delay:
lead_days = values['company_id'].manufacturing_lead + \
product_id.produce_delay
date_expected = warehouse.calendar_id.plan_days(
-1 * lead_days - 1, dt_planned)
-1 * lead_days, dt_planned)
date_planned = date_expected
return date_planned

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>MRP Warehouse Calendar</title>
<style type="text/css">
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/manufacture/tree/12.0/mrp_warehouse_calendar"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_warehouse_calendar"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/manufacture/tree/12.0/mrp_warehouse_calendar"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_warehouse_calendar"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>With this module the manufacturing orders created from procurements consider
the calendar assigned to the warehouse of the picking type of the
manufacturing order to determine, based on the products manufacturing

View File

@@ -1,5 +1,5 @@
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields
from odoo.tests.common import TransactionCase
@@ -70,6 +70,28 @@ class TestMrpWarehouseCalendar(TransactionCase):
self.assertEqual(date_plan_start, friday)
def test_procurement_with_calendar_02(self):
"""Test procuring at the beginning of the day, with no work intervals
before."""
values = {
'date_planned': '2097-01-07 01:00:00', # Monday
'warehouse_id': self.warehouse,
'company_id': self.company,
'rule_id': self.manufacture_route,
}
self.env['procurement.group'].run(
self.product, 100,
self.product.uom_id,
self.warehouse.lot_stock_id, 'Test 2',
'Test 2', values)
mo = self.env['mrp.production'].search(
[('product_id', '=', self.product.id)], limit=1)
date_plan_start = fields.Date.to_date(mo.date_planned_start)
# Friday 4th Jan 2097
friday = fields.Date.to_date('2097-01-04 09:00:00')
self.assertEqual(date_plan_start, friday)
def test_onchange_date_planned(self):
mo = self.env['mrp.production'].new({
'product_id': self.product.id,