Maxime Chambreuil 2012-12-06 16:54:24 -05:00
commit 40e9d9b96a
6331 changed files with 2146652 additions and 1444188 deletions

View File

@ -73,7 +73,6 @@ for a particular financial year and for preparation of vouchers there is a modul
'wizard/account_fiscalyear_close_state.xml',
'wizard/account_chart_view.xml',
'wizard/account_tax_chart_view.xml',
'wizard/account_move_journal_view.xml',
'wizard/account_move_line_reconcile_select_view.xml',
'wizard/account_open_closed_fiscalyear_view.xml',
'wizard/account_move_line_unreconcile_select_view.xml',
@ -128,9 +127,11 @@ for a particular financial year and for preparation of vouchers there is a modul
],
'js': [
'static/src/js/account_move_reconciliation.js',
'static/src/js/account_move_line_quickadd.js',
],
'qweb' : [
"static/src/xml/account_move_reconciliation.xml",
"static/src/xml/account_move_line_quickadd.xml",
],
'css':['static/src/css/account_move_reconciliation.css'
],

View File

@ -541,10 +541,18 @@ class account_account(osv.osv):
return False
return True
def _check_company_account(self, cr, uid, ids, context=None):
for account in self.browse(cr, uid, ids, context=context):
if account.parent_id:
if account.company_id != account.parent_id.company_id:
return False
return True
_constraints = [
(_check_recursion, 'Error!\nYou cannot create recursive accounts.', ['parent_id']),
(_check_type, 'Configuration Error!\nYou cannot define children to an account with internal type different of "View".', ['type']),
(_check_account_type, 'Configuration Error!\nYou cannot select an account type with a deferral method different of "Unreconciled" for accounts with internal type "Payable/Receivable".', ['user_type','type']),
(_check_company_account, 'Error!\nYou cannot create an account which has parent account of different company.', ['parent_id']),
]
_sql_constraints = [
('code_company_uniq', 'unique (code,company_id)', 'The code of the account must be unique per company !')
@ -633,8 +641,7 @@ class account_account(osv.osv):
return True
def _check_allow_type_change(self, cr, uid, ids, new_type, context=None):
group1 = ['payable', 'receivable', 'other']
group2 = ['consolidation','view']
restricted_groups = ['consolidation','view']
line_obj = self.pool.get('account.move.line')
for account in self.browse(cr, uid, ids, context=context):
old_type = account.type
@ -642,14 +649,25 @@ class account_account(osv.osv):
if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]):
#Check for 'Closed' type
if old_type == 'closed' and new_type !='closed':
raise osv.except_osv(_('Warning!'), _("You cannot change the type of account from 'Closed' to any other type which contains journal items!"))
#Check for change From group1 to group2 and vice versa
if (old_type in group1 and new_type in group2) or (old_type in group2 and new_type in group1):
raise osv.except_osv(_('Warning!'), _("You cannot change the type of account from '%s' to '%s' type as it contains journal items!") % (old_type,new_type,))
raise osv.except_osv(_('Warning !'), _("You cannot change the type of account from 'Closed' to any other type as it contains journal items!"))
# Forbid to change an account type for restricted_groups as it contains journal items (or if one of its children does)
if (new_type in restricted_groups):
raise osv.except_osv(_('Warning !'), _("You cannot change the type of account to '%s' type as it contains journal items!") % (new_type,))
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.
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):
account_ids = self.search(cr, uid, [('id', 'child_of', [account.id])], context=context)
if line_obj.search(cr, uid, [('account_id', 'in', account_ids)], context=context):
raise osv.except_osv(_('Warning !'), _("You cannot change the code of account which contains journal items!"))
return True
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
if not ids:
@ -669,6 +687,8 @@ class account_account(osv.osv):
self._check_moves(cr, uid, ids, "write", context=context)
if 'type' in vals.keys():
self._check_allow_type_change(cr, uid, ids, vals['type'], context=context)
if 'code' in vals.keys():
self._check_allow_code_change(cr, uid, ids, context=context)
return super(account_account, self).write(cr, uid, ids, vals, context=context)
def unlink(self, cr, uid, ids, context=None):
@ -677,44 +697,6 @@ class account_account(osv.osv):
account_account()
class account_journal_view(osv.osv):
_name = "account.journal.view"
_description = "Journal View"
_columns = {
'name': fields.char('Journal View', size=64, required=True, translate=True),
'columns_id': fields.one2many('account.journal.column', 'view_id', 'Columns')
}
_order = "name"
account_journal_view()
class account_journal_column(osv.osv):
def _col_get(self, cr, user, context=None):
result = []
cols = self.pool.get('account.move.line')._columns
for col in cols:
if col in ('period_id', 'journal_id'):
continue
result.append( (col, cols[col].string) )
result.sort()
return result
_name = "account.journal.column"
_description = "Journal Column"
_columns = {
'name': fields.char('Column Name', size=64, required=True),
'field': fields.selection(_col_get, 'Field Name', required=True, size=32),
'view_id': fields.many2one('account.journal.view', 'Journal View', select=True),
'sequence': fields.integer('Sequence', help="Gives the sequence order to journal column.", readonly=True),
'required': fields.boolean('Required'),
'readonly': fields.boolean('Readonly'),
}
_order = "view_id, sequence"
account_journal_column()
class account_journal(osv.osv):
_name = "account.journal"
_description = "Journal"
@ -730,7 +712,6 @@ class account_journal(osv.osv):
" Select 'Opening/Closing Situation' for entries generated for new fiscal years."),
'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]),
'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]", help="It acts as a default account for credit amount"),
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]", help="It acts as a default account for debit amount"),
'centralisation': fields.boolean('Centralised Counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."),
@ -866,37 +847,6 @@ class account_journal(osv.osv):
return self.name_get(cr, user, ids, context=context)
def onchange_type(self, cr, uid, ids, type, currency, context=None):
obj_data = self.pool.get('ir.model.data')
user_pool = self.pool.get('res.users')
type_map = {
'sale':'account_sp_journal_view',
'sale_refund':'account_sp_refund_journal_view',
'purchase':'account_sp_journal_view',
'purchase_refund':'account_sp_refund_journal_view',
'cash':'account_journal_bank_view',
'bank':'account_journal_bank_view',
'general':'account_journal_view',
'situation':'account_journal_view'
}
res = {}
view_id = type_map.get(type, 'account_journal_view')
user = user_pool.browse(cr, uid, uid)
if type in ('cash', 'bank') and currency and user.company_id.currency_id.id != currency:
view_id = 'account_journal_bank_view_multi'
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)])
data = obj_data.browse(cr, uid, data_id[0], context=context)
res.update({
'centralisation':type == 'situation',
'view_id':data.res_id,
})
return {
'value':res
}
account_journal()
class account_fiscalyear(osv.osv):
@ -1376,13 +1326,6 @@ class account_move(osv.osv):
'WHERE id IN %s', ('draft', tuple(ids),))
return True
def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
balance = 0.0
for line in line_ids:
if line[2]:
balance += (line[2].get('debit',0.00)- (line[2].get('credit',0.00)))
return {'value': {'balance': balance}}
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
@ -1431,9 +1374,9 @@ class account_move(osv.osv):
if 'line_id' in vals:
c = context.copy()
c['novalidate'] = True
c['period_id'] = vals['period_id']
c['period_id'] = vals['period_id'] if 'period_id' in vals else self._get_period(cr, uid, context)
c['journal_id'] = vals['journal_id']
c['date'] = vals['date']
if 'date' in vals: c['date'] = vals['date']
result = super(account_move, self).create(cr, uid, vals, c)
self.validate(cr, uid, [result], context)
else:
@ -1462,6 +1405,11 @@ class account_move(osv.osv):
raise osv.except_osv(_('User Error!'),
_('You cannot delete a posted journal entry "%s".') % \
move['name'])
for line in move.line_id:
if line.invoice:
raise osv.except_osv(_('User Error!'),
_("Move cannot be deleted if linked to an invoice. (Invoice: %s - Move ID:%s)") % \
(line.invoice.number,move.name))
line_ids = map(lambda x: x.id, move.line_id)
context['journal_id'] = move.journal_id.id
context['period_id'] = move.period_id.id
@ -1670,11 +1618,41 @@ class account_move_reconcile(osv.osv):
'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),
'opening_reconciliation': fields.boolean('Opening Entries Reconciliation', help="Is this reconciliation produced by the opening of a new fiscal year ?."),
}
_defaults = {
'name': lambda self,cr,uid,ctx=None: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile', context=ctx) or '/',
}
# You cannot unlink a reconciliation if it is a opening_reconciliation one,
# you should use the generate opening entries wizard for that
def unlink(self, cr, uid, ids, context=None):
for move_rec in self.browse(cr, uid, ids, context=context):
if move_rec.opening_reconciliation:
raise osv.except_osv(_('Error!'), _('You cannot unreconcile journal items if they has been generated by the \
opening/closing fiscal year process.'))
return super(account_move_reconcile, self).unlink(cr, uid, ids, context=context)
# Look in the line_id and line_partial_ids to ensure the partner is the same or empty
# on all lines. We allow that only for opening/closing period
def _check_same_partner(self, cr, uid, ids, context=None):
for reconcile in self.browse(cr, uid, ids, context=context):
move_lines = []
if not reconcile.opening_reconciliation:
if reconcile.line_id:
first_partner = reconcile.line_id[0].partner_id.id
move_lines = reconcile.line_id
elif reconcile.line_partial_ids:
first_partner = reconcile.line_partial_ids[0].partner_id.id
move_lines = reconcile.line_partial_ids
if any([line.partner_id.id != first_partner for line in move_lines]):
return False
return True
_constraints = [
(_check_same_partner, 'You can only reconcile journal items with the same partner.', ['line_id']),
]
def reconcile_partial_check(self, cr, uid, ids, type='auto', context=None):
total = 0.0
for rec in self.browse(cr, uid, ids, context=context):
@ -2326,8 +2304,13 @@ class account_model(osv.osv):
if not line.partner_id:
raise osv.except_osv(_('Error!'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \
"\nPlease define partner on it!")%(line.name, model.name))
if line.partner_id.property_payment_term:
payment_term_id = False
if model.journal_id.type in ('purchase', 'purchase_refund') and line.partner_id.property_supplier_payment_term:
payment_term_id = line.partner_id.property_supplier_payment_term.id
elif line.partner_id.property_payment_term:
payment_term_id = line.partner_id.property_payment_term.id
if payment_term_id:
pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_maturity)
if pterm_list:
pterm_list = [l[0] for l in pterm_list]
@ -3153,16 +3136,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
default_account = acc_template_ref.get(template.property_account_income_opening.id)
return default_account
def _get_view_id(journal_type):
# Get the journal views
if journal_type in ('general', 'situation'):
data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_view')
elif journal_type in ('sale_refund', 'purchase_refund'):
data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_refund_journal_view')
else:
data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_journal_view')
return data and data[1] or False
journal_names = {
'sale': _('Sales Journal'),
'purchase': _('Purchase Journal'),
@ -3192,7 +3165,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'code': journal_codes[journal_type],
'company_id': company_id,
'centralisation': journal_type == 'situation',
'view_id': _get_view_id(journal_type),
'analytic_journal_id': _get_analytic_journal(journal_type),
'default_credit_account_id': _get_default_account(journal_type, 'credit'),
'default_debit_account_id': _get_default_account(journal_type, 'debit'),
@ -3409,11 +3381,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'''
obj_data = self.pool.get('ir.model.data')
obj_journal = self.pool.get('account.journal')
# Get the id of journal views
tmp = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view_multi')
view_id_cur = tmp and tmp[1] or False
tmp = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view')
view_id_cash = tmp and tmp[1] or False
# we need to loop again to find next number for journal code
# because we can't rely on the value current_num as,
@ -3439,10 +3407,8 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'default_debit_account_id': default_account_id,
}
if line['currency_id']:
vals['view_id'] = view_id_cur
vals['currency'] = line['currency_id']
else:
vals['view_id'] = view_id_cash
return vals
def _prepare_bank_account(self, cr, uid, line, new_code, acc_template_ref, ref_acc_bank, company_id, context=None):

View File

@ -39,7 +39,6 @@ class account_analytic_line(osv.osv):
}
_defaults = {
'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'
@ -108,7 +107,7 @@ class account_analytic_line(osv.osv):
if journal_id:
journal = analytic_journal_obj.browse(cr, uid, journal_id, context=context)
if journal.type == 'sale':
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context)
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context=context)
if product_price_type_ids:
pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0]
# Take the company currency as the reference one

View File

@ -45,12 +45,12 @@ class bank(osv.osv):
def _prepare_name_get(self, cr, uid, bank_dicts, context=None):
"""Add ability to have %(currency_name)s in the format_layout of res.partner.bank.type"""
currency_ids = list(set(data['currency_id'][0] for data in bank_dicts if data['currency_id']))
currency_ids = list(set(data['currency_id'][0] for data in bank_dicts if data.get('currency_id')))
currencies = self.pool.get('res.currency').browse(cr, uid, currency_ids, context=context)
currency_name = dict((currency.id, currency.name) for currency in currencies)
for data in bank_dicts:
data['currency_name'] = data['currency_id'] and currency_name[data['currency_id'][0]] or ''
data['currency_name'] = data.get('currency_id') and currency_name[data['currency_id'][0]] or ''
return super(bank, self)._prepare_name_get(cr, uid, bank_dicts, context=context)
def post_write(self, cr, uid, ids, context=None):
@ -89,11 +89,6 @@ class bank(osv.osv):
}
acc_bank_id = obj_acc.create(cr,uid,acc,context=context)
# Get the journal view id
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:
@ -112,7 +107,6 @@ class bank(osv.osv):
'analytic_journal_id': False,
'default_credit_account_id': acc_bank_id,
'default_debit_account_id': acc_bank_id,
'view_id': view_id_cash
}
journal_id = jour_obj.create(cr, uid, vals_journal, context=context)

View File

@ -61,7 +61,7 @@ class account_bank_statement(osv.osv):
return res
def _get_period(self, cr, uid, context=None):
periods = self.pool.get('account.period').find(cr, uid)
periods = self.pool.get('account.period').find(cr, uid,context=context)
if periods:
return periods[0]
return False
@ -311,7 +311,7 @@ class account_bank_statement(osv.osv):
'statement_id': st_line.statement_id.id,
'journal_id': st_line.statement_id.journal_id.id,
'period_id': st_line.statement_id.period_id.id,
'currency_id': cur_id,
'currency_id': amount_currency and cur_id,
'amount_currency': amount_currency,
'analytic_account_id': analytic_id,
}
@ -486,6 +486,19 @@ class account_bank_statement(osv.osv):
default['move_line_ids'] = []
return super(account_bank_statement, self).copy(cr, uid, id, default, context=context)
def button_journal_entries(self, cr, uid, ids, context=None):
ctx = (context or {}).copy()
ctx['journal_id'] = self.browse(cr, uid, ids[0], context=context).journal_id.id
return {
'view_type':'form',
'view_mode':'tree',
'res_model':'account.move.line',
'view_id':False,
'type':'ir.actions.act_window',
'domain':[('statement_id','in',ids)],
'context':ctx,
}
account_bank_statement()
class account_bank_statement_line(osv.osv):

View File

@ -78,7 +78,7 @@ class account_cash_statement(osv.osv):
"""
res = {}
for statement in self.browse(cr, uid, ids, context=context):
if statement.journal_id.type not in ('cash',):
if (statement.journal_id.type not in ('cash',)) or (not statement.journal_id.cash_control):
continue
start = end = 0
for line in statement.details_ids:
@ -289,13 +289,13 @@ class account_cash_statement(osv.osv):
super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context)
absl_proxy = self.pool.get('account.bank.statement.line')
TABLES = (('Profit', 'profit_account_id'), ('Loss', 'loss_account_id'),)
TABLES = ((_('Profit'), 'profit_account_id'), (_('Loss'), 'loss_account_id'),)
for obj in self.browse(cr, uid, ids, context=context):
if obj.difference == 0.0:
continue
for item_label, item_account in TALBES:
for item_label, item_account in TABLES:
if getattr(obj.journal_id, item_account):
raise osv.except_osv(_('Error!'),
_('There is no %s Account on the journal %s.') % (item_label, obj.journal_id.name,))

View File

@ -217,7 +217,7 @@ class account_invoice(osv.osv):
'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', readonly=True, states={'draft':[('readonly',False)]}, select=True,
help="If you use payment terms, the due date will be computed automatically at the generation "\
"of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."),
"of accounting entries. The payment term may compute several due dates, for example 50% now and 50% in one month, but if you want to force a due date, make sure that the payment term is not set on the invoice. If you keep the payment term and the due date empty, it means direct payment."),
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}),
'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True, states={'draft':[('readonly',False)]},
help="If you use payment terms, the due date will be computed automatically at the generation "\
@ -294,6 +294,18 @@ class account_invoice(osv.osv):
('number_uniq', 'unique(number, company_id, journal_id, type)', 'Invoice Number must be unique per Company!'),
]
def _find_partner(self, inv):
'''
Find the partner for which the accounting entries will be created
'''
#if the chosen partner is not a company and has a parent company, use the parent for the journal entries
#because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait'
part = inv.partner_id
if part.parent_id and not part.is_company:
part = part.parent_id
return part
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')
if context is None:
@ -391,28 +403,34 @@ class account_invoice(osv.osv):
'''
This function opens a window to compose an email, with the edi invoice template message loaded by default
'''
mod_obj = self.pool.get('ir.model.data')
template = mod_obj.get_object_reference(cr, uid, 'account', 'email_template_edi_invoice')
template_id = template and template[1] or False
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
res_id = res and res[1] or False
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
ir_model_data = self.pool.get('ir.model.data')
try:
template_id = ir_model_data.get_object_reference(cr, uid, 'account', 'email_template_edi_invoice')[1]
except ValueError:
template_id = False
try:
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
except ValueError:
compose_form_id = False
ctx = dict(context)
ctx.update({
'default_model': 'account.invoice',
'default_res_id': ids[0],
'default_use_template': True,
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
'mark_invoice_as_sent': True,
})
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(res_id, 'form')],
'view_id': res_id,
'type': 'ir.actions.act_window',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
'nodestroy': True,
}
def confirm_paid(self, cr, uid, ids, context=None):
@ -431,13 +449,12 @@ class account_invoice(osv.osv):
if t['state'] in ('draft', 'cancel') and t['internal_number']== False:
unlink_ids.append(t['id'])
else:
raise osv.except_osv(_('Invalid Action!'), _('You cannot delete an invoice which is open or paid. You should refund it instead.'))
raise osv.except_osv(_('Invalid Action!'), _('You can not delete an invoice which is not cancelled. You should refund it instead.'))
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True
def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
invoice_addr_id = False
partner_payment_term = False
acc_id = False
bank_id = False
@ -447,11 +464,9 @@ class account_invoice(osv.osv):
if partner_id:
opt.insert(0, ('id', partner_id))
res = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['invoice'])
invoice_addr_id = res['invoice']
p = self.pool.get('res.partner').browse(cr, uid, partner_id)
if company_id:
if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id:
if (p.property_account_receivable.company_id and (p.property_account_receivable.company_id.id != company_id)) and (p.property_account_payable.company_id and (p.property_account_payable.company_id.id != company_id)):
property_obj = self.pool.get('ir.property')
rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
@ -474,10 +489,11 @@ class account_invoice(osv.osv):
if type in ('out_invoice', 'out_refund'):
acc_id = p.property_account_receivable.id
partner_payment_term = p.property_payment_term and p.property_payment_term.id or False
else:
acc_id = p.property_account_payable.id
partner_payment_term = p.property_supplier_payment_term and p.property_supplier_payment_term.id or False
fiscal_position = p.property_account_position and p.property_account_position.id or False
partner_payment_term = p.property_payment_term and p.property_payment_term.id or False
if p.bank_ids:
bank_id = p.bank_ids[0].id
@ -518,11 +534,11 @@ class account_invoice(osv.osv):
return result
def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):
res = {}
if not payment_term_id:
return res
res = {}
if not date_invoice:
date_invoice = time.strftime('%Y-%m-%d')
if not payment_term_id:
return {'value':{'date_due': date_invoice}} #To make sure the invoice has a due date when no payment term
pterm_list = self.pool.get('account.payment.term').compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)
if pterm_list:
pterm_list = [line[0] for line in pterm_list]
@ -865,8 +881,11 @@ class account_invoice(osv.osv):
self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj)
# 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.'))
group_check_total_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'group_supplier_inv_check_total')[1]
group_check_total = self.pool.get('res.groups').browse(cr, uid, group_check_total_id, context=context)
if group_check_total and uid in [x.id for x in group_check_total.users]:
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 encoded total does not match the computed total.'))
if inv.payment_term:
total_fixed = total_percent = 0
@ -949,9 +968,10 @@ 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=ctx)),iml)
part = self._find_partner(inv)
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part.id, date, context=ctx)),iml)
line = self.group_lines(cr, uid, iml, line, inv)
@ -980,13 +1000,13 @@ class account_invoice(osv.osv):
for i in line:
i[2]['period_id'] = period_id
ctx.update(invoice=inv)
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}, 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:
ctx.update({'invoice':inv})
move_obj.post(cr, uid, [move_id], context=ctx)
self._log_event(cr, uid, ids)
return True
@ -1059,8 +1079,9 @@ class account_invoice(osv.osv):
self.message_post(cr, uid, [inv_id], body=message, context=context)
return True
def action_cancel(self, cr, uid, ids, *args):
context = {} # TODO: Use context from arguments
def action_cancel(self, cr, uid, ids, context=None):
if context is None:
context = {}
account_move_obj = self.pool.get('account.move')
invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
move_ids = [] # ones that we will need to remove
@ -1230,12 +1251,15 @@ class account_invoice(osv.osv):
ref = invoice.reference
else:
ref = self._convert_ref(cr, uid, invoice.number)
partner = invoice.partner_id
if partner.parent_id and not partner.is_company:
partner = partner.parent_id
# Pay attention to the sign for both debit/credit AND amount_currency
l1 = {
'debit': direction * pay_amount>0 and direction * pay_amount,
'credit': direction * pay_amount<0 and - direction * pay_amount,
'account_id': src_account_id,
'partner_id': invoice.partner_id.id,
'partner_id': partner.id,
'ref':ref,
'date': date,
'currency_id':currency_id,
@ -1246,7 +1270,7 @@ class account_invoice(osv.osv):
'debit': direction * pay_amount<0 and - direction * pay_amount,
'credit': direction * pay_amount>0 and direction * pay_amount,
'account_id': pay_account_id,
'partner_id': invoice.partner_id.id,
'partner_id': partner.id,
'ref':ref,
'date': date,
'currency_id':currency_id,
@ -1363,8 +1387,8 @@ class account_invoice_line(osv.osv):
'origin': fields.char('Source Document', size=256, help="Reference of the document that produced this invoice."),
'sequence': fields.integer('Sequence', help="Gives the sequence of this line when displaying the invoice."),
'invoice_id': fields.many2one('account.invoice', 'Invoice Reference', ondelete='cascade', select=True),
'uos_id': fields.many2one('product.uom', 'Unit of Measure', ondelete='set null'),
'product_id': fields.many2one('product.product', 'Product', ondelete='set null'),
'uos_id': fields.many2one('product.uom', 'Unit of Measure', ondelete='set null', select=True),
'product_id': fields.many2one('product.product', 'Product', ondelete='set null', select=True),
'account_id': fields.many2one('account.account', 'Account', required=True, domain=[('type','<>','view'), ('type', '<>', 'closed')], help="The income or expense account related to the selected product."),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),
'price_subtotal': fields.function(_amount_line, string='Subtotal', type="float",
@ -1405,7 +1429,7 @@ class account_invoice_line(osv.osv):
res['arch'] = etree.tostring(doc)
return res
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
if context is None:
context = {}
company_id = company_id if company_id != None else context.get('company_id',False)
@ -1451,14 +1475,11 @@ class account_invoice_line(osv.osv):
result.update({'price_unit': res.list_price, 'invoice_line_tax_id': tax_id})
result['name'] = res.partner_ref
domain = {}
result['uos_id'] = res.uom_id.id or uom or False
result['uos_id'] = uom_id or res.uom_id.id
if res.description:
result['name'] += '\n'+res.description
if result['uos_id']:
res2 = res.uom_id.category_id.id
if res2:
domain = {'uos_id':[('category_id','=',res2 )]}
domain = {'uos_id':[('category_id','=',res.uom_id.category_id.id)]}
res_final = {'value':result, 'domain':domain}
@ -1474,10 +1495,10 @@ class account_invoice_line(osv.osv):
new_price = res_final['value']['price_unit'] * currency.rate
res_final['value']['price_unit'] = new_price
if uom:
uom = self.pool.get('product.uom').browse(cr, uid, uom, context=context)
if res.uom_id.category_id.id == uom.category_id.id:
new_price = res_final['value']['price_unit'] * uom.factor_inv
if result['uos_id'] != res.uom_id.id:
selected_uom = self.pool.get('product.uom_id').browse(cr, uid, result['uos_id'], context=context)
if res.uom_id.category_id.id == selected_uom.category_id.id:
new_price = res_final['value']['price_unit'] * uom_id.factor_inv
res_final['value']['price_unit'] = new_price
return res_final
@ -1489,8 +1510,6 @@ class account_invoice_line(osv.osv):
context.update({'company_id': company_id})
warning = {}
res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context)
if 'uos_id' in res['value']:
del res['value']['uos_id']
if not uom:
res['value']['price_unit'] = 0.0
if product and uom:
@ -1722,8 +1741,6 @@ class account_invoice_tax(osv.osv):
})
return res
account_invoice_tax()
class res_partner(osv.osv):
""" Inherits partner and adds invoice information in the partner form """
@ -1737,16 +1754,14 @@ class res_partner(osv.osv):
default.update({'invoice_ids' : []})
return super(res_partner, self).copy(cr, uid, id, default, context)
res_partner()
class mail_message(osv.osv):
_name = 'mail.message'
_inherit = 'mail.message'
class mail_compose_message(osv.osv):
_inherit = 'mail.compose.message'
def _postprocess_sent_message(self, cr, uid, message, context=None):
if message.model == 'account.invoice':
self.pool.get('account.invoice').write(cr, uid, [message.res_id], {'sent':True}, context=context)
return super(mail_message, self)._postprocess_sent_message(cr, uid, message=message, context=context)
def send_mail(self, cr, uid, ids, context=None):
context = context or {}
if context.get('default_model') == 'account.invoice' and context.get('default_res_id') and context.get('mark_invoice_as_sent'):
self.pool.get('account.invoice').write(cr, uid, [context['default_res_id']], {'sent': True}, context=context)
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
mail_message()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -61,7 +61,7 @@
<group>
<field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)" groups="account.group_account_user"/>
<field name="invoice_line_tax_id" context="{'type':parent.type}" domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]" widget="many2many_tags"/>
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
<field name="company_id" groups="base.group_multi_company" readonly="1"/>
</group>
</group>
@ -95,7 +95,7 @@
<field name="name"/>
<field name="sequence"/>
<field name="account_id" groups="account.group_account_user"/>
<field name="account_analytic_id" domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" groups="analytic.group_analytic_accounting"/>
<field name="account_analytic_id" domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/>
<field name="manual"/>
<field name="amount"/>
<field name="base" readonly="0"/>
@ -168,10 +168,8 @@
context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"
domain="[('supplier', '=', True)]"/>
<field name="fiscal_position" widget="selection"/>
<group>
<field name="origin"/>
<field name="supplier_invoice_number"/>
</group>
<field name="origin"/>
<field name="supplier_invoice_number"/>
<label for="reference_type"/>
<div>
<field name="reference_type" class="oe_inline oe_edit_only"/>
@ -186,6 +184,7 @@
<field name="journal_id" groups="account.group_account_user"
on_change="onchange_journal_id(journal_id, context)" widget="selection"/>
<field name="currency_id" groups="base.group_multi_currency"/>
<field name="check_total" groups="account.group_supplier_inv_check_total"/>
</group>
</group>
<notebook>
@ -200,7 +199,7 @@
domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '!=', 'view')]"
on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"
domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]"/>
domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
<field name="quantity"/>
<field name="uos_id" groups="product.group_uom"
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
@ -230,7 +229,7 @@
<tree editable="bottom" string="Taxes">
<field name="name"/>
<field name="account_id" groups="account.group_account_invoice"/>
<field name="account_analytic_id" domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" groups="analytic.group_analytic_accounting"/>
<field name="account_analytic_id" domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/>
<field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>
<field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/>
@ -279,8 +278,8 @@
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_ids" widget="mail_thread"/>
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
@ -293,7 +292,7 @@
<form string="Invoice" version="7.0">
<header>
<button name="action_invoice_sent" type="object" string="Send by Email" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user"/>
<button name="invoice_print" string="Print Invoice" type="object" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user"/>
<button name="invoice_print" string="Print" type="object" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user"/>
<button name="action_invoice_sent" type="object" string="Send by Email" attrs="{'invisible':['|',('sent','=',False), ('state', '!=', 'open')]}" groups="base.group_user"/>
<button name="invoice_print" string="Print Invoice" type="object" attrs="{'invisible':['|',('sent','=',False), ('state', '!=', 'open')]}" groups="base.group_user"/>
<button name="invoice_open" states="draft" string="Validate" class="oe_highlight" groups="base.group_user"/>
@ -355,7 +354,7 @@
domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '!=', 'view')]"
on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"
domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]"/>
domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/>
<field name="quantity"/>
<field name="uos_id" groups="product.group_uom"
on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
@ -436,8 +435,8 @@
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread" placeholder="Share a note..."/>
</div>
</form>
</field>

View File

@ -6,7 +6,7 @@
<menuitem name="Invoicing"
id="menu_finance"
groups="group_account_user,group_account_manager,group_account_invoice"
sequence="100"/>
sequence="50"/>
<menuitem id="menu_finance_receivables" name="Customers" parent="menu_finance" sequence="2"/>
<menuitem id="menu_finance_payables" name="Suppliers" parent="menu_finance" sequence="3"/>

View File

@ -166,28 +166,35 @@ class account_move_line(osv.osv):
del data[f]
return data
def _prepare_analytic_line(self, cr, uid, obj_line, context=None):
"""
Prepare the values given at the create() of account.analytic.line upon the validation of a journal item having
an analytic account. This method is intended to be extended in other modules.
:param obj_line: browse record of the account.move.line that triggered the analytic line creation
"""
return {'name': obj_line.name,
'date': obj_line.date,
'account_id': obj_line.analytic_account_id.id,
'unit_amount': obj_line.quantity,
'product_id': obj_line.product_id and obj_line.product_id.id or False,
'product_uom_id': obj_line.product_uom_id and obj_line.product_uom_id.id or False,
'amount': (obj_line.credit or 0.0) - (obj_line.debit or 0.0),
'general_account_id': obj_line.account_id.id,
'journal_id': obj_line.journal_id.analytic_journal_id.id,
'ref': obj_line.ref,
'move_id': obj_line.id,
'user_id': uid,
}
def create_analytic_lines(self, cr, uid, ids, context=None):
acc_ana_line_obj = self.pool.get('account.analytic.line')
for obj_line in self.browse(cr, uid, ids, context=context):
if obj_line.analytic_account_id:
if not obj_line.journal_id.analytic_journal_id:
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name, ))
amt = (obj_line.credit or 0.0) - (obj_line.debit or 0.0)
vals_lines = {
'name': obj_line.name,
'date': obj_line.date,
'account_id': obj_line.analytic_account_id.id,
'unit_amount': obj_line.quantity,
'product_id': obj_line.product_id and obj_line.product_id.id or False,
'product_uom_id': obj_line.product_uom_id and obj_line.product_uom_id.id or False,
'amount': amt,
'general_account_id': obj_line.account_id.id,
'journal_id': obj_line.journal_id.analytic_journal_id.id,
'ref': obj_line.ref,
'move_id': obj_line.id,
'user_id': uid
}
acc_ana_line_obj.create(cr, uid, vals_lines)
vals_line = self._prepare_analytic_line(cr, uid, obj_line, context=context)
acc_ana_line_obj.create(cr, uid, vals_line)
return True
def _default_get_move_form_hook(self, cursor, user, data):
@ -208,17 +215,16 @@ class account_move_line(osv.osv):
if type(period_id) == str:
ids = period_obj.search(cr, uid, [('name', 'ilike', period_id)])
context.update({
'period_id': ids[0]
'period_id': ids and ids[0] or False
})
return context
def _default_get(self, cr, uid, fields, context=None):
#default_get should only do the following:
# -propose the next amount in debit/credit in order to balance the move
# -propose the next account from the journal (default debit/credit account) accordingly
if context is None:
context = {}
if not context.get('journal_id', False):
context['journal_id'] = context.get('search_default_journal_id')
if not context.get('period_id', False):
context['period_id'] = context.get('search_default_period_id')
account_obj = self.pool.get('account.account')
period_obj = self.pool.get('account.period')
journal_obj = self.pool.get('account.journal')
@ -227,134 +233,71 @@ class account_move_line(osv.osv):
fiscal_pos_obj = self.pool.get('account.fiscal.position')
partner_obj = self.pool.get('res.partner')
currency_obj = self.pool.get('res.currency')
if not context.get('journal_id', False):
context['journal_id'] = context.get('search_default_journal_id', False)
if not context.get('period_id', False):
context['period_id'] = context.get('search_default_period_id', False)
context = self.convert_to_period(cr, uid, context)
#pass the right context when search_defaul_journal_id
if context.get('search_default_journal_id',False):
context['journal_id'] = context.get('search_default_journal_id')
# 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 = context.get('balance', 0.00)
if context['journal']:
journal_data = journal_obj.browse(cr, uid, context['journal'], context=context)
if journal_data.type == 'purchase':
if total_new > 0:
account = journal_data.default_credit_account_id
else:
account = journal_data.default_debit_account_id
else:
if total_new > 0:
account = journal_data.default_credit_account_id
else:
account = journal_data.default_debit_account_id
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)) and 'partner_id' in data and (data['partner_id']):
part = partner_obj.browse(cr, uid, data['partner_id'], context=context)
account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
account = account_obj.browse(cr, uid, account, context=context)
data['account_id'] = account.id
s = -total_new
data['debit'] = s > 0 and s or 0.0
data['credit'] = s < 0 and -s or 0.0
data = self._default_get_move_form_hook(cr, uid, data)
return data
# Ends: Manual entry from account.move form
if not 'move_id' in fields: #we are not in manual entry
return data
# Compute the current move
move_id = False
partner_id = False
if context.get('journal_id', False) and context.get('period_id', False):
if 'move_id' in fields:
cr.execute('SELECT move_id \
FROM \
account_move_line \
WHERE \
journal_id = %s and period_id = %s AND create_uid = %s AND state = %s \
ORDER BY id DESC limit 1',
(context['journal_id'], context['period_id'], uid, 'draft'))
if context.get('journal_id'):
total = 0.0
#in account.move form view, it is not possible to compute total debit and credit using
#a browse record. So we must use the context to pass the whole one2many field and compute the total
if context.get('line_id'):
for move_line_dict in move_obj.resolve_2many_commands(cr, uid, 'line_id', context.get('line_id'), context=context):
data['name'] = data.get('name') or move_line_dict.get('name')
data['partner_id'] = data.get('partner_id') or move_line_dict.get('partner_id')
total += move_line_dict.get('debit', 0.0) - move_line_dict.get('credit', 0.0)
elif context.get('period_id'):
#find the date and the ID of the last unbalanced account.move encoded by the current user in that journal and period
move_id = False
cr.execute('''SELECT move_id, date FROM account_move_line
WHERE journal_id = %s AND period_id = %s AND create_uid = %s AND state = %s
ORDER BY id DESC limit 1''', (context['journal_id'], context['period_id'], uid, 'draft'))
res = cr.fetchone()
move_id = (res and res[0]) or False
if not move_id:
return data
else:
data['move_id'] = move_id
if 'date' in fields:
cr.execute('SELECT date \
FROM \
account_move_line \
WHERE \
journal_id = %s AND period_id = %s AND create_uid = %s \
ORDER BY id DESC',
(context['journal_id'], context['period_id'], uid))
res = cr.fetchone()
if res:
data['date'] = res[0]
else:
period = period_obj.browse(cr, uid, context['period_id'],
context=context)
data['date'] = period.date_start
if not move_id:
return data
total = 0
ref_id = False
move = move_obj.browse(cr, uid, move_id, context=context)
if 'name' in fields:
data.setdefault('name', move.line_id[-1].name)
acc1 = False
for l in move.line_id:
acc1 = l.account_id
partner_id = partner_id or l.partner_id.id
ref_id = ref_id or l.ref
total += (l.debit or 0.0) - (l.credit or 0.0)
move_id = res and res[0] or False
data['date'] = res and res[1] or period_obj.browse(cr, uid, context['period_id'], context=context).date_start
data['move_id'] = move_id
if move_id:
#if there exist some unbalanced accounting entries that match the journal and the period,
#we propose to continue the same move by copying the ref, the name, the partner...
move = move_obj.browse(cr, uid, move_id, context=context)
data.setdefault('name', move.line_id[-1].name)
for l in move.line_id:
data['partner_id'] = data.get('partner_id') or l.partner_id.id
data['ref'] = data.get('ref') or l.ref
total += (l.debit or 0.0) - (l.credit or 0.0)
if 'ref' in fields:
data['ref'] = ref_id
if 'partner_id' in fields:
data['partner_id'] = partner_id
if move.journal_id.type == 'purchase':
if total > 0:
account = move.journal_id.default_credit_account_id
else:
account = move.journal_id.default_debit_account_id
else:
if total > 0:
account = move.journal_id.default_credit_account_id
else:
account = move.journal_id.default_debit_account_id
part = partner_id and partner_obj.browse(cr, uid, partner_id) or False
# part = False is acceptable for fiscal position.
account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
if account:
account = account_obj.browse(cr, uid, account, context=context)
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
data['account_id'] = account.id
# Propose the price Tax excluded, the Tax will be added when confirming line
if account.tax_ids:
taxes = fiscal_pos_obj.map_tax(cr, uid, part and part.property_account_position or False, account.tax_ids)
tax = tax_obj.browse(cr, uid, taxes)
for t in tax_obj.compute_inv(cr, uid, tax, total, 1):
total -= t['amount']
s = -total
data['debit'] = s > 0 and s or 0.0
data['credit'] = s < 0 and -s or 0.0
if account and account.currency_id:
data['currency_id'] = account.currency_id.id
acc = account
if s>0:
acc = acc1
compute_ctx = context.copy()
compute_ctx.update({
'res.currency.compute.account': acc,
'res.currency.compute.account_invert': True,
})
v = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], s, context=compute_ctx)
data['amount_currency'] = v
#compute the total of current move
data['debit'] = total < 0 and -total or 0.0
data['credit'] = total > 0 and total or 0.0
#pick the good account on the journal accordingly if the next proposed line will be a debit or a credit
journal_data = journal_obj.browse(cr, uid, context['journal_id'], context=context)
account = total > 0 and journal_data.default_credit_account_id or journal_data.default_debit_account_id
#map the account using the fiscal position of the partner, if needed
part = data.get('partner_id') and partner_obj.browse(cr, uid, data['partner_id'], context=context) or False
if account and data.get('partner_id'):
account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
account = account_obj.browse(cr, uid, account, context=context)
data['account_id'] = account and account.id or False
#compute the amount in secondary currency of the account, if needed
if account and account.currency_id:
data['currency_id'] = account.currency_id.id
#set the context for the multi currency change
compute_ctx = context.copy()
compute_ctx.update({
#the following 2 parameters are used to choose the currency rate, in case where the account
#doesn't work with an outgoing currency rate method 'at date' but 'average'
'res.currency.compute.account': account,
'res.currency.compute.account_invert': True,
})
if data.get('date'):
compute_ctx.update({'date': data['date']})
data['amount_currency'] = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], -total, context=compute_ctx)
data = self._default_get_move_form_hook(cr, uid, data)
return data
def on_create_write(self, cr, uid, id, context=None):
@ -477,6 +420,15 @@ class account_move_line(osv.osv):
result.append(line.id)
return result
def _get_reconcile(self, cr, uid, ids,name, unknow_none, context=None):
res = dict.fromkeys(ids, False)
for line in self.browse(cr, uid, ids, context=context):
if line.reconcile_id:
res[line.id] = str(line.reconcile_id.name)
elif line.reconcile_partial_id:
res[line.id] = str(line.reconcile_partial_id.name)
return res
_columns = {
'name': fields.char('Name', size=64, required=True),
'quantity': fields.float('Quantity', digits=(16,2), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very useful for some reports."),
@ -491,15 +443,16 @@ class account_move_line(osv.osv):
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),
'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2),
'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2),
'reconcile': fields.function(_get_reconcile, type='char', string='Reconcile'),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')),
'amount_residual_currency': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."),
'amount_residual': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
'journal_id': fields.related('move_id', 'journal_id', string='Journal', type='many2one', relation='account.journal', required=True, select=True, readonly=True,
'journal_id': fields.related('move_id', 'journal_id', string='Journal', type='many2one', relation='account.journal', required=True, select=True,
store = {
'account.move': (_get_move_lines, ['journal_id'], 20)
}),
'period_id': fields.related('move_id', 'period_id', string='Period', type='many2one', relation='account.period', required=True, select=True, readonly=True,
'period_id': fields.related('move_id', 'period_id', string='Period', type='many2one', relation='account.period', required=True, select=True,
store = {
'account.move': (_get_move_lines, ['period_id'], 20)
}),
@ -522,7 +475,8 @@ class account_move_line(osv.osv):
type='many2one', relation='account.invoice', fnct_search=_invoice_search),
'account_tax_id':fields.many2one('account.tax', 'Tax'),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True)
'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company',
string='Company', store=True, readonly=True)
}
def _get_date(self, cr, uid, context=None):
@ -530,7 +484,7 @@ class account_move_line(osv.osv):
context or {}
period_obj = self.pool.get('account.period')
dt = time.strftime('%Y-%m-%d')
if ('journal_id' in context) and ('period_id' in context):
if context.get('journal_id') and context.get('period_id'):
cr.execute('SELECT date FROM account_move_line ' \
'WHERE journal_id = %s AND period_id = %s ' \
'ORDER BY id DESC limit 1',
@ -551,6 +505,38 @@ class account_move_line(osv.osv):
cur = self.pool.get('account.journal').browse(cr, uid, context['journal_id']).currency
return cur and cur.id or False
def _get_period(self, cr, uid, context=None):
"""
Return default account period value
"""
context = context or {}
if context.get('period_id', False):
return context['period_id']
account_period_obj = self.pool.get('account.period')
ids = account_period_obj.find(cr, uid, context=context)
period_id = False
if ids:
period_id = ids[0]
return period_id
def _get_journal(self, cr, uid, context=None):
"""
Return journal based on the journal type
"""
context = context or {}
if context.get('journal_id', False):
return context['journal_id']
journal_id = False
journal_pool = self.pool.get('account.journal')
if context.get('journal_type', False):
jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))])
if not jids:
raise osv.except_osv(_('Configuration Error!'), _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration/Journals/Journals.') % context.get('journal_type'))
journal_id = jids[0]
return journal_id
_defaults = {
'blocked': False,
'centralisation': 'normal',
@ -558,12 +544,12 @@ class account_move_line(osv.osv):
'date_created': fields.date.context_today,
'state': 'draft',
'currency_id': _get_currency,
'journal_id': lambda self, cr, uid, c: c.get('journal_id', False),
'journal_id': _get_journal,
'credit': 0.0,
'debit': 0.0,
'amount_currency': 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),
'period_id': _get_period,
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)
}
_order = "date desc, id desc"
@ -582,7 +568,7 @@ class account_move_line(osv.osv):
lines = self.browse(cr, uid, ids, context=context)
for l in lines:
if l.account_id.type == 'view':
raise osv.except_osv(_('Error!'), _('You cannot create journal items on “View” type account %s %s.') % (l.account_id.code, l.account_id.name))
return False
return True
def _check_no_closed(self, cr, uid, ids, context=None):
@ -613,12 +599,34 @@ class account_move_line(osv.osv):
return False
return True
def _check_currency_and_amount(self, cr, uid, ids, context=None):
for l in self.browse(cr, uid, ids, context=context):
if (l.amount_currency and not l.currency_id):
return False
return True
def _check_currency_amount(self, cr, uid, ids, context=None):
for l in self.browse(cr, uid, ids, context=context):
if l.amount_currency:
if (l.amount_currency > 0.0 and l.credit > 0.0) or (l.amount_currency < 0.0 and l.debit > 0.0):
return False
return True
def _check_currency_company(self, cr, uid, ids, context=None):
for l in self.browse(cr, uid, ids, context=context):
if l.currency_id.id == l.company_id.currency_id.id:
return False
return True
_constraints = [
(_check_no_view, 'You cannot create journal items on an account of type view.', ['account_id']),
(_check_no_closed, 'You cannot create journal items on closed account.', ['account_id']),
(_check_company_id, 'Account and Period must belong to the same company.', ['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']),
(_check_currency_and_amount, "You cannot create journal items with a secondary currency without recording both 'currency' and 'amount currency' field.", ['currency_id','amount_currency']),
(_check_currency_amount, 'The amount expressed in the secondary currency must be positif when journal item are debit and negatif when journal item are credit.', ['amount_currency']),
(_check_currency_company, "You cannot provide a secondary currency if it is the same than the company one." , ['currency_id']),
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
@ -646,6 +654,12 @@ class account_move_line(osv.osv):
}
return result
def onchange_account_id(self, cr, uid, ids, account_id, context=None):
res = {'value': {}}
if account_id:
res['value']['account_tax_id'] = [x.id for x in self.pool.get('account.account').browse(cr, uid, account_id, context=context).tax_ids]
return res
def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False):
partner_obj = self.pool.get('res.partner')
payment_term_obj = self.pool.get('account.payment.term')
@ -658,17 +672,24 @@ class account_move_line(osv.osv):
return {'value':val}
if not date:
date = datetime.now().strftime('%Y-%m-%d')
jt = False
if journal:
jt = journal_obj.browse(cr, uid, journal).type
part = partner_obj.browse(cr, uid, partner_id)
if part.property_payment_term:
res = payment_term_obj.compute(cr, uid, part.property_payment_term.id, 100, date)
payment_term_id = False
if jt and jt in ('purchase', 'purchase_refund') and part.property_supplier_payment_term:
payment_term_id = part.property_supplier_payment_term.id
elif jt and part.property_payment_term:
payment_term_id = part.property_payment_term.id
if payment_term_id:
res = payment_term_obj.compute(cr, uid, payment_term_id, 100, date)
if res:
val['date_maturity'] = res[0][0]
if not account_id:
id1 = part.property_account_payable.id
id2 = part.property_account_receivable.id
if journal:
jt = journal_obj.browse(cr, uid, journal).type
if jt:
if jt in ('sale', 'purchase_refund'):
val['account_id'] = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, id2)
elif jt in ('purchase', 'sale_refund'):
@ -917,7 +938,7 @@ class account_move_line(osv.osv):
if lines and lines[0]:
partner_id = lines[0].partner_id and lines[0].partner_id.id or False
if not partner_obj.has_something_to_reconcile(cr, uid, partner_id, context=context):
if partner_id and not partner_obj.has_something_to_reconcile(cr, uid, partner_id, context=context):
partner_obj.mark_as_reconciled(cr, uid, [partner_id], context=context)
return r_id
@ -970,127 +991,6 @@ class account_move_line(osv.osv):
'context':context,
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
journal_pool = self.pool.get('account.journal')
if context is None:
context = {}
result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
if view_type != 'tree':
#Remove the toolbar from the form view
if view_type == 'form':
if result.get('toolbar', False):
result['toolbar']['action'] = []
#Restrict the list of journal view in search view
if view_type == 'search' and result['fields'].get('journal_id', False):
result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context)
ctx = context.copy()
#we add the refunds journal in the selection field of journal
if context.get('journal_type', False) == 'sale':
ctx.update({'journal_type': 'sale_refund'})
result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
elif context.get('journal_type', False) == 'purchase':
ctx.update({'journal_type': 'purchase_refund'})
result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
return result
if context.get('view_mode', False):
return result
fld = []
flds = []
title = _("Accounting Entries") # self.view_header_get(cr, uid, view_id, view_type, context)
ids = journal_pool.search(cr, uid, [], context=context)
journals = journal_pool.browse(cr, uid, ids, context=context)
for journal in journals:
for field in journal.view_id.columns_id:
# sometimes, it's possible that a defined column is not loaded (the module containing
# this field is not loaded) when we make an update.
if field.field not in self._columns:
continue
if not field.field in flds:
fld.append((field.field, field.sequence))
flds.append(field.field)
default_columns = {
'period_id': 3,
'journal_id': 10,
'state': sys.maxint,
}
for d in default_columns:
if d not in flds:
fld.append((d, default_columns[d]))
flds.append(d)
fld = sorted(fld, key=itemgetter(1))
widths = {
'statement_id': 50,
'state': 60,
'tax_code_id': 50,
'move_id': 40,
}
document = etree.Element('tree', string=title, editable="top",
on_write="on_create_write",
colors="red:state=='draft';black:state=='valid'")
fields_get = self.fields_get(cr, uid, flds, context)
for field, _seq in fld:
# TODO add string to element
f = etree.SubElement(document, 'field', name=field)
if field == 'debit':
f.set('sum', _("Total debit"))
elif field == 'credit':
f.set('sum', _("Total credit"))
elif field == 'move_id':
f.set('required', 'False')
elif field == 'account_tax_id':
f.set('domain', "[('parent_id', '=' ,False)]")
f.set('context', "{'journal_id': journal_id}")
elif field == 'account_id' and journal.id:
f.set('domain', "[('journal_id', '=', journal_id),('type','!=','view'), ('type','!=','closed')]")
f.set('on_change', 'onchange_account_id(account_id, partner_id)')
elif field == 'partner_id':
f.set('on_change', 'onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)')
elif field == 'journal_id':
f.set('context', "{'journal_id': journal_id}")
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)')
elif field == 'analytic_account_id':
# Currently it is not working due to being executed by superclass's fields_view_get
# f.set('groups', 'analytic.group_analytic_accounting')
pass
if field in ('amount_currency', 'currency_id'):
f.set('on_change', 'onchange_currency(account_id, amount_currency, currency_id, date, journal_id)')
f.set('attrs', "{'readonly': [('state', '=', 'valid')]}")
if field in widths:
f.set('width', str(widths[field]))
if field in ('journal_id',):
f.set("invisible", "context.get('journal_id', False)")
elif field in ('period_id',):
f.set("invisible", "context.get('period_id', False)")
orm.setup_modifiers(f, fields_get[field], context=context,
in_tree_view=True)
result['arch'] = etree.tostring(document, pretty_print=True)
result['fields'] = fields_get
return result
def _check_moves(self, cr, uid, context=None):
# use the first move ever created for this journal and period
if context is None:
@ -1104,7 +1004,7 @@ class account_move_line(osv.osv):
'has been confirmed.') % res[2])
return res
def _remove_move_reconcile(self, cr, uid, move_ids=None, context=None):
def _remove_move_reconcile(self, cr, uid, move_ids=None, opening_reconciliation=False, context=None):
# Function remove move rencocile ids related with moves
obj_move_line = self.pool.get('account.move.line')
obj_move_rec = self.pool.get('account.move.reconcile')
@ -1119,6 +1019,8 @@ class account_move_line(osv.osv):
unlink_ids += rec_ids
unlink_ids += part_rec_ids
if unlink_ids:
if opening_reconciliation:
obj_move_rec.write(cr, uid, unlink_ids, {'opening_reconciliation': False})
obj_move_rec.unlink(cr, uid, unlink_ids)
return True
@ -1383,6 +1285,19 @@ class account_move_line(osv.osv):
move_obj.button_validate(cr,uid, [vals['move_id']], context)
return result
def list_periods(self, cr, uid, context=None):
ids = self.pool.get('account.period').search(cr,uid,[])
return self.pool.get('account.period').name_get(cr, uid, ids, context=context)
def list_journals(self, cr, uid, context=None):
ng = dict(self.pool.get('account.journal').name_search(cr,uid,'',[]))
ids = ng.keys()
result = []
for journal in self.pool.get('account.journal').browse(cr, uid, ids, context=context):
result.append((journal.id,ng[journal.id],journal.type,
bool(journal.currency),bool(journal.analytic_journal_id)))
return result
account_move_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -41,13 +41,5 @@
groups="group_account_user,group_account_manager"
parent="account.menu_finance_generic_reporting" sequence="3"/>
<report id="account_account_balance_landscape"
string="Account balance"
model="account.account"
name="account.account.balance.landscape"
rml="account/report/account_balance_landscape.rml"
auto="False"
menu="False"/>
</data>
</openerp>

File diff suppressed because it is too large Load Diff

View File

@ -59,417 +59,6 @@
<field eval="account_payment_term_advance" name="payment_id"/>
</record>
<!--
Account Journal View
-->
<record id="account_journal_bank_view" model="account.journal.view">
<field name="name">Bank/Cash Journal View</field>
</record>
<record id="bank_col1" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Date</field>
<field name="field">date</field>
<field eval="True" name="required"/>
<field eval="3" name="sequence"/>
</record>
<record id="bank_col2" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Journal Entry</field>
<field name="field">move_id</field>
<field eval="False" name="required"/>
<field eval="1" name="sequence"/>
</record>
<record id="bank_col7" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Name</field>
<field name="field">name</field>
<field eval="7" name="sequence"/>
<field eval="True" name="required"/>
</record>
<record id="bank_col4" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Statement</field>
<field name="field">statement_id</field>
<field eval="4" name="sequence"/>
</record>
<record id="bank_col6" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Partner</field>
<field name="field">partner_id</field>
<field eval="5" name="sequence"/>
</record>
<record id="bank_col5" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Account</field>
<field name="field">account_id</field>
<field eval="True" name="required"/>
<field eval="6" name="sequence"/>
</record>
<record id="bank_col9" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Debit</field>
<field name="field">debit</field>
<field eval="11" name="sequence"/>
</record>
<record id="bank_col10" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Credit</field>
<field name="field">credit</field>
<field eval="12" name="sequence"/>
</record>
<record id="bank_col3" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Ref</field>
<field name="field">ref</field>
<field eval="2" name="sequence"/>
</record>
<record id="bank_col23" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Status</field>
<field name="field">state</field>
<field eval="True" name="invisible"/>
<field eval="19" name="sequence"/>
</record>
<record id="bank_col20" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view"/>
<field name="name">Reconcile</field>
<field name="field">reconcile_id</field>
<field eval="20" name="sequence"/>
</record>
<record id="account_journal_bank_view_multi" model="account.journal.view">
<field name="name">Bank/Cash Journal (Multi-Currency) View</field>
</record>
<record id="bank_col1_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Date</field>
<field name="field">date</field>
<field eval="True" name="required"/>
<field eval="3" name="sequence"/>
</record>
<record id="bank_col2_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Journal Entry</field>
<field name="field">move_id</field>
<field eval="False" name="required"/>
<field eval="1" name="sequence"/>
</record>
<record id="bank_col7_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Name</field>
<field name="field">name</field>
<field eval="7" name="sequence"/>
<field eval="True" name="required"/>
</record>
<record id="bank_col4_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Statement</field>
<field name="field">statement_id</field>
<field eval="4" name="sequence"/>
</record>
<record id="bank_col6_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Partner</field>
<field name="field">partner_id</field>
<field eval="5" name="sequence"/>
</record>
<record id="bank_col5_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Account</field>
<field name="field">account_id</field>
<field eval="True" name="required"/>
<field eval="6" name="sequence"/>
</record>
<record id="bank_col17_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Currency Amt.</field>
<field name="field">amount_currency</field>
<field eval="9" name="sequence"/>
</record>
<record id="bank_col18_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Currency</field>
<field name="field">currency_id</field>
<field eval="10" name="sequence"/>
</record>
<record id="bank_col9_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Debit</field>
<field name="field">debit</field>
<field eval="11" name="sequence"/>
</record>
<record id="bank_col10_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Credit</field>
<field name="field">credit</field>
<field eval="12" name="sequence"/>
</record>
<record id="bank_col3_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Ref</field>
<field name="field">ref</field>
<field eval="2" name="sequence"/>
</record>
<record id="bank_col23_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Status</field>
<field name="field">state</field>
<field eval="True" name="invisible"/>
<field eval="19" name="sequence"/>
</record>
<record id="bank_col20_multi" model="account.journal.column">
<field name="view_id" ref="account_journal_bank_view_multi"/>
<field name="name">Reconcile</field>
<field name="field">reconcile_id</field>
<field eval="20" name="sequence"/>
</record>
<record id="account_journal_view" model="account.journal.view">
<field name="name">Journal View</field>
</record>
<record id="journal_col1" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Date</field>
<field name="field">date</field>
<field eval="True" name="required"/>
<field eval="3" name="sequence"/>
</record>
<record id="journal_col2" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Journal Entry</field>
<field name="field">move_id</field>
<field eval="False" name="required"/>
<field eval="1" name="sequence"/>
</record>
<record id="journal_col3" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Ref</field>
<field name="field">ref</field>
<field eval="2" name="sequence"/>
</record>
<record id="journal_col5" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Partner</field>
<field name="field">partner_id</field>
<field eval="5" name="sequence"/>
</record>
<record id="journal_col4" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Account</field>
<field name="field">account_id</field>
<field eval="True" name="required"/>
<field eval="6" name="sequence"/>
</record>
<record id="journal_col6" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Name</field>
<field name="field">name</field>
<field eval="7" name="sequence"/>
<field eval="True" name="required"/>
</record>
<record id="journal_col8" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Debit</field>
<field name="field">debit</field>
<field eval="11" name="sequence"/>
</record>
<record id="journal_col9" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Credit</field>
<field name="field">credit</field>
<field eval="12" name="sequence"/>
</record>
<record id="journal_col11" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Analytic Account</field>
<field name="field">analytic_account_id</field>
<field eval="14" name="sequence"/>
</record>
<record id="journal_col24" model="account.journal.column">
<field name="view_id" ref="account_journal_view"/>
<field name="name">Status</field>
<field name="field">state</field>
<field eval="True" name="invisible"/>
<field eval="19" name="sequence"/>
</record>
<record id="account_sp_journal_view" model="account.journal.view">
<field name="name">Sale/Purchase Journal View</field>
</record>
<record id="sp_journal_col1" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Date</field>
<field name="field">date</field>
<field eval="True" name="required"/>
<field eval="3" name="sequence"/>
</record>
<record id="sp_journal_col2" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Journal Entry</field>
<field name="field">move_id</field>
<field eval="False" name="required"/>
<field eval="1" name="sequence"/>
</record>
<record id="sp_journal_col3" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Ref</field>
<field name="field">ref</field>
<field eval="2" name="sequence"/>
</record>
<record id="sp_journal_col4" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Account</field>
<field name="field">account_id</field>
<field eval="True" name="required"/>
<field eval="6" name="sequence"/>
</record>
<record id="sp_journal_col5" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Partner</field>
<field name="field">partner_id</field>
<field eval="5" name="sequence"/>
</record>
<record id="sp_journal_col6" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Name</field>
<field name="field">name</field>
<field eval="7" name="sequence"/>
<field eval="True" name="required"/>
</record>
<record id="sp_journal_col7" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Due Date</field>
<field name="field">date_maturity</field>
<field eval="8" name="sequence"/>
</record>
<record id="sp_journal_col8" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Debit</field>
<field name="field">debit</field>
<field eval="11" name="sequence"/>
</record>
<record id="sp_journal_col9" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Credit</field>
<field name="field">credit</field>
<field eval="12" name="sequence"/>
</record>
<record id="sp_journal_col10" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Tax</field>
<field name="field">account_tax_id</field>
<field eval="13" name="sequence"/>
</record>
<record id="sp_journal_col11" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Analytic Account</field>
<field name="field">analytic_account_id</field>
<field eval="14" name="sequence"/>
</record>
<record id="sp_journal_col24" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Status</field>
<field name="field">state</field>
<field eval="True" name="invisible"/>
<field eval="19" name="sequence"/>
</record>
<record id="sp_journal_col20" model="account.journal.column">
<field name="view_id" ref="account_sp_journal_view"/>
<field name="name">Reconcile</field>
<field name="field">reconcile_id</field>
<field eval="20" name="sequence"/>
</record>
<record id="account_sp_refund_journal_view" model="account.journal.view">
<field name="name">Sale/Purchase Refund Journal View</field>
</record>
<record id="sp_refund_journal_col1" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Date</field>
<field name="field">date</field>
<field eval="True" name="required"/>
<field eval="3" name="sequence"/>
</record>
<record id="sp_refund_journal_col2" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Journal Entry</field>
<field name="field">move_id</field>
<field eval="False" name="required"/>
<field eval="1" name="sequence"/>
</record>
<record id="sp_refund_journal_col3" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Ref</field>
<field name="field">ref</field>
<field eval="2" name="sequence"/>
</record>
<record id="sp_refund_journal_col4" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Account</field>
<field name="field">account_id</field>
<field eval="True" name="required"/>
<field eval="6" name="sequence"/>
</record>
<record id="sp_refund_journal_col5" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Partner</field>
<field name="field">partner_id</field>
<field eval="5" name="sequence"/>
</record>
<record id="sp_refund_journal_col6" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Name</field>
<field name="field">name</field>
<field eval="7" name="sequence"/>
<field eval="True" name="required"/>
</record>
<record id="sp_refund_journal_col7" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Due Date</field>
<field name="field">date_maturity</field>
<field eval="8" name="sequence"/>
</record>
<record id="sp_refund_journal_col8" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Debit</field>
<field name="field">debit</field>
<field eval="11" name="sequence"/>
</record>
<record id="sp_refund_journal_col9" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Credit</field>
<field name="field">credit</field>
<field eval="12" name="sequence"/>
</record>
<record id="sp_refund_journal_col10" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Tax</field>
<field name="field">account_tax_id</field>
<field eval="13" name="sequence"/>
</record>
<record id="sp_refund_journal_col11" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Analytic Account</field>
<field name="field">analytic_account_id</field>
<field eval="14" name="sequence"/>
</record>
<record id="sp_refund_journal_col24" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Status</field>
<field name="field">state</field>
<field eval="True" name="invisible"/>
<field eval="19" name="sequence"/>
</record>
<record id="sp_refund_journal_col20" model="account.journal.column">
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="name">Reconcile</field>
<field name="field">reconcile_id</field>
<field eval="20" name="sequence"/>
</record>
<!--
Account Journal Sequences
-->

View File

@ -131,5 +131,21 @@
<record id="base.user_demo" model="res.users">
<field name="groups_id" eval="[(4,ref('account.group_account_user'))]"/>
</record>
<!-- Add payment term on some demo partners -->
<record id="base.res_partner_2" model="res.partner">
<field name="property_payment_term" ref="account_payment_term_net"/>
</record>
<record id="base.res_partner_12" model="res.partner">
<field name="property_payment_term" ref="account_payment_term"/>
<field name="property_supplier_payment_term" ref="account_payment_term"/>
</record>
<record id="base.res_partner_4" model="res.partner">
<field name="property_supplier_payment_term" ref="account_payment_term_net"/>
</record>
<record id="base.res_partner_1" model="res.partner">
<field name="property_supplier_payment_term" ref="account_payment_term"/>
</record>
</data>
</openerp>

View File

@ -312,7 +312,6 @@
<field name="name">Sales Journal - (test)</field>
<field name="code">TSAJ</field>
<field name="type">sale</field>
<field name="view_id" ref="account_sp_journal_view"/>
<field name="sequence_id" ref="sequence_sale_journal"/>
<field model="account.account" name="default_credit_account_id" ref="a_sale"/>
<field model="account.account" name="default_debit_account_id" ref="a_sale"/>
@ -323,7 +322,6 @@
<field name="name">Sales Credit Note Journal - (test)</field>
<field name="code">TSCNJ</field>
<field name="type">sale_refund</field>
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="sequence_id" ref="sequence_refund_sales_journal"/>
<field model="account.account" name="default_credit_account_id" ref="a_sale"/>
<field model="account.account" name="default_debit_account_id" ref="a_sale"/>
@ -335,7 +333,6 @@
<field name="name">Expenses Journal - (test)</field>
<field name="code">TEXJ</field>
<field name="type">purchase</field>
<field name="view_id" ref="account_sp_journal_view"/>
<field name="sequence_id" ref="sequence_purchase_journal"/>
<field model="account.account" name="default_debit_account_id" ref="a_expense"/>
<field model="account.account" name="default_credit_account_id" ref="a_expense"/>
@ -346,7 +343,6 @@
<field name="name">Expenses Credit Notes Journal - (test)</field>
<field name="code">TECNJ</field>
<field name="type">purchase_refund</field>
<field name="view_id" ref="account_sp_refund_journal_view"/>
<field name="sequence_id" ref="sequence_refund_purchase_journal"/>
<field model="account.account" name="default_debit_account_id" ref="a_expense"/>
<field model="account.account" name="default_credit_account_id" ref="a_expense"/>
@ -358,7 +354,6 @@
<field name="name">Bank Journal - (test)</field>
<field name="code">TBNK</field>
<field name="type">bank</field>
<field name="view_id" ref="account_journal_bank_view"/>
<field name="sequence_id" ref="sequence_bank_journal"/>
<field model="account.account" name="default_debit_account_id" ref="bnk"/>
<field model="account.account" name="default_credit_account_id" ref="bnk"/>
@ -369,7 +364,6 @@
<field name="name">Checks Journal - (test)</field>
<field name="code">TCHK</field>
<field name="type">bank</field>
<field name="view_id" ref="account_journal_bank_view"/>
<field name="sequence_id" ref="sequence_check_journal"/>
<field model="account.account" name="default_debit_account_id" ref="cash"/>
<field model="account.account" name="default_credit_account_id" ref="cash"/>
@ -390,7 +384,6 @@
that test OpenERP arrive directly in the touchscreen UI.
-->
<field name="cash_control" eval="False"/>
<field name="view_id" ref="account_journal_bank_view"/>
<field name="sequence_id" ref="sequence_cash_journal"/>
<field model="account.account" name="default_debit_account_id" ref="cash"/>
<field model="account.account" name="default_credit_account_id" ref="cash"/>
@ -401,7 +394,6 @@
<field name="name">Miscellaneous Journal - (test)</field>
<field name="code">TMIS</field>
<field name="type">general</field>
<field name="view_id" ref="account_journal_view"/>
<field name="sequence_id" ref="sequence_miscellaneous_journal"/>
<field name="analytic_journal_id" ref="sit"/>
<field name="user_id" ref="base.user_root"/>
@ -410,7 +402,6 @@
<field name="name">Opening Entries Journal - (test)</field>
<field name="code">TOEJ</field>
<field name="type">situation</field>
<field name="view_id" ref="account_journal_view"/>
<field name="sequence_id" ref="sequence_opening_journal"/>
<field model="account.account" name="default_debit_account_id" ref="o_income"/>
<field model="account.account" name="default_credit_account_id" ref="o_expense"/>
@ -422,7 +413,6 @@
<field name="name">USD Bank Journal - (test)</field>
<field name="code">TUBK</field>
<field name="type">bank</field>
<field name="view_id" ref="account_journal_bank_view"/>
<field model="account.account" name="default_debit_account_id" ref="usd_bnk"/>
<field model="account.account" name="default_credit_account_id" ref="usd_bnk"/>
<field name="currency" ref="base.USD"/>

View File

@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2011 OpenERP S.A. <http://openerp.com>
# Copyright (c) 2011-2012 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
@ -19,9 +19,8 @@
#
##############################################################################
from osv import fields, osv, orm
from openerp.osv import osv
from edi import EDIMixin
from edi.models import edi
INVOICE_LINE_EDI_STRUCT = {
'name': True,
@ -71,16 +70,6 @@ INVOICE_EDI_STRUCT = {
class account_invoice(osv.osv, EDIMixin):
_inherit = 'account.invoice'
def action_invoice_sent(self, cr, uid, ids, context=None):
""""Override this method to add a link to mail"""
if context is None:
context = {}
invoice_objs = self.browse(cr, uid, ids, context=context)
edi_token = self.pool.get('edi.document').export_edi(cr, uid, invoice_objs, context = context)[0]
web_root_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
ctx = dict(context, edi_web_url_view=edi.EDI_VIEW_WEB_URL % (web_root_url, cr.dbname, edi_token))
return super(account_invoice, self).action_invoice_sent(cr, uid, ids, context=ctx)
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)
@ -111,8 +100,8 @@ class account_invoice(osv.osv, EDIMixin):
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)
res_partner = self.pool.get('res.partner')
partner = res_partner.browse(cr, uid, partner_id, context=context)
if invoice_type in ('out_invoice', 'out_refund'):
invoice_account = partner.property_account_receivable
else:
@ -136,31 +125,30 @@ class account_invoice(osv.osv, EDIMixin):
self._edi_requires_attributes(('company_id','company_address','type'), edi_document)
res_partner = self.pool.get('res.partner')
src_company_id, src_company_name = edi_document.pop('company_id')
xid, company_name = edi_document.pop('company_id')
# Retrofit address info into a unified partner info (changed in v7 - used to keep them separate)
company_address_edi = edi_document.pop('company_address')
company_address_edi['name'] = company_name
company_address_edi['is_company'] = True
company_address_edi['__import_model'] = 'res.partner'
company_address_edi['__id'] = xid # override address ID, as of v7 they should be the same anyway
if company_address_edi.get('logo'):
company_address_edi['image'] = company_address_edi.pop('logo')
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})
# imported company_address = new partner address
address_info = edi_document.pop('company_address')
if 'name' not in address_info:
address_info['name'] = src_company_name
address_info['type'] = 'invoice'
address_info.update(partner_value)
address_id = res_partner.edi_import(cr, uid, address_info, context=context)
if invoice_type.startswith('out_'):
company_address_edi['customer'] = True
else:
company_address_edi['supplier'] = True
partner_id = res_partner.edi_import(cr, uid, company_address_edi, context=context)
# modify edi_document to refer to new partner
partner_address = res_partner.browse(cr, uid, address_id, context=context)
address_edi_m2o = self.edi_m2o(cr, uid, partner_address, context=context)
edi_document['partner_id'] = address_edi_m2o
edi_document.pop('partner_address', False) # ignored
return address_id
partner = res_partner.browse(cr, uid, partner_id, context=context)
partner_edi_m2o = self.edi_m2o(cr, uid, partner, context=context)
edi_document['partner_id'] = partner_edi_m2o
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
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
@ -200,7 +188,7 @@ class account_invoice(osv.osv, EDIMixin):
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
# import company as a new partner
partner_id = self._edi_import_company(cr, uid, edi_document, context=context)
# Set Account

View File

@ -1,17 +1,6 @@
<?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>
@ -27,28 +16,25 @@
</data>
<!-- Mail template and workflow bindings are done in a NOUPDATE block
<!-- Mail template are declared 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="name">Invoice - Send by Email</field>
<field name="email_from">${object.user_id.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.partner_id.email or ''}</field>
<field name="email_recipients">${object.partner_id.id}</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="auto_delete" eval="True"/>
<field name="report_template" ref="account_invoices"/>
<field name="report_name">Invoice_${(object.number or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''}</field>
<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.partner_id.name and ' ' or ''}${object.partner_id.name or ''},</p>
<p>A new invoice is available for ${object.partner_id.name}: </p>
<p>A new invoice is available for you: </p>
<p style="border-left: 1px solid #8e0000; margin-left: 30px;">
&nbsp;&nbsp;<strong>REFERENCES</strong><br />
@ -58,21 +44,17 @@
% if object.origin:
&nbsp;&nbsp;Order reference: ${object.origin}<br />
% endif
% if object.user_id:
&nbsp;&nbsp;Your contact: <a href="mailto:${object.user_id.email or ''}?subject=Invoice%20${object.number}">${object.user_id.name}</a>
% endif
</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))
inv_amount = quote(str(object.residual))
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" % \

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

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

View File

@ -209,15 +209,22 @@ class res_partner(osv.osv):
relation='account.fiscal.position',
string="Fiscal Position",
view_load=True,
help="The fiscal position will determine taxes and the accounts used for the partner.",
help="The fiscal position will determine taxes and accounts used for the partner.",
),
'property_payment_term': fields.property(
'account.payment.term',
type='many2one',
relation='account.payment.term',
string ='Payment Term',
string ='Customer Payment Term',
view_load=True,
help="This payment term will be used instead of the default one for the current partner"),
help="This payment term will be used instead of the default one for sale orders and customer invoices"),
'property_supplier_payment_term': fields.property(
'account.payment.term',
type='many2one',
relation='account.payment.term',
string ='Supplier Payment Term',
view_load=True,
help="This payment term will be used instead of the default one for purchase orders and supplier invoices"),
'ref_companies': fields.one2many('res.company', 'partner_id',
'Companies that refers to partner'),
'last_reconciliation_date': fields.datetime('Latest Reconciliation Date', help='Date on which the partner accounting entries were fully reconciled last time. It differs from the date of the last reconciliation made for this partner, as here we depict the fact that nothing more was to be reconciled at this date. This can be achieved in 2 ways: either the last debit/credit entry was reconciled, either the user pressed the button "Fully Reconciled" in the manual reconciliation process')

View File

@ -6,7 +6,7 @@
<field name="name">account.fiscal.position.form</field>
<field name="model">account.fiscal.position</field>
<field name="arch" type="xml">
<form string="Fiscal Position">
<form string="Fiscal Position" version="7.0">
<group col="4">
<field name="name"/>
<field name="active"/>
@ -89,6 +89,7 @@
</group>
<group>
<field name="property_account_payable" groups="account.group_account_invoice"/>
<field name="property_supplier_payment_term" widget="selection"/>
<field name="debit"/>
</group>
</group>
@ -114,7 +115,7 @@
context="{'search_default_partner_id':[active_id], 'default_partner_id': active_id}"
src_model="res.partner"
view_type="form"
view_mode="tree,form,calendar"/>
view_mode="tree,form"/>
</data>
</openerp>

View File

@ -30,14 +30,14 @@ class product_category(osv.osv):
relation='account.account',
string="Income Account",
view_load=True,
help="This account will be used for invoices to value sales for the current product category"),
help="This account will be used for invoices to value sales."),
'property_account_expense_categ': fields.property(
'account.account',
'account.account',
type='many2one',
relation='account.account',
string="Expense Account",
view_load=True,
help="This account will be used for invoices to value expenses for the current product category"),
help="This account will be used for invoices to value expenses."),
}
product_category()
@ -60,14 +60,14 @@ class product_template(osv.osv):
relation='account.account',
string="Income Account",
view_load=True,
help="This account will be used for invoices instead of the default one to value sales for the current product"),
help="This account will be used for invoices instead of the default one to value sales for the current product."),
'property_account_expense': fields.property(
'account.account',
type='many2one',
relation='account.account',
string="Expense Account",
view_load=True,
help="This account will be used for invoices instead of the default one to value expenses for the current product"),
help="This account will be used for invoices instead of the default one to value expenses for the current product."),
}
product_template()

View File

@ -7,14 +7,14 @@
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Accounting" groups="account.group_account_user">
<page string="Accounting" groups="account.group_account_invoice">
<group name="properties">
<group>
<field name="property_account_income" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('sale_ok','=',0)]}"/>
<field name="property_account_income" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" groups="account.group_account_user"/>
<field name="taxes_id" colspan="2" attrs="{'readonly':[('sale_ok','=',0)]}" widget="many2many_tags"/>
</group>
<group>
<field name="property_account_expense" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" />
<field name="property_account_expense" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" groups="account.group_account_user"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags"/>
</group>
</group>
@ -49,9 +49,11 @@
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="/form/sheet//group[@name='account_property']" position="inside">
<field name="property_account_income_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="property_account_expense_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<xpath expr="//group[@name='parent']" position="inside">
<group name="account_property" string="Account Properties" colspan="2">
<field name="property_account_income_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="property_account_expense_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
</group>
</xpath>
</data>
</field>

View File

@ -94,8 +94,8 @@
<field name="state">open</field>
<field name="partner_id" ref="base.res_partner_19"/>
</record>
<record id="analytic_magasin_bml_1" model="account.analytic.account">
<field name="name">Magasin BML 1</field>
<record id="analytic_millennium_industries" model="account.analytic.account">
<field name="name">Millennium Industries</field>
<field name="parent_id" ref="analytic_integration"/>
<field name="type">normal</field>
<field name="partner_id" ref="base.res_partner_15"/>
@ -121,8 +121,8 @@
<field name="parent_id" ref="analytic_customers"/>
<field name="partner_id" ref="base.res_partner_1"/>
</record>
<record id="analytic_distripc" model="account.analytic.account">
<field name="name">DistriPC</field>
<record id="analytic_deltapc" model="account.analytic.account">
<field name="name">Delta PC</field>
<field name="parent_id" ref="analytic_customers"/>
<field name="type">normal</field>
<field name="partner_id" ref="base.res_partner_4"/>
@ -145,8 +145,8 @@
<field name="partner_id" ref="base.res_partner_17"/>
<field name="state">open</field>
</record>
<record id="analytic_leclerc" model="account.analytic.account">
<field name="name">Leclerc</field>
<record id="analytic_luminous_technologies" model="account.analytic.account">
<field name="name">Luminous Technologies</field>
<field eval="time.strftime('%Y-04-24')" name="date_start"/>
<field eval="str(time.localtime()[0] + 1) + '-04-24'" name="date"/>
<field name="type">normal</field>
@ -161,8 +161,8 @@
<field name="parent_id" ref="analytic_partners"/>
<field name="partner_id" ref="base.res_partner_12"/>
</record>
<record id="analytic_tiny_at_work" model="account.analytic.account">
<field name="name">OpenERP SA AT Work</field>
<record id="analytic_think_big_systems" model="account.analytic.account">
<field name="name">Think Big Systems</field>
<field name="type">normal</field>
<field name="parent_id" ref="analytic_partners"/>
<field name="partner_id" ref="base.res_partner_18"/>

View File

@ -35,7 +35,6 @@
<field name="partner_id"/>
<field name="user_id"/>
<group expand="0" string="Group By...">
<filter string="Manager" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Associated Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="Parent Account" icon="terp-folder-green" domain="[]" context="{'group_by':'parent_id'}"/>
<filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}" groups="base.group_no_one"/>
@ -144,8 +143,8 @@
<field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)"/>
<label for="unit_amount"/>
<div>
<field name="unit_amount" class="oe_inline"/>
<field name="product_uom_id" class="oe_inline"/>
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" class="oe_inline"/>
<field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" class="oe_inline"/>
</div>
</group>
<group string="General Accounting">

View File

@ -10,7 +10,7 @@
<group col="4">
<field name="date1"/>
<field name="date2"/>
<field name="analytic_account_journal_id" widget="many2many_tags" class="oe_inline" required="1"/>
<field name="analytic_account_journal_id" widget="many2many_tags" class="oe_inline" required="1" colspan="4"/>
</group>
<footer>
<button name="check_report" string="Print" type="object" class="oe_highlight"/>

View File

@ -103,6 +103,6 @@ class journal_print(report_sxw.rml_parse, common_report_header):
return True
return data['form']['amount_currency']
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/account_central_journal.rml', parser=journal_print, header='internal')
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/account_central_journal.rml', parser=journal_print, header='external')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -170,12 +170,12 @@
<tr>
<td><para style="terp_tblheader_General_Centre">Chart of Accounts</para></td>
<td><para style="terp_tblheader_General_Centre">Fiscal Year</para></td>
<td><para style="terp_tblheader_General_Centre">Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]]</para></td>
<td><para style="terp_tblheader_General_Centre">Filter By [[ get_filter(data)!='No Filters' and get_filter(data) ]]</para></td>
</tr>
<tr>
<td><para style="terp_default_Centre_8">[[ get_account(data) or removeParentNode('para') ]]</para></td>
<td><para style="terp_default_Centre_8">[[ get_fiscalyear(data) or '' ]]</para></td>
<td><para style="terp_default_Centre_8">[[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] </para>
<td><para style="terp_default_Centre_8">[[ get_filter(data)=='No Filters' and get_filter(data) or removeParentNode('para') ]] </para>
<blockTable colWidths="60.0,60.0" style="Table3">[[ get_filter(data)=='Date' or removeParentNode('blockTable') ]]
<tr>
<td><para style="terp_tblheader_General_Centre">Start Date</para></td>

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