import time
import openerp
-from openerp import SUPERUSER_ID
+from openerp import SUPERUSER_ID, api
from openerp import tools
from openerp.osv import fields, osv, expression
from openerp.tools.translate import _
level -= 1
return True
+class res_company(osv.osv):
+ _inherit = "res.company"
+ _columns = {
+ 'income_currency_exchange_account_id': fields.many2one(
+ 'account.account',
+ string="Gain Exchange Rate Account",
+ domain="[('type', '=', 'other')]",),
+ 'expense_currency_exchange_account_id': fields.many2one(
+ 'account.account',
+ string="Loss Exchange Rate Account",
+ domain="[('type', '=', 'other')]",),
+ }
+
class account_payment_term(osv.osv):
_name = "account.payment.term"
_description = "Payment Term"
_columns = {
- 'name': fields.char('Payment Term', size=64, translate=True, required=True),
+ 'name': fields.char('Payment Term', translate=True, required=True),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the payment term without removing it."),
'note': fields.text('Description', translate=True),
- 'line_ids': fields.one2many('account.payment.term.line', 'payment_id', 'Terms'),
+ 'line_ids': fields.one2many('account.payment.term.line', 'payment_id', 'Terms', copy=True),
}
_defaults = {
'active': 1,
return obj_financial_report.write(cr, uid, [financial_report_ref[field_value].id], {'account_type_ids': [(4, account_type_id)]})
_columns = {
- 'name': fields.char('Account Type', size=64, required=True, translate=True),
+ 'name': fields.char('Account Type', required=True, translate=True),
'code': fields.char('Code', size=32, required=True, select=True),
'close_method': fields.selection([('none', 'None'), ('balance', 'Balance'), ('detail', 'Detail'), ('unreconciled', 'Unreconciled')], 'Deferral Method', required=True, help="""Set here the method that will be used to generate the end of year journal entries for all the accounts of this type.
# Accounts
#----------------------------------------------------------
-class account_tax(osv.osv):
- _name = 'account.tax'
-
class account_account(osv.osv):
_order = "parent_left"
_parent_order = "code"
return True
_columns = {
- 'name': fields.char('Name', size=256, required=True, select=True),
+ 'name': fields.char('Name', required=True, select=True),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."),
'code': fields.char('Code', size=64, required=True, select=1),
'type': fields.selection([
def _check_moves(self, cr, uid, ids, method, context=None):
line_obj = self.pool.get('account.move.line')
- account_ids = self.search(cr, uid, [('id', 'child_of', ids)])
+ account_ids = self.search(cr, uid, [('id', 'child_of', ids)], context=context)
- if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]):
+ if line_obj.search(cr, uid, [('account_id', 'in', account_ids)], context=context):
if method == 'write':
raise osv.except_osv(_('Error!'), _('You cannot deactivate an account that contains journal items.'))
elif method == 'unlink':
raise osv.except_osv(_('Error!'), _('You cannot remove an account that contains journal items.'))
#Checking whether the account is set as a property to any Partner or not
- value = 'account.account,' + str(ids[0])
- partner_prop_acc = self.pool.get('ir.property').search(cr, uid, [('value_reference','=',value)], context=context)
+ values = ['account.account,%s' % (account_id,) for account_id in ids]
+ partner_prop_acc = self.pool.get('ir.property').search(cr, uid, [('value_reference','in', values)], context=context)
if partner_prop_acc:
raise osv.except_osv(_('Warning!'), _('You cannot remove/deactivate an account which is set on a customer or supplier.'))
return True
# For legal reason (forbiden to modify journal entries which belongs to a closed fy or period), Forbid to modify
# the code of an account if journal entries have been already posted on this account. This cannot be simply
- # 'configurable' since it can lead to a lack of confidence in OpenERP and this is what we want to change.
+ # 'configurable' since it can lead to a lack of confidence in Odoo and this is what we want to change.
def _check_allow_code_change(self, cr, uid, ids, context=None):
line_obj = self.pool.get('account.move.line')
for account in self.browse(cr, uid, ids, context=context):
# Dont allow changing the company_id when account_move_line already exist
if 'company_id' in vals:
- move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)])
+ move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)], context=context)
if move_lines:
# Allow the write if the value is the same
- for i in [i['company_id'][0] for i in self.read(cr,uid,ids,['company_id'])]:
+ for i in [i['company_id'][0] for i in self.read(cr,uid,ids,['company_id'], context=context)]:
if vals['company_id']!=i:
raise osv.except_osv(_('Warning!'), _('You cannot change the owner company of an account that already contains journal items.'))
if 'active' in vals and not vals['active']:
_name = "account.journal"
_description = "Journal"
_columns = {
- 'with_last_closing_balance' : fields.boolean('Opening With Last Closing Balance'),
- 'name': fields.char('Journal Name', size=64, required=True),
+ 'with_last_closing_balance': fields.boolean('Opening With Last Closing Balance', help="For cash or bank journal, this option should be unchecked when the starting balance should always set to 0 for new documents."),
+ 'name': fields.char('Journal Name', required=True),
'code': fields.char('Code', size=5, required=True, help="The code will be displayed on reports."),
'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'), ('cash', 'Cash'), ('bank', 'Bank and Checks'), ('general', 'General'), ('situation', 'Opening/Closing Situation')], 'Type', size=32, required=True,
help="Select 'Sale' for customer invoices journals."\
'centralisation': fields.boolean('Centralized Counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."),
'update_posted': fields.boolean('Allow Cancelling Entries', help="Check this box if you want to allow the cancellation the entries related to this journal or of the invoice related to this journal"),
'group_invoice_lines': fields.boolean('Group Invoice Lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."),
- 'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="This field contains the information related to the numbering of the journal entries of this journal.", required=True),
+ 'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="This field contains the information related to the numbering of the journal entries of this journal.", required=True, copy=False),
'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"),
'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
'entry_posted': fields.boolean('Autopost Created Moves', help='Check this box to automatically post entries of this journal. Note that legally, some entries may be automatically posted when the source document is validated (Invoices), whatever the status of this field.'),
'company_id': fields.many2one('res.company', 'Company', required=True, select=1, help="Company related to this journal"),
- 'allow_date':fields.boolean('Check Date in Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'),
-
+ 'allow_date':fields.boolean('Check Date in Period', help= 'If checked, the entry won\'t be created if the entry date is not included into the selected period'),
'profit_account_id' : fields.many2one('account.account', 'Profit Account'),
'loss_account_id' : fields.many2one('account.account', 'Loss Account'),
'internal_account_id' : fields.many2one('account.account', 'Internal Transfers Account', select=1),
_defaults = {
'cash_control' : False,
- 'with_last_closing_balance' : False,
+ 'with_last_closing_balance' : True,
'user_id': lambda self, cr, uid, context: uid,
'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
(_check_currency, 'Configuration error!\nThe currency chosen should be shared by the default accounts too.', ['currency','default_debit_account_id','default_credit_account_id']),
]
- def copy(self, cr, uid, id, default=None, context=None, done_list=None, local=False):
- default = {} if default is None else default.copy()
- if done_list is None:
- done_list = []
+ def copy(self, cr, uid, id, default=None, context=None):
+ default = dict(context or {})
journal = self.browse(cr, uid, id, context=context)
default.update(
code=_("%s (copy)") % (journal['code'] or ''),
- name=_("%s (copy)") % (journal['name'] or ''),
- sequence_id=False)
+ name=_("%s (copy)") % (journal['name'] or ''))
return super(account_journal, self).copy(cr, uid, id, default, context=context)
def write(self, cr, uid, ids, vals, context=None):
_name = "account.fiscalyear"
_description = "Fiscal Year"
_columns = {
- 'name': fields.char('Fiscal Year', size=64, required=True),
+ 'name': fields.char('Fiscal Year', required=True),
'code': fields.char('Code', size=6, required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'date_start': fields.date('Start Date', required=True),
'date_stop': fields.date('End Date', required=True),
'period_ids': fields.one2many('account.period', 'fiscalyear_id', 'Periods'),
- 'state': fields.selection([('draft','Open'), ('done','Closed')], 'Status', readonly=True),
+ 'state': fields.selection([('draft','Open'), ('done','Closed')], 'Status', readonly=True, copy=False),
+ 'end_journal_period_id': fields.many2one(
+ 'account.journal.period', 'End of Year Entries Journal',
+ readonly=True, copy=False),
}
_defaults = {
'state': 'draft',
ids = self.search(cr, uid, args, context=context)
if not ids:
if exception:
- raise osv.except_osv(_('Error!'), _('There is no fiscal year defined for this date.\nPlease create one from the configuration of the accounting menu.'))
+ model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_fiscalyear')
+ msg = _('There is no period defined for this date: %s.\nPlease go to Configuration/Periods and configure a fiscal year.') % dt
+ raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel'))
else:
return []
return ids
_name = "account.period"
_description = "Account period"
_columns = {
- 'name': fields.char('Period Name', size=64, required=True),
+ 'name': fields.char('Period Name', required=True),
'code': fields.char('Code', size=12),
- 'special': fields.boolean('Opening/Closing Period', size=12,
- help="These periods can overlap."),
+ 'special': fields.boolean('Opening/Closing Period',help="These periods can overlap."),
'date_start': fields.date('Start of Period', required=True, states={'done':[('readonly',True)]}),
'date_stop': fields.date('End of Period', required=True, states={'done':[('readonly',True)]}),
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True),
- 'state': fields.selection([('draft','Open'), ('done','Closed')], 'Status', readonly=True,
+ 'state': fields.selection([('draft','Open'), ('done','Closed')], 'Status', readonly=True, copy=False,
help='When monthly periods are created. The status is \'Draft\'. At the end of monthly period it is in \'Done\' status.'),
'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True)
}
(_check_year_limit, 'Error!\nThe period is invalid. Either some periods are overlapping or the period\'s dates are not matching the scope of the fiscal year.', ['date_stop'])
]
+ @api.returns('self')
def next(self, cr, uid, period, step, context=None):
ids = self.search(cr, uid, [('date_start','>',period.date_start)])
if len(ids)>=step:
return ids[step-1]
return False
+ @api.returns('self')
def find(self, cr, uid, dt=None, context=None):
if context is None: context = {}
if not dt:
if not result:
result = self.search(cr, uid, args, context=context)
if not result:
- model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_fiscalyear')
- msg = _('There is no period defined for this date: %s.\nPlease, go to Configuration/Periods and configure a fiscal year.') % dt
+ model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_period')
+ msg = _('There is no period defined for this date: %s.\nPlease go to Configuration/Periods.') % dt
raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel'))
-
return result
- def action_draft(self, cr, uid, ids, *args):
+ def action_draft(self, cr, uid, ids, context=None):
mode = 'draft'
for period in self.browse(cr, uid, ids):
if period.fiscalyear_id.state == 'done':
raise osv.except_osv(_('Warning!'), _('You can not re-open a period which belongs to closed fiscal year'))
cr.execute('update account_journal_period set state=%s where period_id in %s', (mode, tuple(ids),))
cr.execute('update account_period set state=%s where id in %s', (mode, tuple(ids),))
+ self.invalidate_cache(cr, uid, context=context)
return True
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
return result
_columns = {
- 'name': fields.char('Journal-Period Name', size=64, required=True),
+ 'name': fields.char('Journal-Period Name', required=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, ondelete="cascade"),
'period_id': fields.many2one('account.period', 'Period', required=True, ondelete="cascade"),
- 'icon': fields.function(_icon_get, string='Icon', type='char', size=32),
+ 'icon': fields.function(_icon_get, string='Icon', type='char'),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the journal period without removing it."),
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True,
help='When journal period is created. The status is \'Draft\'. If a report is printed it comes to \'Printed\' status. When all transactions are done, it comes in \'Done\' status.'),
}
_order = "period_id"
-
-class account_fiscalyear(osv.osv):
- _inherit = "account.fiscalyear"
- _description = "Fiscal Year"
- _columns = {
- 'end_journal_period_id':fields.many2one('account.journal.period','End of Year Entries Journal', readonly=True),
- }
-
- def copy(self, cr, uid, id, default=None, context=None):
- default = {} if default is None else default.copy()
- default.update({
- 'period_ids': [],
- 'end_journal_period_id': False
- })
- return super(account_fiscalyear, self).copy(cr, uid, id, default=default, context=context)
-
#----------------------------------------------------------
# Entries
#----------------------------------------------------------
return [line.move_id.id for line in line_obj.browse(cr, uid, ids, context=context)]
_columns = {
- 'name': fields.char('Number', size=64, required=True),
- 'ref': fields.char('Reference', size=64),
+ 'name': fields.char('Number', required=True, copy=False),
+ 'ref': fields.char('Reference', copy=False),
'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}),
- 'state': fields.selection([('draft','Unposted'), ('posted','Posted')], 'Status', required=True, readonly=True,
- help='All manually created new journal entries are usually in the status \'Unposted\', but you can set the option to skip that status on the related journal. In that case, they will behave as journal entries automatically created by the system on document validation (invoices, bank statements...) and will be created in \'Posted\' status.'),
- 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}),
+ 'state': fields.selection(
+ [('draft','Unposted'), ('posted','Posted')], 'Status',
+ required=True, readonly=True, copy=False,
+ help='All manually created new journal entries are usually in the status \'Unposted\', '
+ 'but you can set the option to skip that status on the related journal. '
+ 'In that case, they will behave as journal entries automatically created by the '
+ 'system on document validation (invoices, bank statements...) and will be created '
+ 'in \'Posted\' status.'),
+ 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries',
+ states={'posted':[('readonly',True)]},
+ copy=True),
'to_check': fields.boolean('To Review', help='Check this box if you are unsure of that journal entry and if you want to note it as \'to be reviewed\' by an accounting expert.'),
'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store={
_name: (lambda self, cr,uid,ids,c: ids, ['line_id'], 10),
'SET state=%s '\
'WHERE id IN %s',
('posted', tuple(valid_moves),))
+ self.invalidate_cache(cr, uid, context=context)
return True
def button_validate(self, cursor, user, ids, context=None):
cr.execute('UPDATE account_move '\
'SET state=%s '\
'WHERE id IN %s', ('draft', tuple(ids),))
+ self.invalidate_cache(cr, uid, context=context)
return True
def write(self, cr, uid, ids, vals, context=None):
# TODO: Check if period is closed !
#
def create(self, cr, uid, vals, context=None):
- if context is None:
- context = {}
- if 'line_id' in vals and context.get('copy'):
- for l in vals['line_id']:
- if not l[0]:
- l[2].update({
- 'reconcile_id':False,
- 'reconcile_partial_id':False,
- 'analytic_lines':False,
- 'invoice':False,
- 'ref':False,
- 'balance':False,
- 'account_tax_id':False,
- 'statement_id': False,
- })
-
- if 'journal_id' in vals and vals.get('journal_id', False):
+ context = dict(context or {})
+ if vals.get('line_id'):
+ if vals.get('journal_id'):
for l in vals['line_id']:
if not l[0]:
l[2]['journal_id'] = vals['journal_id']
l[2]['period_id'] = default_period
context['period_id'] = default_period
- if vals.get('line_id', False):
c = context.copy()
c['novalidate'] = True
c['period_id'] = vals['period_id'] if 'period_id' in vals else self._get_period(cr, uid, context)
result = super(account_move, self).create(cr, uid, vals, context)
return result
- def copy(self, cr, uid, id, default=None, context=None):
- default = {} if default is None else default.copy()
- context = {} if context is None else context.copy()
- default.update({
- 'state':'draft',
- 'ref': False,
- 'name':'/',
- })
- context.update({
- 'copy':True
- })
- return super(account_move, self).copy(cr, uid, id, default, context)
-
def unlink(self, cr, uid, ids, context=None, check=True):
- if context is None:
- context = {}
+ context = dict(context or {})
if isinstance(ids, (int, long)):
ids = [ids]
toremove = []
def _centralise(self, cr, uid, move, mode, context=None):
assert mode in ('debit', 'credit'), 'Invalid Mode' #to prevent sql injection
currency_obj = self.pool.get('res.currency')
- if context is None:
- context = {}
+ account_move_line_obj = self.pool.get('account.move.line')
+ context = dict(context or {})
if mode=='credit':
account_id = move.journal_id.default_debit_account_id.id
line_id = res[0]
else:
context.update({'journal_id': move.journal_id.id, 'period_id': move.period_id.id})
- line_id = self.pool.get('account.move.line').create(cr, uid, {
+ line_id = account_move_line_obj.create(cr, uid, {
'name': _(mode.capitalize()+' Centralisation'),
'centralisation': mode,
'partner_id': False,
cr.execute('SELECT SUM(%s) FROM account_move_line WHERE move_id=%%s AND id!=%%s' % (mode,), (move.id, line_id2))
result = cr.fetchone()[0] or 0.0
cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id))
+ account_move_line_obj.invalidate_cache(cr, uid, [mode2], [line_id], context=context)
#adjust also the amount in currency if needed
cr.execute("select currency_id, sum(amount_currency) as amount_currency from account_move_line where move_id = %s and currency_id is not null group by currency_id", (move.id,))
res = cr.fetchone()
if res:
cr.execute('update account_move_line set amount_currency=%s , account_id=%s where id=%s', (amount_currency, account_id, res[0]))
+ account_move_line_obj.invalidate_cache(cr, uid, ['amount_currency', 'account_id'], [res[0]], context=context)
else:
context.update({'journal_id': move.journal_id.id, 'period_id': move.period_id.id})
- line_id = self.pool.get('account.move.line').create(cr, uid, {
+ line_id = account_move_line_obj.create(cr, uid, {
'name': _('Currency Adjustment'),
'centralisation': 'currency',
'partner_id': False,
_name = "account.move.reconcile"
_description = "Account Reconciliation"
_columns = {
- 'name': fields.char('Name', size=64, required=True),
- 'type': fields.char('Type', size=16, required=True),
+ 'name': fields.char('Name', required=True),
+ 'type': fields.char('Type', required=True),
'line_id': fields.one2many('account.move.line', 'reconcile_id', 'Entry Lines'),
'line_partial_ids': fields.one2many('account.move.line', 'reconcile_partial_id', 'Partial Entry lines'),
'create_date': fields.date('Creation date', readonly=True),
return True
_constraints = [
- (_check_same_partner, 'You can only reconcile journal items with the same partner.', ['line_id']),
+ (_check_same_partner, 'You can only reconcile journal items with the same partner.', ['line_id', 'line_partial_ids']),
]
def reconcile_partial_check(self, cr, uid, ids, type='auto', context=None):
_name = 'account.tax.code'
_description = 'Tax Code'
_rec_name = 'code'
+ _order = 'sequence, code'
_columns = {
- 'name': fields.char('Tax Case Name', size=64, required=True, translate=True),
+ 'name': fields.char('Tax Case Name', required=True, translate=True),
'code': fields.char('Case Code', size=64),
'info': fields.text('Description'),
'sum': fields.function(_sum_year, string="Year Sum"),
return []
if isinstance(ids, (int, long)):
ids = [ids]
- reads = self.read(cr, uid, ids, ['name','code'], context, load='_classic_write')
+ reads = self.read(cr, uid, ids, ['name','code'], context=context, load='_classic_write')
return [(x['id'], (x['code'] and (x['code'] + ' - ') or '') + x['name']) \
for x in reads]
if user.company_id:
return user.company_id.id
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
+
_defaults = {
'company_id': _default_company,
'sign': 1.0,
'notprintable': False,
}
- def copy(self, cr, uid, id, default=None, context=None):
- if default is None:
- default = {}
- default = default.copy()
- default.update({'line_ids': []})
- return super(account_tax_code, self).copy(cr, uid, id, default, context)
-
_check_recursion = check_cycle
_constraints = [
(_check_recursion, 'Error!\nYou cannot create recursive accounts.', ['parent_id'])
def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
- name = self.read(cr, uid, id, ['name'], context=context)['name']
- default = default.copy()
- default.update({'name': name + _(' (Copy)')})
- return super(account_tax, self).copy_data(cr, uid, id, default=default, context=context)
+ this = self.browse(cr, uid, id, context=context)
+ tmp_default = dict(default, name=_("%s (Copy)") % this.name)
+ return super(account_tax, self).copy_data(cr, uid, id, default=tmp_default, context=context)
_name = 'account.tax'
_description = 'Tax'
_columns = {
- 'name': fields.char('Tax Name', size=64, required=True, translate=True, help="This name will be displayed on reports"),
+ 'name': fields.char('Tax Name', required=True, translate=True, help="This name will be displayed on reports"),
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the tax lines from the lowest sequences to the higher ones. The order is important if you have a tax with several tax children. In this case, the evaluation order is important."),
'amount': fields.float('Amount', required=True, digits_compute=get_precision_tax(), help="For taxes of type percentage, enter % ratio between 0-1."),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the tax without removing it."),
help="The computation method for the tax amount."),
'applicable_type': fields.selection( [('true','Always'), ('code','Given by Python Code')], 'Applicability', required=True,
help="If not applicable (computed through a Python code), the tax won't appear on the invoice."),
- 'domain':fields.char('Domain', size=32, help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."),
+ 'domain':fields.char('Domain', help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."),
'account_collected_id':fields.many2one('account.account', 'Invoice Tax Account', help="Set the account that will be set by default on invoice tax lines for invoices. Leave empty to use the expense account."),
'account_paid_id':fields.many2one('account.account', 'Refund Tax Account', help="Set the account that will be set by default on invoice tax lines for refunds. Leave empty to use the expense account."),
'account_analytic_collected_id':fields.many2one('account.analytic.account', 'Invoice Tax Analytic Account', help="Set the analytic account that will be used by default on the invoice tax lines for invoices. Leave empty if you don't want to use an analytic account on the invoice tax lines by default."),
data['tax_amount']=quantity
# data['amount'] = quantity
elif tax.type=='code':
- localdict = {'price_unit':cur_price_unit, 'product':product, 'partner':partner}
+ localdict = {'price_unit':cur_price_unit, 'product':product, 'partner':partner, 'quantity': quantity}
exec tax.python_compute in localdict
amount = localdict['result']
data['amount'] = amount
cur_price_unit+=amount2
return res
+ def compute_for_bank_reconciliation(self, cr, uid, tax_id, amount, context=None):
+ """ Called by RPC by the bank statement reconciliation widget """
+ tax = self.browse(cr, uid, tax_id, context=context)
+ return self.compute_all(cr, uid, [tax], amount, 1) # TOCHECK may use force_exclude parameter
+
+ @api.v7
def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None, force_excluded=False):
"""
:param force_excluded: boolean used to say that we don't want to consider the value of field price_include of
'taxes': tin + tex
}
+ @api.v8
+ def compute_all(self, price_unit, quantity, product=None, partner=None, force_excluded=False):
+ return self._model.compute_all(
+ self._cr, self._uid, self, price_unit, quantity,
+ product=product, partner=partner, force_excluded=force_excluded)
+
def compute(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None):
_logger.warning("Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included.")
return self._compute(cr, uid, taxes, price_unit, quantity, product, partner)
_name = "account.model"
_description = "Account Model"
_columns = {
- 'name': fields.char('Model Name', size=64, required=True, help="This is a model for recurring accounting entries"),
+ 'name': fields.char('Model Name', required=True, help="This is a model for recurring accounting entries"),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
- 'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'),
+ 'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries', copy=True),
'legend': fields.text('Legend', readonly=True, size=100),
}
context = {}
if data.get('date', False):
+ context = dict(context)
context.update({'date': data['date']})
move_date = context.get('date', time.strftime('%Y-%m-%d'))
_name = "account.model.line"
_description = "Account Model Entries"
_columns = {
- 'name': fields.char('Name', size=64, required=True),
+ 'name': fields.char('Name', required=True),
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the resources from lower sequences to higher ones."),
'quantity': fields.float('Quantity', digits_compute=dp.get_precision('Account'), help="The optional quantity on entries."),
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
_name = "account.subscription"
_description = "Account Subscription"
_columns = {
- 'name': fields.char('Name', size=64, required=True),
- 'ref': fields.char('Reference', size=16),
+ 'name': fields.char('Name', required=True),
+ 'ref': fields.char('Reference'),
'model_id': fields.many2one('account.model', 'Model', required=True),
'date_start': fields.date('Start Date', required=True),
'period_total': fields.integer('Number of Periods', required=True),
'period_nbr': fields.integer('Period', required=True),
'period_type': fields.selection([('day','days'),('month','month'),('year','year')], 'Period Type', required=True),
- 'state': fields.selection([('draft','Draft'),('running','Running'),('done','Done')], 'Status', required=True, readonly=True),
- 'lines_id': fields.one2many('account.subscription.line', 'subscription_id', 'Subscription Lines')
+ 'state': fields.selection([('draft','Draft'),('running','Running'),('done','Done')], 'Status', required=True, readonly=True, copy=False),
+ 'lines_id': fields.one2many('account.subscription.line', 'subscription_id', 'Subscription Lines', copy=True)
}
_defaults = {
'date_start': fields.date.context_today,
_description ='Templates for Accounts'
_columns = {
- 'name': fields.char('Name', size=256, required=True, select=True),
+ 'name': fields.char('Name', required=True, select=True),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."),
'code': fields.char('Code', size=64, required=True, select=1),
'type': fields.selection([
('other','Regular'),
('closed','Closed'),
], 'Internal Type', required=True,help="This type is used to differentiate types with "\
- "special effects in OpenERP: view can not have entries, consolidation are accounts that "\
+ "special effects in Odoo: view can not have entries, consolidation are accounts that "\
"can have children accounts for multi-company consolidations, payable/receivable are for "\
"partners accounts (for debit/credit computations), closed for depreciated accounts."),
'user_type': fields.many2one('account.account.type', 'Account Type', required=True,
_name = 'account.tax.code.template'
_description = 'Tax Code Template'
- _order = 'code'
+ _order = 'sequence, code'
_rec_name = 'code'
_columns = {
- 'name': fields.char('Tax Case Name', size=64, required=True),
+ 'name': fields.char('Tax Case Name', required=True),
'code': fields.char('Case Code', size=64),
'info': fields.text('Description'),
'parent_id': fields.many2one('account.tax.code.template', 'Parent Code', select=True),
'child_ids': fields.one2many('account.tax.code.template', 'parent_id', 'Child Codes'),
'sign': fields.float('Sign For Parent', required=True),
'notprintable':fields.boolean("Not Printable in Invoice", help="Check this box if you don't want any tax related to this tax Code to appear on invoices."),
+ 'sequence': fields.integer(
+ 'Sequence', help=(
+ "Determine the display order in the report 'Accounting "
+ "\ Reporting \ Generic Reporting \ Taxes \ Taxes Report'"),
+ ),
}
_defaults = {
'parent_id': tax_code_template.parent_id and ((tax_code_template.parent_id.id in tax_code_template_ref) and tax_code_template_ref[tax_code_template.parent_id.id]) or False,
'company_id': company_id,
'sign': tax_code_template.sign,
+ 'sequence': tax_code_template.sequence,
}
#check if this tax code already exists
rec_list = obj_tax_code.search(cr, uid, [('name', '=', vals['name']),('code', '=', vals['code']),('company_id', '=', vals['company_id'])], context=context)
return []
if isinstance(ids, (int, long)):
ids = [ids]
- reads = self.read(cr, uid, ids, ['name','code'], context, load='_classic_write')
+ reads = self.read(cr, uid, ids, ['name','code'], context=context, load='_classic_write')
return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \
for x in reads]
_description= "Templates for Account Chart"
_columns={
- 'name': fields.char('Name', size=64, required=True),
+ 'name': fields.char('Name', required=True),
'parent_id': fields.many2one('account.chart.template', 'Parent Chart Template'),
'code_digits': fields.integer('# of Digits', required=True, help="No. of Digits to use for account code"),
'visible': fields.boolean('Can be Visible?', help="Set this to False if you don't want this template to be used actively in the wizard that generate Chart of Accounts from templates, this is useful when you want to generate accounts of this template only when loading its child template."),
_columns = {
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
- 'name': fields.char('Tax Name', size=64, required=True),
+ 'name': fields.char('Tax Name', required=True),
'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the taxes lines from lower sequences to higher ones. The order is important if you have a tax that has several tax children. In this case, the evaluation order is important."),
'amount': fields.float('Amount', required=True, digits_compute=get_precision_tax(), help="For Tax Type percent enter % ratio between 0-1."),
'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code'), ('balance','Balance')], 'Tax Type', required=True),
'applicable_type': fields.selection( [('true','True'), ('code','Python Code')], 'Applicable Type', required=True, help="If not applicable (computed through a Python code), the tax won't appear on the invoice."),
- 'domain':fields.char('Domain', size=32, help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."),
+ 'domain':fields.char('Domain', help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."),
'account_collected_id':fields.many2one('account.account.template', 'Invoice Tax Account'),
'account_paid_id':fields.many2one('account.account.template', 'Refund Tax Account'),
'parent_id':fields.many2one('account.tax.template', 'Parent Tax Account', select=True),
_description = 'Template for Fiscal Position'
_columns = {
- 'name': fields.char('Fiscal Position Template', size=64, required=True),
+ 'name': fields.char('Fiscal Position Template', required=True),
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Account Mapping'),
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Tax Mapping'),
# write values of default taxes for product as super user
if obj_wizard.sale_tax and taxes_ref:
- ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.product', "taxes_id", [taxes_ref[obj_wizard.sale_tax.id]], for_all_users=True, company_id=company_id)
+ ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.template', "taxes_id", [taxes_ref[obj_wizard.sale_tax.id]], for_all_users=True, company_id=company_id)
if obj_wizard.purchase_tax and taxes_ref:
- ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.product', "supplier_taxes_id", [taxes_ref[obj_wizard.purchase_tax.id]], for_all_users=True, company_id=company_id)
+ ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.template', "supplier_taxes_id", [taxes_ref[obj_wizard.purchase_tax.id]], for_all_users=True, company_id=company_id)
# Create Bank journals
self._create_bank_journals_from_o2m(cr, uid, obj_wizard, company_id, acc_template_ref, context=context)
_name='account.bank.accounts.wizard'
_columns = {
- 'acc_name': fields.char('Account Name.', size=64, required=True),
+ 'acc_name': fields.char('Account Name.', required=True),
'bank_account_id': fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True, ondelete='cascade'),
'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."),
- 'account_type': fields.selection([('cash','Cash'), ('check','Check'), ('bank','Bank')], 'Account Type', size=32),
+ 'account_type': fields.selection([('cash','Cash'), ('check','Check'), ('bank','Bank')], 'Account Type'),
}