From d80a097fe76fbdf223f431f124f2eb2d6e40823a Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 5 Feb 2008 20:27:36 +0000 Subject: [PATCH] Bugfixes and improvement bzr revid: fp@tinyerp.com-55519a2f81bdd9229604b2bdbf9585ea972f2ff9 --- addons/account_chart/__terp__.py | 2 +- addons/crm/crm.py | 4 + .../report/account_analytic_profit.py | 50 +- .../report/account_analytic_profit.rml | 454 +++++++++--------- .../wizard/account_analytic_profit.py | 4 +- addons/l10n_be/__terp__.py | 2 +- addons/mrp/mrp_view.xml | 3 + addons/product/pricelist.py | 2 +- .../report_analytic_planning.py | 6 +- .../report_analytic_planning_view.xml | 7 +- addons/report_task/report_task.py | 11 +- addons/sale/sale_view.xml | 30 +- addons/stock/__terp__.py | 2 +- addons/stock/stock.py | 2 +- addons/stock/wizard/wizard_partial_picking.py | 4 +- 15 files changed, 309 insertions(+), 274 deletions(-) diff --git a/addons/account_chart/__terp__.py b/addons/account_chart/__terp__.py index 147b027f955..964091ba5cc 100644 --- a/addons/account_chart/__terp__.py +++ b/addons/account_chart/__terp__.py @@ -1,5 +1,5 @@ { - "name" : "Account Chart", + "name" : "Charts of Accounts", "version" : "1.1", "depends" : ["account"], "author" : "Tiny", diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 06fb54e546a..87f49dac375 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -305,6 +305,10 @@ class crm_case(osv.osv): else: res[case.id] = False return res + def copy(self, cr, uid, id, default=None, context={}): + if not default: default = {} + default.update( {'state':'draft', 'id':False, 'history_line':[],'log_ids':[]}) + return super(crm_case, self).copy(cr, uid, id, default, context) _columns = { 'id': fields.integer('ID', readonly=True), diff --git a/addons/hr_timesheet_invoice/report/account_analytic_profit.py b/addons/hr_timesheet_invoice/report/account_analytic_profit.py index 08506902ec9..402944b066f 100644 --- a/addons/hr_timesheet_invoice/report/account_analytic_profit.py +++ b/addons/hr_timesheet_invoice/report/account_analytic_profit.py @@ -70,32 +70,52 @@ class account_analytic_profit(report_sxw.rml_parse): ]) res={} for line in line_obj.browse(self.cr, self.uid, ids): - if line.to_invoice: - id=line.to_invoice.id - name=line.to_invoice.name - discount=line.to_invoice.factor - else: - if line.account_id.pricelist_id: - name="Fixed Price" + if line.account_id.pricelist_id: + if line.account_id.to_invoice: + if line.to_invoice: + id=line.to_invoice.id + name=line.to_invoice.name + discount=line.to_invoice.factor + else: + name="/" + discount=1.0 + id = -1 + else: + name="Fixed" discount=0.0 id=0 - else: - name="/" - discount=1.0 - id = -1 - if line.account_id.pricelist_id: pl=line.account_id.pricelist_id.id price=price_obj.price_get(self.cr, self.uid, [pl], line.product_id.id, line.unit_amount or 1.0, line.account_id.partner_id.id)[pl] else: + name="/" + discount=1.0 + id = -1 price=0.0 if id not in res: - res[id]={'name': name, 'amount': 0, 'cost':0, 'unit_amount':0,} - res[id]['amount']+=round(price * line.unit_amount * (1-(discount or 0.0)/100.0), 2) + res[id]={'name': name, 'amount': 0, 'cost':0, 'unit_amount':0,'amount_th':0} + xxx = round(price * line.unit_amount * (1-(discount or 0.0)), 2) + res[id]['amount_th']+=xxx + if line.invoice_id: + self.cr.execute('select id from account_analytic_line where invoice_id=%d', (line.invoice_id.id,)) + tot = 0 + for lid in self.cr.fetchall(): + lid2 = line_obj.browse(self.cr, self.uid, lid[0]) + pl=lid2.account_id.pricelist_id.id + price=price_obj.price_get(self.cr, self.uid, [pl], lid2.product_id.id, lid2.unit_amount or 1.0, lid2.account_id.partner_id.id)[pl] + tot += price * lid2.unit_amount * (1-(discount or 0.0)) + if tot: + procent = line.invoice_id.amount_untaxed / tot + res[id]['amount'] += xxx * procent + else: + res[id]['amount'] += xxx + else: + res[id]['amount'] += xxx + res[id]['cost']+=line.amount res[id]['unit_amount']+=line.unit_amount for id in res: res[id]['profit']=res[id]['amount']+res[id]['cost'] - res[id]['eff']=abs(round(res[id]['amount'] / res[id]['cost'] * 100, 2)) + res[id]['eff']='%d' % (-res[id]['amount'] / res[id]['cost'] * 100,) return res.values() def _lines(self, form): diff --git a/addons/hr_timesheet_invoice/report/account_analytic_profit.rml b/addons/hr_timesheet_invoice/report/account_analytic_profit.rml index f11b9dd5dff..f3be0f31da3 100644 --- a/addons/hr_timesheet_invoice/report/account_analytic_profit.rml +++ b/addons/hr_timesheet_invoice/report/account_analytic_profit.rml @@ -1,226 +1,236 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [[ company.name ]] - - - Invoice rate - by user - - - Period from [[ data['form']['date_from'] ]] - to [[ data['form']['date_to'] ]] - Currency: [[ company.currency_id.name ]] - - - - - - - - - - Employee - - - - - - - - Units - - - Income - - - Cost - - - Profit - - - Eff. - - - - - - -
- [[ repeatIn(user_ids(lines(data['form'])), 'e') ]] - - - - [[ e.name ]] - - - - - [[ repeatIn(journal_ids(data['form'], e.id), 'j') ]] - [[ j.name ]] - - - - - - - - - - - [[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], [j.id], [e.id]), 0)]] - - - [[ reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) ]] - - - [[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) ]] - - - [[ reduce(lambda x, y: x+y['profit'], line(data['form'], [j.id], [e.id]), 0)]] - - - [[ round( reduce(lambda x, y: x+y['eff'], line(data['form'], [j.id], [e.id]), 0)/len(line(data['form'], [j.id], [e.id])) , 2)]] % - - - - - [[ repeatIn(line(data['form'], [j.id], [e.id]), 'l') ]] - [[ l['name'] ]] - - - [[ l['unit_amount'] ]] - - - [[ l['amount'] ]] - - - [[ l['cost'] ]] - - - [[ l['profit'] ]] - - - [[ l['eff'] ]] % - - - - - - -
- - - - Totals - - - - - - - - - - - [[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] - - - [[ reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] - - - [[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] - - - [[ reduce(lambda x, y: x+y['profit'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] - - - [[ round(reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)/reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)* -100, 2)]] % - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[[ company.name ]] + + +Invoice rate by user + + +Period from [[ data['form']['date_from'] ]] +to [[ data['form']['date_to'] ]] +Currency: [[ company.currency_id.name ]] + + + + + + + + + +Employee + + + + + + + +Units + + +Theorical + + +Income + + +Cost + + +Profit + + +Eff. + + + + + + +
+[[ repeatIn(user_ids(lines(data['form'])), 'e') ]] +[[ e.name ]] + + + +[[ repeatIn(journal_ids(data['form'], e.id), 'j') ]] +[[ j.name ]] + + + + + + + + + + +[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], [j.id], [e.id]), 0)]] + + +[[ reduce(lambda x, y: x+y['amount_th'], line(data['form'], [j.id], [e.id]), 0) ]] + + +[[ reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) ]] + + +[[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) ]] + + +[[ reduce(lambda x, y: x+y['profit'], line(data['form'], [j.id], [e.id]), 0)]] + + +[[ '%d' % (-reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) / reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) * 100.0,)]] % + + + + + +[[ repeatIn(line(data['form'], [j.id], [e.id]), 'l') ]] +[[ l['name'] ]] + + +[[ l['unit_amount'] ]] + + +[[ l['amount_th'] ]] + + +[[ l['amount'] ]] + + +[[ l['cost'] ]] + + +[[ l['profit'] ]] + + +[[ l['eff'] ]] % + + + + + + +
+ + + +Totals + + + + + + + + + + +[[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + + + + + + + +[[ reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + + +[[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + + +[[ reduce(lambda x, y: x+y['profit'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + + +[[ '%d' % (-reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)/reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)* 100, )]] % + + + + + + +
diff --git a/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py b/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py index 49f935aaca1..705654a89fa 100644 --- a/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py +++ b/addons/hr_timesheet_invoice/wizard/account_analytic_profit.py @@ -34,8 +34,8 @@ form='''
- - + + ''' class wizard_report(wizard.interface): diff --git a/addons/l10n_be/__terp__.py b/addons/l10n_be/__terp__.py index fcb91f9514b..bc4971908ea 100644 --- a/addons/l10n_be/__terp__.py +++ b/addons/l10n_be/__terp__.py @@ -3,7 +3,7 @@ "version" : "1.1", "author" : "Tiny", "category" : "Localisation/Account charts", - "depends" : ["base", "account", "account_report", "base_vat", "base_iban", + "depends" : ["account", "account_report", "base_vat", "base_iban", "account_chart"], "init_xml" : [], "demo_xml" : ["account_demo.xml","account.report.report.csv"], diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 2a2c8e0e31b..1be2c360027 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -385,8 +385,10 @@ + @@ -664,6 +666,7 @@ tree + diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 90f965438bd..f7c70caab80 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -41,7 +41,7 @@ class price_type(osv.osv): sale and purchase prices based on some fields of the product. """ def _price_field_get(self, cr, uid, context={}): - cr.execute('select name, field_description from ir_model_fields where model in (%s,%s) and ttype=%s', ('product.product', 'product.template', 'float')) + cr.execute('select name, field_description from ir_model_fields where model in (%s,%s) and ttype=%s order by name', ('product.product', 'product.template', 'float')) return cr.fetchall() def _get_currency(self, cr, uid, ctx): comp = self.pool.get('res.users').browse(cr,uid,uid).company_id diff --git a/addons/report_analytic_planning/report_analytic_planning.py b/addons/report_analytic_planning/report_analytic_planning.py index 9df0565fb5e..9190bb35773 100644 --- a/addons/report_analytic_planning/report_analytic_planning.py +++ b/addons/report_analytic_planning/report_analytic_planning.py @@ -44,12 +44,14 @@ class report_account_analytic_planning(osv.osv): 'stat_ids': fields.one2many('report_account_analytic.planning.stat', 'planning_id', 'Planning analysis', readonly=True), 'stat_user_ids': fields.one2many('report_account_analytic.planning.stat.user', 'planning_id', 'Planning by user', readonly=True), 'stat_account_ids': fields.one2many('report_account_analytic.planning.stat.account', 'planning_id', 'Planning by account', readonly=True), + 'state': fields.selection([('open','Open'),('done','Done')], 'State', required=True) } _defaults = { 'name': lambda *a: time.strftime('%Y-%m-%d'), 'date_from': lambda *a: time.strftime('%Y-%m-01'), 'date_to': lambda *a: (mx.DateTime.now()+mx.DateTime.RelativeDateTime(months=1,day=1,days=-1)).strftime('%Y-%m-%d'), - 'user_id': lambda self,cr,uid,c: uid + 'user_id': lambda self,cr,uid,c: uid, + 'state': lambda *args: 'open' } _order = 'date_from desc' report_account_analytic_planning() @@ -164,7 +166,7 @@ class report_account_analytic_planning_stat(osv.osv): from report_account_analytic_planning_line l left join - account_analytic_account a on (a.id = l.account_id) + report_account_analytic_planning a on (a.id = l.planning_id) left join product_uom u on (l.amount_unit = u.id) group by diff --git a/addons/report_analytic_planning/report_analytic_planning_view.xml b/addons/report_analytic_planning/report_analytic_planning_view.xml index e76c66bed51..4315353cac6 100644 --- a/addons/report_analytic_planning/report_analytic_planning_view.xml +++ b/addons/report_analytic_planning/report_analytic_planning_view.xml @@ -11,6 +11,7 @@ + @@ -36,6 +37,7 @@ + @@ -138,6 +140,7 @@ + @@ -175,7 +178,7 @@ report_account_analytic.planning.stat form - [('user_id','=',uid)] + [('user_id','=',uid),('planning_id.state','=','open')] graph,tree report_account_analytic.planning.stat form - [('manager_id','=',uid)] + [('manager_id','=',uid),('planning_id.state','=','open')] graph,tree - Sales in shipping exception + Sales in Exception ir.actions.act_window sale.order form tree,form - [('state','=','shipping_except')] + [('state','in',('shipping_except','invoice_except')] - Sales order to be invoiced + Sales Order To Be Invoiced ir.actions.act_window sale.order form @@ -238,12 +238,12 @@ - Sales order in progress + Sales Order in Progress ir.actions.act_window sale.order form tree,form - [('state','=','progress')] + [('state','in',('progress','waiting_date','manual'))] - All quotations + All Quotations ir.actions.act_window sale.order form @@ -266,27 +266,15 @@ sequence="1" action="action_order_tree5"/> - - Sales order in invoice exception - ir.actions.act_window - sale.order - form - tree,form - [('state','=','invoice_except')] - - - - - My sales in shipping exception ir.actions.act_window sale.order form tree,form - [('state','=','shipping_except'),('user_id','=',uid)] + [('state','in',('shipping_except','invoice_except')),('user_id','=',uid)] - + My sales order waiting Invoice @@ -304,7 +292,7 @@ sale.order form tree,form - [('state','=','progress'),('user_id','=',uid)] + [('state','in',('progress','waiting_date','manual')),('user_id','=',uid)] \ + _moves_arch_lst.append('\ ' % (m.id,m.id,)) _moves_fields['price%s' % m.id] = {'string': 'Unit Price', @@ -89,7 +89,7 @@ def _get_moves(self, cr, uid, data, context): 'relation': 'product.uom', 'required': True, 'default': make_default(m.product_uom.id)} - _moves_arch_lst.append('' % (m.id,)) + _moves_arch_lst.append('' % (m.id,)) _moves_fields['currency%s' % m.id] = {'string': 'Currency', 'type': 'many2one', 'relation': 'res.currency', 'required': True, 'default': make_default(currency)}