diff --git a/stock_orderpoint_manual_procurement/README.rst b/stock_orderpoint_manual_procurement/README.rst index c796d1930..00a8809c4 100644 --- a/stock_orderpoint_manual_procurement/README.rst +++ b/stock_orderpoint_manual_procurement/README.rst @@ -9,6 +9,13 @@ Stock Orderpoint Manual Procurement This module allows users to manually start procurements from the list of reordering rules, based on the quantity that is recommended to be procured. +Configuration +============= + +If you want users to be able to change the recommended quantity to procure, +you should assign them to the security group 'Change quantity in manual +procurements from reordering rules', under 'Settings / Users / Users'. + Usage ===== @@ -19,13 +26,9 @@ single or a list of reordering rules. The recommended quantity to procure is adjusted to the procurement unit of measure indicated in the reordering rule. -If you want users to be able to change the recommended quantity to procure, -you should assign them to the security group 'Change quantity in manual -procurements from reordering rules', under 'Settings / Users / Users'. - .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/153/8.0 + :target: https://runbot.odoo-community.org/runbot/153/10.0 Bug Tracker =========== diff --git a/stock_orderpoint_manual_procurement/__init__.py b/stock_orderpoint_manual_procurement/__init__.py index 851fa8da7..fbe944470 100644 --- a/stock_orderpoint_manual_procurement/__init__.py +++ b/stock_orderpoint_manual_procurement/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2016 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/stock_orderpoint_manual_procurement/__manifest__.py b/stock_orderpoint_manual_procurement/__manifest__.py new file mode 100644 index 000000000..53fae582b --- /dev/null +++ b/stock_orderpoint_manual_procurement/__manifest__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2016-17 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). +{ + "name": "Stock Orderpoint Manual Procurement", + "summary": "Allows to create procurement orders from orderpoints instead " + "of relying only on the scheduler.", + "version": "10.0.1.0.0", + "author": "Eficent, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse Management", + "depends": [ + "stock", + "stock_orderpoint_uom", + ], + "data": [ + "security/stock_orderpoint_manual_procurement_security.xml", + "wizards/make_procurement_orderpoint_view.xml", + "views/procurement_order_view.xml", + "views/stock_warehouse_orderpoint_view.xml", + ], + "license": "AGPL-3", + 'installable': True, + 'application': False, +} diff --git a/stock_orderpoint_manual_procurement/__openerp__.py b/stock_orderpoint_manual_procurement/__openerp__.py deleted file mode 100644 index 97582d2a2..000000000 --- a/stock_orderpoint_manual_procurement/__openerp__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2016 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). -{ - "name": "Stock Orderpoint manual procurement", - "summary": "Allows to create procurement orders from orderpoints instead " - "of relying only on the scheduler", - "version": "9.0.1.0.0", - "author": "Eficent Business and IT Consulting Services S.L," - "Odoo Community Association (OCA)", - "website": "https://www.odoo-community.org", - "category": "Warehouse Management", - "depends": ["stock", - "stock_orderpoint_uom"], - "data": ["security/stock_orderpoint_manual_procurement_security.xml", - "wizards/make_procurement_orderpoint_view.xml", - "views/procurement_order_view.xml", - "views/stock_warehouse_orderpoint_view.xml" - ], - "license": "AGPL-3", - 'installable': True, - 'application': False, -} diff --git a/stock_orderpoint_manual_procurement/models/__init__.py b/stock_orderpoint_manual_procurement/models/__init__.py index 85302d460..6654fecb0 100644 --- a/stock_orderpoint_manual_procurement/models/__init__.py +++ b/stock_orderpoint_manual_procurement/models/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2016 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 stock_warehouse_orderpoint diff --git a/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py b/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py index 953f45681..12c1d6368 100644 --- a/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py +++ b/stock_orderpoint_manual_procurement/models/stock_warehouse_orderpoint.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Eficent Business and IT Consulting Services S.L. +# Copyright 2016-17 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 openerp import api, fields, models +from odoo import api, fields, models from datetime import datetime -from openerp.addons import decimal_precision as dp -from openerp.tools import float_compare, float_round +from odoo.addons import decimal_precision as dp +from odoo.tools import float_compare, float_round UNIT = dp.get_precision('Product Unit of Measure') @@ -15,28 +15,35 @@ UNIT = dp.get_precision('Product Unit of Measure') class StockWarehouseOrderpoint(models.Model): _inherit = 'stock.warehouse.orderpoint' + procure_recommended_qty = fields.Float( + string='Procure Recommendation', + compute="_compute_procure_recommended", + digits=UNIT, + ) + procure_recommended_date = fields.Date( + string='Recommended Request Date', + compute="_compute_procure_recommended", + ) + @api.multi @api.depends("product_min_qty", "product_id", "qty_multiple") def _compute_procure_recommended(self): - procurement_model = self.env['procurement.order'] - op_qtys = self.subtract_procurements_from_orderpoints(self.ids) + op_qtys = self.subtract_procurements_from_orderpoints() for op in self: - op.procure_recommended_date = \ - procurement_model._get_orderpoint_date_planned( - op, datetime.today()) + op.procure_recommended_date = op._get_date_planned( + datetime.today()) procure_recommended_qty = 0.0 - prods = op.with_context( + virtual_qty = op.with_context( location=op.location_id.id).product_id.virtual_available - if prods is None: - continue - if float_compare(prods, op.product_min_qty, + if float_compare(virtual_qty, op.product_min_qty, precision_rounding=op.product_uom.rounding) < 0: - qty = max(op.product_min_qty, op.product_max_qty) - prods - reste = op.qty_multiple > 0 and qty % op.qty_multiple or 0.0 + qty = max(op.product_min_qty, op.product_max_qty) - virtual_qty + remainder = \ + op.qty_multiple > 0 and qty % op.qty_multiple or 0.0 if float_compare( - reste, 0.0, + remainder, 0.0, precision_rounding=op.product_uom.rounding) > 0: - qty += op.qty_multiple - reste + qty += op.qty_multiple - remainder if float_compare( qty, 0.0, @@ -56,11 +63,3 @@ class StockWarehouseOrderpoint(models.Model): product_qty = procure_recommended_qty op.procure_recommended_qty = product_qty - - procure_recommended_qty = fields.Float( - string='Procure recommendation', - compute="_compute_procure_recommended", - digits=UNIT) - procure_recommended_date = fields.Date( - string='Request Date', - compute="_compute_procure_recommended") diff --git a/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml b/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml index d12272d92..0e43bcafe 100644 --- a/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml +++ b/stock_orderpoint_manual_procurement/security/stock_orderpoint_manual_procurement_security.xml @@ -1,12 +1,10 @@ - - + Change quantity in manual procurements from reordering rules - + - - + diff --git a/stock_orderpoint_manual_procurement/tests/__init__.py b/stock_orderpoint_manual_procurement/tests/__init__.py index 7934ca650..87fd3dfb9 100644 --- a/stock_orderpoint_manual_procurement/tests/__init__.py +++ b/stock_orderpoint_manual_procurement/tests/__init__.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# Copyright 2016 Serpent Consulting Services Pvt. Ltd. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import test_stock_orderpoint_manual_procurement diff --git a/stock_orderpoint_manual_procurement/tests/test_stock_orderpoint_manual_procurement.py b/stock_orderpoint_manual_procurement/tests/test_stock_orderpoint_manual_procurement.py index 3aa2f948d..90973a5ec 100644 --- a/stock_orderpoint_manual_procurement/tests/test_stock_orderpoint_manual_procurement.py +++ b/stock_orderpoint_manual_procurement/tests/test_stock_orderpoint_manual_procurement.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Eficent Business and IT Consulting Services S.L. +# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # Copyright 2016 Serpent Consulting Services Pvt. Ltd. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp.tests import common +from odoo.tests import common class TestStockWarehouseOrderpoint(common.TransactionCase): diff --git a/stock_orderpoint_manual_procurement/views/procurement_order_view.xml b/stock_orderpoint_manual_procurement/views/procurement_order_view.xml index ccae0d9cc..07ea9284d 100644 --- a/stock_orderpoint_manual_procurement/views/procurement_order_view.xml +++ b/stock_orderpoint_manual_procurement/views/procurement_order_view.xml @@ -1,4 +1,4 @@ - + diff --git a/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml b/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml index 27cafe54b..64f5d0591 100644 --- a/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml +++ b/stock_orderpoint_manual_procurement/views/stock_warehouse_orderpoint_view.xml @@ -1,5 +1,5 @@ - - + + stock.warehouse.orderpoint.tree @@ -13,15 +13,15 @@ + icon="fa fa-cogs" type="action"/> - + diff --git a/stock_orderpoint_manual_procurement/wizards/__init__.py b/stock_orderpoint_manual_procurement/wizards/__init__.py index 02d20c7bc..aa5d94a56 100644 --- a/stock_orderpoint_manual_procurement/wizards/__init__.py +++ b/stock_orderpoint_manual_procurement/wizards/__init__.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2016 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 make_procurement_orderpoint diff --git a/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py b/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py index 8675cf54b..d9a910fc3 100644 --- a/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py +++ b/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Eficent Business and IT Consulting Services S.L. +# Copyright 2016-17 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 openerp import api, fields, models +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError class MakeProcurementOrderpoint(models.TransientModel): @@ -58,12 +59,11 @@ class MakeProcurementOrderpoint(models.TransientModel): for item in self.item_ids: data = item._prepare_procurement() procurement = self.env['procurement.order'].create(data) - procurement.signal_workflow('button_confirm') - procurement.run() res.append(procurement.id) return { - 'domain': "[('id','in', ["+','.join(map(str, res))+"])]", + 'name': _('Created Procurements'), + 'domain': [('id', 'in', res)], 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'procurement.order', @@ -100,6 +100,8 @@ class MakeProcurementOrderpointItem(models.TransientModel): @api.multi def _prepare_procurement(self): + if not self.qty: + raise ValidationError(_("Quantity must be positive.")) return { 'name': self.orderpoint_id.name, 'date_planned': self.date_planned, diff --git a/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint_view.xml b/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint_view.xml index 50152e8ed..fceee2bec 100644 --- a/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint_view.xml +++ b/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint_view.xml @@ -1,63 +1,61 @@ - - + - + - - Request Procurement - make.procurement.orderpoint - - - - Use this assistant to generate a procurement request for this - stock buffer. According to the product configuration, - this may trigger a draft purchase order, a manufacturing - order or a transfer picking. - - - - - - - - - - - - - - - - - - + + Request Procurement + make.procurement.orderpoint + + + + Use this assistant to generate a procurement request for this + stock buffer. According to the product configuration, + this may trigger a draft purchase order, a manufacturing + order or a transfer picking. + + + + + + + + + + + + + + + + + + - - Request Procurement - make.procurement.orderpoint - stock.warehouse.orderpoint - form - new - + + Request Procurement + make.procurement.orderpoint + stock.warehouse.orderpoint + form + new + - - - Request Procurement - client_action_multi - - action - stock.warehouse.orderpoint - + + + Request Procurement + client_action_multi + + action + stock.warehouse.orderpoint + - - +
- Use this assistant to generate a procurement request for this - stock buffer. According to the product configuration, - this may trigger a draft purchase order, a manufacturing - order or a transfer picking. -
+ Use this assistant to generate a procurement request for this + stock buffer. According to the product configuration, + this may trigger a draft purchase order, a manufacturing + order or a transfer picking. +