diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py
index b72d3415bcf..e9f0daddfef 100644
--- a/addons/account/controllers/portal.py
+++ b/addons/account/controllers/portal.py
@@ -12,7 +12,7 @@ class PortalAccount(CustomerPortal):
def _prepare_portal_layout_values(self):
values = super(PortalAccount, self)._prepare_portal_layout_values()
invoice_count = request.env['account.move'].search_count([
- ('type', 'in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund', 'out_receipt', 'in_receipt')),
+ ('move_type', 'in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund', 'out_receipt', 'in_receipt')),
])
values['invoice_count'] = invoice_count
return values
@@ -33,7 +33,7 @@ class PortalAccount(CustomerPortal):
values = self._prepare_portal_layout_values()
AccountInvoice = request.env['account.move']
- domain = [('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]
+ domain = [('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]
searchbar_sortings = {
'date': {'label': _('Invoice Date'), 'order': 'invoice_date desc'},
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index 2733f3a6a90..1645c552fb8 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -1100,7 +1100,7 @@ class AccountJournal(models.Model):
if self.company_id != self.env.ref('base.main_company'):
alias_name += '-' + str(self.company_id.name)
return {
- 'alias_defaults': {'type': type == 'purchase' and 'in_invoice' or 'out_invoice', 'company_id': self.company_id.id, 'journal_id': self.id},
+ 'alias_defaults': {'move_type': type == 'purchase' and 'in_invoice' or 'out_invoice', 'company_id': self.company_id.id, 'journal_id': self.id},
'alias_parent_thread_id': self.id,
'alias_name': alias_name,
}
@@ -1568,10 +1568,10 @@ class AccountTax(models.Model):
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
context = self._context or {}
- if context.get('type'):
- if context.get('type') in ('out_invoice', 'out_refund'):
+ if context.get('move_type'):
+ if context.get('move_type') in ('out_invoice', 'out_refund'):
args += [('type_tax_use', '=', 'sale')]
- elif context.get('type') in ('in_invoice', 'in_refund'):
+ elif context.get('move_type') in ('in_invoice', 'in_refund'):
args += [('type_tax_use', '=', 'purchase')]
if context.get('journal_id'):
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 521bd89cea2..5540b8badaa 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -592,7 +592,7 @@ class AccountBankStatementLine(models.Model):
if self.ref:
ref = move_ref + ' - ' + self.ref if move_ref else self.ref
data = {
- 'type': 'entry',
+ 'move_type': 'entry',
'journal_id': self.statement_id.journal_id.id,
'currency_id': self.statement_id.currency_id.id,
'date': self.statement_id.accounting_date or self.date,
diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py
index 43400afa408..3cee0e2d97f 100644
--- a/addons/account/models/account_journal_dashboard.py
+++ b/addons/account/models/account_journal_dashboard.py
@@ -210,7 +210,7 @@ class account_journal(models.Model):
WHERE move.journal_id = %(journal_id)s
AND move.state = 'posted'
AND move.payment_state in ('not_paid', 'partial')
- AND move.type IN %(invoice_types)s
+ AND move.move_type IN %(invoice_types)s
''', {
'invoice_types': tuple(self.env['account.move'].get_invoice_types(True)),
'journal_id': self.id
@@ -252,7 +252,7 @@ class account_journal(models.Model):
#TODO need to check if all invoices are in the same currency than the journal!!!!
elif self.type in ['sale', 'purchase']:
title = _('Bills to pay') if self.type == 'purchase' else _('Invoices owed to you')
- self.env['account.move'].flush(['amount_residual', 'currency_id', 'type', 'invoice_date', 'company_id', 'journal_id', 'date', 'state', 'payment_state'])
+ self.env['account.move'].flush(['amount_residual', 'currency_id', 'move_type', 'invoice_date', 'company_id', 'journal_id', 'date', 'state', 'payment_state'])
(query, query_args) = self._get_open_bills_to_pay_query()
self.env.cr.execute(query, query_args)
@@ -265,9 +265,9 @@ class account_journal(models.Model):
today = fields.Date.today()
query = '''
SELECT
- (CASE WHEN type IN ('out_refund', 'in_refund') THEN -1 ELSE 1 END) * amount_residual AS amount_total,
+ (CASE WHEN move_type IN ('out_refund', 'in_refund') THEN -1 ELSE 1 END) * amount_residual AS amount_total,
currency_id AS currency,
- type,
+ move_type,
invoice_date,
company_id
FROM account_move move
@@ -275,7 +275,7 @@ class account_journal(models.Model):
AND date <= %s
AND state = 'posted'
AND payment_state in ('not_paid', 'partial')
- AND type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt');
+ AND move_type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt');
'''
self.env.cr.execute(query, (self.id, today))
late_query_results = self.env.cr.dictfetchall()
@@ -324,16 +324,16 @@ class account_journal(models.Model):
"""
return ('''
SELECT
- (CASE WHEN move.type IN ('out_refund', 'in_refund') THEN -1 ELSE 1 END) * move.amount_residual AS amount_total,
+ (CASE WHEN move.move_type IN ('out_refund', 'in_refund') THEN -1 ELSE 1 END) * move.amount_residual AS amount_total,
move.currency_id AS currency,
- move.type,
+ move.move_type,
move.invoice_date,
move.company_id
FROM account_move move
WHERE move.journal_id = %(journal_id)s
AND move.state = 'posted'
AND move.payment_state in ('not_paid', 'partial')
- AND move.type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt');
+ AND move.move_type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt');
''', {'journal_id': self.id})
def _get_draft_bills_query(self):
@@ -344,16 +344,16 @@ class account_journal(models.Model):
"""
return ('''
SELECT
- (CASE WHEN move.type IN ('out_refund', 'in_refund') THEN -1 ELSE 1 END) * move.amount_total AS amount_total,
+ (CASE WHEN move.move_type IN ('out_refund', 'in_refund') THEN -1 ELSE 1 END) * move.amount_total AS amount_total,
move.currency_id AS currency,
- move.type,
+ move.move_type,
move.invoice_date,
move.company_id
FROM account_move move
WHERE move.journal_id = %(journal_id)s
AND move.state = 'draft'
AND move.payment_state in ('not_paid', 'partial')
- AND move.type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt');
+ AND move.move_type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt');
''', {'journal_id': self.id})
def _count_results_and_sum_amounts(self, results_dict, target_currency, curr_cache=None):
@@ -388,11 +388,11 @@ class account_journal(models.Model):
ctx = self._context.copy()
ctx['default_journal_id'] = self.id
if self.type == 'sale':
- ctx['default_type'] = 'out_refund' if ctx.get('refund') else 'out_invoice'
+ ctx['default_move_type'] = 'out_refund' if ctx.get('refund') else 'out_invoice'
elif self.type == 'purchase':
- ctx['default_type'] = 'in_refund' if ctx.get('refund') else 'in_invoice'
+ ctx['default_move_type'] = 'in_refund' if ctx.get('refund') else 'in_invoice'
else:
- ctx['default_type'] = 'entry'
+ ctx['default_move_type'] = 'entry'
ctx['view_no_maturity'] = True
return {
'name': _('Create invoice/bill'),
@@ -466,7 +466,7 @@ class account_journal(models.Model):
'search_default_journal_id': self.id,
})
- domain_type_field = action['res_model'] == 'account.move.line' and 'move_id.type' or 'type' # The model can be either account.move or account.move.line
+ domain_type_field = action['res_model'] == 'account.move.line' and 'move_id.move_type' or 'move_type' # The model can be either account.move or account.move.line
if self.type == 'sale':
action['domain'] = [(domain_type_field, 'in', ('out_invoice', 'out_refund', 'out_receipt'))]
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index 326af6d2e00..d25fe908714 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -54,7 +54,7 @@ class AccountMove(models.Model):
It could either be passed through the context using the 'default_journal_id' key containing its id,
either be determined by the default type.
'''
- move_type = self._context.get('default_type', 'entry')
+ move_type = self._context.get('default_move_type', 'entry')
journal_type = 'general'
if move_type in self.get_sale_types(include_receipts=True):
journal_type = 'sale'
@@ -89,7 +89,7 @@ class AccountMove(models.Model):
@api.model
def _get_default_invoice_date(self):
- return fields.Date.today() if self._context.get('default_type', 'entry') in ('in_invoice', 'in_refund', 'in_receipt') else False
+ return fields.Date.today() if self._context.get('default_move_type', 'entry') in ('in_invoice', 'in_refund', 'in_receipt') else False
@api.model
def _get_default_currency(self):
@@ -118,7 +118,7 @@ class AccountMove(models.Model):
], string='Status', required=True, readonly=True, copy=False, tracking=True,
default='draft')
posted_before = fields.Boolean(help="Technical field for knowing if the move has been posted before", copy=False)
- type = fields.Selection(selection=[
+ move_type = fields.Selection(selection=[
('entry', 'Journal Entry'),
('out_invoice', 'Customer Invoice'),
('out_refund', 'Customer Credit Note'),
@@ -379,7 +379,7 @@ class AccountMove(models.Model):
self.invoice_vendor_bill_id = False
self._recompute_dynamic_lines()
- @api.onchange('type')
+ @api.onchange('move_type')
def _onchange_type(self):
''' Onchange made to filter the partners depending of the type. '''
if self.is_sale_document(include_receipts=True):
@@ -484,7 +484,7 @@ class AccountMove(models.Model):
quantity=quantity,
product=base_line.product_id,
partner=base_line.partner_id,
- is_refund=self.type in ('out_refund', 'in_refund'),
+ is_refund=self.move_type in ('out_refund', 'in_refund'),
)
if base_line.currency_id:
@@ -495,7 +495,7 @@ class AccountMove(models.Model):
quantity=quantity,
product=base_line.product_id,
partner=base_line.partner_id,
- is_refund=self.type in ('out_refund', 'in_refund'),
+ is_refund=self.move_type in ('out_refund', 'in_refund'),
)
for b_tax_res, ac_tax_res in zip(balance_taxes_res['taxes'], amount_currency_taxes_res['taxes']):
tax = self.env['account.tax'].browse(b_tax_res['id'])
@@ -775,7 +775,7 @@ class AccountMove(models.Model):
# Search new account.
domain = [
('company_id', '=', self.company_id.id),
- ('internal_type', '=', 'receivable' if self.type in ('out_invoice', 'out_refund', 'out_receipt') else 'payable'),
+ ('internal_type', '=', 'receivable' if self.move_type in ('out_invoice', 'out_refund', 'out_receipt') else 'payable'),
]
return self.env['account.account'].search(domain, limit=1)
@@ -964,10 +964,10 @@ class AccountMove(models.Model):
param['date'] = self.date
if self.journal_id.refund_sequence:
- if self.type in ('out_refund', 'in_refund'):
- where_string += " AND type IN ('out_refund', 'in_refund') "
+ if self.move_type in ('out_refund', 'in_refund'):
+ where_string += " AND move_type IN ('out_refund', 'in_refund') "
else:
- where_string += " AND type NOT IN ('out_refund', 'in_refund') "
+ where_string += " AND move_type NOT IN ('out_refund', 'in_refund') "
return where_string, param
@@ -989,21 +989,21 @@ class AccountMove(models.Model):
return '%s%04d%s%02d%s%s%s' % (sequence.group('prefix1'), self.date.year, sequence.group('prefix2'), self.date.month, sequence.group('prefix3'), "0" * len(sequence.group('seq')), sequence.group('suffix'))
starting_sequence = "%s/%04d/%02d/0000" % (self.journal_id.code, self.date.year, self.date.month)
- if self.journal_id.refund_sequence and self.type in ('out_refund', 'in_refund'):
+ if self.journal_id.refund_sequence and self.move_type in ('out_refund', 'in_refund'):
starting_sequence = "R" + starting_sequence
return starting_sequence
- @api.depends('type')
+ @api.depends('move_type')
def _compute_type_name(self):
type_name_mapping = {k: v for k, v in
- self._fields['type']._description_selection(self.env)}
+ self._fields['move_type']._description_selection(self.env)}
replacements = {'out_invoice': _('Invoice'), 'out_refund': _('Credit Note')}
for record in self:
- name = type_name_mapping[record.type]
- record.type_name = replacements.get(record.type, name)
+ name = type_name_mapping[record.move_type]
+ record.type_name = replacements.get(record.move_type, name)
- @api.depends('type')
+ @api.depends('move_type')
def _compute_invoice_filter_type_domain(self):
for move in self:
if move.is_sale_document(include_receipts=True):
@@ -1111,7 +1111,7 @@ class AccountMove(models.Model):
total += line.balance
total_currency += line.amount_currency
- if move.type == 'entry' or move.is_outbound():
+ if move.move_type == 'entry' or move.is_outbound():
sign = 1
else:
sign = -1
@@ -1121,13 +1121,13 @@ class AccountMove(models.Model):
move.amount_residual = -sign * (total_residual_currency if len(currencies) == 1 else total_residual)
move.amount_untaxed_signed = -total_untaxed
move.amount_tax_signed = -total_tax
- move.amount_total_signed = abs(total) if move.type == 'entry' else -total
+ move.amount_total_signed = abs(total) if move.move_type == 'entry' else -total
move.amount_residual_signed = total_residual
currency = len(currencies) == 1 and currencies.pop() or move.company_id.currency_id
# Compute 'payment_state'.
- new_pmt_state = 'not_paid' if move.type != 'entry' else False
+ new_pmt_state = 'not_paid' if move.move_type != 'entry' else False
if move.is_invoice(include_receipts=True) and move.state == 'posted':
@@ -1139,9 +1139,9 @@ class AccountMove(models.Model):
elif currency.compare_amounts(total_to_pay, total_residual) != 0:
new_pmt_state = 'partial'
- if new_pmt_state == 'paid' and move.type in ('in_invoice', 'out_invoice', 'entry'):
- reverse_type = move.type == 'in_invoice' and 'in_refund' or move.type == 'out_invoice' and 'out_refund' or 'entry'
- reverse_moves = self.env['account.move'].search([('reversed_entry_id', '=', move.id), ('state', '=', 'posted'), ('type', '=', reverse_type)])
+ if new_pmt_state == 'paid' and move.move_type in ('in_invoice', 'out_invoice', 'entry'):
+ reverse_type = move.move_type == 'in_invoice' and 'in_refund' or move.move_type == 'out_invoice' and 'out_refund' or 'entry'
+ reverse_moves = self.env['account.move'].search([('reversed_entry_id', '=', move.id), ('state', '=', 'posted'), ('move_type', '=', reverse_type)])
# We only set 'reversed' state in cas of 1 to 1 full reconciliation with a reverse entry; otherwise, we use the regular 'paid' state
reverse_moves_full_recs = reverse_moves.mapped('line_ids.full_reconcile_id')
@@ -1152,7 +1152,7 @@ class AccountMove(models.Model):
def _inverse_amount_total(self):
for move in self:
- if len(move.line_ids) != 2 or move.type != 'entry':
+ if len(move.line_ids) != 2 or move.move_type != 'entry':
continue
to_write = []
@@ -1195,7 +1195,7 @@ class AccountMove(models.Model):
('payment_state', '=', 'not_paid'),
('state', '=', 'posted'),
('amount_residual', '=', r.amount_residual),
- ('type', '=', r.type)]
+ ('move_type', '=', r.move_type)]
#there are less than 5 other open invoices of the same type with the same residual
if self.env['account.move'].search_count(domain2) < 5:
res = True
@@ -1299,7 +1299,7 @@ class AccountMove(models.Model):
})
return reconciled_vals
- @api.depends('type', 'line_ids.amount_residual')
+ @api.depends('move_type', 'line_ids.amount_residual')
def _compute_payments_widget_reconciled_info(self):
for move in self:
if move.state != 'posted' or not move.is_invoice(include_receipts=True):
@@ -1393,7 +1393,7 @@ class AccountMove(models.Model):
INNER JOIN account_move move2 ON
move2.name = move.name
AND move2.journal_id = move.journal_id
- AND move2.type = move.type
+ AND move2.move_type = move.move_type
AND move2.id != move.id
WHERE move.id IN %s AND move2.state = 'posted'
''', [tuple(moves.ids)])
@@ -1402,14 +1402,14 @@ class AccountMove(models.Model):
raise ValidationError(_('Posted journal entry must have an unique sequence number per company.\n'
'Problematic numbers: %s\n') % ', '.join(r[1] for r in res))
- @api.constrains('ref', 'type', 'partner_id', 'journal_id', 'invoice_date')
+ @api.constrains('ref', 'move_type', 'partner_id', 'journal_id', 'invoice_date')
def _check_duplicate_supplier_reference(self):
moves = self.filtered(lambda move: move.is_purchase_document() and move.ref)
if not moves:
return
self.env["account.move"].flush([
- "ref", "type", "invoice_date", "journal_id",
+ "ref", "move_type", "invoice_date", "journal_id",
"company_id", "partner_id", "commercial_partner_id",
])
self.env["account.journal"].flush(["company_id"])
@@ -1425,7 +1425,7 @@ class AccountMove(models.Model):
move2.ref = move.ref
AND move2.company_id = journal.company_id
AND move2.commercial_partner_id = partner.commercial_partner_id
- AND move2.type = move.type
+ AND move2.move_type = move.move_type
AND (move.invoice_date is NULL OR move2.invoice_date = move.invoice_date)
AND move2.id != move.id
WHERE move.id IN %s
@@ -1539,12 +1539,12 @@ class AccountMove(models.Model):
vals.pop('invoice_line_ids', None)
new_vals_list.append(vals)
continue
- if not vals.get('type') and not self._context.get('default_type'):
+ if not vals.get('move_type') and not self._context.get('default_move_type'):
vals.pop('invoice_line_ids', None)
new_vals_list.append(vals)
continue
- vals['type'] = vals.get('type', self._context.get('default_type', 'entry'))
- if not vals['type'] in self.get_invoice_types(include_receipts=True):
+ vals['move_type'] = vals.get('move_type', self._context.get('default_move_type', 'entry'))
+ if not vals['move_type'] in self.get_invoice_types(include_receipts=True):
new_vals_list.append(vals)
continue
@@ -1553,7 +1553,7 @@ class AccountMove(models.Model):
if vals.get('invoice_date') and not vals.get('date'):
vals['date'] = vals['invoice_date']
- ctx_vals = {'default_type': vals.get('type') or self._context.get('default_type')}
+ ctx_vals = {'default_move_type': vals.get('move_type') or self._context.get('default_move_type')}
if vals.get('journal_id'):
ctx_vals['default_journal_id'] = vals['journal_id']
# reorder the companies in the context so that the company of the journal
@@ -1587,7 +1587,7 @@ class AccountMove(models.Model):
vals['line_ids'] = vals.pop('invoice_line_ids')
for invoice in self:
- invoice_new = invoice.with_context(default_type=invoice.type, default_journal_id=invoice.journal_id.id).new(origin=invoice)
+ invoice_new = invoice.with_context(default_move_type=invoice.move_type, default_journal_id=invoice.journal_id.id).new(origin=invoice)
invoice_new.update(vals)
values = invoice_new._move_autocomplete_invoice_lines_values()
values.pop('invoice_line_ids', None)
@@ -1683,7 +1683,7 @@ class AccountMove(models.Model):
def _creation_subtype(self):
# OVERRIDE
- if self.type in ('out_invoice', 'out_refund', 'out_receipt'):
+ if self.move_type in ('out_invoice', 'out_refund', 'out_receipt'):
return self.env.ref('account.mt_invoice_created')
else:
return super(AccountMove, self)._creation_subtype()
@@ -1712,7 +1712,7 @@ class AccountMove(models.Model):
'in_refund': _('Credit Note Created'),
'out_receipt': _('Sales Receipt Created'),
'in_receipt': _('Purchase Receipt Created'),
- }[self.type]
+ }[self.move_type]
# -------------------------------------------------------------------------
# BUSINESS METHODS
@@ -1723,35 +1723,35 @@ class AccountMove(models.Model):
return ['out_invoice', 'out_refund', 'in_refund', 'in_invoice'] + (include_receipts and ['out_receipt', 'in_receipt'] or [])
def is_invoice(self, include_receipts=False):
- return self.type in self.get_invoice_types(include_receipts)
+ return self.move_type in self.get_invoice_types(include_receipts)
@api.model
def get_sale_types(self, include_receipts=False):
return ['out_invoice', 'out_refund'] + (include_receipts and ['out_receipt'] or [])
def is_sale_document(self, include_receipts=False):
- return self.type in self.get_sale_types(include_receipts)
+ return self.move_type in self.get_sale_types(include_receipts)
@api.model
def get_purchase_types(self, include_receipts=False):
return ['in_invoice', 'in_refund'] + (include_receipts and ['in_receipt'] or [])
def is_purchase_document(self, include_receipts=False):
- return self.type in self.get_purchase_types(include_receipts)
+ return self.move_type in self.get_purchase_types(include_receipts)
@api.model
def get_inbound_types(self, include_receipts=True):
return ['out_invoice', 'in_refund'] + (include_receipts and ['out_receipt'] or [])
def is_inbound(self, include_receipts=True):
- return self.type in self.get_inbound_types(include_receipts)
+ return self.move_type in self.get_inbound_types(include_receipts)
@api.model
def get_outbound_types(self, include_receipts=True):
return ['in_invoice', 'out_refund'] + (include_receipts and ['in_receipt'] or [])
def is_outbound(self, include_receipts=True):
- return self.type in self.get_outbound_types(include_receipts)
+ return self.move_type in self.get_outbound_types(include_receipts)
def _affect_tax_report(self):
return any(line._affect_tax_report() for line in self.line_ids)
@@ -1816,6 +1816,7 @@ class AccountMove(models.Model):
else:
raise UserError(_('The combination of reference model and reference type on the journal is not implemented'))
+
def _get_move_display_name(self, show_ref=False):
''' Helper to get the display name of an invoice depending of its type.
:param show_ref: A flag indicating of the display name must include or not the journal entry reference.
@@ -1832,7 +1833,7 @@ class AccountMove(models.Model):
'out_receipt': _('Draft Sales Receipt'),
'in_receipt': _('Draft Purchase Receipt'),
'entry': _('Draft Entry'),
- }[self.type]
+ }[self.move_type]
if not self.name or self.name == '/':
draft_name += ' (* %s)' % str(self.id)
else:
@@ -1907,7 +1908,7 @@ class AccountMove(models.Model):
mapping = {}
# Do nothing if the move is not a credit note.
- if move_vals['type'] not in ('out_refund', 'in_refund'):
+ if move_vals['move_type'] not in ('out_refund', 'in_refund'):
return mapping
for line_command in move_vals.get('line_ids', []):
@@ -1944,7 +1945,7 @@ class AccountMove(models.Model):
'credit': balance < 0.0 and -balance or 0.0,
})
- if move_vals['type'] not in ('out_refund', 'in_refund'):
+ if move_vals['move_type'] not in ('out_refund', 'in_refund'):
continue
# ==== Map tax repartition lines ====
@@ -2012,7 +2013,7 @@ class AccountMove(models.Model):
move_vals_list = []
for move, default_values in zip(self, default_values_list):
default_values.update({
- 'type': reverse_type_map[move.type],
+ 'move_type': reverse_type_map[move.move_type],
'reversed_entry_id': move.id,
})
move_vals_list.append(move._reverse_move_vals(default_values, cancel=cancel))
@@ -2047,7 +2048,7 @@ class AccountMove(models.Model):
def message_new(self, msg_dict, custom_values=None):
# OVERRIDE
# Add custom behavior when receiving a new invoice through the mail's gateway.
- if custom_values.get('type', 'entry') not in ('out_invoice', 'in_invoice'):
+ if custom_values.get('move_type', 'entry') not in ('out_invoice', 'in_invoice'):
return False
def is_internal_partner(partner):
@@ -2083,7 +2084,7 @@ class AccountMove(models.Model):
'invoice_source_email': from_mail_addresses[0],
'partner_id': partners and partners[0].id or False,
}
- move_ctx = self.with_context(default_type=custom_values['type'], default_journal_id=custom_values['journal_id'])
+ move_ctx = self.with_context(default_move_type=custom_values['move_type'], default_journal_id=custom_values['journal_id'])
move = super(AccountMove, move_ctx).message_new(msg_dict, custom_values=values)
# Assign followers.
@@ -2176,7 +2177,7 @@ class AccountMove(models.Model):
:rtype bool
'''
self.ensure_one()
- return self.type == 'out_invoice' and not self.invoice_payment_ref
+ return self.move_type == 'out_invoice' and not self.invoice_payment_ref
def action_reverse(self):
action = self.env.ref('account.action_view_account_move_reversal').read()[0]
@@ -2323,7 +2324,7 @@ class AccountMove(models.Model):
.action_register_payment()
def action_switch_invoice_into_refund_credit_note(self):
- if any(move.type not in ('in_invoice', 'out_invoice') for move in self):
+ if any(move.move_type not in ('in_invoice', 'out_invoice') for move in self):
raise ValidationError(_("This action isn't available for this document."))
for move in self:
@@ -2342,7 +2343,7 @@ class AccountMove(models.Model):
'credit' : line_vals['debit']
})
move.write({
- 'type': move.type.replace('invoice', 'refund'),
+ 'move_type': move.move_type.replace('invoice', 'refund'),
'invoice_line_ids' : [(5, 0, 0)],
'invoice_partner_bank_id': False,
})
@@ -2696,7 +2697,7 @@ class AccountMoveLine(models.Model):
product=product or self.product_id,
partner=partner or self.partner_id,
taxes=taxes or self.tax_ids,
- move_type=move_type or self.move_id.type,
+ move_type=move_type or self.move_id.move_type,
)
@api.model
@@ -2733,7 +2734,7 @@ class AccountMoveLine(models.Model):
self.ensure_one()
return self._get_fields_onchange_subtotal_model(
price_subtotal=price_subtotal or self.price_subtotal,
- move_type=move_type or self.move_id.type,
+ move_type=move_type or self.move_id.move_type,
currency=currency or self.currency_id,
company=company or self.move_id.company_id,
date=date or self.move_id.date,
@@ -2781,7 +2782,7 @@ class AccountMoveLine(models.Model):
quantity=quantity or self.quantity,
discount=discount or self.discount,
balance=balance or self.balance,
- move_type=move_type or self.move_id.type,
+ move_type=move_type or self.move_id.move_type,
currency=currency or self.currency_id or self.move_id.currency_id,
taxes=taxes or self.tax_ids,
price_subtotal=price_subtotal or self.price_subtotal,
@@ -3247,13 +3248,13 @@ class AccountMoveLine(models.Model):
self.env['product.product'].browse(vals.get('product_id')),
partner,
taxes,
- move.type,
+ move.move_type,
).get('price_subtotal', 0.0)
vals.update(self._get_fields_onchange_balance_model(
vals.get('quantity', 0.0),
vals.get('discount', 0.0),
balance,
- move.type,
+ move.move_type,
currency,
taxes,
price_subtotal
@@ -3266,7 +3267,7 @@ class AccountMoveLine(models.Model):
self.env['product.product'].browse(vals.get('product_id')),
partner,
taxes,
- move.type,
+ move.move_type,
))
elif any(vals.get(field) for field in BUSINESS_FIELDS):
vals.update(self._get_price_total_and_subtotal_model(
@@ -3277,11 +3278,11 @@ class AccountMoveLine(models.Model):
self.env['product.product'].browse(vals.get('product_id')),
partner,
taxes,
- move.type,
+ move.move_type,
))
vals.update(self._get_fields_onchange_subtotal_model(
vals['price_subtotal'],
- move.type,
+ move.move_type,
currency,
move.company_id,
move.date,
@@ -3489,14 +3490,14 @@ class AccountMoveLine(models.Model):
if 'account_id' in default_fields \
and (self._context.get('journal_id') or self._context.get('default_journal_id')) \
and not values.get('account_id') \
- and self._context.get('default_type') in self.move_id.get_inbound_types():
+ and self._context.get('default_move_type') in self.move_id.get_inbound_types():
# Fill missing 'account_id'.
journal = self.env['account.journal'].browse(self._context.get('default_journal_id') or self._context['journal_id'])
values['account_id'] = journal.default_credit_account_id.id
elif 'account_id' in default_fields \
and (self._context.get('journal_id') or self._context.get('default_journal_id')) \
and not values.get('account_id') \
- and self._context.get('default_type') in self.move_id.get_outbound_types():
+ and self._context.get('default_move_type') in self.move_id.get_outbound_types():
# Fill missing 'account_id'.
journal = self.env['account.journal'].browse(self._context.get('default_journal_id') or self._context['journal_id'])
values['account_id'] = journal.default_debit_account_id.id
@@ -3654,7 +3655,7 @@ class AccountMoveLine(models.Model):
# Eventually create a journal entry to book the difference due to foreign currency's exchange rate that fluctuates
if to_balance and any([not float_is_zero(residual, precision_rounding=digits_rounding_precision) for aml, residual in to_balance.values()]):
if not self.env.context.get('no_exchange_difference'):
- exchange_move = self.env['account.move'].with_context(default_type='entry').create(
+ exchange_move = self.env['account.move'].with_context(default_move_type='entry').create(
self.env['account.full.reconcile']._prepare_exchange_diff_move(move_date=maxdate, company=amls[0].company_id))
part_reconcile = self.env['account.partial.reconcile']
for aml_to_balance, total in to_balance.values():
diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py
index 4d92913892c..36be7e08f95 100644
--- a/addons/account/models/account_payment.py
+++ b/addons/account/models/account_payment.py
@@ -111,14 +111,14 @@ class account_payment(models.Model):
if not invoices or any(invoice.state != 'posted' for invoice in invoices):
raise UserError(_("You can only register payments for open invoices"))
# Check if, in batch payments, there are not negative invoices and positive invoices
- dtype = invoices[0].type
+ dtype = invoices[0].move_type
for inv in invoices[1:]:
- if inv.type != dtype:
- if ((dtype == 'in_refund' and inv.type == 'in_invoice') or
- (dtype == 'in_invoice' and inv.type == 'in_refund')):
+ if inv.move_type != dtype:
+ if ((dtype == 'in_refund' and inv.move_type == 'in_invoice') or
+ (dtype == 'in_invoice' and inv.move_type == 'in_refund')):
raise UserError(_("You cannot register payments for vendor bills and supplier refunds at the same time."))
- if ((dtype == 'out_refund' and inv.type == 'out_invoice') or
- (dtype == 'out_invoice' and inv.type == 'out_refund')):
+ if ((dtype == 'out_refund' and inv.move_type == 'out_invoice') or
+ (dtype == 'out_invoice' and inv.move_type == 'out_refund')):
raise UserError(_("You cannot register payments for customer invoices and credit notes at the same time."))
amount = self._compute_payment_amount(invoices, invoices[0].currency_id, invoices[0].journal_id, rec.get('payment_date') or fields.Date.today())
@@ -127,7 +127,7 @@ class account_payment(models.Model):
'amount': abs(amount),
'payment_type': 'inbound' if amount > 0 else 'outbound',
'partner_id': invoices[0].commercial_partner_id.id,
- 'partner_type': MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].type],
+ 'partner_type': MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].move_type],
'communication': invoices[0].invoice_payment_ref or invoices[0].ref or invoices[0].name,
'invoice_ids': [(6, 0, invoices.ids)],
})
@@ -299,13 +299,13 @@ class account_payment(models.Model):
if not invoices:
return 0.0
- self.env['account.move'].flush(['type', 'currency_id'])
+ self.env['account.move'].flush(['move_type', 'currency_id'])
self.env['account.move.line'].flush(['amount_residual', 'amount_residual_currency', 'move_id', 'account_id'])
self.env['account.account'].flush(['user_type_id'])
self.env['account.account.type'].flush(['type'])
self._cr.execute('''
SELECT
- move.type AS type,
+ move.move_type AS type,
move.currency_id AS currency_id,
SUM(line.amount_residual) AS amount_residual,
SUM(line.amount_residual_currency) AS residual_currency
@@ -315,7 +315,7 @@ class account_payment(models.Model):
LEFT JOIN account_account_type account_type ON account_type.id = account.user_type_id
WHERE move.id IN %s
AND account_type.type IN ('receivable', 'payable')
- GROUP BY move.id, move.type
+ GROUP BY move.id, move.move_type
''', [tuple(invoices.ids)])
query_res = self._cr.dictfetchall()
@@ -637,7 +637,7 @@ class account_payment(models.Model):
If invoice_ids is not empty, there will be one reconcilable move line per invoice to reconcile with.
If the payment is a transfer, a second journal entry is created in the destination journal to receive money from the transfer account.
"""
- AccountMove = self.env['account.move'].with_context(default_type='entry')
+ AccountMove = self.env['account.move'].with_context(default_move_type='entry')
for rec in self:
if rec.state != 'draft':
@@ -790,7 +790,7 @@ class payment_register(models.TransientModel):
'amount': abs(amount),
'currency_id': invoices[0].currency_id.id,
'partner_id': invoices[0].commercial_partner_id.id,
- 'partner_type': MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].type],
+ 'partner_type': MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].move_type],
'partner_bank_account_id': invoices[0].invoice_partner_bank_id.id,
}
return values
@@ -803,7 +803,7 @@ class payment_register(models.TransientModel):
grouped = defaultdict(lambda: self.env["account.move"])
for inv in self.invoice_ids:
if self.group_payment:
- grouped[(inv.commercial_partner_id, inv.currency_id, inv.invoice_partner_bank_id, MAP_INVOICE_TYPE_PARTNER_TYPE[inv.type])] += inv
+ grouped[(inv.commercial_partner_id, inv.currency_id, inv.invoice_partner_bank_id, MAP_INVOICE_TYPE_PARTNER_TYPE[inv.move_type])] += inv
else:
grouped[inv.id] += inv
return [self._prepare_payment_vals(invoices) for invoices in grouped.values()]
diff --git a/addons/account/models/company.py b/addons/account/models/company.py
index 1d5a47dc474..49623dde125 100644
--- a/addons/account/models/company.py
+++ b/addons/account/models/company.py
@@ -451,7 +451,7 @@ class ResCompany(models.Model):
"\nPlease go to Configuration > Journals.")
raise RedirectWarning(msg, action.id, _("Go to the journal configuration"))
- sample_invoice = self.env['account.move'].with_context(default_type='out_invoice', default_journal_id=journal.id).create({
+ sample_invoice = self.env['account.move'].with_context(default_move_type='out_invoice', default_journal_id=journal.id).create({
'invoice_payment_ref': _('Sample invoice'),
'partner_id': partner.id,
'invoice_line_ids': [
diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py
index e9fbcfc910a..6914ec80d41 100644
--- a/addons/account/models/partner.py
+++ b/addons/account/models/partner.py
@@ -311,7 +311,7 @@ class ResPartner(models.Model):
# generate where clause to include multicompany rules
where_query = account_invoice_report._where_calc([
('partner_id', 'in', all_partner_ids), ('state', 'not in', ['draft', 'cancel']),
- ('type', 'in', ('out_invoice', 'out_refund'))
+ ('move_type', 'in', ('out_invoice', 'out_refund'))
])
account_invoice_report._apply_ir_rules(where_query, 'read')
from_clause, where_clause, where_clause_params = where_query.get_sql()
@@ -465,11 +465,11 @@ class ResPartner(models.Model):
self.ensure_one()
action = self.env.ref('account.action_move_out_invoice_type').read()[0]
action['domain'] = [
- ('type', 'in', ('out_invoice', 'out_refund')),
+ ('move_type', 'in', ('out_invoice', 'out_refund')),
('state', '=', 'posted'),
('partner_id', 'child_of', self.id),
]
- action['context'] = {'default_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale', 'search_default_unpaid': 1}
+ action['context'] = {'default_move_type':'out_invoice', 'move_type':'out_invoice', 'journal_type': 'sale', 'search_default_unpaid': 1}
return action
def can_edit_vat(self):
@@ -478,7 +478,7 @@ class ResPartner(models.Model):
if not can_edit_vat:
return can_edit_vat
has_invoice = self.env['account.move'].search([
- ('type', 'in', ['out_invoice', 'out_refund']),
+ ('move_type', 'in', ['out_invoice', 'out_refund']),
('partner_id', 'child_of', self.commercial_partner_id.id),
('state', '=', 'posted')
], limit=1)
diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py
index 3ef358a9093..30df05d623d 100644
--- a/addons/account/report/account_invoice_report.py
+++ b/addons/account/report/account_invoice_report.py
@@ -21,7 +21,7 @@ class AccountInvoiceReport(models.Model):
commercial_partner_id = fields.Many2one('res.partner', string='Partner Company', help="Commercial Entity")
country_id = fields.Many2one('res.country', string="Country")
invoice_user_id = fields.Many2one('res.users', string='Salesperson', readonly=True)
- type = fields.Selection([
+ move_type = fields.Selection([
('out_invoice', 'Customer Invoice'),
('in_invoice', 'Vendor Bill'),
('out_refund', 'Customer Credit Note'),
@@ -58,7 +58,7 @@ class AccountInvoiceReport(models.Model):
_depends = {
'account.move': [
- 'name', 'state', 'type', 'partner_id', 'invoice_user_id', 'fiscal_position_id',
+ 'name', 'state', 'move_type', 'partner_id', 'invoice_user_id', 'fiscal_position_id',
'invoice_date', 'invoice_date_due', 'invoice_payment_term_id', 'invoice_partner_bank_id',
],
'account.move.line': [
@@ -88,7 +88,7 @@ class AccountInvoiceReport(models.Model):
line.partner_id AS commercial_partner_id,
move.name,
move.state,
- move.type,
+ move.move_type,
move.partner_id,
move.invoice_user_id,
move.fiscal_position_id,
@@ -148,7 +148,7 @@ class AccountInvoiceReport(models.Model):
@api.model
def _where(self):
return '''
- WHERE move.type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')
+ WHERE move.move_type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')
AND line.account_id IS NOT NULL
AND NOT line.exclude_from_invoice_tab
'''
@@ -168,7 +168,7 @@ class AccountInvoiceReport(models.Model):
line.partner_id,
move.name,
move.state,
- move.type,
+ move.move_type,
move.amount_residual_signed,
move.amount_total_signed,
move.partner_id,
diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml
index 51c265aeaa6..ce9f4b59310 100644
--- a/addons/account/report/account_invoice_report_view.xml
+++ b/addons/account/report/account_invoice_report_view.xml
@@ -49,7 +49,7 @@
Create a journal entry
@@ -1278,8 +1278,8 @@
Create a customer invoice
@@ -1295,8 +1295,8 @@
Create a credit note
@@ -1313,8 +1313,8 @@
Create a vendor bill
@@ -1330,8 +1330,8 @@
Create a vendor credit note
@@ -1347,8 +1347,8 @@
Create a new sales receipt
@@ -1365,8 +1365,8 @@
Register a new purchase receipt
diff --git a/addons/account/views/account_portal_templates.xml b/addons/account/views/account_portal_templates.xml
index 5be631c873a..620c4ff33e5 100644
--- a/addons/account/views/account_portal_templates.xml
+++ b/addons/account/views/account_portal_templates.xml
@@ -64,7 +64,7 @@
Cancelled
-
+
@@ -89,7 +89,7 @@
-
- Invoice
- Draft Invoice
- Cancelled Invoice
- Credit Note
- Vendor Credit Note
- Vendor Bill
+ Invoice
+ Draft Invoice
+ Cancelled Invoice
+ Credit Note
+ Vendor Credit Note
+ Vendor Bill
@@ -26,7 +26,7 @@
Invoice Date:
+
Please use the following communication for your payment :
@@ -219,7 +219,7 @@