[MERGE] merge with same branch

bzr revid: qdp-launchpad@tinyerp.com-20100922155840-4wbqo6r1z35fnram
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-09-22 17:58:40 +02:00
commit 1b914d691c
20 changed files with 193 additions and 95 deletions

View File

@ -8,8 +8,7 @@
<menuitem id="menu_finance_bank_and_cash" name="Bank and Cash" parent="menu_finance" sequence="3"/>
<menuitem id="menu_finance_periodical_processing" name="Periodical Processing" parent="menu_finance" sequence="8" groups="group_account_user,group_account_manager,base.group_system,group_account_invoice"/>
<!-- This menu is used in account_code module -->
<menuitem id="menu_account_coda" name="Statements" parent="menu_finance_periodical_processing" sequence="12"/>
<menuitem id="menu_finance_periodical_processing_bank" name="Bank Reconciliation" parent="menu_finance_periodical_processing" sequence="8" groups="group_account_user,group_account_manager,base.group_system,group_account_invoice"/>
<menuitem id="menu_account_pp_statements" name="Statements" parent="menu_finance_periodical_processing" sequence="12"/>
<menuitem id="periodical_processing_journal_entries_validation" name="Draft Entries" parent="menu_finance_periodical_processing" groups="group_account_user,group_account_manager,base.group_system"/>
<menuitem id="periodical_processing_reconciliation" name="Reconciliation" parent="menu_finance_periodical_processing"/>
<menuitem id="periodical_processing_invoicing" name="Invoicing" parent="menu_finance_periodical_processing"/>

View File

@ -636,7 +636,7 @@
</record>
<menuitem string="Bank Statements" action="action_bank_statement_tree" id="menu_bank_statement_tree" parent="menu_finance_bank_and_cash" sequence="7"/>
<menuitem name="Statements Reconciliation" action="action_bank_statement_periodic_tree" id="menu_menu_Bank_process" parent="menu_finance_periodical_processing_bank" sequence="7"/>
<menuitem name="Statements Reconciliation" action="action_bank_statement_periodic_tree" id="menu_menu_Bank_process" parent="account.menu_account_pp_statements" sequence="7"/>
<record id="action_bank_statement_draft_tree" model="ir.actions.act_window">

View File

