diff --git a/purchase_date_planned_manual/README.rst b/purchase_date_planned_manual/README.rst index 87d95a3f102..bd8a890a5cb 100644 --- a/purchase_date_planned_manual/README.rst +++ b/purchase_date_planned_manual/README.rst @@ -1,19 +1,39 @@ -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - ============================ Purchase Date Planned Manual ============================ +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: Mature +.. |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 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/11.0/purchase_date_planned_manual + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/142/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| + This module makes the system to always respect the planned (or scheduled) -date set by the user when creating a Purchase order or the day set in the -procurement order if the line is created from there. +date set by the user when creating a Purchase Order. Additionally, this module modifies the PO views and sets in red the lines that are predicted to arrive late compared to the scheduled date and vendor lead time. +**Table of contents** + +.. contents:: + :local: + Usage ===== @@ -32,42 +52,49 @@ Or: #. Now the scheduled date in the procurement is respected even if the line is added to a previously existing PO. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/142/10.0 - 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 smash it by providing detailed and welcomed feedback. +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. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Eficent Contributors ------------- +~~~~~~~~~~~~ * Lois Rilo -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +.. |maintainer-lreficent| image:: https://github.com/lreficent.png?size=40px + :target: https://github.com/lreficent + :alt: lreficent + +Current `maintainer `_: + +|maintainer-lreficent| + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_date_planned_manual/__init__.py b/purchase_date_planned_manual/__init__.py index e50f9b65687..0650744f6bc 100644 --- a/purchase_date_planned_manual/__init__.py +++ b/purchase_date_planned_manual/__init__.py @@ -1,6 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - from . import models diff --git a/purchase_date_planned_manual/__manifest__.py b/purchase_date_planned_manual/__manifest__.py index 6223117b38a..0bead54e2c1 100644 --- a/purchase_date_planned_manual/__manifest__.py +++ b/purchase_date_planned_manual/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -7,11 +6,13 @@ "name": "Purchase Date Planned Manual", "summary": "This module makes the system to always respect the planned " "(or scheduled) date in PO lines.", - "version": "10.0.1.0.0", + "version": "11.0.1.0.0", + "development_status": "Mature", "author": "Eficent, " "Odoo Community Association (OCA)", + "maintainers": ["lreficent"], "website": "https://github.com/OCA/purchase-workflow", - "category": "Purchases", + "category": "Purchase Management", "depends": ["purchase"], "data": [ 'views/purchase_order_view.xml', diff --git a/purchase_date_planned_manual/models/__init__.py b/purchase_date_planned_manual/models/__init__.py index 27cc4d8962e..9f03530643d 100644 --- a/purchase_date_planned_manual/models/__init__.py +++ b/purchase_date_planned_manual/models/__init__.py @@ -1,7 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - from . import purchase_order -from . import procurement_order diff --git a/purchase_date_planned_manual/models/procurement_order.py b/purchase_date_planned_manual/models/procurement_order.py deleted file mode 100644 index 43cb0f9f018..00000000000 --- a/purchase_date_planned_manual/models/procurement_order.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -from odoo import api, models - - -class ProcurementOrder(models.Model): - _inherit = 'procurement.order' - - @api.multi - def _prepare_purchase_order_line(self, po, supplier): - """When creating PO lines mantain as scheduled date the one specified - in the procurement.""" - res = super(ProcurementOrder, self)._prepare_purchase_order_line( - po, supplier) - res['date_planned'] = self.date_planned - return res diff --git a/purchase_date_planned_manual/models/purchase_order.py b/purchase_date_planned_manual/models/purchase_order.py index c4539f124de..9bf4a8644f6 100644 --- a/purchase_date_planned_manual/models/purchase_order.py +++ b/purchase_date_planned_manual/models/purchase_order.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -6,6 +5,7 @@ from dateutil.relativedelta import relativedelta from odoo import api, fields, models, _ from odoo.exceptions import UserError +from odoo.fields import Datetime as Dt class PurchaseOrderLine(models.Model): @@ -48,5 +48,7 @@ def _get_date_planned(self, seller, po=False): @api.multi def action_delayed_line(self): - raise UserError(_('This line is scheduled for: %s. \n However it is ' - 'now planned to arrive late.') % self.date_planned) + raise UserError(_( + 'This line is scheduled for: %s. \n However it is now planned to ' + 'arrive late.') % Dt.to_string(Dt.context_timestamp( + self, Dt.from_string(self.date_planned)))) diff --git a/purchase_date_planned_manual/readme/CONTRIBUTORS.rst b/purchase_date_planned_manual/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..4b574636c05 --- /dev/null +++ b/purchase_date_planned_manual/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Lois Rilo diff --git a/purchase_date_planned_manual/readme/DESCRIPTION.rst b/purchase_date_planned_manual/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..012bf6b5bb7 --- /dev/null +++ b/purchase_date_planned_manual/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module makes the system to always respect the planned (or scheduled) +date set by the user when creating a Purchase Order. + +Additionally, this module modifies the PO views and sets in red the lines +that are predicted to arrive late compared to the scheduled date and vendor +lead time. diff --git a/purchase_date_planned_manual/readme/USAGE.rst b/purchase_date_planned_manual/readme/USAGE.rst new file mode 100644 index 00000000000..ee8afa00333 --- /dev/null +++ b/purchase_date_planned_manual/readme/USAGE.rst @@ -0,0 +1,14 @@ +To use this module you could follow any of the two options below: + +#. Go to 'Purchase' and create a purchase order. +#. Manually set the scheduled date in the PO lines. +#. This date will never be modified by the system and the lines that are + expected to be late are highlighted in red. + +Or: + +#. Create a procurement order for a product that can be bought and have the + route 'buy' activated. +#. Run the procurement. +#. Now the scheduled date in the procurement is respected even if the line is + added to a previously existing PO. diff --git a/purchase_date_planned_manual/tests/__init__.py b/purchase_date_planned_manual/tests/__init__.py index e4322c9b604..e76a6a413fc 100644 --- a/purchase_date_planned_manual/tests/__init__.py +++ b/purchase_date_planned_manual/tests/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import test_date_planned_manual diff --git a/purchase_date_planned_manual/tests/test_date_planned_manual.py b/purchase_date_planned_manual/tests/test_date_planned_manual.py index e1adee015c2..a98642ee313 100644 --- a/purchase_date_planned_manual/tests/test_date_planned_manual.py +++ b/purchase_date_planned_manual/tests/test_date_planned_manual.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Eficent Business and IT Consulting Services S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -13,7 +12,7 @@ def setUp(self, *args, **kwargs): super(TestDatePlannedManual, self).setUp(*args, **kwargs) self.po_model = self.env['purchase.order'] self.pol_model = self.env['purchase.order.line'] - self.proc_model = self.env['procurement.order'] + self.pp_model = self.env['product.product'] # Create some partner, products and supplier info: route_buy_id = self.env.ref('purchase.route_warehouse0_buy').id self.partner = self.env['res.partner'].create({ @@ -24,28 +23,22 @@ def setUp(self, *args, **kwargs): 'name': self.partner.id, 'delay': 2, }).id - self.product_1 = self.env['product.product'].create({ + self.product_1 = self.pp_model.create({ 'name': 'Test product 1', 'type': 'product', 'route_ids': [(4, route_buy_id)], 'seller_ids': [(4, supplier_info_id)], }) - self.product_2 = self.env['product.product'].create({ + self.product_2 = self.pp_model.create({ 'name': 'Test product 2', 'type': 'product', }) # Create purchase order and dates - self.purchase_order = self.env['purchase.order'].create({ + self.purchase_order = self.po_model.create({ 'partner_id': self.partner.id, }) next_week_time = datetime.now() + timedelta(days=7) self.next_week_time = fields.Datetime.to_string(next_week_time) - # Create a warehouse - self.test_warehouse = self.env['stock.warehouse'].create({ - 'name': 'Test Warehouse', - 'code': 'T-WH', - }) - self.test_location = self.test_warehouse.lot_stock_id def test_manually_set_pol_date(self): """Tests the manual modification of scheduled date in purchase order @@ -82,23 +75,3 @@ def test_manually_set_pol_date(self): "state 'draft'.") with self.assertRaises(UserError): po_line_1.action_delayed_line() - - def test_po_created_from_procurements(self): - """Tests the purchase order lines created from procurement orders.""" - proc = self.proc_model.create({ - 'name': 'test', - 'product_id': self.product_1.id, - 'product_qty': 5.0, - 'product_uom': self.product_1.uom_id.id, - 'warehouse_id': self.test_warehouse.id, - 'location_id': self.test_location.id, - 'date_planned': self.next_week_time, - }) - self.assertEqual(proc.state, 'running', - "Procurement has not run correctly.") - self.assertTrue(proc.purchase_id, - "No purchase order created from procurement.") - pol_date = proc.purchase_id.order_line.date_planned - self.assertEqual(pol_date, self.next_week_time, - "Dates in procurement a purchase order line does not " - "match.") diff --git a/purchase_date_planned_manual/views/purchase_order_view.xml b/purchase_date_planned_manual/views/purchase_order_view.xml index 3ca699a4e81..405488641a5 100644 --- a/purchase_date_planned_manual/views/purchase_order_view.xml +++ b/purchase_date_planned_manual/views/purchase_order_view.xml @@ -4,8 +4,7 @@ - purchase.order.form - purchase_date_planned_manual - extension + purchase.order.form - purchase_date_planned_manual purchase.order @@ -18,8 +17,7 @@ icon="fa-exclamation-triangle"/> - predicted_arrival_late - is True + predicted_arrival_late is True