diff options
| author | cod-odoo <cod@openerp.com> | 2014-06-25 11:37:30 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2014-08-04 13:23:46 +0200 |
| commit | a301b4c7fc667a99a65961c1a756eca6d6b87238 (patch) | |
| tree | 50d86e3ce312cdfe719c5377dc588738dde9c31a /addons/analytic | |
| parent | 407cb2292471c1dd11380c503ac2cec6999816b8 (diff) | |
[MOVE] account: moved account/project files to analytic or account, depending on which module the moved code belongs to. This allows to remove references to project in account module. Also added some improvements in project when deleting a project (delete account if void) or when deleting an account (delete project if void).
Diffstat (limited to 'addons/analytic')
36 files changed, 2393 insertions, 72 deletions
diff --git a/addons/analytic/__init__.py b/addons/analytic/__init__.py index d0175cf1424..53109ee0c7e 100644 --- a/addons/analytic/__init__.py +++ b/addons/analytic/__init__.py @@ -19,7 +19,9 @@ # ############################################################################## -import analytic +import models +import report +import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/__openerp__.py b/addons/analytic/__openerp__.py index eaff26df197..79eacdd79bf 100644 --- a/addons/analytic/__openerp__.py +++ b/addons/analytic/__openerp__.py @@ -37,11 +37,26 @@ that have no counterpart in the general financial accounts. 'data': [ 'security/analytic_security.xml', 'security/ir.model.access.csv', - 'analytic_sequence.xml', - 'analytic_view.xml', - 'analytic_data.xml', + 'data/analytic_sequence.xml', + 'views/analytic_view.xml', + 'data/analytic_data.xml', + 'analytic_report.xml', + 'wizard/account_analytic_balance_report_view.xml', + 'wizard/account_analytic_cost_ledger_view.xml', + 'wizard/account_analytic_inverted_balance_report.xml', + 'wizard/account_analytic_journal_report_view.xml', + 'wizard/account_analytic_cost_ledger_for_journal_report_view.xml', + 'wizard/account_analytic_chart_view.xml', + 'views/report_analyticbalance.xml', + 'views/report_analyticjournal.xml', + 'views/report_analyticcostledgerquantity.xml', + 'views/report_analyticcostledger.xml', + 'views/report_invertedanalyticbalance.xml', + ], + 'demo': [ + 'data/analytic_demo.xml', + 'data/analytic_account_demo.xml', ], - 'demo': [], 'installable': True, 'auto_install': False, } diff --git a/addons/analytic/analytic_report.xml b/addons/analytic/analytic_report.xml new file mode 100644 index 00000000000..de2e2feee5a --- /dev/null +++ b/addons/analytic/analytic_report.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <report + id="action_account_analytic_account_inverted_balance" + model="account.analytic.account" + string="Inverted Analytic Balance" + report_type="qweb-pdf" + name="account.report_invertedanalyticbalance" + file="account.report_invertedanalyticbalance" + menu="False" + /> + + <report + id="action_report_analytic_journal" + model="account.analytic.journal" + string="Analytic Journal" + report_type="qweb-pdf" + name="account.report_analyticjournal" + file="account.report_analyticjournal" + menu="False" + /> + + <report + id="action_report_analytic_balance" + model="account.analytic.account" + string="Analytic Balance" + report_type="qweb-pdf" + name="account.report_analyticbalance" + file="account.report_analyticbalance" + menu="False" + /> + + <report + id="action_report_cost_ledger" + model="account.analytic.account" + report_type="qweb-pdf" + string="Cost Ledger" + name="account.report_analyticcostledger" + file="account.report_analyticcostledger" + menu="False" + /> + + <report + id="action_report_cost_ledgerquantity" + model="account.analytic.account" + report_type="qweb-pdf" + string="Cost Ledger (Only quantities)" + name="account.report_analyticcostledgerquantity" + file="account.report_analyticcostledgerquantity" + menu="False" + /> + </data> +</openerp> diff --git a/addons/analytic/analytic_view.xml b/addons/analytic/analytic_view.xml deleted file mode 100644 index 7b1b16037cf..00000000000 --- a/addons/analytic/analytic_view.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - - <record id="view_account_analytic_account_form" model="ir.ui.view"> - <field name="name">analytic.analytic.account.form</field> - <field name="model">account.analytic.account</field> - <field name="arch" type="xml"> - <form string="Analytic Account"> - <sheet string="Analytic Account"> - <div class="oe_right oe_button_box" name="buttons"> - </div> - - <div class="oe_title"> - <label for="name" class="oe_edit_only"/> - <h1> - <field name="name" class="oe_inline"/> - </h1> - <div name="project"/> - </div> - - <group name="main"> - <group> - <field name="partner_id" on_change="on_change_partner_id(partner_id, name)"/> - <field name="manager_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_manager']}"/> - <field name="currency_id" attrs="{'invisible': ['|',('type', '<>', 'view'), ('company_id', '<>', False)]}"/> - </group> - <group> - <field name="type" invisible="context.get('default_type', False)"/> - <field name="template_id" on_change="on_change_template(template_id, date_start)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/> - <field name="code"/> - <field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract'])]}"/> - <field name="company_id" on_change="on_change_company(company_id)" widget="selection" groups="base.group_multi_company" attrs="{'required': [('type','<>','view')]}"/> - </group> - </group> - <notebook> - <page string="Contract Information" name="contract_page" attrs="{'invisible':[('type','not in',['contract', 'template'])]}"> - <group string="Renewal" name="contract"> - <p colspan="2" class="oe_grey oe_edit_only"> - Once the end date of the contract is - passed or the maximum number of service - units (e.g. support contract) is - reached, the account manager is notified - by email to renew the contract with the - customer. - </p> - <field name="date_start"/> - <label for="date" string="End Date"/> - <div name="duration"> - <field name="date" class="oe_inline"/> - </div> - </group> - <separator string="Terms and Conditions" name="description"/> - <field name="description"/> - </page> - </notebook> - </sheet> - <div class="oe_chatter"> - <field name="message_follower_ids" widget="mail_followers"/> - <field name="message_ids" widget="mail_thread"/> - </div> - </form> - </field> - </record> - </data> -</openerp> diff --git a/addons/analytic/data/analytic_account_demo.xml b/addons/analytic/data/analytic_account_demo.xml new file mode 100644 index 00000000000..2c4acc6bc45 --- /dev/null +++ b/addons/analytic/data/analytic_account_demo.xml @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data noupdate="1"> + <record id="analytic_root" model="account.analytic.account"> + <field name="name" model="res.company" use="name" search="[]"/> + </record> + <record id="analytic_absences" model="account.analytic.account"> + <field name="name">Leaves</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_root"/> + </record> + <record id="analytic_internal" model="account.analytic.account"> + <field name="name">Internal</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_root"/> + </record> + <record id="analytic_our_super_product" model="account.analytic.account"> + <field name="name">Our Super Product</field> + <field name="state">open</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_root"/> + </record> + <record id="analytic_project_1" model="account.analytic.account"> + <field name="name">Project 1</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_root"/> + </record> + <record id="analytic_project_2" model="account.analytic.account"> + <field name="name">Project 2</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_root"/> + </record> + <record id="analytic_journal_trainings" model="account.analytic.account"> + <field name="name">Training</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_internal"/> + </record> + <record id="analytic_in_house" model="account.analytic.account"> + <field name="name">In House</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_journal_trainings"/> + </record> + <record id="analytic_online" model="account.analytic.account"> + <field name="name">Online</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_journal_trainings"/> + </record> + <record id="analytic_support" model="account.analytic.account"> + <field name="name">Support</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_our_super_product"/> + </record> + <record id="analytic_partners" model="account.analytic.account"> + <field name="name">Partners</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_support"/> + </record> + <record id="analytic_customers" model="account.analytic.account"> + <field name="name">Customers</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_support"/> + </record> + <record id="analytic_support_internal" model="account.analytic.account"> + <field name="name">Internal</field> + <field name="type">contract</field> + <field name="parent_id" ref="analytic_support"/> + </record> + <record id="analytic_integration" model="account.analytic.account"> + <field name="name">Integration</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_our_super_product"/> + </record> + <record id="analytic_consultancy" model="account.analytic.account"> + <field name="name">Consultancy</field> + <field name="type">contract</field> + <field name="parent_id" ref="analytic_our_super_product"/> + </record> + <record id="analytic_super_product_trainings" model="account.analytic.account"> + <field name="name">Training</field> + <field name="type">contract</field> + <field name="parent_id" ref="analytic_our_super_product"/> + </record> + <record id="analytic_seagate_p1" model="account.analytic.account"> + <field name="name">Seagate P1</field> + <field name="parent_id" ref="analytic_integration"/> + <field name="type">normal</field> + <field name="state">open</field> + <field name="partner_id" ref="base.res_partner_19"/> + </record> + <record id="analytic_seagate_p2" model="account.analytic.account"> + <field name="name">Seagate P2</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_integration"/> + <field name="state">open</field> + <field name="partner_id" ref="base.res_partner_19"/> + </record> + <record id="analytic_millennium_industries" model="account.analytic.account"> + <field name="name">Millennium Industries</field> + <field name="parent_id" ref="analytic_integration"/> + <field name="type">normal</field> + <field name="partner_id" ref="base.res_partner_15"/> + </record> + <record id="analytic_integration_c2c" model="account.analytic.account"> + <field name="name">CampToCamp</field> + <field name="type">normal</field> + <field eval="str(time.localtime()[0] - 1) + '-08-07'" name="date_start"/> + <field eval="time.strftime('%Y-12-31')" name="date"/> + <field name="parent_id" ref="analytic_integration"/> + <field name="partner_id" ref="base.res_partner_12"/> + <field name="state">open</field> + </record> + <record id="analytic_agrolait" model="account.analytic.account"> + <field name="name">Agrolait</field> + <field name="parent_id" ref="analytic_customers"/> + <field name="type">normal</field> + <field name="partner_id" ref="base.res_partner_2"/> + </record> + <record id="analytic_asustek" model="account.analytic.account"> + <field name="name">Asustek</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_customers"/> + <field name="partner_id" ref="base.res_partner_1"/> + </record> + <record id="analytic_deltapc" model="account.analytic.account"> + <field name="name">Delta PC</field> + <field name="parent_id" ref="analytic_customers"/> + <field name="type">normal</field> + <field name="partner_id" ref="base.res_partner_4"/> + </record> + <record id="analytic_spark" model="account.analytic.account"> + <field name="name">Spark Systems</field> + <field eval="str(time.localtime()[0] - 1) + '-05-09'" name="date_start"/> + <field eval="time.strftime('%Y-05-08')" name="date"/> + <field name="parent_id" ref="analytic_partners"/> + <field name="type">normal</field> + <field name="partner_id" ref="base.res_partner_16"/> + <field name="state">open</field> + </record> + <record id="analytic_nebula" model="account.analytic.account"> + <field name="name">Nebula</field> + <field eval="time.strftime('%Y-02-01')" name="date_start"/> + <field eval="time.strftime('%Y-07-01')" name="date"/> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_partners"/> + <field name="partner_id" ref="base.res_partner_17"/> + <field name="state">open</field> + </record> + <record id="analytic_luminous_technologies" model="account.analytic.account"> + <field name="name">Luminous Technologies</field> + <field eval="time.strftime('%Y-04-24')" name="date_start"/> + <field eval="str(time.localtime()[0] + 1) + '-04-24'" name="date"/> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_partners"/> + <field name="partner_id" ref="base.res_partner_11"/> + </record> + <record id="analytic_desertic_hispafuentes" model="account.analytic.account"> + <field name="name">Desertic - Hispafuentes</field> + <field eval="time.strftime('%Y-02-01')" name="date_start"/> + <field eval="str(time.localtime()[0] + 1) + '-02-01'" name="date"/> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_partners"/> + <field name="partner_id" ref="base.res_partner_12"/> + </record> + <record id="analytic_think_big_systems" model="account.analytic.account"> + <field name="name">Think Big Systems</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_partners"/> + <field name="partner_id" ref="base.res_partner_18"/> + </record> + <record id="analytic_partners_camp_to_camp" model="account.analytic.account"> + <field name="name">Camp to Camp</field> + <field eval="time.strftime('%Y-%m-%d', time.localtime(time.time() - 365 * 86400))" name="date_start"/> + <field eval="time.strftime('%Y-%m-%d')" name="date"/> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_partners"/> + <field name="partner_id" ref="base.res_partner_12"/> + <field name="state">open</field> + </record> + <record id="analytic_project_2_support" model="account.analytic.account"> + <field name="name">Support</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_project_2"/> + </record> + <record id="analytic_project_2_development" model="account.analytic.account"> + <field name="name">Development</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_project_2"/> + </record> + <record id="analytic_project_1_trainings" model="account.analytic.account"> + <field name="name">Training</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_project_1"/> + </record> + <record id="analytic_project_1_development" model="account.analytic.account"> + <field name="name">Development</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_project_1"/> + </record> + <record id="analytic_administratif" model="account.analytic.account"> + <field name="name">Administrative</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_internal"/> + </record> + <record id="analytic_commercial_marketing" model="account.analytic.account"> + <field name="name">Commercial & Marketing</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_internal"/> + </record> + <record id="analytic_our_super_product_development" model="account.analytic.account"> + <field name="name">Our Super Product Development</field> + <field name="type">view</field> + <field name="parent_id" ref="analytic_internal"/> + </record> + <record id="analytic_stable" model="account.analytic.account"> + <field name="name">Stable</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_our_super_product_development"/> + </record> + <record id="analytic_trunk" model="account.analytic.account"> + <field name="name">Trunk</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_our_super_product_development"/> + </record> + <record id="analytic_paid" model="account.analytic.account"> + <field name="name">Paid</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_absences"/> + </record> + <record id="analytic_unpaid" model="account.analytic.account"> + <field name="name">Unpaid</field> + <field name="type">normal</field> + <field name="parent_id" ref="analytic_absences"/> + </record> + </data> +</openerp> diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/data/analytic_data.xml index 042c2162036..042c2162036 100644 --- a/addons/analytic/analytic_data.xml +++ b/addons/analytic/data/analytic_data.xml diff --git a/addons/analytic/data/analytic_demo.xml b/addons/analytic/data/analytic_demo.xml new file mode 100644 index 00000000000..5ce34521b45 --- /dev/null +++ b/addons/analytic/data/analytic_demo.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data noupdate="1"> + <record id="cose_journal_sale" model="account.analytic.journal"> + <field name="code">SAL</field> + <field name="name">Sales</field> + <field name="type">sale</field> + </record> + <record id="sit" model="account.analytic.journal"> + <field name="code">START</field> + <field name="name">Miscellaneous Operation</field> + <field name="type">situation</field> + </record> + </data> +</openerp> diff --git a/addons/analytic/analytic_sequence.xml b/addons/analytic/data/analytic_sequence.xml index ab36d77bb33..ab36d77bb33 100644 --- a/addons/analytic/analytic_sequence.xml +++ b/addons/analytic/data/analytic_sequence.xml diff --git a/addons/analytic/models/__init__.py b/addons/analytic/models/__init__.py new file mode 100644 index 00000000000..dca9f87f0ec --- /dev/null +++ b/addons/analytic/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import analytic diff --git a/addons/analytic/analytic.py b/addons/analytic/models/analytic.py index e31efa0eb2a..340a37f2d78 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/models/analytic.py @@ -326,6 +326,7 @@ class account_analytic_line(osv.osv): 'account_id': fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='restrict', select=True, domain=[('type','<>','view')]), 'user_id': fields.many2one('res.users', 'User'), 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), + 'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='restrict', select=True), } @@ -354,4 +355,23 @@ class account_analytic_line(osv.osv): (_check_no_view, 'You cannot create analytic line on view account.', ['account_id']), ] -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + +class account_analytic_journal(osv.osv): + _name = 'account.analytic.journal' + _description = 'Analytic Journal' + _columns = { + 'name': fields.char('Journal Name', required=True), + 'code': fields.char('Journal Code', size=8), + 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the analytic journal without removing it."), + 'type': fields.selection( + [('sale', 'Sale'), ('purchase', 'Purchase'), ('cash', 'Cash'), + ('general', 'General'), ('situation', 'Situation')], + 'Type', required=True, help="Gives the type of the analytic journal. When it needs for a document (eg: an invoice) to create analytic entries, Odoo will look for a matching journal of the same type."), + 'line_ids': fields.one2many('account.analytic.line', 'journal_id', 'Lines'), + 'company_id': fields.many2one('res.company', 'Company', required=True), + } + _defaults = { + 'active': True, + 'type': 'general', + 'company_id': lambda self, cr, uid, c=None: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + } diff --git a/addons/analytic/report/__init__.py b/addons/analytic/report/__init__.py new file mode 100644 index 00000000000..ff72ccd21f1 --- /dev/null +++ b/addons/analytic/report/__init__.py @@ -0,0 +1,29 @@ +# -*- 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/>. +# +############################################################################## + +import analytic_journal +import analytic_balance +import analytic_inverted_balance +import analytic_cost_ledger +import analytic_quantity_cost_ledger + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/analytic/report/analytic_balance.py b/addons/analytic/report/analytic_balance.py new file mode 100644 index 00000000000..b8908898b77 --- /dev/null +++ b/addons/analytic/report/analytic_balance.py @@ -0,0 +1,157 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import osv +from openerp.report import report_sxw + + +class account_analytic_balance(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(account_analytic_balance, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'get_objects': self._get_objects, + 'lines_g': self._lines_g, + 'move_sum': self._move_sum, + 'sum_all': self._sum_all, + 'sum_balance': self._sum_balance, + 'move_sum_balance': self._move_sum_balance, + }) + self.acc_ids = [] + self.read_data = [] + self.empty_acc = False + self.acc_data_dict = {}# maintains a relation with an account with its successors. + self.acc_sum_list = []# maintains a list of all ids + + def get_children(self, ids): + read_data = self.pool.get('account.analytic.account').read(self.cr, self.uid, ids,['child_ids','code','complete_name','balance']) + for data in read_data: + if (data['id'] not in self.acc_ids): + inculde_empty = True + if (not self.empty_acc) and data['balance'] == 0.00: + inculde_empty = False + if inculde_empty: + self.acc_ids.append(data['id']) + self.read_data.append(data) + if data['child_ids']: + self.get_children(data['child_ids']) + return True + + def _get_objects(self, empty_acc): + if self.read_data: + return self.read_data + self.empty_acc = empty_acc + self.read_data = [] + self.get_children(self.ids) + return self.read_data + + def _lines_g(self, account_id, date1, date2): + account_analytic_obj = self.pool.get('account.analytic.account') + ids = account_analytic_obj.search(self.cr, self.uid, + [('parent_id', 'child_of', [account_id])]) + self.cr.execute("SELECT aa.name AS name, aa.code AS code, \ + sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \ + FROM account_analytic_line AS aal, account_account AS aa \ + WHERE (aal.general_account_id=aa.id) \ + AND (aal.account_id IN %s)\ + AND (date>=%s) AND (date<=%s) AND aa.active \ + GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \ + ORDER BY aal.code", (tuple(ids), date1, date2)) + res = self.cr.dictfetchall() + + for r in res: + if r['balance'] > 0: + r['debit'] = r['balance'] + r['credit'] = 0.0 + elif r['balance'] < 0: + r['debit'] = 0.0 + r['credit'] = -r['balance'] + else: + r['balance'] == 0 + r['debit'] = 0.0 + r['credit'] = 0.0 + return res + + def _move_sum(self, account_id, date1, date2, option): + if account_id not in self.acc_data_dict: + account_analytic_obj = self.pool.get('account.analytic.account') + ids = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account_id])]) + self.acc_data_dict[account_id] = ids + else: + ids = self.acc_data_dict[account_id] + + query_params = (tuple(ids), date1, date2) + if option == "credit": + self.cr.execute("SELECT COALESCE(-sum(amount),0.0) FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0",query_params) + elif option == "debit": + self.cr.execute("SELECT COALESCE(sum(amount),0.0) FROM account_analytic_line \ + WHERE account_id IN %s\ + AND date>=%s AND date<=%s AND amount>0",query_params) + elif option == "quantity": + self.cr.execute("SELECT COALESCE(sum(unit_amount),0.0) FROM account_analytic_line \ + WHERE account_id IN %s\ + AND date>=%s AND date<=%s",query_params) + return self.cr.fetchone()[0] or 0.0 + + def _move_sum_balance(self, account_id, date1, date2): + debit = self._move_sum(account_id, date1, date2, 'debit') + credit = self._move_sum(account_id, date1, date2, 'credit') + return (debit-credit) + + def _sum_all(self, accounts, date1, date2, option): + account_analytic_obj = self.pool.get('account.analytic.account') + ids = map(lambda x: x['id'], accounts) + if not ids: + return 0.0 + + if not self.acc_sum_list: + ids2 = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', ids)]) + self.acc_sum_list = ids2 + else: + ids2 = self.acc_sum_list + + query_params = (tuple(ids2), date1, date2) + if option == "debit": + self.cr.execute("SELECT COALESCE(sum(amount),0.0) FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0",query_params) + elif option == "credit": + self.cr.execute("SELECT COALESCE(-sum(amount),0.0) FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0",query_params) + elif option == "quantity": + self.cr.execute("SELECT COALESCE(sum(unit_amount),0.0) FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s",query_params) + return self.cr.fetchone()[0] or 0.0 + + def _sum_balance(self, accounts, date1, date2): + debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0 + credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0 + return (debit-credit) + + +class report_analyticbalance(osv.AbstractModel): + _name = 'report.account.report_analyticbalance' + _inherit = 'report.abstract_report' + _template = 'analytic.report_analyticbalance' + _wrapped_report_class = account_analytic_balance + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/report/analytic_cost_ledger.py b/addons/analytic/report/analytic_cost_ledger.py new file mode 100644 index 00000000000..77c6cad04a4 --- /dev/null +++ b/addons/analytic/report/analytic_cost_ledger.py @@ -0,0 +1,111 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import osv +from openerp.report import report_sxw + + +class account_analytic_cost_ledger(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'lines_g': self._lines_g, + 'lines_a': self._lines_a, + 'account_sum_debit': self._account_sum_debit, + 'account_sum_credit': self._account_sum_credit, + 'account_sum_balance': self._account_sum_balance, + 'sum_debit': self._sum_debit, + 'sum_credit': self._sum_credit, + 'sum_balance': self._sum_balance, + }) + self.children = {} # a memo for the method _get_children + + def _get_children(self, accounts): + """ return all children accounts of the given accounts + :param accounts: list of browse records of 'account.analytic.account' + :return: tuple of account ids + """ + analytic_obj = self.pool.get('account.analytic.account') + res = set() + for account in accounts: + if account.id not in self.children: + self.children[account.id] = analytic_obj.search(self.cr, self.uid, [('parent_id', 'child_of', [account.id])]) + res.update(self.children[account.id]) + return tuple(res) + + def _lines_g(self, account, date1, date2): + self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id \ + FROM account_account AS aa, account_analytic_line AS aal \ + WHERE (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \ + GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (self._get_children([account]), date1, date2)) + res = self.cr.dictfetchall() + for r in res: + r['debit'] = r['balance'] if r['balance'] > 0 else 0.0 + r['credit'] = -r['balance'] if r['balance'] < 0 else 0.0 + return res + + def _lines_a(self, general_account, account, date1, date2): + self.cr.execute("SELECT aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj FROM account_analytic_line AS aal, account_analytic_journal AS aaj \ + WHERE (aal.general_account_id=%s) AND (aal.account_id IN %s) AND (aal.date>=%s) AND (aal.date<=%s) \ + AND (aal.journal_id=aaj.id) \ + ORDER BY aal.date, aaj.code, aal.code", (general_account['id'], self._get_children([account]), date1, date2)) + res = self.cr.dictfetchall() + for r in res: + r['debit'] = r['balance'] if r['balance'] > 0 else 0.0 + r['credit'] = -r['balance'] if r['balance'] < 0 else 0.0 + return res + + def _account_sum_debit(self, account, date1, date2): + return self._sum_debit([account], date1, date2) + + def _account_sum_credit(self, account, date1, date2): + return self._sum_credit([account], date1, date2) + + def _account_sum_balance(self, account, date1, date2): + debit = self._account_sum_debit(account, date1, date2) + credit = self._account_sum_credit(account, date1, date2) + return (debit-credit) + + def _sum_debit(self, accounts, date1, date2): + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", + (self._get_children(accounts), date1, date2,)) + return self.cr.fetchone()[0] or 0.0 + + def _sum_credit(self, accounts, date1, date2): + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", + (self._get_children(accounts), date1, date2,)) + return self.cr.fetchone()[0] or 0.0 + + def _sum_balance(self, accounts, date1, date2): + debit = self._sum_debit(accounts, date1, date2) + credit = self._sum_credit(accounts, date1, date2) + return (debit-credit) + + +class report_analyticcostledger(osv.AbstractModel): + _name = 'report.account.report_analyticcostledger' + _inherit = 'report.abstract_report' + _template = 'analytic.report_analyticcostledger' + _wrapped_report_class = account_analytic_cost_ledger + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/report/analytic_inverted_balance.py b/addons/analytic/report/analytic_inverted_balance.py new file mode 100644 index 00000000000..8a47322546c --- /dev/null +++ b/addons/analytic/report/analytic_inverted_balance.py @@ -0,0 +1,130 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import osv +from openerp.report import report_sxw + +class account_inverted_analytic_balance(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(account_inverted_analytic_balance, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'lines_g': self._lines_g, + 'lines_a': self._lines_a, + 'sum_debit': self._sum_debit, + 'sum_credit': self._sum_credit, + 'sum_balance': self._sum_balance, + 'sum_quantity': self._sum_quantity, + }) + + def _lines_g(self, accounts, date1, date2): + ids = map(lambda x: x.id, accounts) + self.cr.execute("SELECT aa.name AS name, aa.code AS code, " + "sum(aal.amount) AS balance, " + "sum(aal.unit_amount) AS quantity, aa.id AS id \ + FROM account_analytic_line AS aal, account_account AS aa \ + WHERE (aal.general_account_id=aa.id) " + "AND (aal.account_id IN %s) " + "AND (date>=%s) AND (date<=%s) AND aa.active \ + GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id " + "ORDER BY aal.code", + (tuple(ids), date1, date2)) + res = self.cr.dictfetchall() + for r in res: + if r['balance'] > 0: + r['debit'] = r['balance'] + r['credit'] = 0.0 + elif r['balance'] < 0: + r['debit'] = 0.0 + r['credit'] = -r['balance'] + else: + r['debit'] = 0.0 + r['credit'] = 0.0 + return res + + def _lines_a(self, accounts, general_account_id, date1, date2): + ids = map(lambda x: x.id, accounts) + self.cr.execute("SELECT sum(aal.amount) AS balance, " + "sum(aal.unit_amount) AS quantity, " + "aaa.code AS code, aaa.name AS name, account_id \ + FROM account_analytic_line AS aal, " + "account_analytic_account AS aaa \ + WHERE aal.account_id=aaa.id AND aal.account_id IN %s " + "AND aal.general_account_id=%s AND aal.date>=%s " + "AND aal.date<=%s \ + GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name " + "ORDER BY aal.account_id", + (tuple(ids), general_account_id, date1, date2)) + res = self.cr.dictfetchall() + + aaa_obj = self.pool.get('account.analytic.account') + res2 = aaa_obj.read(self.cr, self.uid, ids, ['complete_name']) + complete_name = {} + for r in res2: + complete_name[r['id']] = r['complete_name'] + for r in res: + r['complete_name'] = complete_name[r['account_id']] + if r['balance'] > 0: + r['debit'] = r['balance'] + r['credit'] = 0.0 + elif r['balance'] < 0: + r['debit'] = 0.0 + r['credit'] = -r['balance'] + else: + r['debit'] = 0.0 + r['credit'] = 0.0 + return res + + def _sum_debit(self, accounts, date1, date2): + ids = map(lambda x: x.id, accounts) + self.cr.execute("SELECT sum(amount) \ + FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(ids),date1, date2,)) + return self.cr.fetchone()[0] or 0.0 + + def _sum_credit(self, accounts, date1, date2): + ids = map(lambda x: x.id, accounts) + self.cr.execute("SELECT -sum(amount) \ + FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(ids),date1, date2,)) + return self.cr.fetchone()[0] or 0.0 + + def _sum_balance(self, accounts, date1, date2): + debit = self._sum_debit(accounts, date1, date2) + credit = self._sum_credit(accounts, date1, date2) + return (debit-credit) + + def _sum_quantity(self, accounts, date1, date2): + ids = map(lambda x: x.id, accounts) + self.cr.execute("SELECT sum(unit_amount) \ + FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s", (tuple(ids),date1, date2,)) + return self.cr.fetchone()[0] or 0.0 + + +class report_invertedanalyticbalance(osv.AbstractModel): + _name = 'report.account.report_invertedanalyticbalance' + _inherit = 'report.abstract_report' + _template = 'analytic.report_invertedanalyticbalance' + _wrapped_report_class = account_inverted_analytic_balance + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/report/analytic_journal.py b/addons/analytic/report/analytic_journal.py new file mode 100644 index 00000000000..38231b69f5f --- /dev/null +++ b/addons/analytic/report/analytic_journal.py @@ -0,0 +1,68 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import osv +from openerp.report import report_sxw + + +# +# Use period and Journal for selection or resources +# +class account_analytic_journal(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(account_analytic_journal, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'lines': self._lines, + 'lines_a': self._lines_a, + 'sum_general': self._sum_general, + 'sum_analytic': self._sum_analytic, + }) + + def _lines(self, journal_id, date1, date2): + self.cr.execute('SELECT DISTINCT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%s) AND (move_id is not null)', (date1, date2, journal_id,)) + ids = map(lambda x: x[0], self.cr.fetchall()) + return self.pool.get('account.move.line').browse(self.cr, self.uid, ids) + + def _lines_a(self, move_id, journal_id, date1, date2): + ids = self.pool.get('account.analytic.line').search(self.cr, self.uid, [('move_id','=',move_id), ('journal_id','=',journal_id), ('date','>=',date1), ('date','<=',date2)]) + if not ids: + return [] + return self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids) + + def _sum_general(self, journal_id, date1, date2): + self.cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE id IN (SELECT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%s) AND (move_id is not null))', (date1, date2, journal_id,)) + return self.cr.fetchall()[0][0] or 0 + + def _sum_analytic(self, journal_id, date1, date2): + self.cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE date>=%s AND date<=%s AND journal_id=%s", (date1, date2, journal_id)) + res = self.cr.dictfetchone() + return res['sum'] or 0 + + +class report_analyticjournal(osv.AbstractModel): + _name = 'report.account.report_analyticjournal' + _inherit = 'report.abstract_report' + _template = 'analytic.report_analyticjournal' + _wrapped_report_class = account_analytic_journal + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/report/analytic_quantity_cost_ledger.py b/addons/analytic/report/analytic_quantity_cost_ledger.py new file mode 100644 index 00000000000..c4bf9ade72f --- /dev/null +++ b/addons/analytic/report/analytic_quantity_cost_ledger.py @@ -0,0 +1,127 @@ +# -*- 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/>. +# +############################################################################## +import time +from openerp.osv import osv +from openerp.report import report_sxw + + +class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(account_analytic_quantity_cost_ledger, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'lines_g': self._lines_g, + 'lines_a': self._lines_a, + 'sum_quantity': self._sum_quantity, + 'account_sum_quantity': self._account_sum_quantity, + }) + + def _lines_g(self, account_id, date1, date2, journals): + if not journals: + self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \ + aa.code AS code, aa.name AS name, aa.id AS id \ + FROM account_account AS aa, account_analytic_line AS aal \ + WHERE (aal.account_id=%s) AND (aal.date>=%s) \ + AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ + AND aa.active \ + GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", + (account_id, date1, date2)) + else: + journal_ids = journals + self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \ + aa.code AS code, aa.name AS name, aa.id AS id \ + FROM account_account AS aa, account_analytic_line AS aal \ + WHERE (aal.account_id=%s) AND (aal.date>=%s) \ + AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ + AND aa.active \ + AND (aal.journal_id IN %s ) \ + GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", + (account_id, date1, date2, tuple(journal_ids))) + res = self.cr.dictfetchall() + return res + + def _lines_a(self, general_account_id, account_id, date1, date2, journals): + if not journals: + self.cr.execute("SELECT aal.name AS name, aal.code AS code, \ + aal.unit_amount AS quantity, aal.date AS date, \ + aaj.code AS cj \ + FROM account_analytic_line AS aal, \ + account_analytic_journal AS aaj \ + WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ + AND (aal.date>=%s) AND (aal.date<=%s) \ + AND (aal.journal_id=aaj.id) \ + ORDER BY aal.date, aaj.code, aal.code", + (general_account_id, account_id, date1, date2)) + else: + journal_ids = journals + self.cr.execute("SELECT aal.name AS name, aal.code AS code, \ + aal.unit_amount AS quantity, aal.date AS date, \ + aaj.code AS cj \ + FROM account_analytic_line AS aal, \ + account_analytic_journal AS aaj \ + WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ + AND (aal.date>=%s) AND (aal.date<=%s) \ + AND (aal.journal_id=aaj.id) AND (aaj.id IN %s) \ + ORDER BY aal.date, aaj.code, aal.code", + (general_account_id, account_id, date1, date2,tuple(journal_ids))) + res = self.cr.dictfetchall() + return res + + def _account_sum_quantity(self, account_id, date1, date2, journals): + if not journals: + self.cr.execute("SELECT sum(unit_amount) \ + FROM account_analytic_line \ + WHERE account_id=%s AND date>=%s AND date<=%s", + (account_id, date1, date2)) + else: + journal_ids = journals + self.cr.execute("SELECT sum(unit_amount) \ + FROM account_analytic_line \ + WHERE account_id = %s AND date >= %s AND date <= %s \ + AND journal_id IN %s", + (account_id, date1, date2, tuple(journal_ids),)) + return self.cr.fetchone()[0] or 0.0 + + def _sum_quantity(self, accounts, date1, date2, journals): + ids = map(lambda x: x.id, accounts) + if not ids: + return 0.0 + if not journals: + self.cr.execute("SELECT sum(unit_amount) \ + FROM account_analytic_line \ + WHERE account_id IN %s AND date>=%s AND date<=%s", + (tuple(ids), date1, date2,)) + else: + journal_ids = journals + self.cr.execute("SELECT sum(unit_amount) \ + FROM account_analytic_line \ + WHERE account_id IN %s AND date >= %s AND date <= %s \ + AND journal_id IN %s",(tuple(ids), date1, date2, tuple(journal_ids))) + return self.cr.fetchone()[0] or 0.0 + + +class report_analyticcostledgerquantity(osv.AbstractModel): + _name = 'report.account.report_analyticcostledgerquantity' + _inherit = 'report.abstract_report' + _template = 'analytic.report_analyticcostledgerquantity' + _wrapped_report_class = account_analytic_quantity_cost_ledger + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/security/analytic_security.xml b/addons/analytic/security/analytic_security.xml index bf103ca8988..43bf89de406 100644 --- a/addons/analytic/security/analytic_security.xml +++ b/addons/analytic/security/analytic_security.xml @@ -15,6 +15,13 @@ <field eval="True" name="global"/> <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> </record> + + <record id="analytic_journal_comp_rule" model="ir.rule"> + <field name="name">Analytic journal multi-company</field> + <field name="model_id" ref="model_account_analytic_journal"/> + <field name="global" eval="True"/> + <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> + </record> </data> <data noupdate="0"> diff --git a/addons/analytic/views/analytic_view.xml b/addons/analytic/views/analytic_view.xml new file mode 100644 index 00000000000..0df238fbd0a --- /dev/null +++ b/addons/analytic/views/analytic_view.xml @@ -0,0 +1,372 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_account_analytic_account_form" model="ir.ui.view"> + <field name="name">analytic.analytic.account.form</field> + <field name="model">account.analytic.account</field> + <field name="arch" type="xml"> + <form string="Analytic Account" version="7.0"> + <sheet string="Analytic Account"> + <div class="oe_right oe_button_box" name="buttons"> + </div> + + <div class="oe_title"> + <label for="name" class="oe_edit_only"/> + <h1> + <field name="name" class="oe_inline"/> + </h1> + <div name="project"/> + </div> + + <group name="main"> + <group> + <field name="partner_id" on_change="on_change_partner_id(partner_id, name)"/> + <field name="manager_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_manager']}"/> + <field name="currency_id" attrs="{'invisible': ['|',('type', '<>', 'view'), ('company_id', '<>', False)]}"/> + </group> + <group> + <field name="type" invisible="context.get('default_type', False)"/> + <field name="template_id" on_change="on_change_template(template_id, date_start)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/> + <field name="code"/> + <field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract'])]}"/> + <field name="company_id" on_change="on_change_company(company_id)" widget="selection" groups="base.group_multi_company" attrs="{'required': [('type','<>','view')]}"/> + </group> + </group> + <notebook> + <page string="Contract Information" name="contract_page" attrs="{'invisible':[('type','not in',['contract', 'template'])]}"> + <group string="Renewal" name="contract"> + <p colspan="2" class="oe_grey oe_edit_only"> + Once the end date of the contract is + passed or the maximum number of service + units (e.g. support contract) is + reached, the account manager is notified + by email to renew the contract with the + customer. + </p> + <field name="date_start"/> + <label for="date" string="End Date"/> + <div name="duration"> + <field name="date" class="oe_inline"/> + </div> + </group> + <separator string="Terms and Conditions" name="description"/> + <field name="description"/> + </page> + </notebook> + </sheet> + <div class="oe_chatter"> + <field name="message_follower_ids" widget="mail_followers"/> + <field name="message_ids" widget="mail_thread"/> + </div> + </form> + </field> + </record> + + <record id="view_account_analytic_account_list" model="ir.ui.view"> + <field name="name">account.analytic.account.list</field> + <field name="model">account.analytic.account</field> + <field eval="8" name="priority"/> + <field name="arch" type="xml"> + <tree toolbar="1" colors="red:state=='pending';grey:state in ('cancelled','close');blue:type=='view'" string="Analytic Accounts"> + <field name="complete_name"/> + <field name="partner_id"/> + <field name="code"/> + <field name="date_start"/> + <field name="date"/> + <field name="user_id" invisible="1"/> + <field name="manager_id"/> + <field name="parent_id" invisible="1"/> + <field name="state" invisible="1"/> + <field name="type" invisible="1"/> + <field name="template_id" invisible="1"/> + <field name="company_id" groups="base.group_multi_company"/> + </tree> + </field> + </record> + + <record id="view_account_analytic_account_search" model="ir.ui.view"> + <field name="name">account.analytic.account.search</field> + <field name="model">account.analytic.account</field> + <field name="arch" type="xml"> + <search string="Analytic Account"> + <field name="name" filter_domain="['|', ('name','ilike',self), ('code','ilike',self)]" string="Analytic Account"/> + <field name="date"/> + <field name="partner_id" operator="child_of"/> + <field name="manager_id"/> + <field name="parent_id"/> + <field name="user_id"/> + <filter string="Open" domain="[('state','=','open')]" help="Current Accounts"/> + <filter string="Pending" domain="[('state','=','pending')]" help="Pending Accounts"/> + <group expand="0" string="Group By..."> + <filter string="Associated Partner" domain="[]" context="{'group_by':'partner_id'}"/> + <filter string="Type" domain="[]" context="{'group_by':'type'}"/> + <filter string="Template" domain="[]" context="{'group_by':'template_id'}"/> + <filter string="Parent Account" domain="[]" context="{'group_by':'parent_id'}"/> + <filter string="Status" domain="[]" context="{'group_by':'state'}" groups="base.group_no_one"/> + </group> + </search> + </field> + </record> + + <record id="view_account_analytic_account_tree" model="ir.ui.view"> + <field name="name">account.analytic.account.tree</field> + <field name="model">account.analytic.account</field> + <field name="field_parent">child_complete_ids</field> + <field name="arch" type="xml"> + <tree colors="blue:state=='pending';grey:state in ('close','cancelled');blue:type=='view'" string="Analytic account" toolbar="1"> + <field name="name" invisible="1"/> + <field name="complete_name"/> + <field name="code"/> + <field name="debit"/> + <field name="credit"/> + <field name="balance"/> + <field name="state" invisible="1"/> + <field name="currency_id" groups="base.group_multi_currency"/> + <field name="date" invisible="1"/> + <field name="user_id" invisible="1"/> + <field name="partner_id" invisible="1"/> + <field name="parent_id" invisible="1"/> + <field name="type"/> + <field name="company_id" groups="base.group_multi_company"/> + <field name="template_id" invisible="1"/> + </tree> + </field> + </record> + + + <record id="action_account_analytic_account_form" model="ir.actions.act_window"> + <field name="name">Analytic Accounts</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.account</field> + <field name="context">{}</field> <!-- repair invalid context by setting empty one --> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="view_account_analytic_account_tree"/> + <field name="search_view_id" ref="analytic.view_account_analytic_account_search"/> + </record> + + <record id="act_account_renew_view" model="ir.actions.act_window"> + <field name="name">Accounts to Renew</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.account</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="domain">[('date','<',time.strftime('%Y-%m-%d %H:%M:%S'))]</field> + <field name="filter" eval="True"/> + </record> + + <record id="action_account_analytic_account_tree2" model="ir.actions.act_window"> + <field name="name">Chart of Analytic Accounts</field> + <field name="res_model">account.analytic.account</field> + <field name="view_type">tree</field> + <field name="view_id" ref="view_account_analytic_account_tree"/> + <field name="domain">[('parent_id','=',False)]</field> + <field name="help" type="html"> + <p> + Click to add a new analytic account. + </p><p> + The normal chart of accounts has a structure defined by the + legal requirement of the country. The analytic chart of + accounts structure should reflect your own business needs in + term of costs/revenues reporting. + </p><p> + They are usually structured by contracts, projects, products or + departements. Most of the Odoo operations (invoices, + timesheets, expenses, etc) generate analytic entries on the + related account. + </p> + </field> + </record> + + + <record id="view_account_analytic_line_form" model="ir.ui.view"> + <field name="name">account.analytic.line.form</field> + <field name="model">account.analytic.line</field> + <field name="priority">1</field> + <field name="arch" type="xml"> + <form string="Analytic Entry" version="7.0"> + <group> + <group> + <field name="name"/> + <field name="account_id"/> + <field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/> + </group> + <group> + <field name="date"/> + <field name="company_id" groups="base.group_multi_company"/> + </group> + <group string="Amount"> + <field name="amount"/> + </group> + <group string="Product Information" name="product_info"> + <label for="unit_amount"/> + <div> + <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" class="oe_inline"/> + </div> + </group> + </group> + </form> + </field> + </record> + <record id="view_account_analytic_line_tree" model="ir.ui.view"> + <field name="name">account.analytic.line.tree</field> + <field name="model">account.analytic.line</field> + <field name="arch" type="xml"> + <tree string="Analytic Entries"> + <field name="date"/> + <field name="name"/> + <field name="user_id"/> + <field name="amount" sum="Total" invisible="context.get('to_invoice', False)"/> + <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" sum="Total Quantity"/> + <field domain="[('type','=','normal')]" name="account_id"/> + <field name="company_id" groups="base.group_multi_company"/> + </tree> + </field> + </record> + <record id="view_account_analytic_line_filter" model="ir.ui.view"> + <field name="name">account.analytic.line.select</field> + <field name="model">account.analytic.line</field> + <field name="arch" type="xml"> + <search string="Search Analytic Lines"> + <field name="name" string="Description"/> + <field name="date"/> + <filter string="My Entries" domain="[('user_id','=',uid)]"/> + <field name="account_id" filter_domain="[('account_id','child_of',self)]"/> + <field name="user_id"/> + <group string="Group By..." expand="0"> + <filter string="Analytic Account" context="{'group_by':'account_id'}" name="account_id"/> + <filter string="User" context="{'group_by':'user_id'}" name="user_id"/> + <filter string="Tasks Month" context="{'group_by':'date'}" name="group_date" help="Invoice Tasks by Month"/> + </group> + </search> + </field> + </record> + <record id="action_account_analytic_line_form" model="ir.actions.act_window"> + <field name="name">Analytic Entries</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.line</field> + <field name="view_type">form</field> + <field name="context">{"search_default_user_id":uid}</field> + <field name="view_id" ref="view_account_analytic_line_tree"/> + </record> + + <!-- Entries by Line --> + + <record id="action_account_tree1" model="ir.actions.act_window"> + <field name="name">Analytic Items</field> + <field name="res_model">account.analytic.line</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="domain">[('account_id','child_of',[active_id])]</field> + <field name="context">{'account_id':active_id}</field> + <field name="search_view_id" ref="view_account_analytic_line_filter"/> + </record> + <record id="ir_open_account_analytic_account" model="ir.values"> + <field eval="'tree_but_open'" name="key2"/> + <field eval="'account.analytic.account'" name="model"/> + <field name="name">Open Account Tree</field> + <field eval="'ir.actions.act_window,%d'%action_account_tree1" name="value"/> + </record> + + <record id="account_analytic_line_extended_form" model="ir.ui.view"> + <field name="name">account.analytic.line.extended_form</field> + <field name="model">account.analytic.line</field> + <field name="arch" type="xml"> + <form string="Project line" version="7.0"> + <group> + <group> + <field name="name"/> + <field name="account_id"/> + </group> + <group> + <field name="date" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/> + <field name="company_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/> + </group> + <group string="Amount"> + <field name="amount"/> + </group> + <group string="Product Information"> + <label for="unit_amount"/> + <div> + <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" class="oe_inline"/> + </div> + </group> + </group> + </form> + </field> + </record> + <record id="action_account_analytic_account_line_extended_form" model="ir.actions.act_window"> + <field name="name">account.analytic.line.extended</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.line</field> + <field name="view_type">form</field> + <field name="view_id" ref="view_account_analytic_line_form"/> + </record> + + # + # Analytic Journal + # + + <record id="view_account_analytic_journal_tree" model="ir.ui.view"> + <field name="name">account.analytic.journal.tree</field> + <field name="model">account.analytic.journal</field> + <field name="arch" type="xml"> + <tree string="Analytic Journal"> + <field name="code"/> + <field name="name"/> + <field name="type"/> + </tree> + </field> + </record> + + <record id="view_analytic_journal_search" model="ir.ui.view"> + <field name="name">account.analytic.journal.search</field> + <field name="model">account.analytic.journal</field> + <field name="arch" type="xml"> + <search string="Analytic Journals"> + <field name="name" filter_domain="['|', ('name','ilike',self), ('code','ilike',self)]" string="Analytic Journal"/> + <field name="type"/> + <group expand="0" string="Group By..."> + <filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type'}"/> + </group> + </search> + </field> + </record> + + <record id="view_account_analytic_journal_form" model="ir.ui.view"> + <field name="name">account.analytic.journal.form</field> + <field name="model">account.analytic.journal</field> + <field name="arch" type="xml"> + <form string="Analytic Journal" version="7.0"> + <group col="4"> + <field name="name"/> + <field name="code"/> + <field name="type"/> + <field name="active"/> + <field name="company_id" groups="base.group_multi_company"/> + </group> + </form> + </field> + </record> + <record id="action_account_analytic_journal_form" model="ir.actions.act_window"> + <field name="name">Analytic Journals</field> + <field name="res_model">account.analytic.journal</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="search_view_id" ref="view_analytic_journal_search" /> + </record> + + # + # Open journal entries + # + + <record id="action_account_analytic_journal_open_form" model="ir.actions.act_window"> + <field name="name">Analytic Journal Items</field> + <field name="res_model">account.analytic.line</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + </record> + + </data> +</openerp> diff --git a/addons/analytic/views/report_analyticbalance.xml b/addons/analytic/views/report_analyticbalance.xml new file mode 100644 index 00000000000..09cd56fc83f --- /dev/null +++ b/addons/analytic/views/report_analyticbalance.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> +<data> +<template id="report_analyticbalance"> + <t t-call="report.html_container"> + <t t-call="report.internal_layout"> + <div class="page"> + <h2>Analytic Balance - <span t-esc="res_company.currency_id.name"/></h2> + + <table class="table table-condensed"> + <thead> + <tr> + <th>Code</th> + <th>Account Name</th> + <th>Debit</th> + <th>Credit</th> + <th>Balance</th> + <th>Quantity</th> + </tr> + </thead> + <tbody> + <tr> + <td colspan="2">Total</td> + <td> + <span t-esc="formatLang(sum_all(get_objects(data['form']['empty_acc']), data['form']['date1'], data['form']['date2'], 'debit'))"/> + </td> + <td> + <span t-esc="formatLang(sum_all(get_objects(data['form']['empty_acc']), data['form']['date1'], data['form']['date2'], 'credit'))"/> + </td> + <td> + <span t-esc="formatLang(sum_balance(get_objects(data['form']['empty_acc']), data['form']['date1'], data['form']['date2']),currency_obj=res_company.currency_id)"/> + </td> + <td> + <span t-esc="formatLang(sum_all(get_objects(data['form']['empty_acc']), data['form']['date1'], data['form']['date2'], 'quantity'))"/> + </td> + </tr> + <t t-foreach="get_objects(data['form']['empty_acc'])" t-as="o"> + <tr> + <td><span t-esc="o['code']"/></td> + <td><span t-esc="o['complete_name']"/></td> + <td><span t-esc="formatLang(move_sum(o['id'], data['form']['date1'], data['form']['date2'], 'debit'))"/></td> + <td><span t-esc="formatLang(move_sum(o['id'], data['form']['date1'], data['form']['date2'], 'credit'))"/></td> + <td><span t-esc="formatLang(move_sum_balance(o['id'], data['form']['date1'], data['form']['date2']), currency_obj=res_company.currency_id)"/></td> + <td><span t-esc="formatLang(move_sum(o['id'], data['form']['date1'], data['form']['date2'], 'quantity'))"/></td> + </tr> + <tr t-foreach="lines_g(o['id'], data['form']['date1'], data['form']['date2'])" t-as="move_g"> + <td><span t-esc="move_g['code']"/></td> + <td><span t-esc="move_g['name']"/></td> + <td><span t-esc="formatLang(move_g['debit'])"/></td> + <td><span t-esc="formatLang(move_g['credit'])"/></td> + <td><span t-esc="formatLang(move_g['balance'], currency_obj=res_company.currency_id)"/></td> + <td><span t-esc="formatLang(move_g['quantity'])"/></td> + </tr> + </t> + </tbody> + </table> + </div> + </t> + </t> +</template> +</data> +</openerp> diff --git a/addons/analytic/views/report_analyticcostledger.xml b/addons/analytic/views/report_analyticcostledger.xml new file mode 100644 index 00000000000..cda37d4158f --- /dev/null +++ b/addons/analytic/views/report_analyticcostledger.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> +<data> +<template id="report_analyticcostledger"> + <t t-call="report.html_container"> + <t t-call="report.internal_layout"> + <div class="page"> + <h2>Cost Ledger</h2> + + <div class="row mt32 mb32"> + <div class="col-xs-3"> + <strong>Period From:</strong> + <p t-esc="formatLang(data['form']['date1'], date=True)"/> + </div> + <div class="col-xs-3"> + <strong>Period To:</strong> + <p t-esc="formatLang(data['form']['date2'], date=True)"/> + </div> + <div class="col-xs-3"> + <strong>Printing Date:</strong> + <p t-esc="formatLang(time.strftime('%Y-%m-%d %H:%M:%S'), date_time=True)" /> + </div> + </div> + + <table class="table table-condensed"> + <thead> + <tr> + <th>Date/Code</th> + <th>J.C. /Move</th> + <th>Name</th> + <th>Debit</th> + <th>Credit</th> + <th>Balance</th> + </tr> + </thead> + <tbody> + <tr style="font-weight: bold;"> + <td>Total:</td> + <td></td> + <td></td> + <td><span t-esc="formatLang(sum_debit(docs, data['form']['date1'], data['form']['date2']))"/></td> + <td><span t-esc="formatLang(sum_credit(docs,data['form']['date1'],data['form']['date2']))"/></td> + <td> + <span t-esc="formatLang(sum_debit(docs, data['form']['date1'], data['form']['date2']) - sum_credit(docs, data['form']['date1'], data['form']['date2']), currency_obj=res_company.currency_id)"/> + </td> + </tr> + + <t t-foreach="docs" t-as="account"> + <tr style="font-weight: bold;"> + <td><span t-esc="account.code"/></td> + <td></td> + <td><span t-esc="account.complete_name"/></td> + <td><span t-esc="formatLang(sum_debit([account], data['form']['date1'], data['form']['date2']))"/></td> + <td><span t-esc="formatLang(sum_credit([account], data['form']['date1'], data['form']['date2']))"/></td> + <td><span t-esc="formatLang(sum_debit([account], data['form']['date1'], data['form']['date2']) - sum_credit([account], data['form']['date1'], data['form']['date2']), currency_obj=res_company.currency_id)"/></td> + </tr> + + <t t-foreach="lines_g(account, data['form']['date1'], data['form']['date2'])" t-as="move_g"> + <tr> + <td><span t-esc="move_g['code']"/></td> + <td></td> + <td><span t-esc="move_g['name']"/></td> + <td><span t-esc="move_g['debit']"/></td> + <td><span t-esc="move_g['credit']"/></td> + <td> + <span t-esc="formatLang(move_g['balance'], currency_obj=res_company.currency_id)"/> + </td> + </tr> + <tr t-foreach="lines_a(move_g, account, data['form']['date1'], data['form']['date2'])" t-as="move_a"> + <td> + <t t-esc="formatLang(move_a['date'], date=True)"></t> + </td> + <td><span t-esc="move_a['cj']"/></td> + <td><span t-esc="move_a['name']"/></td> + <td><span t-esc="move_a['debit']"/></td> + <td><span t-esc="move_a['credit']"/></td> + <td> + <span t-esc="formatLang(move_a['balance'], currency_obj=res_company.currency_id)"/> + </td> + </tr> + </t> + </t> + </tbody> + </table> + </div> + </t> + </t> +</template> +</data> +</openerp>
\ No newline at end of file diff --git a/addons/analytic/views/report_analyticcostledgerquantity.xml b/addons/analytic/views/report_analyticcostledgerquantity.xml new file mode 100644 index 00000000000..de49d4972e5 --- /dev/null +++ b/addons/analytic/views/report_analyticcostledgerquantity.xml @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> +<data> +<template id="report_analyticcostledgerquantity"> + <t t-call="report.html_container"> + <t t-call="report.internal_layout"> + <div class="page"> + <h2>Cost Ledger</h2> + + <div class="row mt32 mb32"> + <div class="col-xs-3"> + <strong>Period From:</strong> + <p t-esc="formatLang(data['form']['date1'], date=True)"/> + </div> + <div class="col-xs-3"> + <strong>Period To:</strong> + <p t-esc="formatLang(data['form']['date2'], date=True)"/> + </div> + <div class="col-xs-3"> + <strong>Printing Date:</strong> + <p t-esc="formatLang(time.strftime('%Y-%m-%d %H:%M:%S'), date_time=True)" /> + </div> + </div> + + <table class="table table-condensed"> + <thead> + <tr> + <th>Date/Code</th> + <th>J.C./Move</th> + <th>Name</th> + <th>Quantity</th> + <th>Total</th> + </tr> + </thead> + <tbody> + <tr style="font-weight:bold;"> + <td>Total:</td> + <td></td> + <td></td> + <td></td> + <td> + <span t-esc="sum_quantity(docs, data['form']['date1'], data['form']['date2'], data['form']['journal'])"/> + </td> + </tr> + + <t t-foreach="docs" t-as="account"> + <tr style="font-weight:bold;"> + <td><span t-esc="account.code"/></td> + <td><span t-esc="account.complete_name"/></td> + <td></td> + <td> + <p t-if="account.quantity_max"> + Max quantity : <span t-esc="formatLang(account.quantity_max)"/> + </p> + </td> + <td> + <span t-esc="account_sum_quantity(account.id, data['form']['date1'], data['form']['date2'], data['form']['journal'])"/> + </td> + </tr> + + <t t-foreach="lines_g(account.id, data['form']['date1'], data['form']['date2'], data['form']['journal'])" t-as="move_g"> + <tr style="font-weight:bold;"> + <td><span t-esc="move_g['code']"/></td> + <td colspan="2"><span t-esc="move_g['name']"/></td> + <td></td> + <td class="text-right"><span t-esc="move_g['quantity']"/></td> + </tr> + + <t t-foreach="lines_a(move_g['id'], account.id, data['form']['date1'], data['form']['date2'], data['form']['journal'])" t-as="move_a"> + <tr style="font-weight:normal;"> + <td><span t-esc="formatLang(move_a['date'], date=True)"/></td> + <td><span t-esc="move_a['cj']"/></td> + <td><span t-esc="move_a['name']"/></td> + <td></td> + <td class="text-right"><span t-esc="move_a['quantity']"/></td> + </tr> + </t> + </t> + </t> + </tbody> + </table> + </div> + </t> + </t> +</template> +</data> +</openerp>
\ No newline at end of file diff --git a/addons/analytic/views/report_analyticjournal.xml b/addons/analytic/views/report_analyticjournal.xml new file mode 100644 index 00000000000..1b3a4fda97c --- /dev/null +++ b/addons/analytic/views/report_analyticjournal.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> +<data> +<template id="report_analyticjournal"> + <t t-call="report.html_container"> + <t t-foreach="docs" t-as="o"> + <t t-call="report.internal_layout"> + <div class="page"> + <h2>Analytic Journal</h2> + + <div class="row mt32 mb32"> + <div class="col-xs-3"> + <strong>Period From:</strong> + <p t-esc="formatLang(data['form']['date1'], date=True)"/> + </div> + <div class="col-xs-3"> + <strong>Period To:</strong> + <p t-esc="formatLang(data['form']['date2'], date=True)"/> + </div> + <div class="col-xs-3"> + <strong>Currency:</strong> + <p t-field="res_company.currency_id" /> + </div> + </div> + + <table class="table table-condensed"> + <thead> + <tr> + <th>Date</th> + <th>Code</th> + <th>Move Name</th> + <th>Account n°</th> + <th>General</th> + <th>Analytic</th> + </tr> + <tr> + <th colspan="4"><t t-if="o.code"><span t-esc="o.code"/></t> - <span t-esc="o.name"/></th> + <th><span t-esc="formatLang(sum_general(o.id, data['form']['date1'], data['form']['date2']))"/></th> + <th><span t-esc="formatLang(sum_analytic(o.id, data['form']['date1'], data['form']['date2']))"/></th> + </tr> + </thead> + <tbody> + <t t-foreach="lines(o.id, data['form']['date1'], data['form']['date2'])" t-as="move"> + <tr> + <td></td> + <td></td> + <td> + <span t-esc="move.name"/> + </td> + <td> + <span t-esc="move.account_id.code"/> + <span t-esc="move.account_id.name"/> + </td> + <td> + <span t-esc="formatLang(move.debit-move.credit)"/> + </td> + <td></td> + </tr> + <tr t-foreach="lines_a(move.id, o.id, data['form']['date1'], data['form']['date2'])" t-as="move_a"> + <td> + <span t-esc="formatLang(move_a.date,date = True)"/> + </td> + <td> + <p t-if="move_a.code"><span t-esc="move_a.code"/></p> + </td> + <td> + <span t-esc="move_a.name"/> + </td> + <td><span t-esc="move_a.account_id.code"/> - <span t-esc="move_a.account_id.name"/></td> + <td></td> + <td><span t-esc="formatLang(move_a.amount)"/></td> + </tr> + </t> + <tr t-foreach="lines_a(False, o.id, data['form']['date1'], data['form']['date2'])" t-as="move_a"> + <td><span t-esc="formatLang(move_a.date,date = True)"/></td> + <td><p t-if="move_a.code"><span t-esc="move_a.code"/></p></td> + <td><span t-esc="move_a.name"/></td> + <td><span t-esc="move_a.account_id.code"/> - <span t-esc="move_a.account_id.name"/></td> + <td></td> + <td><span t-esc="formatLang(move_a.amount)"/></td> + </tr> + </tbody> + </table> + </div> + </t> + </t> + </t> +</template> +</data> +</openerp> diff --git a/addons/analytic/views/report_invertedanalyticbalance.xml b/addons/analytic/views/report_invertedanalyticbalance.xml new file mode 100644 index 00000000000..e545ec8525b --- /dev/null +++ b/addons/analytic/views/report_invertedanalyticbalance.xml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> +<data> +<template id="report_invertedanalyticbalance"> + <t t-call="report.html_container"> + <t t-call="report.internal_layout"> + <div class="page"> + <h2>Inverted Analytic Balance - <span t-esc="res_company.currency_id.name"/></h2> + + <table class="table table-condensed"> + <thead> + <tr> + <th>Code</th> + <th>Account Name</th> + <th>Debit</th> + <th>Credit</th> + <th>Balance</th> + <th>Quantity</th> + </tr> + </thead> + <tbody> + <tr> + <td><strong>Total</strong></td> + <td></td> + <td><strong t-esc="formatLang(sum_debit(docs, data['form']['date1'], data['form']['date2']))"/></td> + <td><strong t-esc="formatLang(sum_credit(docs, data['form']['date1'], data['form']['date2']))"/></td> + <td> + <strong t-esc="formatLang(sum_balance(docs, data['form']['date1'], data['form']['date2']), currency_obj=res_company.currency_id)"/> + </td> + <td><strong><span t-esc="formatLang(sum_quantity(docs, data['form']['date1'], data['form']['date2']))"/></strong></td> + </tr> + <t t-foreach="lines_g(docs, data['form']['date1'], data['form']['date2'])" t-as="move_g"> + <tr> + <td> + <strong t-esc="move_g['code']"/> + </td> + <td> + <strong t-esc="move_g['name']"/> + </td> + <td class="text-right"> + <strong> + <span t-esc="formatLang(move_g['debit'])"/> + </strong> + </td> + <td class="text-right"> + <strong> + <span t-esc="formatLang(move_g['credit'])"/> + </strong> + </td> + <td class="text-right"> + <strong> + <span t-esc="formatLang(move_g['balance'], currency_obj = res_company.currency_id)"/> + </strong> + </td> + <td class="text-right"> + <strong> + <span t-esc="formatLang(move_g['quantity'])"/> + </strong> + </td> + </tr> + <t t-foreach="lines_a(docs, move_g['id'], data['form']['date1'], data['form']['date2'])" t-as="move_a"> + <tr> + <td> + <span t-esc="move_a['code']"/> + </td> + <td> + <span t-esc="move_a['complete_name']"/> + </td> + <td class="text-right"> + <span t-esc="formatLang(move_a['debit'])"/> + </td> + <td class="text-right"> + <span t-esc="formatLang(move_a['credit'])"/> + </td> + <td class="text-right"> + <span t-esc="formatLang(move_a['balance'], currency_obj = res_company.currency_id)"/> + </td> + <td class="text-right"> + <span t-esc="formatLang(move_a['quantity'])"/> + </td> + </tr> + </t> + </t> + </tbody> + </table> + </div> + </t> + </t> +</template> +</data> +</openerp> diff --git a/addons/analytic/wizard/__init__.py b/addons/analytic/wizard/__init__.py new file mode 100644 index 00000000000..de0737e07c3 --- /dev/null +++ b/addons/analytic/wizard/__init__.py @@ -0,0 +1,29 @@ +# -*- 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/>. +# +############################################################################## + +import account_analytic_journal_report +import account_analytic_balance_report +import account_analytic_inverted_balance_report +import account_analytic_cost_ledger_report +import account_analytic_cost_ledger_for_journal_report +import account_analytic_chart + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/wizard/account_analytic_balance_report.py b/addons/analytic/wizard/account_analytic_balance_report.py new file mode 100644 index 00000000000..062945fa53e --- /dev/null +++ b/addons/analytic/wizard/account_analytic_balance_report.py @@ -0,0 +1,55 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import fields, osv + + +class account_analytic_balance(osv.osv_memory): + _name = 'account.analytic.balance' + _description = 'Account Analytic Balance' + + _columns = { + 'date1': fields.date('Start of period', required=True), + 'date2': fields.date('End of period', required=True), + 'empty_acc': fields.boolean('Empty Accounts ? ', help='Check if you want to display Accounts with 0 balance too.'), + } + + _defaults = { + 'date1': lambda *a: time.strftime('%Y-01-01'), + 'date2': lambda *a: time.strftime('%Y-%m-%d') + } + + def check_report(self, cr, uid, ids, context=None): + if context is None: + context = {} + data = self.read(cr, uid, ids)[0] + datas = { + 'ids': context.get('active_ids', []), + 'model': 'account.analytic.account', + 'form': data + } + + datas['form']['active_ids'] = context.get('active_ids', False) + + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticbalance', data=datas, context=context) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/wizard/account_analytic_balance_report_view.xml b/addons/analytic/wizard/account_analytic_balance_report_view.xml new file mode 100644 index 00000000000..d4d5d652980 --- /dev/null +++ b/addons/analytic/wizard/account_analytic_balance_report_view.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="account_analytic_balance_view" model="ir.ui.view"> + <field name="name">Account Analytic Balance</field> + <field name="model">account.analytic.balance</field> + <field name="arch" type="xml"> + <form string="Select Period"> + <header> + <button name="check_report" string="Print" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel"/> + </header> + <group col="4"> + <field name="date1"/> + <field name="date2"/> + <newline/> + <field name="empty_acc"/> + </group> + </form> + </field> + </record> + + <record id="action_account_analytic_balance" model="ir.actions.act_window"> + <field name="name">Analytic Balance</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.balance</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="account_analytic_balance_view"/> + <field name="target">new</field> + </record> + + <record model="ir.values" id="account_analytic_balance_values"> + <field name="model_id" ref="analytic.model_account_analytic_account" /> + <field name="name">Account Analytic Balance</field> + <field name="key2">client_print_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_analytic_balance'))" /> + <field name="key">action</field> + <field name="model">account.analytic.account</field> + </record> + + </data> +</openerp> + diff --git a/addons/analytic/wizard/account_analytic_chart.py b/addons/analytic/wizard/account_analytic_chart.py new file mode 100644 index 00000000000..410830a0e9e --- /dev/null +++ b/addons/analytic/wizard/account_analytic_chart.py @@ -0,0 +1,49 @@ +# -*- 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 openerp.osv import fields, osv + +class account_analytic_chart(osv.osv_memory): + _name = 'account.analytic.chart' + _description = 'Account Analytic Chart' + + _columns = { + 'from_date': fields.date('From'), + 'to_date': fields.date('To'), + } + + def analytic_account_chart_open_window(self, cr, uid, ids, context=None): + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + result_context = {} + if context is None: + context = {} + result = mod_obj.get_object_reference(cr, uid, 'analytic', 'action_account_analytic_account_tree2') + id = result and result[1] or False + result = act_obj.read(cr, uid, [id], context=context)[0] + data = self.read(cr, uid, ids, [])[0] + if data['from_date']: + result_context.update({'from_date': data['from_date']}) + if data['to_date']: + result_context.update({'to_date': data['to_date']}) + result['context'] = str(result_context) + return result + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/wizard/account_analytic_chart_view.xml b/addons/analytic/wizard/account_analytic_chart_view.xml new file mode 100644 index 00000000000..8cbab1d5878 --- /dev/null +++ b/addons/analytic/wizard/account_analytic_chart_view.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="account_analytic_chart_view" model="ir.ui.view"> + <field name="name">Chart of Analytic Accounts</field> + <field name="model">account.analytic.chart</field> + <field name="arch" type="xml"> + <form string="Analytic Account Charts"> + <group string="Select the Period for Analysis" col="4"> + <field name="from_date"/> + <field name="to_date"/> + <label string="(Keep empty to open the current situation)" colspan="4"/> + </group> + <footer> + <button name="analytic_account_chart_open_window" string="Open Charts" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel"/> + </footer> + </form> + </field> + </record> + + <record id="action_account_analytic_chart" model="ir.actions.act_window"> + <field name="name">Chart of Analytic Accounts</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.chart</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="account_analytic_chart_view"/> + <field name="target">new</field> + </record> + + </data> +</openerp> diff --git a/addons/analytic/wizard/account_analytic_cost_ledger_for_journal_report.py b/addons/analytic/wizard/account_analytic_cost_ledger_for_journal_report.py new file mode 100644 index 00000000000..ab84af4880a --- /dev/null +++ b/addons/analytic/wizard/account_analytic_cost_ledger_for_journal_report.py @@ -0,0 +1,54 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import fields, osv + + +class account_analytic_cost_ledger_journal_report(osv.osv_memory): + _name = 'account.analytic.cost.ledger.journal.report' + _description = 'Account Analytic Cost Ledger For Journal Report' + + _columns = { + 'date1': fields.date('Start of period', required=True), + 'date2': fields.date('End of period', required=True), + 'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel', 'ledger_id', 'journal_id', 'Journals'), + } + + _defaults = { + 'date1': lambda *a: time.strftime('%Y-01-01'), + 'date2': lambda *a: time.strftime('%Y-%m-%d') + } + + def check_report(self, cr, uid, ids, context=None): + if context is None: + context = {} + data = self.read(cr, uid, ids)[0] + datas = { + 'ids': context.get('active_ids', []), + 'model': 'account.analytic.account', + 'form': data + } + + datas['form']['active_ids'] = context.get('active_ids', False) + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticcostledgerquantity', data=datas, context=context) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/wizard/account_analytic_cost_ledger_for_journal_report_view.xml b/addons/analytic/wizard/account_analytic_cost_ledger_for_journal_report_view.xml new file mode 100644 index 00000000000..55b13e345f0 --- /dev/null +++ b/addons/analytic/wizard/account_analytic_cost_ledger_for_journal_report_view.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="account_analytic_cost_ledger_journal_view" model="ir.ui.view"> + <field name="name">Account Analytic Cost Ledger Journal</field> + <field name="model">account.analytic.cost.ledger.journal.report</field> + <field name="arch" type="xml"> + <form string="Select period"> + <header> + <button name="check_report" string="Print" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel"/> + </header> + <group string="Cost Ledger for Period" col="4"> + <field name="date1"/> + <field name="date2"/> + <field name="journal" colspan="4"/> + </group> + </form> + </field> + </record> + + <record id="action_account_analytic_cost_ledger_journal" model="ir.actions.act_window"> + <field name="name">Cost Ledger (Only quantities)</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.cost.ledger.journal.report</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="account_analytic_cost_ledger_journal_view"/> + <field name="target">new</field> + </record> + + <record model="ir.values" id="account_analytic_cost_ledger_journal_values"> + <field name="model_id" ref="analytic.model_account_analytic_account" /> + <field name="name">Account Analytic Cost Ledger Journal</field> + <field name="key2">client_print_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_analytic_cost_ledger_journal'))" /> + <field name="key">action</field> + <field name="model">account.analytic.account</field> + </record> + + </data> +</openerp> diff --git a/addons/analytic/wizard/account_analytic_cost_ledger_report.py b/addons/analytic/wizard/account_analytic_cost_ledger_report.py new file mode 100644 index 00000000000..978863f5900 --- /dev/null +++ b/addons/analytic/wizard/account_analytic_cost_ledger_report.py @@ -0,0 +1,54 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import osv, fields + + +class account_analytic_cost_ledger(osv.osv_memory): + _name = 'account.analytic.cost.ledger' + _description = 'Account Analytic Cost Ledger' + + _columns = { + 'date1': fields.date('Start of period', required=True), + 'date2': fields.date('End of period', required=True), + } + + _defaults = { + 'date1': lambda *a: time.strftime('%Y-01-01'), + 'date2': lambda *a: time.strftime('%Y-%m-%d') + } + + def check_report(self, cr, uid, ids, context=None): + if context is None: + context = {} + data = self.read(cr, uid, ids)[0] + datas = { + 'ids': context.get('active_ids',[]), + 'model': 'account.analytic.account', + 'form': data + } + + datas['form']['active_ids'] = context.get('active_ids', False) + + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticcostledger', data=datas, context=context) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/wizard/account_analytic_cost_ledger_view.xml b/addons/analytic/wizard/account_analytic_cost_ledger_view.xml new file mode 100644 index 00000000000..25ab748732b --- /dev/null +++ b/addons/analytic/wizard/account_analytic_cost_ledger_view.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="account_analytic_cost_view" model="ir.ui.view"> + <field name="name">Account Analytic Check</field> + <field name="model">account.analytic.cost.ledger</field> + <field name="arch" type="xml"> + <form string="Select Period"> + <header> + <button name="check_report" string="Print" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel"/> + </header> + <group col="4"> + <field name="date1"/> + <field name="date2"/> + </group> + </form> + </field> + </record> + + <record id="action_account_analytic_cost" model="ir.actions.act_window"> + <field name="name">Cost Ledger</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.cost.ledger</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="account_analytic_cost_view"/> + <field name="target">new</field> + </record> + + <record model="ir.values" id="account_analytic_cost_values"> + <field name="model_id" ref="analytic.model_account_analytic_account" /> + <field name="name">Account Analytic Cost</field> + <field name="key2">client_print_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_analytic_cost'))" /> + <field name="key">action</field> + <field name="model">account.analytic.account</field> + </record> + + </data> +</openerp> diff --git a/addons/analytic/wizard/account_analytic_inverted_balance_report.py b/addons/analytic/wizard/account_analytic_inverted_balance_report.py new file mode 100644 index 00000000000..93946960297 --- /dev/null +++ b/addons/analytic/wizard/account_analytic_inverted_balance_report.py @@ -0,0 +1,52 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import fields, osv + + +class account_analytic_inverted_balance(osv.osv_memory): + _name = 'account.analytic.inverted.balance' + _description = 'Account Analytic Inverted Balance' + + _columns = { + 'date1': fields.date('Start of period', required=True), + 'date2': fields.date('End of period', required=True), + } + + _defaults = { + 'date1': lambda *a: time.strftime('%Y-01-01'), + 'date2': lambda *a: time.strftime('%Y-%m-%d') + } + + def check_report(self, cr, uid, ids, context=None): + if context is None: + context = {} + data = self.read(cr, uid, ids)[0] + datas = { + 'ids': context.get('active_ids', []), + 'model': 'account.analytic.account', + 'form': data + } + datas['form']['active_ids'] = context.get('active_ids', False) + return self.pool['report'].get_action(cr, uid, [], 'account.report_invertedanalyticbalance', data=datas, context=context) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/wizard/account_analytic_inverted_balance_report.xml b/addons/analytic/wizard/account_analytic_inverted_balance_report.xml new file mode 100644 index 00000000000..5188c013b4d --- /dev/null +++ b/addons/analytic/wizard/account_analytic_inverted_balance_report.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="account_analytic_invert_balance_view" model="ir.ui.view"> + <field name="name">Account Analytic Inverted Balance</field> + <field name="model">account.analytic.inverted.balance</field> + <field name="arch" type="xml"> + <form string="Select Period"> + <header> + <button name="check_report" string="Print" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel"/> + </header> + <group col="4"> + <field name="date1"/> + <field name="date2"/> + </group> + </form> + </field> + </record> + + <record id="action_account_analytic_invert_balance" model="ir.actions.act_window"> + <field name="name">Inverted Analytic Balance</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.inverted.balance</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="account_analytic_invert_balance_view"/> + <field name="target">new</field> + </record> + + <record model="ir.values" id="account_analytic_invert_balance_values"> + <field name="model_id" ref="analytic.model_account_analytic_account" /> + <field name="name">Account Analytic Inverted Balance</field> + <field name="key2">client_print_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_analytic_invert_balance'))" /> + <field name="key">action</field> + <field name="model">account.analytic.account</field> + </record> + + </data> +</openerp> diff --git a/addons/analytic/wizard/account_analytic_journal_report.py b/addons/analytic/wizard/account_analytic_journal_report.py new file mode 100644 index 00000000000..d8790e805d8 --- /dev/null +++ b/addons/analytic/wizard/account_analytic_journal_report.py @@ -0,0 +1,74 @@ +# -*- 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/>. +# +############################################################################## + +import time +from openerp.osv import fields, osv + + +class account_analytic_journal_report(osv.osv_memory): + _name = 'account.analytic.journal.report' + _description = 'Account Analytic Journal' + + _columns = { + 'date1': fields.date('Start of period', required=True), + 'date2': fields.date('End of period', required=True), + 'analytic_account_journal_id': fields.many2many('account.analytic.journal', 'account_analytic_journal_name', 'journal_line_id', 'journal_print_id', 'Analytic Journals', required=True), + } + + _defaults = { + 'date1': lambda *a: time.strftime('%Y-01-01'), + 'date2': lambda *a: time.strftime('%Y-%m-%d') + } + + def check_report(self, cr, uid, ids, context=None): + if context is None: + context = {} + data = self.read(cr, uid, ids)[0] + ids_list = [] + if context.get('active_id',False): + ids_list.append(context.get('active_id',False)) + else: + record = self.browse(cr,uid,ids[0],context=context) + for analytic_record in record.analytic_account_journal_id: + ids_list.append(analytic_record.id) + datas = { + 'ids': ids_list, + 'model': 'account.analytic.journal', + 'form': data + } + context2 = context.copy() + context2['active_model'] = 'account.analytic.journal' + context2['active_ids'] = ids_list + return self.pool['report'].get_action(cr, uid, [], 'account.report_analyticjournal', data=datas, context=context2) + + def default_get(self, cr, uid, fields, context=None): + if context is None: + context = {} + res = super(account_analytic_journal_report, self).default_get(cr, uid, fields, context=context) + if not context.has_key('active_ids'): + journal_ids = self.pool.get('account.analytic.journal').search(cr, uid, [], context=context) + else: + journal_ids = context.get('active_ids') + if 'analytic_account_journal_id' in fields: + res.update({'analytic_account_journal_id': journal_ids}) + return res + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/wizard/account_analytic_journal_report_view.xml b/addons/analytic/wizard/account_analytic_journal_report_view.xml new file mode 100644 index 00000000000..3aaea712582 --- /dev/null +++ b/addons/analytic/wizard/account_analytic_journal_report_view.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="account_analytic_journal_view" model="ir.ui.view"> + <field name="name">Account Analytic Journal</field> + <field name="model">account.analytic.journal.report</field> + <field name="arch" type="xml"> + <form string="Select Period"> + <group col="4"> + <field name="date1"/> + <field name="date2"/> + <field name="analytic_account_journal_id" widget="many2many_tags" class="oe_inline" required="1" colspan="4"/> + </group> + <footer> + <button name="check_report" string="Print" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel"/> + </footer> + </form> + </field> + </record> + + <record id="action_account_analytic_journal" model="ir.actions.act_window"> + <field name="name">Analytic Journal</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.analytic.journal.report</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="account_analytic_journal_view"/> + <field name="target">new</field> + </record> + + <record model="ir.values" id="account_analytic_journal_values"> + <field name="model_id" ref="analytic.model_account_analytic_journal" /> + <field name="name">Account Analytic Journal</field> + <field name="key2">client_print_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_analytic_journal'))" /> + <field name="key">action</field> + <field name="model">account.analytic.journal</field> + </record> + + </data> +</openerp> |
