New trunk

bzr revid: pinky-dedd7f8a42bd4557112a0513082691b8590ad6cc
This commit is contained in:
pinky 2006-12-07 13:41:40 +00:00
parent 004a0b996f
commit a83dce15e0
857 changed files with 249258 additions and 0 deletions

View File

@ -0,0 +1,37 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import account
import project
import invoice
import transfer
import wizard
import report
import partner
import product

View File

@ -0,0 +1,44 @@
{
"name" : "Accounting and financial management",
"version" : "1.0",
"depends" : ["product"],
"author" : "Tiny",
"description": """Financial and accounting module that covers:
General accounting
Cost / Analytic accounting
Third party accounting
Taxes management
Budgets
""",
"website" : "http://tinyerp.com/module_account.html",
"category" : "Generic Modules/Accounting",
"init_xml" : [
],
"demo_xml" : [
"account_demo.xml",
"project/project_demo.xml",
"project/account.analytic.account.csv"
],
"update_xml" : [
"account_wizard.xml",
"account_view.xml",
"account_end_fy.xml",
"account_view_transfer.xml",
"account_invoice_view.xml",
"account_report.xml",
"partner_view.xml",
"data/account_invoice.xml",
"data/account_data.xml",
"data/account_minimal.xml",
"account_invoice_workflow.xml",
"project/project_view.xml",
"project/project_report.xml",
"product_data.xml",
"product_view.xml",
],
# "translations" : {
# "fr": "i18n/french_fr.csv"
# },
"active": False,
"installable": True
}

1678
addons/account/account.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,106 @@
<?xml version="1.0"?>
<terp>
<data noupdate="1">
<!--
Fiscal year
-->
<record model="account.fiscalyear" id="data_fiscalyear">
<field name="name" eval="'Fiscal Year '+time.strftime('%Y')"/>
<field name="code" eval="'FY'+time.strftime('%Y')"/>
<field name="date_start" eval="time.strftime('%Y')+'-01-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-12-31'"/>
</record>
<!--
Fiscal Periods
-->
<record model="account.period">
<field name="name" eval="'Jan.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-01-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-01-31'"/>
</record>
<record model="account.period">
<field name="name" eval="'Feb.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-02-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-02-28'"/>
</record>
<record model="account.period">
<field name="name" eval="'Mar.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-03-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-03-31'"/>
</record>
<record model="account.period">
<field name="name" eval="'Apr.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-04-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-04-30'"/>
</record>
<record model="account.period">
<field name="name" eval="'May.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-05-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-05-31'"/>
</record>
<record model="account.period">
<field name="name" eval="'Jun.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-06-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-06-30'"/>
</record>
<record model="account.period">
<field name="name" eval="'Jul.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-07-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-07-31'"/>
</record>
<record model="account.period">
<field name="name" eval="'Aug.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-08-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-08-31'"/>
</record>
<record model="account.period">
<field name="name" eval="'Sep.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-09-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-09-30'"/>
</record>
<record model="account.period">
<field name="name" eval="'Oct.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-10-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-10-31'"/>
</record>
<record model="account.period">
<field name="name" eval="'Nov.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-11-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-11-30'"/>
</record>
<record model="account.period">
<field name="name" eval="'Dec.'+time.strftime('%Y')"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field name="date_start" eval="time.strftime('%Y')+'-12-01'"/>
<field name="date_stop" eval="time.strftime('%Y')+'-12-31'"/>
</record>
<record model="account.bank" id="fs">
<field name="name">Fortis</field>
<field name="code">FSB</field>
</record>
<record model="account.bank.account">
<field name="name">001-123456789-73</field>
<field name="journal_id" ref="bank_journal"/>
<field name="bank_id" ref="fs"/>
<field name="currency_id" ref="base.EUR"/>
<field name="account_id" ref="account.cash"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<terp>
<data>
<menuitem name="Financial Management/End of year treatments" sequence="20"/>
<record model="ir.actions.act_window" id="action_account_period_tree">
<field name="name">account.period.tree</field>
<field name="res_model">account.period</field>
<field name="view_type">tree</field>
<field name="domain">[('state','=','draft')]</field>
<field name="view_id" ref="view_account_period_tree"/>
</record>
<menuitem name="Financial Management/End of year treatments/Close a period"
id="menu_action_account_period_close_tree"
action="action_account_period_tree" />
<record model="ir.actions.act_window" id="action_account_fiscalyear_tree">
<field name="name">account.fiscalyear.tree</field>
<field name="res_model">account.fiscalyear</field>
<field name="view_type">tree</field>
<field name="domain">[('state','=','done')]</field>
<field name="view_id" ref="view_account_fiscalyear_tree"/>
</record>
<menuitem name="Financial Management/End of year treatments/Old fiscal years"
id="menu_action_account_fiscalyear_close_tree"
action="action_account_fiscalyear_tree"/>
</data>
</terp>

View File

@ -0,0 +1,319 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="ir.ui.view" id="view_company_from_invoice">
<field name="name">res.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="rml_footer2" position="after">
<field name="currency_id" />
</field>
</field>
</record>
#---------------------------------------------------------
# Invoices
#---------------------------------------------------------
<record model="ir.ui.view" id="view_invoice_line_tree">
<field name="name">account.invoice.line.tree</field>
<field name="model">account.invoice.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Invoice Line">
<field name="name"/>
<field name="account_id"/>
<field name="quantity"/>
<field name="uos_id"/>
<field name="price_unit"/>
<field name="discount"/>
<field name="price_subtotal"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_invoice_line_form">
<field name="name">account.invoice.line.form</field>
<field name="model">account.invoice.line</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Invoice Line">
<notebook>
<page string="Line">
<field name="name" select="1"/>
<field name="account_id" on_change="onchange_account_id(parent.partner_id,account_id)" />
<field name="product_id" select="1" on_change="product_id_change(product_id, uos_id, quantity, name)"/>
<field name="uos_id"/>
<field name="quantity" select="1"/>
<field name="price_unit" select="1"/>
<field name="discount"/>
<newline/>
<field name="price_subtotal"/>
<field name="invoice_line_tax_id" colspan="3"/>
</page>
<page string="Other">
<field name="note" colspan="4"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_invoice_tax_tree">
<field name="name">account.invoice.tax.tree</field>
<field name="model">account.invoice.tax</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Manual Invoice Taxes">
<field name="sequence"/>
<field name="manual"/>
<field name="name"/>
<field name="account_id"/>
<field name="base"/>
<field name="amount"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_invoice_tax_form">
<field name="name">account.invoice.tax.form</field>
<field name="model">account.invoice.tax</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Manual Invoice Taxes">
<field name="name" select="1"/>
<field name="sequence"/>
<field name="account_id" select="1"/>
<field name="manual" select="1"/>
<field name="amount" select="1"/>
<field name="base"/>
<separator string="Tax codes" colspan="4"/>
<field name="base_code_id"/>
<field name="base_amount"/>
<field name="tax_code_id"/>
<field name="tax_amount"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="invoice_tree">
<field name="name">account.invoice.tree</field>
<field name="model">account.invoice</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Invoice" colors="grey:state=='draft'">
<field name="name"/>
<field name="type"/>
<field name="number"/>
<field name="date_invoice"/>
<field name="partner_id"/>
<field name="amount_untaxed"/>
<field name="amount_total"/>
<field name="currency_id"/>
<field name="state"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="invoice_form">
<field name="name">account.invoice.form1</field>
<field name="model">account.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Invoice">
<notebook>
<page string="Invoice">
<field name="name" select="1"/>
<field name="currency_id" on_change="onchange_currency_id(currency_id)" select="1"/>
<newline/>
<field name="type" select="1"/>
<field name="number" select="1"/>
<newline/>
<field name="partner_id" on_change="onchange_partner_id(type,partner_id)" select="1"/>
<field name="address_invoice_id" domain="[('partner_id','=',partner_id)]"/>
<field name="account_id"/>
<field name="project_id"/>
<field name="payment_term"/>
<field name="date_due"/>
<field name="journal_id" select="1"/>
<field name="invoice_line" nolabel="1" widget="one2many_list" colspan="4"/>
<group colspan="4" col="7">
<field name="amount_untaxed"/>
<field name="amount_tax"/>
<field name="amount_total"/>
<button name="button_compute" string="Compute" states="draft" type="object"/>
</group>
<group col="6" colspan="4">
<field name="state" readonly="1" select="1"/>
<button name="invoice_proforma" states="draft" string="Create PRO-FORMA"/>
<button name="invoice_open" states="draft,proforma" string="Create Invoice"/>
<button name="invoice_cancel" states="draft,proforma,sale,open" string="Cancel Invoice"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
</group>
</page>
<page string="Tax Lines">
<field name="tax_line" nolabel="1" widget="one2many_list" colspan="4"/>
</page>
<page string="Other Information">
<field name="reference" select="1"/>
<field name="origin"/>
<field name="address_contact_id" domain="[('partner_id','=',partner_id)]" colspan="3"/>
<field name="partner_ref"/>
<field name="partner_contact"/>
<field name="move_id"/>
<field name="date_invoice" select="1"/>
<field name="period_id"/><label string="(keep empty to use the current period)" align="0.0" colspan="2"/>
<newline/>
<field name="comment" colspan="3"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_invoice_form">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_id" ref="invoice_form"/>
</record>
<menuitem name="Financial Management/Invoices" id="menu_action_invoice_form" action="action_invoice_form" sequence="6"/>
<record model="ir.actions.act_window" id="action_invoice_tree1">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
<menuitem name="Financial Management/Invoices/Customers Invoices" id="menu_action_invoice_tree1" action="action_invoice_tree1"/>
<record model="ir.actions.act_window" id="action_invoice_tree2">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('type','=','in_invoice')]</field>
<field name="context">{'type':'in_invoice'}</field>
</record>
<menuitem name="Financial Management/Invoices/Suppliers Invoices" id="menu_action_invoice_tree2" action="action_invoice_tree2"/>
<record model="ir.actions.act_window" id="action_invoice_tree3">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('type','=','out_refund')]</field>
<field name="context">{'type':'out_refund'}</field>
</record>
<menuitem name="Financial Management/Invoices/Customers Refund" id="menu_action_invoice_tree3" action="action_invoice_tree3"/>
<record model="ir.actions.act_window" id="action_invoice_tree4">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('type','=','in_refund')]</field>
<field name="context">{'type':'in_refund'}</field>
</record>
<menuitem name="Financial Management/Invoices/Suppliers Refund" id="menu_action_invoice_tree4" action="action_invoice_tree4"/>
<record model="ir.actions.act_window" id="action_invoice_tree5">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft'),('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
<menuitem name="Financial Management/Invoices/Customers Invoices/Draft Invoices" action="action_invoice_tree5" id="menu_invoice_draft"/>
<record model="ir.actions.act_window" id="action_invoice_tree6">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','proforma'),('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
<menuitem name="Financial Management/Invoices/Customers Invoices/PRO-FORMA" id="menu_action_invoice_tree6" action="action_invoice_tree6"/>
<record model="ir.actions.act_window" id="action_invoice_tree7">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','open'),('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice'}</field>
</record>
<menuitem name="Financial Management/Invoices/Customers Invoices/Opened Invoices" id="menu_action_invoice_tree7" action="action_invoice_tree7"/>
<record model="ir.actions.act_window" id="action_invoice_tree8">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft'),('type','=','in_invoice')]</field>
<field name="context">{'type':'in_invoice'}</field>
</record>
<menuitem name="Financial Management/Invoices/Suppliers Invoices/Draft" id="menu_action_invoice_tree8" action="action_invoice_tree8"/>
<record model="ir.actions.act_window" id="action_invoice_tree9">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','open'),('type','=','in_invoice')]</field>
<field name="context">{'type':'in_invoice'}</field>
</record>
<menuitem name="Financial Management/Invoices/Suppliers Invoices/Opened" id="menu_action_invoice_tree9" action="action_invoice_tree9"/>
<record model="ir.actions.act_window" id="action_invoice_tree10">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft'),('type','=','out_refund')]</field>
<field name="context">{'type':'out_refund'}</field>
</record>
<menuitem name="Financial Management/Invoices/Customers Refund/Draft" id="menu_action_invoice_tree10" action="action_invoice_tree10"/>
<record model="ir.actions.act_window" id="action_invoice_tree11">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','open'),('type','=','out_refund')]</field>
<field name="context">{'type':'out_refund'}</field>
</record>
<menuitem name="Financial Management/Invoices/Customers Refund/Opened" id="menu_action_invoice_tree11" action="action_invoice_tree11"/>
<record model="ir.actions.act_window" id="action_invoice_tree12">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft'),('type','=','in_refund')]</field>
<field name="context">{'type':'in_refund'}</field>
</record>
<menuitem name="Financial Management/Invoices/Suppliers Refund/Draft" id="menu_action_invoice_tree12" action="action_invoice_tree12"/>
<record model="ir.actions.act_window" id="action_invoice_tree13">
<field name="name">account.invoice</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','open'),('type','=','in_refund')]</field>
<field name="context">{'type':'in_refund'}</field>
</record>
<menuitem name="Financial Management/Invoices/Suppliers Refund/Opened" id="menu_action_invoice_tree13" action="action_invoice_tree13"/>
</data>
</terp>

View File

@ -0,0 +1,121 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="workflow" id="wkf">
<field name="name">account.invoice.basic</field>
<field name="osv">account.invoice</field>
<field name="on_create">True</field>
</record>
<record model="workflow.activity" id="act_draft">
<field name="wkf_id" ref="wkf"/>
<field name="flow_start">True</field>
<field name="name">draft</field>
</record>
<!-- <record model="workflow.activity" id="act_confirm">
<field name="wkf_id" ref="wkf"/>
<field name="name">confirm</field>
</record> -->
<record model="workflow.activity" id="act_sale">
<field name="wkf_id" ref="wkf"/>
<field name="name">sale</field>
<field name="action">action_move_create()&#10;write({'state':'sale'})</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_proforma">
<field name="wkf_id" ref="wkf"/>
<field name="name">proforma</field>
<field name="action">action_move_create()&#10;write({'state':'proforma'})</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_open">
<field name="wkf_id" ref="wkf"/>
<field name="name">open</field>
<field name="action">action_move_create()&#10;action_number()&#10;write({'state':'open'})</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_paid">
<field name="wkf_id" ref="wkf"/>
<field name="name">paid</field>
<field name="flow_stop">True</field>
<field name="action">write({'state':'paid'})</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_cancel">
<field name="wkf_id" ref="wkf"/>
<field name="name">cancel</field>
<field name="flow_stop">True</field>
<field name="action">action_cancel()&#10;write({'state':'cancel'})</field>
<field name="kind">function</field>
</record>
<!--
<record model="workflow.transition" id="t1">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_confirm"/>
</record>
-->
<record model="workflow.transition" id="t2">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_sale"/>
<field name="signal">invoice_sale</field>
</record>
<record model="workflow.transition" id="t3">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_proforma"/>
<field name="signal">invoice_proforma</field>
</record>
<record model="workflow.transition" id="t4">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_open"/>
<field name="signal">invoice_open</field>
</record>
<record model="workflow.transition" id="t5">
<field name="act_from" ref="act_proforma"/>
<field name="act_to" ref="act_open"/>
<field name="signal">invoice_open</field>
</record>
<record model="workflow.transition" id="t6">
<field name="act_from" ref="act_sale"/>
<field name="act_to" ref="act_paid"/>
<field name="trigger_model">account.move.line</field>
<field name="trigger_expr_id">move_line_id_payment_get()</field>
<field name="condition">test_paid()</field>
</record>
<record model="workflow.transition" id="t7">
<field name="act_from" ref="act_proforma"/>
<field name="act_to" ref="act_paid"/>
<field name="trigger_model">account.move.line</field>
<field name="trigger_expr_id">move_line_id_payment_get()</field>
<field name="condition">test_paid()</field>
</record>
<record model="workflow.transition" id="t8">
<field name="act_from" ref="act_open"/>
<field name="act_to" ref="act_paid"/>
<field name="trigger_model">account.move.line</field>
<field name="trigger_expr_id">move_line_id_payment_get()</field>
<field name="condition">test_paid()</field>
</record>
<record model="workflow.transition" id="t9">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record model="workflow.transition" id="t10">
<field name="act_from" ref="act_sale"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record model="workflow.transition" id="t11">
<field name="act_from" ref="act_proforma"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record model="workflow.transition" id="t12">
<field name="act_from" ref="act_open"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,122 @@
<?xml version="1.0"?>
<terp>
<data>
<report id="account_ledger"
string="General Ledger"
model="account.account"
name="account.grand.livre"
rml="account/report/grand_livre.rml"
auto="False"
menu="False"/>
<report id="account_3rdparty_ledger"
string="Third party ledger"
model="res.partner"
name="account.grand.livre.tiers"
rml="account/report/grand_livre_tiers.rml"
auto="False"
menu="False"/>
<report id="account_account_balance"
string="Account balance"
model="account.account"
name="account.account.balance"
rml="account/report/account_balance.rml"
auto="False"
menu="False"/>
<report id="account_3rdparty_account_balance"
string="Third party balance"
model="account.account"
name="account.partner.balance"
rml="account/report/partner_balance.rml"
auto="False"
menu="False"/>
<report id="account_budget"
string="Print Budget"
model="account.budget.post"
name="account.budget"
rml="account/report/budget_report.rml"
auto="False"
menu="False"/>
<report id="account_central_journal"
string="Print Central Journal"
model="account.journal.period"
name="account.central.journal"
rml="account/report/central_journal.rml"
auto="False"/>
<report id="account_general_journal"
string="Print General Journal"
model="account.journal.period"
name="account.general.journal"
rml="account/report/general_journal.rml"
auto="False"/>
<report id="account_journal"
string="Print Journal"
model="account.journal.period"
name="account.journal.period.print"
rml="account/report/account_journal.rml"
auto="False"/>
<report id="account_overdue"
string="Overdue payments"
model="res.partner"
name="account.rappel"
rml="account/report/rappel.rml"
auto="False" />
<report id="account_invoices"
string="Invoices"
model="account.invoice"
name="account.invoice"
rml="account/report/invoice.rml"
auto="False"/>
<report id="account_transfers"
string="Transfers"
model="account.transfer"
name="account.transfer"
xml="account/report/transfer.xml"
xsl="account/report/transfer.xsl"/>
<report id="account_intracom"
string="IntraCom"
model="account.move.line"
name="account.intracom"
menu="False"
auto="False" />
<report id="account_move_line_list"
string="All Entries"
model="account.tax.code"
name="account.tax.code.entries"
rml="account/report/account_tax_code.rml"
/>
<report id="account_vat_declaration"
string="VAT Declaration"
model="account.tax.code"
name="account.vat.declaration"
rml="account/report/tax_report.rml"
auto="False"
menu="False"/>
<wizard
string="Wizard VAT Declaration"
model="account.tax.code"
name="account.vat.declaration"
menu="False"
id="wizard_vat_declaration"/>
<menuitem
name="Financial Management/Reporting/VAT Declaration"
action="wizard_vat_declaration"
type="wizard"
id="menu_wizard_vat_declaration"/>
<!--
<report id="analytic_journal"
string="Analytic journal"
model="account.analytic.account"
name="account.analytic.journal"
xml="account/report/analytic_journal.rml"
auto="False" />
-->
</data>
</terp>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
<?xml version="1.0"?>
<terp>
<data>
#---------------------------------------------------------
# Transfers
#---------------------------------------------------------
<record model="ir.ui.view" id="view_transfer_tree">
<field name="name">account.transfer.tree</field>
<field name="model">account.transfer</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Transfers">
<field name="date"/>
<field name="name" select="1"/>
<field name="type"/>
<field name="amount"/>
<field name="account_src_id"/>
<field name="account_dest_id"/>
<field name="state"/>
<field name="partner_id" select="1"/>
<field name="project_id" select="1"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_transfer_form">
<field name="name">account.transfer.form</field>
<field name="model">account.transfer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Transfers">
<field name="name" select="1"/>
<field name="reference" select="1"/>
<field name="journal_id" select="1"/>
<field name="period_id" select="1"/>
<field name="type" on_change="onchange_type(type)"/>
<field name="partner_id" select="1" on_change="onchange_partner(type,partner_id)"/>
<field name="date" select="1"/>
<field name="project_id"/>
<field name="amount" select="1"/>
<field name="change" select="1"/>
<newline/>
<field name="account_src_id" select="1" on_change="onchange_account(type,account_src_id,account_dest_id)"/>
<field name="account_dest_id" select="1"/>
<newline/>
<field name="state" select="1"/>
<group colspan="2">
<button name="pay_validate" states="draft" string="Confirm Payment" type="object"/>
<button name="pay_cancel" states="posted" string="Cancel Payment" type="object"/>
</group>
<separator string="Related Invoices" colspan="4"/>
<field name="invoice_id" colspan="4" domain="[('partner_id','=',partner_id),('state','=','open')]"/>
<separator string="Adjustement and corrections" colspan="4"/>
<field name="adjust_amount"/>
<field name="adjust_account_id"/>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_transfer_form">
<field name="name">account.transfer.form</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.transfer</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_transfer_form"/>
</record>
<!--
<menuitem name="Financial Management/Entries/Cash Book Transfers" action="action_transfer_form" sequence="15"/>
-->
</data>
</terp>

View File

@ -0,0 +1,191 @@
<?xml version="1.0"?>
<terp>
<data>
<menuitem name="Financial Management" icon="terp-account"/>
<wizard
string="Refund Invoice"
model="account.invoice"
name="account.invoice.refund"
id="wizard_invoice_refund"/>
<wizard
string="Pay Invoice"
model="account.invoice"
name="account.invoice.pay"
id="wizard_invoice_pay"/>
<wizard
string="Spread amount"
model="account.budget.post"
name="account.budget.spread"
menu="False"
id="wizard_budget_spread"/>
<!-- close year, period, journal -->
<wizard
string="Close Fiscal Year"
model="account.fiscalyear"
name="account.fiscalyear.close"
keyword="tree_but_action"
id="wizard_fiscalyear_close"/>
<menuitem
name="Financial Management/End of year treatments/Close a fiscal year"
action="wizard_fiscalyear_close"
type="wizard"
id="menu_wizard_fy_close"/>
<wizard
string="Close Period"
model="account.period"
name="account.period.close"
keyword="tree_but_action"
id="wizard_period_close"/>
<wizard
string="Close Journal"
model="account.journal.period"
name="account.journal.period.close"
keyword="tree_but_action"
id="wizard_journal_period_close"
auto="False"/>
<!-- automatic reconcile -->
<wizard
string="Automatic Reconciliation"
model="account.account"
name="account.automatic.reconcile"
menu="False"
id="wizard_automatic_reconcile"/>
<menuitem name="Financial Management/Periodical Processing/Automatic reconciliation"
action="wizard_automatic_reconcile"
type="wizard"
id="menu_automatic_reconcile"/>
<!-- manual reconcile -->
<wizard
string="Reconcile Entries"
model="account.move.line"
name="account.move.line.reconcile"
id="wizard_reconcile"/>
<wizard
string="Reconcile Entries"
model="account.move.line"
name="account.move.line.reconcile.select"
menu="False"
id="wizard_reconcile_select"/>
<menuitem
name="Financial Management/Periodical Processing/Manual reconciliation"
action="wizard_reconcile_select"
type="wizard"
id="menu_reconcile_select"/>
<!-- unreconcile -->
<wizard
string="Unreconcile Entries"
model="account.move.line"
name="account.move.line.unreconcile"
id="wizard_unreconcile"/>
<wizard
string="Unreconcile Entries"
model="account.move.line"
name="account.move.line.unreconcile.select"
menu="False"
id="wizard_unreconcile_select"/>
<menuitem
name="Financial Management/Periodical Processing/Manual unreconciliation"
action="wizard_unreconcile_select"
type="wizard"
id="menu_unreconcile_select"/>
<!-- subscriptions -->
<wizard
string="Generate Subscription Entries"
model="account.subscription"
name="account.subscription.generate"
menu="False"
id="wizard_generate_subscription"/>
<menuitem
name="Financial Management/Periodical Processing/Subscription entries"
action="wizard_generate_subscription"
type="wizard"
id="menu_generate_subscription"/>
<!-- Aged trial balance -->
<wizard
string="Aged Trial Balance"
model="res.partnet"
name="account.aged.trial.balance"
menu="False"
id="wizard_aged_trial_balance"/>
<menuitem
name="Financial Management/Reporting/Aged Trial Balance"
action="wizard_aged_trial_balance"
type="wizard"
id="menu_aged_trial_balance"/>
<!-- report-related wizards -->
<wizard
string="Partner Balance"
model="res.partner"
name="account.partner.balance.report"
menu="False"
id="wizard_partner_balance_report"/>
<menuitem
name="Financial Management/Reporting/Third party balance"
action="wizard_partner_balance_report"
type="wizard"
id="menu_partner_balance"/>
<wizard
string="Third party ledger"
model="res.partner"
name="account.grand.livre.tiers.report"
menu="False"
id="wizard_grand_livre_tiers"/>
<menuitem
name="Financial Management/Reporting/Third party ledger"
action="wizard_grand_livre_tiers"
type="wizard"
id="menu_third_party_ledger"/>
<wizard
string="Budget"
model="account.budget.post"
name="account.budget.report"
keyword="client_print_multi"
id="wizard_budget_report"/>
<wizard
string="Account Balance"
model="account.account"
name="account.account.balance.report"
keyword="client_print_multi"
id="wizard_balance_report"/>
<wizard
string="General Ledger"
model="account.account"
name="account.grand.livre.report"
keyword="client_print_multi"
id="wizard_general_ledger_report"/>
<wizard
string="Confirm draft invoices"
model="account.invoice"
name="account.invoice.state.confirm"
keyword="client_action_multi"
multi="True"
id="wizard_invoice_state_confirm"/>
<wizard
string="Cancel selected invoices"
model="account.invoice"
name="account.invoice.state.cancel"
keyword="client_action_multi"
multi="True"
id="wizard_invoice_state_cancel"/>
</data>
</terp>

View File

