2
# -*- encoding: utf-8 -*-
3
###########################################################################
4
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
7
# Credits######################################################
8
# Coded by: Vauxoo C.A.
9
# Planified by: Nhomar Hernandez
10
# Audited by: Vauxoo C.A.
11
#############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as published by
14
# the Free Software Foundation, either version 3 of the License, or
15
# (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
##########################################################################
26
from openerp.osv import osv, fields
27
import openerp.tools as tools
28
from openerp.tools.translate import _
30
from tools import config
31
import openerp.netsvc as netsvc
32
import decimal_precision as dp
38
class default_price_to_report(osv.TransientModel):
40
_name = 'default.price.to.report'
43
'list_price': fields.many2one('product.pricelist', 'List Price'),
44
'sure': fields.boolean('Sure?', help="Are sure this operation"),
47
def default_price(self, cr, uid, ids, context=None):
51
method_obj = self.pool.get('method.price')
52
product_obj = self.pool.get('product.product')
53
wzr_brw = self.browse(cr, uid, ids, context=context)[0]
55
if context.get('active_ids'):
56
name = wzr_brw.list_price and wzr_brw.list_price.name or False
57
name = name.split(' ')
58
name = name and name[0] == 'Precio' and name[
59
1].isdigit() and name[1]
62
cost_id = [i.property_cost_structure and
63
i.property_cost_structure.id\
64
for i in product_obj.browse(
65
cr, uid, context.get('active_ids'), context=context)]
66
methods_ids = method_obj.search(cr, uid,
67
[('cost_structure_id', 'in', cost_id), (
68
'default_cost', '=', True)], context=context)
70
raise osv.except_osv(_('Error'), _(
71
'The product already has a default_cost'))
72
methods_ids = method_obj.search(cr, uid,
73
[('cost_structure_id', 'in', cost_id), (
74
'sequence', '=', int(name))], context=context)
75
method_obj.write(cr, uid, methods_ids, {
76
'default_cost': True}, context=context)
78
raise osv.except_osv(_('Error'), _('Please select sure option'))
79
return {'type': 'ir.actions.act_window_close'}