From 2ab70b66aad4ec1ea296d2d52b02819ee9a6b5ad Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 25 Sep 2008 10:09:44 +0530 Subject: [PATCH 01/17] bug fix on move line and account_budget bzr revid: mra@tinyerp.com-20080925043944-ufpmg5fy162ntrms --- addons/account/account_move_line.py | 2 +- addons/account_budget/crossovered_budget.py | 47 +-------------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 12f3682cf56..f9d2dea38cc 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -481,7 +481,7 @@ class account_move_line(osv.osv): self_debit = -writeoff # If comment exist in context, take it - if context['comment']: + if 'comment' in context and context['comment']: libelle=context['comment'] else: libelle='Write-Off' diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py index 420926bbaf4..c5a81a2398b 100644 --- a/addons/account_budget/crossovered_budget.py +++ b/addons/account_budget/crossovered_budget.py @@ -208,51 +208,6 @@ class crossovered_budget_lines(osv.osv): } crossovered_budget_lines() - - -#class account_budget_post(osv.osv): #old code -# _name = 'account.budget.post' -# _inherit = 'account.budget.post' -# _columns = { -# 'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'general_budget_id', 'Budget Lines'), -# } -#account_budget_post() -# -#class account_budget_post_dotation(osv.osv): -# _name = 'account.budget.post.dotation' -# _inherit = 'account.budget.post.dotation' -# -# def _tot_planned(self, cr, uid, ids,name,args,context): -# res={} -# for line in self.browse(cr, uid, ids): -# if line.period_id: -# obj_period=self.pool.get('account.period').browse(cr, uid,line.period_id.id) -# -# total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start) -# budget_id=line.post_id and line.post_id.id or False -# query="select id from crossovered_budget_lines where general_budget_id= '"+ str(budget_id) + "' AND (date_from >='" +obj_period.date_start +"' and date_from <= '"+obj_period.date_stop + "') OR (date_to >='" +obj_period.date_start +"' and date_to <= '"+obj_period.date_stop + "') OR (date_from <'" +obj_period.date_start +"' and date_to > '"+obj_period.date_stop + "')" -# cr.execute(query) -# res1=cr.fetchall() -# -# tot_planned=0.00 -# for record in res1: -# obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid,record[0]) -# count_days = min(strToDate(obj_period.date_stop),strToDate(obj_lines.date_to)) - max(strToDate(obj_period.date_start), strToDate(obj_lines.date_from)) -# days_in_period = count_days.days +1 -# count_days = strToDate(obj_lines.date_to) - strToDate(obj_lines.date_from) -# total_days_of_rec = count_days.days +1 -# tot_planned += obj_lines.planned_amount/total_days_of_rec* days_in_period -# res[line.id]=tot_planned -# else: -# res[line.id]=0.00 -# return res -# -# _columns = { -# 'tot_planned':fields.function(_tot_planned,method=True, string='Total Planned Amount',type='float',store=True), -# } -# -#account_budget_post_dotation() - class account_analytic_account(osv.osv): _name = 'account.analytic.account' _inherit = 'account.analytic.account' @@ -266,7 +221,7 @@ account_analytic_account() #-------------------------------------------------------------- # moved from account/project/project.py # --------------------------------------------------------- -# Budgets +# Budgets. # --------------------------------------------------------- #class account_analytic_budget_post(osv.osv): From b347a98ee0b576e6358391a06a2c0e40a3f77775 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 25 Sep 2008 11:01:25 +0530 Subject: [PATCH 02/17] bug fix: - modify name_get method on account_move_reconcile object - account move line bug fix bzr revid: mra@tinyerp.com-20080925053125-pdg0711nfnnhbf3f --- addons/account/account.py | 20 +++++++++++++------- addons/account/account_move_line.py | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 94086e86742..61c0a77be3b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -924,15 +924,21 @@ class account_move_reconcile(osv.osv): {'reconcile_id': rec.id } ) return True + def name_get(self, cr, uid, ids, context=None): - result = {} + if not len(ids): + return [] + result = [] for r in self.browse(cr, uid, ids, context): total = reduce(lambda y,t: (t.debit or 0.0) - (t.credit or 0.0) + y, r.line_partial_ids, 0.0) if total: - result[r.id] = '%s (%.2f)' % (r.name, total) + name = '%s (%.2f)' % (r.name, total) + result.append((r.id,name)) else: - result[r.id] = r.name + result.append((r.id,r.name)) return result + + account_move_reconcile() #---------------------------------------------------------- @@ -1510,7 +1516,7 @@ class account_config_wizard(osv.osv_memory): } def install_account_chart(self, cr, uid,ids, context=None): - for res in self.read(cr,uid,ids): + for res in self.read(cr,uid,ids): id = res['charts'] def install(id): mod_obj = self.pool.get('ir.module.module') @@ -1558,7 +1564,7 @@ class account_config_wizard(osv.osv_memory): 'target':'new', } - + account_config_wizard() @@ -2036,8 +2042,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'res_model': 'ir.module.module.configuration.wizard', 'type': 'ir.actions.act_window', 'target':'new', - } - + } + wizard_multi_charts_accounts() diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index f9d2dea38cc..e55b6d54fee 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -629,7 +629,7 @@ class account_move_line(osv.osv): 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!')) if update_check: From d73304e6a5e888c102dd4f88bda08f1f65623cae Mon Sep 17 00:00:00 2001 From: Amit Mendapara Date: Thu, 25 Sep 2008 13:18:07 +0530 Subject: [PATCH 03/17] * Fixed process copy (duplicate) problem. bzr revid: ame@tinyerp.com-20080925074807-jrl338k65ce9vsav --- addons/process/process.py | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/addons/process/process.py b/addons/process/process.py index 1a0024af4b1..9417f927786 100644 --- a/addons/process/process.py +++ b/addons/process/process.py @@ -231,6 +231,44 @@ class process_process(osv.osv): return dict(title=title, perm=perm, notes=notes, nodes=nodes, transitions=transitions) + def copy(self, cr, uid, id, default=None, context={}): + """ Deep copy the entire process. + """ + + if not default: + default = {} + + pool = pooler.get_pool(cr.dbname) + process = pool.get('process.process').browse(cr, uid, [id], context)[0] + + nodes = {} + transitions = {} + + # first copy all nodes and and map the new nodes with original for later use in transitions + for node in process.node_ids: + for t in node.transition_in: + tr = transitions.setdefault(t.id, {}) + tr['target'] = node.id + for t in node.transition_out: + tr = transitions.setdefault(t.id, {}) + tr['source'] = node.id + nodes[node.id] = pool.get('process.node').copy(cr, uid, node.id, context=context) + + # then copy transitions with new nodes + for tid, tr in transitions.items(): + vals = { + 'source_node_id': nodes[tr['source']], + 'target_node_id': nodes[tr['target']] + } + tr = pool.get('process.transition').copy(cr, uid, tid, default=vals, context=context) + + # and finally copy the process itself with new nodes + default.update({ + 'active': True, + 'node_ids': [(6, 0, nodes.values())] + }) + return super(process_process, self).copy(cr, uid, id, default, context) + process_process() class process_node(osv.osv): @@ -256,6 +294,16 @@ class process_node(osv.osv): 'model_states': lambda *args: False, 'flow_start': lambda *args: False, } + + def copy(self, cr, uid, id, default=None, context={}): + if not default: + default = {} + default.update({ + 'transition_in': [], + 'transition_out': [] + }) + return super(process_node, self).copy(cr, uid, id, default, context) + process_node() class process_node_condition(osv.osv): From a3a7e64534036d8808c7fe7633a7f7c2624ffb98 Mon Sep 17 00:00:00 2001 From: Amit Mendapara Date: Thu, 25 Sep 2008 13:18:59 +0530 Subject: [PATCH 04/17] Fixed process. bzr revid: ame@tinyerp.com-20080925074859-l8vqvhfms0xz3i05 --- addons/process/process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/process/process.py b/addons/process/process.py index 9417f927786..e095ad041ae 100644 --- a/addons/process/process.py +++ b/addons/process/process.py @@ -204,7 +204,7 @@ class process_process(osv.osv): update_relatives(r, _id, _model) for nid, node in nodes.items(): - if node['active'] or node['model'] == res_model: + if not node['gray'] and (node['active'] or node['model'] == res_model): update_relatives(nid, res_id, res_model) break From 69e8722984911b36fddbf44559572d0e80473c13 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 25 Sep 2008 11:30:39 +0200 Subject: [PATCH 05/17] merge bzr revid: fp@tinyerp.com-20080925093039-vym41oibvd1ezys8 --- addons/stock/product.py | 10 ++++++++-- addons/stock/report/product_stock.py | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index d03a1c9a15c..0e2db338b9f 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -39,7 +39,10 @@ class product_product(osv.osv): return _('Products: ')+self.pool.get('stock.location').browse(cr, user, context['location'], context).name return res - def get_product_available(self,cr,uid,ids,context={}): + def get_product_available(self,cr,uid,ids,context=None): + if not context: + context = {} + print 'CONTEXT', context states=context.get('states',[]) what=context.get('what',()) if not ids: @@ -61,7 +64,10 @@ class product_product(osv.osv): context['location'] = res2[0] if context.get('location', False): - location_ids = [context['location']] + if type(context['location']) == type(1): + location_ids = [context['location']] + else: + location_ids = context['location'] else: cr.execute("select lot_stock_id from stock_warehouse") location_ids = [id for (id,) in cr.fetchall()] diff --git a/addons/stock/report/product_stock.py b/addons/stock/report/product_stock.py index 01d3d0b8290..71a13ab0490 100644 --- a/addons/stock/report/product_stock.py +++ b/addons/stock/report/product_stock.py @@ -79,6 +79,8 @@ class report_stock(report_int): for (qty, dt, prod_id) in cr.fetchall(): if dt<=dt_from: dt= (DateTime.now() + DateTime.RelativeDateTime(days=1)).strftime('%Y-%m-%d') + else: + dt = dt[:10] products.setdefault(prod_id, []) products[prod_id].append((dt,-qty)) @@ -86,6 +88,8 @@ class report_stock(report_int): for (qty, dt, prod_id) in cr.fetchall(): if dt<=dt_from: dt= (DateTime.now() + DateTime.RelativeDateTime(days=1)).strftime('%Y-%m-%d') + else: + dt = dt[:10] products.setdefault(prod_id, []) products[prod_id].append((dt,qty)) From b89d08b6297ffcf16c8d4b72539a5a91b7b5bf52 Mon Sep 17 00:00:00 2001 From: Amit Mendapara Date: Thu, 25 Sep 2008 11:40:23 +0200 Subject: [PATCH 06/17] Fixed process (temporary fix). bzr revid: ame@tinyerp.com-20080925094023-uejyduf4ivmdpt2a --- addons/process/process.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/process/process.py b/addons/process/process.py index e095ad041ae..d7a3eb7e369 100644 --- a/addons/process/process.py +++ b/addons/process/process.py @@ -199,9 +199,14 @@ class process_process(osv.osv): rel = refobj[n] if rel and isinstance(rel, list) : rel = rel[0] - _id = (rel or False) and rel.id - _model = node['model'] - update_relatives(r, _id, _model) + if isinstance(rel, basestring): + print "XXX: ", rel + try: # XXXXXXXXXXXXXXXXXXX + _id = (rel or False) and rel.id + _model = node['model'] + update_relatives(r, _id, _model) + except: + pass for nid, node in nodes.items(): if not node['gray'] and (node['active'] or node['model'] == res_model): From 79e22ccc72933e4f8bc7ab7fb1cb3446422172ab Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 25 Sep 2008 15:28:52 +0530 Subject: [PATCH 07/17] solve problem : - if you make invoice in 2008 fiscal year and then close that year..and create new fiscal year and in new fiscal year you pay that invoice that time..original invoice entries does not get paid and reconciled... bzr revid: mra@tinyerp.com-20080925095852-fh177c0td425yx49 --- addons/account/account_move_line.py | 12 +++++++++++- addons/account/account_view.xml | 14 +++++++++----- addons/account/wizard/wizard_fiscalyear_close.py | 10 ++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index e55b6d54fee..abade8c579c 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -305,6 +305,8 @@ class account_move_line(osv.osv): 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'), #TODO: remove this 'amount_taxed':fields.float("Taxed Amount",digits=(16,2)), + 'parent_move_lines':fields.many2many('account.move.line', 'account_move_line_rel', 'child_id', 'parent_id', 'Parent'), + 'reconcile_implicit':fields.boolean('Implicit Reconciliaiton') } def _get_date(self, cr, uid, context): @@ -435,7 +437,11 @@ class account_move_line(osv.osv): currency = 0.0 account_id = False partner_id = False + implicit_lines = [] for line in unrec_lines: + if line.parent_move_lines: + for i in line.parent_move_lines: + implicit_lines.append(i.id) if line.state <> 'valid': raise osv.except_osv(_('Error'), _('Entry "%s" is not valid !') % line.name) @@ -531,9 +537,13 @@ class account_move_line(osv.osv): 'line_id': map(lambda x: (4,x,False), ids), 'line_partial_ids': map(lambda x: (3,x,False), ids) }) + wf_service = netsvc.LocalService("workflow") + if implicit_lines: + self.write(cr, uid, implicit_lines, {'reconcile_implicit':True,'reconcile_id':r_id}) + for id in implicit_lines: + wf_service.trg_trigger(uid, 'account.move.line', id, cr) # the id of the move.reconcile is written in the move.line (self) by the create method above # because of the way the line_id are defined: (4, x, False) - wf_service = netsvc.LocalService("workflow") for id in ids: wf_service.trg_trigger(uid, 'account.move.line', id, cr) return r_id diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 62cb55b13e4..35d51003902 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -705,6 +705,10 @@ + + + + @@ -1354,10 +1358,10 @@ form form new - - + + + - @@ -1367,8 +1371,8 @@ Define Fiscal Years and Select Charts of Account open - - + + diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 455ab049649..e26410e1dae 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -110,7 +110,7 @@ def _data_save(self, cr, uid, data, context): offset = 0 limit = 100 while True: - cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \ + cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ @@ -123,10 +123,13 @@ def _data_save(self, cr, uid, data, context): if not result: break for move in result: + parent_id = move['id'] + move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, + 'parent_move_lines':[(6,0,[parent_id])] }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, @@ -137,7 +140,7 @@ def _data_save(self, cr, uid, data, context): offset = 0 limit = 100 while True: - cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \ + cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ @@ -149,10 +152,13 @@ def _data_save(self, cr, uid, data, context): if not result: break for move in result: + parent_id = move['id'] + move.pop('id') move.update({ 'date': period.date_start, 'journal_id': new_journal.id, 'period_id': period.id, + 'parent_move_lines':[(6,0,[parent_id])] }) pool.get('account.move.line').create(cr, uid, move) offset += limit From d286f601cb4c6c36c14f28acbc0b683e5acec448 Mon Sep 17 00:00:00 2001 From: "hda@tinyerp.com" <> Date: Thu, 25 Sep 2008 16:57:34 +0530 Subject: [PATCH 08/17] Added pricelists on product form bzr revid: hda@tinyerp.com-20080925112734-3cu3io9c1de22em0 --- addons/sale/__init__.py | 1 + addons/sale/__terp__.py | 1 + addons/sale/product.py | 84 ++++++++++++++++++++++++++++++++++++ addons/sale/product_view.xml | 33 ++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 addons/sale/product.py create mode 100644 addons/sale/product_view.xml diff --git a/addons/sale/__init__.py b/addons/sale/__init__.py index b3718c6b3d0..7b962130480 100644 --- a/addons/sale/__init__.py +++ b/addons/sale/__init__.py @@ -35,6 +35,7 @@ import sale import stock import partner +import product import wizard import report diff --git a/addons/sale/__terp__.py b/addons/sale/__terp__.py index d5bc58a98ae..f540f33ea4b 100644 --- a/addons/sale/__terp__.py +++ b/addons/sale/__terp__.py @@ -62,6 +62,7 @@ "sale_report.xml", "sale_wizard.xml", "stock_view.xml", + "product_view.xml", ], "active": False, "installable": True diff --git a/addons/sale/product.py b/addons/sale/product.py new file mode 100644 index 00000000000..5054aabeabf --- /dev/null +++ b/addons/sale/product.py @@ -0,0 +1,84 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id$ +# +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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 2 +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from osv import fields, osv +from tools import config + +class product_pricelist(osv.osv): + _inherit = "product.pricelist" + def _compute_price(self, cr, uid, ids, field_name, arg, context): + res = {} + for id in ids: + res[id]=0.0 + return res + _columns = { + 'price': fields.function(_compute_price, type='float', method=True, string='Price', digits=(16, int(config['price_accuracy']))), + } +product_pricelist() + +class product_product(osv.osv): + _name = 'product.product' + _inherit = 'product.product' + + def _pricelist_sale_ids(self, cr, uid, ids, name, arg, context=None): + result = {} + if not context: + context={} + pricelist_obj=self.pool.get('product.pricelist') + for product in self.browse(cr, uid, ids, context): + pricelist_ids=pricelist_obj.search(cr,uid,[('type','=','sale')], context=context) + result[product.id]=pricelist_ids + return result + + def _pricelist_purchase_ids(self, cr, uid, ids, name, arg, context=None): + result = {} + pricelist_obj=self.pool.get('product.pricelist') + for product in self.browse(cr, uid, ids, context): + pricelist_ids=pricelist_obj.search(cr,uid,[('type','=','purchase')]) + result[product.id]=pricelist_ids + return result + + _columns = { + 'pricelist_sale':fields.function( + _pricelist_sale_ids, + method=True, + relation='product.pricelist', + string='Sale Pricelists', + type="many2many"), + 'pricelist_purchase':fields.function( + _pricelist_purchase_ids, + method=True, + relation='product.pricelist', + string='Purchase Pricelists', + type="many2many"), + } + +product_product() diff --git a/addons/sale/product_view.xml b/addons/sale/product_view.xml new file mode 100644 index 00000000000..8282544c35e --- /dev/null +++ b/addons/sale/product_view.xml @@ -0,0 +1,33 @@ + + + + + + view.product.pricelists.function.form.inherit + product.product + form + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 18059ab81771faadfa08db1a7896fc2863b68e28 Mon Sep 17 00:00:00 2001 From: Jay Vora Date: Thu, 25 Sep 2008 18:32:10 +0530 Subject: [PATCH 09/17] Bugfix :Problem of Report of Crossovered budget on account budget bzr revid: jvo@tinyerp.com-20080925130210-bmi3uuq26zit9ke3 --- addons/account_budget/crossovered_budget.py | 22 +++++++++++++++---- .../report/crossovered_budget_report.py | 10 +++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py index c5a81a2398b..b8496b5ced7 100644 --- a/addons/account_budget/crossovered_budget.py +++ b/addons/account_budget/crossovered_budget.py @@ -138,7 +138,7 @@ crossovered_budget() class crossovered_budget_lines(osv.osv): - def _pra_amt(self, cr, uid, ids,name,args,context): + def _prac_amt(self, cr, uid, ids,context={}): res = {} for line in self.browse(cr, uid, ids): acc_ids = ','.join([str(x.id) for x in line.general_budget_id.account_ids]) @@ -157,7 +157,14 @@ class crossovered_budget_lines(osv.osv): res[line.id]=result return res - def _theo_amt(self, cr, uid, ids,name,args,context): + def _prac(self, cr, uid, ids,name,args,context): + res={} + for line in self.browse(cr, uid, ids): + res[line.id]=self._prac_amt(cr,uid,[line.id],context=context)[line.id] + + return res + + def _theo_amt(self, cr, uid, ids,context={}): res = {} for line in self.browse(cr, uid, ids): today=datetime.datetime.today() @@ -184,6 +191,13 @@ class crossovered_budget_lines(osv.osv): res[line.id]=theo_amt return res + def _theo(self, cr, uid, ids,name,args,context): + res={} + for line in self.browse(cr, uid, ids): + res[line.id]=self._theo_amt(cr,uid,[line.id],context=context)[line.id] + + return res + def _perc(self, cr, uid, ids,name,args,context): res = {} for line in self.browse(cr, uid, ids): @@ -202,8 +216,8 @@ class crossovered_budget_lines(osv.osv): 'date_to': fields.date('End Date',required=True), 'paid_date': fields.date('Paid Date'), 'planned_amount':fields.float('Planned Amount',required=True), - 'practical_amount':fields.function(_pra_amt,method=True, string='Practical Amount',type='float'), - 'theoritical_amount':fields.function(_theo_amt,method=True, string='Theoritical Amount',type='float'), + 'practical_amount':fields.function(_prac,method=True, string='Practical Amount',type='float'), + 'theoritical_amount':fields.function(_theo,method=True, string='Theoritical Amount',type='float'), 'percentage':fields.function(_perc,method=True, string='Percentage',type='float'), } crossovered_budget_lines() diff --git a/addons/account_budget/report/crossovered_budget_report.py b/addons/account_budget/report/crossovered_budget_report.py index a3de4e1a148..bbe0b54ee95 100644 --- a/addons/account_budget/report/crossovered_budget_report.py +++ b/addons/account_budget/report/crossovered_budget_report.py @@ -63,6 +63,7 @@ class budget_report(report_sxw.rml_parse): budgets = self.pool.get('crossovered.budget').browse(self.cr, self.uid, [object.id], self.context.copy()) + c_b_lines_obj=self.pool.get('crossovered.budget.lines') for budget_id in budgets: res={} @@ -90,6 +91,7 @@ class budget_report(report_sxw.rml_parse): self.cr.execute('select distinct(analytic_account_id) from crossovered_budget_lines where id in (%s)'%(b_line_ids)) an_ids=self.cr.fetchall() + context={'wizard_date_from':d_from,'wizard_date_to':d_to} for i in range(0,len(an_ids)): analytic_name=self.pool.get('account.analytic.account').browse(self.cr, self.uid,[an_ids[i][0]]) @@ -106,9 +108,9 @@ class budget_report(report_sxw.rml_parse): } result.append(res) - line_ids = self.pool.get('crossovered.budget.lines').search(self.cr, self.uid, [('id', 'in', budget_ids),('analytic_account_id','=',an_ids[i][0])]) + line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids),('analytic_account_id','=',an_ids[i][0])]) - line_id = self.pool.get('crossovered.budget.lines').browse(self.cr,self.uid,line_ids) + line_id = c_b_lines_obj.browse(self.cr,self.uid,line_ids) tot_theo=tot_pln=tot_prac=tot_perc=0.00 done_budget=[] @@ -116,8 +118,8 @@ class budget_report(report_sxw.rml_parse): if line.id in budget_lines: theo=pract=0.00 - theo=line._theo_amt(self.cr, self.uid, [line.id],"theoritical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id] - pract=line._pra_amt(self.cr, self.uid, [line.id],"practical_amount",None,context={'wizard_date_from':d_from,'wizard_date_to':d_to})[line.id] + theo=c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id],context)[line.id] + pract=c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id],context)[line.id] if line.general_budget_id.id in done_budget: From 838ab04c2fdb3e3e11138689f369f4d4d38ffb65 Mon Sep 17 00:00:00 2001 From: Amit Mendapara Date: Thu, 25 Sep 2008 18:39:30 +0530 Subject: [PATCH 10/17] Improved Process views (added domains). bzr revid: ame@tinyerp.com-20080925130930-dmva1nkyzxbqh1pc --- addons/process/process_view.xml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/process/process_view.xml b/addons/process/process_view.xml index 1c5e9ef4944..cee536def7d 100644 --- a/addons/process/process_view.xml +++ b/addons/process/process_view.xml @@ -21,18 +21,25 @@ + + + + + +
- + + - + @@ -45,7 +52,7 @@ - + @@ -175,7 +182,7 @@ - + From 7b8878f894fe4d33b1b982fd91ef29c3b595c414 Mon Sep 17 00:00:00 2001 From: Amit Mendapara Date: Thu, 25 Sep 2008 18:58:55 +0530 Subject: [PATCH 11/17] Fixed process copy. bzr revid: ame@tinyerp.com-20080925132855-3kn2srccbh3ilg4r --- addons/process/process.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/process/process.py b/addons/process/process.py index d7a3eb7e369..a5f4946b129 100644 --- a/addons/process/process.py +++ b/addons/process/process.py @@ -356,5 +356,16 @@ class process_transition_action(osv.osv): _defaults = { 'state': lambda *args: 'dummy', } + + def copy(self, cr, uid, id, default=None, context={}): + if not default: + default = {} + + state = self.pool.get('process.transition.action').browse(cr, uid, [id], context)[0].state + if state: + default['state'] = state + + return super(process_transition_action, self).copy(cr, uid, id, default, context) + process_transition_action() From f58b7bc5788179daff8474791f3a4dee40ce9898 Mon Sep 17 00:00:00 2001 From: Jay Vora Date: Thu, 25 Sep 2008 19:29:45 +0530 Subject: [PATCH 12/17] Bugfix:Print Screen Float values well-aligned bzr revid: jvo@tinyerp.com-20080925135945-xc0vponx69cmkov6 --- bin/report/printscreen/ps_form.py | 2 ++ bin/report/printscreen/ps_list.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/report/printscreen/ps_form.py b/bin/report/printscreen/ps_form.py index 1e7757e3f17..e39949b7c51 100644 --- a/bin/report/printscreen/ps_form.py +++ b/bin/report/printscreen/ps_form.py @@ -141,6 +141,8 @@ class report_printscreen_list(report_int): line[f] = line[f][1] if fields[f]['type'] in ('one2many','many2many') and line[f]: line[f] = '( '+str(len(line[f])) + ' )' + if fields[f]['type'] in ('float','integer'): + line[f]=round(line[f],2) col = new_doc.createElement("col") col.setAttribute('tree','no') if line[f] != None: diff --git a/bin/report/printscreen/ps_list.py b/bin/report/printscreen/ps_list.py index 29242a3119e..d0245828735 100644 --- a/bin/report/printscreen/ps_list.py +++ b/bin/report/printscreen/ps_list.py @@ -128,7 +128,6 @@ class report_printscreen_list(report_int): t += fields[f].get('size', 80) / 28 + 1 l.append(s) - for pos in range(len(l)): if not l[pos]: s = fields[fields_order[pos]].get('size', 80) / 28 + 1 @@ -152,7 +151,6 @@ class report_printscreen_list(report_int): count = len(fields_order) for i in range(0,count): tsum.append(0) - for line in results: node_line = new_doc.createElement("row") @@ -163,6 +161,8 @@ class report_printscreen_list(report_int): line[f] = line[f][1] if fields[f]['type'] in ('one2many','many2many') and line[f]: line[f] = '( '+str(len(line[f])) + ' )' + if fields[f]['type'] in ('float','integer'): + line[f]=round(line[f],2) col = new_doc.createElement("col") col.setAttribute('para','yes') col.setAttribute('tree','no') From 18833843b1b323788ec04e3c10b88f60b72db9b4 Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 25 Sep 2008 16:03:46 +0200 Subject: [PATCH 13/17] *improved the pay invoice wizard: the default value of the amount is now the residual and not the total field bzr revid: qdp@tinyerp.com-20080925140346-tnijc5x0103wfczk --- addons/account/wizard/wizard_pay_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/wizard/wizard_pay_invoice.py b/addons/account/wizard/wizard_pay_invoice.py index 44e4fdd065c..fe60dc4689f 100644 --- a/addons/account/wizard/wizard_pay_invoice.py +++ b/addons/account/wizard/wizard_pay_invoice.py @@ -124,7 +124,7 @@ def _get_period(self, cr, uid, data, context={}): raise wizard.except_wizard(_('Error !'), _('Can not pay draft invoice.')) return { 'period_id': period_id, - 'amount': invoice.amount_total, + 'amount': invoice.residual, 'date': time.strftime('%Y-%m-%d') } From f475834cfb60438bddd050316b0a792a09aa6eb5 Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 25 Sep 2008 16:14:39 +0200 Subject: [PATCH 14/17] *account_account form view improved: moved 2 fields and added attrs bzr revid: qdp@tinyerp.com-20080925141439-yv5366wgbcwc7hyx --- addons/account/account_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 35d51003902..b6493f33e1b 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -116,19 +116,19 @@ - + - + - + /> From 703a2410d9398fb5e0c471e2d058dd45664fc1cb Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 25 Sep 2008 16:17:35 +0200 Subject: [PATCH 15/17] *added computation of debit/credit/balance for consolidation accounts *small improvements bzr revid: qdp@tinyerp.com-20080925141735-7loyyuoe6cq9pfgr --- addons/account/account.py | 45 +++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 61c0a77be3b..3dbb1877679 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -160,14 +160,29 @@ class account_account(osv.osv): return super(account_account,self).search(cr, uid, args, offset, limit, order, context=context, count=count) + def _get_children_and_consol(self, cr, uid, ids, context={}): + #this function search for all the children and all consolidated children (recursively) of the given account ids + res = self.search(cr, uid, [('parent_id', 'child_of', ids)]) + for id in res: + this = self.browse(cr, uid, id, context) + for child in this.child_consol_ids: + if child.id not in res: + res.append(child.id) + if len(res) != len(ids): + return self._get_children_and_consol(cr, uid, res, context) + return res + def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''): + #compute the balance/debit/credit accordingly to the value of field_name for the given account ids mapping = { 'balance': "COALESCE(SUM(l.debit) - SUM(l.credit), 0) as balance ", 'debit': "COALESCE(SUM(l.debit), 0) as debit ", 'credit': "COALESCE(SUM(l.credit), 0) as credit " } - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) + #get all the necessary accounts + ids2 = self._get_children_and_consol(cr, uid, ids, context) acc_set = ",".join(map(str, ids2)) + #compute for each account the balance/debit/credit from the move lines accounts = {} if ids2: query = self.pool.get('account.move.line')._query_get(cr, uid, @@ -184,13 +199,29 @@ class account_account(osv.osv): for res in cr.dictfetchall(): accounts[res['id']] = res + #for the asked accounts, get from the dictionnary 'accounts' the value of it res = {} for id in ids: - res[id] = {}.fromkeys(field_names, 0.0) - ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])]) + res[id] = self._get_account_values(cr, uid, id, accounts, field_names, context) + return res + + def _get_account_values(self, cr, uid, id, accounts, field_names, context={}): + res = {}.fromkeys(field_names, 0.0) + browse_rec = self.browse(cr, uid, id) + if browse_rec.type == 'consolidation': + ids2 = self.read(cr, uid, [browse_rec.id], ['child_consol_ids'], context)[0]['child_consol_ids'] + for t in self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])]): + if t not in ids2 and t != browse_rec.id: + ids2.append(t) + for i in ids2: + tmp = self._get_account_values(cr, uid, i, accounts, field_names, context) + for a in field_names: + res[a] += tmp[a] + else: + ids2 = self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])]) for i in ids2: for a in field_names: - res[id][a] += accounts.get(i, {}).get(a, 0.0) + res[a] += accounts.get(i, {}).get(a, 0.0) return res def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}): @@ -216,7 +247,7 @@ class account_account(osv.osv): _columns = { 'name': fields.char('Name', size=128, required=True, select=True), 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Force all moves for this account to have this secondary currency."), - 'code': fields.char('Code', size=64), + 'code': fields.char('Code', size=64, required=True), 'type': fields.selection([ ('receivable','Receivable'), ('payable','Payable'), @@ -229,7 +260,7 @@ class account_account(osv.osv): 'user_type': fields.many2one('account.account.type', 'Account Type', required=True), 'parent_id': fields.many2one('account.account','Parent', ondelete='cascade'), 'child_parent_ids':fields.one2many('account.account','parent_id','Children'), - 'child_consol_ids':fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children',domain=[('type', '=', 'consolidation')]), + 'child_consol_ids':fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'), 'child_id': fields.function(_get_child_ids, method=True, type='many2many',relation="account.account",string="Children Accounts"), 'balance': fields.function(__compute, digits=(16,2), method=True, string='Balance', multi='balance'), 'credit': fields.function(__compute, digits=(16,2), method=True, string='Credit', multi='balance'), @@ -245,7 +276,7 @@ class account_account(osv.osv): 'parent_left': fields.integer('Parent Left', select=1), 'parent_right': fields.integer('Parent Right', select=1), - 'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries otherwise it will print balance of this account") + 'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries when printing the General Ledger, otherwise it will only print its balance.") } def _default_company(self, cr, uid, context={}): From 0d0e87c941b065f1e27ab98d84cdf47fb899d290 Mon Sep 17 00:00:00 2001 From: Jay Vora Date: Thu, 25 Sep 2008 19:47:14 +0530 Subject: [PATCH 16/17] Bugfix on account move line and minor edit on account budget bzr revid: jvo@tinyerp.com-20080925141714-o0dfv75tel6wzxdd --- addons/account/account_view.xml | 4 +++- addons/account_budget/crossovered_budget.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index b6493f33e1b..70709be18f5 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -654,6 +654,7 @@ + @@ -748,7 +749,7 @@ - + @@ -1289,6 +1290,7 @@ + diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py index b8496b5ced7..dfb018d82e8 100644 --- a/addons/account_budget/crossovered_budget.py +++ b/addons/account_budget/crossovered_budget.py @@ -215,9 +215,9 @@ class crossovered_budget_lines(osv.osv): 'date_from': fields.date('Start Date',required=True), 'date_to': fields.date('End Date',required=True), 'paid_date': fields.date('Paid Date'), - 'planned_amount':fields.float('Planned Amount',required=True), - 'practical_amount':fields.function(_prac,method=True, string='Practical Amount',type='float'), - 'theoritical_amount':fields.function(_theo,method=True, string='Theoritical Amount',type='float'), + 'planned_amount':fields.float('Planned Amount',required=True,digits=(16,2)), + 'practical_amount':fields.function(_prac,method=True, string='Practical Amount',type='float',digits=(16,2)), + 'theoritical_amount':fields.function(_theo,method=True, string='Theoritical Amount',type='float',digits=(16,2)), 'percentage':fields.function(_perc,method=True, string='Percentage',type='float'), } crossovered_budget_lines() From d189e17e71b2e9bc4ee238ca29c8047888493293 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 25 Sep 2008 21:40:50 +0200 Subject: [PATCH 17/17] bugfixes bzr revid: fp@tinyerp.com-20080925194050-enw8gayfgjm0b0jc --- bin/osv/fields.py | 1 - bin/report/interface.py | 10 +++++++--- bin/tools/misc.py | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index daee0e4e40a..6ddef4a5338 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -676,7 +676,6 @@ class related(function): return res def __init__(self,*arg,**args): - print arg self.arg = arg super(related, self).__init__(self._fnct_read, arg, fnct_inv_arg=arg,method=True, fnct_search=self._fnct_search,**args) diff --git a/bin/report/interface.py b/bin/report/interface.py index 95e6ec31946..3e133310476 100644 --- a/bin/report/interface.py +++ b/bin/report/interface.py @@ -100,9 +100,13 @@ class report_rml(report_int): # file('/tmp/terp.rml','wb+').write(rml) pool = pooler.get_pool(cr.dbname) ir_actions_report_xml_obj = pool.get('ir.actions.report.xml') - report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, - [('report_name', '=', self.name[7:])], context=context) - self.title = ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name + try: + report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, + [('report_name', '=', self.name[7:])], context=context) + self.title = ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name + except: + print 'Report not Found !' + self.title = 'Unknown' report_type = datas.get('report_type', 'pdf') create_doc = self.generators[report_type] pdf = create_doc(rml, title=self.title) diff --git a/bin/tools/misc.py b/bin/tools/misc.py index f29f1731ddb..d01fa4f293d 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -358,12 +358,12 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non if debug: s.debuglevel = 5 + s.connect(config['smtp_server'], config['smtp_port']) if ssl: s.ehlo() s.starttls() s.ehlo() - s.connect(config['smtp_server'], config['smtp_port']) if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string()) @@ -423,12 +423,12 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_ if debug: s.debuglevel = 5 + s.connect(config['smtp_server'], config['smtp_port']) if ssl: s.ehlo() s.starttls() s.ehlo() - s.connect(config['smtp_server'], config['smtp_port']) if config['smtp_user'] or config['smtp_password']: s.login(config['smtp_user'], config['smtp_password']) s.sendmail(email_from, flatten([email_to, email_cc, email_bcc]), msg.as_string())