@ -499,14 +499,15 @@ class account_installer(osv.osv_memory):
if context is None:
context = {}
fy_obj = self.pool.get('account.fiscalyear')
data_pool = self.pool.get('ir.model.data')
mod_obj = self.pool.get('ir.model.data')
obj_acc = self.pool.get('account.account')
obj_tax_code = self.pool.get('account.tax.code')
obj_temp_tax_code = self.pool.get('account.tax.code.template')
super(account_installer, self).execute(cr, uid, ids, context=context)
record = self.browse(cr, uid, ids, context=context)[0]
company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id
for res in self.read(cr, uid, ids):
if record.charts == 'configurable':
mod_obj = self.pool.get('ir.model.data')
fp = tools.file_open(opj('account','configurable_account_chart.xml'))
tools.convert_xml_import(cr, 'account', fp, {}, 'init',True, None)
fp.close()
@ -518,12 +519,46 @@ class account_installer(osv.osv_memory):
p_tax = (res.get('purchase_tax',0.0))/100
tax_val = {}
default_tax = []
pur_tax_parent = mod_obj._get_id(cr, uid, 'account', 'tax_code_base_purchases')
pur_tax_parent_id = mod_obj.read(cr, uid, [pur_tax_parent], ['res_id'])[0]['res_id']
sal_tax_parent = mod_obj._get_id(cr, uid, 'account', 'tax_code_base_sales')
sal_tax_parent_id = mod_obj.read(cr, uid, [sal_tax_parent], ['res_id'])[0]['res_id']
pur_temp_tax = mod_obj._get_id(cr, uid, 'account', 'tax_code_base_purchases')
pur_temp_tax_id = mod_obj.read(cr, uid, [pur_temp_tax], ['res_id'])[0]['res_id']
pur_temp_tax_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_id], ['name'])
pur_tax_parent_name = pur_temp_tax_names and pur_temp_tax_names[0]['name'] or False
pur_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_parent_name)])
if pur_taxcode_parent_id:
pur_taxcode_parent_id = pur_taxcode_parent_id[0]
else:
pur_taxcode_parent_id = False
pur_temp_tax_paid = mod_obj._get_id(cr, uid, 'account', 'tax_code_input')
pur_temp_tax_paid_id = mod_obj.read(cr, uid, [pur_temp_tax_paid], ['res_id'])[0]['res_id']
pur_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_paid_id], ['name'])
pur_tax_paid_parent_name = pur_temp_tax_names and pur_temp_tax_paid_names[0]['name'] or False
pur_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_paid_parent_name)])
if pur_taxcode_paid_parent_id:
pur_taxcode_paid_parent_id = pur_taxcode_paid_parent_id[0]
else:
pur_taxcode_paid_parent_id = False
sale_temp_tax = mod_obj._get_id(cr, uid, 'account', 'tax_code_base_sales')
sale_temp_tax_id = mod_obj.read(cr, uid, [sale_temp_tax], ['res_id'])[0]['res_id']
sale_temp_tax_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_id], ['name'])
sale_tax_parent_name = sale_temp_tax_names and sale_temp_tax_names[0]['name'] or False
sale_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_parent_name)])
if sale_taxcode_parent_id:
sale_taxcode_parent_id = sale_taxcode_parent_id[0]
else:
sale_taxcode_parent_id = False
sale_temp_tax_paid = mod_obj._get_id(cr, uid, 'account', 'tax_code_output')
sale_temp_tax_paid_id = mod_obj.read(cr, uid, [sale_temp_tax_paid], ['res_id'])[0]['res_id']
sale_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_paid_id], ['name'])
sale_tax_paid_parent_name = sale_temp_tax_paid_names and sale_temp_tax_paid_names[0]['name'] or False
sale_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_paid_parent_name)])
if sale_taxcode_paid_parent_id:
sale_taxcode_paid_parent_id = sale_taxcode_paid_parent_id[0]
else:
sale_taxcode_paid_parent_id = False
if s_tax*100 > 0.0:
tax_account_ids = obj_acc.search(cr, uid, [('name','=','Tax Received')], context=context)
@ -533,15 +568,25 @@ class account_installer(osv.osv_memory):
'code': 'TAX%s%%'%(s_tax*100),
'company_id': company_id.id,
'sign': 1,
'parent_id':sal_tax_parent_id
'parent_id': sale_taxcode_parent_id
}
new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code)
vals_paid_tax_code = {
'name': 'TAX Paid %s%%'%(s_tax*100),
'code': 'TAX Paid %s%%'%(s_tax*100),
'company_id': company_id.id,
'sign': 1,
'parent_id': sale_taxcode_paid_parent_id
}
new_paid_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_paid_tax_code)
sales_tax = obj_tax.create(cr, uid,
{'name':'TAX%s%%'%(s_tax*100),
'description':'TAX%s%%'%(s_tax*100),
'amount':s_tax,
'base_code_id':new_tax_code,
'tax_code_id':new_tax_code,
'tax_code_id':new_paid_tax_code,
'type_tax_use':'sale',
'account_collected_id':sales_tax_account_id,
'account_paid_id':sales_tax_account_id
@ -556,18 +601,28 @@ class account_installer(osv.osv_memory):
purchase_tax_account_id = tax_account_ids and tax_account_ids[0] or False
vals_tax_code = {
'name': 'TAX%s%%'%(p_tax*100),
'code': 'TAX%s%%'%(p_tax*100),
'code': 'TAX%s%%'%(p_tax*100),
'company_id': company_id.id,
'sign': 1,
'parent_id':pur_tax_parent_id
'parent_id': pur_taxcode_parent_id
}
new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code)
vals_paid_tax_code = {
'name': 'TAX Paid %s%%'%(p_tax*100),
'code': 'TAX Paid %s%%'%(p_tax*100),
'company_id': company_id.id,
'sign': 1,
'parent_id': pur_taxcode_paid_parent_id
}
new_paid_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_paid_tax_code)
purchase_tax = obj_tax.create(cr, uid,
{'name':'TAX%s%%'%(p_tax*100),
'description':'TAX%s%%'%(p_tax*100),
'amount':p_tax,
'base_code_id':new_tax_code,
'tax_code_id':new_tax_code,
'tax_code_id':new_paid_tax_code,
'type_tax_use':'purchase',
'account_collected_id':purchase_tax_account_id,
'account_paid_id':purchase_tax_account_id
@ -603,14 +658,6 @@ class account_installer(osv.osv_memory):
elif res['period'] == '3months':
fy_obj.create_period3(cr, uid, [fiscal_id])
# #fially inactive the demo chart of accounts
# data_id = data_pool.search(cr, uid, [('model','=','account.account'), ('name','=','chart0')])
# if data_id:
# data = data_pool.browse(cr, uid, data_id[0])
# account_id = data.res_id
# acc_ids = obj_acc._get_children_and_consol(cr, uid, [account_id])
# if acc_ids:
# cr.execute("update account_account set active='f' where id in " + str(tuple(acc_ids)))
def modules_to_install(self, cr, uid, ids, context=None):
modules = super(account_installer, self).modules_to_install(

View File

@ -332,6 +332,7 @@ class account_invoice(osv.osv):
}
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
journal_obj = self.pool.get('account.journal')
if context.get('active_model','') in ['res.partner']:
partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0]
if not view_type:
@ -343,10 +344,10 @@ class account_invoice(osv.osv):
else:
view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name','=','account.invoice.form')])[0]
res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
type = context.get('journal_type', 'sale')
for field in res['fields']:
type = context.get('journal_type', 'sale')
if field == 'journal_id':
journal_select = self.pool.get('account.journal')._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
res['fields'][field]['selection'] = journal_select
return res

View File

@ -114,8 +114,7 @@ class journal_print(report_sxw.rml_parse, common_report_header):
journal_id = [journal_id]
obj_mline = self.pool.get('account.move.line')
self.cr.execute('update account_journal_period set state=%s where journal_id IN %s and period_id=%s and state=%s', ('printed', self.journal_ids, period_id, 'draft'))
self.cr.commit()
move_state = ['draft','posted']
if self.target_move == 'posted':
move_state = ['posted']
@ -158,4 +157,4 @@ class journal_print(report_sxw.rml_parse, common_report_header):
report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -41,17 +41,14 @@
I clicked on Change Currency button to change the currency
-
!python {model: account.change.currency}: |
try:
self.view_init(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
self.view_init(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
"active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids":
[ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
})
self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
})
self.change_currency(cr, uid, [ref("account_change_currency_0")], {"lang": 'en_US',
"active_model": "account.invoice", "tz": False, "record_id": 4, "active_ids":
[ref("account_invoice_currency")], "type": "out_invoice", "active_id": ref("account_invoice_currency"),
})
except:
print "You can not change currency for Open Invoice !"
})
-
I can't change the currency of invoice when it is not in draft state so i change the state to cancel
-

