Skip to content

Commit

Permalink
[merge]
Browse files Browse the repository at this point in the history
bzr revid: rvalyi@gmail.com-20100723145429-utly4nv20yj1ll45
  • Loading branch information
rvalyi committed Jul 23, 2010
2 parents 39f886f + 2aa3e0c commit 1c365d3
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 172 deletions.
111 changes: 56 additions & 55 deletions addons/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,59 +248,59 @@ def _get_children_and_consol(self, cr, uid, ids, context={}):

def __compute(self, cr, uid, ids, field_names, arg=None, context=None,
query='', query_params=()):
""" compute the balance, debit and/or credit for the provided
account ids
Arguments:
`ids`: account ids
`field_names`: the fields to compute (a list of any of
'balance', 'debit' and 'credit')
`arg`: unused fields.function stuff
`query`: additional query filter (as a string)
`query_params`: parameters for the provided query string
(__compute will handle their escaping) as a
tuple
"""
mapping = {
'balance': "COALESCE(SUM(l.debit),0) " \
"- COALESCE(SUM(l.credit), 0) as balance",
'debit': "COALESCE(SUM(l.debit), 0) as debit",
'credit': "COALESCE(SUM(l.credit), 0) as credit"
}
#get all the necessary accounts
children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
#compute for each account the balance/debit/credit from the move lines
accounts = {}
if children_and_consolidated:
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)

wheres = [""]
if query.strip():
wheres.append(query.strip())
if aml_query.strip():
wheres.append(aml_query.strip())
filters = " AND ".join(wheres)
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
'Filters: %s'%filters)
# IN might not work ideally in case there are too many
# children_and_consolidated, in that case join on a
# values() e.g.:
# SELECT l.account_id as id FROM account_move_line l
# INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
# ON l.account_id = tmp.id
# or make _get_children_and_consol return a query and join on that
request = ("SELECT l.account_id as id, " +\
' , '.join(map(mapping.__getitem__, field_names)) +
" FROM account_move_line l" \
" WHERE l.account_id IN %s " \
+ filters +
" GROUP BY l.account_id")
params = (tuple(children_and_consolidated),) + query_params
cr.execute(request, params)
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
'Status: %s'%cr.statusmessage)

for res in cr.dictfetchall():
accounts[res['id']] = res
""" compute the balance, debit and/or credit for the provided
account ids
Arguments:
`ids`: account ids
`field_names`: the fields to compute (a list of any of
'balance', 'debit' and 'credit')
`arg`: unused fields.function stuff
`query`: additional query filter (as a string)
`query_params`: parameters for the provided query string
(__compute will handle their escaping) as a
tuple
"""
mapping = {
'balance': "COALESCE(SUM(l.debit),0) " \
"- COALESCE(SUM(l.credit), 0) as balance",
'debit': "COALESCE(SUM(l.debit), 0) as debit",
'credit': "COALESCE(SUM(l.credit), 0) as credit"
}
#get all the necessary accounts
children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
#compute for each account the balance/debit/credit from the move lines
accounts = {}
if children_and_consolidated:
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)

wheres = [""]
if query.strip():
wheres.append(query.strip())
if aml_query.strip():
wheres.append(aml_query.strip())
filters = " AND ".join(wheres)
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
'Filters: %s'%filters)
# IN might not work ideally in case there are too many
# children_and_consolidated, in that case join on a
# values() e.g.:
# SELECT l.account_id as id FROM account_move_line l
# INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
# ON l.account_id = tmp.id
# or make _get_children_and_consol return a query and join on that
request = ("SELECT l.account_id as id, " +\
' , '.join(map(mapping.__getitem__, field_names)) +
" FROM account_move_line l" \
" WHERE l.account_id IN %s " \
+ filters +
" GROUP BY l.account_id")
params = (tuple(children_and_consolidated),) + query_params
cr.execute(request, params)
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
'Status: %s'%cr.statusmessage)

for res in cr.dictfetchall():
accounts[res['id']] = res

# consolidate accounts with direct children
children_and_consolidated.reverse()
Expand Down Expand Up @@ -2539,9 +2539,9 @@ def execute(self, cr, uid, ids, context=None):
'account_paid_id': acc_template_ref[value['account_paid_id']],
})