@ -0,0 +1,280 @@
<?xml version="1.0"?>
<terp>
<data>
<!--
Account Type
-->
<record model="account.account.type" id="account_type_receivable" >
<field name="name">Receivable</field>
<field name="code">receivable</field>
<field name="partner_account">True</field>
</record>
<record model="account.account.type" id="account_type_payable" >
<field name="name">Payable</field>
<field name="code">payable</field>
<field name="partner_account">True</field>
</record>
<record model="account.account.type" id="account_type_view">
<field name="name">View</field>
<field name="code">view</field>
</record>
<record model="account.account.type" id="account_type_income" >
<field name="name">Income</field>
<field name="code">income</field>
</record>
<record model="account.account.type" id="account_type_expense">
<field name="name">Expense</field>
<field name="code">expense</field>
</record>
<record model="account.account.type" id="account_type_tax">
<field name="name">Tax</field>
<field name="code">tax</field>
</record>
<record model="account.account.type" id="account_type_cash">
<field name="name">Cash</field>
<field name="code">cash</field>
</record>
<record model="account.account.type" id="account_type_asset">
<field name="name">Asset</field>
<field name="code">asset</field>
</record>
<record model="account.account.type" id="account_type_equity">
<field name="name">Equity</field>
<field name="code">equity</field>
</record>
</data>
<data noupdate="1">
<!--
Payment term
-->
<record model="account.payment.term" id="account_payment_term">
<field name="name">Default Payment Term</field>
</record>
<record model="account.payment.term.line" id="account_payment_term_line">
<field name="name">30 days</field>
<field name="value">balance</field>
<field name="days" eval="30"/>
<field name="condition">net days</field>
<field name="payment_id" eval="account_payment_term"/>
</record>
<!--
Account Journal View
-->
<record model="account.journal.view" id="account_journal_bank_view">
<field name="name">Cash Journal View</field>
</record>
<record model="account.journal.column" id="bank_col1">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Date</field>
<field name="field">date</field>
<field name="required" eval="True"/>
<field name="sequence" eval="1"/>
</record>
<record model="account.journal.column" id="bank_col2">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">N. Piece</field>
<field name="field">move_id</field>
<field name="required" eval="False"/>
<field name="sequence" eval="2"/>
</record>
<record model="account.journal.column" id="bank_col7">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Name</field>
<field name="field">name</field>
<field name="sequence" eval="3"/>
<field name="required" eval="True"/>
</record>
<record model="account.journal.column" id="bank_col4">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Statement</field>
<field name="field">statement_id</field>
<field name="sequence" eval="4"/>
</record>
<record model="account.journal.column" id="bank_col6">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Partner</field>
<field name="field">partner_id</field>
<field name="sequence" eval="5"/>
</record>
<record model="account.journal.column" id="bank_col5">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Account</field>
<field name="field">account_id</field>
<field name="required" eval="True"/>
<field name="sequence" eval="6"/>
</record>
<record model="account.journal.column" id="bank_col9">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Debit</field>
<field name="field">debit</field>
<field name="sequence" eval="10"/>
</record>
<record model="account.journal.column" id="bank_col10">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Credit</field>
<field name="field">credit</field>
<field name="sequence" eval="11"/>
</record>
<record model="account.journal.column" id="bank_col3">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Ref</field>
<field name="field">ref</field>
<field name="sequence" eval="7"/>
</record>
<record model="account.journal.column" id="bank_col23">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">State</field>
<field name="field">state</field>
<field name="sequence" eval="12"/>
</record>
<record model="account.journal.view" id="account_journal_view">
<field name="name">Journal View</field>
</record>
<record model="account.journal.column" id="journal_col1">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Date</field>
<field name="field">date</field>
<field name="required" eval="True"/>
<field name="sequence" eval="1"/>
</record>
<record model="account.journal.column" id="journal_col2">
<field name="view_id" ref="account_journal_view"/>
<field name="name">N. Piece</field>
<field name="field">move_id</field>
<field name="required" eval="False"/>
<field name="sequence" eval="2"/>
</record>
<record model="account.journal.column" id="journal_col3">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Ref</field>
<field name="field">ref</field>
<field name="sequence" eval="3"/>
</record>
<record model="account.journal.column" id="journal_col4">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Account</field>
<field name="field">account_id</field>
<field name="required" eval="True"/>
<field name="sequence" eval="5"/>
</record>
<record model="account.journal.column" id="journal_col5">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Partner</field>
<field name="field">partner_id</field>
<field name="sequence" eval="4"/>
</record>
<record model="account.journal.column" id="journal_col6">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Name</field>
<field name="field">name</field>
<field name="sequence" eval="6"/>
<field name="required" eval="True"/>
</record>
<record model="account.journal.column" id="journal_col7">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Maturity Date</field>
<field name="field">date_maturity</field>
<field name="sequence" eval="7"/>
</record>
<record model="account.journal.column" id="journal_col8">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Debit</field>
<field name="field">debit</field>
<field name="sequence" eval="8"/>
</record>
<record model="account.journal.column" id="journal_col9">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Credit</field>
<field name="field">credit</field>
<field name="sequence" eval="9"/>
</record>
<record model="account.journal.column" id="journal_col24">
<field name="view_id" ref="account_journal_view"/>
<field name="name">State</field>
<field name="field">state</field>
<field name="sequence" eval="10"/>
</record>
<record model="account.journal.column" id="journal_col25">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Tax Acc.</field>
<field name="field">tax_code_id</field>
<field name="sequence" eval="11"/>
</record>
<record model="account.journal.column" id="journal_col26">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Tax</field>
<field name="field">tax_amount</field>
<field name="sequence" eval="12"/>
</record>
<!--
Account Journal Sequences
-->
<record model="ir.sequence.type" id="sequence_journal_type">
<field name="name">Account Journal</field>
<field name="code">account.journal</field>
</record>
<record model="ir.sequence" id="sequence_journal">
<field name="name">Account Journal</field>
<field name="code">account.journal</field>
<field name="prefix"></field>
</record>
<!--
Account Statement Sequences
-->
<record model="ir.sequence.type" id="sequence_statement_type">
<field name="name">Bank Statement</field>
<field name="code">account.bank.statement</field>
</record>
<record model="ir.sequence" id="sequence_statement">
<field name="name">Account Bank Statement</field>
<field name="code">account.bank.statement</field>
<field name="prefix">St. %(month)s/%(day)s</field>
<field name="number_next" eval="0"/>
<field name="number_increment" eval="0"/>
</record>
<!--
Account Journal
-->
<record model="account.journal" id="sales_journal">
<field name="name">Sales Journal</field>
<field name="code">SAJ</field>
<field name="type">sale</field>
<field name="view_id" ref="account_journal_view"/>
<field name="sequence_id" ref="sequence_journal"/>
<field name="default_credit_account_id" model="account.account" search="[('type','=','receivable')]"/>
<field name="default_debit_account_id" model="account.account" search="[('type','=','receivable')]"/>
</record>
<record model="account.journal" id="expenses_journal">
<field name="name">Expenses Journal</field>
<field name="code">EXJ</field>
<field name="type">purchase</field>
<field name="view_id" ref="account_journal_view"/>
<field name="sequence_id" ref="sequence_journal"/>
<field name="default_debit_account_id" model="account.account" search="[('type','=','payable')]"/>
<field name="default_credit_account_id" model="account.account" search="[('type','=','payable')]"/>
</record>
<record model="account.journal" id="bank_journal">
<field name="name">Bank Journal</field>
<field name="code">BNK</field>
<field name="type">cash</field>
<field name="view_id" ref="account_journal_bank_view"/>
<field name="sequence_id" ref="sequence_journal"/>
<field name="default_debit_account_id" model="account.account" search="[('type','=','cash')]"/>
<field name="default_credit_account_id" model="account.account" search="[('type','=','cash')]"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,76 @@
<?xml version="1.0"?>
<terp>
<data noupdate="1">
<record model="res.request.link" id="req_link_invoice">
<field name="name">Invoice</field>
<field name="object">account.invoice</field>
</record>
<!--
Sequences types for invoices
-->
<record model="ir.sequence.type" id="seq_type_out_invoice">
<field name="name">Account Invoice Out</field>
<field name="code">account.invoice.out_invoice</field>
</record>
<record model="ir.sequence.type" id="seq_type_in_invoice">
<field name="name">Account Invoice In</field>
<field name="code">account.invoice.in_invoice</field>
</record>
<record model="ir.sequence.type" id="seq_type_out_refund">
<field name="name">Account Refund Out</field>
<field name="code">account.invoice.out_refund</field>
</record>
<record model="ir.sequence.type" id="seq_type_in_refund">
<field name="name">Account Refund In</field>
<field name="code">account.invoice.in_refund</field>
</record>
<!--
Sequences for invoices
-->
<record model="ir.sequence" id="seq_out_invoice">
<field name="name">Account Invoice Out</field>
<field name="code">account.invoice.out_invoice</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_in_invoice">
<field name="name">Account Invoice In</field>
<field name="code">account.invoice.in_invoice</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_out_refund">
<field name="name">Account Refund Out</field>
<field name="code">account.invoice.out_refund</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_in_refund">
<field name="name">Account Refund In</field>
<field name="code">account.invoice.in_refund</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<!--
Sequences types for analytic account
-->
<record model="ir.sequence.type">
<field name="name">Analytic account</field>
<field name="code">account.analytic.account</field>
</record>
<!--
Sequence for analytic account
-->
<record model="ir.sequence">
<field name="name">Analytic account sequence</field>
<field name="code">account.analytic.account</field>
<field name="padding" eval="3" />
<field name="number_next" eval="2708" />
</record>
</data>
</terp>

View File

@ -0,0 +1,64 @@
<?xml version="1.0"?>
<terp>
<data noupdate="True">
<!--
Minimal Tiny ERP Account Chart
-->
<record model="account.account" id="a_recv">
<field name="name">Main Receivable</field>
<field name="code">40</field>
<field name="type">receivable</field>
<field name="currency_id" ref="base.EUR"/>
<field name="parent_id" eval="[(6,0,[])]"/>
</record>
<record model="account.account" id="a_pay">
<field name="name">Main Payable</field>
<field name="code">440</field>
<field name="type">payable</field>
<field name="currency_id" ref="base.EUR"/>
<field name="parent_id" eval="[(6,0,[])]"/>
</record>
<record model="account.account" id="cash">
<field name="name">Petty Cash</field>
<field name="code">57</field>
<field name="type">cash</field>
<field name="currency_id" ref="base.EUR"/>
<field name="parent_id" eval="[(6,0,[])]"/>
</record>
<record model="account.account" id="a_expense">
<field name="name">Products Purchase</field>
<field name="code">600</field>
<field name="type">expense</field>
<field name="currency_id" ref="base.EUR"/>
<field name="parent_id" eval="[(6,0,[])]"/>
</record>
<record model="account.account" id="a_sale">
<field name="name">Products Sales</field>
<field name="code">701</field>
<field name="type">income</field>
<field name="currency_id" ref="base.EUR"/>
<field name="parent_id" eval="[(6,0,[])]"/>
</record>
<record model="ir.property" id="property_account_receivable" forcecreate="True">
<field name="name">property_account_receivable</field>
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_account_receivable')]"/>
<field name="value" eval="'account.account,'+str(a_recv)"/>
</record>
<record model="ir.property" id="property_account_payable" forcecreate="True">
<field name="name">property_account_payable</field>
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_account_payable')]"/>
<field name="value" eval="'account.account,'+str(a_pay)"/>
</record>
<record model="ir.property" id="property_account_tax" forcecreate="True">
<field name="name">property_account_tax</field>
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_account_tax')]"/>
<field name="value" eval="False"/>
</record>
</data>
</terp>

665
addons/account/invoice.py Normal file
View File

@ -0,0 +1,665 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import netsvc
from osv import fields, osv
import ir
class account_invoice(osv.osv):
def _amount_untaxed(self, cr, uid, ids, prop, unknow_none,unknow_dict):
id_set=",".join(map(str,ids))
cr.execute("SELECT s.id,COALESCE(SUM(l.price_unit*l.quantity*(100-l.discount))/100.0,0)::decimal(16,2) AS amount FROM account_invoice s LEFT OUTER JOIN account_invoice_line l ON (s.id=l.invoice_id) WHERE s.id IN ("+id_set+") GROUP BY s.id ")
res=dict(cr.fetchall())
return res
def _amount_tax(self, cr, uid, ids, prop, unknow_none,unknow_dict):
id_set=",".join(map(str,ids))
cr.execute("SELECT s.id,COALESCE(SUM(l.amount),0)::decimal(16,2) AS amount FROM account_invoice s LEFT OUTER JOIN account_invoice_tax l ON (s.id=l.invoice_id) WHERE s.id IN ("+id_set+") GROUP BY s.id ")
res=dict(cr.fetchall())
return res
def _amount_total(self, cr, uid, ids, prop, unknow_none,unknow_dict):
untax = self._amount_untaxed(cr, uid, ids, prop, unknow_none,unknow_dict)
tax = self._amount_tax(cr, uid, ids, prop, unknow_none,unknow_dict)
res = {}
for id in ids:
res[id] = untax.get(id,0.0) + tax.get(id,0.0)
return res
def _get_journal(self, cr, uid, context):
type_inv = context.get('type', 'out_invoice')
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
cr.execute("select id from account_journal where type=%s limit 1", (type2journal.get(type_inv, 'sale'),))
return cr.fetchone()[0]
def _get_currency(self, cr, uid, context):
cr.execute("select id from res_currency where rate=1.0")
res = cr.fetchone()
return res and res[0] or False
def _get_journal_analytic(self, cr, uid, type_inv, context={}):
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
tt = type2journal.get(type_inv, 'sale')
cr.execute("select id from account_analytic_journal where type=%s limit 1", (tt,))
result = cr.fetchone()
if not result:
raise osv.except_osv('No Analytic Journal !', "You have to define an analytic journal of type '%s' !" % (tt,))
return result[0]
_name = "account.invoice"
_description = 'Invoice'
_order = "number"
_columns = {
'name': fields.char('Invoice Description', size=64, required=True, select=True),
'origin': fields.char('Origin', size=64),
'type': fields.selection([
('out_invoice','Customer Invoice'),
('in_invoice','Supplier Invoice'),
('out_refund','Customer Refund'),
('in_refund','Supplier Refund'),
],'Type', readonly=True, states={'draft':[('readonly',False)]}, select=True),
'number': fields.char('Invoice Number', size=32, readonly=True),
'reference': fields.char('Invoice Reference', size=64),
'project_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft':[('readonly',False)]}),
'comment': fields.text('Additionnal Information'),
'state': fields.selection([
('draft','Draft'),
('proforma','Pro-forma'),
('open','Open'),
('paid','Paid'),
('cancel','Canceled')
],'State', readonly=True, select=True),
'date_invoice': fields.date('Date Invoiced', required=True, states={'open':[('readonly',True)],'close':[('readonly',True)]}),
'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]}),
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, states={'draft':[('readonly',False)]}, relate=True),
'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}),
'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, states={'draft':[('readonly',False)]}),
'partner_contact': fields.char('Partner Contact', size=64),
'partner_ref': fields.char('Partner Reference', size=64),
'payment_term': fields.many2one('account.payment.term', 'Payment Term'),
'period_id': fields.many2one('account.period', 'Force Period', help="Keep empty to use the period of the validation date."),
'account_id': fields.many2one('account.account', 'Dest Account', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'invoice_line': fields.one2many('account.invoice.line', 'invoice_id', 'Invoice Lines', readonly=True, states={'draft':[('readonly',False)]}),
'tax_line': fields.one2many('account.invoice.tax', 'invoice_id', 'Tax Lines', readonly=True, states={'draft':[('readonly',False)]}),
'move_id': fields.many2one('account.move', 'Invoice Movement', readonly=True),
'amount_untaxed': fields.function(_amount_untaxed, method=True, digits=(16,2),string='Untaxed Amount'),
'amount_tax': fields.function(_amount_tax, method=True, string='Tax'),
'amount_total': fields.function(_amount_total, method=True, string='Total'),
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, relate=True),
}
_defaults = {
'type': lambda *a: 'out_invoice',
'date_invoice': lambda *a: time.strftime('%Y-%m-%d'),
'state': lambda *a: 'draft',
'journal_id': _get_journal,
'currency_id': _get_currency,
}
def unlink(self, cr, uid, ids):
invoices = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for t in invoices:
if t['state'] in ('draft', 'cancel'):
unlink_ids.append(t['id'])
else:
raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !')
osv.osv.unlink(self, cr, uid, unlink_ids)
return True
# def get_invoice_address(self, cr, uid, ids):
# res = self.pool.get('res.partner').address_get(cr, uid, [part], ['invoice'])
# return [{}]
def onchange_partner_id(self, cr, uid, ids, type, partner_id):
invoice_addr_id = False
contact_addr_id = False
acc_id = False
opt = [('uid', str(uid))]
if partner_id:
opt.insert(0, ('id', partner_id))
res = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['contact', 'invoice'])
contact_addr_id = res['contact']
invoice_addr_id = res['invoice']
p = self.pool.get('res.partner').browse(cr, uid, partner_id)
if type in ('out_invoice', 'out_refund'):
acc_id = p.property_account_receivable
else:
acc_id = p.property_account_payable
result = {'value': {'address_contact_id': contact_addr_id, 'address_invoice_id': invoice_addr_id, 'account_id': acc_id}}
if partner_id and p.property_payment_term:
result['value']['payment_term'] = p.property_payment_term
return result
def onchange_currency_id(self, cr, uid, ids, curr_id):
return {}
# go from canceled state to draft state
def action_cancel_draft(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state':'draft'})
wf_service = netsvc.LocalService("workflow")
for inv_id in ids:
wf_service.trg_create(uid, 'account.invoice', inv_id, cr)
return True
# Workflow stuff
#################
# return the id of the first move line which has the same account than the invoice
# whose id is in ids
def move_line_id_payment_get(self, cr, uid, ids, *args):
ml = self.pool.get('account.move.line')
for inv in self.read(cr, uid, ids, ['move_id','account_id']):
if inv['move_id']:
move_line_ids = ml.search(cr, uid, [('move_id', '=', inv['move_id'][0])])
for line in ml.read(cr, uid, move_line_ids, ['account_id']):
if line['account_id']==inv['account_id']:
return [line['id']]
return []
def copy(self, cr, uid, id, default=None, context={}):
if not default: default = {}
default.update({'state':'draft', 'number':False, 'move_id':False})
return super(account_invoice, self).copy(cr, uid, id, default, context)
def test_paid(self, cr, uid, ids, *args):
res = self.move_line_id_payment_get(cr, uid, ids)
if not res:
return False
ok = True
for id in res:
cr.execute('select reconcile_id from account_move_line where id=%d', (id,))
ok = ok and bool(cr.fetchone()[0])
return ok
def button_compute(self, cr, uid, ids, context={}):
for id in ids:
self.pool.get('account.invoice.line').move_line_get(cr, uid, id)
return True
def action_move_create(self, cr, uid, ids, *args):
company_currency = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
id_set = ','.join([str(i) for i in ids])
cr.execute('SELECT * FROM account_invoice WHERE move_id IS NULL AND id IN ('+id_set+')')
for inv in cr.dictfetchall():
# create the analytical lines
line_ids = self.read(cr, uid, [inv['id']], ['invoice_line'])[0]['invoice_line']
ils = self.pool.get('account.invoice.line').read(cr, uid, line_ids)
if inv['type'] in ('out_invoice', 'in_refund'):
sign = 1
else:
sign = -1
# one move line per invoice line
iml = self.pool.get('account.invoice.line').move_line_get(cr, uid, inv['id'])
if inv['project_id']:
for il in iml:
il['analytic_lines'] = [(0,0, {
'name': il['name'],
'date': time.strftime('%Y-%m-%d'),
'account_id': inv['project_id'],
'unit_amount': il['quantity'],
'amount': il['price'] * sign,
#'product_id': il['product_id'] and il['product_id'][0],
#'product_uom_id': il['uos_id'] and il['uos_id'][0],
'general_account_id': il['account_id'],
'journal_id': self._get_journal_analytic(cr, uid, inv['type'])
})]
# one move line per tax line
iml += self.pool.get('account.invoice.tax').move_line_get(cr, uid, inv['id'])
# create one move line for the total and possibly adjust the other lines amount
total = 0
total_currency = 0
for i in iml:
if inv['currency_id'] != company_currency:
i['currency_id'] = inv['currency_id']
i['amount_currency'] = i['price']
i['price'] = round(self.pool.get('res.currency').compute(cr, uid, inv['currency_id'], company_currency, i['price']),2)
else:
i['amount_currency'] = False
i['currency_id'] = False
i['ref'] = inv['number']
if inv['type'] in ('out_invoice','in_refund'):
total += i['price']
total_currency += i['amount_currency'] or i['price']
i['price'] = - i['price']
else:
total -= i['price']
total_currency -= i['amount_currency'] or i['price']
acc_id = inv['account_id']
name = inv['name']
if inv['payment_term']:
totlines = self.pool.get('account.payment.term').compute(cr, uid, inv['payment_term'], total)
for t in totlines:
iml.append({ 'type':'dest', 'name':name, 'price': t[1], 'date_maturity': t[0], 'account_id':acc_id, 'ref': inv['number']})
else:
iml.append({ 'type':'dest', 'name':name, 'price': total, 'account_id':acc_id, 'date_maturity' : inv['date_due'] or False, 'amount_currency': total_currency, 'currency_id': inv['currency_id'], 'ref': inv['number']})
date = inv['date_invoice']
part = inv['partner_id']
line = map(lambda x:(0,0,{
'date':date,
'date_maturity': x.get('date_maturity', False),
'partner_id':part,
'name':x['name'],
'debit':x['price']>0 and x['price'],
'credit':x['price']<0 and -x['price'],
'account_id':x['account_id'],
'analytic_lines':x.get('analytic_lines', []),
'amount_currency':x.get('amount_currency', False),
'currency_id':x.get('currency_id', False),
'tax_code_id': x.get('tax_code_id', False),
'tax_amount': x.get('tax_amount', False),
'ref':x.get('ref',False) }) ,iml)
journal_id = inv['journal_id'] #self._get_journal(cr, uid, {'type': inv['type']})
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
if journal.sequence_id:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
move = {'name': name, 'line_id': line, 'journal_id': journal_id}
if inv['period_id']:
move['period_id'] = inv['period_id']
for i in line:
i[2]['period_id'] = inv['period_id']
move_id = self.pool.get('account.move').create(cr, uid, move)
# make the invoice point to that move
self.write(cr, uid, [inv['id']], {'move_id': move_id})
self._log_event(cr, uid, ids)
return True
def action_number(self, cr, uid, ids, *args):
cr.execute('SELECT id, type, number, move_id FROM account_invoice WHERE id IN ('+','.join(map(str,ids))+')')
for (id, invtype, number, move_id) in cr.fetchall():
if not number:
number = self.pool.get('ir.sequence').get(cr, uid, 'account.invoice.'+invtype)
cr.execute('UPDATE account_invoice SET number=%s WHERE id=%d', (number, id))
cr.execute('UPDATE account_move_line SET ref=%s WHERE move_id=%d and ref is null', (number, move_id))
return True
def action_cancel(self, cr, uid, ids, *args):
invoices = self.read(cr, uid, ids, ['move_id'])
for i in invoices:
if i['move_id']:
# delete the move this invoice was pointing to
# Note that the corresponding move_lines and move_reconciles
# will be automatically deleted too
self.pool.get('account.move').unlink(cr, uid, [i['move_id'][0]])
self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})
self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice')
return True
###################
def list_distinct_taxes(self, cr, uid, ids):
invoices = self.browse(cr, uid, ids)
taxes = {}
for inv in invoices:
for tax in inv.tax_line:
if not tax['name'] in taxes:
taxes[tax['name']] = {'name': tax['name']}
return taxes.values()
def _log_event(self, cr, uid, ids, factor=1.0, name='Open Invoice'):
invs = self.read(cr, uid, ids, ['type','partner_id','amount_untaxed'])
for inv in invs:
part=inv['partner_id'] and inv['partner_id'][0]
pc = pr = 0.0
cr.execute('select sum(quantity*price_unit) from account_invoice_line where invoice_id=%d', (inv['id'],))
total = inv['amount_untaxed']
if inv['type'] in ('in_invoice','in_refund'):
partnertype='supplier'
eventtype = 'purchase'
pc = total*factor
else:
partnertype = 'customer'
eventtype = 'sale'
pr = total*factor
if self.pool.get('res.partner.event.type').check(cr, uid, 'invoice_open'):
self.pool.get('res.partner.event').create(cr, uid, {'name':'Invoice: '+name, 'som':False, 'description':name+' '+str(inv['id']), 'document':name, 'partner_id':part, 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'canal_id':False, 'user_id':uid, 'partner_type':partnertype, 'probability':1.0, 'planned_revenue':pr, 'planned_cost':pc, 'type':eventtype})
return len(invs)
def name_search(self, cr, user, name, args=[], operator='ilike', context={}):
ids = []
if name:
ids = self.search(cr, user, [('number','=',name)]+ args)
if not ids:
ids = self.search(cr, user, [('name',operator,name)]+ args)
return self.name_get(cr, user, ids)
def refund(self, cr, uid, ids):
invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'project_id', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line'])
new_ids = []
for invoice in invoices:
del invoice['id']
type_dict = {
'out_invoice': 'out_refund', # Customer Invoice
'in_invoice': 'in_refund', # Supplier Invoice
'out_refund': 'out_invoice', # Customer Refund
'in_refund': 'in_invoice', # Supplier Refund
}
def cleanup_lines(lines):
for line in lines:
del line['id']
del line['invoice_id']
line['account_id'] = line['account_id'] and line['account_id'][0]
line['product_id'] = line['product_id'] and line['product_id'][0]
line['uos_id'] = line['uos_id'] and line['uos_id'][0]
line['invoice_line_tax_id'] = [(6,0, line.get('invoice_line_tax_id', [])) ]
return map(lambda x: (0,0,x), lines)
invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'])
invoice_lines = cleanup_lines(invoice_lines)
tax_lines = self.pool.get('account.invoice.tax').read(cr, uid, invoice['tax_line'])
tax_lines = filter(lambda l: l['manual'], tax_lines)
tax_lines = cleanup_lines(tax_lines)
invoice.update({
'type': type_dict[invoice['type']],
'date_invoice': time.strftime('%Y-%m-%d'),
'state': 'draft',
'number': False,
'invoice_line': invoice_lines,
'tax_line': tax_lines
})
# take the id part of the tuple returned for many2one fields
for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
'project_id', 'account_id', 'currency_id', 'payment_term'):
invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice
new_ids.append(self.create(cr, uid, invoice))
return new_ids
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context={}):
assert len(ids)==1, "Can only pay one invoice at a time"
invoice = self.browse(cr, uid, ids[0])
src_account_id = invoice.account_id.id
journal = self.pool.get('account.journal').browse(cr, uid, pay_journal_id)
if journal.sequence_id:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv('No piece number !', 'Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')
types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
direction = types[invoice.type]
l1 = {
'name': name,
'debit': direction == 1 and pay_amount,
'credit': direction == -1 and pay_amount,
'account_id': src_account_id,
'partner_id': invoice.partner_id.id
}
l2 = {
'name':name,
'debit': direction == -1 and pay_amount,
'credit': direction == 1 and pay_amount,
'account_id': pay_account_id,
'partner_id': invoice.partner_id.id
}
lines = [(0, 0, l1), (0, 0, l2)]
move = {'name': name, 'line_id': lines, 'journal_id': pay_journal_id}
move_id = self.pool.get('account.move').create(cr, uid, move)
line_ids = []
line = self.pool.get('account.move.line')
cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')')
lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) )
for l in lines:
if l.account_id.id==src_account_id:
line_ids.append(l.id)
self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context)
return True
account_invoice()
class account_invoice_line(osv.osv):
def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict):
res = {}
for line in self.browse(cr, uid, ids):
res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2)
return res
_name = "account.invoice.line"
_description = "Invoice line"
_columns = {
'name': fields.char('Description', size=256, required=True),
'invoice_id': fields.many2one('account.invoice', 'Invoice Ref', ondelete='cascade', select=True),
'uos_id': fields.many2one('product.uom', 'Unit', ondelete='set null'),
'product_id': fields.many2one('product.product', 'Product', ondelete='set null'),
'account_id': fields.many2one('account.account', 'Source Account', required=True, domain=[('type','<>','view')]),
'price_unit': fields.float('Unit Price', required=True),
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal'),
'quantity': fields.float('Quantity', required=True),
'discount': fields.float('Discount (%)', digits=(16,2)),
'invoice_line_tax_id': fields.many2many('account.tax', 'account_invoice_line_tax', 'invoice_line_id', 'tax_id', 'Taxes', domain=[('parent_id','=',False)]),
'note': fields.text('Notes'),
}
_defaults = {
'quantity': lambda *a: 1,
'discount': lambda *a: 0.0
}
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice'):
if not product:
return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}}
res = self.pool.get('product.product').browse(cr, uid, product)
result = {'price_unit': res.list_price, 'invoice_line_tax_id':map(lambda x: x.id, res.taxes_id)}
if not name:
result['name'] = res.name
if type in ('out_invoice','out_refund'):
a = res.product_tmpl_id.property_account_income
if not a:
a = res.categ_id.property_account_income_categ
result['account_id'] = a[0]
else:
a = res.product_tmpl_id.property_account_expense
if not a:
a = res.categ_id.property_account_expense_categ
result['account_id'] = a[0]
domain = {}
if not uom:
result['product_uom'] = res.uom_id.id or False
if result['product_uom']:
res2 = self.pool.get('product.uom').read(cr, uid, [result['product_uom']], ['category_id'])
if res2 and res2[0]['category_id']:
domain = {'product_uom':[('category_id','=',res2[0]['category_id'][0])]}
return {'value':result, 'domain':domain}
def move_line_get(self, cr, uid, invoice_id, context={}):
res = []
tax_grouped = {}
tax_obj = self.pool.get('account.tax')
#TODO: rewrite using browse instead of the manual SQL queries
# cr.execute('SELECT id FROM account_invoice_line WHERE invoice_id=%d', (invoice_id,))
inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
for line in inv.invoice_line:
res.append( {
'type':'src',
'name':line.name,
'price_unit':line.price_unit,
'quantity':line.quantity,
'price':round(line.quantity*line.price_unit * (1.0- (line.discount or 0.0)/100.0),2),
'account_id':line.account_id.id
})
for tax2 in line.invoice_line_tax_id:
for tax in tax_obj.compute(cr, uid, [tax2.id], line.price_unit, line.quantity, inv.address_invoice_id.id):
tax['amount'] = tax['amount']*(1.0- (line['discount'] or 0.0)/100.0)
tax['sequence'] = tax2.sequence
#
# Setting the tax account and amount for the line
#
if inv.type in ('out_invoice','out_refund'):
res[-1]['tax_code_id'] = tax2.base_code_id.id
res[-1]['tax_amount'] = line['price_unit'] * line['quantity'] * (1.0- (line['discount'] or 0.0)/100.0) * tax2.base_sign
else:
res[-1]['tax_code_id'] = tax2.ref_base_code_id.id
res[-1]['tax_amount'] = line['price_unit'] * line['quantity'] * (1.0- (line['discount'] or 0.0)/100.0) * tax2.ref_base_sign
if inv.type in ('out_refund','in_refund'):
res[-1]['tax_amount'] = -res[-1]['tax_amount']
if inv.type in ('out_invoice','out_refund'):
tax['account_id'] = tax['account_collected_id'] or line.account_id.id
else:
tax['account_id'] = tax['account_paid_id'] or line.account_id.id
#
# Revoir la clé: tax.id ?
#
key = (res[-1]['tax_code_id'], tax['account_id'])
if not key in tax_grouped:
tax_grouped[key] = tax
tax_grouped[key]['base'] = line['price_unit'] * line['quantity'] * (1.0- (line['discount'] or 0.0)/100.0)
else:
tax_grouped[key]['amount'] += tax['amount']
tax_grouped[key]['base'] += line['price_unit'] * line['quantity'] * (1.0- (line['discount'] or 0.0)/100.0)
# delete automatic tax lines for this invoice
cr.execute("DELETE FROM account_invoice_tax WHERE NOT manual AND invoice_id=%d", (invoice_id,))
self.move_line_tax_create(cr, uid, inv, tax_grouped, context)
return res
def move_line_tax_create(self, cr, uid, inv, tax_grouped, context={}):
# (re)create them
ait = self.pool.get('account.invoice.tax')
for t in tax_grouped.values():
tax = self.pool.get('account.tax').browse(cr, uid, t['id'])
val = {
'invoice_id':inv.id,
'name':t['name'],
'account_id':t['account_id'],
'amount':t['amount'],
'manual':False,
'sequence':t['sequence'],
'base': t['base'],
}
if inv.type in ('out_invoice','out_refund'):
val.update({
'base_code_id': tax.base_code_id.id or False,
'tax_code_id': tax.tax_code_id.id or False,
'base_amount': tax.base_sign * t['base'],
'tax_amount': tax.tax_sign * t['amount']
})
elif inv.type in ('in_invoice','in_refund'):
val.update({
'base_code_id': tax.ref_base_code_id.id or False,
'tax_code_id': tax.ref_tax_code_id.id or False,
'base_amount': tax.ref_base_sign * t['base'],
'tax_amount': tax.ref_tax_sign * t['amount']
})
if inv.type in ('out_refund','in_refund'):
val.update({
'base_amount': -val['base_amount'],
'tax_amount': -val['tax_amount']
})
ait.create(cr, uid, val)
#ait.create(cr, uid, {'invoice_id':invoice_id, 'name':t['name'], 'account_id':t['account_id'], 'amount':t['amount'], 'manual':False, 'sequence':t['sequence'], 'base':t['base']})
return True
#
# Set the tax field according to the account and the partner
#
def onchange_account_id(self, cr, uid, ids, partner_id,account_id):
if not (partner_id and account_id):
return {}
taxes = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids
taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax
if not taxep:
return {'value': {'invoice_line_tax_id': map(lambda x: x.id, taxes or []) }}
res = [taxep[0]]
tp = self.pool.get('account.tax').browse(cr, uid, taxep[0])
for t in taxes:
if not t.tax_group==tp.tax_group:
res.append(t.id)
r = {'value':{'invoice_line_tax_id': res}}
return r
account_invoice_line()
class account_invoice_tax(osv.osv):
_name = "account.invoice.tax"
_description = "Invoice Tax"
_columns = {
'invoice_id': fields.many2one('account.invoice', 'Invoice Line', ondelete='cascade', select=True),
'name': fields.char('Tax Description', size=64, required=True),
'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type','<>','view'),('type','<>','income')]),
'base': fields.float('Base', digits=(16,2)),
'amount': fields.float('Amount', digits=(16,2)),
'manual': fields.boolean('Manual'),
'sequence': fields.integer('Sequence'),
'base_code_id': fields.many2one('account.tax.code', 'Base Code'),
'base_amount': fields.float('Base Code Amount', digits=(16,2)),
'tax_code_id': fields.many2one('account.tax.code', 'Tax Code'),
'tax_amount': fields.float('Tax Code Amount', digits=(16,2)),
}
_order = 'sequence'
_defaults = {
'manual': lambda *a: 1,
'base_amount': lambda *a: 0.0,
'tax_amount': lambda *a: 0.0,
}
def move_line_get(self, cr, uid, invoice_id):
res = []
cr.execute('SELECT * FROM account_invoice_tax WHERE invoice_id=%d', (invoice_id,))
for t in cr.dictfetchall():
res.append({
'type':'tax',
'name':t['name'],
'price_unit': t['amount'],
'quantity': 1,
'price': t['amount'] or 0.0,
'account_id': t['account_id'],
'tax_code_id': t['tax_code_id'],
'tax_amount': t['tax_amount']
})
return res
account_invoice_tax()

