diff --git a/sale_jit_on_services/__init__.py b/sale_jit_on_services/__init__.py index 3fd059abf49..2ba7699b280 100644 --- a/sale_jit_on_services/__init__.py +++ b/sale_jit_on_services/__init__.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution -# Copyright (C) 2013 Camptocamp () -# Authors: Joel Grand-Guillaume +# Author: Yannick Vaucher +# Copyright 2013 Camptocamp SA # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -20,4 +19,4 @@ # ############################################################################## -from . import sale_stock +from . import procurement diff --git a/sale_jit_on_services/__openerp__.py b/sale_jit_on_services/__openerp__.py index c0bc57e60e4..8ba4a0c18f8 100644 --- a/sale_jit_on_services/__openerp__.py +++ b/sale_jit_on_services/__openerp__.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution -# Copyright (C) 2013 Camptocamp () -# Authors: Joel Grand-Guillaume +# Author: Joël Grand-Guillaume, Yannick Vaucher +# Copyright 2013 Camptocamp SA # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -43,12 +42,15 @@ ------------ * Joël Grand-Guillaume + * Yannick Vaucher """, 'author': 'Camptocamp', - 'depends': ['sale_stock'], + 'depends': ['procurement'], 'website': 'http://www.camptocamp.com', - 'data': [], + 'data': [ + 'procurement_workflow.xml' + ], 'test': [ 'test/sale_service_jit_test.yml', ], diff --git a/sale_jit_on_services/procurement.py b/sale_jit_on_services/procurement.py new file mode 100644 index 00000000000..cfe80251b9b --- /dev/null +++ b/sale_jit_on_services/procurement.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Yannick Vaucher +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import orm + +class ProcurementOrder(orm.Model): + """ + Procurement Orders + """ + _inherit = 'procurement.order' + + def is_service(self, cr, uid, ids): + """ condition on the transition to go from 'confirm' activity to + 'confirm_wait' activity """ + for procurement in self.browse(cr, uid, ids): + product = procurement.product_id + if product.type == 'service': + return True + return False diff --git a/sale_jit_on_services/procurement_workflow.xml b/sale_jit_on_services/procurement_workflow.xml new file mode 100644 index 00000000000..28abca0ade8 --- /dev/null +++ b/sale_jit_on_services/procurement_workflow.xml @@ -0,0 +1,14 @@ + + + + + + + + + check_conditions_confirm2wait() and is_service() + + + + diff --git a/sale_jit_on_services/sale_stock.py b/sale_jit_on_services/sale_stock.py deleted file mode 100644 index fa5df854fa7..00000000000 --- a/sale_jit_on_services/sale_stock.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2013 Camptocamp () -# Authors: Joel Grand-Guillaume -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.osv import orm -from openerp import netsvc -import logging -_logger = logging.getLogger(__name__) - -class sale_order(orm.Model): - _inherit = "sale.order" - - def _create_pickings_and_procurements(self, cr, uid, order, order_lines, - picking_id=False, context=None): - """Override the method to launch the procurement automatically for - all line with a service product. - - :param browse_record order: sales order to which the order lines belong - :param list(browse_record) order_lines: sales order line records to procure - :param int picking_id: optional ID of a stock picking to which - the created stock moves will be added. - A new picking will be created if omitted. - :return: True - - """ - res = super(sale_order, self)._create_pickings_and_procurements( - cr, - uid, - order, - order_lines, - picking_id=picking_id, - context=context - ) - wf_service = netsvc.LocalService("workflow") - order.refresh() - for line in order.order_line: - if line.product_id and line.product_id.type == 'service': - if line.procurement_id: - _logger.debug('Trigger button check on procurement`%s`, id %s', - line.procurement_id.name, line.id) - proc_id = line.procurement_id.id - wf_service.trg_validate(uid, - 'procurement.order', - proc_id, - 'button_check', - cr) - return res diff --git a/sale_jit_on_services/test/sale_service_jit_test.yml b/sale_jit_on_services/test/sale_service_jit_test.yml new file mode 100644 index 00000000000..bd11bd3a5e2 --- /dev/null +++ b/sale_jit_on_services/test/sale_service_jit_test.yml @@ -0,0 +1,24 @@ +- + In order to test mrp_jit module with OpenERP, I create procurement order for + Computer Case product and check whether it runs without scheduler or not. +- + !record {model: procurement.order, id: procurement_order_test1}: + company_id: base.main_company + date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S") + location_id: stock.stock_location_stock + name: PROC/TEST/0001 + product_id: product.product_product_1 + product_qty: 1.0 + product_uom: product.product_uom_unit + product_uos_qty: 0.0 +- + | + I confirm the procurement order PROC/TEST/0001. +- + !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_test1} +- + | + I check that the procurement is scheduled automatically. +- + !assert {model: procurement.order, id: procurement_order_test1, string: procstate}: + - state<>'confirmed'