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 @@ By Credit Note account.invoice.report - [('type', '=', 'out_refund')] + [('move_type', '=', 'out_refund')] {'group_by': ['invoice_date:month', 'invoice_user_id']} @@ -73,11 +73,11 @@ - - + + - - + + diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml index 3f03405a485..27be8b04a80 100644 --- a/addons/account/security/account_security.xml +++ b/addons/account/security/account_security.xml @@ -231,14 +231,14 @@ Portal Personal Account Invoices - [('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('message_partner_ids','child_of',[user.commercial_partner_id.id])] + [('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('message_partner_ids','child_of',[user.commercial_partner_id.id])] Portal Invoice Lines - [('move_id.type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('move_id.message_partner_ids','child_of',[user.commercial_partner_id.id])] + [('move_id.move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('move_id.message_partner_ids','child_of',[user.commercial_partner_id.id])] diff --git a/addons/account/static/src/js/bills_tree_upload.js b/addons/account/static/src/js/bills_tree_upload.js index 3e36b495e1a..2894b86844a 100644 --- a/addons/account/static/src/js/bills_tree_upload.js +++ b/addons/account/static/src/js/bills_tree_upload.js @@ -101,7 +101,7 @@ odoo.define('account.dashboard.kanban', function (require) { }), /** * We override _onUpload (from the upload bill mixin) to pass default_journal_id - * and default_type in context. + * and default_move_type in context. * * @override */ @@ -109,9 +109,9 @@ odoo.define('account.dashboard.kanban', function (require) { var kanbanRecord = $(event.currentTarget).closest('.o_kanban_record').data('record'); this.initialState.context['default_journal_id'] = kanbanRecord.id; if ($(event.currentTarget).attr('journal_type') == 'sale') { - this.initialState.context['default_type'] = 'out_invoice' + this.initialState.context['default_move_type'] = 'out_invoice' } else if ($(event.currentTarget).attr('journal_type') == 'purchase') { - this.initialState.context['default_type'] = 'in_invoice' + this.initialState.context['default_move_type'] = 'in_invoice' } UploadBillMixin._onUpload.apply(this, arguments); } diff --git a/addons/account/static/src/js/tax_group.js b/addons/account/static/src/js/tax_group.js index 9f9efe41f38..5c6735aaa2b 100644 --- a/addons/account/static/src/js/tax_group.js +++ b/addons/account/static/src/js/tax_group.js @@ -37,7 +37,7 @@ odoo.define('account.tax_group', function (require) { var creditAmount = 0; var amount_currency = 0; if (line_id.data.currency_id) { // If multi currency enable - if (this.record.data.type === "in_invoice") { + if (this.record.data.move_type === "in_invoice") { amount_currency = line_id.data.amount_currency - deltaAmount; } else { amount_currency = line_id.data.amount_currency + deltaAmount; @@ -45,7 +45,7 @@ odoo.define('account.tax_group', function (require) { } else { var balance = line_id.data.price_subtotal; balance -= deltaAmount; - if (this.record.data.type === "in_invoice") { // For vendor bill + if (this.record.data.move_type === "in_invoice") { // For vendor bill if (balance > 0) { debitAmount = balance; } else if (balance < 0) { @@ -76,7 +76,7 @@ odoo.define('account.tax_group', function (require) { * @returns boolean (true if the invoice is a purchase document) */ _isPurchaseDocument: function () { - return this.record.data.type === "in_invoice" || this.record.data.type === 'in_refund'; + return this.record.data.move_type === "in_invoice" || this.record.data.move_type === 'in_refund'; }, /** diff --git a/addons/account/tests/common.py b/addons/account/tests/common.py index 9f585044054..e047303c0fb 100644 --- a/addons/account/tests/common.py +++ b/addons/account/tests/common.py @@ -901,7 +901,7 @@ class AccountTestInvoicingCommon(SavepointCase): @classmethod def init_invoice(cls, move_type): - move_form = Form(cls.env['account.move'].with_context(default_type=move_type)) + move_form = Form(cls.env['account.move'].with_context(default_move_type=move_type)) move_form.invoice_date = fields.Date.from_string('2019-01-01') move_form.partner_id = cls.partner_a with move_form.invoice_line_ids.new() as line_form: @@ -1080,7 +1080,7 @@ class TestAccountReconciliationCommon(AccountTestCommon): date_invoice = date_invoice or time.strftime('%Y') + '-07-01' invoice_vals = { - 'type': type, + 'move_type': type, 'partner_id': partner_id or self.partner_agrolait_id, 'invoice_date': date_invoice, 'date': date_invoice, @@ -1098,7 +1098,7 @@ class TestAccountReconciliationCommon(AccountTestCommon): if currency_id: invoice_vals['currency_id'] = currency_id - invoice = self.env['account.move'].with_context(default_type=type).create(invoice_vals) + invoice = self.env['account.move'].with_context(default_move_type=type).create(invoice_vals) if auto_validate: invoice.post() return invoice diff --git a/addons/account/tests/test_account_account.py b/addons/account/tests/test_account_account.py index 61ed7666cbb..e9d4bc34a4c 100644 --- a/addons/account/tests/test_account_account.py +++ b/addons/account/tests/test_account_account.py @@ -21,7 +21,7 @@ class TestAccountAccount(AccountTestInvoicingCommon): ''' Ensure you can't change the company of an account.account if there are some journal entries ''' self.env['account.move'].create({ - 'type': 'entry', + 'move_type': 'entry', 'date': '2019-01-01', 'line_ids': [ (0, 0, { diff --git a/addons/account/tests/test_account_analytic.py b/addons/account/tests/test_account_analytic.py index c8251f71838..b4cc71be949 100644 --- a/addons/account/tests/test_account_analytic.py +++ b/addons/account/tests/test_account_analytic.py @@ -31,7 +31,7 @@ class TestAccountAnalyticAccount(AccountTestInvoicingCommon): ''' Ensure you can't change the company of an account.analytic.account if there are some journal entries ''' self.env['account.move'].create({ - 'type': 'entry', + 'move_type': 'entry', 'date': '2019-01-01', 'line_ids': [ (0, 0, { diff --git a/addons/account/tests/test_account_invoice_report.py b/addons/account/tests/test_account_invoice_report.py index a794b2a4b6b..d356353303c 100644 --- a/addons/account/tests/test_account_invoice_report.py +++ b/addons/account/tests/test_account_invoice_report.py @@ -16,7 +16,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon): cls.invoices = cls.env['account.move'].create([ { - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': cls.partner_a.id, 'invoice_date': fields.Date.from_string('2016-01-01'), 'currency_id': cls.currency_data['currency'].id, @@ -34,7 +34,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon): ] }, { - 'type': 'out_receipt', + 'move_type': 'out_receipt', 'invoice_date': fields.Date.from_string('2016-01-01'), 'currency_id': cls.currency_data['currency'].id, 'invoice_line_ids': [ @@ -46,7 +46,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon): ] }, { - 'type': 'out_refund', + 'move_type': 'out_refund', 'partner_id': cls.partner_a.id, 'invoice_date': fields.Date.from_string('2017-01-01'), 'currency_id': cls.currency_data['currency'].id, @@ -59,7 +59,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon): ] }, { - 'type': 'in_invoice', + 'move_type': 'in_invoice', 'partner_id': cls.partner_a.id, 'invoice_date': fields.Date.from_string('2016-01-01'), 'currency_id': cls.currency_data['currency'].id, @@ -72,7 +72,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon): ] }, { - 'type': 'in_receipt', + 'move_type': 'in_receipt', 'partner_id': cls.partner_a.id, 'invoice_date': fields.Date.from_string('2016-01-01'), 'currency_id': cls.currency_data['currency'].id, @@ -85,7 +85,7 @@ class TestAccountInvoiceReport(AccountTestInvoicingCommon): ] }, { - 'type': 'in_refund', + 'move_type': 'in_refund', 'partner_id': cls.partner_a.id, 'invoice_date': fields.Date.from_string('2017-01-01'), 'currency_id': cls.currency_data['currency'].id, diff --git a/addons/account/tests/test_account_journal.py b/addons/account/tests/test_account_journal.py index 10d2c58d9e5..d2b287ca5b7 100644 --- a/addons/account/tests/test_account_journal.py +++ b/addons/account/tests/test_account_journal.py @@ -21,7 +21,7 @@ class TestAccountJournal(AccountTestInvoicingCommon): ''' Ensure you can't change the company of an account.journal if there are some journal entries ''' self.env['account.move'].create({ - 'type': 'entry', + 'move_type': 'entry', 'date': '2019-01-01', 'journal_id': self.company_data['default_journal_sale'].id, }) diff --git a/addons/account/tests/test_account_journal_dashboard.py b/addons/account/tests/test_account_journal_dashboard.py index cb9ffb95375..c994c71298e 100644 --- a/addons/account/tests/test_account_journal_dashboard.py +++ b/addons/account/tests/test_account_journal_dashboard.py @@ -30,7 +30,7 @@ class TestAccountJournalDashboard(AccountTestUsersCommon): }) invoice = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'journal_id': journal.id, 'partner_id': res_partner_3.id, 'invoice_date': date_invoice, @@ -44,7 +44,7 @@ class TestAccountJournalDashboard(AccountTestUsersCommon): })] }) refund = self.env['account.move'].create({ - 'type': 'out_refund', + 'move_type': 'out_refund', 'journal_id': journal.id, 'partner_id': res_partner_3.id, 'invoice_date': '2019-01-21', diff --git a/addons/account/tests/test_account_move_entry.py b/addons/account/tests/test_account_move_entry.py index 8a608c9c407..92159a3e506 100644 --- a/addons/account/tests/test_account_move_entry.py +++ b/addons/account/tests/test_account_move_entry.py @@ -20,7 +20,7 @@ class TestAccountMove(AccountTestInvoicingCommon): tax_repartition_line = cls.company_data['default_tax_sale'].invoice_repartition_line_ids\ .filtered(lambda line: line.repartition_type == 'tax') cls.test_move = cls.env['account.move'].create({ - 'type': 'entry', + 'move_type': 'entry', 'date': fields.Date.from_string('2016-01-01'), 'line_ids': [ (0, None, { @@ -241,7 +241,7 @@ class TestAccountMove(AccountTestInvoicingCommon): def test_misc_draft_reconciled_entries_1(self): draft_moves = self.env['account.move'].create([ { - 'type': 'entry', + 'move_type': 'entry', 'line_ids': [ (0, None, { 'name': 'move 1 receivable line', @@ -258,7 +258,7 @@ class TestAccountMove(AccountTestInvoicingCommon): ] }, { - 'type': 'entry', + 'move_type': 'entry', 'line_ids': [ (0, None, { 'name': 'move 2 receivable line', diff --git a/addons/account/tests/test_account_move_in_invoice.py b/addons/account/tests/test_account_move_in_invoice.py index a1e9b0f9ad1..612fbab8243 100644 --- a/addons/account/tests/test_account_move_in_invoice.py +++ b/addons/account/tests/test_account_move_in_invoice.py @@ -222,7 +222,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): 'supplier_taxes_id': [(6, 0, tax_price_include.ids)], }) - move_form = Form(self.env['account.move'].with_context(default_type='in_invoice')) + move_form = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) move_form.partner_id = self.partner_a move_form.invoice_date = fields.Date.from_string('2019-01-01') move_form.currency_id = self.currency_data['currency'] @@ -367,7 +367,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): 'supplier_taxes_id': [(6, 0, tax_price_include_1.ids)], }) - move_form = Form(self.env['account.move'].with_context(default_type='in_invoice')) + move_form = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) move_form.partner_id = self.partner_a move_form.invoice_date = fields.Date.from_string('2019-01-01') move_form.currency_id = self.currency_data['currency'] @@ -1333,7 +1333,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): def test_in_invoice_create_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'in_invoice', + 'move_type': 'in_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -1383,7 +1383,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): def test_in_invoice_write_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'in_invoice', + 'move_type': 'in_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -1445,7 +1445,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): def test_in_invoice_switch_in_refund_1(self): # Test creating an account_move with an in_invoice_type and switch it in an in_refund. move = self.env['account.move'].create({ - 'type': 'in_invoice', + 'move_type': 'in_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -1457,7 +1457,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): }) move.action_switch_invoice_into_refund_credit_note() - self.assertRecordValues(move, [{'type': 'in_refund'}]) + self.assertRecordValues(move, [{'move_type': 'in_refund'}]) self.assertInvoiceValues(move, [ { **self.product_line_vals_1, @@ -1506,7 +1506,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): modified_product_line_vals_2 = self.product_line_vals_2.copy() modified_product_line_vals_2.update({'quantity': -modified_product_line_vals_2['quantity']}) move = self.env['account.move'].create({ - 'type': 'in_invoice', + 'move_type': 'in_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -1577,7 +1577,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): }) move.action_switch_invoice_into_refund_credit_note() - self.assertRecordValues(move, [{'type': 'in_refund'}]) + self.assertRecordValues(move, [{'move_type': 'in_refund'}]) self.assertInvoiceValues(move, [ { **self.product_line_vals_1, @@ -1624,7 +1624,7 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): def test_in_invoice_change_period_accrual_1(self): move = self.env['account.move'].create({ - 'type': 'in_invoice', + 'move_type': 'in_invoice', 'date': '2017-01-01', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2017-01-01'), diff --git a/addons/account/tests/test_account_move_in_refund.py b/addons/account/tests/test_account_move_in_refund.py index 7c3c600ce3d..83740d9667b 100644 --- a/addons/account/tests/test_account_move_in_refund.py +++ b/addons/account/tests/test_account_move_in_refund.py @@ -824,7 +824,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon): def test_in_refund_create_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'in_refund', + 'move_type': 'in_refund', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -874,7 +874,7 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon): def test_in_refund_write_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'in_refund', + 'move_type': 'in_refund', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, diff --git a/addons/account/tests/test_account_move_out_invoice.py b/addons/account/tests/test_account_move_out_invoice.py index 524da8697f3..508ba4bec0b 100644 --- a/addons/account/tests/test_account_move_out_invoice.py +++ b/addons/account/tests/test_account_move_out_invoice.py @@ -224,7 +224,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): 'taxes_id': [(6, 0, tax_price_include.ids)], }) - move_form = Form(self.env['account.move'].with_context(default_type='out_invoice')) + move_form = Form(self.env['account.move'].with_context(default_move_type='out_invoice')) move_form.partner_id = self.partner_a move_form.invoice_date = fields.Date.from_string('2019-01-01') move_form.currency_id = self.currency_data['currency'] @@ -369,7 +369,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): 'taxes_id': [(6, 0, tax_price_include_1.ids)], }) - move_form = Form(self.env['account.move'].with_context(default_type='out_invoice')) + move_form = Form(self.env['account.move'].with_context(default_move_type='out_invoice')) move_form.partner_id = self.partner_a move_form.invoice_date = fields.Date.from_string('2019-01-01') move_form.currency_id = self.currency_data['currency'] @@ -1726,7 +1726,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): def test_out_invoice_create_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -1776,7 +1776,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): def test_out_invoice_write_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -1830,7 +1830,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): def test_out_invoice_write_2(self): ''' Ensure to not messing the invoice when writing a bad account type. ''' move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_line_ids': [ (0, None, self.product_line_vals_1), @@ -1857,7 +1857,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): with patch.object(fields.Date, 'today', lambda *args, **kwargs: frozen_today), patch.object(fields.Date, 'context_today', lambda *args, **kwargs: frozen_today): # Create an invoice with rate 1/3. move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2016-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -1943,7 +1943,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): ''' Check the date will be set automatically at the next available post date due to the tax lock date. ''' # Create an invoice with rate 1/3. move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2016-01-01'), 'date': fields.Date.from_string('2015-01-01'), @@ -2047,7 +2047,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): def test_out_invoice_switch_out_refund_1(self): # Test creating an account_move with an out_invoice_type and switch it in an out_refund. move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -2059,7 +2059,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): }) move.action_switch_invoice_into_refund_credit_note() - self.assertRecordValues(move, [{'type': 'out_refund'}]) + self.assertRecordValues(move, [{'move_type': 'out_refund'}]) self.assertInvoiceValues(move, [ { **self.product_line_vals_1, @@ -2108,7 +2108,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): modified_product_line_vals_2 = self.product_line_vals_2.copy() modified_product_line_vals_2.update({'quantity': -modified_product_line_vals_2['quantity']}) move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -2180,7 +2180,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): move.action_switch_invoice_into_refund_credit_note() - self.assertRecordValues(move, [{'type': 'out_refund'}]) + self.assertRecordValues(move, [{'move_type': 'out_refund'}]) self.assertInvoiceValues(move, [ { **self.product_line_vals_1, @@ -2227,7 +2227,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): def test_out_invoice_change_period_accrual_1(self): move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'date': '2017-01-01', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2017-01-01'), @@ -2361,7 +2361,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): }) invoice = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'invoice_payment_term_id': zero_balance_payment_term.id, diff --git a/addons/account/tests/test_account_move_out_refund.py b/addons/account/tests/test_account_move_out_refund.py index 8f9e9c0da8b..36474559266 100644 --- a/addons/account/tests/test_account_move_out_refund.py +++ b/addons/account/tests/test_account_move_out_refund.py @@ -807,7 +807,7 @@ class TestAccountMoveOutRefundOnchanges(AccountTestInvoicingCommon): def test_out_refund_create_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'out_refund', + 'move_type': 'out_refund', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, @@ -857,7 +857,7 @@ class TestAccountMoveOutRefundOnchanges(AccountTestInvoicingCommon): def test_out_refund_write_1(self): # Test creating an account_move with the least information. move = self.env['account.move'].create({ - 'type': 'out_refund', + 'move_type': 'out_refund', 'partner_id': self.partner_a.id, 'invoice_date': fields.Date.from_string('2019-01-01'), 'currency_id': self.currency_data['currency'].id, diff --git a/addons/account/tests/test_account_move_partner_count.py b/addons/account/tests/test_account_move_partner_count.py index de3d8ae7fa7..c20f5e428d6 100644 --- a/addons/account/tests/test_account_move_partner_count.py +++ b/addons/account/tests/test_account_move_partner_count.py @@ -30,7 +30,7 @@ class TestAccountMovePartnerCount(TransactionCase): }) self.move = self.env['account.move'].with_env(env).create({ 'partner_id': self.partner.id, - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'journal_id': self.journal.id, 'currency_id': self.env.user.company_id.currency_id.id, }) diff --git a/addons/account/tests/test_account_tax.py b/addons/account/tests/test_account_tax.py index 6a81294bcec..a0959fe177e 100644 --- a/addons/account/tests/test_account_tax.py +++ b/addons/account/tests/test_account_tax.py @@ -24,7 +24,7 @@ class TestAccountTax(AccountTestInvoicingCommon): self.company_data['default_tax_sale'].name = 'test_changing_account_company' self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'date': '2019-01-01', 'invoice_line_ids': [ (0, 0, { diff --git a/addons/account/tests/test_bank_statement_reconciliation.py b/addons/account/tests/test_bank_statement_reconciliation.py index a6782594c07..9910ead5728 100644 --- a/addons/account/tests/test_bank_statement_reconciliation.py +++ b/addons/account/tests/test_bank_statement_reconciliation.py @@ -57,7 +57,7 @@ class TestBankStatementReconciliation(AccountTestCommon): def create_invoice(self, amount): """ Return the move line that gets to be reconciled (the one in the receivable account) """ move = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner.id, 'invoice_line_ids': [(0, 0, { 'quantity': 1, diff --git a/addons/account/tests/test_invoice_taxes.py b/addons/account/tests/test_invoice_taxes.py index a297d7914f5..1e442a2d07d 100644 --- a/addons/account/tests/test_invoice_taxes.py +++ b/addons/account/tests/test_invoice_taxes.py @@ -50,7 +50,7 @@ class TestInvoiceTaxes(AccountTestCommon, SavepointCaseWithUserDemo): :param taxes_per_line: A list of tuple (price_unit, account.tax recordset) ''' - self_ctx = self.env['account.move'].with_context(default_type=inv_type) + self_ctx = self.env['account.move'].with_context(default_move_type=inv_type) invoice_form = Form(self_ctx) invoice_form.partner_id = self.partner_demo diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 08235a14369..dbf4d6f789f 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -76,7 +76,7 @@ class TestPayment(AccountTestCommon): def create_invoice(self, amount=100, type='out_invoice', currency_id=None, partner=None, account_id=None): """ Returns an open invoice """ invoice = self.env['account.move'].create({ - 'type': type, + 'move_type': type, 'partner_id': partner or self.partner_agrolait.id, 'currency_id': currency_id or self.currency_eur_id, 'invoice_date': time.strftime('%Y') + '-06-26', @@ -596,7 +596,7 @@ class TestPayment(AccountTestCommon): 'company_id': self.env.ref('base.main_company').id }) inv1 = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_agrolait.id, 'currency_id': self.currency_usd_id, 'invoice_date': time.strftime('%Y') + '-01-01', diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index d28a673c0e7..424a96b88de 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -132,8 +132,8 @@ class TestReconciliationExec(TestAccountReconciliationCommon): def test_statement_euro_invoice_usd_transaction_euro_full(self): # Create a customer invoice of 50 USD. partner = self.env['res.partner'].create({'name': 'test'}) - move = self.env['account.move'].with_context(default_type='out_invoice').create({ - 'type': 'out_invoice', + move = self.env['account.move'].with_context(default_move_type='out_invoice').create({ + 'move_type': 'out_invoice', 'partner_id': partner.id, 'invoice_date': '%s-07-01' % time.strftime('%Y'), 'date': '%s-07-01' % time.strftime('%Y'), @@ -204,7 +204,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon): 'currency_id': self.currency_usd_id, 'name': 'Foreign invoice with exchange gain', 'account_id': self.account_rcv_id, - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'invoice_date': time.strftime('%Y-%m-%d'), 'date': time.strftime('%Y-%m-%d'), 'journal_id': self.bank_journal_usd_id, @@ -502,8 +502,8 @@ class TestReconciliationExec(TestAccountReconciliationCommon): 'company_id': self.company.id}) # Preparing Invoices (from vendor) - invoice_a = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', + invoice_a = self.env['account.move'].with_context(default_move_type='in_invoice').create({ + 'move_type': 'in_invoice', 'partner_id': self.partner_agrolait_id, 'currency_id': self.currency_usd_id, 'invoice_date': '%s-07-01' % time.strftime('%Y'), @@ -512,8 +512,8 @@ class TestReconciliationExec(TestAccountReconciliationCommon): (0, 0, {'product_id': self.product.id, 'quantity': 1, 'price_unit': 50.0}) ], }) - invoice_b = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', + invoice_b = self.env['account.move'].with_context(default_move_type='in_invoice').create({ + 'move_type': 'in_invoice', 'partner_id': self.partner_agrolait_id, 'currency_id': self.currency_usd_id, 'invoice_date': '%s-08-01' % time.strftime('%Y'), @@ -811,8 +811,8 @@ class TestReconciliationExec(TestAccountReconciliationCommon): 'rate': 2, }) - invoice_cust_1 = self.env['account.move'].with_context(default_type='out_invoice').create({ - 'type': 'out_invoice', + invoice_cust_1 = self.env['account.move'].with_context(default_move_type='out_invoice').create({ + 'move_type': 'out_invoice', 'partner_id': self.partner_agrolait_id, 'invoice_date': '%s-01-01' % time.strftime('%Y'), 'date': '%s-01-01' % time.strftime('%Y'), @@ -1650,7 +1650,7 @@ class TestReconciliationExec(TestAccountReconciliationCommon): 'company_id': self.company.id, }) - move_form = Form(self.env['account.move'].with_context(default_type='out_invoice')) + move_form = Form(self.env['account.move'].with_context(default_move_type='out_invoice')) move_form.partner_id = self.partner_agrolait move_form.currency_id = self.env.ref('base.USD') move_form.invoice_date = time.strftime('%Y') + '-07-01' diff --git a/addons/account/tests/test_reconciliation_matching_rules.py b/addons/account/tests/test_reconciliation_matching_rules.py index 639153fbf47..82091b5c1fa 100644 --- a/addons/account/tests/test_reconciliation_matching_rules.py +++ b/addons/account/tests/test_reconciliation_matching_rules.py @@ -99,7 +99,7 @@ class TestReconciliationMatchingRules(AccountTestCommon): @classmethod def _create_invoice_line(cls, amount, partner, type): ''' Create an invoice on the fly.''' - invoice_form = Form(cls.env['account.move'].with_context(default_type=type, default_invoice_date='2019-09-01', default_date='2019-09-01')) + invoice_form = Form(cls.env['account.move'].with_context(default_move_type=type, default_invoice_date='2019-09-01', default_date='2019-09-01')) invoice_form.partner_id = partner with invoice_form.invoice_line_ids.new() as invoice_line_form: invoice_line_form.name = 'xxxx' diff --git a/addons/account/tests/test_tax_report.py b/addons/account/tests/test_tax_report.py index 15553e0ddb2..087f99bbcb7 100644 --- a/addons/account/tests/test_tax_report.py +++ b/addons/account/tests/test_tax_report.py @@ -158,7 +158,7 @@ class TaxReportTest(AccountTestInvoicingCommon): }) test_invoice = self.env['account.move'].create({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': self.partner_a.id, 'date': '1992-12-22', 'invoice_line_ids': [ diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 46703a76814..8265d8cf357 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -404,13 +404,13 @@ - - - - + + + + - - + + @@ -421,7 +421,7 @@ - + @@ -483,33 +483,33 @@ + attrs="{'invisible': ['|', ('payment_state', '!=', 'paid'), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': ['|', ('payment_state', '!=', 'in_payment'), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': ['|', ('payment_state', '!=', 'partial'), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> @@ -563,7 +563,7 @@ - + @@ -578,7 +578,7 @@
- +

Draft

@@ -594,21 +594,21 @@
+ attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/>
@@ -616,32 +616,32 @@
+ attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/>