128
addons/account/partner.py Normal file
View File

@ -0,0 +1,128 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from osv import fields, osv
import ir
class res_partner(osv.osv):
_name = 'res.partner'
_inherit = 'res.partner'
_description = 'Partner'
def _credit_get(self, cr, uid, ids, prop, unknow_none, context):
res={}
try:
for partner in self.browse(cr, uid, ids, context):
id = partner.id
acc = partner.property_account_receivable[0]
cr.execute("select sum(debit-credit) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (acc, id))
res[id]=cr.fetchone()[0] or 0.0
except:
for id in ids:
res[id]=0.0
return res
def _debit_get(self, cr, uid, ids, prop, unknow_none, unknow_dict):
res={}
try:
for partner in self.browse(cr, uid, ids, context):
id = partner.id
acc = partner.property_account_payable[0]
cr.execute("select sum(debit-credit) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (acc, id))
res[id]=cr.fetchone()[0] or 0.0
except:
for id in ids:
res[id]=0.0
return res
def _credit_search(self, cr, uid, obj, name, args):
if not len(args):
return []
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
cr.execute('select partner_id from account_move_line where account_id in (select id from account_account where type=%s) and reconcile_id is null and state<>\'draft\' group by partner_id having '+where, ('receivable',) )
res = cr.fetchall()
if not len(res):
return [('id','=','0')]
return [('id','in',map(lambda x:x[0], res))]
def _debit_search(self, cr, uid, obj, name, args):
if not len(args):
return []
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
cr.execute('select partner_id from account_move_line where account_id in (select id from account_account where type=%s) and reconcile_id is null and state<>\'draft\' group by partner_id having '+where, ('payable',) )
res = cr.fetchall()
if not len(res):
return [('id','=','0')]
return [('id','in',map(lambda x:x[0], res))]
_columns = {
'credit': fields.function(_credit_get, fnct_search=_credit_search, method=True, string='Receivable'),
'debit': fields.function(_debit_get, fnct_search=_debit_search, method=True, string='Payable'),
'debit_limit': fields.float('Debit Limit'),
'credit_limit': fields.float('Credit Limit'),
'property_account_payable': fields.property(
'account.account',
type='many2one',
relation='account.account',
string="Account Payable",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, as the payable account for the current partner"),
'property_account_receivable': fields.property(
'account.account',
type='many2one',
relation='account.account',
string="Account Receivable",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, as the receivable account for the current partner"),
'property_account_tax': fields.property(
'account.tax',
type='many2one',
relation='account.tax',
string="Default Tax",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This tax will be used, instead of the default one."),
'property_payment_term': fields.property(
'account.payment.term',
type='many2one',
relation='account.payment.term',
string ='Payment Term',
method=True,
view_load=True,
group_name="Accounting Properties",
help="This payment term will be used, instead of the default one, for the current partner"),
}
res_partner()

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<terp>
<data>
<!--
Partners Extension
-->
<record model="ir.ui.view" id="view_partner_form">
<field name="name">res.partner.form.inherit</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="credit_limit" position="after">
<newline/>
<field name="credit" select="1"/>
<field name="debit" select="1"/>
</field>
</field>
</record>
</data>
</terp>

85
addons/account/product.py Normal file
View File

@ -0,0 +1,85 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import netsvc
from osv import fields, osv
class product_category(osv.osv):
_inherit = "product.category"
_columns = {
'property_account_income_categ': fields.property(
'account.account',
type='many2one',
relation='account.account',
string="Income Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value incoming stock for the current product category"),
'property_account_expense_categ': fields.property(
'account.account',
type='many2one',
relation='account.account',
string="Expense Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value outgoing stock for the current product category"),
}
product_category()
#----------------------------------------------------------
# Products
#----------------------------------------------------------
class product_template(osv.osv):
_inherit = "product.template"
_columns = {
'taxes_id': fields.many2many('account.tax', 'product_taxes_rel', 'prod_id', 'tax_id', 'Product Taxes', domain=[('parent_id','=',False)]),
'property_account_income': fields.property(
'account.account',
type='many2one',
relation='account.account',
string="Income Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value incoming stock for the current product"),
'property_account_expense': fields.property(
'account.account',
type='many2one',
relation='account.account',
string="Expense Account",
method=True,
view_load=True,
group_name="Accounting Properties",
help="This account will be used, instead of the default one, to value outgoing stock for the current product"),
}
product_template()

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<terp>
<data>
<!--
Product income and expense accounts, default parameters
-->
<record model="ir.property" id="property_account_expense_prd">
<field name="name">property_account_expense</field>
<field name="fields_id" search="[('model','=','product.template'),('name','=','property_account_expense')]"/>
<field name="value" eval="False"/>
</record>
<record model="ir.property" id="property_account_income_prd">
<field name="name">property_account_income</field>
<field name="fields_id" search="[('model','=','product.template'),('name','=','property_account_income')]"/>
<field name="value" eval="False"/>
</record>
<record model="ir.property" id="property_account_expense_categ">
<field name="name">property_account_expense_categ</field>
<field name="fields_id" search="[('model','=','product.category'),('name','=','property_account_expense_categ')]"/>
<field name="value" eval="'account.account,'+str(ref('account.a_expense'))"/>
</record>
<record model="ir.property" id="property_account_income_categ">
<field name="name">property_account_income_categ</field>
<field name="fields_id" search="[('model','=','product.category'),('name','=','property_account_income_categ')]"/>
<field name="value" eval="'account.account,'+str(ref('account.a_sale'))" model="account.account"/>
</record>
</data>
</terp>

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="ir.ui.view" id="product_normal_form_view">
<field name="name">product.normal.form.inherit</field>
<field name="model">product.product</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="product_manager" position="after">
<newline/>
<field name="taxes_id" colspan="3"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="product_template_form_view">
<field name="name">product.template.product.form.inherit</field>
<field name="model">product.template</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<field name="cost_method" position="after">
<newline/>
<field name="taxes_id" colspan="3"/>
</field>
</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,32 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import project
import report
import wizard

View File

@ -0,0 +1,278 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import operator
from osv import fields
from osv import osv
#
# Model definition
#
class account_analytic_account(osv.osv):
_name = 'account.analytic.account'
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
for account in self.browse(cr, uid, ids):
node_balance = reduce(operator.add, [-line.amount for line in account.line_ids if line.amount<0], 0)
child_balance = reduce(operator.add, [child.credit for child in account.child_ids], 0)
res[account.id] = node_balance + child_balance
for id in ids:
res[id] = round(res.get(id, 0.0),2)
return res
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
for account in self.browse(cr, uid, ids):
node_balance = reduce(operator.add, [line.amount for line in account.line_ids if line.amount>0], 0)
child_balance = reduce(operator.add, [child.debit for child in account.child_ids], 0)
res[account.id] = node_balance + child_balance
for id in ids:
res[id] = round(res.get(id, 0.0),2)
return res
def _balance_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
for account in self.browse(cr, uid, ids):
node_balance = reduce(operator.add, [line.amount for line in account.line_ids], 0)
child_balance = reduce(operator.add, [child.balance for child in account.child_ids], 0)
res[account.id] = node_balance + child_balance
for id in ids:
res[id] = round(res.get(id, 0.0),2)
return res
def _quantity_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
for account in self.browse(cr, uid, ids):
node_balance = reduce(operator.add, [line.unit_amount for line in account.line_ids], 0)
child_balance = reduce(operator.add, [child.quantity for child in account.child_ids], 0)
res[account.id] = node_balance + child_balance
for id in ids:
res[id] = round(res.get(id, 0.0),2)
return res
def name_get(self, cr, uid, ids, context={}):
if not len(ids):
return []
reads = self.read(cr, uid, ids, ['name','parent_id'], context)
res = []
for record in reads:
name = record['name']
if record['parent_id']:
name = record['parent_id'][1]+' / '+name
res.append((record['id'], name))
return res
def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
res = self.name_get(cr, uid, ids)
return dict(res)
_columns = {
'name' : fields.char('Account name', size=64, required=True),
'complete_name': fields.function(_complete_name_calc, method=True, type='char', string='Account Name'),
'code' : fields.char('Account code', size=8),
'active' : fields.boolean('Active'),
'type': fields.selection([('view','View'), ('normal','Normal')], 'type'),
'description' : fields.text('Description'),
'parent_id': fields.many2one('account.analytic.account', 'Parent Cost account', select=True),
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Childs Accounts'),
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic entries'),
'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance'),
'debit' : fields.function(_debit_calc, method=True, type='float', string='Balance'),
'credit' : fields.function(_credit_calc, method=True, type='float', string='Balance'),
'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'),
'quantity_max': fields.float('Maximal quantity'),
'partner_id' : fields.many2one('res.partner', 'Associated partner'),
'contact_id' : fields.many2one('res.partner.address', 'Contact'),
'date_start': fields.date('Date Start'),
'date': fields.date('Date End'),
'stats_ids': fields.one2many('report.hr.timesheet.invoice.journal', 'account_id', string='Statistics', readonly=True),
}
_defaults = {
'active' : lambda *a : True,
'type' : lambda *a : 'normal',
}
_order = 'parent_id desc,code'
def create(self, cr, uid, vals, ctx={}):
parent_id = vals.get('parent_id', 0)
if ('code' not in vals or not vals['code']) and not parent_id:
vals['code'] = self.pool.get('ir.sequence').get(cr, uid, 'account.analytic.account')
elif parent_id:
parent = self.read(cr, uid, [parent_id], ['parent_id'])[0]
childs = self.search(cr, uid, [('parent_id', '=', parent_id), ('active', '=', 1)]) + self.search(cr, uid, [('parent_id', '=', parent_id), ('active', '=', 0)])
vals['code'] = '%03d' % (len(childs) + 1,)
return super(account_analytic_account, self).create(cr, uid, vals, ctx)
def on_change_parent(self, cr, uid, id, parent_id):
if not parent_id:
return {'value': {'code': False, 'partner_id': ''}}
parent = self.read(cr, uid, [parent_id], ['partner_id'])[0]
childs = self.search(cr, uid, [('parent_id', '=', parent_id), ('active', '=', 1)]) + self.search(cr, uid, [('parent_id', '=', parent_id), ('active', '=', 0)])
numchild = len(childs)
if parent['partner_id']:
partner = parent['partner_id'][0]
else:
partner = False
return {'value' : {'code' : '%03d' % (numchild + 1,), 'partner_id' : partner}}
def name_search(self, cr, uid, name, args=[], operator='ilike', context={}):
codes = name.split('.')
codes.reverse()
parent_code = False
while codes:
current_code = codes.pop()
account = self.search(cr, uid, [('parent_id', '=', parent_code), ('code', '=', current_code)]+args)
if account:
parent_code = account[0]
else:
account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args)
break
return self.name_get(cr, uid, account)
account_analytic_account()
class account_analytic_journal(osv.osv):
_name = 'account.analytic.journal'
_columns = {
'name' : fields.char('Journal name', size=64, required=True),
'code' : fields.char('Journal code', size=8),
'active' : fields.boolean('Active'),
'type': fields.selection([('sale','Sale'), ('purchase','Purchase'), ('cash','Cash'), ('general','General'), ('situation','Situation')], 'Type', size=32, required=True, help="Gives the type of the analytic journal. When a document (eg: an invoice) needs to create analytic entries, Tiny ERP will look for a matching journal of the same type."),
'line_ids' : fields.one2many('account.analytic.line', 'journal_id', 'Lines'),
}
_defaults = {
'active': lambda *a: True,
'type': lambda *a: 'general',
}
account_analytic_journal()
class account_analytic_line(osv.osv):
_name = 'account.analytic.line'
_columns = {
'name' : fields.char('Description', size=128, required=True),
'date' : fields.date('Date', required=True),
'amount' : fields.float('Amount', required=True),
'unit_amount' : fields.float('Quantity'),
'product_uom_id' : fields.many2one('product.uom', 'UoM'),
'product_id' : fields.many2one('product.product', 'Product'),
'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
'general_account_id' : fields.many2one('account.account', 'General account', required=True, ondelete='cascade'),
'move_id' : fields.many2one('account.move.line', 'General entry', ondelete='cascade', select=True),
'journal_id' : fields.many2one('account.analytic.journal', 'Analytic journal', required=True, ondelete='cascade', select=True),
'code' : fields.char('Code', size=8),
'user_id' : fields.many2one('res.users', 'User',),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),
}
_order = 'date'
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, unit=False, context={}):
if unit_amount and prod_id:
rate = 1
if unit:
uom_id = self.pool.get('product.uom')
hunit = uom_id.browse(cr, uid, unit)
rate = hunit.factor
uom_id = self.pool.get('product.product')
prod = uom_id.browse(cr, uid, prod_id)
a = prod.product_tmpl_id.property_account_expense
if not a:
a = prod.categ_id.property_account_expense_categ
return {'value' : {'amount' : -round(unit_amount * prod.standard_price * rate,2), 'general_account_id':a[0]}}
return {}
account_analytic_line()
class timesheet_invoice(osv.osv):
_name = "report.hr.timesheet.invoice.journal"
_description = "Analytic account costs and revenues"
_auto = False
_columns = {
'name': fields.date('Month', readonly=True),
'account_id':fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, relate=True, select=True),
'journal_id': fields.many2one('account.analytic.journal', 'Journal', readonly=True),
'quantity': fields.float('Quantities', readonly=True),
'cost': fields.float('Credit', readonly=True),
'revenue': fields.float('Debit', readonly=True)
}
_order = 'name desc, account_id'
def init(self, cr):
#cr.execute("""
#create or replace view report_hr_timesheet_invoice_journal as (
# select
# min(l.id) as id,
# substring(l.create_date for 7)||'-01' as name,
# sum(greatest(-l.amount,0)) as cost,
# sum(greatest(l.amount,0)) as revenue,
# sum(l.unit_amount*u.factor) as quantity,
# journal_id,
# account_id
# from account_analytic_line l
# left join product_uom u on (u.id=l.product_uom_id)
# group by
# substring(l.create_date for 7),
# journal_id,
# account_id
#)""")
cr.execute("""
create or replace view report_hr_timesheet_invoice_journal as (
select
min(l.id) as id,
substring(l.create_date for 7)||'-01' as name,
sum(
CASE WHEN -l.amount>0 THEN 0 ELSE -l.amount
END
) as cost,
sum(
CASE WHEN l.amount>0 THEN l.amount ELSE 0
END
) as revenue,
sum(l.unit_amount*u.factor) as quantity,
journal_id,
account_id
from account_analytic_line l
left join product_uom u on (u.id=l.product_uom_id)
group by
substring(l.create_date for 7),
journal_id,
account_id
)""")
timesheet_invoice()

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<terp>
<data noupdate="1">
<record model="account.analytic.journal" id="cose_journal_sale">
<field name="code">SAL</field>
<field name="name">Sales</field>
<field name="type">sale</field>
</record>
<record model="account.analytic.journal" id="exp">
<field name="code">PUR</field>
<field name="name">Purchases</field>
<field name="type">purchase</field>
</record>
<record model="account.analytic.journal" id="sit">
<field name="code">START</field>
<field name="name">Starting Balance</field>
<field name="type">situation</field>
</record>
</data>
</terp>

View File

@ -0,0 +1,106 @@
<?xml version="1.0"?>
<terp>
<data>
<report
id="analytic_journal_print"
string="Analytic Journal"
model="account.analytic.journal"
name="account.analytic.account.journal"
rml="account/project/report/analytic_journal.rml"
auto="False"
menu="False"/>
<wizard
id="account_analytic_account_journal_report"
string="Analytic Journal"
model="account.analytic.journal"
name="account.analytic.account.journal.report"
keyword="client_print_multi"/>
<report
id="account_analytic_account_balance"
string="Analytic Balance"
model="account.analytic.account"
name="account.analytic.account.balance"
rml="account/project/report/analytic_balance.rml"
auto="False"
menu="False"/>
<wizard
id="account_analytic_account_balance_report"
string="Analytic Balance"
model="account.analytic.account"
name="account.analytic.account.balance.report"
keyword="client_print_multi"/>
<report
id="account_analytic_account_inverted_balance"
string="Inverted Analytic Balance"
model="account.analytic.account"
name="account.analytic.account.inverted.balance"
rml="account/project/report/inverted_analytic_balance.rml"
auto="False"
menu="False"/>
<wizard
id="account_analytic_account_inverted_balance_report"
string="Inverted Analytic Balance"
model="account.analytic.account"
name="account.analytic.account.inverted.balance.report"
keyword="client_print_multi"/>
<report
id="account_analytic_account_cost_ledger"
string="Cost Ledger"
model="account.analytic.account"
name="account.analytic.account.cost_ledger"
rml="account/project/report/cost_ledger.rml"
auto="False"
menu="False"/>
<wizard
id="account_analytic_account_cost_ledger_report"
string="Cost Ledger"
model="account.analytic.account"
name="account.analytic.account.cost_ledger.report"
keyword="client_print_multi"/>
<report
id="account_analytic_account_quantity_cost_ledger"
string="Cost Ledger (Only quantities)"
model="account.analytic.account"
name="account.analytic.account.quantity_cost_ledger"
rml="account/project/report/quantity_cost_ledger.rml"
auto="False"
menu="False"/>
<wizard
id="account_analytic_account_quantity_cost_ledger_report"
string="Cost Ledger (Only quantities)"
model="account.analytic.account"
name="account.analytic.account.quantity_cost_ledger.report"
keyword="client_print_multi"/>
<report
id="account_analytic_account_year_to_date_check"
string="Year to Date Check"
model="account.analytic.account"
name="account.analytic.account.year.to.date.check"
rml="account/project/report/year_to_date_check.rml"
auto="False"
menu="False"/>
<wizard
id="account_analytic_account_year_to_date_report"
string="Year to Date Check"
model="account.analytic.account"
name="account.analytic.account.year_to_date_check.report"
keyword="client_print_multi"/>
</data>
</terp>

View File

