From bd46d32b0cb512dc634d8b49804e7320df765c95 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 19 May 2010 22:02:36 +0200 Subject: [PATCH] [IMP] Improving logging system for main messages bzr revid: fp@tinyerp.com-20100519200236-t7y7pefns8t7cp9f --- addons/account/account_invoice_workflow.xml | 2 +- addons/account/invoice.py | 8 ++++++++ addons/mrp/mrp.py | 6 +++++- addons/mrp_procurement/mrp_procurement.py | 4 ++-- addons/project/project.py | 1 + addons/purchase/purchase.py | 1 + addons/sale/sale.py | 13 ++++--------- addons/stock/stock.py | 13 ++++++++++++- 8 files changed, 34 insertions(+), 14 deletions(-) diff --git a/addons/account/account_invoice_workflow.xml b/addons/account/account_invoice_workflow.xml index 374a436e9ac..4c919765596 100644 --- a/addons/account/account_invoice_workflow.xml +++ b/addons/account/account_invoice_workflow.xml @@ -50,7 +50,7 @@ write({'state':'open'}) paid - write({'state':'paid'}) + confirm_paid() function subflow.paid diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 61383a8aac0..dbaa321f329 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -217,6 +217,7 @@ class account_invoice(osv.osv): _name = "account.invoice" _description = 'Invoice' _order = "number" + _log_create = True _columns = { 'name': fields.char('Description', size=64, select=True,readonly=True, states={'draft':[('readonly',False)]}), 'origin': fields.char('Source Document', size=64, help="Reference of the document that produced this invoice."), @@ -335,6 +336,13 @@ class account_invoice(osv.osv): else: raise orm.except_orm(_('UnknownError'), str(e)) + def confirm_paid(self, cr, uid, ids, context=None): + self.write(cr, uid, ids, {'state':'paid'}, context=context) + for (id,name) in self.name_get(cr, uid, ids): + message = _('Document ') + " '" + name + "' "+ _("has been paid.") + self.log(cr, uid, id, message) + return True + def unlink(self, cr, uid, ids, context=None): invoices = self.read(cr, uid, ids, ['state']) unlink_ids = [] diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index d8900592fe2..7ae3f30b07f 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -419,7 +419,8 @@ class mrp_production(osv.osv): """ _name = 'mrp.production' _description = 'Production' - _date_name = 'date_planned' + _date_name = 'date_planned' + _log_create = True def _production_calc(self, cr, uid, ids, prop, unknow_none, context={}): """ Calculates total hours and total no. of cycles for a production order. @@ -647,6 +648,9 @@ class mrp_production(osv.osv): """ Changes the production state to Ready and location id of stock move. @return: True """ + for (id,name) in self.name_get(cr, uid, ids): + message = _('Manufacturing Order ') + " '" + name + "' "+ _("is ready to produce.") + self.log(cr, uid, id, message) move_obj = self.pool.get('stock.move') self.write(cr, uid, ids, {'state': 'ready'}) for production in self.browse(cr, uid, ids): diff --git a/addons/mrp_procurement/mrp_procurement.py b/addons/mrp_procurement/mrp_procurement.py index 8285cfde597..fc47298d8f5 100644 --- a/addons/mrp_procurement/mrp_procurement.py +++ b/addons/mrp_procurement/mrp_procurement.py @@ -68,8 +68,8 @@ class mrp_procurement(osv.osv): """ _name = "mrp.procurement" _description = "Procurement" - _order = 'priority,date_planned' - + _order = 'priority,date_planned desc' + _log_create = False _columns = { 'name': fields.char('Reason', size=64, required=True, help='Procurement name.'), 'origin': fields.char('Source Document', size=64, diff --git a/addons/project/project.py b/addons/project/project.py index cae9849b3f5..a6c703657d0 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -251,6 +251,7 @@ project() class task(osv.osv): _name = "project.task" _description = "Task" + _log_create = True _date_name = "date_start" def _str_get(self, task, level=0, border='***', context={}): diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index b9e439517bb..6cc30883909 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -211,6 +211,7 @@ class purchase_order(osv.osv): } _name = "purchase.order" _description = "Purchase Order" + _log_create = True _order = "name desc" def unlink(self, cr, uid, ids, context=None): diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 4813062ca04..272ee0ecd70 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -52,6 +52,7 @@ def _incoterm_get(self, cr, uid, context=None): class sale_order(osv.osv): _name = "sale.order" + _log_create = True _description = "Sale Order" def copy(self, cr, uid, id, default=None, context=None): @@ -551,16 +552,10 @@ class sale_order(osv.osv): return True def action_wait(self, cr, uid, ids, *args): - event_p = self.pool.get('res.partner.event.type').check(cr, uid, 'sale_open') - event_obj = self.pool.get('res.partner.event') + for (id,name) in self.name_get(cr, uid, ids): + message = _('Quotation ') + " '" + name + "' "+ _("converted to sale order.") + self.log(cr, uid, id, message) for o in self.browse(cr, uid, ids): - if event_p: - event_obj.create(cr, uid, {'name': 'Sale Order: '+ o.name,\ - 'partner_id': o.partner_id.id,\ - 'date': time.strftime('%Y-%m-%d %H:%M:%S'),\ - 'user_id': (o.user_id and o.user_id.id) or uid,\ - 'partner_type': 'customer', 'probability': 1.0,\ - 'planned_revenue': o.amount_untaxed}) if (o.order_policy == 'manual'): self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': time.strftime('%Y-%m-%d')}) else: diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 6470ac9cedd..898df46e17b 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -402,6 +402,7 @@ stock_tracking() #---------------------------------------------------------- class stock_picking(osv.osv): _name = "stock.picking" + _log_create = True _description = "Picking List" def _set_maximum_date(self, cr, uid, ids, name, value, arg, context): @@ -599,7 +600,16 @@ class stock_picking(osv.osv): wf_service.trg_write(uid, 'stock.picking', pick.id, cr) return True - def action_assign_wkf(self, cr, uid, ids): + def action_assign_wkf(self, cr, uid, ids, context=None): + for pick in self.browse(cr, uid, ids, context=context): + type_list = { + 'out':'Packing List', + 'in':'Reception', + 'internal': 'Internal picking', + 'delivery': 'Delivery order' + } + message = type_list.get(pick.type, _('Document')) + " '" + pick.name + "' "+ _("is ready to be processed.") + self.log(cr, uid, id, message) self.write(cr, uid, ids, {'state': 'assigned'}) return True @@ -1153,6 +1163,7 @@ class stock_move(osv.osv): return (res and res[0]) or False _name = "stock.move" _description = "Stock Move" + _log_create = False def name_get(self, cr, uid, ids, context={}): res = []