From 396bbe73e1dfdbb65789038f2709ff528e5af03a Mon Sep 17 00:00:00 2001 From: mtr Date: Tue, 23 Nov 2010 16:16:33 +0530 Subject: [PATCH 1/6] [ADD] Account_sequence: added installer files bzr revid: mtr@mtr-20101123104633-cnvoe6f8rm7ufq9c --- addons/account_sequence/__init__.py | 1 + addons/account_sequence/__openerp__.py | 2 +- addons/account_sequence/account_sequence.py | 2 +- .../account_sequence_installer.py | 63 +++++++++++++++++++ .../account_sequence_installer_view.xml | 51 +++++++++++++++ 5 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 addons/account_sequence/account_sequence_installer.py create mode 100644 addons/account_sequence/account_sequence_installer_view.xml diff --git a/addons/account_sequence/__init__.py b/addons/account_sequence/__init__.py index 535fb766048..b6707106d4b 100644 --- a/addons/account_sequence/__init__.py +++ b/addons/account_sequence/__init__.py @@ -20,5 +20,6 @@ ############################################################################## import account_sequence +import account_sequence_installer # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_sequence/__openerp__.py b/addons/account_sequence/__openerp__.py index 966cbcbc8ca..2cc6f50e138 100644 --- a/addons/account_sequence/__openerp__.py +++ b/addons/account_sequence/__openerp__.py @@ -30,7 +30,7 @@ 'website': 'http://www.openerp.com', 'depends': ['account'], 'init_xml': [], - 'update_xml': ['account_sequence_data.xml','account_sequence.xml'], + 'update_xml': ['account_sequence_data.xml','account_sequence_installer_view.xml','account_sequence.xml'], 'demo_xml': [], 'installable': True, 'active': False, diff --git a/addons/account_sequence/account_sequence.py b/addons/account_sequence/account_sequence.py index 309bf3bc803..ee3afa380c1 100644 --- a/addons/account_sequence/account_sequence.py +++ b/addons/account_sequence/account_sequence.py @@ -46,7 +46,7 @@ class account_journal(osv.osv): _inherit = "account.journal" _columns = { - 'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence'), + 'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used to maintain the internal number for the journal entries related to this journal."), } account_journal() diff --git a/addons/account_sequence/account_sequence_installer.py b/addons/account_sequence/account_sequence_installer.py new file mode 100644 index 00000000000..d07c0e481aa --- /dev/null +++ b/addons/account_sequence/account_sequence_installer.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 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 . +# +############################################################################## + +from osv import fields, osv + +class account_sequence_installer(osv.osv_memory): + _name = 'account.sequence.installer' + _inherit = 'res.config.installer' + + _columns = { + 'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used on Journals to maintain internal number for accounting entries."), + } + + def _get_internal_sequence(self, cr, uid, context): + obj_sequence = self.pool.get('ir.sequence') + seq_id = obj_sequence.search(cr, uid, [('name','=', 'Internal Sequence Journal')]) + for seq in obj_sequence.browse(cr, uid, seq_id): + if seq.id: + return seq.id + return False + + def execute(self, cr, uid, ids, context): + if context is None: + context = {} + res = super(account_sequence_installer, self).execute(cr, uid, ids, context=context) + jou_obj = self.pool.get('account.journal') + obj_sequence = self.pool.get('ir.sequence') + journal_ids = jou_obj.search(cr, uid, [('type','in',['sale','sale_refund','purchase','purchase_refund','cash', 'bank', 'general','situation'])]) + + for line in self.browse(cr, uid, ids): + for journal in jou_obj.browse(cr, uid, journal_ids): + if not journal.internal_sequence: + seq_id = obj_sequence.search(cr, uid, [('name','=', line.internal_sequence.name)]) + for seq in obj_sequence.browse(cr, uid, seq_id): + if seq.id: + jou_obj.write(cr, uid, [journal.id], {'internal_sequence': seq.id}) + return res + + _defaults = { + 'internal_sequence': _get_internal_sequence + } + +account_sequence_installer() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_sequence/account_sequence_installer_view.xml b/addons/account_sequence/account_sequence_installer_view.xml new file mode 100644 index 00000000000..566dfaa6bc5 --- /dev/null +++ b/addons/account_sequence/account_sequence_installer_view.xml @@ -0,0 +1,51 @@ + + + + + + account.sequence.installer.view + account.sequence.installer + form + + + +
+ Account Sequence Application Configuration +
+ + Configure Your Account Sequence Application + + + + + + You can enhance the Account Sequence Application by installing . + + + + + + Configure + +
+
+
+ + + Account Sequence Application Configuration + ir.actions.act_window + account.sequence.installer + + form + form + new + + + + + 3 + always + + +
+
From de80030a876bea0a0347ce6d93e6c8054aa56776 Mon Sep 17 00:00:00 2001 From: mtr Date: Tue, 23 Nov 2010 16:31:01 +0530 Subject: [PATCH 2/6] [IMP] Account_sequence: code cleaning bzr revid: mtr@mtr-20101123110101-pkttkomd1ma8chbm --- addons/account_sequence/__openerp__.py | 6 +++++- .../account_sequence/account_sequence_installer.py | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/account_sequence/__openerp__.py b/addons/account_sequence/__openerp__.py index 2cc6f50e138..1e3f91a7876 100644 --- a/addons/account_sequence/__openerp__.py +++ b/addons/account_sequence/__openerp__.py @@ -30,7 +30,11 @@ 'website': 'http://www.openerp.com', 'depends': ['account'], 'init_xml': [], - 'update_xml': ['account_sequence_data.xml','account_sequence_installer_view.xml','account_sequence.xml'], + 'update_xml': [ + 'account_sequence_data.xml', + 'account_sequence_installer_view.xml', + 'account_sequence.xml' + ], 'demo_xml': [], 'installable': True, 'active': False, diff --git a/addons/account_sequence/account_sequence_installer.py b/addons/account_sequence/account_sequence_installer.py index d07c0e481aa..b7b6954bcc1 100644 --- a/addons/account_sequence/account_sequence_installer.py +++ b/addons/account_sequence/account_sequence_installer.py @@ -31,7 +31,7 @@ class account_sequence_installer(osv.osv_memory): def _get_internal_sequence(self, cr, uid, context): obj_sequence = self.pool.get('ir.sequence') - seq_id = obj_sequence.search(cr, uid, [('name','=', 'Internal Sequence Journal')]) + seq_id = obj_sequence.search(cr, uid, [('name', '=', 'Internal Sequence Journal')]) for seq in obj_sequence.browse(cr, uid, seq_id): if seq.id: return seq.id @@ -43,21 +43,21 @@ class account_sequence_installer(osv.osv_memory): res = super(account_sequence_installer, self).execute(cr, uid, ids, context=context) jou_obj = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') - journal_ids = jou_obj.search(cr, uid, [('type','in',['sale','sale_refund','purchase','purchase_refund','cash', 'bank', 'general','situation'])]) + journal_ids = jou_obj.search(cr, uid, [('type', 'in', ['sale', 'sale_refund', 'purchase', 'purchase_refund', 'cash', 'bank', 'general', 'situation'])]) for line in self.browse(cr, uid, ids): for journal in jou_obj.browse(cr, uid, journal_ids): if not journal.internal_sequence: - seq_id = obj_sequence.search(cr, uid, [('name','=', line.internal_sequence.name)]) + seq_id = obj_sequence.search(cr, uid, [('name', '=', line.internal_sequence.name)]) for seq in obj_sequence.browse(cr, uid, seq_id): if seq.id: jou_obj.write(cr, uid, [journal.id], {'internal_sequence': seq.id}) return res _defaults = { - 'internal_sequence': _get_internal_sequence - } + 'internal_sequence': _get_internal_sequence + } account_sequence_installer() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From 6269b4aabed7e43f03b64f97c0656e0617bf01c6 Mon Sep 17 00:00:00 2001 From: mtr Date: Tue, 23 Nov 2010 19:12:18 +0530 Subject: [PATCH 3/6] [FIX] Sale: 'Recreate procurement' on shipping exception ignores partial deliveries lp bug: https://launchpad.net/bugs/674420 fixed bzr revid: mtr@mtr-20101123134218-qa6lf3us1c1k76zc --- addons/sale/sale.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 29826e1c293..27740cbd8ac 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -671,6 +671,8 @@ class sale_order(osv.osv): def action_ship_create(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") picking_id = False + move_obj = self.pool.get('stock.move') + proc_obj = self.pool.get('procurement.order') company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] @@ -742,7 +744,13 @@ class sale_order(osv.osv): }) proc_ids.append(proc_id) self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id}) - + + if line.state == 'exception': + for pick in order.picking_ids: + for moves in pick.move_lines: + if moves.state == 'cancel': + move_obj.write(cr, uid, [move_id], {'product_qty': moves.product_qty}) + proc_obj.write(cr, uid, [proc_id], {'product_qty': moves.product_qty, 'product_uos_qty': moves.product_qty}) val = {} for proc_id in proc_ids: wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) @@ -752,7 +760,8 @@ class sale_order(osv.osv): if order.state == 'shipping_except': val['state'] = 'progress' - + val['shipped'] = False + if (order.order_policy == 'manual'): for line in order.order_line: if (not line.invoiced) and (line.state not in ('cancel', 'draft')): From 5189d31000c6a809e6cef495e1dc9466e0b368f4 Mon Sep 17 00:00:00 2001 From: mtr Date: Wed, 24 Nov 2010 12:59:23 +0530 Subject: [PATCH 4/6] [IMP] account_sequence:_get_internal_sequence search using xml_id and search all journals without any domain bzr revid: mtr@mtr-20101124072923-ofkrd55uz1g15ild --- .../account_sequence/account_sequence_installer.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/account_sequence/account_sequence_installer.py b/addons/account_sequence/account_sequence_installer.py index b7b6954bcc1..16808565380 100644 --- a/addons/account_sequence/account_sequence_installer.py +++ b/addons/account_sequence/account_sequence_installer.py @@ -30,12 +30,11 @@ class account_sequence_installer(osv.osv_memory): } def _get_internal_sequence(self, cr, uid, context): - obj_sequence = self.pool.get('ir.sequence') - seq_id = obj_sequence.search(cr, uid, [('name', '=', 'Internal Sequence Journal')]) - for seq in obj_sequence.browse(cr, uid, seq_id): - if seq.id: - return seq.id - return False + mod_obj = self.pool.get('ir.model.data') + result = mod_obj.get_object_reference(cr, uid, 'account_sequence', 'internal_sequence_journal') + res = result[1] or False + return res + def execute(self, cr, uid, ids, context): if context is None: @@ -43,8 +42,7 @@ class account_sequence_installer(osv.osv_memory): res = super(account_sequence_installer, self).execute(cr, uid, ids, context=context) jou_obj = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') - journal_ids = jou_obj.search(cr, uid, [('type', 'in', ['sale', 'sale_refund', 'purchase', 'purchase_refund', 'cash', 'bank', 'general', 'situation'])]) - + journal_ids = jou_obj.search(cr, uid, []) for line in self.browse(cr, uid, ids): for journal in jou_obj.browse(cr, uid, journal_ids): if not journal.internal_sequence: From ec217d2593fe1e7790e82b4a16bb9020f5894bbe Mon Sep 17 00:00:00 2001 From: mtr Date: Wed, 24 Nov 2010 17:11:51 +0530 Subject: [PATCH 5/6] [IMP] sale:'Recreate procurement' on shipping exception now works with more than one sale order line bzr revid: mtr@mtr-20101124114151-mn9u8b0oyicaj0jr --- addons/sale/sale.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 27740cbd8ac..793d779ff8a 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -676,6 +676,7 @@ class sale_order(osv.osv): company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] + new_moves = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: @@ -724,6 +725,8 @@ class sale_order(osv.osv): 'note': line.notes, 'company_id': order.company_id.id, }) + new_moves.append(move_id) + if line.product_id: proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name': line.name, @@ -749,8 +752,9 @@ class sale_order(osv.osv): for pick in order.picking_ids: for moves in pick.move_lines: if moves.state == 'cancel': - move_obj.write(cr, uid, [move_id], {'product_qty': moves.product_qty}) - proc_obj.write(cr, uid, [proc_id], {'product_qty': moves.product_qty, 'product_uos_qty': moves.product_qty}) + for move_id in new_moves: + move_obj.write(cr, uid, [move_id], {'product_qty': moves.product_qty}) + proc_obj.write(cr, uid, [proc_id], {'product_qty': moves.product_qty, 'product_uos_qty': moves.product_qty}) val = {} for proc_id in proc_ids: wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) From 308394a14b1628474427ebe2b21486550c460375 Mon Sep 17 00:00:00 2001 From: mtr Date: Wed, 24 Nov 2010 18:07:51 +0530 Subject: [PATCH 6/6] [IMP] account_sequence:changes in the execute method and return of _get_internal_sequence method bzr revid: mtr@mtr-20101124123751-tga2tn6oy3ipewrn --- addons/account_sequence/account_sequence_installer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/account_sequence/account_sequence_installer.py b/addons/account_sequence/account_sequence_installer.py index 16808565380..482e193d8ef 100644 --- a/addons/account_sequence/account_sequence_installer.py +++ b/addons/account_sequence/account_sequence_installer.py @@ -32,7 +32,7 @@ class account_sequence_installer(osv.osv_memory): def _get_internal_sequence(self, cr, uid, context): mod_obj = self.pool.get('ir.model.data') result = mod_obj.get_object_reference(cr, uid, 'account_sequence', 'internal_sequence_journal') - res = result[1] or False + res = result and result[1] or False return res @@ -46,8 +46,7 @@ class account_sequence_installer(osv.osv_memory): for line in self.browse(cr, uid, ids): for journal in jou_obj.browse(cr, uid, journal_ids): if not journal.internal_sequence: - seq_id = obj_sequence.search(cr, uid, [('name', '=', line.internal_sequence.name)]) - for seq in obj_sequence.browse(cr, uid, seq_id): + for seq in obj_sequence.browse(cr, uid, [line.internal_sequence.id]): if seq.id: jou_obj.write(cr, uid, [journal.id], {'internal_sequence': seq.id}) return res