diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py
index e1b9078ec3f..86166ec0125 100644
--- a/addons/account/__openerp__.py
+++ b/addons/account/__openerp__.py
@@ -19,11 +19,11 @@
#
##############################################################################
{
- "name" : "eInvoicing",
- "version" : "1.1",
- "author" : "OpenERP SA",
- "category": 'Accounting & Finance',
- "description": """
+ 'name' : 'eInvoicing',
+ 'version' : '1.1',
+ 'author' : 'OpenERP SA',
+ 'category' : 'Accounting & Finance',
+ 'description' : """
Accounting and Financial Management.
====================================
@@ -44,14 +44,13 @@ Creates a dashboard for accountants that includes:
* Company Analysis
* Graph of Treasury
-The processes like maintaining of general ledger is done through the defined financial Journals (entry move line orgrouping is maintained through journal) for a particular
-financial year and for preparation of vouchers there is a module named account_voucher.
+The processes like maintaining of general ledger is done through the defined financial Journals (entry move line orgrouping is maintained through journal)
+for a particular financial year and for preparation of vouchers there is a module named account_voucher.
""",
'website': 'http://www.openerp.com',
'images' : ['images/accounts.jpeg','images/bank_statement.jpeg','images/cash_register.jpeg','images/chart_of_accounts.jpeg','images/customer_invoice.jpeg','images/journal_entries.jpeg'],
- 'init_xml': [],
- "depends" : ["base_setup", "product", "analytic", "process", "board", "edi"],
- 'update_xml': [
+ 'depends' : ['base_setup', 'product', 'analytic', 'process', 'board', 'edi'],
+ 'data': [
'security/account_security.xml',
'security/ir.model.access.csv',
'account_menuitem.xml',
@@ -122,12 +121,12 @@ financial year and for preparation of vouchers there is a module named account_v
'ir_sequence_view.xml',
'company_view.xml',
'board_account_view.xml',
- "edi/invoice_action_data.xml",
- "account_bank_view.xml",
- "res_config_view.xml",
- "account_pre_install.yml"
+ 'edi/invoice_action_data.xml',
+ 'account_bank_view.xml',
+ 'res_config_view.xml',
+ 'account_pre_install.yml'
],
- 'demo_xml': [
+ 'demo': [
'demo/account_demo.xml',
'project/project_demo.xml',
'project/analytic_account_demo.xml',
diff --git a/addons/account/account.py b/addons/account/account.py
index fa30b20f2ca..7ec3bcde2c8 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -30,6 +30,8 @@ from osv import fields, osv
import decimal_precision as dp
from tools.translate import _
from tools.float_utils import float_round
+from openerp import SUPERUSER_ID
+
_logger = logging.getLogger(__name__)
@@ -109,7 +111,7 @@ class account_payment_term_line(osv.osv):
'days': fields.integer('Number of Days', required=True, help="Number of days to add before computation of the day of month." \
"If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."),
'days2': fields.integer('Day of the Month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."),
- 'payment_id': fields.many2one('account.payment.term', 'Payment Term', required=True, select=True),
+ 'payment_id': fields.many2one('account.payment.term', 'Payment Term', required=True, select=True, ondelete='cascade'),
}
_defaults = {
'value': 'balance',
@@ -582,6 +584,8 @@ class account_account(osv.osv):
def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
+ if isinstance(ids, (int, long)):
+ ids = [ids]
reads = self.read(cr, uid, ids, ['name', 'code'], context=context)
res = []
for record in reads:
@@ -744,9 +748,11 @@ class account_journal(osv.osv):
'profit_account_id' : fields.many2one('account.account', 'Profit Account'),
'loss_account_id' : fields.many2one('account.account', 'Loss Account'),
'internal_account_id' : fields.many2one('account.account', 'Internal Transfers Account', select=1),
+ 'cash_control' : fields.boolean('Cash Control', help='If you want the journal should be control at opening/closing, check this option'),
}
_defaults = {
+ 'cash_control' : False,
'with_last_closing_balance' : False,
'user_id': lambda self, cr, uid, context: uid,
'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
@@ -815,7 +821,7 @@ class account_journal(osv.osv):
if not 'sequence_id' in vals or not vals['sequence_id']:
# if we have the right to create a journal, we should be able to
# create it's sequence.
- vals.update({'sequence_id': self.create_sequence(cr, 1, vals, context)})
+ vals.update({'sequence_id': self.create_sequence(cr, SUPERUSER_ID, vals, context)})
return super(account_journal, self).create(cr, uid, vals, context)
def name_get(self, cr, user, ids, context=None):
@@ -1369,7 +1375,7 @@ class account_move(osv.osv):
balance = 0.0
for line in line_ids:
if line[2]:
- balance += (line[2]['debit'] or 0.00)- (line[2]['credit'] or 0.00)
+ 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):
@@ -1854,7 +1860,7 @@ class account_tax(osv.osv):
def get_precision_tax():
def change_digit_tax(cr):
- res = pooler.get_pool(cr.dbname).get('decimal.precision').precision_get(cr, 1, 'Account')
+ res = pooler.get_pool(cr.dbname).get('decimal.precision').precision_get(cr, SUPERUSER_ID, 'Account')
return (16, res+2)
return change_digit_tax
@@ -2993,6 +2999,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
_columns = {
'company_id':fields.many2one('res.company', 'Company', required=True),
+ 'currency_id': fields.many2one('res.currency', 'Currency', help="Currency as per company's country."),
'only_one_chart_template': fields.boolean('Only One Chart Template Available'),
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Cash and Banks', required=True),
@@ -3003,6 +3010,13 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'purchase_tax_rate': fields.float('Purchase Tax(%)'),
'complete_tax_set': fields.boolean('Complete Set of Taxes', help='This boolean helps you to choose if you want to propose to the user to encode the sales and purchase rates or use the usual m2o fields. This last choice assumes that the set of tax defined for the chosen template is complete'),
}
+
+ def onchange_company_id(self, cr, uid, ids, company_id, context=None):
+ currency_id = False
+ if company_id:
+ currency_id = self.pool.get('res.company').browse(cr, uid, company_id, context=context).currency_id.id
+ return {'value': {'currency_id': currency_id}}
+
def onchange_tax_rate(self, cr, uid, ids, rate=False, context=None):
return {'value': {'purchase_tax_rate': rate or False}}
@@ -3033,6 +3047,13 @@ class wizard_multi_charts_accounts(osv.osv_memory):
res.update({'bank_accounts_id': [{'acc_name': _('Cash'), 'account_type': 'cash'},{'acc_name': _('Bank'), 'account_type': 'bank'}]})
if 'company_id' in fields:
res.update({'company_id': self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0].company_id.id})
+ if 'currency_id' in fields:
+ company_id = res.get('company_id') or False
+ if company_id:
+ company_obj = self.pool.get('res.company')
+ country_id = company_obj.browse(cr, uid, company_id, context=context).country_id.id
+ currency_id = company_obj.on_change_country(cr, uid, company_id, country_id, context=context)['value']['currency_id']
+ res.update({'currency_id': currency_id})
ids = self.pool.get('account.chart.template').search(cr, uid, [('visible', '=', True)], context=context)
if ids:
@@ -3337,19 +3358,18 @@ class wizard_multi_charts_accounts(osv.osv_memory):
ir_values_obj = self.pool.get('ir.values')
obj_wizard = self.browse(cr, uid, ids[0])
company_id = obj_wizard.company_id.id
+ self.pool.get('res.company').write(cr, uid, [company_id], {'currency_id': obj_wizard.currency_id.id})
# If the floats for sale/purchase rates have been filled, create templates from them
self._create_tax_templates_from_rates(cr, uid, obj_wizard, company_id, context=context)
# Install all the templates objects and generate the real objects
acc_template_ref, taxes_ref, tax_code_ref = self._install_template(cr, uid, obj_wizard.chart_template_id.id, company_id, code_digits=obj_wizard.code_digits, obj_wizard=obj_wizard, context=context)
- # write values of default taxes for product
+ # write values of default taxes for product as super user
if obj_wizard.sale_tax and taxes_ref:
- ir_values_obj.set(cr, uid, key='default', key2=False, name="taxes_id", company=company_id,
- models =[('product.product',False)], value=[taxes_ref[obj_wizard.sale_tax.id]])
+ ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.product', "taxes_id", [taxes_ref[obj_wizard.sale_tax.id]], for_all_users=True, company_id=company_id)
if obj_wizard.purchase_tax and taxes_ref:
- ir_values_obj.set(cr, uid, key='default', key2=False, name="supplier_taxes_id", company=company_id,
- models =[('product.product',False)], value=[taxes_ref[obj_wizard.purchase_tax.id]])
+ ir_values_obj.set_default(cr, SUPERUSER_ID, 'product.product', "supplier_taxes_id", [taxes_ref[obj_wizard.purchase_tax.id]], for_all_users=True, company_id=company_id)
# Create Bank journals
self._create_bank_journals_from_o2m(cr, uid, obj_wizard, company_id, acc_template_ref, context=context)
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index 8df291a98d1..095d461ff3b 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -430,7 +430,7 @@ class account_bank_statement(osv.osv):
'name': st_number,
'balance_end_real': st.balance_end
}, context=context)
- self.message_append_note(cr, uid, [st.id], body=_('Statement %s is confirmed, journal items are created.') % (st_number,), context=context)
+ self.message_post(cr, uid, [st.id], body=_('Statement %s confirmed, journal items were created.') % (st_number,), context=context)
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
def button_cancel(self, cr, uid, ids, context=None):
diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py
index 9af0dcf60f4..17fa05d5f24 100644
--- a/addons/account/account_cash_statement.py
+++ b/addons/account/account_cash_statement.py
@@ -194,12 +194,27 @@ class account_cash_statement(osv.osv):
journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context=context)
if journal and (journal.type == 'cash') and not vals.get('details_ids'):
vals['details_ids'] = []
+
+ last_pieces = None
+
+ if journal.with_last_closing_balance == True:
+ domain = [('journal_id', '=', journal.id),
+ ('state', '=', 'confirm')]
+ last_bank_statement_ids = self.search(cr, uid, domain, limit=1, order='create_date desc', context=context)
+ if last_bank_statement_ids:
+ last_bank_statement = self.browse(cr, uid, last_bank_statement_ids[0], context=context)
+
+ last_pieces = dict(
+ (line.pieces, line.number_closing) for line in last_bank_statement.details_ids
+ )
+
for value in journal.cashbox_line_ids:
nested_values = {
'number_closing' : 0,
- 'number_opening' : 0,
+ 'number_opening' : last_pieces.get(value.pieces, 0) if isinstance(last_pieces, dict) else 0,
'pieces' : value.pieces
}
+
vals['details_ids'].append([0, False, nested_values])
res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context)
diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py
index 012bde42eff..15027b7a8f6 100644
--- a/addons/account/account_invoice.py
+++ b/addons/account/account_invoice.py
@@ -1045,7 +1045,7 @@ class account_invoice(osv.osv):
if obj_inv.type in ('out_invoice', 'out_refund'):
ctx = self.get_log_context(cr, uid, context=ctx)
message = _("Invoice '%s' is validated.") % name
- self.message_append_note(cr, uid, [inv_id], body=message, context=context)
+ self.message_post(cr, uid, [inv_id], body=message, context=context)
return True
def action_cancel(self, cr, uid, ids, *args):
@@ -1127,7 +1127,7 @@ class account_invoice(osv.osv):
return map(lambda x: (0,0,x), lines)
def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
- invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id'])
+ invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id', 'company_id'])
obj_invoice_line = self.pool.get('account.invoice.line')
obj_invoice_tax = self.pool.get('account.invoice.tax')
obj_journal = self.pool.get('account.journal')
@@ -1175,7 +1175,7 @@ class account_invoice(osv.osv):
'name': description,
})
# take the id part of the tuple returned for many2one fields
- for field in ('partner_id',
+ for field in ('partner_id', 'company_id',
'account_id', 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice
@@ -1275,7 +1275,7 @@ class account_invoice(osv.osv):
# TODO: use currency's formatting function
msg = _("Invoice '%s' is paid partially: %s%s of %s%s (%s%s remaining).") % \
(name, pay_amount, code, invoice.amount_total, code, total, code)
- self.message_append_note(cr, uid, [inv_id], body=msg, context=context)
+ self.message_post(cr, uid, [inv_id], body=msg, context=context)
self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context)
# Update the stored value (fields.function), so we write to trigger recompute
@@ -1288,24 +1288,25 @@ class account_invoice(osv.osv):
def _get_document_type(self, type):
type_dict = {
- 'out_invoice': 'Customer invoice',
- 'in_invoice': 'Supplier invoice',
- 'out_refund': 'Customer Refund',
- 'in_refund': 'Supplier Refund',
+ # Translation markers will have no effect at runtime, only used to properly flag export
+ 'out_invoice': _('Customer invoice'),
+ 'in_invoice': _('Supplier invoice'),
+ 'out_refund': _('Customer Refund'),
+ 'in_refund': _('Supplier Refund'),
}
return type_dict.get(type, 'Invoice')
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
- self.message_append_note(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), context=context)
+ self.message_post(cr, uid, [obj.id], body=_("%s created.") % (_(self._get_document_type(obj.type))), context=context)
def confirm_paid_send_note(self, cr, uid, ids, context=None):
- for obj in self.browse(cr, uid, ids, context=context):
- self.message_append_note(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), context=context)
+ for obj in self.browse(cr, uid, ids, context=context):
+ self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (_(self._get_document_type(obj.type))), context=context)
def invoice_cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
- self.message_append_note(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), context=context)
+ self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (_(self._get_document_type(obj.type))), context=context)
account_invoice()
@@ -1361,10 +1362,16 @@ class account_invoice_line(osv.osv):
'company_id': fields.related('invoice_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
'partner_id': fields.related('invoice_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True)
}
+
+ def _default_account_id(self, cr, uid, ids, context=None):
+ prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context)
+ return prop and prop.id or False
+
_defaults = {
'quantity': 1,
'discount': 0.0,
'price_unit': _price_unit_default,
+ 'account_id': _default_account_id,
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
@@ -1473,10 +1480,11 @@ class account_invoice_line(osv.osv):
prod = self.pool.get('product.product').browse(cr, uid, product, context=context)
prod_uom = self.pool.get('product.uom').browse(cr, uid, uom, context=context)
if prod.uom_id.category_id.id != prod_uom.category_id.id:
- warning = {
+ warning = {
'title': _('Warning!'),
'message': _('The selected unit of measure is not compatible with the unit of measure of the product.')
- }
+ }
+ res['value'].update({'uos_id': prod.uom_id.id})
return {'value': res['value'], 'warning': warning}
return res
diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml
index 143c5514141..610485ec3a0 100644
--- a/addons/account/account_invoice_view.xml
+++ b/addons/account/account_invoice_view.xml
@@ -191,17 +191,23 @@
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-