diff options
| author | Fabien Pinckaers <fp@tinyerp.com> | 2010-08-29 22:58:57 +0200 |
|---|---|---|
| committer | Fabien Pinckaers <fp@tinyerp.com> | 2010-08-29 22:58:57 +0200 |
| commit | d64c1eae007c3ee7d623f8768302c91557b0cd7e (patch) | |
| tree | a008d899a6e3271042ff3ea0c9dd59645bc15200 | |
| parent | 1bc0f20a9abc515d6ac578b07edfb94f42c0b2f2 (diff) | |
| parent | 23ed9c4b4ee2e11a26b9476d553534f14473908b (diff) | |
merge
bzr revid: fp@tinyerp.com-20100829205857-285ehurjvns9s7w1
29 files changed, 495 insertions, 201 deletions
diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 96412077840..6f3675392e0 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -60,6 +60,7 @@ module named account_voucher. 'wizard/account_period_close_view.xml', 'wizard/account_fiscalyear_close_state.xml', 'wizard/account_chart_view.xml', + 'wizard/account_tax_chart_view.xml', 'wizard/account_move_journal_view.xml', 'wizard/account_move_line_reconcile_select_view.xml', 'wizard/account_open_closed_fiscalyear_view.xml', diff --git a/addons/account/account.py b/addons/account/account.py index eefe815bf97..f132c933821 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -835,7 +835,7 @@ class account_period(osv.osv): 'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True) } _defaults = { - 'state': lambda *a: 'draft', + 'state': 'draft', } _order = "date_start" @@ -883,13 +883,10 @@ class account_period(osv.osv): return ids def action_draft(self, cr, uid, ids, *args): - users_roles = self.pool.get('res.users').browse(cr, uid, uid).roles_id - for role in users_roles: - if role.name=='Period': - mode = 'draft' - for id in ids: - cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) - cr.execute('update account_period set state=%s where id=%s', (mode, id)) + mode = 'draft' + for id in ids: + cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) + cr.execute('update account_period set state=%s where id=%s', (mode, id)) return True def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=80): diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 270384a1d9f..32403f658fc 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -201,6 +201,7 @@ class account_bank_statement(osv.osv): res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') + account_analytic_line_obj = self.pool.get('account.analytic.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') obj_seq = self.pool.get('ir.sequence') @@ -222,6 +223,11 @@ class account_bank_statement(osv.osv): raise osv.except_osv(_('Configuration Error !'), _('Please verify that an account is defined in the journal.')) + if not st.name == '/': + next_number = st.name + else: + next_number = obj_seq.get(cr, uid, 'account.bank.statement') + for line in st.move_line_ids: if line.state <> 'valid': raise osv.except_osv(_('Error !'), @@ -230,14 +236,18 @@ class account_bank_statement(osv.osv): # In line we get reconcile_id on bank.ste.rec. # in bank stat.rec we get line_new_ids on bank.stat.rec.line for move in st.line_ids: - context.update({'date':move.date}) + if move.analytic_account_id: + if not st.journal_id.analytic_journal_id: + raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,)) + + context.update({'date': move.date}) move_id = account_move_obj.create(cr, uid, { 'journal_id': st.journal_id.id, 'period_id': st.period_id.id, 'date': move.date, }, context=context) account_bank_statement_line_obj.write(cr, uid, [move.id], { - 'move_ids': [(4,move_id, False)] + 'move_ids': [(4, move_id, False)] }) if not move.amount: continue @@ -268,6 +278,7 @@ class account_bank_statement(osv.osv): 'journal_id': st.journal_id.id, 'period_id': st.period_id.id, 'currency_id': st.currency.id, + 'analytic_account_id': move.analytic_account_id and move.analytic_account_id.id or False } amount = res_currency_obj.compute(cr, uid, st.currency.id, @@ -289,7 +300,28 @@ class account_bank_statement(osv.osv): account=acc_cur) val['amount_currency'] = amount_cur - torec.append(account_move_line_obj.create(cr, uid, val , context=context)) + move_line_id = account_move_line_obj.create(cr, uid, val , context=context) + torec.append(move_line_id) + + if move.analytic_account_id: + anal_val = {} + amt = (val['credit'] or 0.0) - (val['debit'] or 0.0) + anal_val = { + 'name': val['name'], + 'ref': val['ref'], + 'date': val['date'], + 'amount': amt, + 'account_id': val['analytic_account_id'], + 'currency_id': val['currency_id'], + 'general_account_id': val['account_id'], + 'journal_id': st.journal_id.analytic_journal_id.id, + 'period_id': val['period_id'], + 'user_id': uid, + 'move_id': move_line_id + } + if val.get('amount_currency', False): + anal_val['amount_currency'] = val['amount_currency'] + account_analytic_line_obj.create(cr, uid, anal_val, context=context) if move.reconcile_id and move.reconcile_id.line_new_ids: for newline in move.reconcile_id.line_new_ids: @@ -367,17 +399,11 @@ class account_bank_statement(osv.osv): account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context) else: account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) - - if st.journal_id.entry_posted: - account_move_obj.write(cr, uid, [move_id], {'state': 'posted'}) + move_name = next_number + ' - ' + str(move.sequence) + account_move_obj.write(cr, uid, [move_id], {'name': move_name, 'state': 'posted'}) # Bank statements will not consider boolean on journal entry_posted self.log(cr, uid, st.id, 'Statement %s is confirmed and entries are created.' % st.name) done.append(st.id) - - next_number = obj_seq.get(cr, uid, 'account.bank.statement') - if not st.name == '/': - next_number = st.name + '/' + next_number[-1:] - account_move_obj.write(cr, uid, [move_id], {'state': 'posted', 'name': next_number}) self.write(cr, uid, [st.id], {'name': next_number}, context=context) self.write(cr, uid, done, {'state':'confirm'}, context=context) @@ -397,28 +423,15 @@ class account_bank_statement(osv.osv): return True def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None): - if not journal_id: - return {'value': {'currency': False}} - account_journal_obj = self.pool.get('account.journal') res_users_obj = self.pool.get('res.users') - res_currency_obj = self.pool.get('res.currency') - cursor.execute('SELECT balance_end_real \ FROM account_bank_statement \ - WHERE journal_id = %s \ - ORDER BY date DESC,id DESC LIMIT 1', (journal_id,)) + WHERE journal_id = %s AND NOT state = %s \ + ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft')) res = cursor.fetchone() balance_start = res and res[0] or 0.0 - - currency_id = account_journal_obj.browse(cursor, user, journal_id, - context=context).currency.id - if not currency_id: - currency_id = res_users_obj.browse(cursor, user, user, - context=context).company_id.currency_id.id - currency = res_currency_obj.name_get(cursor, user, [currency_id], - context=context)[0] - return {'value': {'balance_start': balance_start, 'currency': currency}} + return {'value': {'balance_start': balance_start}} def unlink(self, cr, uid, ids, context=None): stat = self.read(cr, uid, ids, ['state']) @@ -629,6 +642,26 @@ class account_bank_statement_line(osv.osv): else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id + + if not line or (line and not line[0].amount): + res_users_obj = self.pool.get('res.users') + res_currency_obj = self.pool.get('res.currency') + company_currency_id = res_users_obj.browse(cursor, user, user, + context=context).company_id.currency_id.id + if not currency_id: + currency_id = company_currency_id + + cursor.execute('SELECT sum(debit-credit) \ + FROM account_move_line \ + WHERE (reconcile_id is null) \ + AND partner_id = %s \ + AND account_id=%s', (partner_id, account_id)) + pgres = cursor.fetchone() + balance = pgres and pgres[0] or 0.0 + + balance = res_currency_obj.compute(cursor, user, company_currency_id, + currency_id, balance, context=context) + res['value']['amount'] = balance return res def _reconcile_amount(self, cursor, user, ids, name, args, context=None): @@ -669,6 +702,7 @@ class account_bank_statement_line(osv.osv): select=True, required=True, ondelete='cascade'), 'reconcile_id': fields.many2one('account.bank.statement.reconcile', 'Reconcile'), + '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', 'Moves'), diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 41d0344de92..db70d5e0e5a 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -500,7 +500,7 @@ </record> <menuitem action="action_invoice_tree4" id="menu_action_invoice_tree4" parent="menu_finance_payables"/> - <act_window domain="[('partner_id','=',active_id)]" id="act_res_partner_2_account_invoice_opened" name="Invoices" res_model="account.invoice" src_model="res.partner"/> + <act_window context="{'search_default_partner_id':[active_id]}" id="act_res_partner_2_account_invoice_opened" name="Invoices" res_model="account.invoice" src_model="res.partner"/> <act_window domain="[('journal_id','=',active_id),('state','!=','draft'),('reconciled','=',False)]" id="act_account_journal_2_account_invoice_opened" name="Unpaid invoices" res_model="account.invoice" src_model="account.journal"/> diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 3cb21315350..24f4bb795a2 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -3,8 +3,8 @@ <data> <menuitem icon="terp-account" id="menu_finance" name="Accounting" sequence="13"/> - <menuitem id="menu_finance_receivables" name="Receivables" parent="menu_finance" sequence="1" groups="group_account_user,group_account_manager,base.group_system"/> - <menuitem id="menu_finance_payables" name="Payables" parent="menu_finance" sequence="2" groups="group_account_user,group_account_manager,base.group_system"/> + <menuitem id="menu_finance_receivables" name="Customers" parent="menu_finance" sequence="1" groups="group_account_user,group_account_manager,base.group_system"/> + <menuitem id="menu_finance_payables" name="Vendors" parent="menu_finance" sequence="2" groups="group_account_user,group_account_manager,base.group_system"/> <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"/> <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"/> diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index bab05321f4d..c6e24e07842 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -104,7 +104,7 @@ <field name="special"/> <separator colspan="4" string="States"/> <field name="state" select="1"/> - <button name="action_draft" states="done" string="Set to Draft" type="object" icon="gtk-convert"/> + <button name="action_draft" states="done" string="Set to Draft" type="object" icon="gtk-convert" groups="account.group_account_manager"/> </form> </field> </record> @@ -242,8 +242,8 @@ <field name="debit"/> <field name="credit"/> <field name="balance"/> - <field name="company_id" groups="base.group_multi_company"/> <field name="company_currency_id"/> + <field name="company_id" groups="base.group_multi_company"/> <field name="type"/> </tree> </field> @@ -520,6 +520,7 @@ <field name="type"/> <field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/> <field domain="[('journal_id', '=', parent.journal_id), ('type', '<>', 'view')]" name="account_id"/> + <field name="analytic_account_id" groups="base.group_extended" /> <field name="amount"/> <field context="{'partner_id':partner_id,'amount':amount,'account_id':account_id,'currency_id': parent.currency,'journal_id':parent.journal_id, 'date':date}" name="reconcile_id"/> <field name="ref"/> @@ -668,7 +669,6 @@ <field name="period_id"/> <field name="journal_id"/> <field name="partner_id"/> - <field name="reconcile_id"/> <field name="amount" sum="Total Amount"/> <field name="state"/> </tree> @@ -711,9 +711,9 @@ <tree string="Account Tax Code" toolbar="1"> <field name="name"/> <field name="code"/> - <field name="sum"/> <field name="sum_period"/> - <field name="company_id"/> + <field name="sum"/> + <field name="company_id" groups="base.group_multi_company"/> </tree> </field> </record> @@ -858,11 +858,13 @@ <field name="view_id" ref="view_tax_code_tree"/> <field name="help">Chart of Taxes is a tree view reflecting the structure of the Tax Cases (or tax codes) and shows the current tax situation. The tax chart represents the amount of each area of the tax declaration for your country. It’s presented in a hierarchical structure, which can be modified to fit your needs.</field> </record> + + <!-- <menuitem action="action_tax_code_tree" id="menu_action_tax_code_tree" parent="menu_finance_charts" - sequence="12"/> + sequence="12"/> --> <!-- move to wizard --> <!-- Entries lines @@ -1070,8 +1072,11 @@ <newline/> <group expand="0" string="Group By..." colspan="12" col="10"> <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/> + <filter string="Account" icon="terp-folder-orange" context="{'group_by':'account_id'}"/> + <separator orientation="vertical"/> + <filter string="Partner" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/> + <separator orientation="vertical"/> <filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id'}"/> - <filter string="States" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/> </group> <newline/> <group expand="0" string="Extended options..."> @@ -1085,6 +1090,23 @@ </field> </record> + <record id="action_account_moves_all_a" model="ir.actions.act_window"> + <field name="name">Journal Items</field> + <field name="res_model">account.move.line</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="search_view_id" ref="view_account_move_line_filter"/> + </record> + + <menuitem + action="action_account_moves_all_a" + icon="STOCK_JUSTIFY_FILL" + id="menu_action_account_moves_all" + parent="account.menu_finance_entries" + sequence="4" + groups="group_account_user,group_account_manager,base.group_system" + /> + <record id="action_move_line_select" model="ir.actions.act_window"> <field name="name">Entry Lines</field> <field name="res_model">account.move.line</field> @@ -1347,9 +1369,9 @@ res_model="account.move.line" src_model="account.move"/> - <record id="account.act_account_move_to_account_move_line_open" model="ir.actions.act_window"> - <field eval="[(6,0,[ref('account.group_accounting_accountant')])]" name="groups_id"/> - </record> + <record id="account.act_account_move_to_account_move_line_open" model="ir.actions.act_window"> + <field eval="[(6,0,[ref('account.group_accounting_accountant')])]" name="groups_id"/> + </record> <record id="action_move_line_search" model="ir.actions.act_window"> <field name="name">Entry Lines</field> @@ -1412,6 +1434,7 @@ <field name="type"/> <field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/> <field domain="[('journal_id', '=', parent.journal_id)]" name="account_id"/> + <field name="analytic_account_id" groups="base.group_extended" /> <field name="amount"/> <field context="{'partner_id': partner_id, 'amount': amount, 'account_id': account_id, 'date':date}" name="reconcile_id"/> </form> @@ -1818,9 +1841,9 @@ <act_window domain="[('journal_id', '=', active_id)]" id="act_account_journal_2_account_move_line" name="Journal Items" res_model="account.move.line" src_model="account.journal"/> - <act_window context="{'search_default_reconcile_id':False}" domain="[('partner_id', '=', active_id),('reconcile_id','=',False),('account_id.reconcile', '=', True),('account_id.type', 'in', ['receivable', 'payable'])]" id="act_account_partner_account_move_all" name="Receivables & Payables" res_model="account.move.line" src_model="res.partner"/> + <act_window context="{'search_default_reconcile_id':False, 'search_default_partner_id':[active_id]}" domain="[('account_id.reconcile', '=', True),('account_id.type', 'in', ['receivable', 'payable'])]" id="act_account_partner_account_move_all" name="Receivables & Payables" res_model="account.move.line" src_model="res.partner"/> - <act_window domain="[('partner_id', '=', active_id)]" id="act_account_partner_account_move" name="Journal Items" res_model="account.move.line" src_model="res.partner"/> + <act_window context="{'search_default_partner_id':[active_id]}" id="act_account_partner_account_move" name="Journal Items" res_model="account.move.line" src_model="res.partner"/> <record id="view_account_addtmpl_wizard_form" model="ir.ui.view"> <field name="name">Create Account</field> @@ -2364,6 +2387,7 @@ <field name="type"/> <field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/> <field domain="[('journal_id', '=', parent.journal_id), ('type', '<>', 'view')]" name="account_id"/> + <field name="analytic_account_id" groups="base.group_extended" /> <field name="amount"/> <field context="{'partner_id':partner_id,'amount':amount,'account_id':account_id,'currency_id': parent.currency,'journal_id':parent.journal_id, 'date':date}" name="reconcile_id"/> <field name="ref"/> diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml index de8c1ba0cd0..f9512cd4e83 100644 --- a/addons/account/configurable_account_chart.xml +++ b/addons/account/configurable_account_chart.xml @@ -470,6 +470,8 @@ <field name="name">OTAX X</field> <field eval="0.0" name="amount"/> <field name="type">percent</field> + <field name="account_collected_id" ref="conf_ova"/> + <field name="account_paid_id" ref="conf_ova"/> <field name="base_code_id" ref="tax_code_purch_X"/> <field name="tax_code_id" ref="tax_code_output_X"/> <field name="ref_base_code_id" ref="tax_code_purch_X"/> @@ -482,6 +484,8 @@ <field name="name">OTAX O</field> <field eval="0.0" name="amount"/> <field name="type">percent</field> + <field name="account_collected_id" ref="conf_ova"/> + <field name="account_paid_id" ref="conf_ova"/> <field name="base_code_id" ref="tax_code_purch_O"/> <field name="tax_code_id" ref="tax_code_output_O"/> <field name="ref_base_code_id" ref="tax_code_purch_O"/> @@ -524,6 +528,8 @@ <field name="name">ITAX X</field> <field eval="0.0" name="amount"/> <field name="type">percent</field> + <field name="account_collected_id" ref="conf_iva"/> + <field name="account_paid_id" ref="conf_iva"/> <field name="base_code_id" ref="tax_code_sales_X"/> <field name="tax_code_id" ref="tax_code_input_X"/> <field name="ref_base_code_id" ref="tax_code_sales_X"/> @@ -536,6 +542,8 @@ <field name="name">ITAX O</field> <field eval="0.0" name="amount"/> <field name="type">percent</field> + <field name="account_collected_id" ref="conf_iva"/> + <field name="account_paid_id" ref="conf_iva"/> <field name="base_code_id" ref="tax_code_sales_O"/> <field name="tax_code_id" ref="tax_code_input_O"/> <field name="ref_base_code_id" ref="tax_code_sales_O"/> diff --git a/addons/account/data/account_data2.xml b/addons/account/data/account_data2.xml index af55e477b42..980834c0dee 100644 --- a/addons/account/data/account_data2.xml +++ b/addons/account/data/account_data2.xml @@ -247,8 +247,8 @@ <field name="field">state</field> <field eval="14" name="sequence"/> </record> - - + + <record id="account_sp_journal_view" model="account.journal.view"> <field name="name">Sale/Purchase Journal View</field> </record> @@ -346,7 +346,7 @@ <field name="field">reconcile_id</field> <field eval="20" name="sequence"/> </record> - + <record id="account_sp_refund_journal_view" model="account.journal.view"> <field name="name">Sale/Purchase Refund Journal View</field> </record> @@ -444,7 +444,7 @@ <field name="field">reconcile_id</field> <field eval="20" name="sequence"/> </record> - + <!-- Account Journal Sequences --> @@ -461,12 +461,14 @@ <record id="sequence_sale_journal" model="ir.sequence"> <field name="name">Sale Journal</field> <field name="code">account.journal</field> - <field name="prefix"/> + <field eval="3" name="padding"/> + <field name="prefix">%(year)s/</field> </record> <record id="sequence_purchase_journal" model="ir.sequence"> <field name="name">Purchase Journal</field> <field name="code">account.journal</field> - <field name="prefix"/> + <field eval="3" name="padding"/> + <field name="prefix">%(year)s/</field> </record> <!-- @@ -493,10 +495,10 @@ <field name="name">Account Bank Statement</field> <field name="code">account.bank.statement</field> <field name="prefix">St. %(month)s/%(day)s/</field> - <field eval="0" name="number_next"/> + <field eval="1" name="number_next"/> <field eval="1" name="number_increment"/> </record> - + <record id="cash_sequence_statement_type" model="ir.sequence.type"> <field name="name">Cash Statement</field> <field name="code">account.cash.statement</field> diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index bedfed3bb69..fcaca5b19f0 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -346,7 +346,7 @@ <field name="type">sale</field> <field name="view_id" ref="account_sp_journal_view"/> <field name="sequence_id" ref="sequence_sale_journal"/> - <field name="invoice_sequence_id" ref="seq_type_out_invoice"/> + <field name="invoice_sequence_id" ref="seq_out_invoice"/> <field model="account.account" name="default_credit_account_id" ref="a_sale"/> <field model="account.account" name="default_debit_account_id" ref="a_sale"/> <field name="user_id" ref="base.user_root"/> @@ -357,6 +357,7 @@ <field name="type">sale_refund</field> <field name="view_id" ref="account_sp_refund_journal_view"/> <field name="sequence_id" ref="sequence_sale_journal"/> + <field name="invoice_sequence_id" ref="seq_out_refund"/> <field model="account.account" name="default_credit_account_id" ref="a_sale"/> <field model="account.account" name="default_debit_account_id" ref="a_sale"/> <field name="user_id" ref="base.user_root"/> @@ -368,7 +369,7 @@ <field name="type">purchase</field> <field name="view_id" ref="account_sp_journal_view"/> <field name="sequence_id" ref="sequence_purchase_journal"/> - <field name="invoice_sequence_id" ref="seq_type_in_invoice"/> + <field name="invoice_sequence_id" ref="seq_in_invoice"/> <field model="account.account" name="default_debit_account_id" ref="a_expense"/> <field model="account.account" name="default_credit_account_id" ref="a_expense"/> <field name="user_id" ref="base.user_root"/> @@ -379,6 +380,7 @@ <field name="type">purchase_refund</field> <field name="view_id" ref="account_sp_refund_journal_view"/> <field name="sequence_id" ref="sequence_purchase_journal"/> + <field name="invoice_sequence_id" ref="seq_in_refund"/> <field model="account.account" name="default_debit_account_id" ref="a_expense"/> <field model="account.account" name="default_credit_account_id" ref="a_expense"/> <field name="user_id" ref="base.user_root"/> diff --git a/addons/account/installer.py b/addons/account/installer.py index a9d7e12ff72..a9872925321 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -319,15 +319,15 @@ class account_installer(osv.osv_memory): seq_sale = { 'name': 'Sale Journal', 'code': 'account.journal', - 'prefix': 'INV/', - 'padding': 4 + 'prefix': '%(year)s/', + 'padding': 3 } seq_id_sale = obj_sequence.create(cr, uid, seq_sale) seq_purchase = { 'name': 'Purchase Journal', 'code': 'account.journal', - 'prefix': 'VEN/', - 'padding': 4 + 'prefix': '%(year)s/', + 'padding': 3 } seq_id_purchase = obj_sequence.create(cr, uid, seq_purchase) else: @@ -583,8 +583,8 @@ class account_bank_accounts_wizard(osv.osv_memory): _columns = { 'acc_name': fields.char('Account Name.', size=64, required=True), 'bank_account_id': fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True), - 'currency_id': fields.many2one('res.currency', 'Currency'), - 'account_type': fields.selection([('cash','Cash'),('check','Check'),('bank','Bank')], 'Type', size=32), + 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."), + 'account_type': fields.selection([('cash','Cash'),('check','Check'),('bank','Bank')], 'Account Type', size=32), } _defaults = { 'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id, diff --git a/addons/account/invoice.py b/addons/account/invoice.py index e7b95cea8dc..4e1a5a052ec 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -219,7 +219,7 @@ class account_invoice(osv.osv): _name = "account.invoice" _description = 'Invoice' - _order = "id" + _order = "id desc" _columns = { 'name': fields.char('Description', size=64, select=True, readonly=True, states={'draft':[('readonly',False)]}), diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index f3a8cca8ada..7f3c344ebff 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -130,8 +130,8 @@ <act_window id="action_analytic_open" name="Analytic Accounts" - res_model="account.analytic.account" - domain="[('partner_id','=',active_id)]" + res_model="account.analytic.account" + context="{'search_default_partner_id':[active_id]}" src_model="res.partner" view_type="form" view_mode="tree,form,graph,calendar"/> diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index fb7e41101f7..bf0b186e1ea 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -51,7 +51,7 @@ <field name="type">tree</field> <field name="field_parent">child_ids</field> <field name="arch" type="xml"> - <tree toolbar="True" colors="red:(date<=current_date);black:(date>current_date)" string="Analytic account"> + <tree toolbar="True" colors="red:(date<current_date);black:(date>=current_date);black:(date==False)" string="Analytic account"> <field name="name"/> <field name="code"/> <field name="quantity"/> diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index b241b725673..d017a6cbc11 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -156,10 +156,9 @@ <menuitem action="action_account_invoice_report_all" id="menu_action_account_invoice_report_all" parent="account.menu_finance_statistic_report_statement" sequence="0"/> <act_window - domain="[('partner_id', '=', active_id)]" id="act_account_invoice_partner_relation" name="Monthly Turnover" - context="{'search_default_month':1,'search_default_user':1,'group_by_no_leaf':1,'group_by':[]}" + context="{'search_default_partner_id':[active_id], 'search_default_month':1,'search_default_user':1,'group_by_no_leaf':1,'group_by':[]}" res_model="account.invoice.report" src_model="res.partner"/> diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index dea907acf2d..6846e3b771f 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -48,6 +48,7 @@ import account_open_closed_fiscalyear import account_compare_account_balance_report import account_invoice_state import account_chart +import account_tax_chart #TODO: remove this file no moe used # also remove related view fiel diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index aa6b477d30d..9355691369e 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -33,10 +33,11 @@ class account_change_currency(osv.osv_memory): obj_inv = self.pool.get('account.invoice') if context is None: context = {} - state = obj_inv.browse(cr, uid, context['active_id']).state - if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': - raise osv.except_osv(_('Error'), _('You can only change currency for Draft Invoice !')) - pass + if context.get('active_id',False): + state = obj_inv.browse(cr, uid, context['active_id']).state + if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': + raise osv.except_osv(_('Error'), _('You can only change currency for Draft Invoice !')) + pass def change_currency(self, cr, uid, ids, context=None): obj_inv = self.pool.get('account.invoice') diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py index bace3d0ca29..f7de4b593f3 100644 --- a/addons/account/wizard/account_chart.py +++ b/addons/account/wizard/account_chart.py @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + from osv import fields, osv from tools.translate import _ @@ -26,7 +27,7 @@ class account_chart(osv.osv_memory): For Chart of Accounrs """ _name = "account.chart" - _description = "chart" + _description = "Account chart" _columns = { 'fiscalyear': fields.many2one('account.fiscalyear', \ 'Fiscal year', \ @@ -37,11 +38,9 @@ class account_chart(osv.osv_memory): def _get_fiscalyear(self, cr, uid, context=None): """Return default Fiscalyear value""" - fiscalyear_obj = self.pool.get('account.fiscalyear') - fiscalyear = fiscalyear_obj.find(cr, uid) - return fiscalyear + return self.pool.get('account.fiscalyear').find(cr, uid) - def account_chart_open_window(self, cr, uid, ids, context={}): + def account_chart_open_window(self, cr, uid, ids, context=None): """ Opens chart of Accounts @param cr: the current row, from the database cursor, @@ -51,6 +50,8 @@ class account_chart(osv.osv_memory): """ mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') + if context is None: + context = {} data = self.read(cr, uid, ids, [], context=context)[0] result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree') id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id'] @@ -65,6 +66,7 @@ class account_chart(osv.osv_memory): 'fiscalyear': _get_fiscalyear, 'target_move': 'all' } + account_chart() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file diff --git a/addons/account/wizard/account_move_journal_view.xml b/addons/account/wizard/account_move_journal_view.xml index 2520b76a129..b43ad18df6e 100644 --- a/addons/account/wizard/account_move_journal_view.xml +++ b/addons/account/wizard/account_move_journal_view.xml @@ -57,7 +57,7 @@ <!-- </record>--> <!-- <menuitem action="action_account_moves_sale_refund" sequence="5" id="menu_eaction_account_moves_sale_refund" parent="menu_finance_payables" icon="STOCK_JUSTIFY_FILL"/>--> - <record id="action_account_moves_all" model="ir.actions.act_window"> + <record id="action_account_moves_bank" model="ir.actions.act_window"> <field name="name">Journal Items</field> <field name="res_model">account.move.journal</field> <field name="view_type">form</field> @@ -67,10 +67,10 @@ </record> <menuitem - action="action_account_moves_all" + action="action_account_moves_bank" icon="STOCK_JUSTIFY_FILL" - id="menu_eaction_account_moves_all" - parent="account.menu_finance_entries" + id="menu_action_account_moves_bank" + parent="account.menu_finance_bank_and_cash" sequence="4" groups="group_account_user,group_account_manager,base.group_system" /> diff --git a/addons/account/wizard/account_tax_chart.py b/addons/account/wizard/account_tax_chart.py new file mode 100644 index 00000000000..5b5feaf480c --- /dev/null +++ b/addons/account/wizard/account_tax_chart.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import fields, osv + +class account_tax_chart(osv.osv_memory): + """ + For Chart of taxes + """ + _name = "account.tax.chart" + _description = "Account tax chart" + _columns = { + 'period_id': fields.many2one('account.period', \ + 'Period', \ + ), + 'target_move': fields.selection([('all', 'All Entries'), + ('posted', 'All Posted Entries')], 'Target Moves', required=True), + } + + def _get_period(self, cr, uid, context=None): + """Return default period value""" + return self.pool.get('account.period').find(cr, uid) + + def account_tax_chart_open_window(self, cr, uid, ids, context=None): + """ + Opens chart of Accounts + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of account chart’s IDs + @return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries + """ + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + period_obj = self.pool.get('account.period') + if context is None: + context = {} + data = self.read(cr, uid, ids, [], context=context)[0] + result = mod_obj._get_id(cr, uid, 'account', 'action_tax_code_tree') + id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id'] + result = act_obj.read(cr, uid, [id], context=context)[0] + if data['period_id']: + fiscalyear_id = period_obj.read(cr, uid, [data['period_id']], context=context)[0]['fiscalyear_id'][0] + result['context'] = str({'period_id': data['period_id'], \ + 'fiscalyear_id': fiscalyear_id, \ + 'state': data['target_move']}) + else: + result['context'] = str({'state': data['target_move']}) + + if data['period_id']: + result['name'] += ':' + self.pool.get('account.period').read(cr, uid, [data['period_id']], context=context)[0]['code'] + return result + + _defaults = { + 'period_id': _get_period, + 'target_move': 'all' + } + +account_tax_chart() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file diff --git a/addons/account/wizard/account_tax_chart_view.xml b/addons/account/wizard/account_tax_chart_view.xml new file mode 100644 index 00000000000..f60ad394857 --- /dev/null +++ b/addons/account/wizard/account_tax_chart_view.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_account_tax_chart" model="ir.ui.view"> + <field name="name">account.tax.chart.form</field> + <field name="model">account.tax.chart</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Account tax charts"> + <group colspan="4" > + <field name="period_id"/> + <label align="0.7" colspan="6" string="(If you do not select period it will take all open periods)"/> + <field name="target_move"/> + </group> + <separator string="" colspan="4" /> + <group colspan="4" col="6"> + <label string ="" colspan="2"/> + <button icon="gtk-cancel" special="cancel" string="Cancel" /> + <button icon="terp-gtk-go-back-rtl" string="Open Charts" name="account_tax_chart_open_window" type="object" /> + </group> + </form> + </field> + </record> + + <record id="action_account_tax_chart" model="ir.actions.act_window"> + <field name="name">Chart of Taxes</field> + <field name="res_model">account.tax.chart</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="domain">[('parent_id','=',False)]</field> + <field name="view_id" ref="view_account_tax_chart"/> + <field name="help">Chart of Taxes is a tree view reflecting the structure of the Tax Cases (or tax codes) and shows the current tax situation. The tax chart represents the amount of each area of the tax declaration for your country. It’s presented in a hierarchical structure, which can be modified to fit your needs.</field> + <field name="target">new</field> + </record> + + <menuitem + icon="STOCK_INDENT" + action="action_account_tax_chart" + id="menu_action_tax_code_tree" + parent="menu_finance_charts" + sequence="12"/> + + </data> +</openerp> diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index e8a02320533..4cc44433ff8 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -44,6 +44,9 @@ class account_move_line(osv.osv): account_move_line() class account_voucher(osv.osv): + def _get_type(self, cr, uid, ids, context={}): + return context.get('type') + def _get_period(self, cr, uid, context={}): if context.get('period_id', False): return context.get('period_id') @@ -81,6 +84,12 @@ class account_voucher(osv.osv): _order = "date desc, id desc" _rec_name = 'number' _columns = { + 'type':fields.selection([ + ('sale','Sale'), + ('purchase','Purchase'), + ('payment','Payment'), + ('receipt','Receipt'), + ],'Type'), 'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}), 'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"), 'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}), @@ -88,9 +97,9 @@ class account_voucher(osv.osv): 'line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}), 'line_cr_ids':fields.one2many('account.voucher.line','voucher_id','Credits', - domain=[('type','=','cr')], context={'default_type':'cr'}), + domain=[('type','=','cr')], context={'default_type':'cr'}, readonly=True, states={'draft':[('readonly',False)]}), 'line_dr_ids':fields.one2many('account.voucher.line','voucher_id','Debits', - domain=[('type','=','dr')], context={'default_type':'dr'}), + domain=[('type','=','dr')], context={'default_type':'dr'}, readonly=True, states={'draft':[('readonly',False)]}), 'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'narration':fields.text('Narration', readonly=True, states={'draft':[('readonly',False)]}), 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}), @@ -110,7 +119,7 @@ class account_voucher(osv.osv): 'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Payment or Receipt transaction number, i.e. Bank cheque number or payorder number or Wire transfer number or Acknowledge number."), 'number': fields.related('move_id', 'name', type="char", readonly=True, string='Number'), 'move_id':fields.many2one('account.move', 'Account Entry'), - 'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Journal Items', readonly=True, states={'draft':[('readonly',False)]}), + 'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Journal Items', readonly=True), 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, states={'draft':[('readonly',False)]}), 'audit': fields.related('move_id','to_check', type='boolean', relation='account.move', string='Audit Complete ?'), 'pay_now':fields.selection([ @@ -119,11 +128,14 @@ class account_voucher(osv.osv): ],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}), 'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}), 'pre_line':fields.boolean('Previous Payments ?', required=False), + 'date_due': fields.date('Due Date'), + 'term_id':fields.many2one('account.payment.term', 'Term', required=False), } _defaults = { 'period_id': _get_period, 'journal_id':_get_journal, 'currency_id': _get_currency, + 'type':_get_type, 'state': lambda *a: 'draft', 'pay_now':lambda *a: 'pay_later', 'name': lambda *a: '', @@ -196,9 +208,23 @@ class account_voucher(osv.osv): return { 'value':res } - - def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, context={}): - """ + + def onchange_term_id(self, cr, uid, ids, term_id, amount): + term_pool = self.pool.get('account.payment.term') + terms = False + due_date = False + default = {'date_due':False} + if term_id and amount: + terms = term_pool.compute(cr, uid, term_id, amount) + if terms: + due_date = terms[-1][0] + default.update({ + 'date_due':due_date + }) + return {'value':default} + + def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, ttype=False, context={}): + """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @@ -215,33 +241,46 @@ class account_voucher(osv.osv): partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') default = { - 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': 0}, + 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False}, } - # TODO: improve this if possible ! if not partner_id: - if ids: - line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) - if line_ids: - line_pool.unlink(cr, uid, line_ids) + return default + + if not partner_id and ids: + line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) + if line_ids: + line_pool.unlink(cr, uid, line_ids) return default journal = journal_pool.browse(cr, uid, journal_id) partner = partner_pool.browse(cr, uid, partner_id) account_id = False + term_id = False if journal.type in ('sale','sale_refund'): account_id = partner.property_account_receivable.id elif journal.type in ('purchase', 'purchase_refund','expense'): + term_id = partner.property_payment_term.id + if term_id: + vals = self.onchange_term_id(cr, uid, ids, term_id, price) + default['value'].update(vals.get('value')) account_id = partner.property_account_payable.id else: account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id default['value'].update({ - 'account_id':account_id + 'account_id':account_id, + 'term_id':term_id }) if journal.type not in ('cash', 'bank'): return default - - ids = move_line_pool.search(cr, uid, [('account_id.type','in', ('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) + + account_type = 'receivable' + if ttype == 'payment': + account_type = 'payable' + else: + account_type = 'receivable' + + ids = move_line_pool.search(cr, uid, [('account_id.type','=', account_type), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) moves = move_line_pool.browse(cr, uid, ids) total_credit = price or 0.0 total_debit = 0.0 @@ -275,7 +314,11 @@ class account_voucher(osv.osv): default['value']['line_cr_ids'].append(rs) else: default['value']['line_dr_ids'].append(rs) + + if ttype == 'payment' and len(default['value']['line_cr_ids']) > 0: default['value']['pre_line'] = 1 + elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0: + default['value']['pre_line'] = 1 return default @@ -296,11 +339,10 @@ class account_voucher(osv.osv): } } - # TODO def onchange_journal(self, cr, uid, ids, journal_id): return {} - def proforma_voucher(self, cr, uid, ids, context={}): + def proforma_voucher(self, cr, uid, ids): self.action_move_line_create(cr, uid, ids) return True @@ -352,6 +394,14 @@ class account_voucher(osv.osv): } def action_move_line_create(self, cr, uid, ids, *args): + + def _get_payment_term_lines(term_id, amount): + term_pool = self.pool.get('account.payment.term') + if term_id and amount: + terms = term_pool.compute(cr, uid, term_id, amount) + return terms + return False + move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') @@ -380,27 +430,49 @@ class account_voucher(osv.osv): } move_id = move_pool.create(cr, uid, move) company_currency = inv.account_id.company_id.currency_id.id - + #create the first line manually debit = 0.0 credit = 0.0 - # TODO: to improve to select debit or credit - if True: + # TODO: is there any other alternative then the voucher type ?? + if inv.type in ('purchase', 'payment'): + credit = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount) + elif inv.type in ('sale', 'receipt'): debit = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount) - move_line = { - 'name':inv.name or '/', - 'debit':debit, - 'credit':credit, - 'account_id':inv.account_id.id, - 'move_id':move_id , - 'journal_id':inv.journal_id.id, - 'period_id':inv.period_id.id, - 'partner_id':inv.partner_id.id, - 'currency_id':inv.currency_id.id, - 'date':inv.date - } - - master_line = move_line_pool.create(cr, uid, move_line) + + if inv.type == 'purchase' and inv.term_id and _get_payment_term_lines(inv.term_id.id, credit or debit): + terms = _get_payment_term_lines(inv.term_id.id, credit or debit) + for term in terms: + due_date = term[0] + amount = term[1] + move_line = { + 'name':inv.name or '/', + 'debit':0.0, + 'credit':amount, + 'date_maturity':due_date, + 'account_id':inv.account_id.id, + 'move_id':move_id , + 'journal_id':inv.journal_id.id, + 'period_id':inv.period_id.id, + 'partner_id':inv.partner_id.id, + 'currency_id':inv.currency_id.id, + 'date':inv.date + } + master_line = move_line_pool.create(cr, uid, move_line) + else: + move_line = { + 'name':inv.name or '/', + 'debit':debit, + 'credit':credit, + 'account_id':inv.account_id.id, + 'move_id':move_id , + 'journal_id':inv.journal_id.id, + 'period_id':inv.period_id.id, + 'partner_id':inv.partner_id.id, + 'currency_id':inv.currency_id.id, + 'date':inv.date + } + master_line = move_line_pool.create(cr, uid, move_line) rec_list_ids = [] line_total = debit - credit @@ -547,9 +619,9 @@ class account_voucher_line(osv.osv): return res _columns = { - 'voucher_id':fields.many2one('account.voucher', 'Voucher', required=1), + 'voucher_id':fields.many2one('account.voucher', 'Voucher', required=1, ondelete='cascade'), 'name':fields.char('Description', size=256), - 'account_id':fields.many2one('account.account','Account', required=True, domain=[('type','<>','view')]), + 'account_id':fields.many2one('account.account','Account', required=True), 'partner_id':fields.related('voucher_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'), 'amount':fields.float('Amount'), 'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Cr/Dr'), @@ -616,7 +688,11 @@ class account_voucher_line(osv.osv): elif journal.type in ('purchase', 'expense', 'sale_refund'): account_id = journal.default_debit_account_id and journal.default_debit_account_id.id or False elif partner_id: - account_id = partner_pool.browse(cr, user, partner_id, context=context).property_account_receivable.id + partner = partner_pool.browse(cr, user, partner_id, context=context) + if context.get('type') == 'payment': + account_id = partner.property_account_payable.id + elif context.get('type') == 'receipt': + account_id = partner.property_account_receivable.id if (not account_id) and 'account_id' in fields_list: raise osv.except_osv(_('Invalid Error !'), _('Please change partner and try again !')) diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 8044093e7fb..4ffba531dc4 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -8,33 +8,57 @@ <field name="arch" type="xml"> <form string="Bill Payment"> <group col="6" colspan="4"> - <field name="partner_id" on_change="onchange_partner_id(partner_id, type, journal_id)"/> + <field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, type)" string="Customer"/> + <field name="journal_id" + domain="[('type','in',['bank', 'cash'])]" + widget="selection" select="1" + on_change="onchange_partner_id(partner_id, journal_id, amount)" + string="Payment Method"/> + <field name="amount"/> + <field name="reference" select="1" string="Payment Ref"/> <field name="name" colspan="4"/> - <field name="journal_id" domain="[('type','in',['bank', 'cash'])]" widget="selection" select="1" on_change="onchange_journal(journal_id,type)"/> - <field name="account_id" domain="[('type','=','other')]" widget="selection" on_change="onchange_account(account_id)" readonly="1"/> - <field name="number"/> + <field name="account_id" + domain="[('type','=','other')]" + widget="selection" + on_change="onchange_account(account_id)" + invisible="True"/> + <field name="pre_line" invisible="1"/> + <field name="type" invisible="True"/> </group> <notebook colspan="4"> <page string="Payment Information"> - <field name="line_ids" on_change="onchange_price(line_ids, False, False)" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180"> + <field name="line_dr_ids" on_change="onchange_price(line_dr_ids, False, False)" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140"> <tree string="Payment Lines" editable="bottom"> - <field name="ref" on_change="onchange_partner(parent.partner_id,type,parent.type, parent.currency_id)"/> - <field name="amount"/> - <field name="account_id"/> - <field name="type" on_change="onchange_type(parent.partner_id,type,parent.type, parent.currency_id)"/> - <field name="account_analytic_id"/> + <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}" + on_change="onchange_move_line_id(move_line_id)" + domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]" + /> + <field name="account_id" domain="[('type','=','payable')]"/> + <field name="date_original" readonly="1"/> + <field name="date_due" readonly="1"/> + <field name="amount_original" readonly="1"/> + <field name="amount_unreconciled" sum="Open Balance" readonly="1"/> + <field name="amount" sum="Payment"/> + </tree> + </field> + <field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}"> + <tree string="Credits" editable="bottom"> + <field name="move_line_id"/> + <field name="account_id" domain="[('type','=','receivable')]"/> + <field name="date_original"/> + <field name="amount_original"/> + <field name="amount" sum="Payment"/> </tree> </field> <group col="2" colspan="3"> - <separator string="Narration" colspan="2"/> + <separator string="Internal Notes" colspan="2"/> <field name="narration" colspan="2" nolabel="1"/> </group> <group col="2" colspan="1"> <separator string="Other Information" colspan="2"/> - <field name="reference" select="1"/> <field name="date" select="1" on_change="onchange_date(date)"/> <field name="currency_id" select="1" attrs="{'readonly':[('type','in',['sale', 'purchase'])]}"/> - <field name="type" on_change="onchange_journal(journal_id,type)"/> + <field name="number"/> </group> </page> <page string="Journal Items"> @@ -77,13 +101,14 @@ <field name="arch" type="xml"> <form string="Sales Payment"> <group col="6" colspan="4"> - <field name="partner_id" on_change="onchange_partner_id(partner_id, journal_id, amount)" string="Customer"/> + <field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, type)" string="Customer"/> <field name="journal_id" domain="[('type','in',['bank', 'cash'])]" widget="selection" select="1" - on_change="onchange_partner_id(partner_id, journal_id, amount)" + on_change="onchange_partner_id(partner_id, journal_id, amount, type)" string="Payment Method"/> - <field name="amount" on_change="onchange_partner_id(partner_id, journal_id, amount)"/> + <field name="amount" + on_change="onchange_partner_id(partner_id, journal_id, amount, type)"/> <field name="reference" select="1" string="Payment Ref"/> <field name="name" colspan="4"/> <field name="account_id" @@ -92,11 +117,12 @@ on_change="onchange_account(account_id)" invisible="True"/> <field name="pre_line" invisible="1"/> + <field name="type" invisible="True"/> </group> <notebook colspan="4"> <page string="Payment Information"> - <field name="line_cr_ids" default_get="{'journal_id':journal_id, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180"> - <tree string="Invoices and outstanding payments" editable="bottom"> + <field name="line_cr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140"> + <tree string="Invoices and outstanding transactions" editable="bottom"> <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}" on_change="onchange_move_line_id(move_line_id)" domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]" @@ -141,7 +167,7 @@ </notebook> <group col="10" colspan="4"> <field name="state"/> - <button name="proforma_voucher" string="Create" states="draft" icon="terp-document-new"/> + <button name="proforma_voucher" string="Post" states="draft" icon="terp-document-new"/> <button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/> <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/> <button name="%(action_view_account_voucher_unreconcile)d" string="Unreconcile" type="action" states="posted" icon="terp-stock_effects-object-colorize"/> diff --git a/addons/account_voucher/voucher_report.xml b/addons/account_voucher/voucher_report.xml index 57134d3cdec..273fc53de5f 100644 --- a/addons/account_voucher/voucher_report.xml +++ b/addons/account_voucher/voucher_report.xml @@ -2,21 +2,12 @@ <openerp> <data> <report id="report_account_voucher" - string="Print Vouchers" + string="Voucher" model="account.voucher" name="voucher.cash_receipt.drcr" rml="account_voucher/report/report_voucher.rml" auto="False" header = "False" menu="True"/> - -<!-- <report id="report_account_voucher_amt"--> -<!-- string="Print Receipts"--> -<!-- model="account.voucher"--> -<!-- name="voucher.cash_amount"--> -<!-- rml="account_voucher/report/report_voucher_amount.rml"--> -<!-- auto="False"--> -<!-- header = "False"--> -<!-- menu="True"/>--> </data> </openerp> diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 09ff786e94d..4ff3bdc9c5e 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -8,24 +8,25 @@ <field name="arch" type="xml"> <form string="Sales Receipt"> <group col="6" colspan="4"> - <field name="partner_id" on_change="onchange_partner_id(partner_id, journal_id)" string="Customer"/> + <field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id)" string="Customer"/> <field name="journal_id" domain="[('type','=','sale')]" widget="selection" on_change="onchange_journal(journal_id)"/> <field name="number"/> <field name="name" colspan="4"/> <field name="date" on_change="onchange_date(date)"/> + <field name="type" invisible="True"/> </group> <notebook colspan="4"> <page string="Sales Information"> - <field name="line_ids" on_change="onchange_price(line_ids, tax_id, parent.partner_id)" default_get="{'journal_id':journal_id, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180"> + <field name="line_cr_ids" on_change="onchange_price(line_cr_ids, tax_id, parent.partner_id)" default_get="{'journal_id':journal_id, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180"> <tree string="Sales Lines" editable="bottom"> - <field name="account_id" domain="[('user_type.report_type','=','income')]" widget="selection"/> + <field name="account_id" domain="[('user_type.report_type','=','income'),('type','!=','view')]" widget="selection"/> <field name="name"/> <field name="amount" sum="Total"/> <field name="account_analytic_id" groups="base.group_extended"/> </tree> </field> <group col="2" colspan="3"> - <separator string="Narration" colspan="2"/> + <separator string="Internal Notes" colspan="2"/> <field name="narration" colspan="2" nolabel="1"/> </group> <group col="2" colspan="1"> @@ -42,7 +43,7 @@ </group> <group col="3" colspan="1"> <separator string="Total" colspan="3"/> - <field name="tax_id" on_change="onchange_price(line_ids, tax_id, partner_id)" widget="selection" domain="[('type_tax_use','in',('sale','all'))]"/><field name="tax_amount" on_change="onchange_price(line_ids, tax_id, partner_id)" nolabel="1"/> + <field name="tax_id" on_change="onchange_price(line_cr_ids, tax_id, partner_id)" widget="selection" domain="[('type_tax_use','in',('sale','all'))]"/><field name="tax_amount" on_change="onchange_price(line_ids, tax_id, partner_id)" nolabel="1"/> <label colspan="1" string=""/><field name="amount" string="Total"/> </group> </group> @@ -73,7 +74,7 @@ <field name="name">Sales Receipt</field> <field name="res_model">account.voucher.open</field> <field name="view_type">form</field> - <field name="domain">[('journal_id.type','=','sale')]</field> + <field name="domain">[('journal_id.type','=','sale'), ('type','=','sale')]</field> <field name="context">{'journal_type':'sale', 'type':'sale'}</field> <field name="view_id" ref="account_open_vouchers_view"/> <field name="target">new</field> @@ -89,33 +90,39 @@ <field name="arch" type="xml"> <form string="Vendor Bills"> <group col="6" colspan="4"> - <field name="partner_id" on_change="onchange_partner_id(partner_id, type, journal_id)"/> + <field name="partner_id" required="1" string="Vendor" on_change="onchange_partner_id(partner_id, journal_id, amount)"/> + <field name="journal_id" domain="[('type','=','purchase')]" widget="selection" select="1" on_change="onchange_journal(journal_id)"/> + <field name="reference" select="1"/> <field name="name" colspan="4"/> - <field name="journal_id" domain="[('type','=','purchase')]" widget="selection" select="1" on_change="onchange_journal(journal_id,type)"/> - <field name="account_id" domain="[('type','=','other')]" widget="selection" on_change="onchange_account(account_id)"/> <field name="number"/> + <field name="account_id" domain="[('type','=','other')]" invisible="True"/> + <field name="type" invisible="True"/> </group> <notebook colspan="4"> <page string="Bill Information"> - <field name="line_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180"> - <tree string="Voucher Lines" editable="bottom"> - <field name="stype" on_change="onchange_partner(parent.partner_id,type,parent.type, parent.currency_id)"/> - <field name="ref" on_change="onchange_partner(parent.partner_id,type,parent.type, parent.currency_id)"/> + <field name="line_dr_ids" on_change="onchange_price(line_dr_ids, False, parent.partner_id)" default_get="{'journal_id':journal_id,'partner_id':partner_id}" colspan="4" nolabel="1" height="180"> + <tree string="Expense Lines" editable="bottom"> + <field name="account_id" widget="selection" domain="[('user_type.report_type','=','expense'), ('type','!=','view')]"/> + <field name="name"/> <field name="amount"/> - <field name="account_id" domain="[('user_type.report_type','=','expense'), ('type','!=','view')]"/> - <field name="type" on_change="onchange_type(parent.partner_id,type,parent.type, parent.currency_id)"/> - <field name="account_analytic_id"/> + <field name="account_analytic_id" groups="base.group_extended"/> </tree> </field> <group col="2" colspan="3"> - <separator string="Narration" colspan="2"/> + <separator string="Internal Notes" colspan="2"/> <field name="narration" colspan="2" nolabel="1"/> </group> - <group col="2" colspan="1"> - <separator string="Other Information" colspan="2"/> - <field name="reference" select="1"/> - <field name="date" select="1" on_change="onchange_date(date)"/> - <field name="type" on_change="onchange_journal(journal_id,type)"/> + <group col="4" colspan="1"> + <group col="2" colspan="1"> + <separator string="Other Information" colspan="2"/> + <field name="date" string="Bill Date" select="1" on_change="onchange_date(date)"/> + </group> + <group col="2" colspan="1"> + <separator string="Payment Terms" colspan="2"/> + <field name="term_id" widget="selection" on_change="onchange_term_id(term_id, amount)"/> + <field name="date_due"/> + <field name="amount" required="0" string="Amount Due"/> + </group> </group> </page> <page string="Journal Items"> @@ -130,7 +137,7 @@ </notebook> <group col="10" colspan="4"> <field name="state"/> - <button name="proforma_voucher" string="Create" states="draft" icon="terp-document-new"/> + <button name="proforma_voucher" string="Post" states="draft" icon="terp-document-new"/> <button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/> <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/> <button name="%(action_view_account_voucher_unreconcile)d" string="Cancel" type="action" states="posted" icon="terp-stock_effects-object-colorize"/> @@ -142,7 +149,7 @@ <field name="name">Vendor Bills</field> <field name="res_model">account.voucher.open</field> <field name="view_type">form</field> - <field name="domain">[('journal_id.type','=','purchase')]</field> + <field name="domain">[('journal_id.type','=','purchase'), ('type','=','purchase')]</field> <field name="context">{'journal_type':'purchase', 'type':'purchase'}</field> <field name="view_id" ref="account_open_vouchers_view"/> <field name="target">new</field> diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index 4dcb371104d..b7d66e71eeb 100644 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -144,12 +144,14 @@ <field name="date" select='1'/> <field name="number" select='1'/> <field name="partner_id" select='1'/> - </group> - <newline/> - <group col='8' colspan='4'> <field name="journal_id" widget="selection" select="1"/> <field name="period_id" select="1"/> </group> +<!-- <newline/>--> +<!-- <group col='8' colspan='4'>--> +<!-- <field name="journal_id" widget="selection" select="1"/>--> +<!-- <field name="period_id" select="1"/>--> +<!-- </group>--> <newline/> <group expand="0" string="Group By..." colspan="12" col="10"> <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> diff --git a/addons/account_voucher/wizard/account_voucher_unreconcile.py b/addons/account_voucher/wizard/account_voucher_unreconcile.py index d12bee51894..fdb51bb6b91 100644 --- a/addons/account_voucher/wizard/account_voucher_unreconcile.py +++ b/addons/account_voucher/wizard/account_voucher_unreconcile.py @@ -46,10 +46,12 @@ class account_voucher_unreconcile(osv.osv_memory): recs = [] for line in voucher.move_ids: if line.reconcile_id: - recs = [line.reconcile_id.id] - - for rec in recs: - reconcile_pool.unlink(cr, uid, rec) + recs += [line.reconcile_id.id] + if line.reconcile_partial_id: + recs += [line.reconcile_partial_id.id] + + #for rec in recs: + reconcile_pool.unlink(cr, uid, recs) if res.remove: voucher_pool.cancel_voucher(cr, uid, [context.get('active_id')], context) diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py index f3a17be3015..851defe7e73 100644 --- a/addons/hr_holidays/report/holidays_summary_report.py +++ b/addons/hr_holidays/report/holidays_summary_report.py @@ -94,13 +94,13 @@ class report_custom(report_rml): emp_id={} # done={} - cr.execute("select name from res_company") + cr.execute("SELECT name FROM res_company") res=cr.fetchone()[0] date_xml=[] date_today=time.strftime('%Y-%m-%d %H:%M:%S') date_xml +=['<res name="%s" today="%s" />' % (res,date_today)] - cr.execute("select id,name,color_name from hr_holidays_status order by id") + cr.execute("SELECT id, name, color_name FROM hr_holidays_status ORDER BY id") legend=cr.fetchall() today=datetime.datetime.today() @@ -221,23 +221,19 @@ class report_custom(report_rml): elif data['model']=='ir.ui.menu': for id in data['form']['depts']: dept = obj_dept.browse(cr, uid, id, context=context) - - cr.execute("""select dept.manager_id from hr_department dept\ - where dept.id = %s""", (id,)) - result=cr.fetchall() - if result==[]: + cr.execute("""SELECT id FROM hr_employee \ + WHERE department_id = %s""", (id,)) + emp_ids = [x[0] for x in cr.fetchall()] + if emp_ids==[]: continue dept_done=0 - for d in range(0,len(result)): - emp_id[d] = obj_emp.search(cr, uid, [('user_id', '=', result[d][0])]) - items = obj_emp.read(cr, uid, emp_id[d], ['id', 'name']) - for item in items: - if dept_done==0: - emp_xml += emp_create_xml(self, cr, uid, 1, holiday_type, row_id, dept.id, dept.name, som, eom) - row_id = row_id +1 - dept_done=1 - emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom) + for item in obj_emp.read(cr, uid, emp_ids, ['id', 'name']): + if dept_done==0: + emp_xml += emp_create_xml(self, cr, uid, 1, holiday_type, row_id, dept.id, dept.name, som, eom) row_id = row_id +1 + dept_done=1 + emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom) + row_id = row_id +1 # Computing the xml xml='''<?xml version="1.0" encoding="UTF-8" ?> <report> diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_department.py b/addons/hr_holidays/wizard/hr_holidays_summary_department.py index 06651e11d33..9a99d9eff63 100644 --- a/addons/hr_holidays/wizard/hr_holidays_summary_department.py +++ b/addons/hr_holidays/wizard/hr_holidays_summary_department.py @@ -34,7 +34,7 @@ class hr_holidays_summary_dept(osv.osv_memory): } _defaults = { - 'date_from': time.strftime('%Y-%m-%d'), + 'date_from': time.strftime('%Y-%m-01'), 'holiday_type': 'Validated' } diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_employees.py b/addons/hr_holidays/wizard/hr_holidays_summary_employees.py index 379ff7d76c7..0fa58b01581 100644 --- a/addons/hr_holidays/wizard/hr_holidays_summary_employees.py +++ b/addons/hr_holidays/wizard/hr_holidays_summary_employees.py @@ -33,7 +33,7 @@ class hr_holidays_summary_employee(osv.osv_memory): } _defaults = { - 'date_from': time.strftime('%Y-%m-%d'), + 'date_from': time.strftime('%Y-%m-01'), 'holiday_type': 'Validated', } |
