cucumber-openerpscenario 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,53 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- ###############################################################################
3
- # #
4
- # Helper for OERPScenario and InspectOOOR, OpenERP Functional Tests #
5
- # Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com> #
6
- # #
7
- # This program is free software: you can redistribute it and/or modify #
8
- # it under the terms of the GNU Affero General Public License as #
9
- # published by the Free Software Foundation, either version 3 of the #
10
- # License, or (at your option) any later version. #
11
- # #
12
- # This program is distributed in the hope that it will be useful, #
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15
- # GNU Affero General Public License for more details. #
16
- # #
17
- # You should have received a copy of the GNU Affero General Public License #
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19
- # #
20
- ###############################################################################
21
-
22
-
23
- begin
24
- if Object.const_defined? 'PurchaseOrder'
25
- PurchaseOrder.class_eval do
26
- $utils.log.debug("Extending #{self.class} #{self.name}")
27
-
28
- def confirm
29
- wkf_action('purchase_confirm')
30
- end
31
-
32
- def self.to_ary
33
- return [name]
34
- end
35
-
36
- def self.get_last_purchase_order_with_product(product_id)
37
- line = PurchaseOrderLine.find(:first, :domain => [['product_id', '=', product_id]])
38
-
39
- if line
40
- return line.order_id
41
- end
42
- return false
43
-
44
- end
45
- end
46
- else
47
- $utils.log.debug("PurchaseOrder helper not initialized")
48
- end
49
- rescue Exception => e
50
- $utils.log.fatal("ERROR : #{e.to_s}")
51
- end
52
-
53
-
@@ -1,49 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #################################################################################
3
- # #
4
- # OERPScenario, OpenERP Functional Tests #
5
- # Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com> #
6
- # #
7
- # This program is free software: you can redistribute it and/or modify #
8
- # it under the terms of the GNU General Public License as published by #
9
- # the Free Software Foundation, either version 3 Afero of the License, or #
10
- # (at your option) any later version. #
11
- # #
12
- # This program is distributed in the hope that it will be useful, #
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15
- # GNU General Public License for more details. #
16
- # #
17
- # You should have received a copy of the GNU General Public License #
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19
- # #
20
- #################################################################################
21
- require 'pp'
22
- require 'rubygems'
23
- require 'ooor'
24
-
25
- begin
26
- if Object.const_defined? 'ResCurrency'
27
- ResCurrency.class_eval do
28
- $utils.log.debug("Extending #{self.class} #{self.name}")
29
-
30
- def self.get_valid_currency(options={})
31
- if options != nil && options[:currency_name]
32
- currency = ResCurrency.find(:first, :domain => [['name', '=', options[:currency_name]]], :fields => ['id'])
33
- else
34
- user_id = $utils.ooor.config[:user_id]
35
- user = ResUsers.find(:id => user_id)
36
- currency = ResCurrency.find(user.company_id.currency_id.id, :fields => ['id'])
37
- end
38
- currency
39
- end
40
- end
41
- else
42
- $utils.log.debug("ResCurrency helper not initialized")
43
- end
44
- rescue Exception => e
45
- $utils.log.fatal("ERROR : #{e.to_s}")
46
- end
47
-
48
-
49
-
@@ -1,89 +0,0 @@
1
- ###############################################################################
2
- #
3
- # OERPScenario, OpenERP Functional Tests
4
- # Author Nicolas Bessi & Joel Grand-Guillaume 2009
5
- # Copyright Camptocamp SA
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 Afero of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- #
20
- ##############################################################################
21
- require 'pp'
22
- require 'rubygems'
23
- require 'ooor'
24
-
25
- begin
26
- # Add useful methode on partner handling
27
- ##############################################################################
28
- ResPartner.class_eval do
29
- $utils.log.debug("Extending #{self.class} #{self.name}")
30
- ##########################################################################
31
- # Return the first encountred supplier with at least one address
32
- # Input :
33
- # -
34
- # Return
35
- # - The found ResPartner as a instance of the class¨
36
- # Usage Example:
37
- # part = ResPartner.get_supplier({:name => 'toto', :type=>'supplier'})
38
- def self.get_valid_partner(options={})
39
- unless options
40
- options={}
41
- end
42
- domain = options[:domain] || []
43
- field = []
44
- if options.is_a? Integer
45
- partner = ResPartner.find(options)
46
- $utils.set_var('current_partner', partner)
47
- return partner
48
- end
49
- if not options[:new]
50
- domain = options[:domain] || []
51
- domain << ['address', '!=', false]
52
- field = []
53
- options.each do |key, value|
54
- if key == :name
55
- domain.push ['name', 'ilike', value]
56
- elsif key == :type
57
- domain.push [value, '=', true]
58
- elsif key == :fields
59
- field = value
60
- elsif key != :domain && key != :same
61
- domain.push [key.to_s, '=', value]
62
- end
63
- end
64
- partner = ResPartner.find(:first, :domain => domain, :fields => field)
65
- if partner
66
- $utils.set_var('current_partner', partner)
67
- return partner
68
- end
69
- end
70
- createoptions = {:name => options[:name] || 'partnerscenario', :user_id => $utils.ooor.config[:user_id]}
71
- options.each do |key, value|
72
- if key == :type
73
- createoptions[value] = true
74
- elsif key != :domain && key!= :fields
75
- createoptions[key] = value
76
- end
77
- end
78
- address = ResPartnerAddress.new(:name => createoptions[:name] || 'partnerscenario', :email => createoptions[:email])
79
- address.save
80
- createoptions[:address] = [[6, 0, [address.id]]]
81
- partner = ResPartner.new(createoptions)
82
- partner.save
83
- $utils.set_var('current_partner', partner)
84
- return partner
85
- end
86
- end
87
- rescue Exception => e
88
- $utils.log.fatal("ERROR : #{e.to_s}")
89
- end
@@ -1,121 +0,0 @@
1
- ###############################################################################
2
- #
3
- # OERPScenario, OpenERP Functional Tests
4
- # Author Nicolas Bessi & Joel Grand-Guillaume 2009
5
- # Copyright Camptocamp SA
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 Afero of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- #
20
- ##############################################################################
21
- require 'pp'
22
- require 'rubygems'
23
- require 'ooor'
24
-
25
- begin
26
- # Add useful methode on partner handling
27
- ##############################################################################
28
- if Object.const_defined? 'ResUsers'
29
- ResUsers.class_eval do
30
- $utils.log.debug("Extending #{self.class} #{self.name}")
31
-
32
- def self.add_role(user_login, group_array)
33
- if group_array != :all
34
- if group_array.empty?
35
- announce("no group given")
36
- return
37
- end
38
- end
39
-
40
- user = ResUsers.find(:first, :domain => [['login', '=', user_login]])
41
- unless user
42
- raise 'no user found'
43
- end
44
- roles = user.roles_id
45
- if roles
46
- roles.map! { |x| x=x.id }
47
- else
48
- roles = []
49
- end
50
- if group_array == :all
51
- ResRoles.find(:all, :fields => ['id']).each do |g|
52
- roles.push g.id
53
- end
54
- else
55
- group_array.each do |role|
56
- g = ResRoles.find(:first, :domain => [['name', '=', role]], :fields => ['id'])
57
- if g
58
- roles.push g.id
59
- end
60
- end
61
- end
62
- user.roles_id = roles
63
- user.save
64
-
65
- end
66
-
67
- def self.add_group(user_login, group_array, ignor_non_exsiting=false)
68
- if group_array.empty?
69
- announce("no group given")
70
- else
71
- user = ResUsers.find(:first, :domain => [['login', '=', user_login]])
72
- unless user
73
- if ignor_non_exsiting
74
- announce("no user found for #{user_login}")
75
- return
76
- else
77
- raise "no user found for #{user_login}"
78
- end
79
- end
80
- groups = user.groups_id
81
- if groups
82
- groups.map! { |x| x=x.id }
83
- else
84
- groups = []
85
- end
86
- group_array.each do |group|
87
- g = ResGroups.find(:first, :domain => [['name', '=', group]])
88
- if g
89
- groups.push g.id
90
- end
91
- end
92
- user.groups_id = groups
93
- user.save
94
- end
95
- end
96
-
97
-
98
- def self.add_access(acessname, group, o_model, perm = {})
99
- if IrModelAccess.find(:first, :domain => [['name', '=', acessname]], :fields => ['id'])
100
- $log.error "Access #{acessname} allready exist".red
101
- else
102
- permissions = {:read => false, :write => false, :create => false, :unlink => false}.merge(perm)
103
- model_id = IrModel.find(:first, :domain => [['model', '=', o_model]], :fields => ['id']).id
104
- group_id = ResGroups.find(:first, :domain => [['name', '=', group]], :fields => ['id']).id
105
- access = IrModelAccess.new
106
- access.name = acessname
107
- access.model_id = model_id
108
- access.group_id = group_id
109
- permissions.each do |key, val|
110
- eval("access.perm_#{key.to_s} = #{val}")
111
- end
112
- access.create()
113
- end
114
- end
115
- end
116
- else
117
- $utils.log.debug("ResUsers helper not initialized")
118
- end
119
- rescue Exception => e
120
- $utils.log.fatal("ERROR : #{e.to_s}")
121
- end
@@ -1,76 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #################################################################################
3
- # #
4
- # OERPScenario, OpenERP Functional Tests #
5
- # Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com> #
6
- # #
7
- # This program is free software: you can redistribute it and/or modify #
8
- # it under the terms of the GNU General Public License as published by #
9
- # the Free Software Foundation, either version 3 Afero of the License, or #
10
- # (at your option) any later version. #
11
- # #
12
- # This program is distributed in the hope that it will be useful, #
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15
- # GNU General Public License for more details. #
16
- # #
17
- # You should have received a copy of the GNU General Public License #
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19
- # #
20
- #################################################################################
21
- require 'pp'
22
- require 'rubygems'
23
- require 'ooor'
24
-
25
- begin
26
- if Object.const_defined? 'SaleOrder'
27
- SaleOrder.class_eval do
28
- $utils.log.debug("Extending #{self.class} #{self.name}")
29
- # Add useful methode on sale order handling
30
-
31
- def self.to_ary
32
- return [name]
33
- end
34
-
35
- def confirm
36
- wkf_action('order_confirm')
37
- end
38
-
39
- def self.create_sale_order(options={}, function_line='get_sale_order_line')
40
- # Take a partner with appropriate attributes and at least one address
41
- createoptions = {}
42
- options.each do |key, value|
43
- if not [:partner, :currency, :creation_date, :order_lines].include?(key)
44
- if key == :date
45
- createoptions[:date_order] = Date.parse(str=value).to_s
46
- elsif createoptions[key] = value
47
- end
48
- end
49
- end
50
- @partner=ResPartner.get_valid_partner(options[:partner])
51
- if options[:currency].is_a? Integer
52
- currency_id = options[:currency]
53
- else
54
- currency_id = ResCurrency.get_valid_currency(options[:currency]).id
55
- end
56
- # Create a so with partner
57
- so = SaleOrder.new(createoptions)
58
- so.on_change('onchange_partner_id', :partner_id, @partner.id, @partner.id)
59
- so.pricelist_id=ProductPricelist.find(:first, :domain => [['currency_id', '=', currency_id]], :fields => ['id']).id
60
- so.order_line = SaleOrderLine.send(function_line, options[:order_lines], so)
61
- so.create
62
- if options[:creation_date]
63
- so.create_date = Date.parse(str=options[:creation_date]).to_s
64
- end
65
- so.save
66
- so.write(createoptions)
67
- @saleorder=so
68
- return @saleorder
69
- end
70
- end
71
- else
72
- $utils.log.debug("SaleOrder helper not initialized")
73
- end
74
- rescue Exception => e
75
- $utils.log.fatal("ERROR : #{e.to_s}")
76
- end
@@ -1,72 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #################################################################################
3
- # #
4
- # OERPScenario, OpenERP Functional Tests #
5
- # Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com> #
6
- # #
7
- # This program is free software: you can redistribute it and/or modify #
8
- # it under the terms of the GNU General Public License as published by #
9
- # the Free Software Foundation, either version 3 Afero of the License, or #
10
- # (at your option) any later version. #
11
- # #
12
- # This program is distributed in the hope that it will be useful, #
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15
- # GNU General Public License for more details. #
16
- # #
17
- # You should have received a copy of the GNU General Public License #
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19
- # #
20
- #################################################################################
21
- require 'pp'
22
- require 'rubygems'
23
- require 'ooor'
24
-
25
- begin
26
- if Object.const_defined? 'SaleOrderLine'
27
- SaleOrderLine.class_eval do
28
- $utils.log.debug("Extending #{self.class} #{self.name}")
29
-
30
- def self.get_sale_order_line(options, so)
31
- unless options
32
- options = [{:price_unit => 50}]
33
- end
34
- sale_order_lines = []
35
- options.each do |sale_order_line|
36
- @product=ProductProduct.get_valid_product(sale_order_line[:product])
37
- line = SaleOrderLine.new(:product_id => @product.id)
38
- line.on_change('product_id_change', :product_id, @product.id, so.pricelist_id, @product.id, qty=0,
39
- uom=false, qty_uos=0, uos=false, name='', partner_id=so.partner_id.id, lang=false, update_tax=true, date_order=so.date_order, packaging=false, fiscal_position=false, flag=false)
40
- line.price_unit = sale_order_line[:price_unit].to_f
41
- line.product_uom = 1
42
- sale_order_lines << line
43
- end
44
- return sale_order_lines
45
- end
46
-
47
-
48
- ################################ CUSTOM HELPER ####################################################
49
- #Custom helper for the module delivery_delays
50
- def self.delivery_delays_get_sale_order_line(options, so)
51
- sale_order_lines = []
52
- onchange_order_lines = []
53
- options.each do |sale_order_line|
54
- @product=ProductProduct.get_valid_product(sale_order_line[:product])
55
- line = SaleOrderLine.new(:product_id => @product.id)
56
- line.on_change('product_id_change', :product_id, @product.id, so.pricelist_id, @product.id, qty=sale_order_line[:product_uom_qty] || 1.0,
57
- uom=false, qty_uos=0, uos=false, name='', partner_id=so.partner_id.id, lang=false, update_tax=true, date_order=so.date_order, packaging=false, fiscal_position=false, flag=false, context=false, order_lines=onchange_order_lines)
58
- line.price_unit = sale_order_line[:price_unit].to_f
59
- line.product_uom = 1
60
- line.product_uom_qty = sale_order_line[:product_uom_qty] || 1.0
61
- onchange_order_lines <<[0, 0, {:product_id => @product.id, :name => @product.name, :product_uom_qty => sale_order_line[:product_uom_qty] || 1.0}]
62
- sale_order_lines << line
63
- end
64
- return sale_order_lines
65
- end
66
- end
67
- else
68
- $utils.log.debug("SaleOrderLine helper not initialized")
69
- end
70
- rescue Exception => e
71
- $utils.log.fatal("ERROR : #{e.to_s}")
72
- end