@ -0,0 +1,306 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="ir.ui.view" id="view_account_analytic_account_list">
<field name="name">account.analytic.account.list</field>
<field name="model">account.analytic.account</field>
<field name="type">tree</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<tree string="Analytic Account" colors="red:date and (date&lt;=current_date); red:quantity_max and (quantity_max&gt;quantity)">
<!--<tree string="Analytic Account" colors="red:date and (date&lt;=current_date)">-->
<field name="code" />
<field name="complete_name"/>
<field name="partner_id" />
<field name="quantity" />
<field name="quantity_max" />
<field name="date" />
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_account_analytic_account_tree">
<field name="name">account.analytic.account.tree</field>
<field name="model">account.analytic.account</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree string="Analytic Account" colors="red:date and (date&lt;=current_date); red:quantity_max and (quantity_max&gt;quantity)">
<!--<tree string="Analytic Account" colors="red:date and (date&lt;=current_date) or quantity_max and (quantity_max&gt;quantity)">-->
<field name="name"/>
<field name="code"/>
<field name="partner_id" />
<field name="date" />
<field name="balance" />
<field name="quantity" />
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_account_analytic_account_form">
<field name="name">account.analytic.account.form</field>
<field name="model">account.analytic.account</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic Account">
<notebook>
<page string="Account Data">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="parent_id" on_change="on_change_parent(parent_id)" />
<field name="type" select="1" />
<field name="partner_id" select="1" />
<newline/>
<field name="date_start" />
<field name="date" select="1" />
<newline/>
<field name="quantity_max" />
<separator string="Note" colspan="4" />
<field name="description" colspan="4" nolabel="1" />
</page>
<page string="Statistics">
<field name="stats_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_analytic_account_form">
<field name="name">account.analytic.account</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_id" ref="view_account_analytic_account_form"/>
</record>
<menuitem name="Financial Management/Configuration/Analytic Accounts/Accounts Definition" id="account_analytic_def_account"
action="action_account_analytic_account_form"/>
<record model="ir.actions.act_window" id="action_account_analytic_account_tree2">
<field name="name">account.analytic.account</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.analytic.account</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_account_analytic_account_tree"/>
</record>
<menuitem name="Financial Management/Configuration/Analytic Accounts/Analytic Accounts Charts" id="account_analytic_def_chart"
action="action_account_analytic_account_tree2"/>
<menuitem name="Financial Management/Charts/Analytic Accounts Charts" id="account_analytic_chart"
action="action_account_analytic_account_tree2"/>
<menuitem name="Financial Management/Reporting/Analytic/Analytic Balance" id="account_analytic_chart_balance"
action="action_account_analytic_account_tree2"/>
<record model="ir.ui.view" id="view_account_analytic_line_form">
<field name="name">account.analytic.line.form</field>
<field name="model">account.analytic.line</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic Entry">
<field name="name" select="1" colspan="3"/>
<field name="amount" select="1"/>
<field name="date" select="1"/>
<field name="account_id" select="1"/>
<field name="journal_id" select="1"/>
<field name="general_account_id" select="1"/>
<field name="move_id" select="1"/>
<field name="unit_amount" select="1"/>
<newline/>
<field name="product_id" select="1"/>
<field name="product_uom_id" select="1"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_account_analytic_line_tree">
<field name="name">account.analytic.line.tree</field>
<field name="model">account.analytic.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Entries" editable="top">
<field name="date"/>
<field name="name" />
<field name="unit_amount" />
<field name="amount" />
<field name="account_id" domain="[('type','=','normal')]"/>
<field name="general_account_id"/>
<field name="journal_id"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_analytic_line_form">
<field name="name">action.account.analytic.line.form</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>
<menuitem name="Financial Management/Entries/Analytic account/Entries" id="account_entries_analytic_entries" action="action_account_analytic_line_form" />
<record model="ir.actions.act_window" id="action_account_tree1">
<field name="name">account.account.tree1</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','=', active_id)]</field>
</record>
<record model="ir.values" id="ir_open_account_analytic_account">
<field name="key2" eval="'tree_but_open'"/>
<field name="model" eval="'account.analytic.account'"/>
<field name="name">Open Account Tree</field>
<field name="value" eval="'ir.actions.act_window,%d'%action_account_tree1"/>
<field name="object" eval="True"/>
</record>
<record model="ir.ui.view" id="account_analytic_line_extended_form">
<field name="name">account.analytic.line.extended_form</field>
<field name="model">account.analytic.line</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Project line">
<field name="name" />
<field name="account_id" />
<field name="account_id" />
<field name="date" />
<field name="journal_id" />
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" />
<field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" />
<field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)" />
<field name="amount" colspan="3" />
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_analytic_account_line_extended_form">
<field name="name">account.analytic.line.form_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="account_analytic_line_extended_form" />
</record>
#
# Analytic Journal
#
<record model="ir.ui.view" id="view_account_analytic_journal_tree">
<field name="name">account.analytic.journal.tree</field>
<field name="model">account.analytic.journal</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Journal">
<field name="code"/>
<field name="name"/>
<field name="type"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_account_analytic_journal_form">
<field name="name">account.analytic.journal.form</field>
<field name="model">account.analytic.journal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Analytic Journal">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="type" select="1" />
<field name="active" select="1" />
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_analytic_journal_form">
<field name="name">account.analytic.journal.form</field>
<field name="res_model">account.analytic.journal</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Financial Management/Configuration/Journal/Analytic Journal Definition" id="account_def_analytic_journal"
action="action_account_analytic_journal_form"/>
#
# Open journal entries
#
<record model="ir.actions.act_window" id="action_account_analytic_journal_open_form">
<field name="name">account.analytic.line.form</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">[('journal_id','=',active_id)]</field>
</record>
<record model="ir.values" id="ir_open_account_journal_analytic">
<field name="key2" eval="'tree_but_open'"/>
<field name="model" eval="'account.analytic.journal'"/>
<field name="name">Open Analytic Journal</field>
<field name="value" eval="'ir.actions.act_window,%d'%action_account_analytic_journal_open_form"/>
<field name="object" eval="True"/>
</record>
#
# Reporting
#
<record model="ir.actions.act_window" id="action_account_analytic_journal_tree">
<field name="name">account.analytic.journal.tree</field>
<field name="res_model">account.analytic.journal</field>
<field name="view_type">tree</field>
</record>
<menuitem name="Financial Management/Reporting/Analytic/Print analytic journals"
id="account_analytic_journal_print"
action="action_account_analytic_journal_tree"/>
<record model="ir.actions.act_window" id="action_account_analytic_journal_tree2">
<field name="name">account.analytic.journal.tree</field>
<field name="res_model">account.analytic.journal</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_account_analytic_journal_tree"/>
</record>
<menuitem name="Financial Management/Entries/Analytic account/Journal Entries"
id="account_analytic_journal_entries"
action="action_account_analytic_journal_tree2"/>
#
# Statistics
#
<record model="ir.ui.view" id="report_hr_timesheet_invoice_journal_form">
<field name="name">report.hr.timesheet.invoice.journal.form</field>
<field name="model">report.hr.timesheet.invoice.journal</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Analytic Entries Stats">
<field name="name"/>
<field name="account_id"/>
<field name="journal_id"/>
<field name="quantity"/>
<field name="revenue"/>
<field name="cost"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="report_account_analytic_journal_tree">
<field name="name">report.hr.timesheet.invoice.journal</field>
<field name="res_model">report.hr.timesheet.invoice.journal</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
<menuitem name="Financial Management/Reporting/Analytic/All Months/Account Cost and Revenue by journal"
id="report_account_analytic_journal_print"
action="report_account_analytic_journal_tree"/>
<record model="ir.actions.act_window" id="report_account_analytic_journal_tree_month">
<field name="name">report.hr.timesheet.invoice.journal</field>
<field name="res_model">report.hr.timesheet.invoice.journal</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
</record>
<menuitem name="Financial Management/Reporting/Analytic/This Month/Account Cost and Revenue by journal"
id="report_account_analytic_journal_print_month"
action="report_account_analytic_journal_tree_month"/>
</data>
</terp>

View File

@ -0,0 +1,35 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import analytic_journal
import analytic_balance
import inverted_analytic_balance
import cost_ledger
import quantity_cost_ledger
import year_to_date_check

View File

@ -0,0 +1,53 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from report import report_sxw
#
# Use period and Journal for selection or resources
#
class journal_print(report_sxw.rml_parse):
def lines(self, journal_id, *args):
self.cr.execute('select id from account_analytic_line where journal_id=%d order by date,id', (journal_id,))
ids = map(lambda x: x[0], self.cr.fetchall())
res = self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids)
return res
def _sum_lines(self, journal_id):
self.cr.execute('select sum(amount) from account_analytic_line where journal_id=%d', (journal_id,))
return self.cr.fetchone()[0] or 0.0
def __init__(self, cr, uid, name, context):
super(journal_print, self).__init__(cr, uid, name, context)
self.localcontext = {
'time': time,
'lines': self.lines,
'sum_lines': self._sum_lines,
}
report_sxw.report_sxw('report.account.analytic.journal.print', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=journal_print)

View File

@ -0,0 +1,115 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting FROM its eventual inadequacies AND bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees AND support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it AND/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from 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)
self.localcontext.update( {
'time': time,
'lines_g': self._lines_g,
'move_sum_debit': self._move_sum_debit,
'move_sum_credit': self._move_sum_credit,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'sum_balance': self._sum_balance,
'sum_quantity': self._sum_quantity,
'move_sum_balance': self._move_sum_balance,
'move_sum_quantity': self._move_sum_quantity,
})
def _lines_g(self, account_id, date1, date2):
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=%d) AND (date>=%s) AND (date<=%s) \
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code ORDER BY aal.code", (account_id, date1, date2))
res = self.cr.dictfetchall()
for r in res:
if r['balance'] > 0:
r['debit'] = '%.2f' % r['balance']
r['credit'] = ''
elif r['balance'] < 0:
r['debit'] = ''
r['credit'] = '%.2f' % -r['balance']
else:
r['balance'] == 0
r['debit'] = ''
r['credit'] = ''
return res
def _move_sum_debit(self, account_id, date1, date2):
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2))
return self.cr.fetchone()[0] or 0.0
def _move_sum_credit(self, account_id, date1, date2):
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2))
return self.cr.fetchone()[0] or 0.0
def _move_sum_balance(self, account_id, date1, date2):
debit = self._move_sum_debit(account_id, date1, date2)
credit = self._move_sum_credit(account_id, date1, date2)
return (debit-credit) or 0.0
def _move_sum_quantity(self, account_id, date1, date2):
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s", (account_id, date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):
debit = self._sum_debit(accounts, date1, date2) or 0.0
credit = self._sum_credit(accounts, date1, date2) or 0.0
return (debit-credit)
def _sum_quantity(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.analytic.account.balance', 'account.analytic.account', 'addons/account/project/report/analytic_balance.rml',parser=account_analytic_balance)

View File

@ -0,0 +1,212 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau8">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau10">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P3" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Times-Roman"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P7" fontName="Times-Bold" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="6.0" leading="8"/>
<paraStyle name="P9" fontName="Times-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P12" fontName="Times-Italic" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Times-Italic" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P14" fontName="Times-Italic" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="6.0" leading="8"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="161.0,161.0,161.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P1">[[ company.name ]]</para>
</td>
<td>
<para style="P2">Analytic Balance</para>
</td>
<td>
<para style="P3">Period from [[ data['form']['date1'] ]]</para>
<para style="P3">to [[ data['form']['date2'] ]]</para>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P6">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="57.0,227.0,99.0,50.0,49.0" style="Tableau8">
<tr>
<td>
<para style="P7">Code</para>
</td>
<td>
<para style="P7">Account Name</para>
</td>
<td>
<para style="P7">Moves</para>
<para style="P7">Débit Crédit</para>
</td>
<td>
<para style="P7">Balance</para>
</td>
<td>
<para style="P7">Quantity</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P8">[[ repeatIn(objects,'o') ]]</para>
<blockTable colWidths="57.0,227.0,50.0,50.0,49.0,50.0" style="Tableau2">
<tr>
<td>
<para style="P9">[[ o.code ]]</para>
</td>
<td>
<para style="P9">[[ o.complete_name ]]</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P10">[[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]]</para>
<para style="P10">[[ move_g['code'] ]]</para>
</td>
<td>
<para style="P10">[[ move_g['name'] ]]</para>
</td>
<td>
<para style="P11">[[ move_g['debit'] ]]</para>
</td>
<td>
<para style="P11">[[ move_g['credit'] ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % move_g['balance'] ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % (move_g['quantity'] or 0.0) ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P12">Total [[ o.code ]]</para>
</td>
<td>
<para style="P13">[[ o.complete_name ]]</para>
</td>
<td>
<para style="P14">[[ '%.2f' % (move_sum_debit(o.id,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P14">[[ '%.2f' % (move_sum_credit(o.id,data['form']['date1'],data['form']['date2']) or 0 )]]</para>
</td>
<td>
<para style="P14">[[ '%.2f' % move_sum_balance(o.id,data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P14">[[ '%.2f' % move_sum_quantity(o.id,data['form']['date1'],data['form']['date2']) or 0.0]]</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
</section>
<para style="P15">
<font color="white"> </font>
</para>
<blockTable colWidths="284.0,50.0,50.0,50.0,49.0" style="Tableau10">
<tr>
<td>
<para style="P3">Sum</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_debit(objects,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_credit(objects,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % sum_balance(objects,data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % sum_quantity(objects,data['form']['date1'],data['form']['date2']) or 0.0 ]]</para>
</td>
</tr>
</blockTable>
<para style="P16">
<font color="white"> </font>
</para>
<para style="P17">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,67 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import pooler
from 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)
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=%d) 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=%d) 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=%d", (date1, date2, journal_id))
res = self.cr.dictfetchone()
return res['sum'] or 0
report_sxw.report_sxw('report.account.analytic.journal', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=account_analytic_journal)

View File

@ -0,0 +1,231 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P3" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="6.0" leading="8"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P19" fontName="Times-Bold" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P20" fontName="Times-Bold" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P21" fontName="Times-Bold" fontSize="11.0" leading="14" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P22" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<blockTable colWidths="152.0,176.0,154.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P2">Analytic journal</para>
</td>
<td>
<para style="P3">Period from [[ data['form']['date1'] ]]</para>
<para style="P3">to [[ data['form']['date2'] ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="152.0,176.0,154.0" repeatRows="1" style="Tableau2">
<tr>
<td>
<para style="P4">[[ o.code ]]</para>
</td>
<td>
<para style="P4">[[ o.name ]]</para>
</td>
<td>
<para style="P5">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P6">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P7">
<font color="white"> </font>
</para>
<blockTable colWidths="57.0,51.0,190.0,85.0,99.0" style="Tableau3">
<tr>
<td>
<para style="P8">Date</para>
</td>
<td>
<para style="P8">Code</para>
</td>
<td>
<para style="P8">Move name</para>
</td>
<td>
<para style="P8">Account n°</para>
</td>
<td>
<para style="P8">Accounting moves</para>
<para style="P9">General</para>
<para style="P10">Analytic</para>
</td>
</tr>
</blockTable>
<para style="P11">
<font color="white"> </font>
</para>
<section>
<para style="P12">[[ repeatIn(lines(o.id,data['form']['date1'],data['form']['date2']), 'move') ]]</para>
<blockTable colWidths="57.0,51.0,190.0,85.0,99.0" repeatRows="1" style="Tableau4">
<tr>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P14">[[ move.name ]]</para>
</td>
<td>
<para style="P14">[[ move.account_id.code ]] - [[ move.account_id.name ]]</para>
</td>
<td>
<para style="P14">[[ '%.2f' % (move.debit-move.credit) ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="57.0,51.0,190.0,85.0,99.0" style="Tableau6">
<tr>
<td>
<para style="P15">[[ repeatIn(lines_a(move.id,o.id,data['form']['date1'],data['form']['date2']),'move_a') ]]</para>
<para style="P16">[[ move_a.date ]]</para>
</td>
<td>
<para style="P16">[[ move_a.code ]]</para>
</td>
<td>
<para style="P17">[[ move_a.name ]]</para>
</td>
<td>
<para style="P17">[[ move_a.account_id.code ]] - [[ move_a.account_id.name ]]</para>
</td>
<td>
<para style="P17">[[ '%.2f' % move_a.amount ]]</para>
</td>
</tr>
</blockTable>
<para style="P18">
<font color="white"> </font>
</para>
</section>
<blockTable colWidths="57.0,51.0,190.0,85.0,99.0" style="Tableau7">
<tr>
<td>
<para style="P15">[[ repeatIn(lines_a(False,o.id,data['form']['date1'],data['form']['date2']),'move_a') ]]</para>
<para style="P16">[[ move_a.date ]]</para>
</td>
<td>
<para style="P16">[[ move_a.code ]]</para>
</td>
<td>
<para style="P17">[[ move_a.name ]]</para>
</td>
<td>
<para style="P17">[[move_a.account_id.code ]] - [[ move_a.account_id.name ]]</para>
</td>
<td>
<para style="P17">[[ '%.2f' % move_a.amount ]]</para>
</td>
</tr>
</blockTable>
<para style="P19">
<font color="white"> </font>
</para>
<blockTable colWidths="383.0,99.0" repeatRows="1" style="Tableau5">
<tr>
<td>
<para style="P20">Sums of the journal</para>
</td>
<td>
<para style="P21">[[ '%.2f' % sum_general(o.id,data['form']['date1'],data['form']['date2']) ]]</para>
<para style="P20">[[ '%.2f' % sum_analytic(o.id,data['form']['date1'],data['form']['date2']) ]]</para>
</td>
</tr>
</blockTable>
<para style="P22">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,122 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting FROM its eventual inadequacies AND bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees AND support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it AND/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from 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)
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,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'sum_balance': self._sum_balance,
'account_sum_balance': self._account_sum_balance,
})
def _lines_g(self, account_id, 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=%d) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2))
res = self.cr.dictfetchall()
for r in res:
if r['balance'] > 0:
r['debit'] = '%.2f' % r['balance']
r['credit'] = ''
elif r['balance'] < 0:
r['debit'] = ''
r['credit'] = '%.2f' % -r['balance']
else: # r['balance'] == 0
r['debit'] = ''
r['credit'] = ''
return res
def _lines_a(self, general_account_id, account_id, 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=%d) AND (aal.account_id=%d) 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))
res = self.cr.dictfetchall()
for r in res:
if r['balance'] > 0:
r['debit'] = '%.2f' % r['balance']
r['credit'] = ''
elif r['balance'] < 0:
r['debit'] = ''
r['credit'] = '%.2f' % -r['balance']
else: # r['balance'] == 0
r['debit'] = ''
r['credit'] = ''
return res
def _account_sum_debit(self, account_id, date1, date2):
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2))
return self.cr.fetchone()[0] or 0.0
def _account_sum_credit(self, account_id, date1, date2):
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2))
return self.cr.fetchone()[0] or 0.0
def _account_sum_balance(self, account_id, date1, date2):
debit = self._account_sum_debit(account_id, date1, date2)
credit = self._account_sum_credit(account_id, date1, date2)
return (debit-credit)
def _sum_debit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
ids = map(lambda x: x.id, accounts)
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):
debit = self._sum_debit(accounts, date1, date2) or 0.0
credit = self._sum_credit(accounts, date1, date2) or 0.0
return (debit-credit)
report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger)

View File

@ -0,0 +1,315 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau10">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P3" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Times-Roman"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P7" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="3.0" leading="4" alignment="LEFT"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="P12" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P15" fontName="Times-BoldItalic" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P16" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P17" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="CENTER"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="161.0,161.0,161.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P1">[[ company.name ]]</para>
</td>
<td>
<para style="P2">Cost Ledger</para>
</td>
<td>
<para style="P3">Period from [[ data['form']['date1'] ]]</para>
<para style="P3">to [[ data['form']['date2'] ]]</para>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P6">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="57.0,28.0,43.0,184.0,113.0,57.0" style="Tableau3">
<tr>
<td>
<para style="P7">Date</para>
</td>
<td>
<para style="P7">J.C.</para>
</td>
<td>
<para style="P7">Code</para>
</td>
<td>
<para style="P7">Move name</para>
</td>
<td>
<para style="P7">Moves</para>
<para style="P7">Debit Credit</para>
</td>
<td>
<para style="P7">Balance</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P9">[[ repeatIn(objects,'o') ]]</para>
<para style="P10">
<font color="white"> </font>
</para>
<blockTable colWidths="85.0,227.0,57.0,57.0,57.0" style="Tableau2">
<tr>
<td>
<para style="P11">[[ o.code ]]</para>
</td>
<td>
<para style="P11">[[ o.complete_name ]]</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P9">[[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]]</para>
<para style="P8">
<font color="white"> </font>
</para>
<blockTable colWidths="28.0,99.0,184.0,57.0,57.0,57.0" style="Tableau4">
<tr>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P12">[[ move_g['code'] ]]</para>
</td>
<td>
<para style="P12">[[ move_g['name'] ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="57.0,28.0,42.0,184.0,57.0,57.0,56.0" style="Tableau7">
<tr>
<td>
<para style="P13">[[ repeatIn(lines_a(move_g['id'],o.id,data['form']['date1'],data['form']['date2']),'move_a') ]]</para>
<para style="P13">[[ move_a['date'] ]]</para>
</td>
<td>
<para style="P13">[[ move_a['cj'] ]]</para>
</td>
<td>
<para style="P13">[[ move_a['code'] ]]</para>
</td>
<td>
<para style="P14">[[ move_a['name'] ]]</para>
</td>
<td>
<para style="P13">[[ move_a['debit'] ]]</para>
</td>
<td>
<para style="P13">[[ move_a['credit'] ]]</para>
</td>
<td>
<para style="P13">[[ '%.2f' % move_a['balance'] ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="85.0,227.0,57.0,57.0,57.0" style="Tableau6">
<tr>
<td>
<para style="P15">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P16">Sum of account [[ move_g['code'] ]]</para>
</td>
<td>
<para style="P17">[[ move_g['debit'] ]]</para>
</td>
<td>
<para style="P17">[[ move_g['credit'] ]]</para>
</td>
<td>
<para style="P17">[[ '%.2f' % move_g['balance'] ]]</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
</section>
<para style="P8">
<font color="white"> </font>
</para>
<blockTable colWidths="28.0,113.0,170.0,57.0,57.0,57.0" style="Tableau5">
<tr>
<td>
<para style="P18">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P18">sum [[ o.code ]]</para>
</td>
<td>
<para style="P18">[[ o.complete_name ]]</para>
</td>
<td>
<para style="P4">[[ '%.2f' % (account_sum_debit(o.id,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P4">[[ '%.2f' % (account_sum_credit(o.id,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P4">[[ '%.2f' % account_sum_balance(o.id,data['form']['date1'],data['form']['date2'])]]</para>
</td>
</tr>
</blockTable>
<para style="P10">
<font color="white"> </font>
</para>
</section>
<para style="P19">
<font color="white"> </font>
</para>
<blockTable colWidths="312.0,57.0,57.0,57.0" style="Tableau10">
<tr>
<td>
<para style="P3">Sum</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_debit(objects,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_credit(objects,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % sum_balance(objects,data['form']['date1'],data['form']['date2']) ]]</para>
</td>
</tr>
</blockTable>
<para style="P20">
<font color="white"> </font>
</para>
<para style="P11">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,119 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting FROM its eventual inadequacies AND bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees AND support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it AND/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from 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)
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)
if not len(ids):
return 0.0
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 ("+','.join(map(str, ids))+")) AND (date>=%s) AND (date<=%s) \
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (date1, date2))
res = self.cr.dictfetchall()
for r in res:
if r['balance'] > 0:
r['debit'] = '%.2f' % r['balance']
r['credit'] = '%.2f' % 0.0
elif r['balance'] < 0:
r['debit'] = '%.2f' % 0.0
r['credit'] = '%.2f' % -r['balance']
else: # r['balance'] == 0
r['debit'] = '%.2f' % 0.0
r['credit'] = '%.2d' % 0.0
return res
def _lines_a(self, accounts, general_account_id, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
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 ("+','.join(map(str, ids))+") AND aal.general_account_id=%d 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", (general_account_id, date1, date2))
res = self.cr.dictfetchall()
aaa_obj = self.pool.get('account.analytic.account')
for r in res:
r['complete_name'] = aaa_obj.read(self.cr, self.uid, [r['account_id']], ['complete_name'])[0]['complete_name']
if r['balance'] > 0:
r['debit'] = '%.2f' % r['balance']
r['credit'] = ''
elif r['balance'] < 0:
r['debit'] = ''
r['credit'] = '%.2f' % -r['balance']
else: # r['balance'] == 0
r['debit'] = ''
r['credit'] = ''
return res
def _sum_debit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):
debit = self._sum_debit(accounts, date1, date2) or 0.0
credit = self._sum_credit(accounts, date1, date2) or 0.0
return (debit-credit)
def _sum_quantity(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance)

View File

@ -0,0 +1,231 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau8">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau10">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P3" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Times-Roman"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P7" fontName="Times-Bold" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="6.0" leading="8"/>
<paraStyle name="P9" fontName="Times-Bold" fontSize="9.0" leading="11" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="9.0" leading="11" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P12" fontName="Times-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="6.0" leading="8"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="161.0,161.0,161.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P1">[[ company.name ]]</para>
</td>
<td>
<para style="P2">Inverted Analytic Balance</para>
</td>
<td>
<para style="P3">Period from [[ data['form']['date1'] ]]</para>
<para style="P3">to [[ data['form']['date2'] ]]</para>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P6">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="85.0,199.0,99.0,50.0,49.0" style="Tableau8">
<tr>
<td>
<para style="P7">Code</para>
</td>
<td>
<para style="P7">Account Name</para>
</td>
<td>
<para style="P7">Moves</para>
<para style="P7">Débit Crédit</para>
</td>
<td>
<para style="P7">Balance</para>
</td>
<td>
<para style="P7">Quantity</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P8">[[ repeatIn(lines_g(objects,data['form']['date1'],data['form']['date2']),'move_g') ]]</para>
<blockTable colWidths="71.0,213.0,99.0,50.0,50.0" style="Tableau3">
<tr>
<td>
<para style="P9">[[ move_g['code'] ]]</para>
</td>
<td>
<para style="P9">[[ move_g['name'] ]]</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P8">[[ repeatIn(lines_a(objects,move_g['id'],data['form']['date1'],data['form']['date2']),'move_a') ]]</para>
<section>
<blockTable colWidths="28.0,71.0,184.0,50.0,50.0,50.0,49.0" style="Tableau2">
<tr>
<td>
<para style="P10">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P10">[[ move_a['code'] ]]</para>
</td>
<td>
<para style="P10">[[ move_a['complete_name'] ]]</para>
</td>
<td>
<para style="P11">[[ move_a['debit'] ]]</para>
</td>
<td>
<para style="P11">[[ move_a['credit'] ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % move_a['balance'] ]]</para>
</td>
<td>
<para style="P11">[[ '%.2f' % (move_a['quantity'] or 0.0) ]]</para>
</td>
</tr>
</blockTable>
</section>
<blockTable colWidths="71.0,213.0,50.0,50.0,50.0,49.0" style="Tableau4">
<tr>
<td>
<para style="P9">total [[ move_g['code'] ]]</para>
</td>
<td>
<para style="P9">[[ move_g['name'] ]]</para>
</td>
<td>
<para style="P12">[[ move_g['debit'] ]]</para>
</td>
<td>
<para style="P12">[[ move_g['credit'] ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % move_g['balance'] ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % (move_g['quantity'] or 0.0) ]]</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
</section>
<para style="P13">
<font color="white"> </font>
</para>
<blockTable colWidths="284.0,50.0,50.0,50.0,49.0" style="Tableau10">
<tr>
<td>
<para style="P3">Sum</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_debit(objects,data['form']['date1'],data['form']['date2']) or 0) ]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_credit(objects,data['form']['date1'],data['form']['date2']) or 0)]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % sum_balance(objects,data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_quantity(objects,data['form']['date1'],data['form']['date2']) or 0.0) ]]</para>
</td>
</tr>
</blockTable>
<para style="P14">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,89 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting FROM its eventual inadequacies AND bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees AND support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it AND/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from 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)
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=%d) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2))
else:
journal_ids = journals[0][2] # yeah, [0][2] sucks, but I couldn't/didn't want to figure out why
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=%d) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
AND (aal.journal_id IN ("+','.join(map(str, journal_ids))+")) GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2))
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=%d) AND (aal.account_id=%d) 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[0][2] # yeah, [0][2] sucks, but I couldn't/didn't want to figure out why
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=%d) AND (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) \
AND (aal.journal_id=aaj.id) AND (aaj.id IN ("+','.join(map(str, journal_ids))+")) \
ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2))
res = self.cr.dictfetchall()
return res
def _account_sum_quantity(self, account_id, date1, date2):
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s", (account_id, date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_quantity(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.analytic.account.cost_ledger_for_journal', 'account.analytic.account', 'addons/account/project/report/quantity_cost_ledger.rml',parser=account_analytic_quantity_cost_ledger)