# Creating Journals
# Creating Journals Sales and Purchase
vals_journal={}
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_view')])
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')])
data = data_pool.browse(cr, uid, data_id[0])
view_id = data.res_id

Expand Down Expand Up @@ -2573,6 +2573,7 @@ def execute(self, cr, uid, ids, context=None):
vals_journal['type'] = 'purchase'
vals_journal['code'] = _('EXJ')
vals_journal['sequence_id'] = seq_id_purchase
vals_journal['view_id'] = view_id

if obj_multi.chart_template_id.property_account_payable:
vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id]
Expand Down
34 changes: 31 additions & 3 deletions addons/account/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _default_get(self, cr, uid, fields, context={}):
# Compute the current move
move_id = False
partner_id = False
if context.get('journal_id',False) and context.get('period_id',False):
if context.get('journal_id', False) and context.get('period_id', False):
if 'move_id' in fields:
cr.execute('select move_id \
from \
Expand All @@ -199,6 +199,7 @@ def _default_get(self, cr, uid, fields, context={}):
return data
else:
data['move_id'] = move_id

if 'date' in fields:
cr.execute('select date \
from \
Expand All @@ -214,7 +215,6 @@ def _default_get(self, cr, uid, fields, context={}):
period = period_obj.browse(cr, uid, context['period_id'],
context=context)
data['date'] = period.date_start

if not move_id:
return data

Expand Down Expand Up @@ -786,6 +786,31 @@ def view_header_get(self, cr, user, view_id, view_type, context):
return j+(p and (':'+p) or '')
return False

# def onchange_date(self, cr, user, ids, date, context={}):
# """
# Returns a dict that contains new values and context
# @param cr: A database cursor
# @param user: ID of the user currently logged in
# @param date: latest value from user input for field date
# @param args: other arguments
# @param context: context arguments, like lang, time zone
# @return: Returns a dict which contains new values, and context
# """
# res = {}
# period_pool = self.pool.get('account.period')
# pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
# if pids:
# res.update({
# 'period_id':pids[0]
# })
# context.update({
# 'period_id':pids[0]
# })
# return {
# 'value':res,
# 'context':context,
# }

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu)
if view_type != 'tree':
Expand Down Expand Up @@ -848,11 +873,14 @@ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, t
elif field == 'credit':
attrs.append('sum="Total credit"')
elif field == 'account_tax_id':
attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
attrs.append('domain="[(\'parent_id\',\'=\',False), (\'type_tax_use\',\'=\',context.get(journal_id.type, \'sale\'))]"')
elif field == 'account_id' and journal.id:
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'&lt;&gt;\',\'view\'), (\'type\',\'&lt;&gt;\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
elif field == 'partner_id':
attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
# elif field == 'date':
# attrs.append('on_change="onchange_date(date)"')

# if field.readonly:
# attrs.append('readonly="1"')
# if field.required:
Expand Down
29 changes: 19 additions & 10 deletions addons/account/account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@
<field colspan="4" name="name" select="1"/>
<field name="field" select="1"/>
<field name="sequence"/>
<newline/>
<field name="readonly"/>
<field name="required"/>
<!-- <newline/>-->
<!-- <field name="readonly"/>-->
<!-- <field name="required"/>-->
</form>
</field>
</record>
Expand All @@ -283,8 +283,8 @@
<tree string="Journal Column">
<field name="sequence"/>
<field name="name"/>
<field name="required"/>
<field name="readonly"/>
<!-- <field name="required"/>-->
<!-- <field name="readonly"/>-->
</tree>
</field>
</record>
Expand All @@ -295,11 +295,18 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Journal View">
<field colspan="4" name="name" select="1"/>
<field name="name" select="1"/>
<field colspan="4" name="columns_id" nolabel="1" widget="one2many_list"/>
</form>
</field>
</record>
<record id="action_account_journal_view" model="ir.actions.act_window">
<field name="name">Journal Views</field>
<field name="res_model">account.journal.view</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_account_journal_view" id="menu_action_account_journal_view" parent="account.menu_low_level"/>

<!--
# Account Journal
Expand Down Expand Up @@ -953,7 +960,7 @@
<field eval="9" name="priority"/>
<field name="arch" type="xml">
<form string="Account Entry Line">
<notebook>
<notebook colspan="4">
<page string="Information">
<separator colspan="4" string="General Information"/>
<field name="name" select="1"/>
Expand Down Expand Up @@ -1001,8 +1008,11 @@
<search string="Search Entry Lines">
<group col='10' colspan='4'>
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Entry Lines"/>
<separator orientation="vertical"/>
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','valid')]" help="Posted Entry Lines"/>
<filter icon="terp-stock_symbol-selection" string="Unposted" domain="[('move_id.state','=','draft')]" help="Unposted Entry Lines"/>
<separator orientation="vertical"/>
<filter icon="terp-stock_symbol-selection" string="Unreconciled" domain="[('reconcile_id','=',False), ('account_id.type','in',['receivable', 'payable'])]" help="Unreconciled Entry Lines"/>
<field name="date" select='1'/>
<field name="account_id" select='1'/>
<field name="partner_id" select='1'>
Expand All @@ -1012,8 +1022,8 @@
</group>
<newline/>
<group col="10" colspan="4">
<field name="journal_id" widget="selection" context="{'journal_id':self, 'visible_id':self or 0, 'normal_view':False}"/>
<field name="period_id" widget="selection" context="{'period_id':self}"/>
<field name="journal_id" required="1" widget="selection" context="{'journal_id':self, 'visible_id':self or 0, 'normal_view':False}"/>
<field name="period_id" required="1" widget="selection" context="{'period_id':self}"/>
</group>
</search>
</field>
Expand Down Expand Up @@ -1255,7 +1265,6 @@
<field name="view_id" ref="view_move_line_tree"/>
<field name="search_view_id" ref="view_account_move_line_filter"/>
<field name="domain">[('journal_id.type', 'in', ['purchase', 'sale_refund'])]</field>
<field name="context">{'journal_id':1}</field>
</record>

<menuitem action="action_account_moves_purchase" id="menu_eaction_account_moves_purchase" parent="menu_finance_payables"/>
Expand Down
7 changes: 5 additions & 2 deletions addons/account/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,12 @@ def generate_configurable_chart(self, cr, uid, ids, context=None):
'account_paid_id': acc_template_ref[value['account_paid_id']],
})

