From 1ea07696714e43ae7b578df8c10252614581f9d9 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 1 Jun 2010 15:42:46 +0530 Subject: [PATCH 1/4] [IMP]: base_module_quality: Apply minor changes bzr revid: ksa@tinyerp.co.in-20100601101246-pnwln0zovpw6q887 --- addons/base_module_quality/pep8_test/pep8_test.py | 6 +++--- .../base_module_quality/pylint_test/pylint_test.py | 6 +++--- .../structure_test/structure_test.py | 6 +++--- addons/base_module_quality/terp_test/terp_test.py | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/addons/base_module_quality/pep8_test/pep8_test.py b/addons/base_module_quality/pep8_test/pep8_test.py index 52c04756382..4aaaaa7bddc 100644 --- a/addons/base_module_quality/pep8_test/pep8_test.py +++ b/addons/base_module_quality/pep8_test/pep8_test.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -48,7 +48,7 @@ PEP-8 Test , copyright of py files check, method can not call from loops list_files.append(os.path.join(i, j)) py_list = [] for file_py in list_files: - if file_py.split('.')[-1] == 'py' and not file_py.endswith('__init__.py') and not file_py.endswith('__terp__.py'): + if file_py.split('.')[-1] == 'py' and not file_py.endswith('__init__.py') and not file_py.endswith('__openerp__.py'): file_path = os.path.join(module_path, file_py) py_list.append(file_path) diff --git a/addons/base_module_quality/pylint_test/pylint_test.py b/addons/base_module_quality/pylint_test/pylint_test.py index 8dbbce0e2ce..12400dbb196 100644 --- a/addons/base_module_quality/pylint_test/pylint_test.py +++ b/addons/base_module_quality/pylint_test/pylint_test.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -50,7 +50,7 @@ class quality_test(base_module_quality.abstract_quality_check): flag = False self.result_details += '''%s'''%(self.get_style()) for file_py in list_files: - if file_py.split('.')[-1] == 'py' and not file_py.endswith('__init__.py') and not file_py.endswith('__terp__.py'): + if file_py.split('.')[-1] == 'py' and not file_py.endswith('__init__.py') and not file_py.endswith('__openerp__.py'): if not flag: flag = True file_path = os.path.join(module_path, file_py) diff --git a/addons/base_module_quality/structure_test/structure_test.py b/addons/base_module_quality/structure_test/structure_test.py index 466976f5d17..10b80aaacdd 100644 --- a/addons/base_module_quality/structure_test/structure_test.py +++ b/addons/base_module_quality/structure_test/structure_test.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -82,7 +82,7 @@ This test checks if the module satisfy tiny structure # module files calculation (module.py,module_view.xml,etc..) com_list = ['_unit_test.xml', '.py', '_view.xml', '_workflow.xml' , '_wizard.xml', '_report.xml', '_data.xml', '_demo.xml', '_security.xml', '_sequence.xml', '_graph.xml'] com_list = map(lambda x: module_name + x, com_list) - main_file = ['__init__.py', '__terp__.py'] + main_file = ['__init__.py', '__openerp__.py'] com_list.extend(main_file) module_dict['module'] = filter(lambda x: len(x.split(".")) > 1, module_dict['module']) score = self.get_score(module_dict['module'], com_list) diff --git a/addons/base_module_quality/terp_test/terp_test.py b/addons/base_module_quality/terp_test/terp_test.py index 993a80fe32b..a9747496dc1 100644 --- a/addons/base_module_quality/terp_test/terp_test.py +++ b/addons/base_module_quality/terp_test/terp_test.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -49,13 +49,13 @@ class quality_test(base_module_quality.abstract_quality_check): score = 1.0 feel_good_factor = 0 feel_bad_factor = 0 - if '__terp__.py' not in list_files: + if '__openerp__.py' not in list_files: self.no_terp = True - self.result += _("The module does not contain the __terp__.py file") + self.result += _("The module does not contain the __openerp__.py file") return None result_dict = {} result_dict1 = {} - terp_file = os.path.join(module_path,'__terp__.py') + terp_file = os.path.join(module_path,'__openerp__.py') res = eval(tools.file_open(terp_file).read()) terp_keys = ['category', 'name', 'description', 'author', 'website', 'update_xml', 'init_xml', 'depends', 'version', 'active', 'installable', 'demo_xml'] for key in terp_keys: @@ -117,7 +117,7 @@ class quality_test(base_module_quality.abstract_quality_check): self.result_details += self.get_result_details(result_dict) self.result_details += self.get_result_details(result_dict1) - return [_('__terp__.py file'), score] + return [_('__openerp__.pyfile'), score] def run_test(self, cr, uid, module_path): terp_score = self.run_test_terp(cr, uid, module_path) @@ -125,7 +125,7 @@ class quality_test(base_module_quality.abstract_quality_check): if self.score*100 < self.min_score: self.message = 'Score is below than minimal score(%s%%)' % self.min_score if terp_score: - self.result = self.get_result({'__terp__.py': terp_score}) + self.result = self.get_result({'__openerp__.py': terp_score}) return None def get_result(self, dict_terp): From 22f439416273eba39653e4e1cae38c0f10ca9887 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Wed, 2 Jun 2010 19:24:27 +0530 Subject: [PATCH 2/4] [IMP] Improvement in sale and mrp bzr revid: ksa@tinyerp.co.in-20100602135427-p8w2q3n3venurpbn --- .../account/wizard/account_invoice_state.py | 6 +- addons/mrp/mrp.py | 20 ++++--- addons/project/project.py | 7 +-- addons/purchase/purchase.py | 57 +++++++++---------- addons/sale/sale.py | 4 +- 5 files changed, 48 insertions(+), 46 deletions(-) diff --git a/addons/account/wizard/account_invoice_state.py b/addons/account/wizard/account_invoice_state.py index c3934e38db0..3b63ed843d1 100644 --- a/addons/account/wizard/account_invoice_state.py +++ b/addons/account/wizard/account_invoice_state.py @@ -37,11 +37,11 @@ class account_invoice_confirm(osv.osv_memory): context = {} pool_obj = pooler.get_pool(cr.dbname) data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) - + for record in data_inv: if record['state'] not in ('draft','proforma','proforma2'): raise osv.except_osv(_('Warning'), _("Selected Invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state!")) - wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_open', cr) + wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_open', cr) return {} account_invoice_confirm() @@ -61,7 +61,7 @@ class account_invoice_cancel(osv.osv_memory): wf_service = netsvc.LocalService('workflow') pool_obj = pooler.get_pool(cr.dbname) data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) - + for record in data_inv: if record['state'] in ('cancel','paid'): raise osv.except_osv(_('Warning'), _("Selected Invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state!")) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 685d289a194..701438f4c5b 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -20,6 +20,7 @@ ############################################################################## from mx import DateTime +from datetime import datetime, timedelta from osv import fields from osv import osv from tools.translate import _ @@ -117,9 +118,9 @@ class mrp_bom(osv.osv): """ Defines bills of material for a product. """ - _name = 'mrp.bom' + _name = 'mrp.bom' _description = 'Bill of Material' - + def _child_compute(self, cr, uid, ids, name, arg, context={}): """ Gets child bom. @param self: The object pointer @@ -419,7 +420,6 @@ class mrp_production(osv.osv): _name = 'mrp.production' _description = 'Manufacturing Order' _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,15 +647,19 @@ class mrp_production(osv.osv): """ Changes the production state to Ready and location id of stock move. @return: True """ + for production in self.browse(cr, uid, ids): + production = self.browse(cr, uid, [production.id])[0] + s_date = datetime.strptime(production.date_planned,'%Y-%m-%d %H:%M:%S') + for (id,name) in self.name_get(cr, uid, ids): - message = _('Manufacturing Order ') + " '" + name + "' "+ _("is ready to produce.") + message = _('Manufacturing Order ') + " '" + name + "' "+ _("scheduled the") + " " + message += s_date.strftime('%Y-%m-%d') + " " + _("for") + " " + production.product_id.default_code 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): - if production.move_prod_id: - move_obj.write(cr, uid, [production.move_prod_id.id], - {'location_id': production.location_dest_id.id}) + if production.move_prod_id: + move_obj.write(cr, uid, [production.move_prod_id.id], + {'location_id': production.location_dest_id.id}) return True def action_production_end(self, cr, uid, ids): diff --git a/addons/project/project.py b/addons/project/project.py index 61720675f49..43430f134ee 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -150,14 +150,14 @@ class project(osv.osv): if leave['date_start'] > leave['date']: return False return True - + def _check_escalation(self, cr, uid, ids): project_obj = self.browse(cr, uid, ids[0]) if project_obj.project_escalation_id: if project_obj.project_escalation_id.id == project_obj.id: return False - return True - + return True + _constraints = [ (_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date']), (_check_escalation, 'Error! You cannot assign escalation to the same project!', ['project_escalation_id']) @@ -261,7 +261,6 @@ 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 b886dc60a0e..3c09d748360 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -211,7 +211,6 @@ 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): @@ -223,7 +222,7 @@ class purchase_order(osv.osv): else: raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state'])) - # TODO: temporary fix in 5.0, to remove in 5.2 when subflows support + # TODO: temporary fix in 5.0, to remove in 5.2 when subflows support # automatically sending subflow.delete upon deletion wf_service = netsvc.LocalService("workflow") for id in unlink_ids: @@ -248,7 +247,7 @@ class purchase_order(osv.osv): return {'value':{'location_id': res, 'dest_address_id': False}} def onchange_partner_id(self, cr, uid, ids, part): - + if not part: return {'value':{'partner_address_id': False, 'fiscal_position': False}} addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default']) @@ -264,12 +263,12 @@ class purchase_order(osv.osv): #TODO: implement messages system def wkf_confirm_order(self, cr, uid, ids, context={}): todo = [] - for po in self.browse(cr, uid, ids): + for po in self.browse(cr, uid, ids): if not po.order_line: raise osv.except_osv(_('Error !'),_('You can not confirm purchase order without Purchase Order Lines.')) - for line in po.order_line: + for line in po.order_line: if line.state=='draft': - todo.append(line.id) + todo.append(line.id) current_name = self.name_get(cr, uid, ids)[0][1] self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context) for id in ids: @@ -313,13 +312,13 @@ class purchase_order(osv.osv): wf_service = netsvc.LocalService("workflow") for p_id in ids: # Deleting the existing instance of workflow for PO - wf_service.trg_delete(uid, 'purchase.order', p_id, cr) + wf_service.trg_delete(uid, 'purchase.order', p_id, cr) wf_service.trg_create(uid, 'purchase.order', p_id, cr) return True def action_invoice_create(self, cr, uid, ids, *args): res = False - + journal_obj = self.pool.get('account.journal') for o in self.browse(cr, uid, ids): il = [] @@ -437,7 +436,7 @@ class purchase_order(osv.osv): }) if order_line.move_dest_id: self.pool.get('stock.move').write(cr, uid, [order_line.move_dest_id.id], {'location_id':order.location_id.id}) - todo_moves.append(move) + todo_moves.append(move) self.pool.get('stock.move').action_confirm(cr, uid, todo_moves) self.pool.get('stock.move').force_assign(cr, uid, todo_moves) wf_service = netsvc.LocalService("workflow") @@ -459,26 +458,26 @@ class purchase_order(osv.osv): def do_merge(self, cr, uid, ids, context): - """ - To merge similar type of purchase orders. - Orders will only be merged if: - * Purchase Orders are in draft - * Purchase Orders belong to the same partner + """ + To merge similar type of purchase orders. + Orders will only be merged if: + * Purchase Orders are in draft + * Purchase Orders belong to the same partner * Purchase Orders are have same stock location, same pricelist - Lines will only be merged if: - * Order lines are exactly the same except for the quantity and unit + Lines will only be merged if: + * Order lines are exactly the same except for the quantity and unit @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs - @param context: A standard dictionary - + @param ids: the ID or list of IDs + @param context: A standard dictionary + @return: new purchase order id - - """ - wf_service = netsvc.LocalService("workflow") - def make_key(br, fields): + + """ + wf_service = netsvc.LocalService("workflow") + def make_key(br, fields): list_key = [] for field in fields: field_val = getattr(br, field) @@ -496,9 +495,9 @@ class purchase_order(osv.osv): return tuple(list_key) # compute what the new orders should contain - + new_orders = {} - + for porder in [order for order in self.browse(cr, uid, ids) if order.state == 'draft']: order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id')) new_order = new_orders.setdefault(order_key, ({}, [])) @@ -541,7 +540,7 @@ class purchase_order(osv.osv): o_line[field] = field_val o_line['uom_factor'] = order_line.product_uom and order_line.product_uom.factor or 1.0 - + allorders = [] for order_key, (order_data, old_ids) in new_orders.iteritems(): @@ -601,7 +600,7 @@ class purchase_order_line(osv.osv): 'invoiced': fields.boolean('Invoiced', readonly=True), 'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner"), 'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date") - + } _defaults = { 'product_qty': lambda *a: 1.0, @@ -692,7 +691,7 @@ class purchase_order_line(osv.osv): return res def action_confirm(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'confirmed'}, context) - return True + return True purchase_order_line() class mrp_procurement(osv.osv): @@ -700,7 +699,7 @@ class mrp_procurement(osv.osv): _columns = { 'purchase_id': fields.many2one('purchase.order', 'Latest Requisition'), } - + def action_po_assign(self, cr, uid, ids, context={}): """ This is action which call from workflow to assign purchase order to procurements @return: True diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 356bd69f679..a19f51c2f3c 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -510,12 +510,12 @@ class sale_order(osv.osv): def action_invoice_end(self, cr, uid, ids, context=None): if context is None: context = {} - + for order in self.browse(cr, uid, ids, context=context): for line in order.order_line: if line.state == 'exception': self.pool.get('sale.order.line').write(cr, uid, [line.id], {'state': 'confirmed'}, context=context) - + if order.state == 'invoice_except': self.write(cr, uid, [order.id], {'state' : 'progress'}, context=context) From 3eb13e257fa730c6edcd07594e9c30256a30aaf6 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Thu, 3 Jun 2010 13:13:49 +0530 Subject: [PATCH 3/4] [IMP] Task-869 Improvement Log Message for account bzr revid: ksa@tinyerp.co.in-20100603074349-dntnjmu7u98d3opy --- addons/account/invoice.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 313ea48433e..105810f4cbb 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -952,6 +952,11 @@ class account_invoice(osv.osv): def _log_event(self, cr, uid, ids, factor=1.0, name='Open Invoice'): #TODO: implement messages system + for invoice in self.browse(cr, uid, ids): + for (id,number) in self.name_get(cr, uid, ids): + inv_number = number.split('/')[-1] + message = _('Invoice ') + " '" + _('INV/')+ inv_number + "' "+ _("Opened,")+_('journal entries')+ "' " + invoice.move_id.name + "' "+_("Created") + self.log(cr, uid, id, message) return True def name_get(self, cr, uid, ids, context=None): From 51dbc8c418dbc5e6c149f4300840fb0e66d8d1c8 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Thu, 3 Jun 2010 17:26:42 +0530 Subject: [PATCH 4/4] [IMP] Task-849 Improvement log Message for account and mrp bzr revid: ksa@tinyerp.co.in-20100603115642-p6dqe7d57a1adekm --- addons/account/invoice.py | 21 +++++++++++++-------- addons/mrp/mrp.py | 26 +++++++++++++++----------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 105810f4cbb..2ff9759a434 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -862,7 +862,6 @@ class account_invoice(osv.osv): # make the invoice point to that move self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}) self.pool.get('account.move').post(cr, uid, [move_id]) - self._log_event(cr, uid, ids) return True def line_get_convert(self, cr, uid, x, part, date, context=None): @@ -916,6 +915,7 @@ class account_invoice(osv.osv): 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) + self._log_event(cr, uid, ids) return True def action_cancel(self, cr, uid, ids, *args): @@ -951,13 +951,18 @@ class account_invoice(osv.osv): return taxes.values() def _log_event(self, cr, uid, ids, factor=1.0, name='Open Invoice'): - #TODO: implement messages system - for invoice in self.browse(cr, uid, ids): - for (id,number) in self.name_get(cr, uid, ids): - inv_number = number.split('/')[-1] - message = _('Invoice ') + " '" + _('INV/')+ inv_number + "' "+ _("Opened,")+_('journal entries')+ "' " + invoice.move_id.name + "' "+_("Created") - self.log(cr, uid, id, message) - return True + for (invoice_id,number) in self.name_get(cr, uid, ids): + invoice = self.browse(cr,uid,invoice_id) + message = ("%s %s %s %s %s %s %s") % ( + _('Invoice'), + _("INV/"), + number.split('/')[-1], + _("Opened,"), + _('journal entries'), + invoice.move_id.name, + _("Created")) + self.log(cr, uid, invoice_id, message) + return True def name_get(self, cr, uid, ids, context=None): if not len(ids): diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 701438f4c5b..488132a8b78 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -647,19 +647,23 @@ class mrp_production(osv.osv): """ Changes the production state to Ready and location id of stock move. @return: True """ - for production in self.browse(cr, uid, ids): - production = self.browse(cr, uid, [production.id])[0] - s_date = datetime.strptime(production.date_planned,'%Y-%m-%d %H:%M:%S') - - for (id,name) in self.name_get(cr, uid, ids): - message = _('Manufacturing Order ') + " '" + name + "' "+ _("scheduled the") + " " - message += s_date.strftime('%Y-%m-%d') + " " + _("for") + " " + production.product_id.default_code - self.log(cr, uid, id, message) move_obj = self.pool.get('stock.move') self.write(cr, uid, ids, {'state': 'ready'}) - if production.move_prod_id: - move_obj.write(cr, uid, [production.move_prod_id.id], - {'location_id': production.location_dest_id.id}) + + for (production_id,name) in self.name_get(cr, uid, ids): + production = self.browse(cr, uid, production_id) + if production.move_prod_id: + move_obj.write(cr, uid, [production.move_prod_id.id], + {'location_id': production.location_dest_id.id}) + + message = ("%s %s %s %s %s %s") % ( + _('Manufacturing Order '), + name, + _("scheduled the"), + datetime.strptime(production.date_planned,'%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d'), + _("for"), + production.product_id.default_code) + self.log(cr, uid, production_id, message) return True def action_production_end(self, cr, uid, ids):