View File

@ -0,0 +1,263 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau10">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P3" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Times-Roman"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P7" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="3.0" leading="4" alignment="LEFT"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="P12" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P15" fontName="Times-BoldItalic" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P16" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P17" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="CENTER"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="161.0,161.0,161.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P1">[[ company.name ]]</para>
</td>
<td>
<para style="P2">Cost Ledger</para>
</td>
<td>
<para style="P3">Period from [[ data['form']['date1'] ]]</para>
<para style="P3">to [[ data['form']['date2'] ]]</para>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P6">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="57.0,28.0,43.0,298.0,57.0" style="Tableau3">
<tr>
<td>
<para style="P7">Date</para>
</td>
<td>
<para style="P7">J.C.</para>
</td>
<td>
<para style="P7">Code</para>
</td>
<td>
<para style="P7">Move name</para>
</td>
<td>
<para style="P7">Quantity</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P9">[[ repeatIn(objects,'o') ]]</para>
<para style="P10">
<font color="white"> </font>
</para>
<blockTable colWidths="85.0,340.0,57.0" style="Tableau2">
<tr>
<td>
<para style="P11">[[ o.code ]]</para>
</td>
<td>
<para style="P11">[[ o.complete_name ]]</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P9">[[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2'],data['form']['journal']),'move_g') ]]</para>
<para style="P8">
<font color="white"> </font>
</para>
<blockTable colWidths="28.0,99.0,298.0,57.0" style="Tableau4">
<tr>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P12">[[ move_g['code'] ]]</para>
</td>
<td>
<para style="P12">[[ move_g['name'] ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="57.0,28.0,42.0,298.0,57.0" style="Tableau7">
<tr>
<td>
<para style="P13">[[ repeatIn(lines_a(move_g['id'],o.id,data['form']['date1'],data['form']['date2'],data['form']['journal']),'move_a') ]]</para>
<para style="P13">[[ move_a['date'] ]]</para>
</td>
<td>
<para style="P13">[[ move_a['cj'] ]]</para>
</td>
<td>
<para style="P13">[[ move_a['code'] ]]</para>
</td>
<td>
<para style="P14">[[ move_a['name'] ]]</para>
</td>
<td>
<para style="P13">[[ '%.2f' % (move_a['quantity'] or 0.0 )]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="85.0,340.0,57.0" style="Tableau6">
<tr>
<td>
<para style="P15">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P16">Sum of account [[ move_g['code'] ]]</para>
</td>
<td>
<para style="P17">[[ '%.2f' % (move_g['quantity'] or 0.0) ]]</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
</section>
<para style="P8">
<font color="white"> </font>
</para>
<blockTable colWidths="28.0,113.0,283.0,57.0" style="Tableau5">
<tr>
<td>
<para style="P18">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P18">sum [[ o.code ]]</para>
</td>
<td>
<para style="P18">[[ o.complete_name ]]</para>
</td>
<td>
<para style="P4">[[ '%.2f' % (account_sum_quantity(o.id,data['form']['date1'],data['form']['date2']) or 0.0 )]]</para>
</td>
</tr>
</blockTable>
<para style="P10">
<font color="white"> </font>
</para>
</section>
<para style="P19">
<font color="white"> </font>
</para>
<blockTable colWidths="425.0,57.0" style="Tableau10">
<tr>
<td>
<para style="P3">Sum</para>
</td>
<td>
<para style="P3">[[ '%.2f' % (sum_quantity(objects,data['form']['date1'],data['form']['date2']) or 0.0) ]]</para>
</td>
</tr>
</blockTable>
<para style="P20">
<font color="white"> </font>
</para>
<para style="P11">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,117 @@
##############################################################################
#
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting FROM its eventual inadequacies AND bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees AND support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it AND/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from report import report_sxw
class account_analytic_year_to_date_check(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_analytic_year_to_date_check, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'start_date': self._get_start_date,
'end_date': self._get_end_date,
'lines_p': self._lines_p,
'general_debit': self._gen_deb,
'general_credit': self._gen_cred,
'analytic_debit': self._ana_deb,
'analytic_credit': self._ana_cred,
'delta_debit': self._delta_deb,
'delta_credit': self._delta_cred,
})
def _get_periods(self, date1, date2):
self.cr.execute("SELECT name, date_start, date_stop FROM account_period WHERE (date_start>=%s) AND (date_stop<=%s) ORDER BY date_start, date_stop", (date1, date2))
return self.cr.dictfetchall()
def _get_start_date(self, date1, date2):
periods = self._get_periods(date1, date2)
return periods[0]['date_start']
def _get_end_date(self, date1, date2):
periods = self._get_periods(date1, date2)
return periods[-1]['date_stop']
def _lines_p(self, date1, date2):
periods = self._get_periods(date1, date2)
for r in periods:
self.cr.execute("SELECT sum(debit),sum(credit) FROM account_move_line WHERE (date>=%s) AND (date<=%s) AND state<>'draft'", (r['date_start'], r['date_stop']))
(gd, gc) = self.cr.fetchone()
gd = gd or 0.0
gc = gc or 0.0
self.cr.execute("SELECT sum(amount) AS balance FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (amount>0)", (r['date_start'], r['date_stop']))
(ad,) = self.cr.fetchone()
ad = ad or 0.0
self.cr.execute("SELECT sum(amount) AS balance FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (amount<0)", (r['date_start'], r['date_stop']))
(ac,) = self.cr.fetchone()
ac = ac or 0.0
r['gen_debit'] = '%.2f' % gd
r['gen_credit'] = '%.2f' % gc
r['ana_debit'] = '%.2f' % ad
r['ana_credit'] = '%.2f' % ac
r['delta_debit'] = '%.2f' % (gd - ad) or ''
r['delta_credit'] = '%.2f' % (gc - ac) or ''
return periods
def _gen_deb(self, date1, date2):
start = self._get_start_date(date1, date2)
stop = self._get_end_date(date1, date2)
self.cr.execute("SELECT sum(debit) FROM account_move_line WHERE date>=%s AND date<=%s AND state<>'draft'", (start, stop))
return self.cr.fetchone()[0] or 0.0
def _gen_cred(self, date1, date2):
start = self._get_start_date(date1, date2)
stop = self._get_end_date(date1, date2)
self.cr.execute("SELECT sum(credit) FROM account_move_line WHERE date>=%s AND date<=%s AND state<>'draft'", (start, stop))
return self.cr.fetchone()[0] or 0.0
def _ana_deb(self, date1, date2):
start = self._get_start_date(date1, date2)
stop = self._get_end_date(date1, date2)
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE date>=%s AND date<=%s AND amount>0", (start, stop))
return self.cr.fetchone()[0] or 0.0
def _ana_cred(self, date1, date2):
start = self._get_start_date(date1, date2)
stop = self._get_end_date(date1, date2)
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE date>=%s AND date<=%s AND amount<0", (start, stop))
res = self.cr.fetchone()[0] or 0.0
return abs(res)
def _delta_deb(self, date1, date2):
return (self._gen_deb(date1,date2)-self._ana_deb(date1,date2))
def _delta_cred(self, date1, date2):
return (self._gen_cred(date1,date2)-self._ana_cred(date1,date2))
report_sxw.report_sxw('report.account.analytic.account.year_to_date_check', 'account.analytic.account', 'addons/account/project/report/year_to_date_check.rml',parser=account_analytic_year_to_date_check)

View File

@ -0,0 +1,159 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P3" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="Preformatted Text" fontName="Courier" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="0.0"/>
</stylesheet>
<story>
<blockTable colWidths="161.0,161.0,161.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P1">[[ company.name ]]</para>
</td>
<td>
<para style="P2">Year to Day Check</para>
</td>
<td>
<para style="P3">Periods from [[ start_date(data['form']['date1'],data['form']['date2']) ]]</para>
<para style="P3">to [[ end_date(data['form']['date1'],data['form']['date2']) ]]</para>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<blockTable colWidths="57.0,142.0,142.0,71.0,71.0" style="Tableau2">
<tr>
<td>
<para style="P6">Period</para>
</td>
<td>
<para style="P6">General moves</para>
<para style="P6">debit credit</para>
</td>
<td>
<para style="P6">Analytic moves</para>
<para style="P6">debit credit</para>
</td>
<td>
<para style="P6">delta general and analytic debit moves</para>
</td>
<td>
<para style="P6">delta general and analytic credit moves</para>
</td>
</tr>
</blockTable>
<para style="P7">
<font color="white"> </font>
</para>
<blockTable colWidths="57.0,71.0,71.0,71.0,71.0,71.0,71.0" style="Tableau3">
<tr>
<td>
<para style="P8">[[ repeatIn(lines_p(data['form']['date1'],data['form']['date2']),'period') ]]</para>
<para style="P8">[[ period['name'] ]]</para>
</td>
<td>
<para style="P8">[[ period['gen_debit'] ]]</para>
</td>
<td>
<para style="P8">[[ period['gen_credit'] ]]</para>
</td>
<td>
<para style="P8">[[ period['ana_debit'] ]]</para>
</td>
<td>
<para style="P8">[[ period['ana_credit'] ]]</para>
</td>
<td>
<para style="P8">[[ period['delta_debit'] ]]</para>
</td>
<td>
<para style="P8">[[ period['delta_credit'] ]]</para>
</td>
</tr>
</blockTable>
<para style="P7">
<font color="white"> </font>
</para>
<blockTable colWidths="57.0,71.0,71.0,71.0,71.0,73.0,69.0" style="Tableau4">
<tr>
<td>
<para style="P9">Sums</para>
</td>
<td>
<para style="P9">[[ '%.2f' % general_debit(data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % general_credit(data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % analytic_debit(data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % analytic_credit(data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % delta_debit(data['form']['date1'],data['form']['date2']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % delta_credit(data['form']['date1'],data['form']['date2']) ]]</para>
</td>
</tr>
</blockTable>
<para style="P7">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,34 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard_account_analytic_journal_report
import wizard_account_analytic_balance_report
import wizard_account_analytic_inverted_balance_report
import wizard_account_analytic_cost_ledger_report
import wizard_account_analytic_cost_ledger_for_journal_report
import wizard_account_analytic_year_to_date_check

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('report','Print'), ('end','Cancel')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.analytic.account.balance', 'state':'end'}
}
}
wizard_report('account.analytic.account.balance.report')

View File

@ -0,0 +1,59 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
_form = '''<?xml version="1.0"?>
<form string="Select period">
<separator string="Cost Legder for period" colspan="4"/>
<field name="date1"/>
<field name="date2"/>
<separator string="and Journals" colspan="4"/>
<field name="journal" colspan="4"/>
</form>'''
_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'journal': {'string':'Journals','type':'many2many', 'relation':'account.analytic.journal'},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':_form, 'fields':_fields, 'state':[('report','Print'), ('end','Cancel')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.analytic.account.cost_ledger_for_journal', 'state':'end'}
}
}
wizard_report('account.analytic.account.quantity_cost_ledger.report')

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.analytic.account.cost_ledger', 'state':'end'}
}
}
wizard_report('account.analytic.account.cost_ledger.report')

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('report','Print'), ('end','Cancel')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.analytic.account.inverted.balance', 'state':'end'}
}
}
wizard_report('account.analytic.account.inverted.balance.report')

View File

@ -0,0 +1,54 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Analytic Journal Report">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('report','Print'), ('end','Cancel')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.analytic.journal', 'state':'end'}
}
}
wizard_report('account.analytic.account.journal.report')

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('report','Print'), ('end','Cancel')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.analytic.account.year_to_date_check', 'state':'end'}
}
}
wizard_report('account.analytic.account.year_to_date_check.report')

View File

@ -0,0 +1,39 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import budget_report
import central_journal
import general_journal
import account_journal
import account_balance
import partner_balance
import grand_livre
import grand_livre_tiers
import invoice
import rappel
import aged_trial_balance
import tax_report

View File

