[UPD] Update fdate from Principal Branch

bzr revid: ytello@cubicerp.com-20120216165726-i6jahgmrn4y2w0eq
This commit is contained in:
Yury Tello 2012-02-16 11:57:26 -05:00
commit d172292b88
8198 changed files with 1733937 additions and 976480 deletions

View File

@ -29,11 +29,12 @@ import account_bank
import account_cash_statement
import account_move_line
import account_analytic_line
import account_financial_report
import wizard
import report
import product
import ir_sequence
import company
import res_currency
import edi
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -19,11 +19,11 @@
#
##############################################################################
{
"name" : "Accounting and Financial Management",
"name" : "eInvoicing",
"version" : "1.1",
"author" : "OpenERP SA",
"category": 'Accounting & Finance',
'complexity': "normal",
'complexity': "easy",
"description": """
Accounting and Financial Management.
====================================
@ -53,7 +53,7 @@ module named account_voucher.
'website': 'http://www.openerp.com',
'images' : ['images/accounts.jpeg','images/bank_statement.jpeg','images/cash_register.jpeg','images/chart_of_accounts.jpeg','images/customer_invoice.jpeg','images/journal_entries.jpeg'],
'init_xml': [],
"depends" : ["base_setup", "product", "analytic", "process","board"],
"depends" : ["base_setup", "product", "analytic", "process", "board", "edi"],
'update_xml': [
'security/account_security.xml',
'security/ir.model.access.csv',
@ -69,6 +69,7 @@ module named account_voucher.
'wizard/account_period_close_view.xml',
'account_view.xml',
'account_report.xml',
'account_financial_report_data.xml',
'wizard/account_report_common_view.xml',
'wizard/account_invoice_refund_view.xml',
'wizard/account_fiscalyear_close_state.xml',
@ -104,6 +105,7 @@ module named account_voucher.
'account_invoice_view.xml',
'partner_view.xml',
'data/account_data.xml',
'data/data_account_type.xml',
'account_invoice_workflow.xml',
'project/project_view.xml',
'project/project_report.xml',
@ -121,9 +123,9 @@ module named account_voucher.
'ir_sequence_view.xml',
'company_view.xml',
'board_account_view.xml',
"wizard/account_report_profit_loss_view.xml",
"wizard/account_report_balance_sheet_view.xml",
"account_bank_view.xml"
"edi/invoice_action_data.xml",
"account_bank_view.xml",
"account_pre_install.yml"
],
'demo_xml': [
'demo/account_demo.xml',
@ -139,18 +141,17 @@ module named account_voucher.
'test/account_change_currency.yml',
'test/chart_of_account.yml',
'test/account_period_close.yml',
'test/account_fiscalyear_close_state.yml',
'test/account_use_model.yml',
'test/account_validate_account_move.yml',
'test/account_fiscalyear_close.yml',
'test/account_bank_statement.yml',
'test/account_cash_statement.yml',
'test/test_edi_invoice.yml',
'test/account_report.yml',
],
'test/account_fiscalyear_close_state.yml', #last test, as it will definitively close the demo fiscalyear
],
'installable': True,
'active': False,
'auto_install': False,
'certificate': '0080331923549',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,6 @@
#
##############################################################################
import time
from osv import fields
from osv import osv
from tools.translate import _
@ -41,7 +39,7 @@ class account_analytic_line(osv.osv):
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),
'date': fields.date.context_today,
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c),
}
_order = 'date desc'

View File

@ -26,6 +26,8 @@ class bank(osv.osv):
_inherit = "res.partner.bank"
_columns = {
'journal_id': fields.many2one('account.journal', 'Account Journal', help="This journal will be created automatically for this bank account when you save the record"),
'currency_id': fields.related('journal_id', 'currency', type="many2one", relation='res.currency', readonly=True,
string="Currency", help="Currency of the related account journal."),
}
def create(self, cr, uid, data, context={}):
result = super(bank, self).create(cr, uid, data, context=context)
@ -37,15 +39,23 @@ class bank(osv.osv):
self.post_write(cr, uid, ids, context=context)
return result
def _prepare_name(self, bank):
"Return the name to use when creating a bank journal"
return (bank.bank_name or '') + ' ' + bank.acc_number
def post_write(self, cr, uid, ids, context={}):
if isinstance(ids, (int, long)):
ids = [ids]
obj_acc = self.pool.get('account.account')
obj_data = self.pool.get('ir.model.data')
for bank in self.browse(cr, uid, ids, context):
if bank.company_id and not bank.journal_id:
# Find the code and parent of the bank account to create
dig = 6
current_num = 1
ids = obj_acc.search(cr, uid, [('type','=','liquidity')], context=context)
ids = obj_acc.search(cr, uid, [('type','=','liquidity')], context=context)
# No liquidity account exists, no template available
if not ids: continue
@ -57,10 +67,9 @@ class bank(osv.osv):
if not ids:
break
current_num += 1
name = self._prepare_name(bank)
acc = {
'name': (bank.bank_name or '')+' '+bank.acc_number,
'currency_id': bank.company_id.currency_id.id,
'name': name,
'code': new_code,
'type': 'liquidity',
'user_type': ref_acc_bank_temp.user_type.id,
@ -74,7 +83,7 @@ class bank(osv.osv):
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')])
data = obj_data.browse(cr, uid, data_id[0], context=context)
view_id_cash = data.res_id
jour_obj = self.pool.get('account.journal')
new_code = 1
while True:
@ -86,12 +95,11 @@ class bank(osv.osv):
#create the bank journal
vals_journal = {
'name': (bank.bank_name or '')+' '+bank.acc_number,
'name': name,
'code': code,
'type': 'bank',
'company_id': bank.company_id.id,
'analytic_journal_id': False,
'currency_id': False,
'default_credit_account_id': acc_bank_id,
'default_debit_account_id': acc_bank_id,
'view_id': view_id_cash
@ -101,3 +109,4 @@ class bank(osv.osv):
self.write(cr, uid, [bank.id], {'journal_id': journal_id}, context=context)
return True
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -30,10 +30,10 @@ class account_bank_statement(osv.osv):
def create(self, cr, uid, vals, context=None):
seq = 0
if 'line_ids' in vals:
new_line_ids = []
for line in vals['line_ids']:
seq += 1
line[2]['sequence'] = seq
vals[seq - 1] = line
return super(account_bank_statement, self).create(cr, uid, vals, context=context)
def write(self, cr, uid, ids, vals, context=None):
@ -52,8 +52,9 @@ class account_bank_statement(osv.osv):
journal_pool = self.pool.get('account.journal')
journal_type = context.get('journal_type', False)
journal_id = False
company_id = self.pool.get('res.company')._company_default_get(cr, uid, 'account.bank.statement',context=context)
if journal_type:
ids = journal_pool.search(cr, uid, [('type', '=', journal_type)])
ids = journal_pool.search(cr, uid, [('type', '=', journal_type),('company_id','=',company_id)])
if ids:
journal_id = ids[0]
return journal_id
@ -128,7 +129,7 @@ class account_bank_statement(osv.osv):
_description = "Bank Statement"
_columns = {
'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'), # readonly for account_cash_statement
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}),
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}, select=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True,
readonly=True, states={'draft':[('readonly',False)]}),
'period_id': fields.many2one('account.period', 'Period', required=True,
@ -162,37 +163,38 @@ class account_bank_statement(osv.osv):
_defaults = {
'name': "/",
'date': lambda *a: time.strftime('%Y-%m-%d'),
'date': fields.date.context_today,
'state': 'draft',
'journal_id': _default_journal_id,
'period_id': _get_period,
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.bank.statement',context=c),
}
def onchange_date(self, cr, user, ids, date, context=None):
def _check_company_id(self, cr, uid, ids, context=None):
for statement in self.browse(cr, uid, ids, context=context):
if statement.company_id.id != statement.period_id.company_id.id:
return False
return True
_constraints = [
(_check_company_id, 'The journal and period chosen have to belong to the same company.', ['journal_id','period_id']),
]
def onchange_date(self, cr, uid, ids, date, company_id, context=None):
"""
Returns a dict that contains new values and context
@param cr: A database cursor
@param user: ID of the user currently logged in
@param date: latest value from user input for field date
@param args: other arguments
@param context: context arguments, like lang, time zone
@return: Returns a dict which contains new values, and context
Find the correct period to use for the given date and company_id, return it and set it in the context
"""
res = {}
period_pool = self.pool.get('account.period')
if context is None:
context = {}
pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
ctx = context.copy()
ctx.update({'company_id': company_id})
pids = period_pool.find(cr, uid, dt=date, context=ctx)
if pids:
res.update({
'period_id':pids[0]
})
context.update({
'period_id':pids[0]
})
res.update({'period_id': pids[0]})
context.update({'period_id': pids[0]})
return {
'value':res,
@ -297,7 +299,7 @@ class account_bank_statement(osv.osv):
context=context):
if line.state <> 'valid':
raise osv.except_osv(_('Error !'),
_('Journal Item "%s" is not valid') % line.name)
_('Journal item "%s" is not valid.') % line.name)
# Bank statements will not consider boolean on journal entry_posted
account_move_obj.post(cr, uid, [move_id], context=context)
@ -308,7 +310,7 @@ class account_bank_statement(osv.osv):
def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
st = self.browse(cr, uid, st_id, context=context)
if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001):
if not ((abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001) or (abs((st.balance_end or 0.0) - st.balance_end_cash) < 0.0001)):
raise osv.except_osv(_('Error !'),
_('The statement balance is incorrect !\nThe expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end))
return True
@ -352,13 +354,16 @@ class account_bank_statement(osv.osv):
for st_line in st.line_ids:
if st_line.analytic_account_id:
if not st.journal_id.analytic_journal_id:
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,))
raise osv.except_osv(_('No Analytic Journal !'),_("You have to assign an analytic journal on the '%s' journal!") % (st.journal_id.name,))
if not st_line.amount:
continue
st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context)
self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context)
self.write(cr, uid, [st.id], {'name': st_number}, context=context)
self.write(cr, uid, [st.id], {
'name': st_number,
'balance_end_real': st.balance_end
}, context=context)
self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,))
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
@ -382,8 +387,10 @@ class account_bank_statement(osv.osv):
ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
res = cr.fetchone()
balance_start = res and res[0] or 0.0
account_id = self.pool.get('account.journal').read(cr, uid, journal_id, ['default_debit_account_id'], context=context)['default_debit_account_id']
return {'value': {'balance_start': balance_start, 'account_id': account_id}}
journal_data = self.pool.get('account.journal').read(cr, uid, journal_id, ['default_debit_account_id', 'company_id'], context=context)
account_id = journal_data['default_debit_account_id']
company_id = journal_data['company_id']
return {'value': {'balance_start': balance_start, 'account_id': account_id, 'company_id': company_id}}
def unlink(self, cr, uid, ids, context=None):
stat = self.read(cr, uid, ids, ['state'], context=context)
@ -471,12 +478,12 @@ class account_bank_statement_line(osv.osv):
'Moves'),
'ref': fields.char('Reference', size=32),
'note': fields.text('Notes'),
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of bank statement lines."),
'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of bank statement lines."),
'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
}
_defaults = {
'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
'date': lambda self,cr,uid,context={}: context.get('date', time.strftime('%Y-%m-%d')),
'date': lambda self,cr,uid,context={}: context.get('date', fields.date.context_today(self,cr,uid,context=context)),
'type': 'general',
}

View File

@ -16,12 +16,26 @@
<group name="accounting" col="2" colspan="2" attrs="{'invisible': [('company_id','=', False)]}" groups="base.group_extended">
<separator string="Accounting Information" colspan="2"/>
<field name="journal_id"/>
<field name="currency_id"/>
</group>
</group>
</field>
</record>
<record id="view_partner_bank_tree_add_currency" model="ir.ui.view">
<field name="name">Partner Bank Accounts - Add currency on tree</field>
<field name="model">res.partner.bank</field>
<field name="type">tree</field>
<field name="inherit_id" ref="base.view_partner_bank_tree"/>
<field name="arch" type="xml">
<field name="acc_number" position="after">
<field name="currency_id"/>
</field>
</field>
</record>
<record id="action_bank_tree" model="ir.actions.act_window">
<field name="name">Setup your Bank Accounts</field>
<field name="res_model">res.partner.bank</field>

View File

@ -311,7 +311,7 @@ class account_cash_statement(osv.osv):
if journal_type == 'bank':
return super(account_cash_statement, self).balance_check(cr, uid, cash_id, journal_type, context)
if not self._equal_balance(cr, uid, cash_id, context):
raise osv.except_osv(_('Error !'), _('The closing balance should be the same than the computed balance !'))
raise osv.except_osv(_('Error !'), _('The closing balance should be the same than the computed balance!'))
return True
def statement_close(self, cr, uid, ids, journal_type='bank', context=None):

View File

@ -0,0 +1,135 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from operator import itemgetter
import netsvc
import pooler
from osv import fields, osv
import decimal_precision as dp
from tools.translate import _
# ---------------------------------------------------------
# Account Financial Report
# ---------------------------------------------------------
class account_financial_report(osv.osv):
_name = "account.financial.report"
_description = "Account Report"
def _get_level(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for report in self.browse(cr, uid, ids, context=context):
level = 0
if report.parent_id:
level = report.parent_id.level + 1
res[report.id] = level
return res
def _get_children_by_order(self, cr, uid, ids, context=None):
res = []
for id in ids:
res.append(id)
ids2 = self.search(cr, uid, [('parent_id', '=', id)], order='sequence ASC', context=context)
res += self._get_children_by_order(cr, uid, ids2, context=context)
return res
def _get_balance(self, cr, uid, ids, field_names, args, context=None):
account_obj = self.pool.get('account.account')
res = {}
for report in self.browse(cr, uid, ids, context=context):
if report.id in res:
continue
res[report.id] = dict((fn, 0.0) for fn in field_names)
if report.type == 'accounts':
# it's the sum of the linked accounts
for a in report.account_ids:
for field in field_names:
res[report.id][field] += getattr(a, field)
elif report.type == 'account_type':
# it's the sum the leaf accounts with such an account type
report_types = [x.id for x in report.account_type_ids]
account_ids = account_obj.search(cr, uid, [('user_type','in', report_types), ('type','!=','view')], context=context)
for a in account_obj.browse(cr, uid, account_ids, context=context):
for field in field_names:
res[report.id][field] += getattr(a, field)
elif report.type == 'account_report' and report.account_report_id:
# it's the amount of the linked report
res2 = self._get_balance(cr, uid, [report.account_report_id.id], field_names, False, context=context)
for key, value in res2.items():
for field in field_names:
res[report.id][field] += value[field]
elif report.type == 'sum':
# it's the sum of the children of this account.report
res2 = self._get_balance(cr, uid, [rec.id for rec in report.children_ids], field_names, False, context=context)
for key, value in res2.items():
for field in field_names:
res[report.id][field] += value[field]
return res
_columns = {
'name': fields.char('Report Name', size=128, required=True, translate=True),
'parent_id': fields.many2one('account.financial.report', 'Parent'),
'children_ids': fields.one2many('account.financial.report', 'parent_id', 'Account Report'),
'sequence': fields.integer('Sequence'),
'balance': fields.function(_get_balance, 'Balance', multi='balance'),
'debit': fields.function(_get_balance, 'Debit', multi='balance'),
'credit': fields.function(_get_balance, 'Credit', multi="balance"),
'level': fields.function(_get_level, string='Level', store=True, type='integer'),
'type': fields.selection([
('sum','View'),
('accounts','Accounts'),
('account_type','Account Type'),
('account_report','Report Value'),
],'Type'),
'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'),
'account_report_id': fields.many2one('account.financial.report', 'Report Value'),
'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'),
'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'),
'display_detail': fields.selection([
('no_detail','No detail'),
('detail_flat','Display children flat'),
('detail_with_hierarchy','Display children with hierarchy')
], 'Display details'),
'style_overwrite': fields.selection([
(0, 'Automatic formatting'),
(1,'Main Title 1 (bold, underlined)'),
(2,'Title 2 (bold)'),
(3,'Title 3 (bold, smaller)'),
(4,'Normal Text'),
(5,'Italic Text (smaller)'),
(6,'Smallest Text'),
],'Financial Report Style', help="You can set up here the format you want this record to be displayed. If you leave the automatic formatting, it will be computed based on the financial reports hierarchy (auto-computed field 'level')."),
}
_defaults = {
'type': 'sum',
'display_detail': 'detail_flat',
'sign': 1,
'style_overwrite': 0,
}
account_financial_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--
Financial Reports
-->
<record id="account_financial_report_profitandloss0" model="account.financial.report">
<field name="name">Profit and Loss</field>
<field name="type">sum</field>
</record>
<record id="account_financial_report_income0" model="account.financial.report">
<field name="name">Income</field>
<field name="parent_id" ref="account_financial_report_profitandloss0"/>
<field name="display_detail">detail_with_hierarchy</field>
<field name="type">account_type</field>
</record>
<record id="account_financial_report_expense0" model="account.financial.report">
<field name="name">Expense</field>
<field name="parent_id" ref="account_financial_report_profitandloss0"/>
<field name="display_detail">detail_with_hierarchy</field>
<field name="type">account_type</field>
</record>
<record id="account_financial_report_balancesheet0" model="account.financial.report">
<field name="name">Balance Sheet</field>
<field name="type">sum</field>
</record>
<record id="account_financial_report_assets0" model="account.financial.report">
<field name="name">Assets</field>
<field name="parent_id" ref="account_financial_report_balancesheet0"/>
<field name="display_detail">detail_with_hierarchy</field>
<field name="type">account_type</field>
</record>
<record id="account_financial_report_liabilitysum0" model="account.financial.report">
<field name="name">Liability</field>
<field name="parent_id" ref="account_financial_report_balancesheet0"/>
<field name="display_detail">no_detail</field>
<field name="type">sum</field>
</record>
<record id="account_financial_report_liability0" model="account.financial.report">
<field name="name">Liability</field>
<field name="parent_id" ref="account_financial_report_liabilitysum0"/>
<field name="display_detail">detail_with_hierarchy</field>
<field name="type">account_type</field>
</record>
<record id="account_financial_report_profitloss_toreport0" model="account.financial.report">
<field name="name">Profit (Loss) to report</field>
<field name="parent_id" ref="account_financial_report_liabilitysum0"/>
<field name="display_detail">no_detail</field>
<field name="type">account_report</field>
<field name="account_report_id" ref="account_financial_report_profitandloss0"/>
</record>
</data>
</openerp>

View File

@ -25,18 +25,15 @@
</xpath>
<group colspan="8" position="inside">
<group colspan="4" width="600">
<field name="charts"/>
<field name="charts"/>
<group colspan="4" groups="account.group_account_user">
<separator col="4" colspan="4" string="Configure Fiscal Year"/>
<field name="company_id" colspan="4" widget="selection"/><!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it -->
<field name="has_default_company" invisible="1" />
<field name="company_id" colspan="4" widget="selection" attrs="{'invisible' : [('has_default_company', '=', True)]}"/><!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it -->
<field name="date_start" on_change="on_change_start_date(date_start)"/>
<field name="date_stop"/>
<field name="period" colspan="4"/>
</group>
<group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}">
<field name="sale_tax" on_change="on_change_tax(sale_tax)" attrs="{'required':[('charts','=','configurable')]}"/>
<field name="purchase_tax" groups="base.group_extended"/>
</group>
</group>
</group>
</data>
@ -56,7 +53,7 @@
<record id="category_accounting_configuration" model="ir.actions.todo.category">
<field name="name">Accounting</field>
<field name="sequence">5</field>
</record>
</record>
<record id="account_configuration_installer_todo" model="ir.actions.todo">
<field name="action_id" ref="action_account_configuration_installer"/>

View File

@ -58,17 +58,19 @@ class account_invoice(osv.osv):
return res and res[0] or False
def _get_currency(self, cr, uid, context=None):
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid], context=context)[0]
if user.company_id:
return user.company_id.currency_id.id
return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=', 1.0)])[0]
res = False
journal_id = self._get_journal(cr, uid, context=context)
if journal_id:
journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context)
res = journal.currency and journal.currency.id or journal.company_id.currency_id.id
return res
def _get_journal_analytic(self, cr, uid, type_inv, context=None):
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
tt = type2journal.get(type_inv, 'sale')
result = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=',tt)], context=context)
if not result:
raise osv.except_osv(_('No Analytic Journal !'),_("You must define an analytic journal of type '%s' !") % (tt,))
raise osv.except_osv(_('No Analytic Journal !'),_("You must define an analytic journal of type '%s'!") % (tt,))
return result[0]
def _get_type(self, cr, uid, context=None):
@ -207,7 +209,7 @@ class account_invoice(osv.osv):
help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Invoice. \
\n* The \'Pro-forma\' when invoice is in Pro-forma state,invoice does not have an invoice number. \
\n* The \'Open\' state is used when user create invoice,a invoice number is generated.Its in open state till user does not pay invoice. \
\n* The \'Paid\' state is set automatically when invoice is paid.\
\n* The \'Paid\' state is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled. \
\n* The \'Cancelled\' state is used when user cancel invoice.'),
'date_invoice': fields.date('Invoice Date', readonly=True, states={'draft':[('readonly',False)]}, select=True, help="Keep empty to use the current date"),
'date_due': fields.date('Due Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, select=True,
@ -251,17 +253,17 @@ class account_invoice(osv.osv):
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}),
'check_total': fields.float('Total', digits_compute=dp.get_precision('Account'), states={'open':[('readonly',True)],'close':[('readonly',True)]}),
'check_total': fields.float('Verification Total', digits_compute=dp.get_precision('Account'), states={'open':[('readonly',True)],'close':[('readonly',True)]}),
'reconciled': fields.function(_reconciled, string='Paid/Reconciled', type='boolean',
store={
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, None, 50), # Check if we can remove ?
'account.move.line': (_get_invoice_from_line, None, 50),
'account.move.reconcile': (_get_invoice_from_reconcile, None, 50),
}, help="The Journal Entry of the invoice have been totally reconciled with one or several Journal Entries of payment."),
}, help="It indicates that the invoice has been paid and the journal entry of the invoice has been reconciled with one or several journal entries of payment."),
'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',
help='Bank Account Number, Company bank account if Invoice is customer or supplier refund, otherwise Partner bank account number.', readonly=True, states={'draft':[('readonly',False)]}),
help='Bank Account Number to which the invoice will be paid. A Company bank account if this is a Customer Invoice or Supplier Refund, otherwise a Partner bank account number.', readonly=True, states={'draft':[('readonly',False)]}),
'move_lines':fields.function(_get_lines, type='many2many', relation='account.move.line', string='Entry Lines'),
'residual': fields.function(_amount_residual, digits_compute=dp.get_precision('Account'), string='Residual',
'residual': fields.function(_amount_residual, digits_compute=dp.get_precision('Account'), string='Balance',
store={
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line','move_id'], 50),
'account.invoice.tax': (_get_invoice_tax, None, 50),
@ -286,6 +288,9 @@ class account_invoice(osv.osv):
'internal_number': False,
'user_id': lambda s, cr, u, c: u,
}
_sql_constraints = [
('number_uniq', 'unique(number, company_id, journal_id, type)', 'Invoice Number must be unique per Company!'),
]
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
journal_obj = self.pool.get('account.journal')
@ -306,13 +311,22 @@ class account_invoice(osv.osv):
view_id = view_id[0]
res = super(account_invoice,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
type = context.get('journal_type', 'sale')
type = context.get('journal_type', False)
for field in res['fields']:
if field == 'journal_id':
if field == 'journal_id' and type:
journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
res['fields'][field]['selection'] = journal_select
doc = etree.XML(res['arch'])
if context.get('type', False):
for node in doc.xpath("//field[@name='partner_bank_id']"):
if context['type'] == 'in_refund':
node.set('domain', "[('partner_id.ref_companies', 'in', [company_id])]")
elif context['type'] == 'out_refund':
node.set('domain', "[('partner_id', '=', partner_id)]")
res['arch'] = etree.tostring(doc)
if view_type == 'search':
if context.get('type', 'in_invoice') in ('out_invoice', 'out_refund'):
for node in doc.xpath("//group[@name='extended filter']"):
@ -335,7 +349,7 @@ class account_invoice(osv.osv):
context = {}
res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'invoice_form')
view_id = res and res[1] or False
context.update({'view_id': view_id})
context['view_id'] = view_id
return context
def create(self, cr, uid, vals, context=None):
@ -411,7 +425,7 @@ class account_invoice(osv.osv):
pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
if not rec_res_id and not pay_res_id:
raise osv.except_osv(_('Configuration Error !'),
_('Can not find account chart for this company, Please Create account.'))
_('Can not find a chart of accounts for this company, you should create one.'))
account_obj = self.pool.get('account.account')
rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id])
@ -452,10 +466,10 @@ class account_invoice(osv.osv):
result['value'].update(to_update['value'])
return result
def onchange_journal_id(self, cr, uid, ids, journal_id=False):
def onchange_journal_id(self, cr, uid, ids, journal_id=False, context=None):
result = {}
if journal_id:
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context)
currency_id = journal.currency and journal.currency.id or journal.company_id.currency_id.id
result = {'value': {
'currency_id': currency_id,
@ -478,7 +492,7 @@ class account_invoice(osv.osv):
pterm_list.sort()
res = {'value':{'date_due': pterm_list[-1]}}
else:
raise osv.except_osv(_('Data Insufficient !'), _('The Payment Term of Supplier does not have Payment Term Lines(Computation) defined !'))
raise osv.except_osv(_('Data Insufficient !'), _('The payment term of supplier does not have a payment term line!'))
return res
def onchange_invoice_line(self, cr, uid, ids, lines):
@ -511,7 +525,7 @@ class account_invoice(osv.osv):
pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
if not rec_res_id and not pay_res_id:
raise osv.except_osv(_('Configuration Error !'),
_('Can not find account chart for this company, Please Create account.'))
_('Can not find a chart of account, you should create one from the configuration of the accounting menu.'))
if type in ('out_invoice', 'out_refund'):
acc_id = rec_res_id
else:
@ -526,7 +540,7 @@ class account_invoice(osv.osv):
result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)])
if not result_id:
raise osv.except_osv(_('Configuration Error !'),
_('Can not find account chart for this company in invoice line account, Please Create account.'))
_('Can not find a chart of account, you should create one from the configuration of the accounting menu.'))
inv_line_obj.write(cr, uid, [line.id], {'account_id': result_id[-1]})
else:
if invoice_line:
@ -560,18 +574,6 @@ class account_invoice(osv.osv):
else:
journal_ids = obj_journal.search(cr, uid, [])
if currency_id and company_id:
currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
if currency.company_id and currency.company_id.id != company_id:
val['currency_id'] = False
else:
val['currency_id'] = currency.id
if company_id:
company = self.pool.get('res.company').browse(cr, uid, company_id)
if company.currency_id.company_id and company.currency_id.company_id.id != company_id:
val['currency_id'] = False
else:
val['currency_id'] = company.currency_id.id
return {'value': val, 'domain': dom}
# go from canceled state to draft state
@ -607,15 +609,15 @@ class account_invoice(osv.osv):
res[r[0]].append( r[1] )
return res
def copy(self, cr, uid, id, default={}, context=None):
if context is None:
context = {}
def copy(self, cr, uid, id, default=None, context=None):
default = default or {}
default.update({
'state':'draft',
'number':False,
'move_id':False,
'move_name':False,
'internal_number': False,
'period_id': False,
})
if 'date_invoice' not in default:
default.update({
@ -727,13 +729,13 @@ class account_invoice(osv.osv):
key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id)
tax_key.append(key)
if not key in compute_taxes:
raise osv.except_osv(_('Warning !'), _('Global taxes defined, but are not in invoice lines !'))
raise osv.except_osv(_('Warning !'), _('Global taxes defined, but they are not in invoice lines !'))
base = compute_taxes[key]['base']
if abs(base - tax.base) > inv.company_id.currency_id.rounding:
raise osv.except_osv(_('Warning !'), _('Tax base different !\nClick on compute to update tax base'))
raise osv.except_osv(_('Warning !'), _('Tax base different!\nClick on compute to update the tax base.'))
for key in compute_taxes:
if not key in tax_key:
raise osv.except_osv(_('Warning !'), _('Taxes missing !'))
raise osv.except_osv(_('Warning !'), _('Taxes are missing!\nClick on compute button.'))
def compute_invoice_totals(self, cr, uid, inv, company_currency, ref, invoice_move_lines):
total = 0
@ -791,33 +793,39 @@ class account_invoice(osv.osv):
line.append((0,0,val))
return line
def action_move_create(self, cr, uid, ids, *args):
def action_move_create(self, cr, uid, ids, context=None):
"""Creates invoice related analytics and financial move lines"""
ait_obj = self.pool.get('account.invoice.tax')
cur_obj = self.pool.get('res.currency')
context = {}
for inv in self.browse(cr, uid, ids):
period_obj = self.pool.get('account.period')
payment_term_obj = self.pool.get('account.payment.term')
journal_obj = self.pool.get('account.journal')
move_obj = self.pool.get('account.move')
if context is None:
context = {}
for inv in self.browse(cr, uid, ids, context=context):
if not inv.journal_id.sequence_id:
raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal'))
raise osv.except_osv(_('Error !'), _('Please define sequence on the journal related to this invoice.'))
if not inv.invoice_line:
raise osv.except_osv(_('No Invoice Lines !'), _('Please create some invoice lines.'))
if inv.move_id:
continue
ctx = context.copy()
ctx.update({'lang': inv.partner_id.lang})
if not inv.date_invoice:
self.write(cr, uid, [inv.id], {'date_invoice':time.strftime('%Y-%m-%d')})
self.write(cr, uid, [inv.id], {'date_invoice': fields.date.context_today(self,cr,uid,context=context)}, context=ctx)
company_currency = inv.company_id.currency_id.id
# create the analytical lines
# one move line per invoice line
iml = self._get_analytic_lines(cr, uid, inv.id)
iml = self._get_analytic_lines(cr, uid, inv.id, context=ctx)
# check if taxes are all computed
ctx = context.copy()
ctx.update({'lang': inv.partner_id.lang})
compute_taxes = ait_obj.compute(cr, uid, inv.id, context=ctx)
self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj)
if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0):
raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.'))
# I disabled the check_total feature
#if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0):
# raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.'))
if inv.payment_term:
total_fixed = total_percent = 0
@ -828,7 +836,7 @@ class account_invoice(osv.osv):
total_percent += line.value_amount
total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0)
if (total_fixed + total_percent) > 100:
raise osv.except_osv(_('Error !'), _("Can not create the invoice !\nThe related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."))
raise osv.except_osv(_('Error !'), _("Can not create the invoice !\nThe related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount. The latest line of your payment term must be of type 'balance' to avoid rounding issues."))
# one move line per tax line
iml += ait_obj.move_line_get(cr, uid, inv.id)
@ -855,8 +863,8 @@ class account_invoice(osv.osv):
name = inv['name'] or '/'
totlines = False
if inv.payment_term:
totlines = self.pool.get('account.payment.term').compute(cr,
uid, inv.payment_term.id, total, inv.date_invoice or False)
totlines = payment_term_obj.compute(cr,
uid, inv.payment_term.id, total, inv.date_invoice or False, context=ctx)
if totlines:
res_amount_currency = total_currency
i = 0
@ -902,12 +910,12 @@ class account_invoice(osv.osv):
date = inv.date_invoice or time.strftime('%Y-%m-%d')
part = inv.partner_id.id
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})),iml)
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context=ctx)),iml)
line = self.group_lines(cr, uid, iml, line, inv)
journal_id = inv.journal_id.id
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
journal = journal_obj.browse(cr, uid, journal_id, context=ctx)
if journal.centralisation:
raise osv.except_osv(_('UserError'),
_('You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu.'))
@ -919,26 +927,26 @@ class account_invoice(osv.osv):
'line_id': line,
'journal_id': journal_id,
'date': date,
'type': entry_type,
'narration':inv.comment
}
period_id = inv.period_id and inv.period_id.id or False
ctx.update({'company_id': inv.company_id.id})
if not period_id:
period_ids = self.pool.get('account.period').search(cr, uid, [('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d')), ('company_id', '=', inv.company_id.id)])
if period_ids:
period_id = period_ids[0]
period_ids = period_obj.find(cr, uid, inv.date_invoice, context=ctx)
period_id = period_ids and period_ids[0] or False
if period_id:
move['period_id'] = period_id
for i in line:
i[2]['period_id'] = period_id
move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name
move_id = move_obj.create(cr, uid, move, context=ctx)
new_move_name = move_obj.browse(cr, uid, move_id, context=ctx).name
# make the invoice point to that move
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name})
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}, context=ctx)
# Pass invoice in context in method post: used if you want to get the same
# account move reference when creating the same invoice after a cancelled one:
self.pool.get('account.move').post(cr, uid, [move_id], context={'invoice':inv})
ctx.update({'invoice':inv})
move_obj.post(cr, uid, [move_id], context=ctx)
self._log_event(cr, uid, ids)
return True
@ -1077,7 +1085,8 @@ class account_invoice(osv.osv):
del line['invoice_id']
for field in ('company_id', 'partner_id', 'account_id', 'product_id',
'uos_id', 'account_analytic_id', 'tax_code_id', 'base_code_id'):
line[field] = line.get(field, False) and line[field][0]
if line.get(field):
line[field] = line[field][0]
if 'invoice_line_tax_id' in line:
line['invoice_line_tax_id'] = [(6,0, line.get('invoice_line_tax_id', [])) ]
return map(lambda x: (0,0,x), lines)
@ -1205,7 +1214,7 @@ class account_invoice(osv.osv):
l2['name'] = name
lines = [(0, 0, l1), (0, 0, l2)]
move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date, 'type': entry_type}
move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
line_ids = []
@ -1258,7 +1267,7 @@ class account_invoice_line(osv.osv):
def _price_unit_default(self, cr, uid, context=None):
if context is None:
context = {}
if 'check_total' in context:
if context.get('check_total', False):
t = context['check_total']
for l in context.get('invoice_line', {}):
if isinstance(l, (list, tuple)) and len(l) >= 3 and l[2]:
@ -1323,9 +1332,9 @@ class account_invoice_line(osv.osv):
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") )
if not product:
if type in ('in_invoice', 'in_refund'):
return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}}
return {'value': {}, 'domain':{'product_uom':[]}}
else:
return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}}
return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}}
part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
fpos_obj = self.pool.get('account.fiscal.position')
fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id, context=context) or False
@ -1353,6 +1362,17 @@ class account_invoice_line(osv.osv):
taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a, context=context).tax_ids or False)
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
if type in ('in_invoice','in_refund') and tax_id and price_unit:
tax_pool = self.pool.get('account.tax')
tax_browse = tax_pool.browse(cr, uid, tax_id)
if not isinstance(tax_browse, list):
tax_browse = [tax_browse]
taxes = tax_pool.compute_inv(cr, uid, tax_browse, price_unit, 1)
tax_amount = reduce(lambda total, tax_dict: total + tax_dict.get('amount', 0.0), taxes, 0.0)
price_unit = price_unit - tax_amount
if qty != 0:
price_unit = price_unit / float(qty)
if type in ('in_invoice', 'in_refund'):
result.update( {'price_unit': price_unit or res.standard_price,'invoice_line_tax_id': tax_id} )
else:
@ -1367,7 +1387,6 @@ class account_invoice_line(osv.osv):
if res2:
domain = {'uos_id':[('category_id','=',res2 )]}
result['categ_id'] = res.categ_id.id
res_final = {'value':result, 'domain':domain}
if not company_id or not currency_id:
@ -1559,6 +1578,7 @@ class account_invoice_tax(osv.osv):
for line in inv.invoice_line:
for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id)['taxes']:
tax['price_unit'] = cur_obj.round(cr, uid, cur, tax['price_unit'])
val={}
val['invoice_id'] = inv.id
val['name'] = tax['name']
@ -1627,12 +1647,7 @@ class res_partner(osv.osv):
}
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
if context is None:
context = {}
default = default or {}
default.update({'invoice_ids' : []})
return super(res_partner, self).copy(cr, uid, id, default, context)

View File

@ -120,7 +120,7 @@
<field name="number"/>
<field name="partner_id" groups="base.group_user"/>
<field name="reference" invisible="1"/>
<field name="name"/>
<field name="name" invisible="1"/>
<field name="journal_id" invisible="1"/>
<field name="period_id" invisible="1" groups="account.group_account_user"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
@ -152,8 +152,8 @@
<field name="currency_id" width="50"/>
<button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
<newline/>
<field string="Supplier" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field string="Supplier" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}" options='{"quick_create": false}' domain="[('supplier', '=', True)]"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id" context="{'default_partner_id': partner_id}" options='{"quick_create": false}'/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/>
<field name="date_invoice"/>
@ -168,8 +168,7 @@
<field name="reference_type" nolabel="1" size="0"/>
<field name="reference" nolabel="1"/>
<field name="date_due"/>
<field name="check_total" required="2"/>
<field colspan="4" default_get="{'check_total': check_total, 'invoice_line': invoice_line, 'address_invoice_id': address_invoice_id, 'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False}" name="invoice_line" context="{'type': type}" nolabel="1">
<field colspan="4" context="{'address_invoice_id': address_invoice_id, 'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False, 'type': type}" name="invoice_line" nolabel="1">
<tree string="Invoice lines">
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, context, parent.company_id)"/>
<field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(parent.fiscal_position,account_id)"/>
@ -179,7 +178,7 @@
<field name="price_unit"/>
<!-- Removed if subtotal is set -->
<field name="price_subtotal"/>
<field name="name"/>
<field invisible="True" name="name"/>
<field invisible="True" name="uos_id"/>
</tree>
</field>
@ -257,27 +256,25 @@
<field name="arch" type="xml">
<form string="Invoice">
<group colspan="4" col="8">
<field name="journal_id" groups="base.group_user" on_change="onchange_journal_id(journal_id)" widget="selection"/>
<field name="journal_id" groups="base.group_user" on_change="onchange_journal_id(journal_id, context)" widget="selection"/>
<field name="number"/>
<field name="type" invisible="1"/>
<field name="currency_id" width="50"/>
<button name="%(action_account_change_currency)d" type="action" icon="terp-stock_effects-object-colorize" string="Change" attrs="{'invisible':[('state','!=','draft')]}" groups="account.group_account_user"/>
<newline/>
<field string="Customer" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" groups="base.group_user" context="{'search_default_customer': 1}"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id"/>
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<field string="Customer" name="partner_id" on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" groups="base.group_user" context="{'search_default_customer': 1}" options='{"quick_create": false}' domain="[('customer', '=', True)]"/>
<field domain="[('partner_id','=',partner_id)]" name="address_invoice_id" context="{'default_partner_id': partner_id}" options='{"quick_create": false}'/>
<field name="fiscal_position" groups="base.group_extended" widget="selection" options='{"quick_create": false}'/>
<newline/>
<field name="date_invoice"/>
<field name="period_id" domain="[('state', '=', 'draft')]" groups="account.group_account_user" widget="selection"/>
<group colspan="2" col="1" groups="account.group_account_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
<field name="payment_term" widget="selection"/>
<newline/>
<field domain="[('company_id', '=', company_id),('type','=', 'receivable')]" name="account_id" groups="account.group_account_user"/>
<field name="name" groups="base.group_extended"/>
</group>
<notebook colspan="4">
<page string="Invoice">
<field domain="[('company_id', '=', company_id),('type','=', 'receivable')]" name="account_id" groups="account.group_account_user"/>
<field name="name"/>
<field name="payment_term" widget="selection"/>
<field colspan="4" name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}"/>
<group col="1" colspan="2">
<field name="tax_line" nolabel="1">
@ -294,7 +291,9 @@
</field>
</group>
<group col="4" colspan="2">
<button colspan="2" name="button_reset_taxes" states="draft,proforma2" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific" help="This action will erase taxes"/>
<group colspan="2" col="1">
<button name="button_reset_taxes" states="draft,proforma2" string="Compute Taxes" type="object" groups="base.group_user" icon="terp-stock_format-scientific" help="This action will erase taxes"/>
</group>
<field name="amount_untaxed"/>
<label string="" colspan="2"/>
<field name="amount_tax"/>
@ -305,7 +304,6 @@
<group col="8" colspan="4" groups="base.group_user">
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel" groups="base.group_no_one"/>
<button name="action_cancel_draft" states="cancel" string="Reset to Draft" type="object" icon="terp-stock_effects-object-colorize"/>
<button name='%(action_account_state_open)d' type='action' string='Re-Open' groups="account.group_account_invoice" attrs="{'invisible':['|', ('state','&lt;&gt;','paid'), ('reconciled', '=', True)]}" icon="gtk-convert" help="This button only appears when the state of the invoice is 'paid' (showing that it has been fully reconciled) and auto-computed boolean 'reconciled' is False (depicting that it's not the case anymore). In other words, the invoice has been dereconciled and it does not fit anymore the 'paid' state. You should press this button to re-open it and let it continue its normal process after having resolved the eventual exceptions it may have created."/>
<button name="%(action_account_invoice_refund)d" type='action' string='Refund' states='open,paid' icon="gtk-execute"/>
<button name="invoice_proforma2" states="draft" string="PRO-FORMA" icon="terp-gtk-media-pause" groups="account.group_account_user"/>
@ -362,13 +360,13 @@
<separator orientation="vertical"/>
<filter name="unpaid" icon="terp-dolar_ok!" string="Unpaid" domain="[('state','=','open')]" help="Unpaid Invoices"/>
<separator orientation="vertical"/>
<field name="number"/>
<field name="number"
string="Reference"
filter_domain="['|', ('number','ilike',self),('origin','ilike',self)]"/>
<field name="partner_id"/>
<field name="user_id" widget="selection" string="Salesman">
<filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" />
<filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" />
</field>
<field name="origin"/>
<field name="amount_total"/>
</group>
<newline/>
<group>
@ -432,7 +430,7 @@
<field name="view_mode">tree,form,calendar,graph</field>
<field eval="False" name="view_id"/>
<field name="domain">[('type','=','out_invoice')]</field>
<field name="context">{'type':'out_invoice', 'journal_type': 'sale'}</field>
<field name="context">{'default_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale'}</field>
<field name="search_view_id" ref="view_account_invoice_filter"/>
<field name="help">With Customer Invoices you can create and manage sales invoices issued to your customers. OpenERP can also generate draft invoices automatically from sales orders or deliveries. You should only confirm them before sending them to your customers.</field>
</record>
@ -460,7 +458,7 @@
<field name="view_mode">tree,form,calendar,graph</field>
<field eval="False" name="view_id"/>
<field name="domain">[('type','=','in_invoice')]</field>
<field name="context">{'type':'in_invoice', 'journal_type': 'purchase'}</field>
<field name="context">{'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'}</field>
<field name="search_view_id" ref="view_account_invoice_filter"/>
<field name="help">With Supplier Invoices you can enter and manage invoices issued by your suppliers. OpenERP can also generate draft invoices automatically from purchase orders or receipts. This way, you can control the invoice from your supplier according to what you purchased or received.</field>
</record>
@ -473,7 +471,7 @@
<field name="view_mode">tree,form,calendar,graph</field>
<field eval="False" name="view_id"/>
<field name="domain">[('type','=','out_refund')]</field>
<field name="context">{'type':'out_refund', 'journal_type': 'sale_refund'}</field>
<field name="context">{'default_type':'out_refund', 'type':'out_refund', 'journal_type': 'sale_refund'}</field>
<field name="search_view_id" ref="view_account_invoice_filter"/>
<field name="help">With Customer Refunds you can manage the credit notes for your customers. A refund is a document that credits an invoice completely or partially. You can easily generate refunds and reconcile them directly from the invoice form.</field>
</record>
@ -499,7 +497,7 @@
<field name="view_mode">tree,form,calendar,graph</field>
<field eval="False" name="view_id"/>
<field name="domain">[('type','=','in_refund')]</field>
<field name="context">{'type':'in_refund', 'journal_type': 'purchase_refund'}</field>
<field name="context">{'default_type': 'in_refund', 'type': 'in_refund', 'journal_type': 'purchase_refund'}</field>
<field name="search_view_id" ref="view_account_invoice_filter"/>
<field name="help">With Supplier Refunds you can manage the credit notes you receive from your suppliers. A refund is a document that credits an invoice completely or partially. You can easily generate refunds and reconcile them directly from the invoice form.</field>
</record>

View File

@ -43,6 +43,7 @@
<menuitem id="menu_finance_statistic_report_statement" name="Statistic Reports" parent="menu_finance_reporting" sequence="300"/>
<menuitem id="next_id_22" name="Partners" parent="menu_finance_generic_reporting" sequence="1"/>
<menuitem id="menu_multi_currency" name="Multi-Currencies" parent="menu_finance_generic_reporting" sequence="10"/>
<menuitem
parent="account.menu_finance_legal_statement"
id="final_accounting_reports"

View File

@ -94,7 +94,7 @@ class account_move_line(osv.osv):
if initial_bal and not context.get('periods', False) and not where_move_lines_by_date:
#we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice
#so we have to invalidate this query
raise osv.except_osv(_('Warning !'),_("You haven't supplied enough argument to compute the initial balance"))
raise osv.except_osv(_('Warning !'),_("You haven't supplied enough argument to compute the initial balance, please select a period and journal in the context."))
if context.get('journal_ids', False):
@ -228,13 +228,8 @@ class account_move_line(osv.osv):
# Compute simple values
data = super(account_move_line, self).default_get(cr, uid, fields, context=context)
# Starts: Manual entry from account.move form
if context.get('lines',[]):
total_new = 0.00
for i in context['lines']:
if i[2]:
total_new += (i[2]['debit'] or 0.00)- (i[2]['credit'] or 0.00)
for item in i[2]:
data[item] = i[2][item]
if context.get('lines'):
total_new = context.get('balance', 0.00)
if context['journal']:
journal_data = journal_obj.browse(cr, uid, context['journal'], context=context)
if journal_data.type == 'purchase':
@ -555,10 +550,12 @@ class account_move_line(osv.osv):
'blocked': False,
'centralisation': 'normal',
'date': _get_date,
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
'date_created': fields.date.context_today,
'state': 'draft',
'currency_id': _get_currency,
'journal_id': lambda self, cr, uid, c: c.get('journal_id', False),
'credit': 0.0,
'debit': 0.0,
'account_id': lambda self, cr, uid, c: c.get('account_id', False),
'period_id': lambda self, cr, uid, c: c.get('period_id', False),
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)
@ -579,14 +576,14 @@ class account_move_line(osv.osv):
lines = self.browse(cr, uid, ids, context=context)
for l in lines:
if l.account_id.type == 'view':
return False
raise osv.except_osv(_('Error :'), _('You can not create journal items on a "view" account %s %s') % (l.account_id.code, l.account_id.name))
return True
def _check_no_closed(self, cr, uid, ids, context=None):
lines = self.browse(cr, uid, ids, context=context)
for l in lines:
if l.account_id.type == 'closed':
return False
raise osv.except_osv(_('Error :'), _('You can not create journal items on a closed account %s %s') % (l.account_id.code, l.account_id.name))
return True
def _check_company_id(self, cr, uid, ids, context=None):
@ -611,11 +608,11 @@ class account_move_line(osv.osv):
return True
_constraints = [
(_check_no_view, 'You can not create move line on view account.', ['account_id']),
(_check_no_closed, 'You can not create move line on closed account.', ['account_id']),
(_check_company_id, 'Company must be same for its related account and period.', ['company_id']),
(_check_date, 'The date of your Journal Entry is not in the defined period!', ['date']),
(_check_currency, 'The selected account of your Journal Entry must receive a value in its secondary currency', ['currency_id']),
(_check_no_view, 'You can not create journal items on an account of type view.', ['account_id']),
(_check_no_closed, 'You can not create journal items on closed account.', ['account_id']),
(_check_company_id, 'Company must be the same for its related account and period.', ['company_id']),
(_check_date, 'The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal.', ['date']),
(_check_currency, 'The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal.', ['currency_id']),
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
@ -824,13 +821,9 @@ class account_move_line(osv.osv):
(tuple(ids), ))
r = cr.fetchall()
#TODO: move this check to a constraint in the account_move_reconcile object
if (len(r) != 1) and not context.get('fy_closing', False):
raise osv.except_osv(_('Error'), _('Entries are not of the same account or already reconciled ! '))
if not unrec_lines:
raise osv.except_osv(_('Error'), _('Entry is already reconciled'))
account = account_obj.browse(cr, uid, account_id, context=context)
if not context.get('fy_closing', False) and not account.reconcile:
raise osv.except_osv(_('Error'), _('The account is not defined to be reconciled !'))
if r[0][1] != None:
raise osv.except_osv(_('Error'), _('Some entries are already reconciled !'))
@ -1062,6 +1055,7 @@ class account_move_line(osv.osv):
elif field == 'statement_id':
f.set('domain', "[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]")
f.set('invisible', 'True')
elif field == 'date':
f.set('on_change', 'onchange_date(date)')
@ -1082,8 +1076,6 @@ class account_move_line(osv.osv):
f.set("invisible", "context.get('journal_id', False)")
elif field in ('period_id',):
f.set("invisible", "context.get('period_id', False)")
else:
f.set('invisible', "context.get('visible_id') not in %s" % (fields.get(field)))
orm.setup_modifiers(f, fields_get[field], context=context,
in_tree_view=True)
@ -1212,9 +1204,9 @@ class account_move_line(osv.osv):
for line in self.browse(cr, uid, ids, context=context):
err_msg = _('Move name (id): %s (%s)') % (line.move_id.name, str(line.move_id.id))
if line.move_id.state <> 'draft' and (not line.journal_id.entry_posted):
raise osv.except_osv(_('Error !'), _('You can not do this modification on a confirmed entry ! Please note that you can just change some non important fields ! \n%s') % err_msg)
raise osv.except_osv(_('Error !'), _('You can not do this modification on a confirmed entry! You can just change some non legal fields or you must unconfirm the journal entry first! \n%s') % err_msg)
if line.reconcile_id:
raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields ! \n%s') % err_msg)
raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry! You can just change some non legal fields or you must unreconcile first!\n%s') % err_msg)
t = (line.journal_id.id, line.period_id.id)
if t not in done:
self._update_journal_check(cr, uid, line.journal_id.id, line.period_id.id, context)
@ -1243,6 +1235,14 @@ class account_move_line(osv.osv):
m = move_obj.browse(cr, uid, vals['move_id'])
context['journal_id'] = m.journal_id.id
context['period_id'] = m.period_id.id
#we need to treat the case where a value is given in the context for period_id as a string
if 'period_id' not in context or not isinstance(context.get('period_id', ''), (int, long)):
period_candidate_ids = self.pool.get('account.period').name_search(cr, uid, name=context.get('period_id',''))
if len(period_candidate_ids) != 1:
raise osv.except_osv(_('Encoding error'), _('No period found or more than one period found for the given date.'))
context['period_id'] = period_candidate_ids[0][0]
if not context.get('journal_id', False) and context.get('search_default_journal_id', False):
context['journal_id'] = context.get('search_default_journal_id')
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
move_id = vals.get('move_id', False)
journal = journal_obj.browse(cr, uid, context['journal_id'], context=context)
@ -1324,7 +1324,7 @@ class account_move_line(osv.osv):
base_sign = 'base_sign'
tax_sign = 'tax_sign'
tmp_cnt = 0
for tax in tax_obj.compute_all(cr, uid, [tax_id], total, 1.00).get('taxes'):
for tax in tax_obj.compute_all(cr, uid, [tax_id], total, 1.00, force_excluded=True).get('taxes'):
#create the base movement
if tmp_cnt == 0:
if tax[base_code]:
@ -1336,8 +1336,6 @@ class account_move_line(osv.osv):
else:
data = {
'move_id': vals['move_id'],
'journal_id': vals['journal_id'],
'period_id': vals['period_id'],
'name': tools.ustr(vals['name'] or '') + ' ' + tools.ustr(tax['name'] or ''),
'date': vals['date'],
'partner_id': vals.get('partner_id',False),
@ -1354,8 +1352,6 @@ class account_move_line(osv.osv):
#create the VAT movement
data = {
'move_id': vals['move_id'],
'journal_id': vals['journal_id'],
'period_id': vals['period_id'],
'name': tools.ustr(vals['name'] or '') + ' ' + tools.ustr(tax['name'] or ''),
'date': vals['date'],
'partner_id': vals.get('partner_id',False),

View File

@ -0,0 +1,22 @@
-
I configure automatically if the country is set on the company, mainly for online offers.
-
!python {model: account.installer}: |
modules = self.pool.get('ir.module.module')
wizards = self.pool.get('ir.actions.todo')
wiz = wizards.browse(cr, uid, ref('account.account_configuration_installer_todo'))
part = self.pool.get('res.partner').browse(cr, uid, ref('base.main_partner'))
# if we know the country and the wizard has not yet been executed, we do it
if (part.country.id) and (wiz.state=='open'):
mod = 'l10n_'+part.country.code.lower()
ids = modules.search(cr, uid, [ ('name','=',mod) ], context=context)
if ids:
wizards.write(cr, uid, [ref('account.account_configuration_installer_todo')], {
'state': 'done'
})
wiz_id = self.create(cr, uid, {
'charts': mod
})
self.execute_simple(cr, uid, [wiz_id])
modules.state_update(cr, uid, ids,
'to install', ['uninstalled'], context=context)

View File

@ -10,6 +10,7 @@
<report auto="False" id="account_central_journal" model="account.journal.period" name="account.central.journal" rml="account/report/account_central_journal.rml" string="Central Journal" header="False"/>
<report auto="False" id="account_general_journal" model="account.journal.period" name="account.general.journal" rml="account/report/account_general_journal.rml" string="General Journal" header="False"/>
<report auto="False" id="account_journal" model="account.journal.period" name="account.journal.period.print" rml="account/report/account_journal.rml" string="Journal" header="False"/>
<report auto="False" id="account_journal_sale_purchase" model="account.journal.period" name="account.journal.period.print.sale.purchase" rml="account/report/account_journal_sale_purchase.rml" string="Sale/Purchase Journal" header="False"/>
<report auto="False" id="account_overdue" model="res.partner" name="account.overdue" rml="account/report/account_print_overdue.rml" string="Overdue Payments"/>
<report
auto="False"
@ -18,7 +19,8 @@
name="account.invoice"
rml="account/report/account_print_invoice.rml"
string="Invoices"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/',''))"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
usage="default"
multi="True"/>
<report id="account_transfers" model="account.transfer" name="account.transfer" string="Transfers" xml="account/report/transfer.xml" xsl="account/report/transfer.xsl"/>
<report auto="False" id="account_intracom" menu="False" model="account.move.line" name="account.intracom" string="IntraCom"/>

View File

@ -171,8 +171,8 @@
<field name="user_type" select="1"/>
<field name="active" groups="base.group_extended" />
<newline/>
<field name="debit" invisible="context.get('config_invisible', True)"/>
<field name="credit" invisible="context.get('config_invisible', True)"/>
<field name="debit" invisible="context.get('config_invisible', True)" attrs="{'readonly':[('type','=','view')]}"/>
<field name="credit" invisible="context.get('config_invisible', True)" attrs="{'readonly':[('type','=','view')]}"/>
<field name="balance" invisible="context.get('config_invisible', True)"/>
</group>
<notebook colspan="4">
@ -295,6 +295,44 @@
<field name="domain">[('parent_id','=',False)]</field>
</record>
<record id="view_account_gain_loss_tree" model="ir.ui.view">
<field name="name">Unrealized Gain or Loss</field>
<field name="model">account.account</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Unrealized Gains and losses">
<field name="code"/>
<field name="name"/>
<field name="parent_id" invisible="1"/>
<field name="user_type" invisible="1"/>
<field name="type" invisible="1"/>
<field name="currency_id"/>
<field name="exchange_rate"/>
<field name="foreign_balance"/>
<field name="adjusted_balance"/>
<field name="balance"/>
<field name="unrealized_gain_loss"/>
</tree>
</field>
</record>
<record id="action_account_gain_loss" model="ir.actions.act_window">
<field name="name">Unrealized Gain or Loss</field>
<field name="res_model">account.account</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_account_gain_loss_tree"/>
<field name="domain">[('currency_id','!=',False)]</field>
<field name="help">When doing multi-currency transactions, you may loose or gain some amount due to changes of exchange rate. This menu gives you a forecast of the Gain or Loss you'd realized if those transactions were ended today. Only for accounts having a secondary currency set.</field>
</record>
<menuitem
name="Unrealized Gain or Loss"
action="action_account_gain_loss"
groups="account.group_account_user"
id="menu_unrealized_gains_losses"
parent="account.menu_multi_currency"/>
<!--
Journal
@ -439,7 +477,7 @@
<separator string="Company" colspan="4"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="user_id" groups="base.group_extended"/>
<field name="currency"/>
<field name="currency" groups="base.group_extended"/>
</group>
<group colspan="2" col="2" groups="base.group_extended">
<separator string="Validations" colspan="4"/>
@ -486,8 +524,9 @@
<field name="arch" type="xml">
<search string="Search Bank Statements">
<group>
<filter string="Draft" domain="[('state','=','draft')]" icon="terp-document-new"/>
<filter string="Confirmed" domain="[('state','=','confirm')]" icon="terp-camera_test"/>
<filter string="Draft" name="state_draft" domain="[('state','=','draft')]" icon="terp-document-new"/>
<filter string="Open" name="state_open" domain="[('state','=','open')]" icon="terp-check"/>
<filter string="Confirmed" name="state_confirmed" domain="[('state','=','confirm')]" icon="terp-camera_test"/>
<separator orientation="vertical"/>
<field name="date"/>
<field name="name"/>
@ -556,7 +595,7 @@
<form string="Bank Statement">
<group col="7" colspan="4">
<field name="name" select="1"/>
<field name="date" select="1" on_change="onchange_date(date)"/>
<field name="date" select="1" on_change="onchange_date(date, company_id)"/>
<field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" select="1" widget="selection"/>
<newline/>
<field name="period_id"/>
@ -617,7 +656,8 @@
<form string="Bank Statement">
<group col="7" colspan="4">
<field name="name" select="1"/>
<field name="date" select="1" on_change="onchange_date(date)"/>
<field name="date" select="1" on_change="onchange_date(date, company_id)"/>
<field name='company_id' widget="selection" groups="base.group_multi_company" />
<field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" widget="selection"/>
<newline/>
<field name="period_id"/>
@ -752,7 +792,6 @@
<group col="2" colspan="2">
<separator string="Reporting Configuration" colspan="4"/>
<field name="report_type" select="2"/>
<field name="sign" />
</group>
<group col="2" colspan="2">
<separator string="Closing Method" colspan="4"/>
@ -1201,8 +1240,8 @@
</group>
<newline/>
<group>
<field name="journal_id" widget="selection" context="{'journal_id':self, 'visible_id':self, 'normal_view':False}"/>
<field name="period_id" context="{'period_id':self, 'search_default_period_id':self}"/>
<field name="journal_id" widget="selection" context="{'journal_id':self}"/>
<field name="period_id" context="{'period_id':self}"/>
</group>
<newline/>
<group expand="0" string="Group By...">
@ -1237,14 +1276,6 @@
groups="group_account_user"
/>
<record id="action_move_line_select" model="ir.actions.act_window">
<field name="name">Journal Items</field>
<field name="res_model">account.move.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_account_move_line_filter"/>
</record>
<record id="action_view_move_line" model="ir.actions.act_window">
<field name="name">Lines to reconcile</field>
<field name="res_model">account.move.line</field>
@ -1263,7 +1294,6 @@
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_move_line_tree"/>
<field name="search_view_id" ref="view_account_move_line_filter"/>
<field name="domain">[]</field>
<field name="context">{'search_default_account_id': [active_id]}</field>
</record>
@ -1272,7 +1302,6 @@
<field name="model">account.account</field>
<field name="name">Open Journal Items</field>
<field eval="'ir.actions.act_window,%d'%action_move_line_select" name="value"/>
<field eval="True" name="object"/>
</record>
<!--
Account.Entry Edition
@ -1327,7 +1356,10 @@
</group>
<notebook colspan="4">
<page string="Journal Items">
<field colspan="4" name="line_id" nolabel="1" height="250" widget="one2many_list" default_get="{'lines':line_id ,'journal':journal_id }">
<field name="balance" invisible="1"/>
<field colspan="4" name="line_id" nolabel="1" height="250" widget="one2many_list"
on_change="onchange_line_id(line_id)"
context="{'balance': balance , 'journal': journal_id }">
<form string="Journal Item">
<group col="6" colspan="4">
<field name="name"/>
@ -1550,7 +1582,12 @@
context="{'search_default_account_id':[active_id], 'search_default_unreconciled':1, 'default_account_id': active_id}"
src_model="account.account"/>
<act_window domain="[('reconcile_id', '=', active_id)]" id="act_account_acount_move_line_reconcile_open" name="Reconciled entries" res_model="account.move.line" src_model="account.move.reconcile"/>
<act_window
domain="[('reconcile_id', '=', active_id)]"
id="act_account_acount_move_line_reconcile_open"
name="Reconciled entries"
res_model="account.move.line"
src_model="account.move.reconcile"/>
<!--
@ -1592,7 +1629,7 @@
<tree string="Journal Entry Model Line" editable="bottom">
<field name="sequence"/>
<field name="name"/>
<field name="account_id"/>
<field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation'), ('company_id', '=', parent.company_id)]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="partner_id"/>
<field name="debit"/>
@ -1611,12 +1648,12 @@
<form string="Journal Entry Model Line">
<field colspan="4" name="name" select="1"/>
<field name="sequence"/>
<field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="account_id" domain="[('type','&lt;&gt;','view'), ('type','&lt;&gt;','consolidation'), ('company_id', '=', parent.company_id)]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="partner_id"/>
<field name="debit" select="1"/>
<field name="credit" select="1"/>
<field name="quantity"/>
<field name="quantity"/>
<field name="date_maturity"/>
</form>
</field>
@ -1714,35 +1751,37 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Payment Term">
<field name="name" select="1"/>
<field name="sequence"/>
<group colspan="2" col="4">
<separator string="Amount Computation" colspan="4"/>
<field name="value" colspan="4"/>
<field name="value_amount" colspan="4" attrs="{'readonly':[('value','=','balance')]}"/>
<group>
<group colspan="2" col="4">
<field name="name" select="1"/>
<separator string="Amount Computation" colspan="4"/>
<field name="value" colspan="4"/>
<field name="value_amount" colspan="4" attrs="{'readonly':[('value','=','balance')]}"/>
</group>
<group colspan="2" col="4">
<field name="sequence"/>
<separator string="Due Date Computation" colspan="4"/>
<field name="days" colspan="4"/>
<field name="days2" colspan="4"/>
</group>
</group>
<group colspan="2" col="4">
<separator string="Due date Computation" colspan="4"/>
<field name="days" colspan="4"/>
<field name="days2" colspan="4"/>
</group>
<label string=""/>
<newline/>
<label string="Example: at 14 net days 2 percents, remaining amount at 30 days end of month." colspan="4"/>
<separator string="Example" colspan="4"/>
<label string="At 14 net days 2 percent, remaining amount at 30 days end of month." colspan="4"/>
<group colspan="2" col="2">
<label string="Line 1:" colspan="2"/>
<label string=" valuation: percent"/>
<label string=" number of days: 14"/>
<label string=" value amount: 0.02"/>
<label string=" day of the month: 0"/>
<label string=" Valuation: Percent"/>
<label string=" Number of Days: 14"/>
<label string=" Value amount: 0.02"/>
<label string=" Day of the Month: 0"/>
</group>
<newline/>
<group colspan="2" col="2">
<label string="Line 2:" colspan="2"/>
<label string=" valuation: balance"/>
<label string=" number of days: 30"/>
<label string=" value amount: n.a"/>
<label string=" day of the month= -1"/>
<label string=" Valuation: Balance"/>
<label string=" Number of Days: 30"/>
<label string=" Value amount: n.a"/>
<label string=" Day of the Month= -1"/>
</group>
</form>
</field>
@ -1769,7 +1808,7 @@
<separator colspan="4" string="Information"/>
<field name="name" select="1"/>
<field name="active" select="1"/>
<separator colspan="4" string="Description on invoices"/>
<separator colspan="4" string="Description On Invoices"/>
<field colspan="4" name="note" nolabel="1"/>
<separator colspan="4" string="Computation"/>
<field colspan="4" name="line_ids" nolabel="1"/>
@ -1981,7 +2020,6 @@
<field name="model">account.tax.code</field>
<field name="name">Tax Details</field>
<field eval="'ir.actions.act_window,%d'%action_tax_code_line_open" name="value"/>
<field eval="True" name="object"/>
</record>
@ -2003,7 +2041,14 @@
res_model="account.move.line"
src_model="account.journal"/>
<act_window context="{'search_default_reconcile_id':False, 'search_default_partner_id':[active_id], 'default_partner_id': active_id}" domain="[('account_id.reconcile', '=', True),('account_id.type', 'in', ['receivable', 'payable'])]" id="act_account_partner_account_move_all" name="Receivables &amp; Payables" res_model="account.move.line" src_model="res.partner" groups="base.group_extended"/>
<act_window
context="{'search_default_reconcile_id':False, 'search_default_partner_id':[active_id], 'default_partner_id': active_id}"
domain="[('account_id.reconcile', '=', True),('account_id.type', 'in', ['receivable', 'payable'])]"
id="act_account_partner_account_move_all"
name="Receivables &amp; Payables"
res_model="account.move.line"
src_model="res.partner"
groups="base.group_extended"/>
<act_window context="{'search_default_partner_id':[active_id], 'default_partner_id': active_id}" id="act_account_partner_account_move" name="Journal Items" res_model="account.move.line" src_model="res.partner" groups="account.group_account_user"/>
@ -2068,6 +2113,7 @@
<field name="currency_id"/>
<field name="reconcile"/>
<field name="chart_template_id"/>
<separator string="Default taxes" colspan="4"/>
<field name="tax_ids" colspan="4" nolabel="1"/>
</page>
@ -2138,9 +2184,13 @@
<form string="Chart of Accounts Template">
<group>
<field name="name"/>
<field name="account_root_id"/>
<field name="bank_account_view_id"/>
<field name="tax_code_root_id"/>
<field name="account_root_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="bank_account_view_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="tax_code_root_id" attrs="{'required': [('parent_id', '=', False)]}"/>
<field name="parent_id" />
<!--<field name="code_digits" />-->
<field name="visible" />
<field name="complete_tax_set" />
</group>
<field name="tax_template_ids" colspan="4" readonly="1" nolabel="1"/>
<separator string="Properties" colspan="4"/>
@ -2224,7 +2274,9 @@
<field name="chart_template_id"/>
<field name="type"/>
<field name="type_tax_use"/>
<field name="price_include"/>
<group colspan="2" col="4">
<field name="price_include"/>
</group>
</group>
<notebook colspan="4">
<page string="Tax Definition">
@ -2391,10 +2443,14 @@
<group string="res_config_contents" position="replace">
<field name="company_id" widget="selection"/> <!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it -->
<field name ="code_digits" groups="account.group_account_user"/>
<field name="chart_template_id" widget="selection" on_change="onchange_chart_template_id(chart_template_id)"/>
<field name ="seq_journal" groups="account.group_account_user"/>
<field name="sale_tax" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('sale','all'))]"/>
<field name="purchase_tax" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('purchase', 'all'))]"/>
<field name="chart_template_id" widget="selection" on_change="onchange_chart_template_id(chart_template_id)" domain="[('visible','=', True)]"/>
<field name ="seq_journal" groups="base.group_extended"/>
<field name="sale_tax" attrs="{'invisible': [('complete_tax_set', '!=', True)]}" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('sale','all'))]"/>
<field name="purchase_tax" attrs="{'invisible': [('complete_tax_set', '!=', True)]}" domain="[('chart_template_id', '=', chart_template_id),('parent_id','=',False),('type_tax_use','in',('purchase', 'all'))]"/>
<newline/>
<field name ="sale_tax_rate" attrs="{'invisible': [('complete_tax_set', '=', True)]}" on_change="onchange_tax_rate(sale_tax_rate)"/>
<field name ="purchase_tax_rate" attrs="{'invisible': [('complete_tax_set', '=', True)]}"/>
<field name ="complete_tax_set" invisible="1"/>
<newline/> <!-- extended view because the web UI is not good for one2many -->
<field colspan="4" mode="tree" name="bank_accounts_id" nolabel="1" widget="one2many_list" groups="account.group_account_user">
<form string="Bank Information">
@ -2429,8 +2485,20 @@
<field name="model_id" ref="base.model_ir_actions_todo"/>
<field eval="5" name="sequence"/>
<field name="code">
act_window_ids = pool.get('ir.actions.act_window').search(cr, uid,[('name', 'in', ('Accounting Chart Configuration', 'Generate Chart of Accounts from a Chart Template'))], context=context)
todo_ids = pool.get('ir.actions.todo').search(cr, uid, [('action_id', 'in', act_window_ids)], context=context)
# check for unconfigured companies
account_installer_obj = self.pool.get('account.installer')
account_installer_obj.check_unconfigured_cmp(cr, uid, context=context)
action_ids = []
# fetch the act_window actions related to chart of account configuration
# we use ir.actions.todo to enable the possibility for other modules to insert their own
# wizards during the configuration process
ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_wizard_multi_chart')
if ref:
action_ids += [ref[1]]
ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_account_configuration_installer')
if ref:
action_ids += [ref[1]]
todo_ids = pool.get('ir.actions.todo').search(cr, uid, [('action_id', 'in', action_ids)], context=context)
pool.get('ir.actions.todo').write(cr, uid, todo_ids, {'state':'open'}, context=context)
action = pool.get('res.config').next(cr, uid, [], context)
</field>
@ -2557,7 +2625,7 @@ action = pool.get('res.config').next(cr, uid, [], context)
<form string="Statement">
<group col="6" colspan="4">
<field name="name" select="1"/>
<field name="company_id" select="1" groups="base.group_multi_company"/>
<field name='company_id' widget="selection" groups="base.group_multi_company" />
<field name="journal_id" on_change="onchange_journal_id(journal_id)" select="1" widget="selection"/>
<field name="user_id" select="1" readonly="1"/>
<field name="period_id" select="1"/>
@ -2630,7 +2698,7 @@ action = pool.get('res.config').next(cr, uid, [], context)
<group col="6" colspan="4">
<group col="2" colspan="2">
<separator string="Dates" colspan="4"/>
<field name="date" select="1" attrs="{'readonly':[('state','!=','draft')]}" on_change="onchange_date(date)"/>
<field name="date" select="1" attrs="{'readonly':[('state','!=','draft')]}" on_change="onchange_date(date, company_id)"/>
<field name="closing_date" select="1" readonly="1"/>
</group>
<group col="2" colspan="2">
@ -2721,10 +2789,15 @@ action = pool.get('res.config').next(cr, uid, [], context)
<field name="parent_id"/>
<field name="sequence"/>
<field name="type"/>
<field name="sign"/>
<field name="style_overwrite"/>
</group>
<notebook colspan="4">
<page string="Report" attrs="{'invisible': [('state','!=','confirm')]}">
<field name="display_detail" attrs="{'invisible': [('type','!=','accounts')]}"/>
<notebook colspan="6">
<page string="Report">
<group colspan="4" col="4">
<field name="display_detail" attrs="{'invisible': [('type','not in',['accounts','account_type'])]}" colspan="2"/>
<label string="" colspan="2"/>
</group>
<newline/>
<field name="account_ids" nolabel="1" colspan="6" attrs="{'invisible': [('type', '!=', 'accounts')]}"/>
<newline/>
@ -2733,9 +2806,6 @@ action = pool.get('res.config').next(cr, uid, [], context)
<field name="account_type_ids" nolabel="1" attrs="{'invisible': [('type', '!=', 'account_type')]}"/>
<newline/>
</page>
<page string="Notes" attrs="{'invisible': [('state','!=','confirm')]}">
<field name="note" nolabel="1" colspan="4"/>
</page>
</notebook>
</form>
</field>

View File

@ -30,6 +30,7 @@
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="domain">[('type','=','liquidity')]</field>
<field name="context">{'default_type': 'liquidity'}</field>
<field name="view_id" ref="account.view_treasory_graph"/>
</record>
<record id="board_account_form" model="ir.ui.view">
@ -38,17 +39,15 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Account Board">
<hpaned>
<child1>
<action colspan="4" height="160" width="400" name="%(account.action_invoice_tree1)d" string="Customer Invoices to Approve" domain="[('state','=','draft'),('type','=','out_invoice')]"/>
<action colspan="4" height="160" width="400" name="%(action_company_analysis_tree)d" string="Company Analysis" groups="account.group_account_manager"/>
</child1>
<child2>
<action colspan="4" height="220" name="%(action_treasory_graph)d" string="Treasury" groups="account.group_account_manager,account.group_account_user"/>
<action colspan="4" height="220" name="%(action_aged_receivable)d" string="Aged Receivables" groups="account.group_account_manager,account.group_account_user"/>
<!-- <action colspan="4" height="220" name="%(action_aged_income)d" string="Aged income"/> -->
</child2>
</hpaned>
<board style="2-1">
<column>
<action name="%(account.action_invoice_tree1)d" creatable="true" string="Draft Customer Invoices" domain="[('state','in',('draft','proforma2')), ('type','=','out_invoice')]"/>
<action name="%(action_company_analysis_tree)d" string="Company Analysis"/>
</column>
<column>
<action name="%(action_treasory_graph)d" string="Treasury"/> <!--groups="account.group_account_manager,account.group_account_user"-->
</column>
</board>
</form>
</field>
</record>

View File

@ -24,6 +24,7 @@ from osv import fields, osv
class res_company(osv.osv):
_inherit = "res.company"
_columns = {
'paypal_account': fields.char("Paypal Account", size=128, help="Paypal username (usually email) for receiving online payments."),
'overdue_msg': fields.text('Overdue Payments Message', translate=True),
'property_reserve_and_surplus_account': fields.property(
'account.account',

View File

@ -24,6 +24,7 @@
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="property_reserve_and_surplus_account" colspan="2"/>
<field name="paypal_account" />
</field>
</field>
</record>

View File

@ -1,26 +1,6 @@
<openerp>
<data>
<data noupdate="1">
<!-- Types -->
<record model="account.account.type" id="conf_account_type_receivable">
<field name="name">Receivable</field>
<field name="code">receivable</field>
<field name="report_type">income</field>
<field name="close_method">unreconciled</field>
</record>
<record model="account.account.type" id="conf_account_type_payable">
<field name="name">Payable</field>
<field name="code">payable</field>
<field name="report_type">expense</field>
<field name="close_method">unreconciled</field>
</record>
<record model="account.account.type" id="conf_account_type_view">
<field name="name">View</field>
<field name="code">view</field>
<field name="close_method">none</field>
</record>
<record model="account.account.type" id="account_type_income_view1">
<field name="name">Income View</field>
<field name="code">view</field>
@ -41,78 +21,32 @@
<field name="code">liability</field>
<field name="report_type">liability</field>
</record>
<record model="account.account.type" id="conf_account_type_income">
<field name="name">Income</field>
<field name="code">income</field>
<field name="report_type">income</field>
<field name="close_method">none</field>
</record>
<record model="account.account.type" id="conf_account_type_expense">
<field name="name">Expense</field>
<field name="code">expense</field>
<field name="report_type">expense</field>
<field name="close_method">none</field>
</record>
<record model="account.account.type" id="conf_account_type_tax">
<field name="name">Tax</field>
<field name="code">tax</field>
<field name="report_type">expense</field>
<field name="close_method">unreconciled</field>
<field name="report_type">expense</field>
</record>
<record model="account.account.type" id="conf_account_type_cash">
<field name="name">Cash</field>
<field name="code">cash</field>
<field name="report_type">asset</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="conf_account_type_liability">
<field name="name">Liability</field>
<field name="code">liability</field>
<field name="report_type">liability</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="conf_account_type_asset">
<field name="name">Asset</field>
<field name="code">asset</field>
<field name="report_type">asset</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="conf_account_type_equity">
<field name="name">Equity</field>
<field name="code">equity</field>
<field name="close_method">balance</field>
<field name="report_type">liability</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="conf_account_type_bnk">
<field name="name">Bank</field>
<field name="code">bank</field>
<field name="report_type">asset</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="conf_account_type_chk">
<record model="account.account.type" id="conf_account_type_chk">
<field name="name">Check</field>
<field name="code">check</field>
<field name="report_type">asset</field>
<field name="close_method">balance</field>
<field name="report_type">asset</field>
</record>
<!-- Account Templates-->
<record id="conf_chart0" model="account.account.template">
<field name="code">0</field>
<field name="name">Configurable Account Chart</field>
<field eval="0" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="conf_account_type_view"/>
<field name="user_type" ref="data_account_type_view"/>
</record>
<!-- Balance Sheet -->
@ -122,7 +56,7 @@
<field name="name">Balance Sheet</field>
<field ref="conf_chart0" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="conf_account_type_view"/>
<field name="user_type" ref="data_account_type_view"/>
</record>
<record id="conf_fas" model="account.account.template">
@ -162,7 +96,7 @@
<field name="name">Purchased Stocks</field>
<field ref="conf_cas" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="conf_a_recv" model="account.account.template">
@ -171,7 +105,7 @@
<field ref="conf_cas" name="parent_id"/>
<field name="type">receivable</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="conf_account_type_receivable"/>
<field name="user_type" ref="data_account_type_receivable"/>
</record>
<record id="conf_ova" model="account.account.template">
@ -179,7 +113,7 @@
<field name="name">Tax Paid</field>
<field ref="conf_cas" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="conf_bnk" model="account.account.template">
@ -195,49 +129,49 @@
<field name="name">Opening Income Account</field>
<field ref="conf_cas" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_income"/>
<field name="user_type" ref="data_account_type_income"/>
</record>
<record id="conf_cli" model="account.account.template">
<field name="code">111</field>
<field name="code">12</field>
<field name="name">Current Liabilities</field>
<field ref="conf_nca" name="parent_id"/>
<field ref="conf_bal" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_liability_view1"/>
</record>
<record id="conf_a_pay" model="account.account.template">
<field name="code">1111</field>
<field name="code">120</field>
<field name="name">Creditors</field>
<field ref="conf_cli" name="parent_id"/>
<field name="type">payable</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="conf_account_type_payable"/>
<field name="user_type" ref="data_account_type_payable"/>
</record>
<record id="conf_iva" model="account.account.template">
<field name="code">1112</field>
<field name="code">121</field>
<field name="name">Tax Received</field>
<field ref="conf_cli" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_liability"/>
<field name="user_type" ref="data_account_type_liability"/>
</record>
<record id="conf_a_reserve_and_surplus" model="account.account.template">
<field name="code">1113</field>
<field name="code">122</field>
<field name="name">Reserve and Profit/Loss Account</field>
<field ref="conf_cli" name="parent_id"/>
<field name="type">other</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="conf_account_type_liability"/>
<field name="user_type" ref="data_account_type_liability"/>
</record>
<record id="conf_o_expense" model="account.account.template">
<field name="code">1114</field>
<field name="code">123</field>
<field name="name">Opening Expense Account</field>
<field ref="conf_cli" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<!-- Profit and Loss -->
@ -247,7 +181,7 @@
<field name="name">Profit and Loss</field>
<field ref="conf_chart0" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="conf_account_type_view"/>
<field name="user_type" ref="data_account_type_view"/>
</record>
<record id="conf_rev" model="account.account.template">
@ -263,7 +197,7 @@
<field name="name">Product Sales</field>
<field ref="conf_rev" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_income"/>
<field name="user_type" ref="data_account_type_income"/>
</record>
<record id="conf_cos" model="account.account.template">
@ -279,7 +213,7 @@
<field name="name">Cost of Goods Sold</field>
<field ref="conf_cos" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<record id="conf_ovr" model="account.account.template">
@ -295,7 +229,7 @@
<field name="name">Expenses</field>
<field ref="conf_ovr" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<record id="conf_a_salary_expense" model="account.account.template">
@ -303,7 +237,7 @@
<field name="name">Salary Expenses</field>
<field ref="conf_ovr" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="conf_account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<!-- Taxes -->
@ -448,6 +382,7 @@
<field name="property_account_income_opening" ref="conf_o_income"/>
<field name="property_account_expense_opening" ref="conf_o_expense"/>
<field name="property_reserve_and_surplus_account" ref="conf_a_reserve_and_surplus"/>
<field name="complete_tax_set" eval="False"/>
</record>
<!-- VAT Codes -->

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record model="account.account.type" id="data_account_type_view">
<field name="name">Root/View</field>
<field name="code">view</field>
<field name="close_method">none</field>
</record>
<record model="account.account.type" id="data_account_type_receivable">
<field name="name">Receivable</field>
<field name="code">receivable</field>
<field name="close_method">unreconciled</field>
<field name="report_type">asset</field>
</record>
<record model="account.account.type" id="data_account_type_payable">
<field name="name">Payable</field>
<field name="code">payable</field>
<field name="close_method">unreconciled</field>
<field name="report_type">liability</field>
</record>
<record model="account.account.type" id="data_account_type_bank">
<field name="name">Bank</field>
<field name="code">bank</field>
<field name="close_method">balance</field>
</record>
<record model="account.account.type" id="data_account_type_cash">
<field name="name">Cash</field>
<field name="code">cash</field>
<field name="close_method">balance</field>
<field name="report_type">asset</field>
</record>
<record model="account.account.type" id="data_account_type_asset">
<field name="name">Asset</field>
<field name="code">asset</field>
<field name="close_method">balance</field>
<field name="report_type">asset</field>
</record>
<record model="account.account.type" id="data_account_type_liability">
<field name="name">Liability</field>
<field name="code">liability</field>
<field name="close_method">balance</field>
<field name="report_type">liability</field>
</record>
<record model="account.account.type" id="data_account_type_income">
<field name="name">Income</field>
<field name="code">income</field>
<field name="close_method">none</field>
<field name="report_type">income</field>
</record>
<record model="account.account.type" id="data_account_type_expense">
<field name="name">Expense</field>
<field name="code">expense</field>
<field name="close_method">none</field>
<field name="report_type">expense</field>
</record>
</data>
</openerp>

View File

@ -7,7 +7,7 @@
-->
<record id="data_fiscalyear" model="account.fiscalyear">
<field eval="'Fiscal Year '+time.strftime('%Y')" name="name"/>
<field eval="'Fiscal Year X '+time.strftime('%Y')" name="name"/>
<field eval="'FY'+time.strftime('%Y')" name="code"/>
<field eval="time.strftime('%Y')+'-01-01'" name="date_start"/>
<field eval="time.strftime('%Y')+'-12-31'" name="date_stop"/>
@ -20,7 +20,7 @@
<record id="period_1" model="account.period">
<field eval="'01/'+time.strftime('%Y')" name="code"/>
<field eval="'01/'+time.strftime('%Y')" name="name"/>
<field eval="'X 01/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-01-01'" name="date_start"/>
@ -29,16 +29,17 @@
</record>
<record id="period_2" model="account.period">
<field eval="'02/'+time.strftime('%Y')" name="code"/>
<field eval="'02/'+time.strftime('%Y')" name="name"/>
<field eval="'X 02/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-02-01'" name="date_start"/>
<field eval="time.strftime('%Y')+'-02-28'" name="date_stop"/>
<!-- for the last day of February, we have to compute the day before March 1st -->
<field eval="(DateTime.today().replace(month=3, day=1) - timedelta(days=1)).strftime('%Y-%m-%d')" name="date_stop"/>
<field name="company_id" ref="base.main_company"/>
</record>
<record id="period_3" model="account.period">
<field eval="'03/'+time.strftime('%Y')" name="code"/>
<field eval="'03/'+time.strftime('%Y')" name="name"/>
<field eval="'X 03/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-03-01'" name="date_start"/>
@ -47,7 +48,7 @@
</record>
<record id="period_4" model="account.period">
<field eval="'04/'+time.strftime('%Y')" name="code"/>
<field eval="'04/'+time.strftime('%Y')" name="name"/>
<field eval="'X 04/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-04-01'" name="date_start"/>
@ -56,7 +57,7 @@
</record>
<record id="period_5" model="account.period">
<field eval="'05/'+time.strftime('%Y')" name="code"/>
<field eval="'05/'+time.strftime('%Y')" name="name"/>
<field eval="'X 05/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-05-01'" name="date_start"/>
@ -65,7 +66,7 @@
</record>
<record id="period_6" model="account.period">
<field eval="'06/'+time.strftime('%Y')" name="code"/>
<field eval="'06/'+time.strftime('%Y')" name="name"/>
<field eval="'X 06/'+time.strftime('%Y')" name="name"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="True" name="special"/>
<field eval="time.strftime('%Y')+'-06-01'" name="date_start"/>
@ -74,7 +75,7 @@
</record>
<record id="period_7" model="account.period">
<field eval="'07/'+time.strftime('%Y')" name="code"/>
<field eval="'07/'+time.strftime('%Y')" name="name"/>
<field eval="'X 07/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-07-01'" name="date_start"/>
@ -83,7 +84,7 @@
</record>
<record id="period_8" model="account.period">
<field eval="'08/'+time.strftime('%Y')" name="code"/>
<field eval="'08/'+time.strftime('%Y')" name="name"/>
<field eval="'X 08/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-08-01'" name="date_start"/>
@ -92,7 +93,7 @@
</record>
<record id="period_9" model="account.period">
<field eval="'09/'+time.strftime('%Y')" name="code"/>
<field eval="'09/'+time.strftime('%Y')" name="name"/>
<field eval="'X 09/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-09-01'" name="date_start"/>
@ -101,7 +102,7 @@
</record>
<record id="period_10" model="account.period">
<field eval="'10/'+time.strftime('%Y')" name="code"/>
<field eval="'10/'+time.strftime('%Y')" name="name"/>
<field eval="'X 10/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-10-01'" name="date_start"/>
@ -110,7 +111,7 @@
</record>
<record id="period_11" model="account.period">
<field eval="'11/'+time.strftime('%Y')" name="code"/>
<field eval="'11/'+time.strftime('%Y')" name="name"/>
<field eval="'X 11/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-11-01'" name="date_start"/>
@ -119,7 +120,7 @@
</record>
<record id="period_12" model="account.period">
<field eval="'12/'+time.strftime('%Y')" name="code"/>
<field eval="'12/'+time.strftime('%Y')" name="name"/>
<field eval="'X 12/'+time.strftime('%Y')" name="name"/>
<field eval="True" name="special"/>
<field name="fiscalyear_id" ref="data_fiscalyear"/>
<field eval="time.strftime('%Y')+'-12-01'" name="date_start"/>
@ -129,6 +130,6 @@
<record id="base.user_demo" model="res.users">
<field name="groups_id" eval="[(4,ref('account.group_account_user'))]"/>
</record>
</record>
</data>
</openerp>

View File

@ -2,9 +2,9 @@
<openerp>
<data noupdate="1">
<record id="demo_invoice_0" model="account.invoice">
<field name="date_due">2011-07-21</field>
<field name="date_due" eval="time.strftime('%Y')+'-01-30'"/>
<field name="payment_term" ref="account.account_payment_term"/>
<field name="journal_id" ref="account.refund_expenses_journal"/>
<field name="journal_id" ref="account.expenses_journal"/>
<field name="currency_id" ref="base.EUR"/>
<field name="address_invoice_id" ref="base.res_partner_address_wong"/>
<field name="user_id" ref="base.user_demo"/>
@ -15,7 +15,7 @@
<field name="type">in_invoice</field>
<field name="account_id" ref="account.a_pay"/>
<field eval="0" name="reconciled"/>
<field name="date_invoice">2011-06-01</field>
<field name="date_invoice" eval="time.strftime('%Y')+'-01-01'"/>
<field eval="14.0" name="amount_untaxed"/>
<field eval="14.0" name="amount_total"/>
<field name="partner_id" ref="base.res_partner_maxtor"/>

View File

@ -5,62 +5,15 @@
Account Type
-->
<record id="account_type_root" model="account.account.type">
<field name="name">View</field>
<field name="code">view</field>
<field name="close_method">none</field>
</record>
<record id="account_type_asset" model="account.account.type">
<field name="name">Asset</field>
<field name="code">asset</field>
<field name="report_type">asset</field>
<field name="close_method">balance</field>
</record>
<record id="account_type_receivable" model="account.account.type">
<field name="name">Receivable</field>
<field name="code">receivable</field>
<field name="report_type">asset</field>
<field name="close_method">unreconciled</field>
</record>
<record id="account_type_liability" model="account.account.type">
<field name="name">Liability</field>
<field name="code">liability</field>
<field name="report_type">liability</field>
<field name="close_method">balance</field>
</record>
<record id="account_type_payable" model="account.account.type">
<field name="name">Payable</field>
<field name="code">payable</field>
<field name="report_type">liability</field>
<field name="close_method">unreconciled</field>
</record>
<record id="account_type_income" model="account.account.type">
<field name="name">Income</field>
<field name="code">income</field>
<field name="report_type">income</field>
<field name="close_method">none</field>
</record>
<record id="account_type_expense" model="account.account.type">
<field name="name">Expense</field>
<field name="code">expense</field>
<field name="report_type">expense</field>
<field name="close_method">none</field>
</record>
<record id="account_type_cash_equity" model="account.account.type">
<field name="name">Equity</field>
<field name="code">equity</field>
<field name="close_method">balance</field>
<field name="report_type">liability</field>
<field name="close_method">balance</field>
</record>
<record id="account_type_cash_moves" model="account.account.type">
<field name="name">Cash</field>
<field name="code">cash</field>
<field name="report_type">asset</field>
<field name="close_method">balance</field>
</record>
<!--
Chart of Account
Chart of Accounts
-->
<record id="chart0" model="account.account">
@ -68,7 +21,7 @@
<field name="name">Chart For Automated Tests</field>
<field eval="0" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_root"/>
<field name="user_type" ref="data_account_type_view"/>
</record>
<!-- Balance Sheet -->
@ -78,14 +31,14 @@
<field name="name">Balance Sheet - (test)</field>
<field ref="chart0" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_root"/>
<field name="user_type" ref="data_account_type_view"/>
</record>
<record model="account.account" id="assets_view">
<field name="name">Assets - (test)</field>
<field name="code">X10</field>
<field name="type">view</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="bal"/>
</record>
@ -95,7 +48,7 @@
<field name="name">Fixed Assets - (test)</field>
<field ref="assets_view" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="xfa" model="account.account">
@ -103,7 +56,7 @@
<field name="name">Fixed Asset Account - (test)</field>
<field ref="fas" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="nca" model="account.account">
@ -111,7 +64,7 @@
<field name="name">Net Current Assets - (test)</field>
<field ref="assets_view" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="cas" model="account.account">
@ -119,7 +72,7 @@
<field name="name">Current Assets - (test)</field>
<field ref="nca" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="stk" model="account.account">
@ -127,7 +80,7 @@
<field name="name">Purchased Stocks - (test)</field>
<field ref="cas" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="a_recv" model="account.account">
@ -136,7 +89,7 @@
<field ref="cas" name="parent_id"/>
<field name="type">receivable</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="account_type_receivable"/>
<field name="user_type" ref="data_account_type_receivable"/>
</record>
<record id="ova" model="account.account">
@ -144,7 +97,7 @@
<field name="name">Output VAT - (test)</field>
<field ref="cas" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="bnk" model="account.account">
@ -152,7 +105,7 @@
<field name="name">Bank Current Account - (test)</field>
<field ref="cas" name="parent_id"/>
<field name="type">liquidity</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="cash" model="account.account">
@ -160,7 +113,7 @@
<field name="name">Cash - (test)</field>
<field ref="cas" name="parent_id"/>
<field name="type">liquidity</field>
<field name="user_type" ref="account_type_asset"/>
<field name="user_type" ref="data_account_type_asset"/>
</record>
<record id="o_income" model="account.account">
@ -168,14 +121,14 @@
<field name="name">Opening Income - (test)</field>
<field ref="cas" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_income"/>
<field name="user_type" ref="data_account_type_income"/>
</record>
<record model="account.account" id="liabilities_view">
<field name="name">Liabilities - (test)</field>
<field name="code">X11</field>
<field name="type">view</field>
<field name="user_type" ref="account_type_liability"/>
<field name="user_type" ref="data_account_type_liability"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="bal"/>
</record>
@ -185,7 +138,7 @@
<field name="name">Current Liabilities - (test)</field>
<field ref="liabilities_view" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_liability"/>
<field name="user_type" ref="data_account_type_liability"/>
</record>
<record id="a_pay" model="account.account">
@ -194,7 +147,7 @@
<field ref="cli" name="parent_id"/>
<field name="type">payable</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="account_type_payable"/>
<field name="user_type" ref="data_account_type_payable"/>
</record>
<record id="iva" model="account.account">
@ -202,7 +155,7 @@
<field name="name">Input VAT - (test)</field>
<field ref="cli" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_liability"/>
<field name="user_type" ref="data_account_type_liability"/>
</record>
<record id="rsa" model="account.account">
@ -210,7 +163,7 @@
<field name="name">Reserve and Profit/Loss - (test)</field>
<field ref="cli" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_liability"/>
<field name="user_type" ref="data_account_type_liability"/>
</record>
<record id="o_expense" model="account.account">
@ -218,7 +171,7 @@
<field name="name">Opening Expense - (test)</field>
<field ref="cli" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<!-- Profit and Loss -->
@ -228,14 +181,14 @@
<field name="name">Profit and Loss - (test)</field>
<field ref="chart0" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_root"/>
<field name="user_type" ref="data_account_type_view"/>
</record>
<record model="account.account" id="income_view">
<field name="name">Income - (test)</field>
<field name="code">X20</field>
<field name="type">view</field>
<field name="user_type" ref="account_type_income"/>
<field name="user_type" ref="data_account_type_income"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="gpf"/>
</record>
@ -244,7 +197,7 @@
<field name="name">Foreign Exchange Gain - (test)</field>
<field name="code">X201</field>
<field name="type">other</field>
<field name="user_type" ref="account_type_income"/>
<field name="user_type" ref="data_account_type_income"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="income_view"/>
</record>
@ -254,7 +207,7 @@
<field name="name">Revenue - (test)</field>
<field ref="income_view" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_income"/>
<field name="user_type" ref="data_account_type_income"/>
</record>
<record id="a_sale" model="account.account">
@ -262,14 +215,14 @@
<field name="name">Product Sales - (test)</field>
<field ref="rev" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_income"/>
<field name="user_type" ref="data_account_type_income"/>
</record>
<record model="account.account" id="expense_view">
<field name="name">Expense - (test)</field>
<field name="code">X21</field>
<field name="type">view</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="gpf"/>
</record>
@ -280,7 +233,7 @@
<field name="name">Cost of Sales - (test)</field>
<field ref="expense_view" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<record id="cog" model="account.account">
@ -288,7 +241,7 @@
<field name="name">Cost of Goods Sold - (test)</field>
<field ref="cos" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<record id="ovr" model="account.account">
@ -296,7 +249,7 @@
<field name="name">Overheads - (test)</field>
<field ref="expense_view" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<record id="a_expense" model="account.account">
@ -304,14 +257,14 @@
<field name="name">Expenses - (test)</field>
<field ref="ovr" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<record model="account.account" id="income_fx_expense">
<field name="name">Foreign Exchange Loss - (test)</field>
<field name="code">X2111</field>
<field name="type">other</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" ref="ovr"/>
</record>
@ -321,7 +274,7 @@
<field name="name">Salary Expenses - (test)</field>
<field ref="ovr" name="parent_id"/>
<field name="type">other</field>
<field name="user_type" ref="account_type_expense"/>
<field name="user_type" ref="data_account_type_expense"/>
</record>
<!-- Properties -->

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2011 OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,275 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2011 OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv, orm
from edi import EDIMixin
INVOICE_LINE_EDI_STRUCT = {
'name': True,
'origin': True,
'uos_id': True,
'product_id': True,
'price_unit': True,
'quantity': True,
'discount': True,
'note': True,
# fields used for web preview only - discarded on import
'price_subtotal': True,
}
INVOICE_TAX_LINE_EDI_STRUCT = {
'name': True,
'base': True,
'amount': True,
'manual': True,
'sequence': True,
'base_amount': True,
'tax_amount': True,
}
INVOICE_EDI_STRUCT = {
'name': True,
'origin': True,
'company_id': True, # -> to be changed into partner
'type': True, # -> reversed at import
'internal_number': True, # -> reference at import
'comment': True,
'date_invoice': True,
'date_due': True,
'partner_id': True,
'payment_term': True,
#custom: currency_id
'invoice_line': INVOICE_LINE_EDI_STRUCT,
'tax_line': INVOICE_TAX_LINE_EDI_STRUCT,
# fields used for web preview only - discarded on import
#custom: 'partner_ref'
'amount_total': True,
'amount_untaxed': True,
'amount_tax': True,
}
class account_invoice(osv.osv, EDIMixin):
_inherit = 'account.invoice'
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
"""Exports a supplier or customer invoice"""
edi_struct = dict(edi_struct or INVOICE_EDI_STRUCT)
res_company = self.pool.get('res.company')
res_partner_address = self.pool.get('res.partner.address')
edi_doc_list = []
for invoice in records:
# generate the main report
self._edi_generate_report_attachment(cr, uid, invoice, context=context)
edi_doc = super(account_invoice,self).edi_export(cr, uid, [invoice], edi_struct, context)[0]
edi_doc.update({
'company_address': res_company.edi_export_address(cr, uid, invoice.company_id, context=context),
'company_paypal_account': invoice.company_id.paypal_account,
'partner_address': res_partner_address.edi_export(cr, uid, [invoice.address_invoice_id], context=context)[0],
'currency': self.pool.get('res.currency').edi_export(cr, uid, [invoice.currency_id], context=context)[0],
'partner_ref': invoice.reference or False,
})
edi_doc_list.append(edi_doc)
return edi_doc_list
def _edi_tax_account(self, cr, uid, invoice_type='out_invoice', context=None):
#TODO/FIXME: should select proper Tax Account
account_pool = self.pool.get('account.account')
account_ids = account_pool.search(cr, uid, [('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')])
tax_account = False
if account_ids:
tax_account = account_pool.browse(cr, uid, account_ids[0])
return tax_account
def _edi_invoice_account(self, cr, uid, partner_id, invoice_type, context=None):
partner_pool = self.pool.get('res.partner')
partner = partner_pool.browse(cr, uid, partner_id, context=context)
if invoice_type in ('out_invoice', 'out_refund'):
invoice_account = partner.property_account_receivable
else:
invoice_account = partner.property_account_payable
return invoice_account
def _edi_product_account(self, cr, uid, product_id, invoice_type, context=None):
product_pool = self.pool.get('product.product')
product = product_pool.browse(cr, uid, product_id, context=context)
if invoice_type in ('out_invoice','out_refund'):
account = product.property_account_income or product.categ_id.property_account_income_categ
else:
account = product.property_account_expense or product.categ_id.property_account_expense_categ
return account
def _edi_import_company(self, cr, uid, edi_document, context=None):
# TODO: for multi-company setups, we currently import the document in the
# user's current company, but we should perhaps foresee a way to select
# the desired company among the user's allowed companies
self._edi_requires_attributes(('company_id','company_address','type'), edi_document)
res_partner_address = self.pool.get('res.partner.address')
res_partner = self.pool.get('res.partner')
# imported company = new partner
src_company_id, src_company_name = edi_document.pop('company_id')
partner_id = self.edi_import_relation(cr, uid, 'res.partner', src_company_name,
src_company_id, context=context)
invoice_type = edi_document['type']
partner_value = {}
if invoice_type in ('out_invoice', 'out_refund'):
partner_value.update({'customer': True})
if invoice_type in ('in_invoice', 'in_refund'):
partner_value.update({'supplier': True})
res_partner.write(cr, uid, [partner_id], partner_value, context=context)
# imported company_address = new partner address
address_info = edi_document.pop('company_address')
address_info['partner_id'] = (src_company_id, src_company_name)
address_info['type'] = 'invoice'
address_id = res_partner_address.edi_import(cr, uid, address_info, context=context)
# modify edi_document to refer to new partner
partner_address = res_partner_address.browse(cr, uid, address_id, context=context)
edi_document['partner_id'] = (src_company_id, src_company_name)
edi_document.pop('partner_address', False) # ignored
edi_document['address_invoice_id'] = self.edi_m2o(cr, uid, partner_address, context=context)
return partner_id
def edi_import(self, cr, uid, edi_document, context=None):
""" During import, invoices will import the company that is provided in the invoice as
a new partner (e.g. supplier company for a customer invoice will be come a supplier
record for the new invoice.
Summary of tasks that need to be done:
- import company as a new partner, if type==in then supplier=1, else customer=1
- partner_id field is modified to point to the new partner
- company_address data used to add address to new partner
- change type: out_invoice'<->'in_invoice','out_refund'<->'in_refund'
- reference: should contain the value of the 'internal_number'
- reference_type: 'none'
- internal number: reset to False, auto-generated
- journal_id: should be selected based on type: simply put the 'type'
in the context when calling create(), will be selected correctly
- payment_term: if set, create a default one based on name...
- for invoice lines, the account_id value should be taken from the
product's default, i.e. from the default category, as it will not
be provided.
- for tax lines, we disconnect from the invoice.line, so all tax lines
will be of type 'manual', and default accounts should be picked based
on the tax config of the DB where it is imported.
"""
if context is None:
context = {}
self._edi_requires_attributes(('company_id','company_address','type','invoice_line','currency'), edi_document)
# extract currency info
res_currency = self.pool.get('res.currency')
currency_info = edi_document.pop('currency')
currency_id = res_currency.edi_import(cr, uid, currency_info, context=context)
currency = res_currency.browse(cr, uid, currency_id)
edi_document['currency_id'] = self.edi_m2o(cr, uid, currency, context=context)
# change type: out_invoice'<->'in_invoice','out_refund'<->'in_refund'
invoice_type = edi_document['type']
invoice_type = invoice_type.startswith('in_') and invoice_type.replace('in_','out_') or invoice_type.replace('out_','in_')
edi_document['type'] = invoice_type
#import company as a new partner
partner_id = self._edi_import_company(cr, uid, edi_document, context=context)
# Set Account
invoice_account = self._edi_invoice_account(cr, uid, partner_id, invoice_type, context=context)
edi_document['account_id'] = invoice_account and self.edi_m2o(cr, uid, invoice_account, context=context) or False
# reference: should contain the value of the 'internal_number'
edi_document['reference'] = edi_document.get('internal_number', False)
# reference_type: 'none'
edi_document['reference_type'] = 'none'
# internal number: reset to False, auto-generated
edi_document['internal_number'] = False
# discard web preview fields, if present
edi_document.pop('partner_ref', None)
# journal_id: should be selected based on type: simply put the 'type' in the context when calling create(), will be selected correctly
context.update(type=invoice_type)
# for invoice lines, the account_id value should be taken from the product's default, i.e. from the default category, as it will not be provided.
for edi_invoice_line in edi_document['invoice_line']:
product_info = edi_invoice_line['product_id']
product_id = self.edi_import_relation(cr, uid, 'product.product', product_info[1],
product_info[0], context=context)
account = self._edi_product_account(cr, uid, product_id, invoice_type, context=context)
# TODO: could be improved with fiscal positions perhaps
# account = fpos_obj.map_account(cr, uid, fiscal_position_id, account.id)
edi_invoice_line['account_id'] = self.edi_m2o(cr, uid, account, context=context) if account else False
# discard web preview fields, if present
edi_invoice_line.pop('price_subtotal', None)
# for tax lines, we disconnect from the invoice.line, so all tax lines will be of type 'manual', and default accounts should be picked based
# on the tax config of the DB where it is imported.
tax_account = self._edi_tax_account(cr, uid, context=context)
tax_account_info = self.edi_m2o(cr, uid, tax_account, context=context)
for edi_tax_line in edi_document.get('tax_line', []):
edi_tax_line['account_id'] = tax_account_info
edi_tax_line['manual'] = True
return super(account_invoice,self).edi_import(cr, uid, edi_document, context=context)
def _edi_record_display_action(self, cr, uid, id, context=None):
"""Returns an appropriate action definition dict for displaying
the record with ID ``rec_id``.
:param int id: database ID of record to display
:return: action definition dict
"""
action = super(account_invoice,self)._edi_record_display_action(cr, uid, id, context=context)
try:
invoice = self.browse(cr, uid, id, context=context)
if 'out_' in invoice.type:
view_ext_id = 'invoice_form'
journal_type = 'sale'
else:
view_ext_id = 'invoice_supplier_form'
journal_type = 'purchase'
ctx = "{'type': '%s', 'journal_type': '%s'}" % (invoice.type, journal_type)
action.update(context=ctx)
view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', view_ext_id)[1]
action.update(views=[(view_id,'form'), (False, 'tree')])
except ValueError:
# ignore if views are missing
pass
return action
class account_invoice_line(osv.osv, EDIMixin):
_inherit='account.invoice.line'
class account_invoice_tax(osv.osv, EDIMixin):
_inherit = "account.invoice.tax"
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,186 @@
<?xml version="1.0" ?>
<openerp>
<data>
<!-- EDI Export + Send email Action -->
<record id="ir_actions_server_edi_invoice" model="ir.actions.server">
<field name="code">if (object.type in ('out_invoice', 'out_refund')) and not object.partner_id.opt_out: object.edi_export_and_email(template_ext_id='account.email_template_edi_invoice', context=context)</field>
<field eval="6" name="sequence"/>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="condition">True</field>
<field name="name">Auto-email confirmed invoices</field>
</record>
<!-- EDI related Email Templates menu -->
<record model="ir.actions.act_window" id="action_email_templates">
<field name="name">Email Templates</field>
<field name="res_model">email.template</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" ref="email_template.email_template_tree" />
<field name="search_view_id" ref="email_template.view_email_template_search"/>
<field name="context">{'search_default_model_id':'account.invoice'}</field>
<field name="context" eval="{'search_default_model_id': ref('account.model_account_invoice')}"/>
</record>
<menuitem id="menu_email_templates" parent="menu_configuration_misc" action="action_email_templates" sequence="30"/>
</data>
<!-- Mail template and workflow bindings are done in a NOUPDATE block
so users can freely customize/delete them -->
<data noupdate="1">
<!-- bind the mailing server action to invoice open activity -->
<record id="account.act_open" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_edi_invoice"/>
</record>
<!--Email template -->
<record id="email_template_edi_invoice" model="email.template">
<field name="name">Automated Invoice Notification Mail</field>
<field name="email_from">${object.user_id.user_email or object.company_id.email or 'noreply@localhost'}</field>
<field name="subject">${object.company_id.name} Invoice (Ref ${object.number or 'n/a' })</field>
<field name="email_to">${object.address_invoice_id.email or ''}</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); ">
<p>Hello${object.address_invoice_id.name and ' ' or ''}${object.address_invoice_id.name or ''},</p>
<p>A new invoice is available for ${object.partner_id.name}: </p>
<p style="border-left: 1px solid #8e0000; margin-left: 30px;">
&nbsp;&nbsp;<strong>REFERENCES</strong><br />
&nbsp;&nbsp;Invoice number: <strong>${object.number}</strong><br />
&nbsp;&nbsp;Invoice total: <strong>${object.amount_total} ${object.currency_id.name}</strong><br />
&nbsp;&nbsp;Invoice date: ${object.date_invoice}<br />
% if object.origin:
&nbsp;&nbsp;Order reference: ${object.origin}<br />
% endif
&nbsp;&nbsp;Your contact: <a href="mailto:${object.user_id.user_email or ''}?subject=Invoice%20${object.number}">${object.user_id.name}</a>
</p>
<p>
You can view the invoice document, download it and pay online using the following link:
</p>
<a style="display:block; width: 150px; height:20px; margin-left: 120px; color: #FFF; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; text-align: center; text-decoration: none !important; line-height: 1; padding: 5px 0px 0px 0px; background-color: #8E0000; border-radius: 5px 5px; background-repeat: repeat no-repeat;"
href="${ctx.get('edi_web_url_view') or ''}">View Invoice</a>
% if object.company_id.paypal_account and object.type in ('out_invoice', 'in_refund'):
<%
comp_name = quote(object.company_id.name)
inv_number = quote(object.number)
paypal_account = quote(object.company_id.paypal_account)
inv_amount = quote(str(object.amount_total))
cur_name = quote(object.currency_id.name)
paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=%s&amp;item_name=%s%%20Invoice%%20%s&amp;" \
"invoice=%s&amp;amount=%s&amp;currency_code=%s&amp;button_subtype=services&amp;no_note=1&amp;bn=OpenERP_Invoice_PayNow_%s" % \
(paypal_account,comp_name,inv_number,inv_number,inv_amount,cur_name,cur_name)
%>
<br/>
<p>It is also possible to directly pay with Paypal:</p>
<a style="margin-left: 120px;" href="${paypal_url}">
<img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
</a>
% endif
<br/>
<p>If you have any question, do not hesitate to contact us.</p>
<p>Thank you for choosing ${object.company_id.name or 'us'}!</p>
<br/>
<br/>
<div style="width: 375px; margin: 0px; padding: 0px; background-color: #8E0000; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; background-repeat: repeat no-repeat;">
<h3 style="margin: 0px; padding: 2px 14px; font-size: 12px; color: #FFF;">
<strong style="text-transform:uppercase;">${object.company_id.name}</strong></h3>
</div>
<div style="width: 347px; margin: 0px; padding: 5px 14px; line-height: 16px; background-color: #F2F2F2;">
<span style="color: #222; margin-bottom: 5px; display: block; ">
% if object.company_id.street:
${object.company_id.street}<br/>
% endif
% if object.company_id.street2:
${object.company_id.street2}<br/>
% endif
% if object.company_id.city or object.company_id.zip:
${object.company_id.zip} ${object.company_id.city}<br/>
% endif
% if object.company_id.country_id:
${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}<br/>
% endif
</span>
% if object.company_id.phone:
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
Phone:&nbsp; ${object.company_id.phone}
</div>
% endif
% if object.company_id.website:
<div>
Web :&nbsp;<a href="${object.company_id.website}">${object.company_id.website}</a>
</div>
%endif
<p></p>
</div>
</div>
]]></field>
<field name="body_text"><![CDATA[
Hello${object.address_invoice_id.name and ' ' or ''}${object.address_invoice_id.name or ''},
A new invoice is available for ${object.partner_id.name}:
| Invoice number: *${object.number}*
| Invoice total: *${object.amount_total} ${object.currency_id.name}*
| Invoice date: ${object.date_invoice}
% if object.origin:
| Order reference: ${object.origin}
% endif
| Your contact: ${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
You can view the invoice document, download it and pay online using the following link:
${ctx.get('edi_web_url_view') or 'n/a'}
% if object.company_id.paypal_account and object.type in ('out_invoice', 'in_refund'):
<%
comp_name = quote(object.company_id.name)
inv_number = quote(object.number)
paypal_account = quote(object.company_id.paypal_account)
inv_amount = quote(str(object.amount_total))
cur_name = quote(object.currency_id.name)
paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Invoice%%20%s"\
"&invoice=%s&amount=%s&currency_code=%s&button_subtype=services&no_note=1&bn=OpenERP_Invoice_PayNow_%s" % \
(paypal_account,comp_name,inv_number,inv_number,inv_amount,cur_name,cur_name)
%>
It is also possible to directly pay with Paypal:
${paypal_url}
% endif
If you have any question, do not hesitate to contact us.
Thank you for choosing ${object.company_id.name}!
--
${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
${object.company_id.name}
% if object.company_id.street:
${object.company_id.street or ''}
% endif
% if object.company_id.street2:
${object.company_id.street2}
% endif
% if object.company_id.city or object.company_id.zip:
${object.company_id.zip or ''} ${object.company_id.city or ''}
% endif
% if object.company_id.country_id:
${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}
% endif
% if object.company_id.phone:
Phone: ${object.company_id.phone}
% endif
% if object.company_id.website:
${object.company_id.website or ''}
% endif
]]></field>
</record>
</data>
</openerp>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

13350
addons/account/i18n/es_CR.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

10451
addons/account/i18n/es_VE.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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