123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- # -*- coding: utf-8 -*-
- ##############################################################################
- # 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
- #
- # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
- # GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
- # If not, see <http://www.gnu.org/licenses/>.
- #
- ##############################################################################
- import datetime
- from openerp.osv import osv
- from openerp.report import report_sxw
- class MrpReport(report_sxw.rml_parse):
- def __init__(self, cr, uid, name, context=None):
- super(MrpReport, self).__init__(cr, uid, name, context=context)
- self.localcontext.update({
- 'get_details': self.get_details,
- 'get_date': self.get_date,
- })
- self.context = context
- def get_date(self):
- date = datetime.datetime.now()
- return date
- def get_details(self, data):
- lines = []
- if data['filter'] is True:
- if data['filter_user'] is True:
- if len(data['product']) > 0 \
- and data['stage'] is not False:
- for k in range(0, len(data['product'])):
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned) \
- and obj.state == data['stage'] \
- and obj.product_id.id == data['product'][k] \
- and obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- elif len(data['product']) == 0 and data['stage'] is not False:
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned) \
- and obj.state == data['stage'] \
- and obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- if len(data['product']) > 0 \
- and data['stage'] is False:
- for k in range(0, len(data['product'])):
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned) \
- and obj.product_id.id == data['product'][k] \
- and obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- if len(data['product']) == 0 \
- and data['stage'] is False:
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned) \
- and obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- if data['filter_user'] is False:
- if len(data['product']) > 0 \
- and data['stage'] is not False:
- for k in range(0, len(data['product'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned) \
- and obj.state == data['stage'] \
- and obj.product_id.id == data['product'][k]:
- lines.append(obj)
- elif len(data['product']) == 0 and data['stage'] is not False:
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned) \
- and obj.state == data['stage']:
- lines.append(obj)
- if len(data['product']) > 0 \
- and data['stage'] is False:
- for k in range(0, len(data['product'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned) \
- and obj.product_id.id == data['product'][k]:
- lines.append(obj)
- if len(data['product']) == 0 \
- and data['stage'] is False:
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if (data['date_from'] <= obj.date_planned) \
- and (data['date_to'] >= obj.date_planned):
- lines.append(obj)
- if data['filter'] is False:
- if data['filter_user'] is True:
- if len(data['product']) > 0 \
- and data['stage'] is not False:
- for k in range(0, len(data['product'])):
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if obj.state == data['stage'] \
- and obj.product_id.id == data['product'][k] \
- and obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- elif len(data['product']) == 0 and data['stage'] is not False:
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if obj.state == data['stage'] \
- and obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- if len(data['product']) > 0 \
- and data['stage'] is False:
- for k in range(0, len(data['product'])):
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if obj.product_id.id == data['product'][k] \
- and obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- if len(data['product']) == 0 \
- and data['stage'] is False:
- for l in range(0, len(data['responsible'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if obj.user_id.id == data['responsible'][l]:
- lines.append(obj)
- if data['filter_user'] is False:
- if len(data['product']) > 0 \
- and data['stage'] is not False:
- for k in range(0, len(data['product'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if obj.state == data['stage'] \
- and obj.product_id.id == data['product'][k]:
- lines.append(obj)
- elif len(data['product']) == 0 and data['stage'] is not False:
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if obj.state == data['stage']:
- lines.append(obj)
- if len(data['product']) > 0 \
- and data['stage'] is False:
- for k in range(0, len(data['product'])):
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- if obj.product_id.id == data['product'][k]:
- lines.append(obj)
- if len(data['product']) == 0 \
- and data['stage'] is False:
- for i in self.pool.get('mrp.production').search(self.cr, self.uid, []):
- obj = self.pool.get('mrp.production').browse(self.cr, self.uid, i)
- lines.append(obj)
- return lines
- class PrintReport(osv.AbstractModel):
- _name = 'report.eirumrp_reports.mrp_pdf'
- _inherit = 'report.abstract_report'
- _template = 'eirumrp_reports.mrp_pdf'
- _wrapped_report_class = MrpReport
|