diff --git a/addons/account/account.py b/addons/account/account.py index 174863831fb..333f4fe0f86 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -100,9 +100,9 @@ class AccountAccount(models.Model): help="Forces all moves for this account to have this secondary currency.") code = fields.Char(size=64, required=True, index=True) deprecated = fields.Boolean(index=True, default=False) - user_type = fields.Many2one('account.account.type', string='Type', required=True, + user_type_id = fields.Many2one('account.account.type', string='Type', required=True, oldname="user_type", help="Account Type is used for information purpose, to generate country-specific legal reports, and set the rules to close a fiscal year and generate opening entries.") - internal_type = fields.Selection(related='user_type.type', store=True) + internal_type = fields.Selection(related='user_type_id.type', store=True) #has_unreconciled_entries = fields.Boolean(compute='_compute_has_unreconciled_entries', # help="The account has at least one unreconciled debit and credit since last time the invoices & payments matching was performed.") last_time_entries_checked = fields.Datetime(string='Latest Invoices & Payments Matching Date', readonly=True, copy=False, @@ -228,11 +228,11 @@ class AccountJournal(models.Model): analytic_journal_id = fields.Many2one('account.analytic.journal', string='Analytic Journal', help="Journal for analytic entries") refund_sequence = fields.Boolean(string='Dedicated Refund Sequence', help="Check this box if you don't want to share the same sequence for invoices and refunds made from this journal") - inbound_payment_methods = fields.Many2many('account.payment.method', 'account_journal_inbound_payment_method_rel', 'journal_id', 'inbound_payment_method', + inbound_payment_method_ids = fields.Many2many('account.payment.method', 'account_journal_inbound_payment_method_rel', 'journal_id', 'inbound_payment_method', domain=[('payment_type', '=', 'inbound')], string='Inbound Payment Methods', default=lambda self: self._default_inbound_payment_methods(), help="Means of payment for collecting money. Odoo modules offer various payments handling facilities, " "but you can always use the 'Manual' payment method in order to manage payments outside of the software.") - outbound_payment_methods = fields.Many2many('account.payment.method', 'account_journal_outbound_payment_method_rel', 'journal_id', 'outbound_payment_method', + outbound_payment_method_ids = fields.Many2many('account.payment.method', 'account_journal_outbound_payment_method_rel', 'journal_id', 'outbound_payment_method', domain=[('payment_type', '=', 'outbound')], string='Outbound Payment Methods', default=lambda self: self._default_outbound_payment_methods(), help="Means of payment for sending money. Odoo modules offer various payments handling facilities, " "but you can always use the 'Manual' payment method in order to manage payments outside of the software.") @@ -342,7 +342,7 @@ class AccountJournal(models.Model): 'name': name, 'currency_id': currency_id or False, 'code': new_code, - 'user_type': liquidity_type and liquidity_type.id or False, + 'user_type_id': liquidity_type and liquidity_type.id or False, 'company_id': company.id, } @@ -409,11 +409,11 @@ class AccountJournal(models.Model): return res @api.multi - @api.depends('inbound_payment_methods', 'outbound_payment_methods') + @api.depends('inbound_payment_method_ids', 'outbound_payment_method_ids') def _methods_compute(self): for journal in self: - journal.at_least_one_inbound = bool(len(self.inbound_payment_methods)) - journal.at_least_one_outbound = bool(len(self.outbound_payment_methods)) + journal.at_least_one_inbound = bool(len(self.inbound_payment_method_ids)) + journal.at_least_one_outbound = bool(len(self.outbound_payment_method_ids)) #---------------------------------------------------------- diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index bbc04f454d1..5b8faf5a428 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -49,17 +49,17 @@ class AccountAnalyticLine(models.Model): if not unit_obj or prod.uom_po_id.category_id.id != unit_obj.category_id.id: unit = prod.uom_po_id.id if j_id.type <> 'sale': - a = prod.property_account_expense.id + a = prod.property_account_expense_id.id if not a: - a = prod.categ_id.property_account_expense_categ.id + a = prod.categ_id.property_account_expense_categ_id.id if not a: raise UserError(_('There is no expense account defined ' \ 'for this product: "%s" (id:%d).') % \ (prod.name, prod.id,)) else: - a = prod.property_account_income.id + a = prod.property_account_income_id.id if not a: - a = prod.categ_id.property_account_income_categ.id + a = prod.categ_id.property_account_income_categ_id.id if not a: raise UserError(_('There is no income account defined ' \ 'for this product: "%s" (id:%d).') % \ @@ -117,13 +117,13 @@ class AccountAnalyticLine(models.Model): if not self.product_uom_id or self.product_id.uom_po_id.category_id.id != self.product_uom_id.category_id.id: unit = self.product_id.uom_po_id.id if journal_id.type != 'sale': - account = self.product_id.property_account_expense.id or self.product_id.categ_id.property_account_expense_categ.id + account = self.product_id.property_account_expense_id.id or self.product_id.categ_id.property_account_expense_categ_id.id if not account: raise UserError(_('There is no expense account defined ' \ 'for this product: "%s" (id:%d).') % \ (self.product_id.name, self.product_id.id,)) else: - account = self.product_id.property_account_income.id or self.product_id.categ_id.property_account_income_categ.id + account = self.product_id.property_account_income_id.id or self.product_id.categ_id.property_account_income_categ_id.id if not account: raise UserError(_('There is no income account defined ' \ 'for this product: "%s" (id:%d).') % \ @@ -156,4 +156,4 @@ class AccountAnalyticLine(models.Model): if context.get('account_id', False): analytic_account = self.env['account.analytic.account'].search([('id', '=', context['account_id'])], limit=1) header = _('Entries: ') + (analytic_account.name or '') - return header \ No newline at end of file + return header diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index c7c6c120804..3ca812c7590 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -448,9 +448,9 @@ class AccountBankStatementLine(models.Model): } if self.partner_id: if amount > 0: - data['open_balance_account_id'] = self.partner_id.property_account_receivable.id + data['open_balance_account_id'] = self.partner_id.property_account_receivable_id.id else: - data['open_balance_account_id'] = self.partner_id.property_account_payable.id + data['open_balance_account_id'] = self.partner_id.property_account_payable_id.id return data @@ -557,7 +557,7 @@ class AccountBankStatementLine(models.Model): # Select move lines until their total amount is greater than the statement line amount domain = [('reconciled', '=', False)] - domain += [('account_id.user_type.type', '=', amount > 0 and 'receivable' or 'payable')] # Make sure we can't mix receivable and payable + domain += [('account_id.user_type_id.type', '=', amount > 0 and 'receivable' or 'payable')] # Make sure we can't mix receivable and payable domain += amount_domain_maker('<', amount) # Will also enforce > 0 mv_lines = self.get_move_lines_for_reconciliation(excluded_ids=excluded_ids, limit=5, additional_domain=domain) st_line_currency = self.currency_id or self.journal_id.currency_id or self.journal_id.company_id.currency_id diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index f4b855b4aad..06471732d88 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -427,16 +427,16 @@ class AccountInvoice(models.Model): type = self.type if p: partner_id = p.id - rec_account = p.property_account_receivable - pay_account = p.property_account_payable + rec_account = p.property_account_receivable_id + pay_account = p.property_account_payable_id if 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: + if p.property_account_receivable_id.company_id and \ + p.property_account_receivable_id.company_id.id != company_id and \ + p.property_account_payable_id.company_id and \ + p.property_account_payable_id.company_id.id != company_id: prop = self.env['ir.property'] - rec_dom = [('name', '=', 'property_account_receivable'), ('company_id', '=', company_id)] - pay_dom = [('name', '=', 'property_account_payable'), ('company_id', '=', company_id)] + rec_dom = [('name', '=', 'property_account_receivable_id'), ('company_id', '=', company_id)] + pay_dom = [('name', '=', 'property_account_payable_id'), ('company_id', '=', company_id)] res_dom = [('res_id', '=', 'res.partner,%s' % partner_id)] rec_prop = prop.search(rec_dom + res_dom) or prop.search(rec_dom) pay_prop = prop.search(pay_dom + res_dom) or prop.search(pay_dom) @@ -449,11 +449,11 @@ class AccountInvoice(models.Model): if type in ('out_invoice', 'out_refund'): account_id = rec_account.id - payment_term_id = p.property_payment_term.id + payment_term_id = p.property_payment_term_id.id else: account_id = pay_account.id - payment_term_id = p.property_supplier_payment_term.id - fiscal_position = p.property_account_position.id + payment_term_id = p.property_supplier_payment_term_id.id + fiscal_position = p.property_account_position_id.id bank_id = p.bank_ids and p.bank_ids.ids[0] or False self.account_id = account_id self.payment_term_id = payment_term_id @@ -596,10 +596,10 @@ class AccountInvoice(models.Model): 'uos_id': line.uos_id.id, 'account_analytic_id': line.account_analytic_id.id, 'tax_ids': tax_ids, - 'invoice': self.id, + 'invoice_id': self.id, } if line['account_analytic_id']: - move_line_dict['analytic_lines'] = [(0, 0, line._get_analytic_line())] + move_line_dict['analytic_line_ids'] = [(0, 0, line._get_analytic_line())] res.append(move_line_dict) return res @@ -642,7 +642,7 @@ class AccountInvoice(models.Model): am = line2[tmp]['debit'] - line2[tmp]['credit'] + (l['debit'] - l['credit']) line2[tmp]['debit'] = (am > 0) and am or 0.0 line2[tmp]['credit'] = (am < 0) and -am or 0.0 - line2[tmp]['analytic_lines'] += l['analytic_lines'] + line2[tmp]['analytic_line_ids'] += l['analytic_line_ids'] else: line2[tmp] = l line = [] @@ -707,7 +707,7 @@ class AccountInvoice(models.Model): 'date_maturity': t[0], 'amount_currency': diff_currency and amount_currency, 'currency_id': diff_currency and inv.currency_id.id, - 'invoice': inv.id + 'invoice_id': inv.id }) else: iml.append({ @@ -718,7 +718,7 @@ class AccountInvoice(models.Model): 'date_maturity': inv.date_due, 'amount_currency': diff_currency and total_currency, 'currency_id': diff_currency and inv.currency_id.id, - 'invoice': inv.id + 'invoice_id': inv.id }) part = self.env['res.partner']._find_accounting_partner(inv.partner_id) line = [(0, 0, self.line_get_convert(l, part.id)) for l in iml] @@ -737,7 +737,7 @@ class AccountInvoice(models.Model): } ctx['company_id'] = inv.company_id.id ctx['dont_create_taxes'] = True - ctx['invoice'] = inv.move_name and inv or False + ctx['invoice_id'] = inv.move_name and inv or False move = account_move.with_context(ctx).create(move_vals) # make the invoice point to that move vals = { @@ -764,14 +764,14 @@ class AccountInvoice(models.Model): 'debit': line['price'] > 0 and line['price'], 'credit': line['price'] < 0 and -line['price'], 'account_id': line['account_id'], - 'analytic_lines': line.get('analytic_lines', []), + 'analytic_line_ids': line.get('analytic_line_ids', []), 'amount_currency': line['price'] > 0 and abs(line.get('amount_currency', False)) or -abs(line.get('amount_currency', False)), 'currency_id': line.get('currency_id', False), 'quantity': line.get('quantity', 1.00), 'product_id': line.get('product_id', False), 'product_uom_id': line.get('uos_id', False), 'analytic_account_id': line.get('account_analytic_id', False), - 'invoice': line.get('invoice', False), + 'invoice_id': line.get('invoice_id', False), 'tax_ids': line.get('tax_ids', False), 'tax_line_id': line.get('tax_line_id', False), } @@ -914,10 +914,10 @@ class AccountInvoice(models.Model): payment_type = self.type in ('out_invoice', 'in_refund') and 'inbound' or 'outbound' if payment_type == 'inbound': payment_method = self.env.ref('account.account_payment_method_manual_in') - journal_payment_methods = pay_journal.inbound_payment_methods + journal_payment_methods = pay_journal.inbound_payment_method_ids else: payment_method = self.env.ref('account.account_payment_method_manual_out') - journal_payment_methods = pay_journal.outbound_payment_methods + journal_payment_methods = pay_journal.outbound_payment_method_ids if payment_method not in journal_payment_methods: raise UserError(_('No appropriate payment method enabled on journal %s') % pay_journal.name) @@ -930,9 +930,9 @@ class AccountInvoice(models.Model): 'partner_type': self.type in ('out_invoice', 'out_refund') and 'customer' or 'supplier', 'journal_id': pay_journal.id, 'payment_type': payment_type, - 'payment_method': payment_method.id, + 'payment_method_id': payment_method.id, 'payment_difference_handling': writeoff_acc and 'reconcile' or 'open', - 'writeoff_account': writeoff_acc and writeoff_acc.id or False, + 'writeoff_account_id': writeoff_acc and writeoff_acc.id or False, }) payment.post() diff --git a/addons/account/account_move.py b/addons/account/account_move.py index 8aeb37c75ba..4a7554c2f54 100644 --- a/addons/account/account_move.py +++ b/addons/account/account_move.py @@ -40,7 +40,7 @@ class AccountMove(models.Model): total += line.debit move.amount = total - @api.depends('line_ids.debit', 'line_ids.credit', 'line_ids.matched_debit_ids.amount', 'line_ids.matched_credit_ids.amount', 'line_ids.account_id.user_type.type') + @api.depends('line_ids.debit', 'line_ids.credit', 'line_ids.matched_debit_ids.amount', 'line_ids.matched_credit_ids.amount', 'line_ids.account_id.user_type_id.type') def _compute_matched_percentage(self): """Compute the percentage to apply for cash basis method. This value is relevant only for moves that involve journal items on receivable or payable accounts. @@ -49,7 +49,7 @@ class AccountMove(models.Model): total_amount = 0.0 total_reconciled = 0.0 for line in move.line_ids: - if line.account_id.user_type.type in ('receivable', 'payable'): + if line.account_id.user_type_id.type in ('receivable', 'payable'): amount = abs(line.debit - line.credit) total_amount += amount for partial_line in (line.matched_debit_ids + line.matched_credit_ids): @@ -334,7 +334,7 @@ class AccountMoveLine(models.Model): date_maturity = fields.Date(string='Due date', index=True, required=True, help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line.") date = fields.Date(related='move_id.date', string='Date', required=True, index=True, default=fields.Date.context_today, store=True, copy=False) - analytic_lines = fields.One2many('account.analytic.line', 'move_id', string='Analytic lines') + analytic_line_ids = fields.One2many('account.analytic.line', 'move_id', string='Analytic lines', oldname="analytic_lines") tax_ids = fields.Many2many('account.tax', string='Taxes', copy=False, readonly=True) tax_line_id = fields.Many2one('account.tax', string='Originator tax', copy=False, readonly=True) analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account') @@ -342,9 +342,9 @@ class AccountMoveLine(models.Model): counterpart = fields.Char("Counterpart", compute='_get_counterpart', help="Compute the counter part accounts of this journal item for this journal entry. This can be needed in reports.") # TODO: put the invoice link and partner_id on the account_move - invoice = fields.Many2one('account.invoice') + invoice_id = fields.Many2one('account.invoice', oldname="invoice") partner_id = fields.Many2one('res.partner', string='Partner', index=True, ondelete='restrict') - user_type = fields.Many2one('account.account.type', related='account_id.user_type', index=True, store=True) + user_type_id = fields.Many2one('account.account.type', related='account_id.user_type_id', index=True, store=True, oldname="user_type") _sql_constraints = [ ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry !'), @@ -418,7 +418,7 @@ class AccountMoveLine(models.Model): FROM account_move_line l RIGHT JOIN account_account a ON (a.id = l.account_id) - RIGHT JOIN account_account_type at ON (at.id = a.user_type) + RIGHT JOIN account_account_type at ON (at.id = a.user_type_id) %s WHERE a.reconcile IS TRUE @@ -904,7 +904,7 @@ class AccountMoveLine(models.Model): if ('account_id' in vals): account = AccountObj.browse(vals['account_id']) if journal.type_control_ids: - type = account.user_type + type = account.user_type_id for t in journal.type_control_ids: if type.code == t.code: ok = True @@ -988,10 +988,10 @@ class AccountMoveLine(models.Model): raise UserError(_('You cannot use deprecated account.')) if any(key in vals for key in ('account_id', 'journal_id', 'date', 'move_id', 'debit', 'credit', 'amount_currency', 'currency_id')): self._update_check() - #when we set the expected payment date, log a note on the invoice related (if any) - if vals.get('expected_pay_date') and self.invoice: + #when we set the expected payment date, log a note on the invoice_id related (if any) + if vals.get('expected_pay_date') and self.invoice_id: msg = _('New expected payment date: ') + vals['expected_pay_date'] + '.\n' + vals.get('internal_note', '') - self.invoice.message_post(body=msg) #TODO: check it is an internal note (not a regular email)! + self.invoice_id.message_post(body=msg) #TODO: check it is an internal note (not a regular email)! #when making a reconciliation on an existing liquidity journal item, mark the payment as reconciled if 'statement_id' in vals and self.payment_id: # In case of an internal transfer, there are 2 liquidity move lines to match with a bank statement @@ -1057,8 +1057,8 @@ class AccountMoveLine(models.Model): if obj_line.analytic_account_id: if not obj_line.journal_id.analytic_journal_id: raise UserError(_("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name, )) - if obj_line.analytic_lines: - obj_line.analytic_lines.unlink() + if obj_line.analytic_line_ids: + obj_line.analytic_line_ids.unlink() vals_line = obj_line._prepare_analytic_line()[0] self.env['account.analytic.line'].create(vals_line) @@ -1094,7 +1094,7 @@ class AccountMoveLine(models.Model): domain += [(date_field, '<=', context['date_to'])] if context.get('date_from'): if not context.get('strict_range'): - domain += ['|', (date_field, '>=', context['date_from']), ('account_id.user_type.include_initial_balance', '=', True)] + domain += ['|', (date_field, '>=', context['date_from']), ('account_id.user_type_id.include_initial_balance', '=', True)] else: domain += [(date_field, '>=', context['date_from'])] diff --git a/addons/account/account_payment.py b/addons/account/account_payment.py index 70d38d6978b..1f8e252155e 100644 --- a/addons/account/account_payment.py +++ b/addons/account/account_payment.py @@ -31,8 +31,8 @@ class account_abstract_payment(models.AbstractModel): _description = "Contains the logic shared between models which allows to register payments" payment_type = fields.Selection([('outbound', 'Send Money'), ('inbound', 'Receive Money')], string='Payment Type', required=True) - payment_method = fields.Many2one('account.payment.method', string='Payment Method', required=True) - payment_method_code = fields.Char(related='payment_method.code', + payment_method_id = fields.Many2one('account.payment.method', string='Payment Method', required=True, oldname="payment_method") + payment_method_code = fields.Char(related='payment_method_id.code', help="Technical field used to adapt the interface to the payment method selected.") partner_type = fields.Selection([('customer', 'Customer'), ('supplier', 'Supplier')]) @@ -60,7 +60,7 @@ class account_abstract_payment(models.AbstractModel): if not self.journal_id: self.hide_payment_method = True return - journal_payment_methods = self.payment_type == 'inbound' and self.journal_id.inbound_payment_methods or self.journal_id.outbound_payment_methods + journal_payment_methods = self.payment_type == 'inbound' and self.journal_id.inbound_payment_method_ids or self.journal_id.outbound_payment_method_ids self.hide_payment_method = len(journal_payment_methods) == 1 and journal_payment_methods[0].code == 'manual' @api.onchange('journal_id') @@ -68,11 +68,11 @@ class account_abstract_payment(models.AbstractModel): if self.journal_id: self.currency_id = self.journal_id.currency_id or self.company_id.currency_id # Set default payment method (we consider the first to be the default one) - payment_methods = self.payment_type == 'inbound' and self.journal_id.inbound_payment_methods or self.journal_id.outbound_payment_methods - self.payment_method = payment_methods and payment_methods[0] or False + payment_methods = self.payment_type == 'inbound' and self.journal_id.inbound_payment_method_ids or self.journal_id.outbound_payment_method_ids + self.payment_method_id = payment_methods and payment_methods[0] or False # Set payment method domain (restrict to methods enabled for the journal and to selected payment type) payment_type = self.payment_type in ('outbound', 'transfer') and 'outbound' or 'inbound' - return {'domain': {'payment_method': [('payment_type', '=', payment_type), ('id', 'in', payment_methods.ids)]}} + return {'domain': {'payment_method_id': [('payment_type', '=', payment_type), ('id', 'in', payment_methods.ids)]}} return {} def _get_invoices(self): @@ -98,7 +98,7 @@ class account_register_payments(models.TransientModel): @api.onchange('payment_type') def _onchange_payment_type(self): if self.payment_type: - return {'domain': {'payment_method': [('payment_type', '=', self.payment_type)]}} + return {'domain': {'payment_method_id': [('payment_type', '=', self.payment_type)]}} def _get_invoices(self): return self.env['account.invoice'].browse(self._context.get('active_ids')) @@ -141,7 +141,7 @@ class account_register_payments(models.TransientModel): """ Hook for extension """ return { 'journal_id': self.journal_id.id, - 'payment_method': self.payment_method.id, + 'payment_method_id': self.payment_method_id.id, 'payment_date': self.payment_date, 'communication': self.communication, 'invoice_ids': [(4, inv.id, None) for inv in self._get_invoices()], @@ -194,7 +194,7 @@ class account_payment(models.Model): has_invoices = fields.Boolean(compute="_get_has_invoices", help="Technical field used for usablity purposes") payment_difference = fields.Monetary(compute='_compute_payment_difference', readonly=True) payment_difference_handling = fields.Selection([('open', 'Partial payment'), ('reconcile', 'Mark invoice as fully paid')], default='open', string="Payment Difference", copy=False) - writeoff_account = fields.Many2one('account.account', string="Counterpart Account", domain=[('deprecated', '=', False)], copy=False) + writeoff_account_id = fields.Many2one('account.account', string="Counterpart Account", domain=[('deprecated', '=', False)], copy=False) # FIXME: ondelete='restrict' not working (eg. cancel a bank statement reconciliation with a payment) move_line_ids = fields.One2many('account.move.line', 'payment_id', readonly=True, copy=False, ondelete='restrict') @@ -210,9 +210,9 @@ class account_payment(models.Model): self.destination_account_id = self.company_id.transfer_account_id.id elif self.partner_id: if self.partner_type == 'customer': - self.destination_account_id = self.partner_id.property_account_receivable.id + self.destination_account_id = self.partner_id.property_account_receivable_id.id else: - self.destination_account_id = self.partner_id.property_account_payable.id + self.destination_account_id = self.partner_id.property_account_payable_id.id @api.onchange('partner_type') def _onchange_partner_type(self): @@ -256,12 +256,12 @@ class account_payment(models.Model): @api.model def create(self, vals): - self._check_communication(vals['payment_method'], vals.get('communication', '')) + self._check_communication(vals['payment_method_id'], vals.get('communication', '')) return super(account_payment, self).create(vals) def _check_communication(self, payment_method_id, communication): """ This method is to be overwritten by payment type modules. The method body would look like : - if payment_method_id == self.env.ref('my_module.payment_method').id: + if payment_method_id == self.env.ref('my_module.payment_method_id').id: try: communication.decode('ascii') except UnicodeError: @@ -442,7 +442,7 @@ class account_payment(models.Model): """ return { 'partner_id': self.payment_type in ('inbound', 'outbound') and self.partner_id.commercial_partner_id.id or False, - 'invoice': invoice_id and invoice_id.id or False, + 'invoice_id': invoice_id and invoice_id.id or False, 'move_id': move_id, 'debit': debit, 'credit': credit, diff --git a/addons/account/chart_template.py b/addons/account/chart_template.py index e7c2925971a..329e492c67c 100644 --- a/addons/account/chart_template.py +++ b/addons/account/chart_template.py @@ -24,7 +24,7 @@ class AccountAccountTemplate(models.Model): name = fields.Char(required=True, index=True) currency_id = fields.Many2one('res.currency', string='Secondary Currency', help="Forces all moves for this account to have this secondary currency.") code = fields.Char(size=64, required=True, index=True) - user_type = fields.Many2one('account.account.type', string='Type', required=True, + user_type_id = fields.Many2one('account.account.type', string='Type', required=True, help="These types are defined according to your country. The type contains more information "\ "about the account and its specificities.") reconcile = fields.Boolean(string='Allow Invoices & payments Matching', default=False, @@ -71,20 +71,20 @@ class AccountChartTemplate(models.Model): help='List of all the taxes that have to be installed by the wizard') bank_account_code_char = fields.Char(string='Code of the main bank account') transfer_account_id = fields.Many2one('account.account.template', string='Transfer Account', required=True, - domain=lambda self: [('reconcile', '=', True), ('user_type.id', '=', self.env.ref('account.data_account_type_current_assets').id)], + domain=lambda self: [('reconcile', '=', True), ('user_type_id.id', '=', self.env.ref('account.data_account_type_current_assets').id)], help="Intermediary account used when moving money from a liquidity account to another") income_currency_exchange_account_id = fields.Many2one('account.account.template', string="Gain Exchange Rate Account", domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)]) expense_currency_exchange_account_id = fields.Many2one('account.account.template', string="Loss Exchange Rate Account", domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)]) - property_account_receivable = fields.Many2one('account.account.template', string='Receivable Account') - property_account_payable = fields.Many2one('account.account.template', string='Payable Account') - property_account_expense_categ = fields.Many2one('account.account.template', string='Expense Category Account') - property_account_income_categ = fields.Many2one('account.account.template', string='Income Category Account') - property_account_expense = fields.Many2one('account.account.template', string='Expense Account on Product Template') - property_account_income = fields.Many2one('account.account.template', string='Income Account on Product Template') - property_stock_account_input_categ = fields.Many2one('account.account.template') - property_stock_account_output_categ = fields.Many2one('account.account.template') + property_account_receivable_id = fields.Many2one('account.account.template', string='Receivable Account', oldname="property_account_receivable") + property_account_payable_id = fields.Many2one('account.account.template', string='Payable Account', oldname="property_account_payable") + property_account_expense_categ_id = fields.Many2one('account.account.template', string='Expense Category Account', oldname="property_account_expense_categ") + property_account_income_categ_id = fields.Many2one('account.account.template', string='Income Category Account', oldname="property_account_income_categ") + property_account_expense_id = fields.Many2one('account.account.template', string='Expense Account on Product Template', oldname="property_account_expense") + property_account_income_id = fields.Many2one('account.account.template', string='Income Account on Product Template', oldname="property_account_income") + property_stock_account_input_categ_id = fields.Many2one('account.account.template', oldname="property_stock_account_input_categ") + property_stock_account_output_categ_id = fields.Many2one('account.account.template', oldname="property_stock_account_output_categ") property_stock_valuation_account_id = fields.Many2one('account.account.template') @api.one @@ -159,9 +159,9 @@ class AccountChartTemplate(models.Model): # Get the default accounts default_account = False if journal['type'] == 'sale': - default_account = acc_template_ref.get(self.property_account_income_categ.id) + default_account = acc_template_ref.get(self.property_account_income_categ_id.id) elif journal['type'] == 'purchase': - default_account = acc_template_ref.get(self.property_account_expense_categ.id) + default_account = acc_template_ref.get(self.property_account_expense_categ_id.id) elif journal['type'] == 'general' and journal['name'] == _('Exchange Rate Journal'): if type=='credit': default_account = acc_template_ref.get(self.income_currency_exchange_account_id.id) @@ -206,12 +206,12 @@ class AccountChartTemplate(models.Model): self.ensure_one() PropertyObj = self.env['ir.property'] todo_list = [ - ('property_account_receivable', 'res.partner', 'account.account'), - ('property_account_payable', 'res.partner', 'account.account'), - ('property_account_expense_categ', 'product.category', 'account.account'), - ('property_account_income_categ', 'product.category', 'account.account'), - ('property_account_expense', 'product.template', 'account.account'), - ('property_account_income', 'product.template', 'account.account'), + ('property_account_receivable_id', 'res.partner', 'account.account'), + ('property_account_payable_id', 'res.partner', 'account.account'), + ('property_account_expense_categ_id', 'product.category', 'account.account'), + ('property_account_income_categ_id', 'product.category', 'account.account'), + ('property_account_expense_id', 'product.template', 'account.account'), + ('property_account_income_id', 'product.template', 'account.account'), ] for record in todo_list: account = getattr(self, record[0]) @@ -232,8 +232,8 @@ class AccountChartTemplate(models.Model): #create the property PropertyObj.create(vals) stock_properties = [ - 'property_stock_account_input_categ', - 'property_stock_account_output_categ', + 'property_stock_account_input_categ_id', + 'property_stock_account_output_categ_id', 'property_stock_valuation_account_id', ] for stock_property in stock_properties: @@ -354,7 +354,7 @@ class AccountChartTemplate(models.Model): 'name': account_template.name, 'currency_id': account_template.currency_id and account_template.currency_id.id or False, 'code': code_acc, - 'user_type': account_template.user_type and account_template.user_type.id or False, + 'user_type_id': account_template.user_type_id and account_template.user_type_id.id or False, 'reconcile': account_template.reconcile, 'note': account_template.note, 'tax_ids': [(6, 0, tax_ids)], @@ -548,15 +548,15 @@ class WizardMultiChartsAccounts(models.TransientModel): currency_id = fields.Many2one('res.currency', string='Currency', help="Currency as per company's country.", required=True) only_one_chart_template = fields.Boolean(string='Only One Chart Template Available') chart_template_id = fields.Many2one('account.chart.template', string='Chart Template', required=True) - bank_accounts_id = fields.One2many('account.bank.accounts.wizard', 'bank_account_id', string='Cash and Banks', required=True) + bank_account_ids = fields.One2many('account.bank.accounts.wizard', 'bank_account_id', string='Cash and Banks', required=True, oldname="bank_accounts_id") bank_account_code_char = fields.Char('Bank Accounts Code') code_digits = fields.Integer(string='# of Digits', required=True, help="No. of Digits to use for account code") - sale_tax = fields.Many2one('account.tax.template', string='Default Sales Tax') - purchase_tax = fields.Many2one('account.tax.template', string='Default Purchase Tax') + sale_tax_id = fields.Many2one('account.tax.template', string='Default Sales Tax', oldname="sale_tax") + purchase_tax_id = fields.Many2one('account.tax.template', string='Default Purchase Tax', oldname="purchase_tax") sale_tax_rate = fields.Float(string='Sales Tax(%)') use_anglo_saxon = fields.Boolean(string='Use Anglo-Saxon Accounting', related='chart_template_id.use_anglo_saxon') transfer_account_id = fields.Many2one('account.account.template', required=True, string='Transfer Account', - domain=lambda self: [('reconcile', '=', True), ('user_type.id', '=', self.env.ref('account.data_account_type_current_assets').id)], + domain=lambda self: [('reconcile', '=', True), ('user_type_id.id', '=', self.env.ref('account.data_account_type_current_assets').id)], help="Intermediary account used when moving money from a liquidity account to another") purchase_tax_rate = fields.Float(string='Purchase Tax(%)') complete_tax_set = fields.Boolean('Complete Set of Taxes', @@ -597,11 +597,11 @@ class WizardMultiChartsAccounts(models.TransientModel): purchase_tax_domain = base_tax_domain + [('type_tax_use', '=', 'purchase')] sale_tax = tax_templ_obj.search(sale_tax_domain, order="sequence, id desc", limit=1) purchase_tax = tax_templ_obj.search(purchase_tax_domain, order="sequence, id desc", limit=1) - self.sale_tax = sale_tax.id - self.purchase_tax = purchase_tax.id + self.sale_tax_id = sale_tax.id + self.purchase_tax_id = purchase_tax.id res.setdefault('domain', {}) - res['domain']['sale_tax'] = repr(sale_tax_domain) - res['domain']['purchase_tax'] = repr(purchase_tax_domain) + res['domain']['sale_tax_id'] = repr(sale_tax_domain) + res['domain']['purchase_tax_id'] = repr(purchase_tax_domain) if self.chart_template_id.transfer_account_id: self.transfer_account_id = self.chart_template_id.transfer_account_id.id if self.chart_template_id.code_digits: @@ -617,8 +617,8 @@ class WizardMultiChartsAccounts(models.TransientModel): tax_templ_obj = self.env['account.tax.template'] account_chart_template = self.env['account.chart.template'] - if 'bank_accounts_id' in fields: - res.update({'bank_accounts_id': [{'acc_name': _('Cash'), 'account_type': 'cash'}, {'acc_name': _('Bank'), 'account_type': 'bank'}]}) + if 'bank_account_ids' in fields: + res.update({'bank_account_ids': [{'acc_name': _('Cash'), 'account_type': 'cash'}, {'acc_name': _('Bank'), 'account_type': 'bank'}]}) if 'company_id' in fields: res.update({'company_id': self.env.user.company_id.id}) if 'currency_id' in fields: @@ -641,14 +641,14 @@ class WizardMultiChartsAccounts(models.TransientModel): if 'chart_template_id' in fields: res.update({'only_one_chart_template': len(chart_templates) == 1, 'chart_template_id': chart_id}) - if 'sale_tax' in fields: + if 'sale_tax_id' in fields: sale_tax = tax_templ_obj.search([('chart_template_id', 'in', chart_hierarchy_ids), ('type_tax_use', '=', 'sale')], limit=1, order='sequence') - res.update({'sale_tax': sale_tax and sale_tax.id or False}) - if 'purchase_tax' in fields: + res.update({'sale_tax_id': sale_tax and sale_tax.id or False}) + if 'purchase_tax_id' in fields: purchase_tax = tax_templ_obj.search([('chart_template_id', 'in', chart_hierarchy_ids), ('type_tax_use', '=', 'purchase')], limit=1, order='sequence') - res.update({'purchase_tax': purchase_tax and purchase_tax.id or False}) + res.update({'purchase_tax_id': purchase_tax and purchase_tax.id or False}) res.update({ 'purchase_tax_rate': 15.0, 'sale_tax_rate': 15.0, @@ -730,10 +730,10 @@ class WizardMultiChartsAccounts(models.TransientModel): acc_template_ref, taxes_ref = self.chart_template_id._install_template(company, code_digits=self.code_digits, transfer_account_id=self.transfer_account_id) # write values of default taxes for product as super user - if self.sale_tax and taxes_ref: - ir_values_obj.sudo().set_default('product.template', "taxes_id", [taxes_ref[self.sale_tax.id]], for_all_users=True, company_id=company.id) - if self.purchase_tax and taxes_ref: - ir_values_obj.sudo().set_default('product.template', "supplier_taxes_id", [taxes_ref[self.purchase_tax.id]], for_all_users=True, company_id=company.id) + if self.sale_tax_id and taxes_ref: + ir_values_obj.sudo().set_default('product.template', "taxes_id", [taxes_ref[self.sale_tax_id.id]], for_all_users=True, company_id=company.id) + if self.purchase_tax_id and taxes_ref: + ir_values_obj.sudo().set_default('product.template', "supplier_taxes_id", [taxes_ref[self.purchase_tax_id.id]], for_all_users=True, company_id=company.id) # Create Bank journals self._create_bank_journals_from_o2m(company, acc_template_ref) @@ -742,14 +742,14 @@ class WizardMultiChartsAccounts(models.TransientModel): self.env['account.account'].create({ 'code': '0', 'name': _('Undistributed Profits/Losses'), - 'user_type': self.env.ref("account.data_unaffected_earnings").id, + 'user_type_id': self.env.ref("account.data_unaffected_earnings").id, 'company_id': company.id,}) return {} @api.multi def _create_bank_journals_from_o2m(self, company, acc_template_ref): ''' - This function creates bank journals and its accounts for each line encoded in the field bank_accounts_id of the + This function creates bank journals and its accounts for each line encoded in the field bank_account_ids of the wizard. :param company_id: the id of the company for which the wizard is running. @@ -760,8 +760,8 @@ class WizardMultiChartsAccounts(models.TransientModel): self.ensure_one() # Build a list with all the data to process journal_data = [] - if self.bank_accounts_id: - for acc in self.bank_accounts_id: + if self.bank_account_ids: + for acc in self.bank_account_ids: vals = { 'acc_name': acc.acc_name, 'account_type': acc.account_type, diff --git a/addons/account/company.py b/addons/account/company.py index d7c0a2686f3..d56a10644a4 100644 --- a/addons/account/company.py +++ b/addons/account/company.py @@ -14,7 +14,7 @@ class ResCompany(models.Model): period_lock_date = fields.Date(help="Only users with the 'Adviser' role can edit accounts prior to and inclusive of this date") fiscalyear_lock_date = fields.Date(string="Fiscal Year lock date", help="No users, including Advisers, can edit accounts prior to and inclusive of this date") transfer_account_id = fields.Many2one('account.account', - domain=lambda self: [('reconcile', '=', True), ('user_type.id', '=', self.env.ref('account.data_account_type_current_assets').id), ('deprecated', '=', False)], string="Transfer Account", help="Intermediary account used when moving money from a liquidity account to another") + domain=lambda self: [('reconcile', '=', True), ('user_type_id.id', '=', self.env.ref('account.data_account_type_current_assets').id), ('deprecated', '=', False)], string="Transfer Account", help="Intermediary account used when moving money from a liquidity account to another") expects_chart_of_accounts = fields.Boolean(string='Expects a Chart of Accounts', default=True) chart_template_id = fields.Many2one('account.chart.template', help='The chart template for the company (if any)') bank_account_code_char = fields.Char(string='Code of the main bank account') @@ -31,8 +31,8 @@ class ResCompany(models.Model): expense_currency_exchange_account_id = fields.Many2one('account.account', related='currency_exchange_journal_id.default_debit_account_id', string="Loss Exchange Rate Account", domain="[('internal_type', '=', 'other'), ('deprecated', '=', False), ('company_id', '=', id)]") anglo_saxon_accounting = fields.Boolean(string="Use anglo-saxon accounting") - property_stock_account_input_categ = fields.Many2one('account.account') - property_stock_account_output_categ = fields.Many2one('account.account') + property_stock_account_input_categ_id = fields.Many2one('account.account', oldname="property_stock_account_input_categ") + property_stock_account_output_categ_id = fields.Many2one('account.account', oldname="property_stock_account_output_categ") property_stock_valuation_account_id = fields.Many2one('account.account') @api.multi diff --git a/addons/account/demo/account_demo.xml b/addons/account/demo/account_demo.xml index ee8e66f848d..c3038bcca8b 100644 --- a/addons/account/demo/account_demo.xml +++ b/addons/account/demo/account_demo.xml @@ -56,22 +56,22 @@ - + - - + + - + - + @@ -120,95 +120,95 @@ Foreign Exchange Gain - (test) X2010 - + X2020 Product Sales - (test) - + X2021 Sale of Lands - (test) - + X2022 Bank Accounts Interests - (test) - + X2030 Cost of Goods Sold - (test) - + Foreign Exchange Loss - (test) X2110 - + X2120 Expenses - (test) - + X2121 Salary Expenses - (test) - + X2122 Purchase of Equipments - (test) - + X2123 Bank Fees - (test) - + X3001 Capital - + X3002 Dividends - + X0000 Unaffected Earnings - + - - property_account_receivable - + + property_account_receivable_id + - - property_account_payable - + + property_account_payable_id + - - property_account_position - + + property_account_position_id + @@ -286,15 +286,15 @@ Product income and expense accounts, default parameters --> - - property_account_expense_categ - + + property_account_expense_categ_id + - - property_account_income_categ - + + property_account_income_categ_id + diff --git a/addons/account/tests/test_account_customer_invoice.py b/addons/account/tests/test_account_customer_invoice.py index 1ce28c8bdc7..0b79b47a0d9 100644 --- a/addons/account/tests/test_account_customer_invoice.py +++ b/addons/account/tests/test_account_customer_invoice.py @@ -24,13 +24,13 @@ class TestAccountCustomerInvoice(AccountTestUsers): self.journalrec = self.env['account.journal'].search([('type', '=', 'sale')])[0] self.partner3 = self.env.ref('base.res_partner_3') account_user_type = self.env.ref('account.data_account_type_receivable') - self.ova = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_current_assets').id)])[0] + self.ova = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_current_assets').id)], limit=1) #only adviser can create an account self.account_rec1_id = self.account_model.sudo(self.account_manager.id).create(dict( code="cust_acc", name="customer account", - user_type=account_user_type.id, + user_type_id=account_user_type.id, reconcile=True, )) @@ -39,7 +39,7 @@ class TestAccountCustomerInvoice(AccountTestUsers): { 'product_id': self.env.ref('product.product_product_5').id, 'quantity': 10.0, - 'account_id': self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_revenue').id)])[0].id, + 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, 'name': 'product test 5', 'price_unit': 100.00, } diff --git a/addons/account/tests/test_account_supplier_invoice.py b/addons/account/tests/test_account_supplier_invoice.py index 2c76dc7a13c..e8531700be4 100644 --- a/addons/account/tests/test_account_supplier_invoice.py +++ b/addons/account/tests/test_account_supplier_invoice.py @@ -16,8 +16,8 @@ class TestAccountSupplierInvoice(AccountingTestCase): }) # Should be changed by automatic on_change later - invoice_account = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_receivable').id)])[0].id - invoice_line_account = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_expenses').id)])[0].id + invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id + invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id invoice = self.env['account.invoice'].create({'partner_id': self.env.ref('base.res_partner_2').id, 'account_id': invoice_account, diff --git a/addons/account/tests/test_account_validate_account_move.py b/addons/account/tests/test_account_validate_account_move.py index 0745ee422b7..e5265ead8e2 100644 --- a/addons/account/tests/test_account_validate_account_move.py +++ b/addons/account/tests/test_account_validate_account_move.py @@ -4,7 +4,7 @@ class TestAccountValidateAccount(AccountingTestCase): def test_account_validate_account(self): account_move_line = self.env['account.move.line'] - account_cash = self.env['account.account'].search([('user_type.type', '=', 'liquidity')], limit=1) + account_cash = self.env['account.account'].search([('user_type_id.type', '=', 'liquidity')], limit=1) journal = self.env['account.journal'].search([('type', '=', 'bank')], limit=1) company_id = self.env['res.users'].browse(self.env.uid).company_id.id diff --git a/addons/account/tests/test_bank_statement_reconciliation.py b/addons/account/tests/test_bank_statement_reconciliation.py index cb7b55a371f..b31150db953 100644 --- a/addons/account/tests/test_bank_statement_reconciliation.py +++ b/addons/account/tests/test_bank_statement_reconciliation.py @@ -35,7 +35,7 @@ class TestBankStatementReconciliation(AccountingTestCase): self.assertTrue(rec_move) counterpart_mv_line = None for l in rec_move.line_ids: - if l.account_id.user_type.type == 'receivable': + if l.account_id.user_type_id.type == 'receivable': counterpart_mv_line = l break self.assertIsNotNone(counterpart_mv_line) @@ -64,7 +64,7 @@ class TestBankStatementReconciliation(AccountingTestCase): 'price_unit': amount, 'invoice_id': invoice.id, 'name': '.', - 'account_id': self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_revenue').id)])[0].id, + 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, }) invoice.signal_workflow('invoice_open') diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 95853964b0c..fba65d6f54c 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -22,9 +22,9 @@ class TestPayment(AccountingTestCase): self.payment_method_manual_in = self.env.ref("account.account_payment_method_manual_in") self.payment_method_manual_out = self.env.ref("account.account_payment_method_manual_out") - self.account_receivable = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_receivable').id)])[0] - self.account_payable = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_payable').id)])[0] - self.account_revenue = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_revenue').id)])[0] + self.account_receivable = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1) + self.account_payable = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1) + self.account_revenue = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) self.bank_euro = self.env['res.partner.bank'].create({'acc_number': '0123456789', 'bank_name': 'Test Bank', 'company_id': self.env.user.company_id.id}) self.bank_journal_euro = self.bank_euro.journal_id @@ -126,7 +126,7 @@ class TestPayment(AccountingTestCase): register_payments = self.register_payments_model.with_context(ctx).create({ 'payment_date': time.strftime('%Y') + '-07-15', 'journal_id': self.bank_journal_euro.id, - 'payment_method': self.payment_method_manual_in.id, + 'payment_method_id': self.payment_method_manual_in.id, }) register_payments.create_payment() payment = self.payment_model.search([], order="id desc", limit=1) @@ -158,7 +158,7 @@ class TestPayment(AccountingTestCase): 'currency_id': self.currency_usd_id, 'journal_id': self.bank_journal_usd.id, 'destination_journal_id': self.bank_journal_euro.id, - 'payment_method': self.payment_method_manual_out.id, + 'payment_method_id': self.payment_method_manual_out.id, }) payment.post() self.check_journal_items(payment.move_line_ids, [ @@ -177,11 +177,11 @@ class TestPayment(AccountingTestCase): 'journal_id': self.bank_journal_usd.id, 'partner_type': 'supplier', 'partner_id': self.partner_axelor.id, - 'payment_method': self.payment_method_manual_out.id, + 'payment_method_id': self.payment_method_manual_out.id, }) payment.post() self.check_journal_items(payment.move_line_ids, [ {'account_id': self.account_usd.id, 'debit': 0.0, 'credit': 38.21, 'amount_currency': -58.42, 'currency_id': self.currency_usd_id}, - {'account_id': self.partner_axelor.property_account_payable.id, 'debit': 38.21, 'credit': 0.0, 'amount_currency': 50, 'currency_id': self.currency_chf_id}, + {'account_id': self.partner_axelor.property_account_payable_id.id, 'debit': 38.21, 'credit': 0.0, 'amount_currency': 50, 'currency_id': self.currency_chf_id}, ]) diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index 056232e701d..cb69a12e12e 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -21,8 +21,8 @@ class TestReconciliation(AccountingTestCase): self.currency_usd_id = self.env.ref("base.USD").id self.currency_euro_id = self.env.ref("base.EUR").id self.env.ref('base.main_company').write({'currency_id': self.currency_euro_id}) - self.account_rcv = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_receivable').id)])[0] - self.account_rsa = self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_payable').id)])[0] + self.account_rcv = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1) + self.account_rsa = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1) self.product = self.env.ref("product.product_product_4") self.bank_euro = self.env['res.partner.bank'].create({'acc_number': 'Reconciliation test', 'bank_name': 'Test Bank', 'company_id': self.env.user.company_id.id}) @@ -53,7 +53,7 @@ class TestReconciliation(AccountingTestCase): 'price_unit': 100, 'invoice_id': invoice.id, 'name': 'product that cost 100', - 'account_id': self.env['account.account'].search([('user_type', '=', self.env.ref('account.data_account_type_revenue').id)])[0].id, + 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, }) #validate invoice diff --git a/addons/account/tests/test_search.py b/addons/account/tests/test_search.py index f79e368d9c2..eb94a9bd910 100644 --- a/addons/account/tests/test_search.py +++ b/addons/account/tests/test_search.py @@ -14,21 +14,21 @@ class TestSearch(AccountTestUsers): self.atax = self.account_model.create(dict( name="Tax Received", code="X121", - user_type=ac_ids.id, + user_type_id=ac_ids.id, reconcile=True, )).id, "X121 Tax Received" self.apurchase = self.account_model.create(dict( name="Purchased Stocks", code="X1101", - user_type=ac_ids.id, + user_type_id=ac_ids.id, reconcile=True, )).id, "X1101 Purchased Stocks" self.asale = self.account_model.create(dict( name="Product Sales", code="XX200", - user_type=ac_ids.id, + user_type_id=ac_ids.id, reconcile=True, )).id, "XX200 Product Sales" @@ -56,16 +56,15 @@ class TestSearch(AccountTestUsers): self.assertEqual(set([self.asale[0]]), set([a[0] for a in asale_ids]), "name_search 'ilike XX200' should have returned Product Sales account only") def test_property_unset_search(self): - cr, uid = self.cr, self.uid - res_partner_model = self.registry('res.partner') - account_payment_term_model = self.registry('account.payment.term') + res_partner_model = self.env['res.partner'] + account_payment_term_model = self.env['account.payment.term'] - a_partner = res_partner_model.create(cr, uid, {'name': 'test partner'}) - a_payment_term = account_payment_term_model.create(cr, uid, {'name': 'test payment term'}) + a_partner = res_partner_model.create({'name': 'test partner'}) + a_payment_term = account_payment_term_model.create({'name': 'test payment term'}) - partner_ids = res_partner_model.search(cr, uid, [('property_payment_term', '=', False), ('id', '=', a_partner)]) - self.assertTrue(partner_ids, "unset property field 'propety_payment_term' should have been found") + partners = res_partner_model.search([('property_payment_term_id', '=', False), ('id', '=', a_partner.id)]) + self.assertTrue(partners, "unset property field 'propety_payment_term' should have been found") - res_partner_model.write(cr, uid, [a_partner], {'property_payment_term': a_payment_term}) - partner_ids = res_partner_model.search(cr, uid, [('property_payment_term', '=', False), ('id', '=', a_partner)]) - self.assertFalse(partner_ids, "set property field 'propety_payment_term' should not have been found") + a_partner.write({'property_payment_term_id': a_payment_term}) + partners = res_partner_model.search([('property_payment_term_id', '=', False), ('id', '=', a_partner.id)]) + self.assertFalse(partners, "set property field 'propety_payment_term' should not have been found") diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py index bb036b22ab8..2b9e11045e9 100644 --- a/addons/account/tests/test_tax.py +++ b/addons/account/tests/test_tax.py @@ -45,7 +45,7 @@ class TestTax(AccountTestUsers): }) self.bank_journal = self.env['account.journal'].search([('type', '=', 'bank'), ('company_id', '=', self.account_manager.company_id.id)])[0] self.bank_account = self.bank_journal.default_debit_account_id - self.expense_account = self.env['account.account'].search([('user_type.type', '=', 'payable')])[0] #Should be done by onchange later + self.expense_account = self.env['account.account'].search([('user_type_id.type', '=', 'payable')], limit=1) #Should be done by onchange later def test_tax_group(self): res = self.group_tax.compute_all(200.0) diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 92ccc306cdb..2fc95ac6ae4 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -455,7 +455,7 @@ - + diff --git a/addons/account/views/account_payment_view.xml b/addons/account/views/account_payment_view.xml index 0ff503e29fe..415d55d7d1f 100644 --- a/addons/account/views/account_payment_view.xml +++ b/addons/account/views/account_payment_view.xml @@ -10,7 +10,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -102,7 +102,7 @@ - +