~serpent-consulting-services/openerp-usa/fix-shipping_api_ups_cc

« back to all changes in this revision

Viewing changes to assembly_bom/report/consumption_report.py

  • Committer: npgllc
  • Date: 2012-08-02 17:13:27 UTC
  • Revision ID: npgllc-20120802171327-2xgyyjjb5d1kx26y
Removed all the 6.0 compatible modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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
 
import time
23
 
 
24
 
from report import report_sxw
25
 
 
26
 
class consumption_report(report_sxw.rml_parse):
27
 
    def _get_consumption_lines(self,product_id):
28
 
 
29
 
        """ Finds the consumption details for the product
30
 
         @param self: The object pointer.
31
 
         @param product_id: ID of the product
32
 
         @comment: fetches the consumption details of the product using 'find_consumption_details'
33
 
                   which analyses stock moves to find consumption details
34
 
         @return: List of dictionaries showing the consumption details
35
 
        """
36
 
        res=[]
37
 
        detail_list=self.localcontext.get('detail_list',[])
38
 
        cr=self.cr;uid=self.uid
39
 
        details=self.pool.get("product.product").find_consumption_details(cr,uid,[product_id],context=self.localcontext)
40
 
        detail_list=details.get('detail_list',[])
41
 
        return detail_list
42
 
 
43
 
    def _get_us_date(self,date_string):
44
 
        """ Converts the input date string to us format
45
 
         @param self: The object pointer.
46
 
         @param date_string: Expects date in ISO format YYYY-MM-DD
47
 
         @comment: uses format_lang method to convert the date to the us format
48
 
         @return: Returns either the us format date or an empty string
49
 
        """
50
 
        us_string=''
51
 
        if date_string:
52
 
            us_string=self.formatLang(date_string,date=True)
53
 
        return us_string
54
 
 
55
 
    def _format_product_name(self,product_name,reference):
56
 
        """ Adds the product name and reference
57
 
         @param self: The object pointer.
58
 
         @param product_name: name of the product
59
 
         @param reference: Reference of the product
60
 
         @comment: adds the the reference and the product name if there is a reference string
61
 
         @return: returns '[reference] product_name' or 'product_name'
62
 
        """
63
 
        if reference:
64
 
            reference="[%s] "%reference
65
 
        else:
66
 
            reference=""
67
 
        return reference+product_name
68
 
 
69
 
    def __init__(self, cr, uid, name, context=None):
70
 
        """ Parser __init__ override
71
 
        """
72
 
        super(consumption_report, self).__init__(cr, uid, name, context=context)
73
 
        self.localcontext.update({
74
 
            'time': time,
75
 
            '_get_consumption_lines':self._get_consumption_lines,
76
 
            '_get_':self._get_consumption_lines,
77
 
            '_get_us_date':self._get_us_date,
78
 
            '_format_product_name':self._format_product_name,
79
 
            'source_loc_id':context.get('source_loc_id', False),#1. location id selected for getting consumption details in the wizard
80
 
            'start_date':context.get('start_date',False),#2. getting start date selected in the wizard
81
 
            'end_date':context.get('end_date',False),#3. getting end date selected in the wizard
82
 
        })
83
 
 
84
 
report_sxw.report_sxw('report.product.consumption', 'product.product', 'addons/assembly_bom/report/consumption_report.rml', parser=consumption_report, header=False)
85
 
 
86
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
87