Skip to content

Commit

Permalink
Merge 34e01b1 into 51f6fd0
Browse files Browse the repository at this point in the history
  • Loading branch information
mdietrichc2c committed Oct 8, 2014
2 parents 51f6fd0 + 34e01b1 commit 98d009b
Show file tree
Hide file tree
Showing 11 changed files with 892 additions and 0 deletions.
32 changes: 32 additions & 0 deletions stock_obsolete/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2008-2014 Camtocamp SA
# @author Joël Grand-Guillaume, Matthieu Dietrich
# $Id: $
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from . import wizard
from . import stock_obsolete
from . import report
53 changes: 53 additions & 0 deletions stock_obsolete/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# @author Grand-Guillaume Joel, Matthieu Dietrich
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################

{
"name": "Stock obsolete",
"version": "1.0",
"author": "Camptocamp",
"category": "Generic Modules/Stock",
"description":
"""
Add a special view and wizard on product to check the validity of each
stock product, with an amount of depreciation. Your finance can now
take in charge a factor for each product, based on the depreciation
value for each product. You can set the depreciation value based on the
out of stock amount for each product for the last 12/24 months.
""",
"website": "http://camptocamp.com",
"depends": ["stock", "product"],
"demo": [],
"data": [
"stock_obsolete_view.xml",
"stock_obsolete_report.xml",
],
'test': [
'test/stock_obsolete.yml',
],
"active": False,
"installable": True
}
30 changes: 30 additions & 0 deletions stock_obsolete/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2008 Camtocamp SA
# @author Joël Grand-Guillaume
# $Id: $
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from . import product_obsolete
95 changes: 95 additions & 0 deletions stock_obsolete/report/product_obsolete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) Camptocamp SA - Joel Grand-Guillaume
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################

import time
import re
from report import report_sxw
from openerp.tools.translate import _


class ProductObsolete(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(ProductObsolete, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'comma_me': self.comma_me,
'get_name_of': self.get_depreciation_name,
})
self.context = context

def comma_me(self, amount):
if type(amount) is float:
amount = str('%.2f' % amount)
else:
amount = str(amount)
orig = amount
new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
if orig == new:
return new
else:
return self.comma_me(new)

def get_depreciation_name(self, value):
if value == 'no':
return _('No')
elif value == 'half':
return _('Half')
elif value == 'full':
return _('Full')
else:
return False

def set_context(self, objects, data, ids, report_type=None):
prod_obj = self.pool.get('product.product')
if data.get('ids', False) and \
data.get('model', False) == 'product.product':
ids = [data['ids']]
else:
ids = prod_obj.search(self.cr, self.uid,
[('type', '=', 'product')],
limit=4000)

objects = prod_obj.browse(self.cr, self.uid, ids)

def o_compare(x, y):
if x.outgoing_qty_till_12m < y.outgoing_qty_till_12m:
return 1
elif x.outgoing_qty_till_12m == y.outgoing_qty_till_12m:
return 0
else: # x<y
return -1

# sort object by depreciation 12 month
objects.sort(o_compare)
self.ids = [o.id for o in objects]
self.localcontext['objects'] = objects

report_sxw.report_sxw('report.product.obsolete',
'product.product',
'addons/stock_obsolete/report/product_obsolete.rml',
parser=ProductObsolete, header=False)
Loading

0 comments on commit 98d009b

Please sign in to comment.