diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 21f5b96848b..453ec9e9067 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -692,17 +692,7 @@ class account_move_line(osv.osv): def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if not context: context={} - raise_ex=False - if ('debit' in vals and 'credit' in vals) and not vals['debit'] and not vals['credit']: - raise_ex=True - if ('debit' in vals and 'credit' not in vals) and not vals['debit']: - raise_ex=True - if ('credit' in vals and 'debit' not in vals) and not vals['credit']: - raise_ex=True - - if raise_ex: - raise osv.except_osv(_('Wrong Accounting Entry!'), _('Both Credit and Debit cannot be zero!')) account_obj = self.pool.get('account.account') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 66353a7e168..7ebdbfeb98b 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -77,7 +77,6 @@ class mrp_repair(osv.osv): 'state': fields.selection([ ('draft','Quotation'), ('confirmed','Confirmed'), - ('ready','Ready to Repair'), ('under_repair','Under Repair'), ('2binvoiced','To be Invoiced'), ('invoice_except','Invoice Exception'), @@ -204,14 +203,14 @@ class mrp_repair(osv.osv): } def get_last_move(lst_move): - while lst_move.move_dest_id and lst_move.state == 'done': + while lst_move.move_dest_id and lst_move.move_dest_id and lst_move.move_dest_id.picking_id.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 + date = move.picking_id.date_done limit = mx.DateTime.strptime(date, '%Y-%m-%d %H:%M:%S') + RelativeDateTime(months=product.warranty) return {'value': { 'location_id': move.location_dest_id.id, @@ -259,8 +258,8 @@ class mrp_repair(osv.osv): 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 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 @@ -337,10 +336,6 @@ class mrp_repair(osv.osv): 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 @@ -349,7 +344,7 @@ class mrp_repair(osv.osv): for order in self.browse(cr, uid, ids): val = {} if (order.invoice_method=='b4repair'): - val['state'] = 'ready' + val['state'] = 'under_repair' else: #val['state'] = 'done' pass @@ -363,7 +358,7 @@ class mrp_repair(osv.osv): 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' + val['state'] = 'confirmed' else: #val['state'] = 'done' pass @@ -381,13 +376,15 @@ class mrp_repair(osv.osv): picking = self.pool.get('stock.picking').create(cr, uid, { 'origin': repair.name, - 'state': 'assigned', + 'state': 'draft', '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 ? }) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'stock.picking', picking, 'button_confirm', cr) move_id = self.pool.get('stock.move').create(cr, uid, { 'name': repair.name, diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml index 360c905331b..d53a3ec5754 100644 --- a/addons/mrp_repair/mrp_repair_view.xml +++ b/addons/mrp_repair/mrp_repair_view.xml @@ -83,8 +83,7 @@