# Creating Journals
# Creating Journals Sales and Purchase
vals_journal={}
view_id = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Journal View')])[0]
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')])
data = data_pool.browse(cr, uid, data_id[0])
view_id = data.res_id

seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0]

if seq_journal:
Expand Down
4 changes: 3 additions & 1 deletion addons/crm/wizard/crm_forward_to_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def get_lead_details(self, cr, uid, lead_id, context=None):
"Partner: %s" % (lead.partner_id and lead.partner_id.name_get()[0][1]),
"Contact: %s" % (pa.name or ''),
"Title: %s" % (pa.title or ''),
"Function: %s" % (pa.function and pa.function.name_get()[0][1] or ''),
"Function: %s" % (pa.function or ''),
"Street: %s" % (pa.street or ''),
"Street2: %s" % (pa.street2 or ''),
"Zip: %s" % (pa.zip or ''),
Expand All @@ -244,6 +244,8 @@ def get_lead_details(self, cr, uid, lead_id, context=None):
"Phone: %s" % (pa.phone or ''),
"Fax: %s" % (pa.fax or ''),
"Mobile: %s" % (pa.mobile or ''),
"Lead Category: %s" % (lead.categ_id and lead.categ_id.name or ''),
"Details: %s" % (lead.description or ''),
]
return "\n".join(body + ['---'])

Expand Down
1 change: 0 additions & 1 deletion addons/mrp/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
'wizard/mrp_change_standard_price_view.xml',
# 'wizard/mrp_track_prod_view.xml',
'mrp_view.xml',
'mrp_wizard.xml',
'mrp_report.xml',
'company_view.xml',
'process/stockable_product_process.xml',
Expand Down
Loading

0 comments on commit 1c365d3

Please sign in to comment.