Skip to content

Commit

Permalink
rewrite sale_jit_on_services using workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
yvaucher committed Apr 8, 2014
1 parent bd8f33c commit a725985
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 74 deletions.
7 changes: 3 additions & 4 deletions sale_jit_on_services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2013 Camptocamp (<http://www.camptocamp.com>)
# 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
Expand All @@ -20,4 +19,4 @@
#
##############################################################################

from . import sale_stock
from . import procurement
12 changes: 7 additions & 5 deletions sale_jit_on_services/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2013 Camptocamp (<http://www.camptocamp.com>)
# 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
Expand Down Expand Up @@ -43,12 +42,15 @@
------------
* Joël Grand-Guillaume <[email protected]>
* Yannick Vaucher <[email protected]>
""",
'author': 'Camptocamp',
'depends': ['sale_stock'],
'depends': ['procurement'],
'website': 'http://www.camptocamp.com',
'data': [],
'data': [
'procurement_workflow.xml'
],
'test': [
'test/sale_service_jit_test.yml',
],
Expand Down
36 changes: 36 additions & 0 deletions sale_jit_on_services/procurement.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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
14 changes: 14 additions & 0 deletions sale_jit_on_services/procurement_workflow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<openerp>
<data>

<record model="workflow.transition" id="trans_direct_confirm_to_wait_services">
<!-- Duplicates the transition between the act_confirm and act_confirm_wait activites
but, this time, without the signal and only for services -->
<field name="act_from" ref="procurement.act_confirm"/>
<field name="act_to" ref="procurement.act_confirm_wait"/>
<field name="condition">check_conditions_confirm2wait() and is_service()</field>
</record>

</data>
</openerp>
65 changes: 0 additions & 65 deletions sale_jit_on_services/sale_stock.py

This file was deleted.

24 changes: 24 additions & 0 deletions sale_jit_on_services/test/sale_service_jit_test.yml
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit a725985

Please sign in to comment.