diff --git a/addons/account/account.py b/addons/account/account.py index e65a898f79a..0279b424a6d 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -623,7 +623,7 @@ class account_journal(osv.osv): 'centralisation': fields.boolean('Centralised counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."), 'update_posted': fields.boolean('Allow Cancelling Entries', help="Check this box if you want to allow the cancellation the entries related to this journal or of the invoice related to this journal"), 'group_invoice_lines': fields.boolean('Group invoice lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."), - 'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True), + 'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=False), 'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"), 'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'), 'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'), @@ -646,8 +646,58 @@ class account_journal(osv.osv): raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines')) return super(account_journal, self).write(cr, uid, ids, vals, context=context) + def create_sequence(self, cr, uid, ids, context={}): + """ + Create new entry sequence for every new Joural + @param cr: cursor to database + @param user: id of current user + @param ids: list of record ids to be process + @param context: context arguments, like lang, time zone + @return: return a result + """ + + seq_pool = self.pool.get('ir.sequence') + seq_typ_pool = self.pool.get('ir.sequence.type') + + result = True + + journal = self.browse(cr, uid, ids[0], context) + code = journal.code.lower() + types = { + 'name':journal.name, + 'code':code + } + type_id = seq_typ_pool.create(cr, uid, types) + + seq = { + 'name':journal.name, + 'code':code, + 'active':True, + 'prefix':journal.code + "/%(year)s/", + 'padding':4, + 'number_increment':1 + } + seq_id = seq_pool.create(cr, uid, seq) + + res = {} + if not journal.sequence_id: + res.update({ + 'sequence_id':seq_id + }) + + if not journal.invoice_sequence_id: + res.update({ + 'invoice_sequence_id':seq_id + }) + + result = self.write(cr, uid, [journal.id], res) + + return result + def create(self, cr, uid, vals, context={}): journal_id = super(account_journal, self).create(cr, uid, vals, context) + self.create_sequence(cr, uid, [journal_id], context) + # journal_name = self.browse(cr, uid, [journal_id])[0].code # periods = self.pool.get('account.period') # ids = periods.search(cr, uid, [('date_stop','>=',time.strftime('%Y-%m-%d'))]) diff --git a/addons/account/account_demo.xml b/addons/account/account_demo.xml index 0b4ee8f097d..a8a1d1405cd 100644 --- a/addons/account/account_demo.xml +++ b/addons/account/account_demo.xml @@ -3,8 +3,8 @@ + Fiscal year + --> @@ -15,8 +15,8 @@ + Fiscal Periods + --> diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index c96fb9fe8c7..6ef38dde583 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -330,53 +330,50 @@
- + - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - + - - - - - + + + + - - - - - - + + + + + + + + + + + + + + + diff --git a/addons/account/data/account_data2.xml b/addons/account/data/account_data2.xml index ba606287d6a..10303dd8cbf 100644 --- a/addons/account/data/account_data2.xml +++ b/addons/account/data/account_data2.xml @@ -3,8 +3,8 @@ + Payment term + --> 30 Days End of Month @@ -17,10 +17,10 @@ + Account Journal View + --> - Cash Journal View + Bank/Cash Journal View @@ -74,12 +74,6 @@ credit - - - Tax - account_tax_id - - Analytic Account @@ -100,7 +94,7 @@ - Multi-Currency Cash Journal View + Bank/Cash Journal (Multi-Currency) View @@ -203,6 +197,12 @@ ref + + + Partner + partner_id + + Account @@ -210,12 +210,6 @@ - - - Partner - partner_id - - Name @@ -223,12 +217,6 @@ - - - Maturity Date - date_maturity - - Debit @@ -241,41 +229,206 @@ credit - - - Tax - account_tax_id - - Analytic Account analytic_account_id - - - Tax Acc. - tax_code_id - - - - - Tax - tax_amount - - State state - - + + + + Sale/Purchase Journal View + + + + Date + date + + + + + + N. Piece + move_id + + + + + + Ref + ref + + + + + Account + account_id + + + + + + Partner + partner_id + + + + + Name + name + + + + + + Maturity Date + date_maturity + + + + + Debit + debit + + + + + Credit + credit + + + + + Tax + account_tax_id + + + + + Analytic Account + analytic_account_id + + + + + Tax Acc. + tax_code_id + + + + + Tax + tax_amount + + + + + State + state + + + + + Sale/Purchase Refund Journal View + + + + Date + date + + + + + + N. Piece + move_id + + + + + + Ref + ref + + + + + Account + account_id + + + + + + Partner + partner_id + + + + + Name + name + + + + + + Maturity Date + date_maturity + + + + + Debit + debit + + + + + Credit + credit + + + + + Tax + account_tax_id + + + + + Analytic Account + analytic_account_id + + + + + Tax Acc. + tax_code_id + + + + + Tax + tax_amount + + + + + State + state + + + Account Journal Sequences + --> Account Journal @@ -298,8 +451,8 @@ + Account Statement Sequences + --> Account reconcile sequence diff --git a/addons/account/data/account_invoice.xml b/addons/account/data/account_invoice.xml index de2fff507f5..96407d926f2 100644 --- a/addons/account/data/account_invoice.xml +++ b/addons/account/data/account_invoice.xml @@ -5,10 +5,10 @@ Invoice account.invoice - + + Sequences types for invoices + --> Account Invoice Out account.invoice.out_invoice @@ -27,8 +27,8 @@ + Sequences for invoices + --> Account Invoice Out account.invoice.out_invoice @@ -55,16 +55,16 @@ + Sequences types for analytic account + --> Analytic account account.analytic.account + Sequence for analytic account + --> Analytic account sequence account.analytic.account diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index 308de35e316..a1f3204b7f0 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -170,14 +170,14 @@ your own chart of account. + Account Journal + --> x Sales Journal SAJ sale - + @@ -188,8 +188,7 @@ your own chart of account. x Sales Credit Note Journal SCNJ sale_refund - True - + @@ -200,7 +199,7 @@ your own chart of account. x Expenses Journal EXJ purchase - + @@ -211,8 +210,7 @@ your own chart of account. x Expenses Credit Notes Journal ECNJ purchase_refund - True - + @@ -241,8 +239,8 @@ your own chart of account. + Product income and expense accounts, default parameters + --> property_account_expense diff --git a/addons/account/report/account_balance.rml b/addons/account/report/account_balance.rml index 1892072f251..3434c649a49 100644 --- a/addons/account/report/account_balance.rml +++ b/addons/account/report/account_balance.rml @@ -244,12 +244,12 @@ Credit Balance - [[ repeatIn(lines(data['form']), 'a') ]] - [[ a['level']>2 and setTag('para','para',{'fontName':"Helvetica"}) ]][[ a['code'] and a['code'] or removeParentNode('tr') ]] - [[ a['level']>2 and setTag('para','para',{'fontName':"Helvetica"}) ]][[ '..'*(a['level']-1) ]][[ a['name'] ]] - [[ a['level']>2 and setTag('para','para',{'fontName':"Helvetica"}) ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['debit']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[formatLang(a['debit']) ]] - [[ a['level']>2 and setTag('para','para',{'fontName':"Helvetica"}) ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['credit']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[ formatLang(a['credit']) ]] - [[ a['level']>2 and setTag('para','para',{'fontName':"Helvetica"}) ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['balance']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[ formatLang(a['balance']) ]] + + [[ repeatIn(lines(data['form']), 'a') ]][[ (a['level']>2 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ a['code'] or removeParentNode('tr') ]] + [[ (a['level']>2 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ '..'*(a['level']-1) ]][[ a['name'] ]] + [[ (a['level']>2 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['debit']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[formatLang(a['debit']) ]] + [[ (a['level']>2 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font')]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['credit']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[ formatLang(a['credit']) ]] + [[ (a['level']>2 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['balance']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[ formatLang(a['balance']) ]] diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml index 5645c34d20c..f44c78a9cbe 100644 --- a/addons/account/report/account_entries_report_view.xml +++ b/addons/account/report/account_entries_report_view.xml @@ -49,42 +49,44 @@ search - - - - - - - + + + + + + + - - - - + - + + + + + + + + + + + - - + + + @@ -99,13 +101,18 @@ - - - - - - + + + + + + + + + + + @@ -118,8 +125,7 @@ account.entries.report form tree,graph - {'search_default_This Month':1,'search_default_Journal':1,'group_by_no_leaf':1,'group_by':[]} - + {'search_default_profit': 1,'search_default_group_account':1,'search_default_group_month': 1, 'group_by_no_leaf':1,'group_by':[]} diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 43c8344f110..a06c59da06a 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -77,84 +77,83 @@ class account_invoice_report(osv.osv): tools.drop_view_if_exists(cr, 'account_invoice_report') cr.execute(""" create or replace view account_invoice_report as ( - select - min(l.id) as id, - s.date_invoice as date, - to_char(s.date_invoice, 'YYYY') as year, - to_char(s.date_invoice, 'MM') as month, - to_char(s.date_invoice, 'YYYY-MM-DD') as day, - l.product_id as product_id, - sum(case when s.type in ('out_refund','in_invoice') then - l.quantity * u.factor * -1 - else - l.quantity * u.factor - end) as product_qty, - s.partner_id as partner_id, - s.reconciled::integer, - s.payment_term as payment_term, - s.period_id as period_id, - u.name as uom_name, - s.currency_id as currency_id, - s.journal_id as journal_id, - s.fiscal_position as fiscal_position, - s.user_id as user_id, - s.company_id as company_id, - sum(case when s.type in ('out_refund','in_invoice') then - l.quantity*l.price_unit * -1 - else - l.quantity*l.price_unit - end) as price_total, - sum(case when s.type in ('out_refund','in_invoice') then - l.quantity*l.price_unit * -1 - else - l.quantity*l.price_unit - end) / sum(l.quantity * u.factor)::decimal(16,2) as price_average, - count(*) as nbr, - s.type as type, - s.state, - pt.categ_id, - s.date_due as date_due, - s.address_contact_id as address_contact_id, - s.address_invoice_id as address_invoice_id, - s.account_id as account_id, - s.partner_bank as partner_bank, - sum(case when s.type in ('out_refund','in_invoice') then - s.residual * -1 - else - s.residual - end) as residual, - case when s.state != 'paid' then null else - extract(epoch from avg(am.date_created-l.create_date))/(24*60*60)::decimal(16,2) - end as delay_to_pay - from account_invoice_line l - left join account_invoice s on (s.id=l.invoice_id) - left join product_template pt on (pt.id=l.product_id) - left join product_uom u on (u.id=l.uos_id), - account_move_line am left join account_invoice i on (i.move_id=am.move_id) - where am.account_id=i.account_id - group by - s.type, - s.date_invoice, - s.partner_id, - l.product_id, - u.name, - l.uos_id, - s.reconciled, - s.user_id, - s.state, - s.residual, - pt.categ_id, - s.company_id, - s.payment_term, - s.period_id, - s.fiscal_position, - s.currency_id, - s.journal_id, - s.date_due, - s.address_contact_id, - s.address_invoice_id, - s.account_id, - s.partner_bank + select min(ail.id) as id, + ai.date_invoice as date, + to_char(ai.date_invoice, 'YYYY') as year, + to_char(ai.date_invoice, 'MM') as month, + to_char(ai.date_invoice, 'YYYY-MM-DD') as day, + ail.product_id, + ai.partner_id as partner_id, + ai.reconciled::integer, + ai.payment_term as payment_term, + ai.period_id as period_id, + u.name as uom_name, + ai.currency_id as currency_id, + ai.journal_id as journal_id, + ai.fiscal_position as fiscal_position, + ai.user_id as user_id, + ai.company_id as company_id, + count(ail.*) as nbr, + ai.type as type, + ai.state, + pt.categ_id, + ai.date_due as date_due, + ai.address_contact_id as address_contact_id, + ai.address_invoice_id as address_invoice_id, + ai.account_id as account_id, + ai.partner_bank as partner_bank, + sum(case when ai.type in ('out_refund','in_invoice') then + ail.quantity * u.factor * -1 + else + ail.quantity * u.factor + end) as product_qty, + sum(case when ai.type in ('out_refund','in_invoice') then + ail.quantity*ail.price_unit * -1 + else + ail.quantity*ail.price_unit + end) as price_total, + sum(ail.quantity*ail.price_unit)/sum(ail.quantity*u.factor)*count(ail.product_id)::decimal(16,2) as price_average, + sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) + from account_move_line as aml + left join account_invoice as a ON (a.move_id=aml.move_id) + left join account_invoice_line as l ON (a.id=l.invoice_id) + where a.id=ai.id)) as delay_to_pay, + (case when ai.type in ('out_refund','in_invoice') then + ai.residual * -1 + else + ai.residual + end)/(select count(l.*) from account_invoice_line as l + left join account_invoice as a ON (a.id=l.invoice_id) + where a.id=ai.id) as residual + from account_invoice_line as ail + left join account_invoice as ai ON (ai.id=ail.invoice_id) + left join product_template pt on (pt.id=ail.product_id) + left join product_uom u on (u.id=ail.uos_id) + group by ail.product_id, + ai.date_invoice, + ai.id, + to_char(ai.date_invoice, 'YYYY'), + to_char(ai.date_invoice, 'MM'), + to_char(ai.date_invoice, 'YYYY-MM-DD'), + ai.partner_id, + ai.reconciled, + ai.payment_term, + ai.period_id, + u.name, + ai.currency_id, + ai.journal_id, + ai.fiscal_position, + ai.user_id, + ai.company_id, + ai.type, + ai.state, + pt.categ_id, + ai.date_due, + ai.address_contact_id, + ai.address_invoice_id, + ai.account_id, + ai.partner_bank, + ai.residual ) """) account_invoice_report() diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index f4956939fce..ca89cd10852 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -32,8 +32,8 @@ - - + + @@ -84,7 +84,7 @@ help = "Done Invoices"/> - + - - + + - - + + - - + + - + - - - - - + + + + + diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index aa5951911af..d09350071e4 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -26,7 +26,7 @@ - 1cm 27.7cm 20cm 27.7cm + 0.88cm 27.7cm 20.12cm 27.7cm @@ -35,7 +35,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -181,9 +181,9 @@ - + [[ repeatIn(objects, 'a') ]] - + Start Date @@ -210,7 +210,7 @@ [[ formatLang(time.strftime('%Y-%m-%d %H:%M:%S'),date_time = True) ]] - + @@ -220,7 +220,7 @@ - + [[data['form']['amount_currency'] == False or removeParentNode('blockTable')]] Date @@ -232,45 +232,46 @@ Crebit Balance - + +
+ [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + [[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]] + + + + + [[ o.code or '']] [[ o.name or '']] + + [[formatLang(sum_debit_account(o, data['form'])) ]] + [[formatLang(sum_credit_account(o, data['form'])) ]] + [[formatLang(sum_solde_account(o, data['form'])) ]] + + + + + + + + + + + + + [[ repeatIn(lines(o, data['form']), 'line') ]] [[ formatLang(line['date'],date=True) ]] + [[ line['partner'] or '']] + [[ line['ref'] or '']] + [[ line['move'] or '']] + [[ line['name'] or '' ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] + + +
-
- [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] - [[data['form']['amount_currency'] == False or removeParentNode('blockTable')]] - - - - - [[ o.code or '']] [[ o.name or '']] - - [[formatLang(sum_debit_account(o, data['form'])) ]] - [[formatLang(sum_credit_account(o, data['form'])) ]] - [[formatLang(sum_solde_account(o, data['form'])) ]] - - - - - - - - - - - - - [[ repeatIn(lines(o, data['form']), 'line') ]] [[ formatLang(line['date'],date=True) ]] - [[ line['partner'] or '']] - [[ line['ref'] or '']] - [[ line['move'] or '']] - [[ line['name'] or '' ]] - [[ formatLang(line['debit']) ]] - [[ formatLang(line['credit']) ]] - [[ formatLang(line['progress']) ]] - - -
- - [[data['form']['amount_currency'] == True or removeParentNode('blockTable')]] + + + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] Date Partner @@ -284,11 +285,11 @@
- [[repeatIn(get_children_accounts(a,data['form']), 'o')]] - [[data['form']['amount_currency'] == True or removeParentNode('blockTable')]] + [[ repeatIn(get_children_accounts(a,data['form']), 'o') ]] + [[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]] - + [[ o.code or '' ]] [[ o.name or '' ]] diff --git a/addons/account/report/partner_balance.rml b/addons/account/report/partner_balance.rml index 801125b5669..f14fba6749c 100644 --- a/addons/account/report/partner_balance.rml +++ b/addons/account/report/partner_balance.rml @@ -162,182 +162,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -430,19 +254,19 @@ Balance - + [[ formatLang(solde_debit(data)) ]] [[ formatLang(solde_credit(data)) ]] - [[ repeatIn(lines(data), 'a') ]][[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]][[ a['ref'] ]] [[ a['type']==3 and a['code'] ]] - [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]][[ a['name'] ]] - [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]][[ formatLang(a['debit']) ]] - [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]][[ formatLang(a['credit']) ]] - [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]][[ formatLang(a['balance']) ]] - [[ a['type']==3 and ( setTag('para','para',{'fontName':'Helvetica-Bold'})) ]][[ formatLang(a['enlitige'] or 0.00) ]] + [[ repeatIn(lines(data), 'a') ]][[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ a['ref'] ]] [[ a['type']==3 and a['code'] ]] + [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ a['name'] ]] + [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['debit']) ]] + [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['credit']) ]] + [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['balance']) ]] + [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['enlitige'] or 0.00) ]] diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index 9f9ce13276c..1d9d1e6a8d0 100644 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -58,7 +58,7 @@ - +