--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import mrp_repair
+import wizard
+import report
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+ "name":"Products Repairs Module",
+ "version":"1.0",
+ "author":"Tiny",
+ "description": """
+ The aim is to have a complete module to manage all products repairs. The following topics should be covered by this module:
+ * Add/remove products in the reparation
+ * Impact for stocks
+ * Invoicing (products and/or services)
+ * Warrenty concept
+ * Repair quotation report
+ * Notes for the technician and for the final customer
+""",
+
+ "category":"Custom",
+ "depends":["base","sale","account"],
+ "demo_xml":[],
+ "update_xml":["mrp_repair_sequence.xml","mrp_repair_wizard.xml", "mrp_repair_view.xml", "mrp_repair_workflow.xml", "mrp_repair_report.xml"],
+ "active": False,
+ "installable": True,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import time
+from osv import fields,osv
+import netsvc
+import mx.DateTime
+from mx.DateTime import RelativeDateTime, today, DateTime, localtime
+from tools import config
+class mrp_repair(osv.osv):
+ _name = 'mrp.repair'
+ _description = 'Repairs Order'
+
+ def _amount_untaxed(self, cr, uid, ids, field_name, arg, context):
+ res = {}
+ cur_obj=self.pool.get('res.currency')
+ for repair in self.browse(cr, uid, ids):
+ res[repair.id] = 0.0
+ for line in repair.operations:
+ res[repair.id] += line.price_subtotal
+ for line in repair.fees_lines:
+ res[repair.id] += line.price_subtotal
+ cur = repair.pricelist_id.currency_id
+ res[repair.id] = cur_obj.round(cr, uid, cur, res[repair.id])
+ return res
+
+ def _amount_tax(self, cr, uid, ids, field_name, arg, context):
+ res = {}
+ cur_obj=self.pool.get('res.currency')
+ for repair in self.browse(cr, uid, ids):
+ val = 0.0
+ cur=repair.pricelist_id.currency_id
+ for line in repair.operations:
+ for c in self.pool.get('account.tax').compute(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id):
+ val+= c['amount']
+ for line in repair.fees_lines:
+ for c in self.pool.get('account.tax').compute(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id):
+ val+= c['amount']
+ res[repair.id]=cur_obj.round(cr, uid, cur, val)
+ return res
+
+ def _amount_total(self, cr, uid, ids, field_name, arg, context):
+ res = {}
+ untax = self._amount_untaxed(cr, uid, ids, field_name, arg, context)
+ tax = self._amount_tax(cr, uid, ids, field_name, arg, context)
+ cur_obj=self.pool.get('res.currency')
+ for id in ids:
+ repair=self.browse(cr, uid, [id])[0]
+ cur=repair.pricelist_id.currency_id
+ res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0))
+ return res
+ _columns = {
+ 'name' : fields.char('Name',size=24, required=True),
+ 'product_id': fields.many2one('product.product', string='Product to Repair', required=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'partner_id' : fields.many2one('res.partner', 'Partner', select=True),
+ 'address_id': fields.many2one('res.partner.address', 'Delivery Address', domain="[('partner_id','=',partner_id)]"),
+ 'prodlot_id': fields.many2one('stock.production.lot', 'Lot Number', select=True, domain="[('product_id','=',product_id)]"),
+ 'state': fields.selection([
+ ('draft','Quotation'),
+ ('confirmed','Confirmed'),
+ ('ready','Ready to Repair'),
+ ('under_repair','Under Repair'),
+ ('2binvoiced','To be Invoiced'),
+ ('invoice_except','Invoice Exception'),
+ ('done','Done'),
+ ('cancel','Cancel')
+ ], 'Repair State', readonly=True, help="Gives the state of the Repair Order"),
+ 'location_id': fields.many2one('stock.location', 'Current Location', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'location_dest_id': fields.many2one('stock.location', 'Delivery Location', required=True, readonly=True, states={'draft':[('readonly',False)]}),
+ 'move_id': fields.many2one('stock.move', 'Move',required=True, domain="[('product_id','=',product_id)]", readonly=True, states={'draft':[('readonly',False)]}),#,('location_dest_id','=',location_id),('prodlot_id','=',prodlot_id)
+ 'guarantee_limit': fields.date('Guarantee limit'),
+ 'operations' : fields.one2many('mrp.repair.line', 'repair_id', 'Operation Lines', readonly=True, states={'draft':[('readonly',False)]}),
+ 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
+ 'partner_invoice_id':fields.many2one('res.partner.address', 'Invoice to', domain="[('partner_id','=',partner_id)]"),
+ 'invoice_method':fields.selection([
+ ("none","No Invoice"),
+ ("b4repair","Before Repair"),
+ ("after_repair","After Repair")
+ ], "Invoice Method",
+ select=True, states={'draft':[('readonly',False)]}, readonly=True),
+ 'invoice_id': fields.many2one('account.invoice', 'Invoice', readonly=True),
+ 'picking_id': fields.many2one('stock.picking', 'Packing',readonly=True),
+ 'fees_lines' : fields.one2many('mrp.repair.fee', 'repair_id', 'Fees Lines', readonly=True, states={'draft':[('readonly',False)]}),
+ 'internal_notes' : fields.text('Internal Notes'),
+ 'quotation_notes' : fields.text('Quotation Notes'),
+ 'invoiced': fields.boolean('Invoiced', readonly=True),
+ 'repaired' : fields.boolean('Repaired', readonly=True),
+ 'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount'),
+ 'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'),
+ 'amount_total': fields.function(_amount_total, method=True, string='Total'),
+ }
+
+ _defaults = {
+ 'state': lambda *a: 'draft',
+ 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'mrp.repair'),
+ 'invoice_method': lambda *a: 'none',
+ 'pricelist_id': lambda self, cr, uid,context : self.pool.get('product.pricelist').search(cr,uid,[('type','=','sale')])[0]
+ }
+
+ def copy(self, cr, uid, id, default=None, context=None):
+ if not default:
+ default = {}
+ default.update({
+ 'state':'draft',
+ 'repaired':False,
+ 'invoiced':False,
+ 'invoice_id': False,
+ 'picking_id': False,
+ 'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.repair'),
+ })
+ return super(mrp_repair, self).copy(cr, uid, id, default, context)
+
+
+ def onchange_product_id(self, cr, uid, ids, product_id=None):
+ return {'value': {
+ 'prodlot_id': False,
+ 'move_id': False,
+ 'guarantee_limit' :False,
+ 'location_id': False,
+ 'location_dest_id': False,
+ }
+ }
+
+ def onchange_move_id(self, cr, uid, ids, prod_id=False, move_id=False):
+ if not prod_id:
+ return {'value': {
+ 'prodlot_id': False,
+ 'move_id': False,
+ 'guarantee_limit' :False,
+ 'location_id': False,
+ 'location_dest_id': False
+ }
+ }
+ if move_id:
+ move = self.pool.get('stock.move').browse(cr, uid, move_id)
+ product = self.pool.get('product.product').browse(cr, uid, prod_id)
+ date = move.date_planned
+ limit = mx.DateTime.strptime(date, '%Y-%m-%d %H:%M:%S') + RelativeDateTime(months=product.warranty)
+ return {'value': {
+ 'guarantee_limit': limit.strftime('%Y-%m-%d'),
+ }
+ }
+
+ def button_dummy(self, cr, uid, ids, context=None):
+ return True
+
+ def onchange_partner_id(self, cr, uid, ids, part):
+ if not part:
+ return {'value': {
+ 'address_id': False,
+ 'partner_invoice_id': False,
+ 'pricelist_id': self.pool.get('product.pricelist').search(cr,uid,[('type','=','sale')])[0]
+ }
+ }
+ addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery', 'invoice', 'default'])
+ partner = self.pool.get('res.partner').browse(cr, uid, part)
+ pricelist = partner.property_product_pricelist and partner.property_product_pricelist.id or False
+ return {'value': {
+ 'address_id': addr['delivery'],
+ 'partner_invoice_id': addr['invoice'],
+ 'pricelist_id': pricelist
+ }
+ }
+
+
+ def onchange_lot_id(self, cr, uid, ids, lot, product_id):
+ if not lot:
+ return {'value': {
+ 'location_id': False,
+ 'location_dest_id': False,
+ 'move_id': False,
+ 'guarantee_limit': False
+ }
+ }
+ lot_info = self.pool.get('stock.production.lot').browse(cr, uid, lot)
+ move_ids = self.pool.get('stock.move').search(cr, uid, [('prodlot_id', '=', lot)])
+
+ if not len(move_ids):
+ return {'value': {
+ 'location_id': False,
+ 'location_dest_id': False,
+ 'move_id': False,
+ 'guarantee_limit':False
+ }
+ }
+
+ def get_last_move(lst_move):
+ while lst_move.move_dest_id and lst_move.state == 'done':
+ lst_move = lst_move.move_dest_id
+ return lst_move
+
+ move_id = move_ids[0]
+ move = get_last_move(self.pool.get('stock.move').browse(cr, uid, move_id))
+ product = self.pool.get('product.product').browse(cr, uid, product_id)
+ date = move.date_planned
+ limit = mx.DateTime.strptime(date, '%Y-%m-%d %H:%M:%S') + RelativeDateTime(months=product.warranty)
+ return {'value': {
+ 'location_id': move.location_dest_id.id,
+ 'location_dest_id': move.location_dest_id.id,
+ 'move_id': move.id,
+ 'guarantee_limit': limit.strftime('%Y-%m-%d')
+ }
+ }
+
+ def action_cancel_draft(self, cr, uid, ids, *args):
+ if not len(ids):
+ return False
+ mrp_line_obj = self.pool.get('mrp.repair.line')
+ for repair in self.browse(cr, uid, ids):
+ mrp_line_obj.write(cr, uid, [l.id for l in repair.operations], {'state': 'draft'})
+ self.write(cr, uid, ids, {'state':'draft'})
+ wf_service = netsvc.LocalService("workflow")
+ for id in ids:
+ wf_service.trg_create(uid, 'mrp.repair', id, cr)
+ return True
+
+ def action_confirm(self, cr, uid, ids, *args):
+ mrp_line_obj = self.pool.get('mrp.repair.line')
+ for o in self.browse(cr, uid, ids):
+ if (o.invoice_method == 'b4repair'):
+ self.write(cr, uid, [o.id], {'state': '2binvoiced'})
+ else:
+ self.write(cr, uid, [o.id], {'state': 'confirmed'})
+ mrp_line_obj.write(cr, uid, [l.id for l in o.operations], {'state': 'confirmed'})
+ return True
+
+ def action_cancel(self, cr, uid, ids, context=None):
+ ok=True
+ mrp_line_obj = self.pool.get('mrp.repair.line')
+ for repair in self.browse(cr, uid, ids):
+ mrp_line_obj.write(cr, uid, [l.id for l in repair.operations], {'state': 'cancel'})
+ self.write(cr,uid,ids,{'state':'cancel'})
+ return True
+
+ def wkf_invoice_create(self, cr, uid, ids, *args):
+ return self.action_invoice_create(cr, uid, ids)
+
+ def action_invoice_create(self, cr, uid, ids, group=False, context=None):
+ res={}
+ invoices_group = {}
+ for repair in self.browse(cr, uid, ids, context=context):
+ res[repair.id]=False
+ if repair.state in ('draft','cancel') or repair.invoice_id:
+ continue
+ if not (repair.partner_id.id and repair.partner_invoice_id.id):
+ raise osv.except_osv('No partner !','You have to select a partner in the repair form ! ')
+ comment=repair.quotation_notes
+ if (repair.invoice_method != 'none'):
+ if group and repair.partner_invoice_id.id in invoices_group:
+ inv_id= invoices_group[repair.partner_invoice_id.id]
+ invoice=invoice_obj.browse(cr, uid,inv_id)
+ invoice_vals = {
+ 'name': invoice.name +', '+repair.name,
+ 'origin': invoice.origin+', '+repair.name,
+ 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''),
+ }
+ invoice_obj.write(cr, uid, [inv_id],invoice_vals,context=context)
+ else:
+ a = repair.partner_id.property_account_receivable.id
+ inv = {
+ 'name': repair.name,
+ 'origin':repair.name,
+ 'type': 'out_invoice',
+ 'account_id': a,
+ 'partner_id': repair.partner_id.id,
+ 'address_invoice_id': repair.address_id.id,
+ 'currency_id': repair.pricelist_id.currency_id.id,
+ 'comment': repair.quotation_notes,
+ }
+ inv_obj = self.pool.get('account.invoice')
+ inv_id = inv_obj.create(cr, uid, inv)
+ invoices_group[repair.partner_invoice_id.id] = inv_id
+ self.write(cr, uid, repair.id , {'invoiced':True,'invoice_id' : inv_id})
+
+ for operation in repair.operations:
+ if operation.to_invoice == True:
+ if group:
+ name = repair.name + '-' + operation.name
+ else:
+ name = operation.name
+ invoice_line_id=self.pool.get('account.invoice.line').create(cr, uid, {
+ 'invoice_id': inv_id,
+ 'name': name,
+ 'origin':repair.name,
+ 'account_id': a,
+ 'quantity' : operation.product_uom_qty,
+ 'invoice_line_tax_id': [(6,0,[x.id for x in operation.tax_id])],
+ 'uos_id' : operation.product_uom.id,
+ 'price_unit' : operation.price_unit,
+ 'price_subtotal' : operation.product_uom_qty*operation.price_unit,
+ 'product_id' : operation.product_id and operation.product_id.id or False
+ })
+ self.pool.get('mrp.repair.line').write(cr, uid, [operation.id], {'invoiced':True,'invoice_line_id':invoice_line_id})
+ for fee in repair.fees_lines:
+ if fee.to_invoice == True:
+ if group:
+ name = repair.name + '-' + fee.name
+ else:
+ name = fee.name
+ invoice_fee_id=self.pool.get('account.invoice.line').create(cr, uid, {
+ 'invoice_id': inv_id,
+ 'name': name,
+ 'origin':repair.name,
+ 'account_id': a,
+ 'quantity': fee.product_uom_qty,
+ 'invoice_line_tax_id': [(6,0,[x.id for x in fee.tax_id])],
+ 'uos_id': fee.product_uom.id,
+ 'product_id': fee.product_id and fee.product_id.id or False,
+ 'price_unit': fee.price_unit,
+ 'price_subtotal': fee.product_uom_qty*fee.price_unit
+ })
+ self.pool.get('mrp.repair.fee').write(cr, uid, [fee.id], {'invoiced':True,'invoice_line_id':invoice_fee_id})
+ res[repair.id]=inv_id
+ #self.action_invoice_end(cr, uid, ids)
+ return res
+
+ def action_invoice_cancel(self, cr, uid, ids, context=None):
+ self.write(cr, uid, ids, {'state':'invoice_except'})
+ return True
+
+ def action_repair_ready(self, cr, uid, ids, context=None):
+ self.write(cr, uid, ids, {'state':'ready'})
+ return True
+
+ def action_repair_start(self, cr, uid, ids, context=None):
+ self.write(cr, uid, ids, {'state':'under_repair'})
+ return True
+
+ def action_invoice_end(self, cr, uid, ids, context=None):
+ for order in self.browse(cr, uid, ids):
+ val = {}
+ if (order.invoice_method=='b4repair'):
+ val['state'] = 'ready'
+ else:
+ #val['state'] = 'done'
+ pass
+ self.write(cr, uid, [order.id], val)
+ return True
+
+ def action_repair_end(self, cr, uid, ids, context=None):
+ for order in self.browse(cr, uid, ids):
+ val = {}
+ val['repaired']=True
+ if (not order.invoiced and order.invoice_method=='after_repair'):
+ val['state'] = '2binvoiced'
+ elif (not order.invoiced and order.invoice_method=='b4repair'):
+ val['state'] = 'ready'
+ else:
+ #val['state'] = 'done'
+ pass
+ self.write(cr, uid, [order.id], val)
+ return True
+
+ def wkf_repair_done(self, cr, uid, ids, *args):
+ res=self.action_repair_done(cr,uid,ids)
+ return True
+
+ def action_repair_done(self, cr, uid, ids, context=None):
+ res = {}
+ company = self.pool.get('res.users').browse(cr, uid, uid).company_id
+ for repair in self.browse(cr, uid, ids, context=context):
+
+ picking = self.pool.get('stock.picking').create(cr, uid, {
+ 'origin': repair.name,
+ 'state': 'assigned',
+ 'move_type': 'one',
+ 'address_id': repair.address_id and repair.address_id.id or False,
+ 'note': repair.internal_notes,
+ 'invoice_state': 'none',
+ 'type': 'out', # FIXME delivery ?
+ })
+
+ move_id = self.pool.get('stock.move').create(cr, uid, {
+ 'name': repair.name,
+ 'picking_id': picking,
+ 'product_id': repair.product_id.id,
+ 'product_qty': 1.0,
+ 'product_uom': repair.product_id.uom_id.id,
+ #'product_uos_qty': line.product_uom_qty,
+ #'product_uos': line.product_uom.id,
+ 'prodlot_id': repair.prodlot_id and repair.prodlot_id.id or False,
+ 'address_id': repair.address_id and repair.address_id.id or False,
+ 'location_id': repair.location_id.id,
+ 'location_dest_id': repair.location_dest_id.id,
+ 'tracking_id': False,
+ 'state': 'assigned', # FIXME done ?
+ })
+
+ self.write(cr, uid, [repair.id], {'state':'done', 'picking_id':picking})
+ res[repair.id] = picking
+ return res
+
+
+mrp_repair()
+
+
+class ProductChangeMixin(object):
+ def product_id_change(self, cr, uid, ids, pricelist, product, uom=False, product_uom_qty=0, partner_id=False, guarantee_limit=False):
+ result = {}
+ warning = {}
+
+ if not product_uom_qty:
+ product_uom_qty = 1
+ result['product_uom_qty'] = product_uom_qty
+
+ if product:
+ product_obj = self.pool.get('product.product').browse(cr, uid, product)
+ result['name'] = product_obj.partner_ref
+ result['product_uom'] = product_obj.uom_id and product_obj.uom_id.id or False
+ if not pricelist:
+ warning={
+ 'title':'No Pricelist !',
+ 'message':
+ 'You have to select a pricelist in the Repair form !\n'
+ 'Please set one before choosing a product.'
+ }
+ else:
+ price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist],
+ product, product_uom_qty, partner_id, {'uom': uom,})[pricelist]
+
+ if price is False:
+ warning={
+ 'title':'No valid pricelist line found !',
+ 'message':
+ "Couldn't find a pricelist line matching this product and quantity.\n"
+ "You have to change either the product, the quantity or the pricelist."
+ }
+ else:
+ result.update({'price_unit': price, 'price_subtotal' :price*product_uom_qty})
+
+ return {'value': result, 'warning': warning}
+
+
+class mrp_repair_line(osv.osv, ProductChangeMixin):
+ _name = 'mrp.repair.line'
+ _description = 'Repair Operations Lines'
+
+ def copy(self, cr, uid, id, default=None, context=None):
+ if not default: default = {}
+ default.update( {'invoice_line_id':False,'move_ids':[],'invoiced':False,'state':'draft'})
+ return super(mrp_repair_line, self).copy(cr, uid, id, default, context)
+
+ def _amount_line(self, cr, uid, ids, field_name, arg, context):
+ res = {}
+ cur_obj=self.pool.get('res.currency')
+ for line in self.browse(cr, uid, ids):
+ res[line.id] = line.to_invoice and line.price_unit * line.product_uom_qty or 0
+ cur = line.repair_id.pricelist_id.currency_id
+ res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
+ return res
+
+ _columns = {
+ 'name' : fields.char('Name',size=64,required=True),
+ 'repair_id': fields.many2one('mrp.repair', 'Repair Order Ref',ondelete='cascade', select=True),
+ 'type': fields.selection([('add','Add'),('remove','Remove')],'Type'),
+ 'to_invoice': fields.boolean('To Invoice'),
+ 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok','=',True)]),
+ 'invoiced': fields.boolean('Invoiced',readonly=True),
+ 'price_unit': fields.float('Unit Price', required=True, digits=(16, int(config['price_accuracy']))),
+ 'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal',digits=(16, int(config['price_accuracy']))),
+ 'tax_id': fields.many2many('account.tax', 'repair_operation_line_tax', 'repair_operation_line_id', 'tax_id', 'Taxes'),
+ 'product_uom_qty': fields.float('Quantity (UoM)', digits=(16,2), required=True),
+ 'product_uom': fields.many2one('product.uom', 'Product UoM', required=True),
+ 'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line', readonly=True),
+ 'location_id': fields.many2one('stock.location', 'Source Location', required=True, select=True),
+ 'location_dest_id': fields.many2one('stock.location', 'Dest. Location', required=True, select=True),
+ 'move_ids': fields.one2many('stock.move', 'repair_line_id', 'Inventory Moves', readonly=True),
+ 'state': fields.selection([('draft','Draft'),('confirmed','Confirmed'),('done','Done'),('cancel','Canceled')], 'Status', required=True, readonly=True),
+ }
+ _defaults = {
+ 'state': lambda *a: 'draft',
+ 'product_uom_qty':lambda *a:1,
+ }
+
+ def onchange_operation_type(self, cr, uid, ids, type,guarantee_limit):
+ if not type:
+ return {'value': {
+ 'location_id': False,
+ 'location_dest_id': False
+ }
+ }
+ stock_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Stock')])[0]
+ produc_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Default Production')])[0]
+ to_invoice=False
+ if guarantee_limit and today() > mx.DateTime.strptime(guarantee_limit, '%Y-%m-%d'):
+ to_invoice=True
+ if type == 'add':
+ return {'value': {
+ 'to_invoice': to_invoice,
+ 'location_id': stock_id,
+ 'location_dest_id' : produc_id
+ }
+ }
+ if type == 'remove':
+ return {'value': {
+ 'to_invoice': to_invoice,
+ 'location_id': produc_id,
+ 'location_dest_id':False
+ }
+ }
+
+mrp_repair_line()
+
+class mrp_repair_fee(osv.osv, ProductChangeMixin):
+ _name = 'mrp.repair.fee'
+ _description = 'Repair Fees line'
+ def copy(self, cr, uid, id, default=None, context=None):
+ if not default: default = {}
+ default.update( {'invoice_line_id':False,'invoiced':False})
+ return super(mrp_repair_fee, self).copy(cr, uid, id, default, context)
+ def _amount_line(self, cr, uid, ids, field_name, arg, context):
+ res = {}
+ cur_obj=self.pool.get('res.currency')
+ for line in self.browse(cr, uid, ids):
+ res[line.id] = line.to_invoice and line.price_unit * line.product_uom_qty or 0
+ cur = line.repair_id.pricelist_id.currency_id
+ res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
+ return res
+
+ _columns = {
+ 'repair_id': fields.many2one('mrp.repair', 'Repair Order Ref', required=True, ondelete='cascade', select=True),
+ 'name': fields.char('Description', size=64, select=True,required=True),
+ 'product_id': fields.many2one('product.product', 'Product'),
+ 'product_uom_qty': fields.float('Quantity', digits=(16,2), required=True),
+ 'price_unit': fields.float('Unit Price', required=True),
+ 'product_uom': fields.many2one('product.uom', 'Product UoM', required=True),
+ 'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal',digits=(16, int(config['price_accuracy']))),
+ 'tax_id': fields.many2many('account.tax', 'repair_fee_line_tax', 'repair_fee_line_id', 'tax_id', 'Taxes'),
+ 'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line', readonly=True),
+ 'to_invoice': fields.boolean('To Invoice'),
+ 'invoiced': fields.boolean('Invoiced',readonly=True),
+ }
+ _defaults = {
+ 'to_invoice': lambda *a: True,
+ }
+
+mrp_repair_fee()
+
+
+class stock_move(osv.osv):
+ _inherit = 'stock.move'
+ _columns = {
+ 'repair_line_id': fields.many2one('mrp.repair.line', 'Repair Operation Line', ondelete='set null', select=True, readonly=True),
+ }
+ _defaults = {
+ 'repair_line_id': lambda *a:False
+ }
+stock_move()
+
+class stock_picking(osv.osv):
+ _inherit = 'stock.picking'
+ _columns = {
+ 'repair_id': fields.many2one('mrp.repair', 'Repair Order', ondelete='set null', select=True, readonly=True),
+ }
+ _defaults = {
+ 'repair_id': lambda *a: False
+ }
+stock_picking()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <report
+ id="report_mrp_repair"
+ string="Repair Quotation"
+ model="mrp.repair"
+ name="repair.order"
+ rml="mrp_repair/report/order.rml"
+ auto="False"/>
+ </data>
+</openerp>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data noupdate="1">
+ <record id="seq_type_mrp_repair" model="ir.sequence.type">
+ <field name="name">Repair Order</field>
+ <field name="code">mrp.repair</field>
+ </record>
+ <record id="seq_mrp_repair" model="ir.sequence">
+ <field name="name">Repair Order</field>
+ <field name="code">mrp.repair</field>
+ <field name="prefix">RMA</field>
+ <field name="padding">5</field>
+ </record>
+ </data>
+</openerp>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="view_repair_order_form" model="ir.ui.view">
+ <field name="name">mrp.repair.form</field>
+ <field name="model">mrp.repair</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Repairs order">
+ <group col="6" colspan="4">
+ <field name="name"/>
+ <newline/>
+ <field name="product_id" select="1" on_change="onchange_product_id(product_id)"/>
+ <field name="prodlot_id" select="2" on_change="onchange_lot_id(prodlot_id,product_id)"/>
+ <field name="repaired"/>
+ <field name="partner_id" select="2" on_change="onchange_partner_id(partner_id)" />
+ <field name="address_id"/>
+ <field name="invoiced"/>
+ </group>
+ <notebook colspan="4">
+ <page string="Products">
+ <field name="location_id"/>
+ <field name="move_id" on_change="onchange_move_id(product_id, move_id)"/>
+ <field name="location_dest_id"/>
+ <field name="guarantee_limit" />
+ <newline/>
+ <separator colspan="4" string="Operations"/>
+ <field colspan="4" mode="tree,form" name="operations" nolabel="1" widget="one2many_list">
+ <form string="Operations">
+ <notebook>
+ <page string="Repair Line">
+ <field name="name" colspan="4"/>
+ <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)" colspan="4"/>
+ <field name="product_uom_qty" string="Qty" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)"/>
+ <field name="product_uom" string="UoM"/>
+ <field name="price_unit"/>
+ <field name="price_subtotal"/>
+ <field name="location_id"/>
+ <field name="location_dest_id"/>
+ <newline/>
+ <field name="type" on_change="onchange_operation_type(type,parent.guarantee_limit)"/>
+ <group colspan="2">
+ <field name="to_invoice"/>
+ <field name="invoiced"/>
+ </group>
+ <newline/>
+ <field colspan="4" name="tax_id" domain="[('parent_id','=',False)]"/>
+ <separator colspan="4" string="States"/>
+ <field name="state"/>
+ </page>
+ <page string="History" groups="base.group_extended">
+ <separator colspan="4" string="Invoice Lines"/>
+ <field colspan="4" name="invoice_line_id" nolabel="1"/>
+
+ <separator colspan="4" string="Stock Moves"/>
+ <field colspan="4" name="move_ids" nolabel="1" widget="many2many"/>
+ </page>
+
+ </notebook>
+ </form>
+ <tree string="Operations lines" editable="bottom">
+ <field name="type" on_change="onchange_operation_type(type,parent.guarantee_limit)"/>
+ <field name='name'/>
+ <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)"/>
+ <field name="location_id"/>
+ <field name="location_dest_id"/>
+ <field name="product_uom_qty" string="Qty" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)"/>
+ <field name="product_uom" string="UoM"/>
+ <field name="price_unit"/>
+ <field name="price_subtotal"/>
+ <field name="to_invoice"/>
+ </tree>
+ </field>
+ <newline/>
+ <group col="7" colspan="4">
+ <field name="amount_untaxed" sum="Untaxed amount"/>
+ <field name="amount_tax"/>
+ <field name="amount_total" sum="Total amount"/>
+ <button name="button_dummy" states="draft" string="Compute" type="object"/>
+ </group>
+ <newline/>
+ <group col="13" colspan="4">
+ <field name="state" select="2"/>
+ <button name="repair_confirm" states="draft" string="Confirm Repair"/>
+ <button name="repair_ready" states="confirmed" string="Ready to Repair"/>
+ <button name="action_repair_start" states="ready" string="Start Repair"/>
+ <button name="action_repair_end" states="under_repair" string="End Repair"/>
+ <button name="invoice_recreate" states="invoice_except" string="Recreate Invoice"/>
+ <button name="invoice_corrected" states="invoice_except" string="Invoice Corrected"/>
+ <button name="action_invoice_create" states="2binvoiced" string="Make Invoice"/>
+ <button name="%(action_cancel_repair)d" states="invoice_except" string="Cancel Repair" type="action"/>
+ <button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
+ <button name="cancel" states="draft" string="Cancel Repair"/>
+ <button name="%(action_cancel_repair)d" states="confirmed,2binvoiced,ready,under_repair" string="Cancel Repair" type="action"/>
+ </group>
+ </page>
+ <page string="Invoicing">
+ <field name="pricelist_id" context="product_id=product_id"/>
+ <field name="partner_invoice_id"/>
+ <field name="invoice_method"/>
+ <field name="invoice_id"/>
+ <separator colspan="4" string="Fees"/>
+ <field colspan="4" mode="tree,form" name="fees_lines" nolabel="1" widget="one2many_list">
+ <form string="Fees Line">
+ <notebook>
+ <page string="Fees Line">
+ <field name='name'/>
+ <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id,parent.guarantee_limit)" colspan="4"/>
+ <field name="product_uom_qty" string="Qty" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id,parent.guarantee_limit)"/>
+ <field name="product_uom" string="UoM" />
+ <field name="price_unit"/>
+ <field name="price_subtotal"/>
+ <newline/>
+ <group colspan="2">
+ <field name="to_invoice"/>
+ <field name="invoiced"/>
+ </group>
+ <newline/>
+ <field colspan="4" name="tax_id" domain="[('parent_id','=',False)]"/>
+ </page>
+ <page string="History" groups="base.group_extended">
+ <field colspan="4" name="invoice_line_id" />
+ </page>
+ </notebook>
+ </form>
+ <tree string="Fees lines" editable="bottom">
+ <field name='name'/>
+ <field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id,parent.guarantee_limit)"/>
+ <field name="product_uom_qty" string="Qty" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id,parent.guarantee_limit)"/>
+ <field name="product_uom" string="UoM"/>
+ <field name="price_unit"/>
+ <field name="price_subtotal"/>
+ <field name="to_invoice"/>
+ </tree>
+ </field>
+ </page>
+ <page string="Quality">
+ <separator colspan="4" string="Internal Notes"/>
+ <field colspan="4" name="internal_notes" nolabel="1"/>
+ <separator colspan="4" string="Quotation Notes"/>
+ <field colspan="4" name="quotation_notes" nolabel="1"/>
+ </page>
+ <page string="History" groups="base.group_extended">
+ <!-- <field name="invoice_id"/> -->
+ <field name="picking_id"/>
+ </page>
+ </notebook>
+ </form>
+ </field>
+ </record>
+
+ <record id="view_repair_order_tree" model="ir.ui.view">
+ <field name="name">mrp.repair.tree</field>
+ <field name="model">mrp.repair</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Repairs order">
+ <field name="name" select="1" />
+ <field name="product_id" select="1" />
+ <field name="prodlot_id" select="2"/>
+ <field name="partner_id" select="2"/>
+ <field name="address_id"/>
+ <field name="location_id"/>
+ <field name="state" select="2"/>
+ <field name="move_id"/>
+ <field name="location_dest_id"/>
+ <field name="guarantee_limit"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="action_repair_order_form" model="ir.actions.act_window">
+ <field name="name">New Repair</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">mrp.repair</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form,tree</field>
+ </record>
+
+ <record id="action_repair_order_tree" model="ir.actions.act_window">
+ <field name="name">Repair Orders</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">mrp.repair</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <record id="action_repair_quotation_tree" model="ir.actions.act_window">
+ <field name="name">Repairs in quotation</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">mrp.repair</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="domain">[('state','=','draft')]</field>
+ </record>
+
+ <record id="action_repair_progress_tree" model="ir.actions.act_window">
+ <field name="name">Repairs in progress</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">mrp.repair</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="domain">[('state','=','confirmed')]</field>
+ </record>
+
+ <record id="action_repair_2binvoiced_tree" model="ir.actions.act_window">
+ <field name="name">Repairs to be invoiced</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">mrp.repair</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="domain">[('state','=','2binvoiced')]</field>
+ </record>
+
+ <menuitem action="action_repair_order_tree" id="menu_repair_order" parent="mrp.menu_mrp_root" name="Repairs"/>
+
+ <menuitem action="action_repair_quotation_tree" id="menu_repair_quotation" parent="menu_repair_order"/>
+
+ <menuitem action="action_repair_progress_tree" id="menu_repair_progress" parent="menu_repair_order"/>
+
+ <menuitem action="action_repair_2binvoiced_tree" id="menu_repair_2binvoiced" parent="menu_repair_order"/>
+
+ <menuitem action="action_repair_order_form" id="menu_repair_form" parent="menu_repair_order" sequence = "50"/>
+
+
+ </data>
+</openerp>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <wizard
+ id="action_cancel_repair"
+ model="mrp.repair"
+ name="mrp.repair.cancel"
+ string="Cancel Repair"
+ menu = "False"
+ multi = "True"
+ />
+ <wizard
+ id="wizard_mrp_repair_make_invoice"
+ keyword="client_action_multi"
+ model="mrp.repair"
+ name="mrp.repair.make_invoice"
+ multi="True"
+ string="Make invoices"/>
+
+ </data>
+</openerp>
+
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record id="wkf_repair" model="workflow">
+ <field name="name">mrp.repair.basic</field>
+ <field name="osv">mrp.repair</field>
+ <field name="on_create">True</field>
+ </record>
+
+ <!-- Activity -->
+ <record id="act_draft" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="flow_start">True</field>
+ <field name="name">draft</field>
+ </record>
+
+ <record id="act_confirm" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">confirm</field>
+ <field name="kind">function</field>
+ <field name="action">action_confirm()</field>
+ <field name="split_mode">OR</field>
+ </record>
+ <record id="act_wait_invoice" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">wait_invoice</field>
+ </record>
+ <record id="act_wait_repair" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">wait_repair</field>
+ </record>
+
+ <record id="act_done" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">done</field>
+ <field name="flow_stop">True</field>
+ <field name="kind">function</field>
+ <field name="action">wkf_repair_done()</field>
+ <field name="join_mode">XOR</field>
+ </record>
+ <!-- <record id="act_invoice" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">invoice</field>
+ <field name="kind">subflow</field>
+ <field name="subflow_id" search="[('name','=','account.invoice.basic')]"/>
+ <field name="action">action_invoice_create()</field>
+ </record> -->
+ <record id="act_repair_start" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">Start Repair</field>
+ <field name="kind">function</field>
+ <field name="action">action_repair_start()</field>
+ </record>
+ <record id="act_repair_ready" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">Ready Repair</field>
+ <field name="kind">function</field>
+ <field name="action">action_repair_ready()</field>
+ </record>
+
+
+
+ <record id="act_invoice_end" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">invoice_end</field>
+ <field name="kind">function</field>
+ <field name="action">wkf_invoice_create()</field>
+ </record>
+ <record id="act_repair_end" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">repair_end</field>
+ <field name="kind">function</field>
+ <field name="action">action_repair_end()</field>
+ </record>
+
+ <!-- <record id="act_invoice_cancel" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">invoice_cancel</field>
+ <field name="flow_stop">True</field>
+ <field name="kind">stopall</field>
+ <field name="action">action_cancel()</field>
+ </record>
+ <record id="act_invoice_except" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">invoice_except</field>
+ <field name="kind">function</field>
+ <field name="action">action_invoice_cancel()</field>
+ </record> -->
+
+
+
+ <record id="act_cancel" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">cancel</field>
+ <field name="flow_stop">True</field>
+ <field name="kind">stopall</field>
+ <field name="action">action_cancel()</field>
+ </record>
+ <record id="act_cancel2" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">cancel2</field>
+ <field name="flow_stop">True</field>
+ <field name="kind">stopall</field>
+ <field name="action">action_cancel()</field>
+ </record>
+ <record id="act_cancel3" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_repair"/>
+ <field name="name">cancel3</field>
+ <field name="flow_stop">True</field>
+ <field name="kind">stopall</field>
+ <field name="action">action_cancel()</field>
+ </record>
+
+ <!-- Transistion -->
+
+
+ <record id="trans_draft_confirm" model="workflow.transition">
+ <field name="act_from" ref="act_draft"/>
+ <field name="act_to" ref="act_confirm"/>
+ <field name="signal">repair_confirm</field>
+ </record>
+
+ <record id="trans_draft_cancel" model="workflow.transition">
+ <field name="act_from" ref="act_draft"/>
+ <field name="act_to" ref="act_cancel"/>
+ <field name="signal">cancel</field>
+ </record>
+
+ <record id="trans_confirm_wait_invoice" model="workflow.transition">
+ <field name="act_from" ref="act_confirm"/>
+ <field name="act_to" ref="act_wait_invoice"/>
+ <field name="condition">invoice_method=='b4repair'</field>
+ </record>
+
+ <record id="trans_confirm_wait_ship" model="workflow.transition">
+ <field name="act_from" ref="act_confirm"/>
+ <field name="act_to" ref="act_wait_repair"/>
+ <field name="condition">(invoice_method=='after_repair' or invoice_method=='none')</field>
+ </record>
+
+ <!-- <record id="trans_confirm_wait_invoice_shipping" model="workflow.transition">
+ <field name="act_from" ref="act_wait_invoice"/>
+ <field name="act_to" ref="act_invoice_end"/>
+ <field name="condition">(invoice_method=='none')</field>
+ </record> -->
+
+ <record id="trans_wait_invoice_invoice" model="workflow.transition">
+ <field name="act_from" ref="act_wait_invoice"/>
+ <field name="act_to" ref="act_invoice_end"/>
+ <field name="signal">action_invoice_create</field>
+ </record>
+ <record id="trans_invoice_start_repair" model="workflow.transition">
+ <field name="act_from" ref="act_invoice_end"/>
+ <field name="act_to" ref="act_repair_ready"/>
+ <field name="condition">invoice_method=='b4repair'</field>
+ </record>
+
+ <record id="trans_wait_invoice_cancel2" model="workflow.transition">
+ <field name="act_from" ref="act_wait_invoice"/>
+ <field name="act_to" ref="act_cancel2"/>
+ <field name="signal">cancel</field>
+ </record>
+
+
+
+ <record id="trans_invoice_end_done" model="workflow.transition">
+ <field name="act_from" ref="act_invoice_end"/>
+ <field name="act_to" ref="act_done"/>
+ <field name="condition">invoice_method=='after_repair'</field>
+ </record>
+
+
+
+ <record id="trans_wait_repair_ready" model="workflow.transition">
+ <field name="act_from" ref="act_wait_repair"/>
+ <field name="act_to" ref="act_repair_ready"/>
+ <field name="signal">repair_ready</field>
+ </record>
+ <record id="trans_ready_repair_start" model="workflow.transition">
+ <field name="act_from" ref="act_repair_ready"/>
+ <field name="act_to" ref="act_repair_start"/>
+ <field name="signal">action_repair_start</field>
+ </record>
+ <record id="trans_repair_repair_end" model="workflow.transition">
+ <field name="act_from" ref="act_repair_start"/>
+ <field name="act_to" ref="act_repair_end"/>
+ <field name="signal">action_repair_end</field>
+ </record>
+ <record id="trans_reapir_end_done" model="workflow.transition">
+ <field name="act_from" ref="act_repair_end"/>
+ <field name="act_to" ref="act_done"/>
+ <field name="condition">invoice_method=='none' or invoice_method=='b4repair'</field>
+ </record>
+ <record id="trans_reapir_end_invoice" model="workflow.transition">
+ <field name="act_from" ref="act_repair_end"/>
+ <field name="act_to" ref="act_wait_invoice"/>
+ <field name="condition">invoice_method=='after_repair'</field>
+ </record>
+
+ <record id="trans_wait_repair_cancel3" model="workflow.transition">
+ <field name="act_from" ref="act_wait_repair"/>
+ <field name="act_to" ref="act_cancel3"/>
+ <field name="signal">cancel</field>
+ </record>
+
+
+
+
+
+
+
+
+
+ </data>
+</openerp>
--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import order
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import time
+from report import report_sxw
+from osv import osv
+import pooler
+
+class order(report_sxw.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ super(order, self).__init__(cr, uid, name, context)
+ self.localcontext.update({
+ 'time': time,
+ 'total': self.total,
+ 'adr_get' : self._adr_get
+ })
+
+
+ def total(self, repair):
+ total = 0.0
+ for operation in repair.operations:
+ total+=operation.price_subtotal
+ for fee in repair.fees_lines:
+ total+=fee.price_subtotal
+ return total
+
+ def _adr_get(self, partner, type):
+ res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
+ res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
+ addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type])
+ adr_id = addresses and addresses[type] or False
+ return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
+
+report_sxw.report_sxw('report.repair.order','mrp.repair','addons/mrp_repair/report/order.rml',parser=order)
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
--- /dev/null
+<?xml version="1.0"?>
+<document filename="test.pdf">
+ <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
+ <pageTemplate id="first">
+ <frame id="first" x1="15.0" y1="42.0" width="539" height="758"/>
+ </pageTemplate>
+ </template>
+ <stylesheet>
+ <blockTableStyle id="Standard_Outline">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ </blockTableStyle>
+ <blockTableStyle id="AddressTable">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table2">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="0,0" stop="0,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="1,0" stop="1,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
+ <lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table3">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="0,0" stop="0,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="1,0" stop="1,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
+ <lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
+ <lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
+ </blockTableStyle>
+ <blockTableStyle id="HeadingTable">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table6">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table7">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table8">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table9">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table4">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ <lineStyle kind="LINEBEFORE" colorName="#ffffff" start="0,0" stop="0,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/>
+ <lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
+ <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
+ <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
+ <lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
+ <lineStyle kind="LINEBEFORE" colorName="#ffffff" start="0,1" stop="0,-1"/>
+ <lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
+ </blockTableStyle>
+ <blockTableStyle id="Table1">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ </blockTableStyle>
+ <initialize>
+ <paraStyle name="all" alignment="justify"/>
+ </initialize>
+ <paraStyle name="P1" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P2" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P3" fontName="Helvetica-Oblique" fontSize="7.0" leading="9" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P4" fontName="Helvetica-Oblique" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P5" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P6" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P7" fontName="Helvetica-Bold" fontSize="5.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P8" fontName="Helvetica-Bold" fontSize="7.0" leading="9" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P9" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P10" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P11" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="P12" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="P13" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P14" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="P15" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="P16" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="P17" fontName="Helvetica"/>
+ <paraStyle name="P18" fontName="Helvetica" fontSize="9.0" leading="11"/>
+ <paraStyle name="P19" fontName="Helvetica-Bold" fontSize="9.0" leading="11"/>
+ <paraStyle name="P20" fontName="Helvetica-Oblique" fontSize="2.0" leading="3"/>
+ <paraStyle name="P21" fontName="Helvetica-Oblique" fontSize="2.0" leading="3"/>
+ <paraStyle name="P22" fontName="Helvetica-Bold" fontSize="9.0" leading="11"/>
+ <paraStyle name="P23" fontName="Helvetica-Oblique" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P24" fontName="Helvetica" fontSize="2.0" leading="3"/>
+ <paraStyle name="P25" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT"/>
+ <paraStyle name="P26" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
+ <paraStyle name="P27" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P28" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P29" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P30" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P31" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P32" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P33" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P34" fontName="Helvetica" fontSize="5.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P35" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P36" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P37" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P38" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="P39" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="P40" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="P41" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="Standard" fontName="Times-Roman"/>
+ <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
+ <paraStyle name="Heading" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="12.0" spaceAfter="6.0"/>
+ <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
+ <paraStyle name="Table Contents" fontName="Times-Roman"/>
+ <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/>
+ <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="Index" fontName="Times-Roman"/>
+ <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="Footer" fontName="Times-Roman"/>
+ <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
+ <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
+ <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_1" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_Italic" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="Preformatted Text" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_right_bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
+ <paraStyle name="terp_default_centre_9_bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
+ </stylesheet>
+ <images/>
+ <story>
+ <para style="P9">[[ repeatIn(objects,'o') ]]</para>
+ <blockTable colWidths="265.0,51.0,225.0" style="AddressTable">
+ <tr>
+ <td>
+ <para style="P37">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
+ <para style="P10">Shipping address :[[ o.address_id.title or '' ]] [[ o.address_id.name ]]</para>
+ <para style="P1">[[ o.address_id.street ]]</para>
+ <para style="P1">[[ o.address_id.street2 or '' ]]</para>
+ <para style="P1">[[ o.address_id.city or '' ]] [[ o.address_id.zip or '' ]]</para>
+ <para style="P1">[[ o.address_id.state_id and o.address_id.state_id.name or '' ]] [[ o.address_id.country_id and o.address_id.country_id.name or '' ]]</para>
+ <para style="P1">
+ <font color="white"> </font>
+ </para>
+ <para style="P10">Invoice address :[[ o.partner_id and o.partner_id.property_payment_term.name and removeParentNode('para')]]</para>
+ <para style="P1">[[ o.partner_invoice_id.street ]] [[ o.partner_invoice_id.street2 and (', %s' % o.partner_invoice_id.street2 or '') ]]</para>
+ <para style="P1">[[ o.partner_invoice_id.zip or '' ]] [[ o.partner_invoice_id.city or '' ]] [[ o.partner_invoice_id.country_id and (', %s' % (o.partner_invoice_id.country_id and o.partner_invoice_id.country_id.name or '')) ]]</para>
+ </td>
+ <td>
+ <para style="P9">
+ <font color="white"> </font>
+ </para>
+ </td>
+ <td>
+ <para style="P19">[[ o.partner_id.name ]]</para>
+ <para style="P18">[[ o.partner_id and adr_get(o.partner_id, 'default')['name'] ]]</para>
+ <para style="P18">[[ o.partner_id and adr_get(o.partner_id, 'default')['street'] ]]</para>
+ <para style="P18">[[ o.partner_id and adr_get(o.partner_id, 'default')['zip'] ]] [[ o.partner_id and adr_get(o.partner_id, 'default')['city'] ]]</para>
+ <para style="P18">[[ o.partner_id and adr_get(o.partner_id, 'default')['country_id'] and adr_get(o.partner_id, 'default')['country_id'][1] ]]</para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="P9">
+ <font color="white"> </font>
+ </para>
+ <para style="P7">
+ <font color="white"> </font>
+ </para>
+ <para style="P6">[[ o.state<>'draft' and removeParentNode('para') ]]Repair Quotation</para>
+ <para style="P26">[[ o.state=='draft' and removeParentNode('para') ]]Repair Order N° : [[ o.name ]]</para>
+ <para style="P8">
+ <font color="white"> </font>
+ </para>
+ <para style="P5">
+ <font color="white"> </font>
+ </para>
+ <blockTable colWidths="130.0,136.0,136.0,136.0" style="Table2">
+ <tr>
+ <td>
+ <para style="P12">Product to Repair </para>
+ </td>
+ <td>
+ <para style="P12">Lot Number</para>
+ </td>
+ <td>
+ <para style="P12">Guarantee Limit </para>
+ </td>
+ <td>
+ <para style="P12">Printing Date</para>
+ </td>
+ </tr>
+ </blockTable>
+ <blockTable colWidths="130.0,136.0,136.0,136.0" style="Table3">
+ <tr>
+ <td>
+ <para style="P13">[[ o.product_id.name or '' ]]</para>
+ </td>
+ <td>
+ <para style="P13">[[ o.prodlot_id.name or '' ]]</para>
+ </td>
+ <td>
+ <para style="P13">[[ o.guarantee_limit ]]</para>
+ </td>
+ <td>
+ <para style="P13">[[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="P9">
+ <font color="white"> </font>
+ </para>
+ <para style="P9">
+ <font color="white"> </font>
+ </para>
+ <blockTable colWidths="165.0,165.0,90.0,51.0,64.0" repeatRows="1" style="HeadingTable">
+ <tr>
+ <td>
+ <para style="P11">Product</para>
+ </td>
+ <td>
+ <para style="P11">VAT</para>
+ </td>
+ <td>
+ <para style="P14">Quantity</para>
+ </td>
+ <td>
+ <para style="P15">Unit Price</para>
+ </td>
+ <td>
+ <para style="P16">Price</para>
+ </td>
+ </tr>
+ </blockTable>
+ <section>
+ <para style="P32">
+ <font color="white"> </font>
+ </para>
+ <para style="P33">Operation Line(s)</para>
+ <blockTable colWidths="537.0" style="Table6">
+ <tr>
+ <td>
+ <para style="P4">[[ repeatIn(o.operations,'line') ]]</para>
+ <blockTable colWidths="35.0,130.0,165.0,90.0,51.0,64.0" style="Table7">
+ <tr>
+ <td>
+ <para style="P3">Add [[ ((line.type == 'add') or removeParentNode('para')) and '' ]] </para>
+ <para style="P3">Remove [[ ((line.type == 'remove') or removeParentNode('para')) and '' ]]</para>
+ </td>
+ <td>
+ <para style="P1">[[ line.product_id.name ]]</para>
+ </td>
+ <td>
+ <para style="P31">[[ ', '.join(map(lambda x: x.name, line.tax_id)) or '0.00' ]]</para>
+ </td>
+ <td>
+ <para style="P31">[[ line.product_uom_qty or '0.00' ]] [[ line.product_uom.name ]]</para>
+ </td>
+ <td>
+ <para style="P28">[[ line.price_unit ]]</para>
+ </td>
+ <td>
+ <para style="P29">[[ line.price_subtotal ]]</para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="P25">
+ <font color="white"> </font>
+ </para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="P34">
+ <font color="white"> </font>
+ </para>
+ </section>
+ <para style="P22">Fees Line(s)</para>
+ <blockTable colWidths="539.0" style="Table8">
+ <tr>
+ <td>
+ <para style="P23">[[ repeatIn(o.fees_lines,'fees') ]]</para>
+ <blockTable colWidths="35.0,130.0,165.0,90.0,51.0,64.0" style="Table9">
+ <tr>
+ <td>
+ <para style="P23">
+ <font color="white"> </font>
+ </para>
+ </td>
+ <td>
+ <para style="P1">[[ fees.product_id.name ]]</para>
+ </td>
+ <td>
+ <para style="P31">[[ ', '.join(map(lambda x: x.name, fees.tax_id)) or '0.00' ]]</para>
+ </td>
+ <td>
+ <para style="P31">[[ fees.product_uom_qty or '0.00' ]] [[ fees.product_uom.name ]] </para>
+ </td>
+ <td>
+ <para style="P28">[[ fees.price_unit ]]</para>
+ </td>
+ <td>
+ <para style="P29">[[ fees.price_subtotal ]]</para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="P24">
+ <font color="white"> </font>
+ </para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="P21">
+ <font color="white"> </font>
+ </para>
+ <para style="P20">
+ <font color="white"> </font>
+ </para>
+ <blockTable colWidths="436.0,39.0,40.0,22.0" style="Table4">
+ <tr>
+ <td>
+ <para style="P1">
+ <font color="white"> </font>
+ </para>
+ </td>
+ <td>
+ <para style="P35">Total :</para>
+ </td>
+ <td>
+ <para style="P27">[[ total(o) ]] </para>
+ </td>
+ <td>
+ <para style="P30">[[ o.pricelist_id.currency_id.name ]]</para>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <para style="P1">
+ <font color="white"> </font>
+ </para>
+ </td>
+ <td>
+ <para style="P35">
+ <font color="white"> </font>
+ </para>
+ </td>
+ <td>
+ <para style="P27">
+ <font color="white"> </font>
+ </para>
+ </td>
+ <td>
+ <para style="P30">
+ <font color="white"> </font>
+ </para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="Standard">
+ <font color="white"> </font>
+ </para>
+ <blockTable colWidths="43.0,492.0" style="Table1">
+ <tr>
+ <td>
+ <para style="P2">Notes : </para>
+ </td>
+ <td>
+ <para style="P1">[[ format(o.quotation_notes or '') ]]</para>
+ </td>
+ </tr>
+ </blockTable>
+ <para style="P17">
+ <font color="white"> </font>
+ </para>
+ </story>
+</document>
--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import wizard_cancel_repair
+import wizard_make_invoice
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import wizard
+import netsvc
+import pooler
+
+cancel_form = """<?xml version="1.0"?>
+<form string="Cancel Repair...??">
+ <label colspan="4" string="This operation will cancel the Repair process, but will not cancel it's Invoice.\nDo you want to continue?" />
+</form>
+"""
+
+cancel_fields = {}
+
+def check_state(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])[0]
+ if repair_obj.invoice_id:
+ return 'display'
+ else:
+ pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
+ return 'end'
+
+
+def _cancel_repair(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])
+ pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
+ mrp_line_obj = pool.get('mrp.repair.line')
+ for line in repair_obj:
+ mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'})
+ return {}
+
+class repair_cancel(wizard.interface):
+ states = {
+ 'init' : {
+ 'actions' : [],
+ 'result' : {'type' : 'choice', 'next_state' : check_state}
+ },
+
+ 'display' : {
+ 'actions' : [],
+ 'result' : {'type' : 'form',
+ 'arch' : cancel_form,
+ 'fields' : cancel_fields,
+ 'state' : [('end', 'No'),('yes', 'Yes') ]}
+ },
+ 'yes' : {
+ 'actions' : [],
+ 'result' : {'type' : 'action',
+ 'action' : _cancel_repair,
+ 'state' : 'end'}
+ },
+ 'end' : {
+ 'actions' : [],
+ 'result': {'type': 'state', 'state': 'end'},
+ },
+ }
+repair_cancel("mrp.repair.cancel")
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
--- /dev/null
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import wizard
+import netsvc
+import pooler
+
+invoice_form = """<?xml version="1.0"?>
+<form string="Create invoices">
+ <separator colspan="4" string="Do you really want to create the invoices ?" />
+ <field name="group"/>
+</form>
+"""
+invoice_fields = {
+ 'group': {
+ 'string': 'Group by partner invoice address',
+ 'type':'boolean'
+ },
+}
+
+ack_form = """<?xml version="1.0"?>
+<form string="Create invoices">
+ <separator string="Invoices created" />
+</form>"""
+
+ack_fields = {}
+
+def _makeInvoices(self, cr, uid, data, context):
+ order_obj = pooler.get_pool(cr.dbname).get('mrp.repair')
+ newinv = order_obj.action_invoice_create(cr, uid, data['ids'],group=data['form']['group'],context=context)
+
+ return {
+ 'domain': [('id','in', newinv.values())],
+ 'name': 'Invoices',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.invoice',
+ 'view_id': False,
+ 'context': "{'type':'out_refund'}",
+ 'type': 'ir.actions.act_window'
+ }
+
+
+class make_invoice(wizard.interface):
+ states = {
+ 'init' : {
+ 'actions' : [],
+ 'result' : {'type' : 'form',
+ 'arch' : invoice_form,
+ 'fields' : invoice_fields,
+ 'state' : [('end', 'Cancel'),('invoice', 'Create invoices') ]}
+ },
+ 'invoice' : {
+ 'actions' : [],
+ 'result' : {'type' : 'action',
+ 'action' : _makeInvoices,
+ 'state' : 'end'}
+ },
+ }
+make_invoice("mrp.repair.make_invoice")
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+