@ -0,0 +1,97 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from report import report_sxw
class account_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_balance, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'lines': self.lines,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'sum_sdebit': self._sum_sdebit,
'sum_scredit': self._sum_scredit
})
self.context = context
def lines(self, ids=None, done=None, level=0):
ids = ids or self.ids
done = done or {}
if not self.ids:
return []
result = []
for account in self.pool.get('account.account').browse(self.cr, self.uid, ids, self.context):
if account.id in done:
continue
done[account.id] = 1
res = {
'code': account.code,
'name': account.name,
'debit': account.debit,
'credit': account.credit,
'level': level,
'sdebit': account.debit > account.credit and account.debit - account.credit,
'scredit': account.debit < account.credit and account.credit - account.debit,
'balance': account.balance
}
if not (res['credit'] or res['debit']) and not account.child_id:
continue
result.append(res)
ids2 = [(x.code,x.id) for x in account.child_id]
ids2.sort()
result += self.lines([x[1] for x in ids2], done, level+1)
self.ids = done
return result
def _sum_debit(self):
if not self.ids:
return 0.0
self.cr.execute('select sum(debit) from account_move_line where account_id in (' + ','.join(map(str, self.ids)) + ') and date>=%s and date<=%s and state<>\'draft\'', (self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
if not self.ids:
return 0.0
self.cr.execute('select sum(credit) from account_move_line where account_id in (' + ','.join(map(str, self.ids)) + ') and date>=%s and date<=%s and state<>\'draft\'', (self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_sdebit(self):
debit, credit = self._sum_debit(), self._sum_credit()
return debit > credit and debit - credit
def _sum_scredit(self):
debit, credit = self._sum_debit(), self._sum_credit()
return credit > debit and credit - debit
report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance)

View File

@ -0,0 +1,186 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="35.0" y1="35.0" width="525" height="772"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Bold" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Trial balance</para>
</td>
<td>
<para style="P2">From [[ data['form']['date1'] ]]</para>
<para style="P2">to [[ data['form']['date2'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">Complete</para>
</td>
<td>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<blockTable colWidths="44.0,247.0,160.0,74.0" style="Table6">
<tr>
<td>
<para style="P6">Code</para>
</td>
<td>
<para style="P6">Account name</para>
</td>
<td>
<para style="P6">Transactions</para>
</td>
<td>
<para style="P7">Balance</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="291.0,78.0,82.0,73.0" style="Table2">
<tr>
<td>
<para style="P8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P6">Debit</para>
</td>
<td>
<para style="P6">Credit</para>
</td>
<td>
<para style="P6">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P9">
<font color="white"> </font>
</para>
<blockTable colWidths="45.0,246.0,78.0,82.0,73.0" style="Table3">
<tr>
<td>
<para style="P10">[[ repeatIn(lines(), 'a') ]]<font face="Times-Roman">[[ a['code'] ]]</font></para>
</td>
<td>
<para style="P11">[[ '. . '*(a['level']-1) + a['name'] ]]</para>
</td>
<td>
<para style="P12">[[ a['debit'] and '%.2f' % a['debit'] or '' ]]</para>
</td>
<td>
<para style="P12">[[ a['credit'] and '%.2f' % a['credit'] or '' ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f'% a['balance'] ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="291.0,77.0,82.0,74.0" style="Table4">
<tr>
<td>
<para style="P13">Balance brought forward</para>
</td>
<td>
<para style="P14">[[ '%.2f' % sum_debit() ]]</para>
</td>
<td>
<para style="P14">[[ '%.2f' % sum_credit() ]]</para>
</td>
<td>
<para style="P14">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,60 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from report import report_sxw
#
# Use period and Journal for selection or resources
#
class journal_print(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(journal_print, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit
})
def lines(self, period_id, journal_id, *args):
self.cr.execute('update account_journal_period set state=%s where journal_id=%d and period_id=%d and state=%s', ('printed',journal_id,period_id,'draft'))
self.cr.commit()
self.cr.execute('select id from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\' order by date,id', (period_id, 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 _sum_debit(self, period_id, journal_id):
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, period_id, journal_id):
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print)

View File

@ -0,0 +1,163 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="Table Contents">[[ repeatIn(objects, 'o') ]]</para>
<blockTable colWidths="161.0,161.0,161.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Journal</para>
</td>
<td>
<para style="P2">[[o.period_id.name ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">[[ o.journal_id.code ]] [[ o.journal_id.name ]]</para>
</td>
<td>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="49.0,48.0,61.0,98.0,108.0,58.0,60.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P7">Date</para>
</td>
<td>
<para style="P7">Voucher Nb</para>
</td>
<td>
<para style="P7">Account Number</para>
</td>
<td>
<para style="P7">Third party</para>
</td>
<td>
<para style="P7">Entry label</para>
</td>
<td>
<para style="P7">Debit</para>
</td>
<td>
<para style="P7">Credit</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="49.0,48.0,61.0,98.0,108.0,58.0,60.0" style="Table3">
<tr>
<td>
<para style="Table Contents">
<font face="Times-Roman" size="8.0">[[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]] </font>
<font face="Times-Roman" size="8.0">[[ line.date ]]</font>
</para>
</td>
<td>
<para style="P8">[[ line.ref ]]</para>
</td>
<td>
<para style="P8">[[ line.account_id.code ]]</para>
</td>
<td>
<para style="P8">[[ line.partner_id and line.partner_id.name ]]</para>
</td>
<td>
<para style="P9">[[ line.name ]]</para>
</td>
<td>
<para style="P10">[[ line.debit and '%.2f' % line.debit or '' ]]</para>
</td>
<td>
<para style="P10">[[ line.credit and '%.2f' % line.credit or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="364.0,58.0,60.0" style="Table4">
<tr>
<td>
<para style="P11">TOTAL:</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_debit(o.period_id.id, o.journal_id.id) ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_credit(o.period_id.id, o.journal_id.id) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,167 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="P1">[[ repeatIn(objects, 'o') ]]</para>
<blockTable colWidths="145.0,192.0,145.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P2">Accounting Entries</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P4">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P5">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="49.0,39.0,54.0,117.0,105.0,58.0,60.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P7">Date</para>
</td>
<td>
<para style="P7">Voucher Nb</para>
</td>
<td>
<para style="P7">Account Number</para>
</td>
<td>
<para style="P7">Third party (Country)</para>
</td>
<td>
<para style="P7">Entry label</para>
</td>
<td>
<para style="P7">Debit</para>
</td>
<td>
<para style="P7">Credit</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="49.0,38.0,55.0,118.0,104.0,58.0,60.0" style="Table3">
<tr>
<td>
<para style="Table Contents">
<font face="Times-Roman" size="8.0">[[ repeatIn(o.line_ids, 'line') ]] </font>
<font face="Times-Roman" size="8.0">[[ line.date ]]</font>
</para>
</td>
<td>
<para style="P8">[[ line.ref ]]</para>
</td>
<td>
<para style="P8">[[ line.account_id.code ]]</para>
</td>
<td>
<para style="P8">[[ line.partner_id and line.partner_id.name ]] ([[ line.partner_id and line.partner_id.address and line.partner_id.address[0].country_id.code or '' ]] )</para>
</td>
<td>
<para style="P9">[[ line.name ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % line.debit ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % line.credit ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="364.0,58.0,60.0" style="Table4">
<tr>
<td>
<para style="P11">TOTAL:</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,112 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import pooler
from report import report_sxw
class aged_trial_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(aged_trial_report, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'get_lines': self._get_lines,
'get_total': self._get_total,
'get_before': self._get_before,
'get_for_period': self._get_for_period,
})
def _add_header(self, node):
return True
def _get_lines(self, form):
res = []
self.cr.execute("SELECT DISTINCT res_partner.id AS id, res_partner.name AS name \
FROM res_partner, account_move_line AS line, account_account \
WHERE (line.account_id=account_account.id) AND (line.reconcile_id IS NULL) \
AND (line.partner_id=res_partner.id) AND (line.state<>'draft') \
ORDER BY res_partner.name")
partners = self.cr.dictfetchall()
for partner in partners:
values = {}
self.cr.execute("SELECT SUM(debit-credit) FROM account_move_line AS line, account_account \
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) \
AND (date<'%s') AND (partner_id=%d) AND (reconcile_id IS NULL) AND (line.state<>'draft')" % (form['0']['start'], partner['id']))
before = self.cr.fetchone()
values['before'] = before and before[0] or ""
for i in range(5):
self.cr.execute("SELECT SUM(debit-credit) FROM account_move_line AS line, account_account \
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) \
AND (date>='%s') AND (date<='%s') AND (partner_id=%d) AND (reconcile_id IS NULL) AND line.state<>'draft'" % (form[str(i)]['start'], form[str(i)]['stop'], partner['id']))
during = self.cr.fetchone()
values[str(i)] = during and during[0] or ""
self.cr.execute("SELECT SUM(debit-credit) FROM account_move_line AS line, account_account \
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) \
AND (partner_id=%d) AND (reconcile_id IS NULL) AND (line.state<>'draft')" % (partner['id']))
total = self.cr.fetchone()
values['total'] = total and total[0] or 0.0
values['name'] = partner['name']
t = 0.0
for i in range(5)+['before']:
t+= float(values.get(str(i), 0.0) or 0.0)
if values['total']:
res.append(values)
total = 0.0
totals = {}
for r in res:
total += float(r['total'] or 0.0)
for i in range(5)+['before']:
totals.setdefault(str(i), 0.0)
totals[str(i)] += float(r[str(i)] or 0.0)
return res
def _get_total(self):
self.cr.execute("SELECT SUM(debit-credit) FROM account_move_line AS line, account_account \
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) AND reconcile_id IS NULL AND (line.state<>'draft') and partner_id is not null")
total = self.cr.fetchone()
return total and total[0] or 0.0
def _get_before(self, date):
self.cr.execute("SELECT SUM(debit-credit) FROM account_move_line AS line, account_account \
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) AND reconcile_id IS NULL AND (date<'%s') and (line.state<>'draft') and partner_id is not null" % (date))
before = self.cr.fetchone()
return before and before[0] or 0.0
def _get_for_period(self, period):
self.cr.execute("SELECT SUM(debit-credit) FROM account_move_line AS line, account_account \
WHERE (line.account_id=account_account.id) AND (account_account.type IN ('payable','receivable')) \
AND reconcile_id IS NULL AND (date>='%s') AND (date<='%s') and (line.state<>'draft') and partner_id is not null" % (period['start'], period['stop']))
period = self.cr.fetchone()
return period and period[0] or 0.0
report_sxw.report_sxw(
'report.account.aged.trial.balance',
'res.partner',
'addons/account/report/aged_trial_balance.rml',
parser=aged_trial_report)

View File

@ -0,0 +1,186 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(842.0,595.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="728" height="481"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="198.0,313.0,217.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Aged Trial balance</para>
</td>
<td>
<para style="P2">From the beginning</para>
<para style="P2">to [[ data['form']['4']['stop'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<blockTable colWidths="218.0,71.0,71.0,71.0,71.0,71.0,71.0,85.0" style="Tableau1">
<tr>
<td>
<para style="P6">Partners</para>
</td>
<td>
<para style="P7">[[ data['form']['4']['name'] ]]</para>
</td>
<td>
<para style="P7">[[ data['form']['3']['name'] ]]</para>
</td>
<td>
<para style="P7">[[ data['form']['2']['name'] ]]</para>
</td>
<td>
<para style="P7">[[ data['form']['1']['name'] ]]</para>
</td>
<td>
<para style="P7">[[ data['form']['0']['name'] ]]</para>
</td>
<td>
<para style="P7">Before [[ data['form']['0']['start'] ]]</para>
</td>
<td>
<para style="P6">Total</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="218.0,71.0,71.0,71.0,71.0,71.0,71.0,85.0" style="Tableau2">
<tr>
<td>
<para style="P3">[[ repeatIn(get_lines(data['form']), 'partner') ]]</para>
<para style="P3">[[ partner['name'] ]]</para>
</td>
<td>
<para style="P8">[[ '%.2f' % (partner['4'] or 0.0) ]]</para>
</td>
<td>
<para style="P8">[[ '%.2f' % (partner['3'] or 0.0) ]]</para>
</td>
<td>
<para style="P8">[[ '%.2f' % (partner['2'] or 0.0) ]]</para>
</td>
<td>
<para style="P8">[[ '%.2f' % (partner['1'] or 0.0) ]]</para>
</td>
<td>
<para style="P8">[[ '%.2f' % (partner['0'] or 0.0) ]]</para>
</td>
<td>
<para style="P8">[[ '%.2f' % (partner['before'] or 0.0) ]]</para>
</td>
<td>
<para style="P8">[[ '%.2f' % (partner['total'] or 0.0) ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="218.0,71.0,71.0,71.0,71.0,71.0,71.0,85.0" style="Tableau3">
<tr>
<td>
<para style="P6">Account total</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['4']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['3']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['2']) ]]</para>
</td>
<td>
<para style="P9">[['%.2f' % get_for_period(data['form']['1']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_for_period(data['form']['0']) ]]</para>
</td>
<td>
<para style="P9">[[ '%.2f' % get_before(data['form']['0']['start']) ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % get_total() ]]</para>
</td>
</tr>
</blockTable>
<para style="P5">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,71 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from report import report_sxw
import datetime
class budget_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(budget_report, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'lines': self.lines,
'budget_total': self.budget_total,
'post_total': self.post_total,
'time': time,
})
def post_total(self, post_obj, date1, date2):
def str2date(date_str):
return datetime.date.fromtimestamp(time.mktime(time.strptime(date_str, '%Y-%m-%d')))
def interval(d1str, d2str):
return (str2date(d2str) - str2date(d1str) + datetime.timedelta(days=1)).days
prev = reduce(lambda x,d: x + d.amount, post_obj.dotation_ids, 0.0)
period_days = interval(date1, date2)
for d in post_obj.dotation_ids:
i = interval(d.period_id.date_start, d.period_id.date_stop)
total_days = reduce(lambda x,d: x+interval(d.period_id.date_start, d.period_id.date_stop), post_obj.dotation_ids, 0)
achievements = reduce(lambda x,l: x+l['achievements'], self.lines(post_obj, date1, date2), 0.0)
return [{'prev': prev, 'prev_period': prev * period_days / total_days, 'achievements': achievements}]
def budget_total(self, post_objs, date1, date2):
res = {'prev': 0.0, 'prev_period': 0.0, 'achievements': 0.0}
for post_obj in post_objs:
r = self.post_total(post_obj, date1, date2)[0]
for k in r:
res[k] += r[k]
return [res]
def lines(self, post_obj, date1, date2):
res = []
for a in post_obj.account_ids:
self.cr.execute("SELECT COALESCE(SUM(debit-credit), 0) FROM account_move_line WHERE account_id=%d AND date>=%s AND date<=%s and state<>'draft'", (a.id, date1, date2))
achievements = float(self.cr.fetchone()[0]) * (post_obj.sens=='produit' and -1 or 1)
res.append({'name': a.name, 'code': a.code, 'achievements': achievements})
return res
report_sxw.report_sxw('report.account.budget', 'account.budget.post', 'addons/account/report/budget_report.rml',parser=budget_report)

View File

@ -0,0 +1,248 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="498" height="678"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table8">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table9">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table10">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Bold" fontSize="18.0" leading="22" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P7" fontName="Times-BoldItalic" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman"/>
<paraStyle name="P9" fontName="Times-Bold"/>
<paraStyle name="P10" fontName="Times-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Times-Bold" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="145.0,189.0,164.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P1">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P2">Budget Analysis</para>
</td>
<td>
<para style="P3">From [[ data['form']['date1'] ]]</para>
<para style="P3">to [[ data['form']['date2'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P4">[[ company.name ]]</para>
</td>
<td>
<para style="P5">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">Currency: <font face="Times-Roman" size="11.0">[[ company.currency_id.name ]]</font></para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P6">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="104.0,53.0,60.0,72.0,73.0,63.0,73.0" repeatRows="1" style="Table5">
<tr>
<td>
<para style="P7">Budget item detail</para>
</td>
<td>
<para style="P7">Account Number</para>
</td>
<td>
<para style="P7">Budget</para>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P7">Period Budget</para>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P7">Performance</para>
</td>
<td>
<para style="P7">Spread</para>
</td>
<td>
<para style="P7">% performance</para>
</td>
</tr>
</blockTable>
<para style="P8">
<font color="white"> </font>
</para>
<section>
<para style="P8">[[ repeatIn(objects, 'o') ]]</para>
<blockTable colWidths="75.0,424.0" style="Table8">
<tr>
<td>
<para style="P9">[[ o.code ]]</para>
</td>
<td>
<para style="P10">[[ o.name ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="103.0,53.0,61.0,72.0,72.0,66.0,71.0" style="Table9">
<tr>
<td>
<para style="P11">
<font face="Times-Roman">[[ repeatIn(lines(o, data['form']['date1'], data['form']['date2']), 'a') ]] </font>
<font face="Times-Roman">[[ a['name'] ]]</font>
</para>
</td>
<td>
<para style="P12">[[ a['code'] ]]</para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P14">[[ '%.2f' % a['achievements'] ]]</para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="156.0,61.0,72.0,72.0,66.0,70.0" style="Table10">
<tr>
<td>
<para style="P15">Total [[ o.code ]]</para>
<para style="Table Contents">[[ repeatIn( post_total(o, data['form']['date1'], data['form']['date2']), 'total') ]]</para>
</td>
<td>
<para style="P16">[[ '%.2f' % total['prev'] ]]</para>
</td>
<td>
<para style="P16">[[ '%.2f' % total['prev_period'] ]]</para>
</td>
<td>
<para style="P16">[[ '%.2f' % total['achievements'] ]]</para>
</td>
<td>
<para style="P16">[[ '%.2f' % (total['prev_period'] - total['achievements']) ]]</para>
</td>
<td>
<para style="P16">[[ total['prev_period'] and ('%.2f' % (total['achievements'] / total['prev_period'] * 100.0)) or 0.0]] %</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</section>
<blockTable colWidths="156.0,61.0,72.0,72.0,67.0,68.0" style="Table7">
<tr>
<td>
<para style="P17">Results</para>
<para style="Table Contents">[[ repeatIn( budget_total(objects, data['form']['date1'], data['form']['date2']), 'total') ]]</para>
</td>
<td>
<para style="P18">[[ '%.2f' % total['prev'] ]]</para>
</td>
<td>
<para style="P18">[[ '%.2f' % total['prev_period'] ]]</para>
</td>
<td>
<para style="P18">[[ '%.2f' % total['achievements'] ]]</para>
</td>
<td>
<para style="P18">[[ '%.2f' % (total['prev_period'] - total['achievements']) ]]</para>
</td>
<td>
<para style="P18">[[ '%.2f' % (total['achievements'] / total['prev_period'] * 100.0) ]] %</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,56 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from report import report_sxw
#
# Use period and Journal for selection or resources
#
class journal_print(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(journal_print, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'lines': self.lines,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit
})
def lines(self, period_id, journal_id, *args):
self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%d and l.journal_id=%d and l.state<>\'draft\' group by a.id, a.code, a.name', (period_id, journal_id))
return self.cr.dictfetchall()
def _sum_debit(self, period_id, journal_id):
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, period_id, journal_id):
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print)

View File

@ -0,0 +1,158 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Bold" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="Table Contents">[[ repeatIn(objects, 'o') ]]</para>
<blockTable colWidths="147.0,184.0,151.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="P1">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P2">Central Journal</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P4">[[ company.name ]]</para>
</td>
<td>
<para style="P3">[[ o.journal_id.code ]] [[ o.journal_id.name ]]</para>
</td>
<td>
<para style="P5">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P6">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P7">
<font color="white"> </font>
</para>
<blockTable colWidths="158.0,103.0,103.0,58.0,60.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P8">Account number</para>
</td>
<td>
<para style="P8">Account name</para>
</td>
<td>
<para style="P8">Currency</para>
</td>
<td>
<para style="P8">Debit</para>
</td>
<td>
<para style="P8">Credit</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="158.0,104.0,103.0,58.0,60.0" style="Table3">
<tr>
<td>
<para style="P9"><font face="Times-Roman">[[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]]</font>[[ line['code'] ]]</para>
</td>
<td>
<para style="P10">[[ line['name'] ]]</para>
</td>
<td>
<para style="P10">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P11">[[ line['debit'] and '%.2f' % line['debit'] or '' ]]</para>
</td>
<td>
<para style="P11">[[ line['credit'] and '%.2f' % line['credit'] or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="364.0,58.0,60.0" style="Table4">
<tr>
<td>
<para style="P12">TOTAL:</para>
</td>
<td>
<para style="P13">[[ '%.2f' % sum_debit(o.period_id.id, o.journal_id.id) ]]</para>
</td>
<td>
<para style="P13">[[ '%.2f' % sum_credit(o.period_id.id, o.journal_id.id) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<pageBreak/>
<para style="P14">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,97 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from report import report_sxw
#
# Use period and Journal for selection or resources
#
class journal_print(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(journal_print, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'periods': self.periods,
'sum_debit_period': self._sum_debit_period,
'sum_credit_period': self._sum_credit_period,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit
})
def preprocess(self, objects, datas, ids):
super(journal_print, self).preprocess(objects, datas, ids)
self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')')
res = self.cr.fetchall()
self.period_ids = ','.join([str(x[0]) for x in res])
self.journal_ids = ','.join([str(x[1]) for x in res])
# returns a list of period objs
def periods(self, journal_period_objs):
dic = {}
def filter_unique(o):
key = o.period_id.id
res = key in dic
if not res:
dic[key] = True
return not res
filtered_objs = filter(filter_unique, journal_period_objs)
return map(lambda x: x.period_id, filtered_objs)
def lines(self, period_id):
if not self.journal_ids:
return []
self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%d and journal_id in (' + self.journal_ids + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,))
return self.cr.dictfetchall()
def _sum_debit_period(self, period_id):
if not self.journal_ids:
return 0.0
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,))
return self.cr.fetchone()[0] or 0.0
def _sum_credit_period(self, period_id):
if not self.journal_ids:
return 0.0
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self):
if not self.journal_ids or not self.period_ids:
return 0.0
self.cr.execute('select sum(debit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
if not self.journal_ids or not self.period_ids:
return 0.0
self.cr.execute('select sum(credit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print)

View File

@ -0,0 +1,183 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
</stylesheet>
<story>
<blockTable colWidths="161.0,161.0,161.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">General Journal </para>
</td>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4">Currency: <font face="Times-Roman">[[ company.currency_id.name ]]</font></para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<blockTable colWidths="95.0,135.0,61.0,101.0,90.0" repeatRows="1" style="Table5">
<tr>
<td>
<para style="P6">Journal code</para>
</td>
<td>
<para style="P6">Journal name</para>
</td>
<td>
<para style="P6">Period</para>
</td>
<td>
<para style="P6">Debit trans.</para>
</td>
<td>
<para style="P6">Credit trans.</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<section>
<para style="P7">[[ repeatIn( periods(objects), 'o') ]]</para>
<blockTable colWidths="95.0,134.0,62.0,101.0,90.0" style="Table3">
<tr>
<td>
<para style="P8">
<font face="Times-Roman">[[ repeatIn(lines(o.id), 'line') ]]</font>
<font face="Times-Roman">[[ line['code'] ]]</font>
</para>
</td>
<td>
<para style="P9">[[ line['name'] ]]</para>
</td>
<td>
<para style="P9">[[ o.name ]]</para>
</td>
<td>
<para style="P10">[[ line['debit'] and ('%.2f' % line['debit']) or '' ]]</para>
</td>
<td>
<para style="P10">[[ line['credit'] and ('%.2f' % line['credit']) or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="292.0,101.0,89.0" repeatRows="1" style="Table4">
<tr>
<td>
<para style="P11">Total [[ o.name ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_debit_period(o.id) ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_credit_period(o.id) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="292.0,101.0,89.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P11">TOTAL:</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_debit() ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_credit() ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,103 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from report import report_sxw
class grand_livre(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(grand_livre, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit_account': self._sum_debit_account,
'sum_credit_account': self._sum_credit_account,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit
})
def preprocess(self, objects, data, ids):
# compute the list of accounts to work on, that is: the accounts the user
# selected AND all their childs
def _rec_account_get(cr, uid, accounts, found=None):
if not found:
found = []
for acc in accounts:
if acc.id not in found:
found.append(acc.id)
_rec_account_get(cr, uid, acc.child_id, found)
return found
toprocess = self.pool.get('account.account').browse(self.cr, self.uid, ids)
newids = _rec_account_get(self.cr, self.uid, toprocess)
# filter out accounts which have no transaction in them
self.cr.execute(
"SELECT DISTINCT account_id " \
"FROM account_move_line l " \
"WHERE date>=%s AND date<=%s " \
"AND l.state<>'draft' " \
"AND account_id IN (" + ','.join(map(str,newids)) + ")",
(data['form']['date1'], data['form']['date2']))
newids = [id for (id,) in self.cr.fetchall()]
objects = self.pool.get('account.account').browse(self.cr, self.uid, newids)
super(grand_livre, self).preprocess(objects, data, newids)
def lines(self, account):
self.cr.execute(
"select l.date, j.code, l.ref, l.name, l.debit, l.credit " \
"from account_move_line l left join account_journal j on (l.journal_id=j.id) " \
"where account_id=%d and date>=%s and date<=%s and (l.state<>'draft') " \
"order by l.id",
(account.id, self.datas['form']['date1'], self.datas['form']['date2']))
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum += r['debit'] - r['credit']
r['progress'] = sum
return res
def _sum_debit_account(self, account):
self.cr.execute("select sum(debit) from account_move_line where account_id=%d and date>=%s and date<=%s and (state<>'draft')", (account.id, self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit_account(self, account):
self.cr.execute("select sum(credit) from account_move_line where account_id=%d and date>=%s and date<=%s and (state<>'draft')", (account.id, self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self):
if not self.ids:
return 0.0
self.cr.execute("select sum(debit) from account_move_line where account_id in (" + ','.join(map(str, self.ids)) + ") and date>=%s and date<=%s and (state<>'draft')", (self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
if not self.ids:
return 0.0
self.cr.execute("select sum(credit) from account_move_line where account_id in (" +','.join(map(str, self.ids)) + ") and date>=%s and date<=%s and (state<>'draft')", (self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.grand.livre', 'account.account', 'addons/account/report/grand_livre.rml',parser=grand_livre)

View File

@ -0,0 +1,203 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="14.0" leading="17"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="126.0,217.0,138.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">General ledger</para>
</td>
<td>
<para style="P2">From [[ data['form']['date1'] ]]</para>
<para style="P2">to [[ data['form']['date2'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">Complete</para>
</td>
<td>
<para style="P4">Currency: [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5">Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="45.0,36.0,50.0,145.0,69.0,72.0,64.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P7">Date</para>
</td>
<td>
<para style="P7">J. code</para>
</td>
<td>
<para style="P7">Voucher Nb</para>
</td>
<td>
<para style="P7">Entry label</para>
</td>
<td>
<para style="P7">Debit</para>
</td>
<td>
<para style="P7">Credit</para>
</td>
<td>
<para style="P7">Progressive balance</para>
</td>
</tr>
</blockTable>
<para style="Text body">
<font color="white"> </font>
</para>
<section>
<para style="P8">[[ repeatIn(objects, 'o') ]]</para>
<para style="P9">[[ o.code ]] [[ o.name ]]</para>
<blockTable colWidths="45.0,37.0,50.0,145.0,69.0,72.0,63.0" style="Table3">
<tr>
<td>
<para style="P10"><font face="Times-Roman">[[ repeatIn(lines(o), 'line') ]]</font>[[ line['date'] ]]</para>
</td>
<td>
<para style="P11">[[ line['code'] ]]</para>
</td>
<td>
<para style="P11">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P12">[[ line['name'] ]]</para>
</td>
<td>
<para style="P13">[[ line['debit'] and '%.2f' % line['debit'] or '' ]]</para>
</td>
<td>
<para style="P13">[[ line['credit'] and '%.2f' % line['credit'] or '' ]]</para>
</td>
<td>
<para style="P13">[[ line['progress'] and '%.2f' % line['progress'] or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="277.0,69.0,72.0,63.0" style="Table5">
<tr>
<td>
<para style="P14">Account total [[ o.code ]] </para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_debit_account(o) ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_credit_account(o) ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' % (sum_debit_account(o) - sum_credit_account(o)) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</section>
<para style="Text body">
<font color="white"> </font>
</para>
<blockTable colWidths="277.0,69.0,72.0,63.0" style="Table4">
<tr>
<td>
<para style="P14">TOTAL:</para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_debit() ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_credit() ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' % (sum_debit() - sum_credit()) ]]</para>
</td>
</tr>
</blockTable>
<para style="P16">
<font color="white"> </font>
</para>
<para style="P5">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,122 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from report import report_sxw
class grand_livre_tiers(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(grand_livre_tiers, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit_partner': self._sum_debit_partner,
'sum_credit_partner': self._sum_credit_partner,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit
})
def preprocess(self, objects, data, ids):
self.cr.execute(
"SELECT DISTINCT partner_id " \
"FROM account_move_line " \
"WHERE partner_id IS NOT NULL AND date>=%s AND date<=%s AND state<>'draft'",
(data['form']['date1'], data['form']['date2']))
new_ids = [id for (id,) in self.cr.fetchall()]
self.cr.execute(
"SELECT a.id " \
"FROM account_account a LEFT JOIN account_account_type t ON (a.type=t.code) " \
"WHERE t.partner_account=TRUE")
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
self.partner_ids = ','.join(map(str, new_ids))
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
super(grand_livre_tiers, self).preprocess(objects, data, new_ids)
def lines(self, partner):
self.cr.execute(
"SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit " \
"FROM account_move_line l LEFT JOIN account_journal j ON (l.journal_id=j.id) " \
"WHERE l.partner_id=%d " \
"AND l.account_id IN (" + self.account_ids + ") " \
"AND l.date>=%s AND l.date<=%s AND state<>'draft'" \
"ORDER BY l.id",
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum += r['debit'] - r['credit']
r['progress'] = sum
return res
def _sum_debit_partner(self, partner):
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id=%d " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date>=%s AND date<=%s AND state<>'draft'",
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit_partner(self, partner):
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id=%d " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date>=%s AND date<=%s AND state<>'draft'",
(partner.id, self.datas["form"]["date1"], self.datas["form"]["date2"]))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self):
if not self.ids:
return 0.0
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date>=%s AND date<=%s AND state<>'draft'",
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
if not self.ids:
return 0.0
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
"AND account_id IN (" + self.account_ids + ") " \
"AND date>=%s AND date<=%s AND state<>'draft'",
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.grand.livre.tiers', 'res.partner', 'addons/account/report/grand_livre_tiers.rml',parser=grand_livre_tiers)

View File

@ -0,0 +1,202 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Bold" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="145.0,187.0,149.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Third party ledger</para>
</td>
<td>
<para style="P2"><i>From</i> [[ data['form']['date1'] ]]</para>
<para style="P2"><i>to</i> [[ data['form']['date2'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">Complete</para>
</td>
<td>
<para style="P4"><i>Currency:</i> [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5"><i>Printing date:</i> [[ time.strftime('%Y-%m-%d') ]] <i>at</i> [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="45.0,36.0,50.0,145.0,69.0,72.0,64.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P7">Date</para>
</td>
<td>
<para style="P7">J. code</para>
</td>
<td>
<para style="P7">Voucher Nb</para>
</td>
<td>
<para style="P7">Entry label</para>
</td>
<td>
<para style="P7">Debit</para>
</td>
<td>
<para style="P7">Credit</para>
</td>
<td>
<para style="P7">Progressive balance</para>
</td>
</tr>
</blockTable>
<para style="Text body">
<font color="white"> </font>
</para>
<section>
<para style="P8">[[ repeatIn(objects, 'p') ]]</para>
<para style="P9">[[ p.ref ]] [[ p.name ]]</para>
<blockTable colWidths="45.0,37.0,50.0,145.0,69.0,72.0,63.0" style="Table3">
<tr>
<td>
<para style="P10"><font face="Times-Roman">[[ repeatIn(lines(p), 'line') ]]</font>[[ line['date'] ]]</para>
</td>
<td>
<para style="P11">[[ line['code'] ]]</para>
</td>
<td>
<para style="P11">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P12">[[ line['name'] ]]</para>
</td>
<td>
<para style="P13">[[ line['debit'] and '%.2f' % line['debit'] or '' ]]</para>
</td>
<td>
<para style="P13">[[ line['credit'] and '%.2f' % line['credit'] or '' ]]</para>
</td>
<td>
<para style="P13">[[ line['progress'] and '%.2f' % line['progress'] or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="277.0,69.0,72.0,63.0" style="Table5">
<tr>
<td>
<para style="P14">Total for [[ p.ref ]] </para>
<para style="P14">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_debit_partner(p) ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_credit_partner(p) ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' %(sum_debit_partner(p) - sum_credit_partner(p)) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</section>
<para style="Text body">
<font color="white"> </font>
</para>
<blockTable colWidths="277.0,69.0,72.0,63.0" style="Table4">
<tr>
<td>
<para style="P14">Balance brought forward</para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_debit() ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' % sum_credit() ]]</para>
</td>
<td>
<para style="P15">[[ '%.2f' %(sum_debit() - sum_credit()) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,38 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from report import report_sxw
class account_invoice(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_invoice, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
})
report_sxw.report_sxw('report.account.invoice', 'account.invoice', 'addons/account/report/invoice.rml', parser=account_invoice)

View File

@ -0,0 +1,280 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="34.0" y1="28.0" width="527" height="786"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau8">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="LEFT"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="LEFT"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P11" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Italic" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Times-Bold" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P19" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P20" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P21" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P22" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT"/>
<paraStyle name="P23" fontName="Courier-Bold" fontSize="11.0" leading="14" alignment="CENTER"/>
<paraStyle name="P24" fontName="Courier-Bold" fontSize="12.0" leading="15" alignment="CENTER"/>
<paraStyle name="P25" fontName="Courier-Bold" fontSize="12.0" leading="15" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<para style="P1">[[ setLang(o.partner_id.lang) ]]</para>
<blockTable colWidths="295.0,232.0" style="Tableau2">
<tr>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="Standard">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
<para style="Standard">[[ o.address_invoice_id.title or '' ]] [[ o.address_invoice_id.name ]]</para>
<para style="Standard">[[ o.address_invoice_id.street ]]</para>
<para style="Standard">[[ o.address_invoice_id.street2 or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.state_id and o.address_invoice_id.state_id.name or '' ]]</para>
<para style="Standard">[[ o.address_invoice_id.country_id and o.address_invoice_id.country_id.name or '' ]]</para>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="Standard">Tél. : [[ o.address_invoice_id.phone or '' ]]</para>
<para style="Standard">Fax : [[ o.address_invoice_id.fax or '' ]]</para>
<para style="Standard">TVA : [[ o.partner_id.vat or '' ]]</para>
</td>
</tr>
</blockTable>
<para style="P3">
<font color="white"> </font>
</para>
<para style="P4">
<font face="Times-Roman">Invoice [[ (o.type=='out_invoice' or removeParentNode('font')) and '' ]]</font>
<font face="Times-Roman">Refund [[ (o.type=='out_refund' or removeParentNode('font')) and '' ]]</font>
<font face="Times-Roman">Supplier Refund [[ (o.type=='in_refund' or removeParentNode('font')) and '' ]]</font>
<font face="Times-Roman">Supplier Invoice [[ (o.type=='in_invoice' or removeParentNode('font')) and '' ]]</font>
<font face="Times-Roman">[[ o.number ]]</font>
</para>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P6">
<font face="Times-Roman">Document</font>
<font face="Times-Roman">:</font>
<font face="Times-Roman">[[o.name]]</font>
</para>
<para style="P6">
<font face="Times-Roman">Invoice Date: </font>
<font face="Times-Roman">[[o.date_invoice]]</font>
</para>
<para style="P7"><font face="Times-Roman">Customer Ref:</font> [[ o.address_invoice_id.partner_id.ref or '/' ]]</para>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau6">
<tr>
<td>
<para style="P8">Description</para>
</td>
<td>
<para style="P9">Taxes</para>
</td>
<td>
<para style="P9">Quantity</para>
</td>
<td>
<para style="P9">Unit Price</para>
</td>
<td>
<para style="P9">Disc.</para>
</td>
<td>
<para style="P9">Net Price</para>
</td>
</tr>
</blockTable>
<section>
<para style="P10">[[repeatIn(o.invoice_line,'l') ]]</para>
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau7">
<tr>
<td>
<para style="Table Contents">[[ l.name ]]</para>
</td>
<td>
<para style="P11">[[ ', '.join([lt.name for lt in l.invoice_line_tax_id]) ]]</para>
</td>
<td>
<para style="P12">[[ l.quantity ]] [[l.uos_id and l.uos_id.name or '' ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % l.price_unit ]]</para>
</td>
<td>
<para style="P12">[[ '%.3f' % (l.discount or 0.0) ]] </para>
</td>
<td>
<para style="P12">[[ '%.2f' %l.price_subtotal ]] [[o.currency_id.code ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="28.0,499.0" style="Tableau8">
<tr>
<td>
<para style="P13">[[ repeatIn((l.note and [l.note]) or [], 'note') ]]</para>
</td>
<td>
<para style="P14">[[ note or removeParentNode('table') ]] [[ setTag('para','xpre') ]]</para>
</td>
</tr>
</blockTable>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="215.0,313.0" style="Tableau3">
<tr>
<td>
<blockTable colWidths="81.0,73.0,60.0" style="Tableau4">
<tr>
<td>
<para style="P15">Tax</para>
</td>
<td>
<para style="P12">Base</para>
</td>
<td>
<para style="P12">Amount</para>
</td>
</tr>
<tr>
<td>
<para style="P16"><font face="Times-Roman">[[ repeatIn(o.tax_line,'t') ]]</font> [[ t.name ]]</para>
</td>
<td>
<para style="P17">[[ '%.2f' % t.base ]]</para>
</td>
<td>
<para style="P17">[[ '%.2f' % t.amount]]</para>
</td>
</tr>
</blockTable>
</td>
<td>
<blockTable colWidths="214.0,95.0" style="Tableau5">
<tr>
<td>
<para style="P18">Subtotal :</para>
</td>
<td>
<para style="P19">[[ '%.2f' % o.amount_untaxed ]] [[o.currency_id.code ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P18">Taxes :</para>
</td>
<td>
<para style="P19">[[ '%.2f' % o.amount_tax ]] [[o.currency_id.code ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P20">Total :</para>
</td>
<td>
<para style="P21">[[ '%.2f' % o.amount_total ]] [[o.currency_id.code ]]</para>
</td>
</tr>
</blockTable>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P22">[[ o.comment or '' ]] <font face="Times-Roman">[[ setTag('para','xpre') ]]</font></para>
<para style="P22">
<font color="white"> </font>
</para>
<para style="P22">[[ (o.payment_term and o.payment_term.note) or '' ]] <font face="Times-Roman">[[ setTag('para','xpre') ]]</font></para>
<para style="P23">
<font color="white"> </font>
</para>
<para style="P23">
<font color="white"> </font>
</para>
<para style="P24">
<font color="white"> </font>
</para>
<para style="P25">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,168 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import pooler
import time
from report import report_sxw
class partner_balance(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(partner_balance, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'lines': self.lines,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'sum_litige': self._sum_litige,
'sum_sdebit': self._sum_sdebit,
'sum_scredit': self._sum_scredit,
'solde_debit': self._solde_balance_debit,
'solde_credit': self._solde_balance_credit,
})
def preprocess(self, objects, data, ids):
self.cr.execute('select distinct partner_id from account_move_line where partner_id is not null and date>=%s and date<=%s', (data['form']['date1'], data['form']['date2']))
new_ids = [id for (id,) in self.cr.fetchall()]
self.cr.execute("SELECT a.id FROM account_account a LEFT JOIN account_account_type t ON (a.type=t.code) WHERE t.partner_account=TRUE")
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
self.partner_ids = ','.join(map(str, new_ids))
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
super(partner_balance, self).preprocess(objects, data, new_ids)
def lines(self):
if not self.partner_ids:
return []
#TODO: use an SQL CASE to compute sdebit and scredit
#CHECKME: est-ce que les "enlitige", il fautdrait pas tester l etat de la ligne aussi?
self.cr.execute(
"SELECT p.ref, p.name, sum(debit) as debit, sum(credit) as credit, " \
"(SELECT sum(debit-credit) FROM account_move_line WHERE partner_id=p.id AND date>=%s AND date<=%s AND blocked=TRUE) as enlitige " \
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
"WHERE partner_id IN (" + self.partner_ids + ") " \
"AND account_id IN (" + self.account_ids + ") " \
"AND l.date>=%s AND l.date<=%s " \
"AND l.state<>'draft' " \
"GROUP BY p.id, p.ref, p.name " \
"ORDER BY p.ref, p.name",
(self.datas['form']['date1'], self.datas['form']['date2'], self.datas['form']['date1'], self.datas['form']['date2']))
res = self.cr.dictfetchall()
for r in res:
r['sdebit'] = r['debit'] > r['credit'] and r['debit'] - r['credit']
r['scredit'] = r['credit'] > r['debit'] and r['credit'] - r['debit']
return res
def _sum_debit(self):
if not self.ids:
return 0.0
self.cr.execute(
'SELECT sum(debit) ' \
'FROM account_move_line ' \
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
"AND state<>'draft' " \
'AND date>=%s AND date<=%s',
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self):
if not self.ids:
return 0.0
self.cr.execute(
'SELECT sum(credit) ' \
'FROM account_move_line ' \
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
"AND state<>'draft' " \
'AND date>=%s AND date<=%s',
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_litige(self):
if not self.ids:
return 0.0
self.cr.execute(
'SELECT sum(debit-credit) ' \
'FROM account_move_line ' \
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
"AND state<>'draft' " \
'AND date>=%s AND date<=%s AND blocked=TRUE',
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_sdebit(self):
if not self.ids:
return 0.0
self.cr.execute(
'SELECT sum(debit-credit) ' \
'FROM (' \
'SELECT sum(debit), sum(credit) ' \
'FROM account_move_line ' \
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
'AND date>=%s AND date<=%s ' \
"AND state<>'draft' " \
'GROUP BY partner_id' \
') AS dc (debit,credit) ' \
'WHERE debit>credit',
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _sum_scredit(self):
if not self.ids:
return 0.0
self.cr.execute(
'SELECT sum(credit-debit) ' \
'FROM (' \
'SELECT sum(debit), sum(credit) ' \
'FROM account_move_line ' \
'WHERE partner_id IN (' + self.partner_ids + ') ' \
'AND account_id IN (' + self.account_ids + ') ' \
'AND date>=%s AND date<=%s ' \
"AND state<>'draft' " \
'GROUP BY partner_id' \
') AS dc (debit,credit) ' \
'WHERE credit>debit',
(self.datas['form']['date1'], self.datas['form']['date2']))
return self.cr.fetchone()[0] or 0.0
def _solde_balance_debit(self):
debit, credit = self._sum_debit(), self._sum_credit()
return debit > credit and debit - credit
def _solde_balance_credit(self):
debit, credit = self._sum_debit(), self._sum_credit()
return credit > debit and credit - debit
report_sxw.report_sxw('report.account.partner.balance', 'res.partner', 'addons/account/report/partner_balance.rml',parser=partner_balance)

View File

@ -0,0 +1,234 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" rightIndent="17.0" leftIndent="-0.0" fontName="Times-Bold" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="8.0" leading="10"/>
<paraStyle name="P14" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="145.0,186.0,151.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Third party balance</para>
</td>
<td>
<para style="P2"><i>From</i> [[ data['form']['date1'] ]]</para>
<para style="P2"><i>to</i> [[ data['form']['date2'] ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4"><i>Currency:</i> [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5"><i>Printing date:</i> [[ time.strftime('%Y-%m-%d') ]] <i>at</i> [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<blockTable colWidths="60.0,137.0,118.0,109.0,58.0" repeatRows="1" style="Table6">
<tr>
<td>
<para style="P6">Account number</para>
</td>
<td>
<para style="P6">Account name</para>
</td>
<td>
<para style="P6">Transactions</para>
</td>
<td>
<para style="P6">Balances</para>
</td>
<td>
<para style="P6">In dispute</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="197.0,60.0,58.0,55.0,54.0,58.0" repeatRows="1" style="Table2">
<tr>
<td>
<para style="P6">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P6">Debit</para>
</td>
<td>
<para style="P6">Credit</para>
</td>
<td>
<para style="P6">Debit</para>
</td>
<td>
<para style="P6">Credit</para>
</td>
<td>
<para style="P6">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P7">
<font color="white"> </font>
</para>
<blockTable colWidths="61.0,137.0,60.0,58.0,55.0,54.0,57.0" style="Table3">
<tr>
<td>
<para style="P8">[[ repeatIn(lines(), 'a') ]]<font face="Times-Roman">[[ a['ref'] ]]</font></para>
</td>
<td>
<para style="P9">[[ a['name'] ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % a['debit'] ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % a['credit'] ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % a['sdebit'] ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % a['scredit'] ]]</para>
</td>
<td>
<para style="P10">[[ '%.2f' % (a['enlitige'] or 0.0) ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="198.0,60.0,58.0,56.0,53.0,57.0" style="Table4">
<tr>
<td>
<para style="P11">Grand total</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_debit() ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_credit() ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_sdebit() ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_scredit() ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % sum_litige() ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P11">Balance</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P12">[[ '%.2f' % solde_debit() ]]</para>
</td>
<td>
<para style="P12">[[ '%.2f' % solde_credit() ]]</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P13"/>
<para style="P14">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,62 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import ir
from osv import osv
from report import report_sxw
import pooler
class report_rappel(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(report_rappel, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time' : time,
'adr_get' : self._adr_get,
'getLines' : self._lines_get,
})
def _adr_get(self, partner, type):
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type])
adr_id = addresses and addresses[type] or False
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
def _lines_get(self, partner):
part = pooler.get_pool(self.cr.dbname).get('res.partner')
acc = partner.property_account_receivable[0]
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
movelines = moveline_obj.search(self.cr, self.uid, [('partner_id','=',partner.id), ('account_id','=',acc), ('state','=','valid')])
movelines = moveline_obj.read(self.cr, self.uid, movelines)
return movelines
report_sxw.report_sxw('report.account.rappel', 'res.partner', 'addons/account/report/rappel.rml',parser=report_rappel)

View File

@ -0,0 +1,234 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="42.0" y1="28.0" width="511" height="786"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
<blockBackground colorName="#e6e6e6" start="6,0" stop="6,0"/>
<blockBackground colorName="#e6e6e6" start="7,0" stop="7,0"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="14.0" leading="17" alignment="LEFT"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT"/>
<paraStyle name="P9" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Times-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Times-Roman" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]]</para>
<blockTable colWidths="286.0,224.0" style="Tableau2">
<tr>
<td>
<para style="P2">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">[[ o.name ]]</para>
<para style="P4">[[ adr_get(o, 'invoice')['name'] ]]</para>
<para style="P4">[[ adr_get(o, 'invoice')['street'] ]]</para>
<para style="P4">[[ adr_get(o, 'invoice')['zip'] ]] [[ adr_get(o, 'invoice')['city'] ]]</para>
<para style="P4">[[ adr_get(o, 'invoice')['country_id'][1] ]]</para>
<para style="P4">
<font color="white"> </font>
</para>
<para style="P4">VAT: [[ o.vat ]]</para>
</td>
</tr>
</blockTable>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P6">
<font color="white"> </font>
</para>
<para style="P4"><font face="Times-Roman">Document</font><font face="Times-Roman">:</font> Customer account statement</para>
<para style="P4">
<font face="Times-Roman">Date: </font>
<font face="Times-Roman">[[ time.strftime('%d/%m/%Y') ]]</font>
</para>
<para style="P7"><font face="Times-Roman">Customer Ref:</font> [[ o.id ]]</para>
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">Dear Sir/Madam,</para>
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">Exception made if there was a mistake of ours, it seems that the following bills staid unpaid. Please, take appropriate measures in order to carry out this payment in the next 8 days.</para>
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at (+32).10.68.94.39.</para>
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">Best regards.</para>
<para style="P9">
<font color="white"> </font>
</para>
<blockTable colWidths="59.0,137.0,65.0,58.0,60.0,57.0,56.0,19.0" style="Tableau3">
<tr>
<td>
<para style="P10">Date</para>
</td>
<td>
<para style="P10">Description</para>
</td>
<td>
<para style="P10">Ref</para>
</td>
<td>
<para style="P10">Maturity date</para>
</td>
<td>
<para style="P11">Due</para>
</td>
<td>
<para style="P11">Paid</para>
</td>
<td>
<para style="P11">Maturity</para>
</td>
<td>
<para style="P11">Li.</para>
</td>
</tr>
<tr>
<td>
<para style="P12">
<font face="Times-Roman">[[repeatIn(getLines(o), 'line') ]]</font>
<font face="Times-Roman"> [[ line['date'] ]]</font>
</para>
</td>
<td>
<para style="P13">[[ line['name'] ]]</para>
</td>
<td>
<para style="P14">[[ line['ref'] ]]</para>
</td>
<td>
<para style="P14">[[ line['date_maturity'] ]]</para>
</td>
<td>
<para style="P15">[[ line['debit'] and '%.2f' % line['debit'] or '' ]]</para>
</td>
<td>
<para style="P16">[[ line['credit'] and '%.2f' % line['credit'] or '' ]]</para>
</td>
<td>
<para style="P16">[[ (line['date_maturity'] &lt; time.strftime('%Y-%m-%d')) and (line['debit'] - line['credit']) or '' ]]</para>
</td>
<td>
<para style="P16">[[ line['blocked'] and 'X' or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="318.0,61.0,56.0,56.0,19.0" style="Tableau6">
<tr>
<td>
<para style="P17">Sub-Total: </para>
</td>
<td>
<para style="P17">[[ '%.2f' % (reduce(lambda x,y: x+y['debit'], getLines(o), 0)) ]]</para>
</td>
<td>
<para style="P16">
<font face="Times-Bold">[[ '%.2f' % (reduce(lambda x,y: x+y['credit'], getLines(o), 0)) ]]</font>
</para>
</td>
<td>
<para style="P15">[[ reduce(lambda x,y: x+(y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] &lt; time.strftime('%Y-%m-%d'), getLines(o)), 0) ]]</para>
</td>
<td>
<para style="P18">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P17">Balance: </para>
</td>
<td>
<para style="P17">[[ '%.2f' % (reduce(lambda x,y: x+(y['debit'] - y['credit']), getLines(o), 0)) ]]</para>
</td>
<td>
<para style="P19">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P17">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P18">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P20">
<font face="Times-Roman">Total amount due: </font>
<font face="Times-Roman">[[ '%.2f' % (reduce(lambda x,y: x+(y['debit']-y['credit']), getLines(o), 0)) ]] [[ company.currency_id.code ]].</font>
</para>
<para style="P4">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -0,0 +1,74 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import pooler
from report import report_sxw
class tax_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context): #name, table, rml):
super(tax_report, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'get_period': self._get_period,
'get_codes': self._get_codes,
'get_general': self._get_general,
})
def _add_header(self, node):
return True
def _get_period(self, period_id):
return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
def _get_general(self, tax_code_id, period_id):
self.cr.execute('select sum(tax_amount) as tax_amount, sum(debit) as debit, sum(credit) as credit, count(*) as count, account_id from account_move_line where state<>%s and period_id=%d and tax_code_id=%d group by account_id', ('draft',period_id, tax_code_id))
res = self.cr.dictfetchall()
i = 0
while i<len(res):
res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
i+=1
#print '-'*50
#print 'GENERAL', res
return res
def _get_codes(self, period_id, parent=False, level=0):
tc = self.pool.get('account.tax.code')
ids = tc.search(self.cr, self.uid, [('parent_id','=',parent)])
res = []
for code in tc.browse(self.cr, self.uid, ids, {'period_id':period_id}):
res.append((' - '*level*2, code))
res += self._get_codes(period_id, code.id, level+1)
return res
report_sxw.report_sxw(
'report.account.vat.declaration',
'account.tax.code',
'addons/account/report/tax_report.rml',
parser=tax_report)

View File

@ -0,0 +1,166 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="42.0" y1="42.0" width="511" height="758"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="0,1" stop="0,1"/>
<blockBackground colorName="#e6e6e6" start="1,1" stop="1,1"/>
<blockBackground colorName="#e6e6e6" start="2,1" stop="2,1"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P6" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="6.0" leading="8"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="7.0" leading="9" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
<blockTable colWidths="139.0,220.0,152.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1">Tax Report</para>
</td>
<td>
<para style="P2"><i>Period:</i> [[ get_period(data['form']['period_id']) ]]</para>
</td>
</tr>
<tr>
<td>
<para style="Table Contents">[[ company.name ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4"><i>Currency:</i> [[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="Standard">
<font color="white"> </font>
</para>
<para style="P5"><i>Printing date: </i>[[ time.strftime('%Y-%m-%d') ]] <i>at</i> [[ time.strftime('%H:%M:%S') ]]</para>
<para style="P6">
<font color="white"> </font>
</para>
<blockTable colWidths="148.0,168.0,64.0,59.0,71.0" repeatRows="1" style="Tableau3">
<tr>
<td>
<para style="Table Heading">Tax Code / Account</para>
</td>
<td>
<para style="Table Heading">General Account</para>
</td>
<td>
<para style="Table Heading">Debit</para>
</td>
<td>
<para style="Table Heading">Credit</para>
</td>
<td>
<para style="Table Heading">Tax Amount</para>
</td>
</tr>
</blockTable>
<para style="P7">
<font color="white"> </font>
</para>
<section>
<para style="P7">[[ repeatIn(get_codes(data['form']['period_id']), 'o') ]]</para>
<blockTable colWidths="316.0,64.0,59.0,71.0" repeatRows="1" style="Tableau1">
<tr>
<td>
<para style="P8">[[ o[0] ]] [[ o[1].code ]] - [[ o[1].name ]]</para>
</td>
<td>
<para style="P8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">[[ o[1].sum_period and ('%.2f' % o[1].sum_period) or '' ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="44.0,273.0,62.0,60.0,72.0" repeatRows="1" style="Tableau2">
<tr>
<td>
<para style="P10">[[repeatIn(get_general(o[1], data['form']['period_id']), 'g') ]]</para>
</td>
<td>
<para style="P11">[[ g['account'].name ]]</para>
</td>
<td>
<para style="P12">[[ g['debit'] and '%.2f' % g['debit'] or '' ]]</para>
</td>
<td>
<para style="P12">[[ g['credit'] and '%.2f' % g['credit'] or '' ]]</para>
</td>
<td>
<para style="P12">[[ g['tax_amount'] and '%.2f' % g['tax_amount'] or '' ]]</para>
</td>
</tr>
</blockTable>
<para style="P13">
<font color="white"> </font>
</para>
</section>
</story>
</document>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<transfer-list>
<transfer type="fields" name="id">
<name type="field" name="name"/>
<partner_id type="field" name="partner_id.name"/>
<date type="field" name="date"/>
<type type="field" name="type"/>
<reference type="field" name="reference"/>
<amount type="field" name="amount"/>
<change type="field" name="change"/>
</transfer>
</transfer-list>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:import href="../../custom/corporate_defaults.xsl"/>
<xsl:import href="../../base/report/rml_template.xsl"/>
<xsl:variable name="page_format">a4_normal</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="rml"/>
</xsl:template>
<xsl:template name="stylesheet">
</xsl:template>
<xsl:template name="story">
<xsl:apply-templates select="transfer-list"/>
</xsl:template>
<xsl:template match="transfer-list">
<xsl:apply-templates select="transfer"/>
</xsl:template>
<xsl:template match="transfer">
<setNextTemplate name="other_pages"/>
<para>
<b t="1">Document</b>: <i><xsl:value-of select="name"/></i>
</para><para>
<b t="1">Type</b>: <i><xsl:value-of select="type"/></i>
</para><para>
<b t="1">Reference</b>: <i><xsl:value-of select="reference"/></i>
</para><para>
<b t="1">Partner ID</b>: <i><xsl:value-of select="partner_id"/></i>
</para><para>
<b t="1">Date</b>: <i><xsl:value-of select="date"/></i>
</para><para>
<b t="1">Amount</b>: <i><xsl:value-of select="amount"/></i>
</para>
<xsl:if test="number(change)>0">
<para>
<b t="1">Change</b>: <i><xsl:value-of select="change"/></i>
</para>
</xsl:if>
<setNextTemplate name="first_page"/>
<pageBreak/>
</xsl:template>
</xsl:stylesheet>

266
addons/account/transfer.py Normal file
View File

@ -0,0 +1,266 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import netsvc
from osv import fields, osv
import ir
class account_transfer(osv.osv):
_name = "account.transfer"
_description = "Money Transfer"
def _get_period(self, cr, uid, context):
periods = self.pool.get('account.period').find(cr, uid)
if periods:
return periods[0]
else:
return False
_columns = {
'name': fields.char('Description', size=64, required=True),
'state': fields.selection( (('draft','draft'),('posted','posted')),'State', readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner', states={'posted':[('readonly',True)]}),
'project_id': fields.many2one('account.analytic.account', 'Analytic Account', states={'posted':[('readonly',True)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}),
'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
'date': fields.date('Payment Date', required=True, states={'posted':[('readonly',True)]}),
'type': fields.selection([
('undefined','Undefined'),
('in_payment','Incoming Customer Payment'),
('out_payment','Outgoing Supplier Payment'),
('expense', 'Direct Expense'),
('transfer','Money Transfer'),
('change','Currency Change'),
('refund','Customer Refund'),
('sale','Manual Sale'),
# ('expense reimburse','Remboursement Depense')
], 'Transfer Type', required=True, states={'posted':[('readonly',True)]} ),
'reference': fields.char('Reference',size=64),
'account_src_id': fields.many2one('account.account', 'Source Account', required=True, states={'posted':[('readonly',True)]}),
'account_dest_id': fields.many2one('account.account', 'Destination Account', required=True, states={'posted':[('readonly',True)]}),
'amount': fields.float('Amount', digits=(16,2), required=True, states={'posted':[('readonly',True)]}),
'change': fields.float('Amount Changed', digits=(16,2), states={'posted':[('readonly',True)]}, readonly=True),
'move_id': fields.many2one('account.move', 'Entry', readonly=True),
'adjust_amount': fields.float('Adjustement amount', states={'posted':[('readonly',True)]}),
'adjust_account_id': fields.many2one('account.account', 'Adjustement Account', states={'posted':[('readonly',True)]}),
'invoice_id': fields.many2many('account.invoice','account_transfer_invoice','transfer_id','invoice_id','Invoices', states={'posted':[('readonly',True)]}, help="You can select customer or supplier invoice that are related to this payment. This is optionnal but if you specify the invoices, Tiny ERP will automatically reconcile the entries and mark invoices as paid."),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),
'state': lambda *a: 'draft',
'period_id' : _get_period,
}
def unlink(self, cr, uid, ids):
transfers = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for t in transfers:
if t['state']=='draft':
unlink_ids.append(t['id'])
else:
raise osv.except_osv('Invalid action !', 'Cannot delete transfer(s) which are already posted !')
osv.osv.unlink(self, cr, uid, unlink_ids)
return True
def _onchange_type_domain(self,cr,uid,ids,type):
type_acc={
'in_payment': ('receivable','cash'),
'out_payment': ('cash','payable'),
'expense': ('cash','expense'),
'transfer': ('cash','cash'),
'change': ('cash','cash'),
'refund': ('receivable','income'),
'sale': ('income','cash'),
}
d = {'account_src_id': [('type','<>','view')], 'account_dest_id': [('type','<>','view')]}
if type_acc.has_key(type):
d['account_src_id'].append(('type','=',type_acc[type][0]))
d['account_dest_id'].append(('type','=',type_acc[type][1]))
return d
def onchange_type(self, cr, uid, ids, type):
ro = {'change':type!='change',
'adjust_amount': type not in ('in_payment','out_payment'),
'adjust_account_id': type not in ('in_payment','out_payment')}
d=self._onchange_type_domain(cr,uid,ids,type)
return {'domain': d, 'value': {'account_src_id': False, 'account_dest_id': False}, 'readonly':ro}
def _onchange_account_domain(self,cr,uid,ids,type, account_src, account_dest):
d=self._onchange_type_domain(cr,uid,ids,type)
if type != 'change':
if account_src and not account_dest:
cr.execute("SELECT currency_id FROM account_account WHERE id=%d",(account_src,))
d['account_dest_id'].append(('currency_id','=',cr.fetchall()[0][0]))
if account_dest and not account_src:
cr.execute("SELECT currency_id FROM account_account WHERE id=%d",(account_dest,))
d['account_src_id'].append(('currency_id','=',cr.fetchall()[0][0]))
return d
def onchange_account(self, cr, uid, ids, type, account_src, account_dest):
d=self._onchange_account_domain(cr,uid,ids,type,account_src,account_dest)
return {'domain': d}
def onchange_partner(self, cr, uid, ids, type, partner_id):
if partner_id:
value={}
if type=='in_payment':
a = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_receivable[0]
value['account_src_id'] = a
value['account_dest_id'] = False
# compute the amount this partner owe us (the sum of all move lines which have not been matched)
cr.execute("SELECT COALESCE(SUM(debit-credit),0) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (a, partner_id))
value['amount'] = cr.fetchone()[0]
d = self._onchange_account_domain(cr,uid,ids,type, value['account_src_id'], value['account_dest_id'])
return {'domain': d, 'value': value}
elif type=='out_payment':
a = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_payable[0]
value['account_src_id'] = False
value['account_dest_id'] = a
# compute the amount we owe this partner (the sum of all move lines which have not been matched)
cr.execute("SELECT COALESCE(SUM(debit-credit),0) from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null and state<>'draft'", (a,partner_id))
value['amount'] = -cr.fetchone()[0]
# get the new domain
d = self._onchange_account_domain(cr,uid,ids,type, value['account_src_id'], value['account_dest_id'])
return {'domain': d, 'value': value}
return self.onchange_type(cr,uid,ids, type)
def pay_validate(self, cr, uid, ids, *args):
transfers = self.read(cr, uid, ids)
for pay in transfers:
if pay['state']!='draft':
continue
name = pay['name']
partner_id = (pay['partner_id'] or None) and pay['partner_id'][0]
project_id = (pay['project_id'] or None) and pay['project_id'][0]
# create two move lines (one for the source account and one for the destination account)
l = {
'name':name,
'journal_id': pay['journal_id'][0],
'period_id': pay['period_id'][0],
}
#CHECKME: why don't these two lines have period_id and journal_id defined?
l2 = {
'name':name,
'credit':pay['amount']<0 and -pay['amount'],
'debit':pay['amount']>0 and pay['amount'],
'account_id': pay['account_dest_id'][0],
'partner_id': partner_id
}
l1 = {
'name':name,
'debit':pay['amount']<0 and -pay['amount'],
'credit':pay['amount']>0 and pay['amount'],
'account_id': pay['account_src_id'][0],
'partner_id': partner_id
}
line_id = [l1, l2]
# possibly create two more lines if there is an adjustment
if False and pay['adjust_amount']:
if pay['adjust_account_id']:
la = l.copy()
la.update({'name': name+' adjustment', 'credit':pay['adjust_amount']<0 and -pay['adjust_amount'], 'debit':pay['adjust_amount']>0 and pay['adjust_amount'], 'account_id': pay['adjust_account_id'][0],})
line_id.append(la)
la = l.copy()
la.update({'name': name+' adjustment', 'debit':pay['adjust_amount']<0 and -pay['adjust_amount'], 'credit':pay['adjust_amount']>0 and pay['adjust_amount'], 'account_id': pay['account_src_id'][0],})
line_id.append(la)
else:
raise Exception('No Adjust Account !', 'missing adjust account')
# create the new move and its 2 (or 4) lines
move = l.copy()
move['line_id'] = [(0, 0, l) for l in line_id]
move_id = self.pool.get('account.move').create(cr, uid, move)
# get account_id depending on the type of transfer
tmp = {'in_payment':pay['account_src_id'][0], 'out_payment':pay['account_dest_id'][0]}
account_id = tmp.get(pay['type'], None)
if account_id and len(pay['invoice_id']):
# get the ids of all moves lines which 1) use account_id 2) are not matched 3) correspond to the selected invoices
inv_set = ",".join(map(str, pay["invoice_id"]))
query = "SELECT id FROM account_move_line "+\
"WHERE account_id=%d "+\
"AND reconcile_id IS NULL "+\
"AND move_id IN (SELECT move_id FROM account_invoice WHERE id IN ("+inv_set+"))"
cr.execute(query, (account_id,))
l_ids = [i[0] for i in cr.fetchall()]
if not l_ids:
print 'Error: no unmatched move line found for account %d and invoices %s while confirming transfer %d' % (account_id, pay['invoice_id'], pay['id'])
continue
# compute the sum of those lines
l_set = ",".join(map(str, l_ids))
cr.execute("SELECT SUM(debit-credit) FROM account_move_line WHERE id IN (" + l_set + ")")
s = cr.fetchone()[0]
# if that amount = the amount paid, match those lines (from the selected invoices) with the current transfer
types = {'out_payment': -1, 'in_payment': 1}
sign = types.get(pay['type'], 1)
if (s-(pay['adjust_amount'] or 0.0))==sign*pay['amount']:
# get the id of the move_line for the current transfer
cr.execute("SELECT id FROM account_move_line WHERE account_id=%d AND move_id=%d", (account_id,move_id))
l_ids.append(cr.fetchall()[0][0])
self.pool.get('account.move.line').reconcile(cr, uid, l_ids, writeoff_period_id=pay['period_id'][0], writeoff_journal_id=pay['journal_id'][0], writeoff_acc_id=pay['adjust_account_id'] and pay['adjust_account_id'][0])
else:
raise osv.except_osv('Warning !', 'Could not confirm payment because its amount (%.2f) is different from the selected invoice(s) amount (%.2f) !' % (pay['amount']+pay['adjust_amount'],s))
elif account_id and partner_id:
# compute the sum of all move lines for this account and partner which were not matched
cr.execute("SELECT SUM(debit-credit) FROM account_move_line WHERE account_id=%d AND partner_id=%d AND reconcile_id is null", (account_id, partner_id))
s = cr.fetchone()[0]
# if that amount is 0, we match those move lines together
if s==0.0:
cr.execute("select id from account_move_line where account_id=%d and partner_id=%d and reconcile_id is null", (account_id, partner_id))
ids2 = [id for (id,) in cr.fetchall()]
if len(ids2):
self.pool.get('account.move.line').reconcile(cr, uid, ids2, writeoff_period_id=pay['period_id'][0], writeoff_journal_id=pay['journal_id'][0], writeoff_acc_id=pay['adjust_account_id'] and pay['adjust_account_id'][0])
# change transfer state and assign it its move
self.write(cr, uid, [pay['id']], {'state':'posted', 'move_id': move_id})
return True
def pay_cancel(self, cr, uid, ids, *args):
pays = self.read(cr, uid, ids, ['move_id'])
self.pool.get('account.move').unlink(cr, uid, [ x['move_id'][0] for x in pays if x['move_id']] )
self.write(cr, uid, ids, {'state':'draft'})
return True
account_transfer()

View File

@ -0,0 +1,56 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard_automatic_reconcile
import wizard_reconcile_select
import wizard_unreconcile_select
import wizard_reconcile
import wizard_unreconcile
import wizard_refund
import wizard_pay_invoice
import wizard_journal
import wizard_journal_select
import wizard_bank_reconcile
import wizard_budget_spread
import wizard_subscription_generate
import wizard_aged_trial_balance
import wizard_budget_report
import wizard_grand_livre_report
import wizard_grand_livre_tiers_report
import wizard_account_balance_report
import wizard_partner_balance_report
import wizard_journal_close
import wizard_period_close
import wizard_fiscalyear_close
import wizard_vat
import wizard_invoice_state

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.account.balance', 'state':'end'}
}
}
wizard_report('account.account.balance.report')

View File

@ -0,0 +1,73 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import time
import datetime
from mx.DateTime import *
_aged_trial_form = """<?xml version="1.0"?>
<form string="Aged Trial Balance">
<field name="period_length"/>
</form>"""
_aged_trial_fields = {
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
}
def _calc_dates(self, cr, uid, data, context):
res = {}
period_length = data['form']['period_length']
if period_length<=0:
raise wizard.except_wizard('UserError', 'You must enter a period length that cannot be 0 or below !')
start = now()
for i in range(5)[::-1]:
stop = start-RelativeDateTime(days=period_length)
res[str(i)] = {
'name' : 'over '+str((5-i)*period_length)+' days',
'stop': start.strftime('%Y-%m-%d'),
'start' : stop.strftime('%Y-%m-%d'),
}
start = stop - RelativeDateTime(days=1)
return res
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Trial Balance')]},
},
'print': {
'actions': [_calc_dates],
'result': {'type':'print', 'report':'account.aged.trial.balance', 'state':'end'},
},
}
wizard_report('account.aged.trial.balance')

View File

@ -0,0 +1,323 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
import pooler
import time
#TODO:
# a rajouter comme questions ds le wizard:
# - account_id (et mettre wizard ds le menu et pas sur client_action_multi)
# - journal
# - compte d'ajustement
# - montant max (0,03)
# <field name="max_amount"/>
# - libelle write-off
# - devise principale ou secondaire
# devise secondaire = amount_currency
# si devise: pas prendre ceux avec montant_devise = 0
# a demander à fabien:
# - checkbox (comme ds sage) "lettrage rapide des comptes soldés"?
# pr creer ecriture: creer move.line avec period et journal dans le contexte
# faire methode sur period: get_current_period
_reconcile_form = '''<?xml version="1.0"?>
<form string="Reconciliation">
<separator string="Options" colspan="4"/>
<field name="account_ids" colspan="3" domain="[('reconcile','=',1)]"/>
<field name="date1"/>
<field name="date2"/>
<field name="power"/>
<separator string="Write-Off Move" colspan="4"/>
<field name="max_amount"/>
<field name="writeoff_acc_id"/>
<field name="journal_id"/>
<field name="period_id"/>
</form>'''
_reconcile_fields = {
'account_ids': {
'string': 'Account to reconcile',
'type': 'many2many',
'relation': 'account.account',
'domain': [('reconcile','=',1)],
'required': True
},
'writeoff_acc_id': {
'string': 'Account',
'type': 'many2one',
'relation': 'account.account',
'required': True
},
'journal_id': {
'string': 'Journal',
'type': 'many2one',
'relation': 'account.journal',
'required': True
},
'period_id': {
'string': 'Period',
'type': 'many2one',
'relation': 'account.period',
'required': True
},
'max_amount': {
'string': 'Maximum write-off amount',
'type': 'float',
},
#'currency': {
# 'string': 'Reconcile in',
# 'type': 'selection',
# 'selection': [('current','current currency'), ('secondary','secondary currency')],
# 'required': True
#},
'power': {
'string': 'Power',
'type': 'selection',
'selection': [(p,str(p)) for p in range(2, 10)],
'required': True
},
'date1': {
'string': 'Start of period',
'type': 'date',
'required': True,
'default': lambda *a: time.strftime('%Y-01-01')
},
'date2': {
'string': 'End of period',
'type': 'date',
'required': True,
'default': lambda *a: time.strftime('%Y-%m-%d')
},
}
_result_form = '''<?xml version="1.0"?>
<form string="Reconciliation result">
<field name="reconciled"/>
<newline/>
<field name="unreconciled"/>
</form>'''
_result_fields = {
'reconciled': {
'string': 'Reconciled transactions',
'type': 'integer',
'readonly': True
},
'unreconciled': {
'string': 'Not reconciled transactions',
'type': 'integer',
'readonly': True
},
}
#TODO: cleanup and comment this code... For now, it is awfulllll
# (way too complex, and really slow)...
def do_reconcile(cr, uid, credits, debits, max_amount, power, writeoff_acc_id, period_id, journal_id, context={}):
# for one value of a credit, check all debits, and combination of them
# depending on the power. It starts with a power of one and goes up
# to the max power allowed
def check2(value, move_list, power):
def check(value, move_list, power):
for i in range(len(move_list)):
move = move_list[i]
if power == 1:
if abs(value - move[1]) <= max_amount + 0.00001:
return [move[0]]
else:
del move_list[i]
res = check(value - move[1], move_list, power-1)
move_list[i:i] = [move]
if res:
res.append(move[0])
return res
return False
for p in range(1, power+1):
res = check(value, move_list, p)
if res:
return res
return False
# for a list of credit and debit and a given power, check if there
# are matching tuples of credit and debits, check all debits, and combination of them
# depending on the power. It starts with a power of one and goes up
# to the max power allowed
def check4(list1, list2, power):
def check3(value, list1, list2, list1power, power):
for i in range(len(list1)):
move = list1[i]
if list1power == 1:
res = check2(value + move[1], list2, power - 1)
if res:
return ([move[0]], res)
else:
del list1[i]
res = check3(value + move[1], list1, list2, list1power-1, power-1)
list1[i:i] = [move]
if res:
x, y = res
x.append(move[0])
return (x, y)
return False
for p in range(1, power):
res = check3(0, list1, list2, p, power)
if res:
return res
return False
def check5(list1, list2, max_power):
for p in range(2, max_power+1):
res = check4(list1, list2, p)
if res:
return res
ok = True
reconciled = 0
move_line_obj = pooler.get_pool(cr.dbname).get('account.move.line')
while credits and debits and ok:
res = check5(credits, debits, power)
if res:
move_line_obj.reconcile(cr, uid, res[0] + res[1], 'auto', writeoff_acc_id, period_id, journal_id, context)
reconciled += len(res[0]) + len(res[1])
credits = [(id, credit) for (id, credit) in credits if id not in res[0]]
debits = [(id, debit) for (id, debit) in debits if id not in res[1]]
else:
ok = False
return (reconciled, len(credits)+len(debits))
def _reconcile(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
move_line_obj = pooler.get_pool(cr.dbname).get('account.move.line')
form = data['form']
max_amount = form.get('max_amount', 0.0)
power = form['power']
reconciled = unreconciled = 0
if not form['account_ids']:
return {'reconciled':0, 'unreconciled':[0]}
for account_id in form['account_ids'][0][2]:
# reconcile automatically all transactions from partners whose balance is 0
cr.execute(
"SELECT partner_id " \
"FROM account_move_line " \
"WHERE account_id=%d " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"GROUP BY partner_id " \
"HAVING ABS(SUM(debit-credit)) < %f AND count(*)>0",
(account_id, max_amount))
partner_ids = [id for (id,) in cr.fetchall()]
for partner_id in partner_ids:
cr.execute(
"SELECT id " \
"FROM account_move_line " \
"WHERE account_id=%d " \
"AND partner_id=%d " \
"AND state <> 'draft' " \
"AND reconcile_id IS NULL",
(account_id, partner_id))
line_ids = [id for (id,) in cr.fetchall()]
if len(line_ids):
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
reconciled += len(line_ids)
# get the list of partners who have more than one unreconciled transaction
cr.execute(
"SELECT partner_id " \
"FROM account_move_line " \
"WHERE account_id=%d " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"GROUP BY partner_id " \
"HAVING count(*)>1",
(account_id,))
partner_ids = [id for (id,) in cr.fetchall()]
#filter?
for partner_id in partner_ids:
# get the list of unreconciled 'debit transactions' for this partner
cr.execute(
"SELECT id, debit " \
"FROM account_move_line " \
"WHERE account_id=%d " \
"AND partner_id=%d " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND debit > 0",
(account_id, partner_id))
debits = cr.fetchall()
# get the list of unreconciled 'credit transactions' for this partner
cr.execute(
"SELECT id, credit " \
"FROM account_move_line " \
"WHERE account_id=%d " \
"AND partner_id=%d " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " \
"AND credit > 0",
(account_id, partner_id))
credits = cr.fetchall()
(rec, unrec) = do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
reconciled += rec
unreconciled += unrec
# add the number of transactions for partners who have only one
# unreconciled transactions to the unreconciled count
partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or ''
cr.execute(
"SELECT count(*) " \
"FROM account_move_line " \
"WHERE account_id=%d " \
"AND reconcile_id IS NULL " \
"AND state <> 'draft' " + partner_filter,
(account_id,))
additional_unrec = cr.fetchone()[0]
return {'reconciled':reconciled, 'unreconciled':unreconciled+additional_unrec}
class wiz_reconcile(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':_reconcile_form, 'fields':_reconcile_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
},
'reconcile': {
'actions': [_reconcile],
'result': {'type':'form', 'arch':_result_form, 'fields':_result_fields, 'state':[('end','OK')]}
}
}
wiz_reconcile('account.automatic.reconcile')

View File

@ -0,0 +1,69 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="journal_id"/>
</form>''' % ('Bank reconciliation',)
_journal_fields = {
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
cr.execute('select default_credit_account_id from account_journal where id=%d', (form['journal_id'],))
account_id = cr.fetchone()[0]
if not account_id:
raise 'You have to define the bank account\nin the journal definition for reconciliation.'
return {
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id),
'name': 'Saisie Standard',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': False,
'context': "{'journal_id':%d}" % (form['journal_id'],),
'type': 'ir.actions.act_window'
}
class wiz_journal(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for bank reconciliation')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_journal('account.move.bank.reconcile')

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.budget', 'state':'end'}
}
}
wizard_report('account.budget.report')

View File

@ -0,0 +1,63 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
_spread_form = '''<?xml version="1.0"?>
<form string="Spread">
<field name="fiscalyear"/>
<newline/>
<field name="quantity"/>
<field name="amount"/>
</form>'''
_spread_fields = {
'fiscalyear': {'string':'Fiscal Year', 'type':'many2one', 'relation':'account.fiscalyear', 'required':True},
'quantity': {'string':'Quantity', 'type':'float', 'digits':(16,2)},
'amount': {'string':'Amount', 'type':'float', 'digits':(16,2)},
}
class wizard_budget_spread(wizard.interface):
def _spread(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
form = data['form']
res = service.execute(cr.dbname, uid, 'account.budget.post', 'spread', data['ids'], form['fiscalyear'], form['quantity'], form['amount'])
return {}
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':_spread_form, 'fields':_spread_fields, 'state':[('end','Cancel'),('spread','Spread')]}
},
'spread': {
'actions': [_spread],
'result': {'type':'state', 'state':'end'}
}
}
wizard_budget_spread('account.budget.spread')

View File

@ -0,0 +1,135 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import osv
import pooler
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Fiscal Year">
<field name="fy_id"/>
<field name="fy2_id"/>
<field name="report_new"/>
<field name="report_name" colspan="3"/>
<field name="report_journal" colspan="3"/>
<separator string="Are you sure ?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
'fy2_id': {'string':'New Fiscal Year', 'type':'many2one', 'relation': 'account.fiscalyear', 'domain':[('state','=','draft')], 'required':True},
'report_new': {'string':'Create new entries', 'type':'boolean', 'required':True, 'default': lambda *a:True},
'report_name': {'string':'Name of new entries', 'type':'char', 'size': 64, 'required':True},
'report_journal': {'string':'New Entries Journal', 'type':'many2one', 'relation': 'account.journal', 'required':True},
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_load(self, cr, uid, data, context):
data['form']['report_new'] = True
data['form']['report_name'] = 'End of Fiscal Year Entry'
return data['form']
def _data_save(self, cr, uid, data, context):
if not data['form']['sure']:
raise wizard.except_wizard('UserError', 'Closing of fiscal year canceled, please check the box !')
pool = pooler.get_pool(cr.dbname)
fy_id = data['form']['fy_id']
cr.execute('update account_journal_period set state=%s where period_id in (select id from account_period where fiscalyear_id=%d)', ('done',fy_id))
cr.execute('update account_period set state=%s where fiscalyear_id=%d', ('done',fy_id))
cr.execute('update account_fiscalyear set state=%s where id=%d', ('done',fy_id))
if data['form']['report_new']:
period = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids[0]
cr.execute('select id from account_account')
ids = map(lambda x: x[0], cr.fetchall())
for account in pool.get('account.account').browse(cr, uid, ids):
if account.close_method=='none':
continue
if account.close_method=='balance':
if abs(account.balance)>0.0001:
pool.get('account.move.line').create(cr, uid, {
'debit': account.balance>0 and account.balance,
'credit': account.balance<0 and -account.balance,
'name': data['form']['report_name'],
'date': period.date_start,
'journal_id': data['form']['report_journal'],
'period_id': period.id,
'account_id': account.id
}, {'journal_id': data['form']['report_journal'], 'period_id':period.id})
if account.close_method=='unreconciled':
offset = 0
limit = 100
while True:
cr.execute('select name,quantity,debit,credit,account_id,ref,amount_currency,currency_id,blocked,partner_id,date_maturity,date_created from account_move_line where account_id=%d and period_id in (select id from account_period where fiscalyear_id=%d) and reconcile_id is NULL order by id limit %d offset %d', (account.id,fy_id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
move.update({
'date': period.date_start,
'journal_id': data['form']['report_journal'],
'period_id': period.id,
})
pool.get('account.move.line').create(cr, uid, move, {'journal_id': data['form']['report_journal'], 'period_id':period.id})
offset += limit
if account.close_method=='detail':
offset = 0
limit = 100
while True:
cr.execute('select name,quantity,debit,credit,account_id,ref,amount_currency,currency_id,blocked,partner_id,date_maturity,date_created from account_move_line where account_id=%d and period_id in (select id from account_period where fiscalyear_id=%d) order by id limit %d offset %d', (account.id,fy_id, limit, offset))
result = cr.dictfetchall()
if not result:
break
for move in result:
move.update({
'date': period.date_start,
'journal_id': data['form']['report_journal'],
'period_id': period.id,
})
pool.get('account.move.line').create(cr, uid, move)
offset += limit
cr.execute('update account_move_line set active=False where period_id in (select id from account_period where fiscalyear_id=%d)', (fy_id,))
return {}
class wiz_journal_close(wizard.interface):
states = {
'init': {
'actions': [_data_load],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Fiscal Year')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close('account.fiscalyear.close')

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.grand.livre', 'state':'end'}
}
}
wizard_report('account.grand.livre.report')

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.grand.livre.tiers', 'state':'end'}
}
}
wizard_report('account.grand.livre.tiers.report')

View File

@ -0,0 +1,62 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
def _invoice_confirm(self, cr, uid, data, context):
wf_service = netsvc.LocalService('workflow')
for id in data['ids']:
wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_open', cr)
return {}
class wizard_invoice_confirm(wizard.interface):
states = {
'init': {
'actions': [_invoice_confirm],
'result': {'type':'state', 'state':'end'}
}
}
wizard_invoice_confirm('account.invoice.state.confirm')
def _invoice_cancel(self, cr, uid, data, context):
wf_service = netsvc.LocalService('workflow')
for id in data['ids']:
wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)
return {}
class wizard_invoice_cancel(wizard.interface):
states = {
'init': {
'actions': [_invoice_cancel],
'result': {'type':'state', 'state':'end'}
}
}
wizard_invoice_cancel('account.invoice.state.cancel')

View File

@ -0,0 +1,80 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
from osv import osv
import pooler
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="journal_id"/>
<newline/>
<field name="period_id"/>
</form>''' % ('Saisies des ecritures',)
_journal_fields = {
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True}
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
view_res = cr.fetchone()
jp = pooler.get_pool(cr.dbname).get('account.journal.period')
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
if not len(ids):
name = pooler.get_pool(cr.dbname).get('account.journal').read(cr, uid, [form['journal_id']])[0]['name']
state = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['state']
if state == 'done':
raise wizard.except_wizard('UserError', 'This period is already closed !')
jp.create(cr, uid, {'name':name, 'period_id': form['period_id'], 'journal_id':form['journal_id']})
return {
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (form['journal_id'],form['period_id']),
'name': 'Saisie Standard',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': view_res,
'context': "{'journal_id':%d, 'period_id':%d}" % (form['journal_id'],form['period_id']),
'type': 'ir.actions.act_window'
}
class wiz_journal(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open Journal')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_journal('account.move.journal')

View File

@ -0,0 +1,81 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Journal">
<separator string="Close the journal" colspan="4"/>
<field name="debit"/>
<field name="credit"/>
<field name="count"/>
<separator string="Are you sure ?" colspan="4"/>
<field name="sur"/>
</form>'''
_transaction_fields = {
'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
'count': {'string':'Count', 'type':'float', 'readonly':True},
'sur': {'string':'Check this box', 'type':'boolean'},
}
def _data_load(self, cr, uid, data, context):
data['form']['credit'] = 0
data['form']['debit'] = 0
data['form']['count'] = 0
for id in data['ids']:
cr.execute('select sum(credit), sum(debit), count(*) from account_move_line where journal_id=%d and period_id=%d', result)
result = cr.fetchone()
data['form']['credit'] += result[0] or 0.0
data['form']['debit'] += result[1] or 0.0
data['form']['count'] += result[2] or 0.0
return data['form']
def _data_save(self, cr, uid, data, context):
if data['form']['sur']:
for id in data['ids']:
cr.execute('select journal_id,period_id from account_journal_period where id=%d', (id,))
result = cr.fetchone()
cr.execute('delete from account_move_line where journal_id=%d and period_id=%d and state=\'draft\'', result)
cr.execute('update account_journal_period set state=%s where id=%d', ('done', id))
return {}
class wiz_journal_close(wizard.interface):
states = {
'init': {
'actions': [_data_load],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Journal')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close('account.journal.period.close')

View File

@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
def _action_open_window(self, cr, uid, data, context):
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
view_res = cr.fetchone()
cr.execute('select journal_id,period_id from account_journal_period where id=%d', (data['id'],))
journal_id,period_id = cr.fetchone()
return {
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (journal_id,period_id),
'name': 'Saisie Standard',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.move.line',
'view_id': view_res,
'context': "{'journal_id':%d, 'period_id':%d}" % (journal_id,period_id),
'type': 'ir.actions.act_window'
}
class wiz_journal(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_journal('account.move.journal.select')

View File

@ -0,0 +1,54 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.partner.balance', 'state':'end'}
}
}
wizard_report('account.partner.balance.report')

View File

@ -0,0 +1,111 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
import osv
import time
import pooler
pay_form = '''<?xml version="1.0"?>
<form string="Pay invoice">
<field name="amount"/>
<field name="dest_account_id"/>
<field name="journal_id"/>
<field name="period_id"/>
</form>'''
pay_fields = {
'amount': {'string': 'Amount paid', 'type':'float', 'required':True},
'dest_account_id': {'string':'Payment to Account', 'type':'many2one', 'required':True, 'relation':'account.account', 'domain':[('type','=','cash')]},
'journal_id': {'string': 'Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
}
def _pay_and_reconcile(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
form = data['form']
account_id = form.get('writeoff_acc_id', False)
period_id = form.get('period_id', False)
journal_id = form.get('journal_id', False)
service.execute(cr.dbname, uid, 'account.invoice', 'pay_and_reconcile', [data['id']], form['amount'], form['dest_account_id'], journal_id, account_id, period_id, journal_id, context)
return {}
def _trans_reconcile(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
return {}
def _wo_check(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
if data['form']['amount'] == invoice.amount_total:
return 'reconcile'
return 'addendum'
_transaction_add_form = '''<?xml version="1.0"?>
<form string="Information addendum">
<separator string="Write-Off Move" colspan="4"/>
<field name="writeoff_acc_id"/>
</form>'''
_transaction_add_fields = {
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
}
def _get_value_addendum(self, cr, uid, data, context={}):
return {}
def _get_period(self, cr, uid, data, context={}):
pool = pooler.get_pool(cr.dbname)
ids = pool.get('account.period').find(cr, uid, context=context)
period_id = False
if len(ids):
period_id = ids[0]
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
return {'period_id': period_id, 'amount': invoice.amount_total}
class wizard_pay_invoice(wizard.interface):
states = {
'init': {
'actions': [_get_period],
'result': {'type':'form', 'arch':pay_form, 'fields':pay_fields, 'state':[('end','Cancel'),('writeoff_check','Pay Invoice')]}
},
'writeoff_check': {
'actions': [],
'result' : {'type': 'choice', 'next_state': _wo_check }
},
'addendum': {
'actions': [_get_value_addendum],
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Pay and reconcile')]}
},
'reconcile': {
'actions': [_pay_and_reconcile],
'result': {'type':'state', 'state':'end'}
}
}
wizard_pay_invoice('account.invoice.pay')

View File

@ -0,0 +1,61 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
_transaction_form = '''<?xml version="1.0"?>
<form string="Close Period">
<separator string="Are you sure ?" colspan="4"/>
<field name="sure"/>
</form>'''
_transaction_fields = {
'sure': {'string':'Check this box', 'type':'boolean'},
}
def _data_save(self, cr, uid, data, context):
mode = 'done'
if data['form']['sure']:
for id in data['ids']:
cr.execute('update account_journal_period set state=%s where period_id=%d', (mode, id))
cr.execute('update account_period set state=%s where id=%d', (mode, id))
return {}
class wiz_journal_close(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Period')]}
},
'close': {
'actions': [_data_save],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_journal_close('account.period.close')

View File

@ -0,0 +1,120 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
import time
import osv
import pooler
_transaction_form = '''<?xml version="1.0"?>
<form string="Reconciliation">
<separator string="Reconciliation transactions" colspan="4"/>
<field name="trans_nbr"/>
<newline/>
<field name="credit"/>
<field name="debit"/>
<separator string="Write-Off" colspan="4"/>
<field name="writeoff"/>
</form>'''
_transaction_fields = {
'trans_nbr': {'string':'# of Transaction', 'type':'integer', 'readonly':True},
'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
'writeoff': {'string':'Write-Off amount', 'type':'float', 'readonly':True},
}
def _trans_rec_get(self, cr, uid, data, context={}):
service = netsvc.LocalService("object_proxy")
res = filter(lambda x: not x['reconcile_id'], service.execute(cr.dbname, uid, 'account.move.line', 'read', data['ids']))
credit = debit = 0
account_id = False
for trans in res:
credit += trans['credit']
debit += trans['debit']
account_id = trans['account_id'][0]
return {'trans_nbr': len(res), 'account_id': account_id, 'credit': credit, 'debit': debit, 'writeoff': debit - credit}
def _trans_rec_reconcile(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
form = data['form']
account_id = form.get('writeoff_acc_id', False)
period_id = form.get('period_id', False)
journal_id = form.get('journal_id', False)
service.execute(cr.dbname, uid, 'account.move.line', 'reconcile', data['ids'], 'manual', account_id, period_id, journal_id, context)
return {}
def _wo_check(self, cr, uid, data, context):
if data['form']['writeoff'] == 0:
return 'reconcile'
return 'addendum'
_transaction_add_form = '''<?xml version="1.0"?>
<form string="Information addendum">
<separator string="Write-Off Move" colspan="4"/>
<field name="journal_id"/>
<field name="period_id"/>
<field name="writeoff_acc_id"/>
</form>'''
_transaction_add_fields = {
'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'period_id': {'string': 'Write-Off Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
}
def _trans_rec_addendum(self, cr, uid, data, context={}):
pool = pooler.get_pool(cr.dbname)
ids = pool.get('account.period').find(cr, uid, context=context)
period_id = False
if len(ids):
period_id = ids[0]
return {'period_id':period_id}
class wiz_reconcile(wizard.interface):
states = {
'init': {
'actions': [_trans_rec_get],
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('writeoff_check','Reconcile')]}
},
'writeoff_check': {
'actions': [],
'result' : {'type' : 'choice', 'next_state': _wo_check }
},
'addendum': {
'actions': [_trans_rec_addendum],
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
},
'reconcile': {
'actions': [_trans_rec_reconcile],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_reconcile('account.move.line.reconcile')

View File

@ -0,0 +1,63 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="account_id"/>
</form>''' % ('Reconciliation',)
_journal_fields = {
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
return {
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['form']['account_id'],
'name': 'Reconciliation',
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
class wiz_rec_select(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for reconciliation')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_rec_select('account.move.line.reconcile.select')

View File

@ -0,0 +1,64 @@
##############################################################################
#
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import pooler
sur_form = '''<?xml version="1.0"?>
<form string="Refund Invoice">
<label string="Are you sure you want to refund this invoice ?"/>
</form>'''
sur_fields = {
}
class wiz_refund(wizard.interface):
def _invoice_refund(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
ids = pool.get('account.invoice').refund(cr, uid, data['ids'])
return {
'domain': "[('id','in', ["+','.join(map(str,ids))+"])]",
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window'
}
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':sur_form, 'fields':sur_fields, 'state':[('end','Cancel'),('refund','Refund Invoice')]}
},
'refund': {
'actions': [],
'result': {'type':'action', 'action':_invoice_refund, 'state':'end'}
}
}
wiz_refund('account.invoice.refund')

View File

@ -0,0 +1,65 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
# Fabien Pinckaers <fp@tiny.Be>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
import wizard
import pooler
#
# TODO: add an intermediate screen for checks
#
_subscription_form = '''<?xml version="1.0"?>
<form string="%s">
<seperator string="Generate entries before:" colspan="4"/>
<field name="date"/>
</form>''' % ('Subscription Compute',)
_subscription_fields = {
'date': {'string':'Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
}
class wiz_subscription(wizard.interface):
def _action_generate(self, cr, uid, data, context):
cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['form']['date'],))
ids = map(lambda x: x[0], cr.fetchall())
pooler.get_pool(cr.dbname).get('account.subscription.line').move_create(cr, uid, ids)
return {}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_subscription_form, 'fields':_subscription_fields, 'state':[('end','Cancel'),('generate','Compute Entry Dates')]}
},
'generate': {
'actions': [_action_generate],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_subscription('account.subscription.generate')

View File

@ -0,0 +1,48 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import pooler
def _trans_unrec(self, cr, uid, data, context):
recs = pooler.get_pool(cr.dbname).get('account.move.line').read(cr, uid, data['ids'], ['reconcile_id',])
recs = filter(lambda x: x['reconcile_id'], recs)
rec_ids = [rec['reconcile_id'][0] for rec in recs]
if len(rec_ids):
cr.execute('update account_move_line set state=\'valid\' where reconcile_id in ('+','.join(map(str,rec_ids))+')')
pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, rec_ids)
return {}
class wiz_unreconcile(wizard.interface):
states = {
'init': {
'actions': [_trans_unrec],
'result': {'type': 'state', 'state':'end'}
}
}
wiz_unreconcile('account.move.line.unreconcile')

View File

@ -0,0 +1,62 @@
##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
_journal_form = '''<?xml version="1.0"?>
<form string="%s">
<field name="account_id"/>
</form>''' % ('Unreconciliation',)
_journal_fields = {
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
}
def _action_open_window(self, cr, uid, data, context):
return {
'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['form']['account_id'],
'name': 'Unreconciliation',
'view_type': 'form',
'view_mode': 'tree,form',
'view_id': False,
'res_model': 'account.move.line',
'type': 'ir.actions.act_window'
}
class wiz_unrec_select(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for unreconciliation')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
wiz_unrec_select('account.move.line.unreconcile.select')

View File

Some files were not shown because too many files have changed in this diff Show More