View File

@ -143,7 +143,6 @@
(data, format) = netsvc.LocalService('report.account.account.balance').create(cr, uid, [ref('account.bal'),ref('account.gpf')], data_dict, {'periods': []})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-account_balance-normal.'+format), 'wb+').write(data)
print "Account Balance Report in Normal mode - From Menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids':[ref('account.bal'),ref('account.gpf')]})
@ -174,7 +173,6 @@
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-central_journal.'+format), 'wb+').write(data)
print "Central Journal Report - From Menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids':journal_period_ids})
@ -226,7 +224,6 @@
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger.'+format), 'wb+').write(data)
print "GL report from menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids': acc_ids})
(data, format) = netsvc.LocalService('report.account.general.ledger').create(cr, uid, [], data_dict, {})
@ -255,7 +252,6 @@
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-landscape.'+format), 'wb+').write(data)
print "GL report landscape mode from menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids': acc_ids})
(data, format) = netsvc.LocalService('report.account.general.ledger_landscape').create(cr, uid, [], data_dict, {})
@ -285,7 +281,6 @@
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-print_journal.'+format), 'wb+').write(data)
print "Journal Report - From Menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids':journal_period_ids})

View File

@ -47,8 +47,3 @@ for a in account_lists:
(a2['parent_right']<a['parent_right']))
if a2['parent_id']==a['id']:
assert (a2['parent_left']>a['parent_left']) and (a2['parent_right']<a['parent_right'])
print 'Tests Ok'

