[MERGE] merged the dev3 branch

bzr revid: qdp-launchpad@tinyerp.com-20110201155023-bhmz3wby39n868eq
This commit is contained in:
qdp-launchpad@tinyerp.com
2011-02-01 16:50:23 +01:00
25 changed files with 66 additions and 118 deletions
+6 -5
View File
@@ -301,10 +301,11 @@ class account_account(osv.osv):
for fn in field_names:
sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0)
for child in current.child_id:
if child.company_id.currency_id.id == current.company_id.currency_id.id:
sums[current.id][fn] += sums[child.id][fn]
else:
sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context)
if sums.get(child.id, False):
if child.company_id.currency_id.id == current.company_id.currency_id.id:
sums[current.id][fn] += sums[child.id][fn]
else:
sums[current.id][fn] += currency_obj.compute(cr, uid, child.company_id.currency_id.id, current.company_id.currency_id.id, sums[child.id][fn], context=context)
res = {}
null_result = dict((fn, 0.0) for fn in field_names)
for id in ids:
@@ -995,7 +996,7 @@ class account_journal_period(osv.osv):
return super(account_journal_period, self).write(cr, uid, ids, vals, context=context)
def create(self, cr, uid, vals, context=None):
period_id=vals.get('period_id',False)
period_id = vals.get('period_id',False)
if period_id:
period = self.pool.get('account.period').browse(cr, uid, period_id, context=context)
vals['state']=period.state
+1 -3
View File
@@ -314,7 +314,6 @@ class account_bank_statement(osv.osv):
return state=='draft'
def button_confirm_bank(self, cr, uid, ids, context=None):
done = []
obj_seq = self.pool.get('ir.sequence')
if context is None:
context = {}
@@ -355,7 +354,6 @@ class account_bank_statement(osv.osv):
self.write(cr, uid, [st.id], {'name': st_number}, context=context)
self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,))
done.append(st.id)
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
def button_cancel(self, cr, uid, ids, context=None):
@@ -463,7 +461,7 @@ class account_bank_statement_line(osv.osv):
select=True, required=True, ondelete='cascade'),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
'move_ids': fields.many2many('account.move',
'account_bank_statement_line_move_rel', 'move_id','statement_id',
'account_bank_statement_line_move_rel', 'statement_id','move_id',
'Moves'),
'ref': fields.char('Reference', size=32),
'note': fields.text('Notes'),
+1 -60
View File
@@ -522,7 +522,7 @@ class account_invoice(osv.osv):
if not result_id:
raise osv.except_osv(_('Configuration Error !'),
_('Can not find account chart for this company in invoice line account, Please Create account.'))
inv_line_obj.write(cr, uid, [line.id], {'account_id': result_id[0]})
inv_line_obj.write(cr, uid, [line.id], {'account_id': result_id[-1]})
else:
if invoice_line:
for inv_line in invoice_line:
@@ -1310,65 +1310,6 @@ class account_invoice_line(osv.osv):
result = {}
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
if company_id:
property_obj = self.pool.get('ir.property')
account_obj = self.pool.get('account.account')
in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
if not in_pro_id:
in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
if not exp_pro_id:
exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
if not in_pro_id:
in_acc = res.product_tmpl_id.property_account_income
in_acc_cate = res.categ_id.property_account_income_categ
if in_acc:
app_acc_in = in_acc
else:
app_acc_in = in_acc_cate
else:
# Get the fields from the ir.property record
my_value = property_obj.read(cr,uid,in_pro_id,['name','value_reference','res_id'])
# Parse the value_reference field to get the ID of the account.account record
account_id = int (my_value[0]["value_reference"].split(",")[1])
# Use the ID of the account.account record in the browse for the account.account record
app_acc_in = account_obj.browse(cr, uid, account_id, context=context)
if not exp_pro_id:
ex_acc = res.product_tmpl_id.property_account_expense
ex_acc_cate = res.categ_id.property_account_expense_categ
if ex_acc:
app_acc_exp = ex_acc
else:
app_acc_exp = ex_acc_cate
else:
app_acc_exp = account_obj.browse(cr, uid, exp_pro_id, context=context)[0]
if not in_pro_id and not exp_pro_id:
in_acc = res.product_tmpl_id.property_account_income
in_acc_cate = res.categ_id.property_account_income_categ
ex_acc = res.product_tmpl_id.property_account_expense
ex_acc_cate = res.categ_id.property_account_expense_categ
if in_acc or ex_acc:
app_acc_in = in_acc
app_acc_exp = ex_acc
else:
app_acc_in = in_acc_cate
app_acc_exp = ex_acc_cate
if app_acc_in and app_acc_in.company_id.id != company_id and app_acc_exp and app_acc_exp.company_id.id != company_id:
in_res_id = account_obj.search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)])
exp_res_id = account_obj.search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)])
if not in_res_id and not exp_res_id:
raise osv.except_osv(_('Configuration Error !'),
_('Can not find account chart for this company, Please Create account.'))
in_obj_acc = account_obj.browse(cr, uid, in_res_id, context=context)
exp_obj_acc = account_obj.browse(cr, uid, exp_res_id, context=context)
if in_acc or ex_acc:
res.product_tmpl_id.property_account_income = in_obj_acc[0]
res.product_tmpl_id.property_account_expense = exp_obj_acc[0]
else:
res.categ_id.property_account_income_categ = in_obj_acc[0]
res.categ_id.property_account_expense_categ = exp_obj_acc[0]
if type in ('out_invoice','out_refund'):
a = res.product_tmpl_id.property_account_income.id
if not a:
+2 -2
View File
@@ -136,7 +136,7 @@
<field name="help">The normal chart of accounts has a structure defined by the legal requirement of the country. The analytic chart of account structure should reflect your own business needs in term of costs/revenues reporting. They are usually structured by contracts, projects, products or departements. Most of the OpenERP operations (invoices, timesheets, expenses, etc) generate analytic entries on the related account.</field>
</record>
<menuitem groups="analytic.group_analytic_accounting" id="next_id_40"
<menuitem groups="analytic.group_analytic_accounting" id="next_id_40"
name="Analytic" parent="account.menu_finance_generic_reporting"
sequence="4"/>
@@ -373,7 +373,7 @@
<field name="help">To print an analytics (or costs) journal for a given period. The report give code, move name, account number, general amount and analytic amount.</field>
</record>
<menuitem groups="analytic.group_analytic_accounting"
action="action_account_analytic_journal_tree"
action="action_account_analytic_journal_tree"
id="account_analytic_journal_print" parent="account.next_id_40"/>
#
+2 -2
View File
@@ -89,10 +89,10 @@ class account_balance(report_sxw.rml_parse, common_report_header):
self.sum_debit += account_rec['debit']
self.sum_credit += account_rec['credit']
if disp_acc == 'bal_movement':
if currency_obj.is_zero(self.cr, self.uid, currency, res['credit']) > 0 or currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) > 0 or currency_obj.is_zero(self.cr, self.uid, currency, res['balance']) != 0:
if not currency_obj.is_zero(self.cr, self.uid, currency, res['credit']) > 0 or not currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) > 0 or not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']):
self.result_acc.append(res)
elif disp_acc == 'bal_solde':
if currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) != 0:
if not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']):
self.result_acc.append(res)
else:
self.result_acc.append(res)
@@ -207,7 +207,6 @@ class account_balance_landscape(report_sxw.rml_parse):
return cmp(x.code, y.code)
for n in range(0,len(accounts)):
accounts[n].sort(cmp_code)
common={}
merged_accounts=zip(*accounts)
for entry in merged_accounts:
@@ -143,10 +143,10 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header)
if typ == 'asset' and account.type <> 'view' and (account.debit <> account.credit):
self.result_sum_cr += account.balance
if data['form']['display_account'] == 'bal_movement':
if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0:
if not currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
accounts_temp.append(account_dict)
elif data['form']['display_account'] == 'bal_solde':
if currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0:
if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
accounts_temp.append(account_dict)
else:
accounts_temp.append(account_dict)
@@ -296,7 +296,6 @@ class partner_balance(report_sxw.rml_parse, common_report_header):
def _get_partners(self):
cr, uid = self.cr, self.uid
context = self.localcontext # all of it?
if self.result_selection == 'customer':
return _('Receivable Accounts')
+2 -2
View File
@@ -113,10 +113,10 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header):
if typ == 'income' and account.type <> 'view' and (account.debit <> account.credit):
self.result_sum_cr += abs(account.debit - account.credit)
if data['form']['display_account'] == 'bal_movement':
if currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0:
if not currency_pool.is_zero(self.cr, self.uid, currency, account.credit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.debit) > 0 or not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
accounts_temp.append(account)
elif data['form']['display_account'] == 'bal_solde':
if currency_pool.is_zero(self.cr, self.uid, currency, account.balance) != 0:
if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
accounts_temp.append(account)
else:
accounts_temp.append(account)
+1 -1
View File
@@ -36,7 +36,7 @@ class account_state_open(osv.osv_memory):
if data_inv.reconciled:
raise osv.except_osv(_('Warning'), _('Invoice is already reconciled'))
wf_service = netsvc.LocalService("workflow")
res = wf_service.trg_validate(uid, 'account.invoice', context['active_ids'][0], 'open_test', cr)
wf_service.trg_validate(uid, 'account.invoice', context['active_ids'][0], 'open_test', cr)
return {'type': 'ir.actions.act_window_close'}
account_state_open()
+1 -1
View File
@@ -107,7 +107,7 @@ class account_use_model(osv.osv_memory):
})
c = context.copy()
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
id_line = account_move_line_obj.create(cr, uid, val, context=c)
account_move_line_obj.create(cr, uid, val, context=c)
context.update({'move_ids':move_ids})
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_move_form')], context=context)
@@ -43,6 +43,7 @@
<field name="res_model">payment.order.create</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_create_payment_order"/>
<field name="target">new</field>
</record>
@@ -518,7 +518,6 @@ class account_voucher(osv.osv):
elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0:
default['value']['pre_line'] = 1
default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price)
return default
def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
@@ -728,7 +727,6 @@ class account_voucher(osv.osv):
line.type = 'cr'
else:
line.type = 'dr'
if (line.type=='dr'):
line_total += amount
move_line['debit'] = amount
@@ -379,7 +379,7 @@
<field name="amount_currency"/>
<field name="currency_id"/>
</tree>
</field>
</field>
</page>
</notebook>
<group col="10" colspan="4">
+5 -5
View File
@@ -109,12 +109,12 @@ class account_analytic_account(osv.osv):
def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
res = self.name_get(cr, uid, ids)
return dict(res)
def _child_compute(self, cr, uid, ids, name, arg, context=None):
result = {}
if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context):
result[account.id] = map(lambda x: x.id, [child for child in account.child_ids if child.state != 'template'])
@@ -224,13 +224,13 @@ class account_analytic_account(osv.osv):
cr.execute("select analytic_account_id from project_project")
project_ids = [x[0] for x in cr.fetchall()]
return self.name_get(cr, uid, project_ids, context=context)
account = self.search(cr, uid, [('code', '=', name)]+args, limit=limit, context=context)
account = self.search(cr, uid, [('code', '=', name)] + args, limit=limit, context=context)
if not account:
account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context)
account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)] + args, limit=limit, context=context)
newacc = account
while newacc:
newacc = self.search(cr, uid, [('parent_id', 'in', newacc)]+args, limit=limit, context=context)
account+=newacc
account += newacc
return self.name_get(cr, uid, account, context=context)
account_analytic_account()
+3 -2
View File
@@ -24,6 +24,7 @@ import time
import netsvc
from osv import fields, osv
from tools.translate import _
import decimal_precision as dp
def _employee_get(obj, cr, uid, context=None):
if context is None:
@@ -225,8 +226,8 @@ class hr_expense_line(osv.osv):
'name': fields.char('Expense Note', size=128, required=True),
'date_value': fields.date('Date', required=True),
'expense_id': fields.many2one('hr.expense.expense', 'Expense', ondelete='cascade', select=True),
'total_amount': fields.function(_amount, method=True, string='Total'),
'unit_amount': fields.float('Unit Price'),
'total_amount': fields.function(_amount, method=True, string='Total', digits_compute=dp.get_precision('Account')),
'unit_amount': fields.float('Unit Price', digits_compute=dp.get_precision('Account')),
'unit_quantity': fields.float('Quantities' ),
'product_id': fields.many2one('product.product', 'Product', domain=[('hr_expense_ok','=',True)]),
'uom_id': fields.many2one('product.uom', 'UoM' ),
+3 -3
View File
@@ -111,7 +111,7 @@ class hr_holidays(osv.osv):
_columns = {
'name': fields.char('Description', required=True, size=64),
'state': fields.selection([('draft', 'Draft'), ('confirm', 'Waiting Approval'), ('refuse', 'Refused'),
'state': fields.selection([('draft', 'Draft'), ('confirm', 'Waiting Approval'), ('refuse', 'Refused'),
('validate1', 'Waiting Second Approval'), ('validate', 'Approved'), ('cancel', 'Cancelled')],
'State', readonly=True, help='When the holiday request is created the state is \'Draft\'.\n It is confirmed by the user and request is sent to admin, the state is \'Waiting Approval\'.\
If the admin accepts it, the state is \'Approved\'. If it is refused, the state is \'Refused\'.'),
@@ -126,7 +126,7 @@ class hr_holidays(osv.osv):
'notes': fields.text('Reasons',readonly=True, states={'draft':[('readonly',False)]}),
'number_of_days_temp': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)]}),
'number_of_days': fields.function(_compute_number_of_days, method=True, string='Number of Days', store=True),
'case_id': fields.char('Meeting', size=64),
'case_id': fields.many2one('crm.meeting', 'Meeting'),
'type': fields.selection([('remove','Leave Request'),('add','Allocation Request')], 'Request Type', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Choose 'Leave Request' if someone wants to take an off-day. \nChoose 'Allocation Request' if you want to increase the number of leaves available for someone"),
'parent_id': fields.many2one('hr.holidays', 'Parent'),
'linked_request_ids': fields.one2many('hr.holidays', 'parent_id', 'Linked Requests',),
@@ -290,7 +290,7 @@ class hr_holidays(osv.osv):
for record in self.browse(cr, uid, ids):
# Delete the meeting
if record.case_id:
obj_crm_meeting.unlink(cr, uid, [record.case_id])
obj_crm_meeting.unlink(cr, uid, [record.case_id.id])
# If a category that created several holidays, cancel all related
wf_service = netsvc.LocalService("workflow")
+1
View File
@@ -318,6 +318,7 @@
action="open_allocation_holidays"/>
<record model="ir.actions.act_window" id="open_company_allocation">
<field name="name">Leaves Summary</field>
<field name="res_model">hr.holidays</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@@ -3,6 +3,7 @@
<data>
<record model="ir.actions.act_window" id="action_hr_available_holidays_report">
<field name="name">Leaves Analysis</field>
<field name="res_model">hr.holidays</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@@ -145,7 +145,7 @@
<para style="terp_tblheader_Details">Bank Account</para>
</td>
<td>
<para style="terp_tblheader_Details">C/D</para>
<para style="terp_tblheader_Details">D/C</para>
</td>
</tr>
</blockTable>
@@ -239,7 +239,7 @@
<para style="terp_tblheader_Details">Bank Account</para>
</td>
<td>
<para style="terp_tblheader_Details">C/D</para>
<para style="terp_tblheader_Details">D/C</para>
</td>
</tr>
</blockTable>
+1 -1
View File
@@ -33,7 +33,7 @@ system to store and search in your CV base.
""",
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'depends': ['hr','survey','crm'],
'depends': ['decimal_precision', 'hr', 'survey', 'crm'],
'update_xml': [
'wizard/hr_recruitment_phonecall_view.xml',
'wizard/hr_recruitment_create_partner_job_view.xml',
+8 -4
View File
@@ -5,18 +5,22 @@
acc_number: 001-1001-1291-12323
bank: base.res_bank_1
bvr_number: 01-101-12
name: Argolait Main Account
partner_id: base.res_partner_agrolait
name: Asustek Main Account
partner_id: base.res_partner_asus
sequence: 0.0
state: bvbank
-
In order to test the BVR report, I will assign a bank to the invoice
-
!record {model: account.invoice, id: account.test_invoice_1}:
!record {model: account.invoice, id: test_invoice_2}:
partner_bank_id: res_partner_bank_account0
address_invoice_id: base.res_partner_address_tang
partner_id: base.res_partner_asus
account_id: account.a_recv
company_id: base.main_company
-
In order to test the PDF reports defined on a l10n_ch, we will print BVR Report
-
!python {model: account.invoice}: |
from tools.test_reports import try_report
try_report(cr, uid, 'report.invoice_web_bvr', [ref('account.test_invoice_1')])
try_report(cr, uid, 'report.invoice_web_bvr', [ref('test_invoice_2')])
+1 -1
View File
@@ -554,7 +554,7 @@ def _create_dta(obj, cr, uid, data, context=None):
dta = dta + record_gt890(v).generate()
dta_data = base64.encodestring(dta)
payment_obj.set_done(cr, uid, data['id'], context)
payment_obj.set_done(cr, uid, [data['id']], context)
attachment_obj.create(cr, uid, {
'name': 'DTA',
'datas': dta_data,
+3 -3
View File
@@ -361,11 +361,11 @@
<field name="name">France PCMN</field>
<field name="account_root_id" ref="pcg_0"/>
<field name="tax_code_root_id" ref="vat_code_chart_root"/>
<field name="bank_account_view_id" ref="fr_pcg_cash"/>
<field name="bank_account_view_id" ref="pcg_5121"/>
<field name="property_account_receivable" ref="fr_pcg_recv"/>
<field name="property_account_payable" ref="fr_pcg_pay"/>
<field name="property_account_expense_categ" ref="fr_pcg_expense"/>
<field name="property_account_income_categ" ref="fr_pcg_sale"/>
<field name="property_account_expense_categ" ref="pcg_6071"/>
<field name="property_account_income_categ" ref="pcg_7071"/>
</record>
<!--
+18 -14
View File
@@ -92,10 +92,11 @@ class sale_order(osv.osv):
if not ids:
return {}
res = {}
tmp = {}
for id in ids:
res[id] = [0.0, 0.0]
tmp[id] = {'picked': 0.0, 'total': 0.0}
cr.execute('''SELECT
p.sale_id, sum(m.product_qty), mp.state as mp_state
p.sale_id as sale_order_id, sum(m.product_qty) as nbr, mp.state as procurement_state, m.state as move_state, p.type as picking_type
FROM
stock_move m
LEFT JOIN
@@ -103,23 +104,26 @@ class sale_order(osv.osv):
LEFT JOIN
procurement_order mp on (mp.move_id=m.id)
WHERE
p.sale_id IN %s GROUP BY mp.state, p.sale_id''', (tuple(ids),))
for oid, nbr, mp_state in cr.fetchall():
if mp_state == 'cancel':
p.sale_id IN %s GROUP BY m.state, mp.state, p.sale_id, p.type''', (tuple(ids),))
for item in cr.dictfetchall():
if item['move_state'] == 'cancel':
continue
if mp_state == 'done':
res[oid][0] += nbr or 0.0
res[oid][1] += nbr or 0.0
if item['picking_type'] == 'in':#this is a returned picking
tmp[item['sale_order_id']]['total'] -= item['nbr'] or 0.0 # Deducting the return picking qty
if item['procurement_state'] == 'done' or item['move_state'] == 'done':
tmp[item['sale_order_id']]['picked'] -= item['nbr'] or 0.0
else:
res[oid][1] += nbr or 0.0
for r in res:
if not res[r][1]:
res[r] = 0.0
else:
res[r] = 100.0 * res[r][0] / res[r][1]
tmp[item['sale_order_id']]['total'] += item['nbr'] or 0.0
if item['procurement_state'] == 'done' or item['move_state'] == 'done':
tmp[item['sale_order_id']]['picked'] += item['nbr'] or 0.0
for order in self.browse(cr, uid, ids, context=context):
if order.shipped:
res[order.id] = 100.0
else:
res[order.id] = tmp[order.id]['total'] and (100.0 * tmp[order.id]['picked'] / tmp[order.id]['total']) or 0.0
return res
def _invoiced_rate(self, cursor, user, ids, name, arg, context=None):