2010-03-09 12:00:43 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
##############################################################################
|
|
|
|
|
#
|
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
|
#
|
|
|
|
|
# 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/>.
|
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
|
import time
|
2010-08-13 07:28:43 +00:00
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
|
from openerp.osv import fields, osv
|
|
|
|
|
from openerp.tools.translate import _
|
2010-06-08 13:06:11 +00:00
|
|
|
|
|
2014-07-06 14:44:26 +00:00
|
|
|
|
|
2010-08-13 07:28:43 +00:00
|
|
|
|
class product_margin(osv.osv_memory):
|
2010-03-09 12:00:43 +00:00
|
|
|
|
_name = 'product.margin'
|
|
|
|
|
_description = 'Product Margin'
|
2010-06-08 13:06:11 +00:00
|
|
|
|
_columns = {
|
|
|
|
|
'from_date': fields.date('From'),
|
|
|
|
|
'to_date': fields.date('To'),
|
2014-07-06 14:44:26 +00:00
|
|
|
|
'invoice_state': fields.selection([
|
|
|
|
|
('paid', 'Paid'),
|
|
|
|
|
('open_paid', 'Open and Paid'),
|
|
|
|
|
('draft_open_paid', 'Draft, Open and Paid'),
|
|
|
|
|
], 'Invoice State', select=True, required=True),
|
2010-06-08 13:06:11 +00:00
|
|
|
|
}
|
2014-07-06 14:44:26 +00:00
|
|
|
|
|
2010-06-08 13:06:11 +00:00
|
|
|
|
_defaults = {
|
2010-08-13 07:28:43 +00:00
|
|
|
|
'from_date': time.strftime('%Y-01-01'),
|
|
|
|
|
'to_date': time.strftime('%Y-12-31'),
|
|
|
|
|
'invoice_state': "open_paid",
|
2010-06-08 13:06:11 +00:00
|
|
|
|
}
|
2014-07-06 14:44:26 +00:00
|
|
|
|
|
2010-06-08 13:06:11 +00:00
|
|
|
|
def action_open_window(self, cr, uid, ids, context=None):
|
2010-03-09 12:00:43 +00:00
|
|
|
|
"""
|
|
|
|
|
@param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
2010-03-12 13:42:55 +00:00
|
|
|
|
@param ids: the ID or list of IDs if we want more than one
|
2010-03-09 12:00:43 +00:00
|
|
|
|
|
|
|
|
|
@return:
|
|
|
|
|
"""
|
2014-07-06 14:44:26 +00:00
|
|
|
|
context = dict(context or {})
|
|
|
|
|
|
|
|
|
|
def ref(module, xml_id):
|
|
|
|
|
proxy = self.pool.get('ir.model.data')
|
|
|
|
|
return proxy.get_object_reference(cr, uid, module, xml_id)
|
|
|
|
|
|
|
|
|
|
model, search_view_id = ref('product', 'product_search_form_view')
|
|
|
|
|
model, graph_view_id = ref('product_margin', 'view_product_margin_graph')
|
|
|
|
|
model, form_view_id = ref('product_margin', 'view_product_margin_form')
|
|
|
|
|
model, tree_view_id = ref('product_margin', 'view_product_margin_tree')
|
2010-03-09 12:00:43 +00:00
|
|
|
|
|
|
|
|
|
#get the current product.margin object to obtain the values from it
|
2014-07-06 14:44:26 +00:00
|
|
|
|
records = self.browse(cr, uid, ids, context=context)
|
|
|
|
|
record = records[0]
|
|
|
|
|
|
|
|
|
|
context.update(invoice_state=record.invoice_state)
|
|
|
|
|
|
|
|
|
|
if record.from_date:
|
|
|
|
|
context.update(date_from=record.from_date)
|
|
|
|
|
|
|
|
|
|
if record.to_date:
|
|
|
|
|
context.update(date_to=record.to_date)
|
2010-03-09 12:00:43 +00:00
|
|
|
|
|
2014-07-06 14:44:26 +00:00
|
|
|
|
views = [
|
|
|
|
|
(tree_view_id, 'tree'),
|
|
|
|
|
(form_view_id, 'form'),
|
|
|
|
|
(graph_view_id, 'graph')
|
|
|
|
|
]
|
2010-03-09 12:00:43 +00:00
|
|
|
|
return {
|
|
|
|
|
'name': _('Product Margins'),
|
2010-12-14 07:13:21 +00:00
|
|
|
|
'context': context,
|
2010-03-09 12:00:43 +00:00
|
|
|
|
'view_type': 'form',
|
|
|
|
|
"view_mode": 'tree,form,graph',
|
2014-07-06 14:44:26 +00:00
|
|
|
|
'res_model': 'product.product',
|
2010-03-09 12:00:43 +00:00
|
|
|
|
'type': 'ir.actions.act_window',
|
2014-07-06 14:44:26 +00:00
|
|
|
|
'views': views,
|
2010-03-09 12:00:43 +00:00
|
|
|
|
'view_id': False,
|
2014-07-06 14:44:26 +00:00
|
|
|
|
'search_view_id': search_view_id,
|
2010-03-09 12:00:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 07:28:43 +00:00
|
|
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|