View File

@ -45,7 +45,7 @@ class account_invoice_refund(osv.osv_memory):
context = {}
journal = obj_journal.search(cr, uid, [('type', '=', 'sale_refund')])
if context.get('type', False):
if context['type'] == 'in_invoice':
if context['type'] in ('in_invoice', 'in_refund'):
journal = obj_journal.search(cr, uid, [('type', '=', 'purchase_refund')])
return journal and journal[0] or False
@ -55,6 +55,20 @@ class account_invoice_refund(osv.osv_memory):
'filter_refund': 'modify',
}
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
journal_obj = self.pool.get('account.journal')
res = super(account_invoice_refund,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
type = context.get('journal_type', 'sale_refund')
if type in ('sale', 'sale_refund'):
type = 'sale_refund'
else:
type = 'purchase_refund'
for field in res['fields']:
if field == 'journal_id':
journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
res['fields'][field]['selection'] = journal_select
return res
def compute_refund(self, cr, uid, ids, mode='refund', context=None):
"""
@param cr: the current row, from the database cursor,

View File

@ -11,7 +11,7 @@
<separator string="Refund Invoice Options" colspan="4"/>
<group colspan="4" >
<field name="description"/>
<field name="journal_id"/>
<field name="journal_id" widget='selection'/>
<field name="date"/>
<field name="period"/>
<field name="filter_refund"/>

View File

@ -46,7 +46,7 @@
<field name="arch" type="xml">
<search string="Search Coda">
<group col="10" colspan="4">
<field name="journal_id"/>
<field name="journal_id" widget='selection'/>
<field name="date"/>
<field name="user_id" default="uid"/>
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
@ -57,7 +57,7 @@
<filter string="Date" icon="terp-go-month" domain="[]" context="{'group_by':'date'}"/>
<separator orientation="vertical"/>
<filter string="User" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Company" icon="terp-personal" domain="[]" context="{'group_by':'company_id'}"/>
<filter string="Company" icon="terp-go-home" domain="[]" groups="base.group_multi_company" context="{'group_by':'company_id'}"/>
</group>
</search>
</field>

View File

@ -268,6 +268,18 @@ class payment_line(osv.osv):
else:
return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
def _get_date(self, cr, uid, context=None):
if context is None:
context = {}
date = False
if context.get('order_id') and context['order_id']:
order = self.pool.get('payment.order').browse(cr, uid, context['order_id'], context)
if order.date_prefered == 'fixed':
date = order.date_scheduled
else:
date = time.strftime('%Y-%m-%d')
return date
def _get_ml_inv_ref(self, cr, uid, ids, *a):
res={}
for id in self.browse(cr, uid, ids):
@ -328,6 +340,7 @@ class payment_line(osv.osv):
'state': lambda *args: 'normal',
'currency': _get_currency,
'company_currency': _get_currency,
'date': _get_date,
}
_sql_constraints = [
('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),

View File

@ -88,7 +88,7 @@
<field name="date_scheduled" select="1" attrs="{'readonly':[('date_prefered','!=','fixed')]}" />
<button colspan="2" name="%(action_create_payment_order)d" string="Select Invoices to Pay" type="action" attrs="{'invisible':[('state','=','done')]}" icon="gtk-find"/>
</group>
<field name="line_ids" colspan="4" widget="one2many_list" nolabel="1">
<field name="line_ids" colspan="4" widget="one2many_list" nolabel="1" default_get="{'order_id': active_id}" >
<form string="Payment Line">
<notebook>
<page string="Payment">

View File

@ -529,7 +529,7 @@ class account_voucher(osv.osv):
return {'value':res}
def action_move_line_create(self, cr, uid, ids, context=None):
def _get_payment_term_lines(term_id, amount):
term_pool = self.pool.get('account.payment.term')
if term_id and amount:
@ -648,7 +648,7 @@ class account_voucher(osv.osv):
if line.move_line_id.id:
rec_ids = [master_line, line.move_line_id.id]
rec_list_ids.append(rec_ids)
if not self.pool.get('res.currency').is_zero(cr, uid, inv.currency_id, line_total):
diff = line_total
move_line = {
@ -819,7 +819,9 @@ class account_bank_statement(osv.osv):
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None):
st_line = self.pool.get('account.bank.statement.line').browse(cr, uid, st_line_id, context=context)
if st_line.voucher_id:
self.pool.get('account.voucher').proforma_voucher(cr, uid, [st_line.voucher_id.id], context={'force_name': next_number})
#self.pool.get('account.voucher').proforma_voucher(cr, uid, [st_line.voucher_id.id], context={'force_name': next_number})
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr)
return self.pool.get('account.move.line').write(cr, uid, [x.id for x in st_line.voucher_id.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line, company_currency_id, next_number, context=context)
@ -853,4 +855,12 @@ class account_bank_statement_line(osv.osv):
}
def unlink(self, cr, uid, ids, context=None):
statement_line = self.browse(cr, uid, ids, context)
unlink_ids = []
for st_line in statement_line:
unlink_ids.append(st_line.voucher_id.id)
self.pool.get('account.voucher').unlink(cr, uid, unlink_ids, context=context)
return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)
account_bank_statement_line()

View File

@ -179,21 +179,6 @@
<field name="search_view_id" ref="view_voucher_filter"/>
</record>
<record id="view_bank_statement_form_invoice_periodic" model="ir.ui.view">
<field name="name">account.bank.statement.invoice.form.inherit</field>
<field name="model">account.bank.statement</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_bank_statement_periodic_form"/>
<field name="arch" type="xml">
<field name="currency" invisible="1" position="after">
<button name="%(action_view_account_statement_from_invoice_lines)d"
string="Import Invoices" type="action" icon="gtk-execute"
attrs="{'invisible':[('state','=','confirm')]}"/>
</field>
</field>
</record>
<record id="view_bank_statement_form_invoice" model="ir.ui.view">
<field name="name">account.bank.statement.invoice.form.inherit</field>
<field name="model">account.bank.statement</field>

View File

@ -47,12 +47,14 @@ class account_statement_from_invoice_lines(osv.osv_memory):
statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool.get('account.bank.statement.line')
currency_obj = self.pool.get('res.currency')
# statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
voucher_obj = self.pool.get('account.voucher')
voucher_line_obj = self.pool.get('account.voucher.line')
line_date = time.strftime('%Y-%m-%d')
statement = statement_obj.browse(cr, uid, statement_id, context=context)
# for each selected move lines
for line in line_obj.browse(cr, uid, line_ids, context=context):
voucher_res = {}
ctx = context.copy()
# take the date for computation of currency => use payment date
ctx['date'] = line_date
@ -69,10 +71,29 @@ class account_statement_from_invoice_lines(osv.osv_memory):
elif (line.invoice and line.invoice.currency_id.id <> statement.currency.id):
amount = currency_obj.compute(cr, uid, line.invoice.currency_id.id,
statement.currency.id, amount, context=ctx)
voucher_res = { 'type':(amount < 0 and 'payment' or 'receipt') ,
'name': line.name,
'partner_id': line.partner_id.id,
'journal_id': statement.journal_id.id,
'account_id': line.account_id.id,
'company_id':statement.company_id.id,
'currency_id':statement.currency.id,
'date':line.date,
'amount':abs(amount),
'period_id':statement.period_id.id}
voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'))
voucher_line_dict = False
if result['value']['line_ids']:
for line_dict in result['value']['line_ids']:
move_line = line_obj.browse(cr, uid, line_dict['move_line_id'], context)
if line.move_id.id == move_line.move_id.id:
voucher_line_dict = line_dict
# reconcile_id = statement_reconcile_obj.create(cr, uid, {
# 'line_ids': [(6, 0, [line.id])]
# }, context=context)
if voucher_line_dict:
voucher_line_dict.update({'voucher_id':voucher_id})
voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
if line.journal_id.type == 'sale':
type = 'customer'
elif line.journal_id.type == 'purchase':
@ -87,7 +108,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
'account_id': line.account_id.id,
'statement_id': statement_id,
'ref': line.ref,
# 'reconcile_id': reconcile_id,
'voucher_id': voucher_id,
'date': time.strftime('%Y-%m-%d'), #time.strftime('%Y-%m-%d'), #line.date_maturity or,
}, context=context)
return {}

View File

@ -45,12 +45,12 @@ class decimal_precision(osv.osv):
return res and res[0] or 2
def write(self, cr, uid, ids, data, *args, **argv):
self.precision_get.clear_cache(cr.dbname)
res = super(decimal_precision, self).write(cr, uid, ids, data, *args, **argv)
for obj in self.pool.obj_list():
for colname,col in self.pool.get(obj)._columns.items():
if isinstance(col, fields.float):
col.digits_change(cr)
self.precision_get.clear_cache(cr.dbname)
return res
decimal_precision()

View File

@ -23,11 +23,14 @@
import time
import datetime
from itertools import groupby
from operator import itemgetter
import netsvc
from osv import fields, osv
from tools.translate import _
class hr_holidays_status(osv.osv):
_name = "hr.holidays.status"
_description = "Leave Type"
@ -35,39 +38,51 @@ class hr_holidays_status(osv.osv):
def get_days_cat(self, cr, uid, ids, category_id, return_false, context=None):
if context is None:
context = {}
cr.execute("""SELECT id, type, number_of_days, holiday_status_id FROM hr_holidays WHERE category_id = %s AND state='validate' AND holiday_status_id in %s""",
[category_id, tuple(ids)])
result = sorted(cr.dictfetchall(), key=lambda x: x['holiday_status_id'])
grouped_lines = dict((k, [v for v in itr]) for k, itr in groupby(result, itemgetter('holiday_status_id')))
res = {}
for record in self.browse(cr, uid, ids, context=context):
res[record.id] = {}
max_leaves = leaves_taken = 0
if not return_false:
cr.execute("""SELECT type, sum(number_of_days) FROM hr_holidays WHERE category_id = %s AND state='validate' AND holiday_status_id = %s GROUP BY type""", (str(category_id), str(record.id)))
for line in cr.fetchall():
if line[0] =='remove':
leaves_taken = -line[1]
if line[0] =='add':
max_leaves = line[1]
if record.id in grouped_lines:
leaves_taken = -sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'remove'])
max_leaves = sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'add'])
res[record.id]['max_leaves'] = max_leaves
res[record.id]['leaves_taken'] = leaves_taken
res[record.id]['remaining_leaves'] = max_leaves - leaves_taken
return res
def get_days(self, cr, uid, ids, employee_id, return_false, context=None):
if context is None:
context = {}
cr.execute("""SELECT id, type, number_of_days, holiday_status_id FROM hr_holidays WHERE employee_id = %s AND state='validate' AND holiday_status_id in %s""",
[employee_id, tuple(ids)])
result = sorted(cr.dictfetchall(), key=lambda x: x['holiday_status_id'])
grouped_lines = dict((k, [v for v in itr]) for k, itr in groupby(result, itemgetter('holiday_status_id')))
res = {}
for record in self.browse(cr, uid, ids, context=context):
res[record.id] = {}
max_leaves = leaves_taken = 0
if not return_false:
cr.execute("""SELECT type, sum(number_of_days) FROM hr_holidays WHERE employee_id = %s AND state='validate' AND holiday_status_id = %s GROUP BY type""", (str(employee_id), str(record.id)))
for line in cr.fetchall():
if line[0] =='remove':
leaves_taken = -line[1]
if line[0] =='add':
max_leaves = line[1]
if record.id in grouped_lines:
leaves_taken = -sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'remove'])
max_leaves = sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'add'])
res[record.id]['max_leaves'] = max_leaves
res[record.id]['leaves_taken'] = leaves_taken
res[record.id]['remaining_leaves'] = max_leaves - leaves_taken
return res
def _user_left_days(self, cr, uid, ids, name, args, context=None):

View File

@ -34,8 +34,6 @@ class one2many_mod2(fields.one2many):
if values is None:
values = {}
res = {}.fromkeys(ids, [])
# dict:
# {idn: (date_current, user_id), ...
# 1: ('2010-08-15', 1)}
@ -59,9 +57,13 @@ class one2many_mod2(fields.one2many):
ids2 = obj.pool.get(self._obj).search(cr, user, dom, limit=self._limit)
res = {}
for i in ids:
res[i] = []
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
if r[self._fields_id]:
res.setdefault(r[self._fields_id][0], []).append(r['id'])
res[r[self._fields_id][0]].append(r['id'])
return res
@ -82,7 +84,6 @@ class one2many_mod(fields.one2many):
if values is None:
values = {}
res = {}.fromkeys(ids, [])
res5 = obj.read(cr, user, ids, ['date_current', 'user_id'], context=context)
res6 = {}
@ -96,11 +97,13 @@ class one2many_mod(fields.one2many):
dom = [('date', '=', res6[id][0]), ('user_id', '=', res6[id][1])]
ids2.extend(obj.pool.get(self._obj).search(cr, user,
dom, limit=self._limit))
res = {}
for i in ids:
res[i] = []
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2,
[self._fields_id], context=context, load='_classic_write'):
if r[self._fields_id]:
res.setdefault(r[self._fields_id][0], []).append(r['id'])
res[r[self._fields_id][0]].append(r['id'])
return res

View File

@ -357,7 +357,9 @@ class many2many_domain(fields.many2many):
context = {}
move_obj = obj.pool.get('stock.move')
res = {}.fromkeys(ids, [])
res = {}
for i in ids:
res[i] = []
valid_move_ids = move_obj.search(cr, user, self._domain) # move ids relative to domain argument
cr.execute("SELECT production_id, move_id from mrp_production_move_ids where production_id in %s and move_id in %s",
[tuple(ids), tuple(valid_move_ids)])
@ -377,7 +379,9 @@ class one2many_domain(fields.one2many):
context = {}
move_obj = obj.pool.get('stock.move')
res = {}.fromkeys(ids, [])
res = {}
for i in ids:
res[i] = []
move_ids = move_obj.search(cr, user, self._domain+[('production_id', 'in', tuple(ids))], context=context)
related_move_dict = dict([(o.production_id.id, [o.id]) for o in move_obj.browse(cr, user, move_ids, context=context)])
res.update(related_move_dict)