diff options
117 files changed, 532 insertions, 530 deletions
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 @@ <record id="filter_invoice_refund" model="ir.filters"> <field name="name">By Credit Note</field> <field name="model_id">account.invoice.report</field> - <field name="domain">[('type', '=', 'out_refund')]</field> + <field name="domain">[('move_type', '=', 'out_refund')]</field> <field name="user_id" eval="False"/> <field name="context">{'group_by': ['invoice_date:month', 'invoice_user_id']}</field> </record> @@ -73,11 +73,11 @@ <filter string="To Invoice" name="toinvoice" domain="[('state','=','draft')]" help = "Draft Invoices"/> <filter string="Invoiced" name="current" domain="[('state','not in', ('draft','cancel'))]"/> <separator/> - <filter string="Customers" name="customer" domain="['|', ('type','=','out_invoice'),('type','=','out_refund')]"/> - <filter string="Vendors" name="supplier" domain="['|', ('type','=','in_invoice'),('type','=','in_refund')]"/> + <filter string="Customers" name="customer" domain="['|', ('move_type','=','out_invoice'),('move_type','=','out_refund')]"/> + <filter string="Vendors" name="supplier" domain="['|', ('move_type','=','in_invoice'),('move_type','=','in_refund')]"/> <separator/> - <filter string="Invoices" name="invoice" domain="['|', ('type','=','out_invoice'),('type','=','in_invoice')]"/> - <filter string="Credit Notes" name="creditnote" domain="['|', ('type','=','out_refund'),('type','=','in_refund')]"/> + <filter string="Invoices" name="invoice" domain="['|', ('move_type','=','out_invoice'),('move_type','=','in_invoice')]"/> + <filter string="Credit Notes" name="creditnote" domain="['|', ('move_type','=','out_refund'),('move_type','=','in_refund')]"/> <field name="partner_id" operator="child_of"/> <field name="invoice_user_id" /> <field name="product_id" /> 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 @@ <record id="account_invoice_rule_portal" model="ir.rule"> <field name="name">Portal Personal Account Invoices</field> <field name="model_id" ref="account.model_account_move"/> - <field name="domain_force">[('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('message_partner_ids','child_of',[user.commercial_partner_id.id])]</field> + <field name="domain_force">[('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('message_partner_ids','child_of',[user.commercial_partner_id.id])]</field> <field name="groups" eval="[(4, ref('base.group_portal'))]"/> </record> <record id="account_invoice_line_rule_portal" model="ir.rule"> <field name="name">Portal Invoice Lines</field> <field name="model_id" ref="account.model_account_move_line"/> - <field name="domain_force">[('move_id.type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('move_id.message_partner_ids','child_of',[user.commercial_partner_id.id])]</field> + <field name="domain_force">[('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])]</field> <field name="groups" eval="[(4, ref('base.group_portal'))]"/> </record> 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 @@ <field name="name"/> <field name="partner_id" invisible="1"/> <field name="invoice_source_email" invisible="1"/> - <field name="invoice_partner_display_name" invisible="context.get('default_type') not in ('in_invoice', 'in_refund','in_receipt')" groups="base.group_user" string="Vendor" /> - <field name="invoice_partner_display_name" invisible="context.get('default_type') not in ('out_invoice', 'out_refund','out_receipt')" groups="base.group_user" string="Customer" /> - <field name="invoice_date" optional="show" invisible="context.get('default_type') not in ('in_invoice', 'in_refund','in_receipt')" string="Bill Date"/> - <field name="invoice_date" optional="show" invisible="context.get('default_type') not in ('out_invoice', 'out_refund','out_receipt')" string="Invoice Date"/> + <field name="invoice_partner_display_name" invisible="context.get('default_move_type') not in ('in_invoice', 'in_refund','in_receipt')" groups="base.group_user" string="Vendor" /> + <field name="invoice_partner_display_name" invisible="context.get('default_move_type') not in ('out_invoice', 'out_refund','out_receipt')" groups="base.group_user" string="Customer" /> + <field name="invoice_date" optional="show" invisible="context.get('default_move_type') not in ('in_invoice', 'in_refund','in_receipt')" string="Bill Date"/> + <field name="invoice_date" optional="show" invisible="context.get('default_move_type') not in ('out_invoice', 'out_refund','out_receipt')" string="Invoice Date"/> <field name="invoice_origin" optional="hide" string="Source Document"/> - <field name="invoice_payment_ref" optional="hide" invisible="context.get('default_type') in ('out_invoice', 'out_refund','out_receipt')"/> - <field name="invoice_user_id" optional="hide" invisible="context.get('default_type') not in ('out_invoice', 'out_refund','out_receipt')" string="Sales Person"/> + <field name="invoice_payment_ref" optional="hide" invisible="context.get('default_move_type') in ('out_invoice', 'out_refund','out_receipt')"/> + <field name="invoice_user_id" optional="hide" invisible="context.get('default_move_type') not in ('out_invoice', 'out_refund','out_receipt')" string="Sales Person"/> <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" optional="show"/> <field name="invoice_date_due" optional="show"/> <field name="amount_untaxed_signed" string="Tax Excluded" sum="Total" optional="show"/> @@ -421,7 +421,7 @@ <field name="company_currency_id" invisible="1"/> <field name="state" optional="hide"/> <field name="payment_state"/> - <field name="type" invisible="context.get('default_type', True)"/> + <field name="move_type" invisible="context.get('default_move_type', True)"/> </tree> </field> </record> @@ -483,33 +483,33 @@ <button name="action_invoice_sent" type="object" string="Send & Print" - attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('invoice_sent', '=', True), ('type', 'not in', ('out_invoice', 'out_refund'))]}" + attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('invoice_sent', '=', True), ('move_type', 'not in', ('out_invoice', 'out_refund'))]}" class="oe_highlight" groups="account.group_account_invoice"/> <button name="action_invoice_sent" type="object" string="Send & Print" - attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('invoice_sent', '=', False), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}" + attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('invoice_sent', '=', False), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}" groups="account.group_account_invoice"/> <!-- Register Payment (only invoices / receipts) --> <button name="action_invoice_register_payment" id="account_invoice_payment_btn" type="object" class="oe_highlight" - attrs="{'invisible': ['|', '|', ('state', '!=', 'posted'), ('payment_state', 'not in', ('not_paid', 'partial')), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}" + attrs="{'invisible': ['|', '|', ('state', '!=', 'posted'), ('payment_state', 'not in', ('not_paid', 'partial')), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}" string="Register Payment" groups="account.group_account_invoice"/> <!-- Preview (only customer invoices) --> <button name="preview_invoice" type="object" string="Preview" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/> <!-- Reverse --> <button name="%(action_view_account_move_reversal)d" string="Reverse Entry" type="action" groups="account.group_account_invoice" - attrs="{'invisible': ['|', ('type', '!=', 'entry'), '|', ('state', '!=', 'posted'), ('payment_state', '=', 'reversed')]}"/> + attrs="{'invisible': ['|', ('move_type', '!=', 'entry'), '|', ('state', '!=', 'posted'), ('payment_state', '=', 'reversed')]}"/> <button name="action_reverse" string='Add Credit Note' type='object' groups="account.group_account_invoice" - attrs="{'invisible': ['|', ('type', 'not in', ('out_invoice', 'in_invoice')), ('state', '!=', 'posted')]}"/> + attrs="{'invisible': ['|', ('move_type', 'not in', ('out_invoice', 'in_invoice')), ('state', '!=', 'posted')]}"/> <!-- Duplicate --> <button name="action_duplicate" string="Duplicate" type="object" groups="account.group_account_invoice" - attrs="{'invisible': [('type', '!=', 'entry')]}"/> + attrs="{'invisible': [('move_type', '!=', 'entry')]}"/> <!-- Cancel --> <button name="button_cancel" string="Cancel Entry" type="object" groups="account.group_account_invoice" attrs="{'invisible' : ['|', ('id', '=', False), ('state', '!=', 'draft')]}"/> @@ -525,12 +525,12 @@ </div> <div groups="account.group_account_invoice,account.group_account_readonly" class="alert alert-info" role="alert" style="margin-bottom:0px;" - attrs="{'invisible': ['|', '|', ('type', 'not in', ('out_invoice', 'out_refund')), ('invoice_has_outstanding', '=', False), ('payment_state', 'not in', ('not_paid', 'partial'))]}"> + attrs="{'invisible': ['|', '|', ('move_type', 'not in', ('out_invoice', 'out_refund')), ('invoice_has_outstanding', '=', False), ('payment_state', 'not in', ('not_paid', 'partial'))]}"> You have <bold><a class="alert-link" href="#outstanding" role="button">outstanding payments</a></bold> for this customer. You can allocate them to mark this invoice as paid. </div> <div groups="account.group_account_invoice,account.group_account_readonly" class="alert alert-info" role="alert" style="margin-bottom:0px;" - attrs="{'invisible': ['|', '|', ('type', 'not in', ('in_invoice', 'in_refund')), ('invoice_has_outstanding', '=', False), ('payment_state', 'not in', ('not_paid', 'partial'))]}"> + attrs="{'invisible': ['|', '|', ('move_type', 'not in', ('in_invoice', 'in_refund')), ('invoice_has_outstanding', '=', False), ('payment_state', 'not in', ('not_paid', 'partial'))]}"> You have <bold><a class="alert-link" href="#outstanding" role="button">outstanding debits</a></bold> for this supplier. You can allocate them to mark this bill as paid. </div> <sheet> @@ -539,18 +539,18 @@ class="oe_stat_button" icon="fa-bars" type="object" - attrs="{'invisible': ['|', '|', ('type', '!=', 'entry'), ('id', '=', False), ('has_reconciled_entries', '=', False)]}" + attrs="{'invisible': ['|', '|', ('move_type', '!=', 'entry'), ('id', '=', False), ('has_reconciled_entries', '=', False)]}" string="Reconciled Entries"> </button> </div> <!-- Payment status for invoices / receipts --> <widget name="web_ribbon" title="Paid" - attrs="{'invisible': ['|', ('payment_state', '!=', 'paid'), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': ['|', ('payment_state', '!=', 'paid'), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> <widget name="web_ribbon" title="In Payment" - attrs="{'invisible': ['|', ('payment_state', '!=', 'in_payment'), ('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'))]}"/> <widget name="web_ribbon" title="Partial" - attrs="{'invisible': ['|', ('payment_state', '!=', 'partial'), ('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'))]}"/> <widget name="web_ribbon" title="Reversed" bg_color="bg-danger" attrs="{'invisible': [('payment_state', '!=', 'reversed')]}"/> @@ -563,7 +563,7 @@ <field name="id" invisible="1"/> <field name="show_name_warning" invisible="1"/> <field name="posted_before" invisible="1"/> - <field name="type" invisible="1"/> + <field name="move_type" invisible="1"/> <field name="payment_state" invisible="1" force_save="1"/> <field name="invoice_filter_type_domain" invisible="1"/> <field name="company_currency_id" invisible="1"/> @@ -578,7 +578,7 @@ <div class="oe_title"> <!-- Invoice draft header --> - <span class="o_form_label"><field name="type" attrs="{'invisible': [('type', '=', 'entry')]}" readonly="1" nolabel="1"/></span> + <span class="o_form_label"><field name="move_type" attrs="{'invisible': [('move_type', '=', 'entry')]}" readonly="1" nolabel="1"/></span> <h1> <span attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('name', '!=', '/')]}">Draft</span> </h1> @@ -594,21 +594,21 @@ <group id="header_left_group"> <div class="o_td_label"> <label for="partner_id" string="Customer" style="font-weight:bold;" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/> <label for="partner_id" string="Vendor" style="font-weight:bold;" - attrs="{'invisible': [('type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/> </div> <field name="partner_id" widget="res_partner_many2one" nolabel="1" context="{ - 'res_partner_search_mode': (context.get('default_type', 'entry') in ('out_invoice', 'out_refund', 'out_receipt') and 'customer') or (context.get('default_type', 'entry') in ('in_invoice', 'in_refund', 'in_receipt') and 'supplier') or False, + 'res_partner_search_mode': (context.get('default_move_type', 'entry') in ('out_invoice', 'out_refund', 'out_receipt') and 'customer') or (context.get('default_move_type', 'entry') in ('in_invoice', 'in_refund', 'in_receipt') and 'supplier') or False, 'show_address': 1, 'default_is_company': True, 'show_vat': True}" options='{"always_reload": True, "no_quick_create": True}' - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> <field name="ref"/> <field name="invoice_vendor_bill_id" - attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('type', '!=', 'in_invoice')]}" - domain="[('company_id', '=', company_id), ('partner_id','child_of', [partner_id]), ('type','=','in_invoice')]" + attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('move_type', '!=', 'in_invoice')]}" + domain="[('company_id', '=', company_id), ('partner_id','child_of', [partner_id]), ('move_type','=','in_invoice')]" string="Auto-Complete" placeholder="Select an old vendor bill" options="{'no_create': True}" context="{'show_total_amount': True}"/> </group> @@ -616,32 +616,32 @@ <!-- Invoice date (only invoices / receipts) --> <div class="o_td_label"> <label for="invoice_date" string="Invoice Date" style="font-weight:bold;" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/> <label for="invoice_date" string="Bill Date" style="font-weight:bold;" - attrs="{'invisible': [('type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]}"/> </div> <field name="invoice_date" nolabel="1" options="{'datepicker': {'warn_future': true}}" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> <field name="date" string="Accounting Date" - attrs="{'invisible': [('type', 'in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/> <!-- Invoice payment terms (only invoices) + due date (only invoices / receipts) --> <label for="invoice_payment_term_id" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> - <div class="d-flex" attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + <div class="d-flex" attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"> <field name="invoice_payment_term_id" placeholder="Terms" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> <span class="o_form_label mx-3 oe_edit_only" - attrs="{'invisible': [ '|', '|', ('state', '!=', 'draft'), ('invoice_payment_term_id', '!=', False), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"> or </span> + attrs="{'invisible': [ '|', '|', ('state', '!=', 'draft'), ('invoice_payment_term_id', '!=', False), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"> or </span> <field name="invoice_date_due" force_save="1" placeholder="Date" - attrs="{'invisible': ['|', ('invoice_payment_term_id', '!=', False), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': ['|', ('invoice_payment_term_id', '!=', False), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]}"/> </div> <field name="journal_id" - invisible="context.get('default_journal_id') and context.get('type', 'entry') != 'entry'" + invisible="context.get('default_journal_id') and context.get('move_type', 'entry') != 'entry'" groups="account.group_account_readonly" options="{'no_create': True}" domain="[('type', '=?', invoice_filter_type_domain)]" @@ -651,13 +651,13 @@ <field name="currency_id" groups="base.group_multi_currency" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"/> </group> </group> <notebook> <page id="invoice_tab" string="Invoice Lines" - attrs="{'invisible': [('type', '=', 'entry')]}"> + attrs="{'invisible': [('move_type', '=', 'entry')]}"> <field name="invoice_line_ids" widget="section_and_note_one2many" mode="tree,kanban" @@ -673,7 +673,7 @@ <field name="sequence" widget="handle"/> <field name="move_name" invisible="1"/> <field name="product_id" optional="show" domain="['|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/> - <field name="name" widget="section_and_note_text" attrs="{'required': [('parent.type', 'not in', ('in_invoice', 'in_refund','in_receipt'))]}"/> + <field name="name" widget="section_and_note_text" attrs="{'required': [('parent.move_type', 'not in', ('in_invoice', 'in_refund','in_receipt'))]}"/> <field name="account_id" groups="account.group_account_readonly" domain="[('deprecated', '=', False), ('user_type_id.type', 'not in', ('receivable', 'payable')), ('company_id', '=', parent.company_id)]" @@ -836,7 +836,7 @@ <!-- Totals (only invoices / receipts) --> <group class="oe_right"> <group class="oe_subtotal_footer" - attrs="{'invisible': ['|', ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), + attrs="{'invisible': ['|', ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), ('payment_state' ,'=', 'invoicing_legacy')]}"> <field name="amount_tax" invisible="1"/> <field name="amount_untaxed" attrs="{'invisible': [('amount_tax', '=', 0)]}"/> @@ -852,7 +852,7 @@ <group class="oe_invoice_outstanding_credits_debits" style="width: 350px !important;"> <field name="invoice_outstanding_credits_debits_widget" colspan="2" nolabel="1" widget="payment" - attrs="{'invisible': ['|', ('state', '!=', 'posted'), ('type', 'in', ('out_receipt', 'in_receipt'))]}"/> + attrs="{'invisible': ['|', ('state', '!=', 'posted'), ('move_type', 'in', ('out_receipt', 'in_receipt'))]}"/> </group> </group> @@ -860,12 +860,12 @@ <field name="narration" placeholder="Terms and Conditions" nolabel="1" height="50"/> </page> <page id="aml_tab" string="Journal Items" groups="account.group_account_readonly"> - <div class="alert alert-info text-center mb-0" role="alert" attrs="{'invisible': ['|', ('payment_state', '!=', 'invoicing_legacy'), ('type', '=', 'entry')]}"> + <div class="alert alert-info text-center mb-0" role="alert" attrs="{'invisible': ['|', ('payment_state', '!=', 'invoicing_legacy'), ('move_type', '=', 'entry')]}"> <span>This entry has been generated through the Invoicing app, before installing Accounting. Its balance has been imported separately.</span> </div> <field name="line_ids" context="{'line_ids': line_ids, 'journal_id': journal_id, 'default_partner_id': commercial_partner_id, 'default_currency_id': currency_id != company_currency_id and currency_id or False}" - attrs="{'invisible': [('payment_state', '=', 'invoicing_legacy'), ('type', '!=', 'entry')]}"> + attrs="{'invisible': [('payment_state', '=', 'invoicing_legacy'), ('move_type', '!=', 'entry')]}"> <tree editable="bottom" string="Journal Items" decoration-muted="display_type in ('line_section', 'line_note')" default_order="sequence, date desc, move_name desc, id"> <!-- Displayed fields --> <field name="account_id" @@ -875,7 +875,7 @@ }"/> <field name="partner_id" domain="['|', ('parent_id', '=', False), ('is_company', '=', True)]" - attrs="{'column_invisible': [('parent.type', '!=', 'entry')]}"/> + attrs="{'column_invisible': [('parent.move_type', '!=', 'entry')]}"/> <field name="name" widget="section_and_note_text" optional="show"/> <field name="analytic_account_id" optional="hide" @@ -896,7 +896,7 @@ optional="hide"/> <field name="currency_id" options="{'no_create': True}" groups="base.group_multi_currency" - attrs="{'column_invisible': [('parent.type', '!=', 'entry')]}"/> + attrs="{'column_invisible': [('parent.move_type', '!=', 'entry')]}"/> <field name="tax_ids" widget="many2many_tags" optional="hide" domain="[('type_tax_use', '=?', parent.invoice_filter_type_domain)]" @@ -908,7 +908,7 @@ ('display_type', 'in', ('line_section', 'line_note')), ('tax_line_id', '!=', False), '&', - ('parent.type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), + ('parent.move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), ('account_internal_type', 'in', ('receivable', 'payable')), ]}"/> <field name="debit" @@ -971,30 +971,30 @@ </field> </page> <page id="other_tab" string="Other Info" name="other_info" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> <group id="other_tab_group"> <group string="Invoice" name="sale_info_group" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}"> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}"> <field name="invoice_user_id"/> <field name="invoice_origin" string="Source Document" attrs="{'invisible': [('invoice_origin', '=', False)]}"/> </group> <group string="Accounting" name="accounting_info_group" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> <field name="invoice_incoterm_id"/> <field name="fiscal_position_id"/> <field name="invoice_cash_rounding_id" groups="account.group_cash_rounding"/> <field name="invoice_source_email" widget="email" - attrs="{'invisible': ['|', ('type', 'not in', ('in_invoice', 'in_refund')), ('invoice_source_email', '=', False)]}"/> + attrs="{'invisible': ['|', ('move_type', 'not in', ('in_invoice', 'in_refund')), ('invoice_source_email', '=', False)]}"/> <field name="to_check"/> </group> <group string="Payments" name="payments_info_group" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> - <field name="invoice_payment_ref" attrs="{'readonly': [('state', '=', 'paid'), ('type', 'in', ('in_invoice', 'in_refund'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> + <field name="invoice_payment_ref" attrs="{'readonly': [('state', '=', 'paid'), ('move_type', 'in', ('in_invoice', 'in_refund'))]}"/> <field name="invoice_partner_bank_id" context="{'default_partner_id': commercial_partner_id}" domain="[('partner_id', '=', bank_partner_id)]" @@ -1003,15 +1003,15 @@ </group> </page> <page id="other_tab_entry" string="Other Info" name="other_info" - attrs="{'invisible': [('type', '!=', 'entry')]}"> + attrs="{'invisible': [('move_type', '!=', 'entry')]}"> <group id="other_tab_entry_group"> <group name="misc_group"> <field name="auto_post" - attrs="{'invisible': [('type', '!=', 'entry')], 'readonly': [('reversed_entry_id', '!=', False)]}"/> + attrs="{'invisible': [('move_type', '!=', 'entry')], 'readonly': [('reversed_entry_id', '!=', False)]}"/> <field name="reversed_entry_id" - attrs="{'invisible': [('type', '!=', 'entry')]}"/> + attrs="{'invisible': [('move_type', '!=', 'entry')]}"/> <field name="to_check" - attrs="{'invisible': [('type', '!=', 'entry')]}" /> + attrs="{'invisible': [('move_type', '!=', 'entry')]}" /> </group> <group> <field name="company_id" groups="base.group_multi_company" required="1"/> @@ -1025,7 +1025,7 @@ <!-- Attachment preview --> <div class="o_attachment_preview" attrs="{'invisible': ['|', - ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), + ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('state', '!=', 'draft')]}" /> <!-- Chatter --> <div class="oe_chatter"> @@ -1261,7 +1261,7 @@ <field name="view_mode">tree,kanban,form</field> <field name="view_id" ref="view_move_tree"/> <field name="search_view_id" ref="view_account_move_filter"/> - <field name="context">{'default_type': 'entry', 'search_default_misc_filter':1, 'view_no_maturity': True}</field> + <field name="context">{'default_move_type': 'entry', 'search_default_misc_filter':1, 'view_no_maturity': True}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a journal entry @@ -1278,8 +1278,8 @@ <field name="view_mode">tree,kanban,form</field> <field name="view_id" ref="view_invoice_tree"/> <field name="search_view_id" ref="view_account_invoice_filter"/> - <field name="domain">[('type', '=', 'out_invoice')]</field> - <field name="context">{'default_type': 'out_invoice'}</field> + <field name="domain">[('move_type', '=', 'out_invoice')]</field> + <field name="context">{'default_move_type': 'out_invoice'}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a customer invoice @@ -1295,8 +1295,8 @@ <field name="view_mode">tree,kanban,form</field> <field name="view_id" ref="view_invoice_tree"/> <field name="search_view_id" ref="view_account_invoice_filter"/> - <field name="domain">[('type', '=', 'out_refund')]</field> - <field name="context">{'default_type': 'out_refund'}</field> + <field name="domain">[('move_type', '=', 'out_refund')]</field> + <field name="context">{'default_move_type': 'out_refund'}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a credit note @@ -1313,8 +1313,8 @@ <field name="view_mode">tree,kanban,form</field> <field name="view_id" ref="view_invoice_tree"/> <field name="search_view_id" ref="view_account_invoice_filter"/> - <field name="domain">[('type', '=', 'in_invoice')]</field> - <field name="context">{'default_type': 'in_invoice'}</field> + <field name="domain">[('move_type', '=', 'in_invoice')]</field> + <field name="context">{'default_move_type': 'in_invoice'}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a vendor bill @@ -1330,8 +1330,8 @@ <field name="view_mode">tree,kanban,form</field> <field name="view_id" ref="view_invoice_tree"/> <field name="search_view_id" ref="view_account_invoice_filter"/> - <field name="domain">[('type', '=', 'in_refund')]</field> - <field name="context">{'default_type': 'in_refund'}</field> + <field name="domain">[('tmove_ype', '=', 'in_refund')]</field> + <field name="context">{'default_move_type': 'in_refund'}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a vendor credit note @@ -1347,8 +1347,8 @@ <field name="view_mode">tree,kanban,form</field> <field name="view_id" ref="view_invoice_tree"/> <field name="search_view_id" ref="view_account_invoice_filter"/> - <field name="domain">[('type', '=', 'out_receipt')]</field> - <field name="context">{'default_type': 'out_receipt'}</field> + <field name="domain">[('move_type', '=', 'out_receipt')]</field> + <field name="context">{'default_move_type': 'out_receipt'}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a new sales receipt @@ -1365,8 +1365,8 @@ <field name="view_mode">tree,kanban,form</field> <field name="view_id" ref="view_invoice_tree"/> <field name="search_view_id" ref="view_account_invoice_filter"/> - <field name="domain">[('type', '=', 'in_receipt')]</field> - <field name="context">{'default_type': 'in_receipt'}</field> + <field name="domain">[('move_type', '=', 'in_receipt')]</field> + <field name="context">{'default_move_type': 'in_receipt'}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> 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 @@ <span class="badge badge-pill badge-warning"><i class="fa fa-fw fa-remove" aria-label="Cancelled" title="Cancelled" role="img"></i><span class="d-none d-md-inline"> Cancelled</span></span> </t> </td> - <td class="text-right"><span t-esc="-invoice.amount_residual if invoice.type == 'out_refund' else invoice.amount_residual" t-options='{"widget": "monetary", "display_currency": invoice.currency_id}'/></td> + <td class="text-right"><span t-esc="-invoice.amount_residual if invoice.move_type == 'out_refund' else invoice.amount_residual" t-options='{"widget": "monetary", "display_currency": invoice.currency_id}'/></td> </tr> </t> </tbody> @@ -89,7 +89,7 @@ <b t-if="invoice.amount_residual > 0" t-field="invoice.amount_residual"/> <b t-else="1" t-field="invoice.amount_total"/> </h2> - <div class="small" t-if="invoice.state != 'paid' and invoice.type == 'out_invoice'"><i class="fa fa-clock-o"/><span class="o_portal_sidebar_timeago ml4" t-att-datetime="invoice.invoice_date_due"/></div> + <div class="small" t-if="invoice.state != 'paid' and invoice.move_type == 'out_invoice'"><i class="fa fa-clock-o"/><span class="o_portal_sidebar_timeago ml4" t-att-datetime="invoice.invoice_date_due"/></div> </t> <t t-set="entries"> diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml index bfc28d65aef..a435ae4695b 100644 --- a/addons/account/views/report_invoice.xml +++ b/addons/account/views/report_invoice.xml @@ -12,12 +12,12 @@ </t> <div class="page"> <h2> - <span t-if="o.type == 'out_invoice' and o.state == 'posted'">Invoice</span> - <span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span> - <span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span> - <span t-if="o.type == 'out_refund'">Credit Note</span> - <span t-if="o.type == 'in_refund'">Vendor Credit Note</span> - <span t-if="o.type == 'in_invoice'">Vendor Bill</span> + <span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Invoice</span> + <span t-if="o.move_type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span> + <span t-if="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span> + <span t-if="o.move_type == 'out_refund'">Credit Note</span> + <span t-if="o.move_type == 'in_refund'">Vendor Credit Note</span> + <span t-if="o.move_type == 'in_invoice'">Vendor Bill</span> <span t-if="o.name != '/'" t-field="o.name"/> </h2> @@ -26,7 +26,7 @@ <strong>Invoice Date:</strong> <p class="m-0" t-field="o.invoice_date"/> </div> - <div class="col-auto mw-100 mb-2" t-if="o.invoice_date_due and o.type == 'out_invoice' and o.state == 'posted'" name="due_date"> + <div class="col-auto mw-100 mb-2" t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'" name="due_date"> <strong>Due Date:</strong> <p class="m-0" t-field="o.invoice_date_due"/> </div> @@ -165,7 +165,7 @@ </div> </div> </div> - <p t-if="o.type in ('out_invoice', 'in_refund') and o.invoice_payment_ref"> + <p t-if="o.move_type in ('out_invoice', 'in_refund') and o.invoice_payment_ref"> Please use the following communication for your payment : <b><span t-field="o.invoice_payment_ref"/></b> </p> <p t-if="o.invoice_payment_term_id" name="payment_term"> @@ -219,7 +219,7 @@ <template id="report_invoice"> <t t-call="web.html_container"> <t t-foreach="docs" t-as="o"> - <t t-set="lang" t-value="o.invoice_user_id.sudo().lang if o.type in ('in_invoice', 'in_refund') else o.partner_id.lang"/> + <t t-set="lang" t-value="o.invoice_user_id.sudo().lang if o.move_type in ('in_invoice', 'in_refund') else o.partner_id.lang"/> <t t-call="account.report_invoice_document" t-lang="lang"/> </t> </t> @@ -228,7 +228,7 @@ <template id="report_invoice_with_payments"> <t t-call="web.html_container"> <t t-foreach="docs" t-as="o"> - <t t-set="lang" t-value="o.invoice_user_id.sudo().lang if o.type in ('in_invoice', 'in_refund') else o.partner_id.lang"/> + <t t-set="lang" t-value="o.invoice_user_id.sudo().lang if o.move_type in ('in_invoice', 'in_refund') else o.partner_id.lang"/> <t t-call="account.report_invoice_document_with_payments" t-lang="lang"/> </t> </t> diff --git a/addons/account/wizard/account_move_reversal.py b/addons/account/wizard/account_move_reversal.py index c62dc3508dd..c00327ea58f 100644 --- a/addons/account/wizard/account_move_reversal.py +++ b/addons/account/wizard/account_move_reversal.py @@ -35,7 +35,7 @@ class AccountMoveReversal(models.TransientModel): if any(move.state != "posted" for move in move_ids): raise UserError(_('You can only reverse posted moves.')) res['move_ids'] = [(6, 0, move_ids.ids)] - res['refund_method'] = (len(move_ids) > 1 or move_ids.type == 'entry') and 'cancel' or 'refund' + res['refund_method'] = (len(move_ids) > 1 or move_ids.move_type == 'entry') and 'cancel' or 'refund' return res @api.depends('move_ids') @@ -44,7 +44,7 @@ class AccountMoveReversal(models.TransientModel): move_ids = record.move_ids record.residual = len(move_ids) == 1 and move_ids.amount_residual or 0 record.currency_id = len(move_ids.currency_id) == 1 and move_ids.currency_id or False - record.move_type = move_ids.type if len(move_ids) == 1 else (any(move.type in ('in_invoice', 'out_invoice') for move in move_ids) and 'some_invoice' or False) + record.move_type = move_ids.move_type if len(move_ids) == 1 else (any(move.move_type in ('in_invoice', 'out_invoice') for move in move_ids) and 'some_invoice' or False) def _prepare_default_reversal(self, move): return { diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index 79b6468b143..5423d1c7af9 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -165,8 +165,8 @@ class AccountPayment(models.Model): multi_stub = self.company_id.account_check_printing_multi_stub invoices = self.reconciled_invoice_ids.sorted(key=lambda r: r.invoice_date_due) - debits = invoices.filtered(lambda r: r.type == 'in_invoice') - credits = invoices.filtered(lambda r: r.type == 'in_refund') + debits = invoices.filtered(lambda r: r.move_type == 'in_invoice') + credits = invoices.filtered(lambda r: r.move_type == 'in_refund') # Prepare the stub lines if not credits: @@ -200,7 +200,7 @@ class AccountPayment(models.Model): """ Return the dict used to display an invoice/refund in the stub """ # Find the account.partial.reconcile which are common to the invoice and the payment - if invoice.type in ['in_invoice', 'out_refund']: + if invoice.move_type in ['in_invoice', 'out_refund']: invoice_sign = 1 invoice_payment_reconcile = invoice.line_ids.mapped('matched_debit_ids').filtered(lambda r: r.debit_move_id in self.move_line_ids) else: diff --git a/addons/account_check_printing/tests/test_print_check.py b/addons/account_check_printing/tests/test_print_check.py index 3a47340a0c6..1a79d7c419b 100644 --- a/addons/account_check_printing/tests/test_print_check.py +++ b/addons/account_check_printing/tests/test_print_check.py @@ -32,7 +32,7 @@ class TestPrintCheck(AccountTestCommon): cls.bank_journal.check_manual_sequencing = True def create_invoice(self, amount=100, is_refund=False): - invoice = self.env['account.move'].with_context(default_type=is_refund and 'out_refund' or 'in_invoice').create({ + invoice = self.env['account.move'].with_context(default_move_type=is_refund and 'out_refund' or 'in_invoice').create({ 'partner_id': self.partner_axelor.id, 'invoice_date': time.strftime('%Y') + '-06-26', 'date': time.strftime('%Y') + '-06-26', diff --git a/addons/account_debit_note/tests/test_out_debit_note.py b/addons/account_debit_note/tests/test_out_debit_note.py index a184e3f65a2..78fcada72b8 100644 --- a/addons/account_debit_note/tests/test_out_debit_note.py +++ b/addons/account_debit_note/tests/test_out_debit_note.py @@ -23,7 +23,7 @@ class TestAccountDebitNote(AccountTestInvoicingCommon): debit_note = self.env['account.move'].search([('debit_origin_id', '=', invoice.id)]) debit_note.ensure_one() self.assertEqual(len(debit_note.invoice_line_ids), 2, "Should have copied the invoice lines") - self.assertEqual(debit_note.type, 'out_invoice', 'Type of debit note should be the same as the original invoice') + self.assertEqual(debit_note.move_type, 'out_invoice', 'Type of debit note should be the same as the original invoice') self.assertEqual(debit_note.state, 'draft', 'We should create debit notes in draft state') def test_10_debit_note_in_refund(self): @@ -42,5 +42,5 @@ class TestAccountDebitNote(AccountTestInvoicingCommon): debit_note.ensure_one() self.assertFalse(debit_note.invoice_line_ids, 'We should not copy lines by default on debit notes') - self.assertEqual(debit_note.type, 'in_invoice', 'Type of debit note should not be refund anymore') + self.assertEqual(debit_note.move_type, 'in_invoice', 'Type of debit note should not be refund anymore') self.assertEqual(debit_note.state, 'draft', 'We should create debit notes in draft state')
\ No newline at end of file diff --git a/addons/account_debit_note/views/account_move_view.xml b/addons/account_debit_note/views/account_move_view.xml index 6deffec1c07..0a2dc555a64 100644 --- a/addons/account_debit_note/views/account_move_view.xml +++ b/addons/account_debit_note/views/account_move_view.xml @@ -10,7 +10,7 @@ <button name="%(action_view_account_move_debit)d" string='Add Debit Note' type='action' groups="account.group_account_invoice" attrs="{'invisible': ['|', '|', ('debit_origin_id', '!=', False), - ('type', 'not in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund')), ('state', '!=', 'posted')]}"/> + ('move_type', 'not in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund')), ('state', '!=', 'posted')]}"/> </button> <div class="oe_button_box" position="inside"> <button type="object" class="oe_stat_button" name="action_view_debit_notes" icon="fa-plus" attrs="{'invisible': [('debit_note_count', '=', 0)]}"> diff --git a/addons/account_debit_note/wizard/account_debit_note.py b/addons/account_debit_note/wizard/account_debit_note.py index af553426c12..3501599c60a 100644 --- a/addons/account_debit_note/wizard/account_debit_note.py +++ b/addons/account_debit_note/wizard/account_debit_note.py @@ -39,14 +39,14 @@ class AccountDebitNote(models.TransientModel): def _compute_from_moves(self): for record in self: move_ids = record.move_ids - record.move_type = move_ids[0].type if len(move_ids) == 1 or not any(m.type != move_ids[0].type for m in move_ids) else False + record.move_type = move_ids[0].move_type if len(move_ids) == 1 or not any(m.move_type != move_ids[0].move_type for m in move_ids) else False record.journal_type = record.move_type in ['in_refund', 'in_invoice'] and 'purchase' or 'sale' def _prepare_default_values(self, move): - if move.type in ('in_refund', 'out_refund'): - type = 'in_invoice' if move.type == 'in_refund' else 'out_invoice' + if move.move_type in ('in_refund', 'out_refund'): + type = 'in_invoice' if move.move_type == 'in_refund' else 'out_invoice' else: - type = move.type + type = move.move_type default_values = { 'ref': '%s, %s' % (move.name, self.reason) if self.reason else move.name, 'date': self.date or move.date, @@ -54,9 +54,9 @@ class AccountDebitNote(models.TransientModel): 'journal_id': self.journal_id and self.journal_id.id or move.journal_id.id, 'invoice_payment_term_id': None, 'debit_origin_id': move.id, - 'type': type, + 'move_type': type, } - if not self.copy_lines or move.type in [('in_refund', 'out_refund')]: + if not self.copy_lines or move.move_type in [('in_refund', 'out_refund')]: default_values['line_ids'] = [(5, 0, 0)] return default_values diff --git a/addons/account_facturx/data/facturx_templates.xml b/addons/account_facturx/data/facturx_templates.xml index 672cd106d4e..f5749c54893 100644 --- a/addons/account_facturx/data/facturx_templates.xml +++ b/addons/account_facturx/data/facturx_templates.xml @@ -32,7 +32,7 @@ quantity=line.quantity, product=line.product_id, partner=record.partner_id, - is_refund=line.move_id.type in ('in_refund', 'out_refund'))"/> + is_refund=line.move_id.move_type in ('in_refund', 'out_refund'))"/> <ram:GrossPriceProductTradePrice> <ram:ChargeAmount t-att-currencyID="currency.name" @@ -119,7 +119,7 @@ <!-- Document Headers. --> <rsm:ExchangedDocument> <ram:ID t-esc="record.ref"/> - <ram:TypeCode t-esc="'381' if 'refund' in record.type else '380'"/> + <ram:TypeCode t-esc="'381' if 'refund' in record.move_type else '380'"/> <ram:IssueDateTime> <udt:DateTimeString format="102" t-esc="format_date(record.invoice_date)"/> </ram:IssueDateTime> diff --git a/addons/account_facturx/models/account_move.py b/addons/account_facturx/models/account_move.py index bc80f157aa4..68020ea6c90 100644 --- a/addons/account_facturx/models/account_move.py +++ b/addons/account_facturx/models/account_move.py @@ -58,12 +58,12 @@ class AccountMove(models.Model): if self._context.get('default_journal_id'): journal = self.env['account.journal'].browse(self.env.context['default_journal_id']) default_type = 'out_invoice' if journal.type == 'sale' else 'in_invoice' - elif self._context.get('default_type'): - default_type = self._context['default_type'] - elif self.type in self.env['account.move'].get_invoice_types(include_receipts=True): + elif self._context.get('default_move_type'): + default_type = self._context['default_move_type'] + elif self.move_type in self.env['account.move'].get_invoice_types(include_receipts=True): # in case an attachment is saved on a draft invoice previously created, we might # have lost the default value in context but the type was already set - default_type = self.type + default_type = self.move_type if not default_type: raise UserError(_("No information about the journal or the type of invoice is passed")) @@ -93,10 +93,10 @@ class AccountMove(models.Model): refund_sign = -1 if 'refund' in default_type else 1 # Write the type as the journal entry is already created. - self.type = default_type + self.move_type = default_type # self could be a single record (editing) or be empty (new). - with Form(self.with_context(default_type=default_type)) as invoice_form: + with Form(self.with_context(default_move_type=default_type)) as invoice_form: # Partner (first step to avoid warning 'Warning! You must first select a partner.'). partner_type = invoice_form.journal_id.type == 'purchase' and 'SellerTradeParty' or 'BuyerTradeParty' elements = tree.xpath('//ram:'+partner_type+'/ram:SpecifiedTaxRegistration/ram:ID', namespaces=tree.nsmap) @@ -231,7 +231,7 @@ class AccountMove(models.Model): res = super(AccountMove, self).message_post(**kwargs) if not self.env.context.get('no_new_invoice') and len(self) == 1 and self.state == 'draft' and ( - self.env.context.get('default_type', self.type) in self.env['account.move'].get_invoice_types(include_receipts=True) + self.env.context.get('default_move_type', self.move_type) in self.env['account.move'].get_invoice_types(include_receipts=True) or self.env['account.journal'].browse(self.env.context.get('default_journal_id')).type in ('sale', 'purchase') ): for attachment in self.env['ir.attachment'].browse(kwargs.get('attachment_ids', [])): diff --git a/addons/account_payment/views/account_portal_templates.xml b/addons/account_payment/views/account_portal_templates.xml index e30c5e61394..43e1d231830 100644 --- a/addons/account_payment/views/account_portal_templates.xml +++ b/addons/account_payment/views/account_portal_templates.xml @@ -7,7 +7,7 @@ <td class="text-center"> <t t-set="tx_ids" t-value="invoice.transaction_ids.filtered(lambda tx: tx.state in ('pending', 'authorized', 'done'))"/> <t t-set="pending_manual_txs" t-value="tx_ids.filtered(lambda tx: tx.state == 'pending' and tx.acquirer_id.provider in ('transfer', 'manual'))"/> - <a t-if="invoice.state == 'posted' and invoice.payment_state in ('not_paid', 'partial') and invoice.amount_total and invoice.type == 'out_invoice' and (pending_manual_txs or not tx_ids)" + <a t-if="invoice.state == 'posted' and invoice.payment_state in ('not_paid', 'partial') and invoice.amount_total and invoice.move_type == 'out_invoice' and (pending_manual_txs or not tx_ids)" t-att-href="invoice.get_portal_url(anchor='portal_pay')" title="Pay Now" aria-label="Pay now" class="btn btn-sm btn-primary" role="button"> <i class="fa fa-arrow-circle-right"/><span class='d-none d-md-inline'> Pay Now</span> </a> @@ -71,7 +71,8 @@ <t t-set="tx_ids" t-value="invoice.transaction_ids.filtered(lambda tx: tx.state in ('pending', 'authorized', 'done'))"/> <t t-set="pending_manual_txs" t-value="tx_ids.filtered(lambda tx: tx.state == 'pending' and tx.acquirer_id.provider in ('transfer', 'manual'))"/> <div> - <a href="#" t-if="invoice.state == 'posted' and invoice.payment_state in ('not_paid', 'partial') and invoice.amount_total and invoice.type == 'out_invoice' and (pending_manual_txs or not tx_ids)" + <a href="#" t-if="invoice.state == 'posted' and invoice.payment_state in ('not_paid', 'partial') and invoice.amount_total and invoice.move_type == 'out_invoice' and (pending_manual_txs or not tx_ids)" + class="btn btn-primary btn-block mb-2" data-toggle="modal" data-target="#pay_with"> <i class="fa fa-fw fa-arrow-circle-right"/> Pay Now </a> diff --git a/addons/gamification_sale_crm/data/gamification_sale_crm_data.xml b/addons/gamification_sale_crm/data/gamification_sale_crm_data.xml index 93725e68ba3..791d862726c 100644 --- a/addons/gamification_sale_crm/data/gamification_sale_crm_data.xml +++ b/addons/gamification_sale_crm/data/gamification_sale_crm_data.xml @@ -10,7 +10,7 @@ <field name="model_id" ref="account.model_account_invoice_report"/> <field name="field_id" ref="account.field_account_invoice_report__price_subtotal"/> <field name="field_date_id" ref="account.field_account_invoice_report__invoice_date"/> - <field name="domain">[('state','!=','cancel'),('invoice_user_id','=',user.id),('type','=','out_invoice')]</field> + <field name="domain">[('state','!=','cancel'),('invoice_user_id','=',user.id),('move_type','=','out_invoice')]</field> </record> <record model="gamification.goal.definition" id="definition_crm_nbr_new_leads"> @@ -76,7 +76,7 @@ <field name="suffix">orders</field> <field name="model_id" ref="account.model_account_invoice_report"/> <field name="field_date_id" ref="account.field_account_invoice_report__invoice_date"/> - <field name="domain">[('state','=','paid'),('invoice_user_id','=',user.id),('type','=','out_invoice')]</field> + <field name="domain">[('state','=','paid'),('invoice_user_id','=',user.id),('move_type','=','out_invoice')]</field> </record> <record model="gamification.goal.definition" id="definition_crm_tot_paid_sale_order"> <field name="name">Total Paid Sales Orders</field> @@ -86,7 +86,7 @@ <field name="model_id" ref="account.model_account_invoice_report"/> <field name="field_id" ref="account.field_account_invoice_report__price_subtotal"/> <field name="field_date_id" ref="account.field_account_invoice_report__invoice_date"/> - <field name="domain">[('state','=','paid'),('invoice_user_id','=',user.id),('type','=','out_invoice')]</field> + <field name="domain">[('state','=','paid'),('invoice_user_id','=',user.id),('move_type','=','out_invoice')]</field> </record> @@ -98,7 +98,7 @@ <field name="suffix">invoices</field> <field name="model_id" ref="account.model_account_invoice_report"/> <field name="field_date_id" ref="account.field_account_invoice_report__invoice_date"/> - <field name="domain">[('state','!=','cancel'),('invoice_user_id','=',user.id),('type','=','out_refund')]</field> + <field name="domain">[('state','!=','cancel'),('invoice_user_id','=',user.id),('move_type','=','out_refund')]</field> </record> <record model="gamification.goal.definition" id="definition_crm_tot_customer_refunds"> <field name="name">Total Customer Credit Notes</field> @@ -109,7 +109,7 @@ <field name="model_id" ref="account.model_account_invoice_report"/> <field name="field_id" ref="account.field_account_invoice_report__price_subtotal"/> <field name="field_date_id" ref="account.field_account_invoice_report__invoice_date"/> - <field name="domain">[('state','!=','cancel'),('invoice_user_id','=',user.id),('type','=','out_refund')]</field> + <field name="domain">[('state','!=','cancel'),('invoice_user_id','=',user.id),('move_type','=','out_refund')]</field> </record> diff --git a/addons/l10n_ae/views/report_invoice_templates.xml b/addons/l10n_ae/views/report_invoice_templates.xml index f32ef820134..0018bc69a62 100644 --- a/addons/l10n_ae/views/report_invoice_templates.xml +++ b/addons/l10n_ae/views/report_invoice_templates.xml @@ -7,7 +7,7 @@ </p> </xpath> <xpath expr="//h2/span" position="before"> - <span t-if="o.company_id.country_id.code == 'AE' and o.type in ['out_invoice', 'out_refund']">Tax</span> + <span t-if="o.company_id.country_id.code == 'AE' and o.move_type in ['out_invoice', 'out_refund']">Tax</span> </xpath> <xpath expr="//div[hasclass('clearfix')]" position="after"> diff --git a/addons/l10n_ar/demo/account_customer_invoice_demo.xml b/addons/l10n_ar/demo/account_customer_invoice_demo.xml index 6931e8eea47..7dfdd85269b 100644 --- a/addons/l10n_ar/demo/account_customer_invoice_demo.xml +++ b/addons/l10n_ar/demo/account_customer_invoice_demo.xml @@ -8,7 +8,7 @@ <field name="partner_id" ref="res_partner_gritti_agrimensura"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -21,7 +21,7 @@ <field name="partner_id" ref="res_partner_cmr"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-05'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -36,7 +36,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-12'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -50,7 +50,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-12'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -64,7 +64,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -83,7 +83,7 @@ <field name="journal_id" ref="l10n_ar.sale_expo_journal_ri"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-03'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_incoterm_id" ref="account.incoterm_EXW"/> @@ -103,7 +103,7 @@ <field name="journal_id" ref="l10n_ar.sale_expo_journal_ri"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-03'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_incoterm_id" ref="account.incoterm_EXW"/> @@ -122,7 +122,7 @@ <field name="partner_id" ref="l10n_ar.par_cfa"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -135,7 +135,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -149,7 +149,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -165,7 +165,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -181,7 +181,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -202,7 +202,7 @@ <field name="journal_id" ref="l10n_ar.sale_expo_journal_ri"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-20'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_incoterm_id" ref="account.incoterm_EXW"/> @@ -217,7 +217,7 @@ <field name="journal_id" ref="l10n_ar.sale_expo_journal_ri"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-20'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_incoterm_id" ref="account.incoterm_EXW"/> @@ -232,7 +232,7 @@ <field name="journal_id" ref="l10n_ar.sale_expo_journal_ri"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-22'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_incoterm_id" ref="account.incoterm_EXW"/> @@ -246,7 +246,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -259,7 +259,7 @@ <field name="partner_id" ref="l10n_ar.res_partner_adhoc"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ diff --git a/addons/l10n_ar/demo/account_supplier_invoice_demo.xml b/addons/l10n_ar/demo/account_supplier_invoice_demo.xml index 05f794bad85..3fbd753fd1e 100644 --- a/addons/l10n_ar/demo/account_supplier_invoice_demo.xml +++ b/addons/l10n_ar/demo/account_supplier_invoice_demo.xml @@ -7,7 +7,7 @@ <field name="partner_id" ref="res_partner_gritti_agrimensura"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -26,7 +26,7 @@ <field name="partner_id" ref="res_partner_foreign"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -42,7 +42,7 @@ <field name="partner_id" ref="res_partner_foreign"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-11'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -57,7 +57,7 @@ <field name="partner_id" ref="res_partner_foreign"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-15'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -72,7 +72,7 @@ <field name="partner_id" ref="res_partner_foreign"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-18'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -91,7 +91,7 @@ <field name="partner_id" ref="res_partner_odoo"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-26'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -105,7 +105,7 @@ <field name="partner_id" ref="res_partner_odoo"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-27'"/> <field name="company_id" ref="company_ri"/> <field name="invoice_line_ids" eval="[ @@ -120,7 +120,7 @@ <field name="partner_id" ref="l10n_ar.partner_afip"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <!-- as we create lines separatelly we need to set journal, if not, misc journal is selected --> <field name="journal_id" model="account.journal" search="[('type', '=', 'purchase'), ('company_id', '=', obj().env.company.id)]"/> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-13'"/> diff --git a/addons/l10n_ar/models/account_move.py b/addons/l10n_ar/models/account_move.py index ac5c915cb0a..b40936c3962 100644 --- a/addons/l10n_ar/models/account_move.py +++ b/addons/l10n_ar/models/account_move.py @@ -84,7 +84,7 @@ class AccountMove(models.Model): for inv in self.filtered(lambda x: x.company_id.l10n_ar_company_requires_vat): purchase_aliquots = 'not_zero' # we require a single vat on each invoice line except from some purchase documents - if inv.type in ['in_invoice', 'in_refund'] and inv.l10n_latam_document_type_id.purchase_aliquots == 'zero': + if inv.move_type in ['in_invoice', 'in_refund'] and inv.l10n_latam_document_type_id.purchase_aliquots == 'zero': purchase_aliquots = 'zero' for line in inv.mapped('invoice_line_ids').filtered(lambda x: x.display_type not in ('line_section', 'line_note')): vat_taxes = line.tax_ids.filtered(lambda x: x.tax_group_id.l10n_ar_vat_afip_code) diff --git a/addons/l10n_be_edi/models/account_invoice.py b/addons/l10n_be_edi/models/account_invoice.py index d6d755e71e1..1850c775cdf 100644 --- a/addons/l10n_be_edi/models/account_invoice.py +++ b/addons/l10n_be_edi/models/account_invoice.py @@ -44,9 +44,9 @@ class AccountMove(models.Model): else: type = 'in_invoice' - default_journal = self.with_context(default_type=type)._get_default_journal() + default_journal = self.with_context(default_move_type=type)._get_default_journal() - with Form(self.with_context(default_type=type, default_journal_id=default_journal.id)) as invoice_form: + with Form(self.with_context(default_move_type=type, default_journal_id=default_journal.id)) as invoice_form: # Reference elements = tree.xpath('//cbc:ID', namespaces=namespaces) if elements: diff --git a/addons/l10n_be_edi/tests/test_ubl.py b/addons/l10n_be_edi/tests/test_ubl.py index 37ef7bd9984..2680b7bca52 100644 --- a/addons/l10n_be_edi/tests/test_ubl.py +++ b/addons/l10n_be_edi/tests/test_ubl.py @@ -16,7 +16,7 @@ class TestUBL(common.TransactionCase): def test_ubl_invoice_import(self): xml_file_path = get_module_resource('l10n_be_edi', 'test_xml_file', 'efff_test.xml') xml_file = open(xml_file_path, 'rb').read() - invoice = self.env['account.move'].with_context(default_type='in_invoice').create({}) + invoice = self.env['account.move'].with_context(default_move_type='in_invoice').create({}) attachment_id = self.env['ir.attachment'].create({ 'name': 'efff_test.xml', diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py index 4aa7348b594..74a20da4465 100644 --- a/addons/l10n_ch/models/account_invoice.py +++ b/addons/l10n_ch/models/account_invoice.py @@ -141,14 +141,14 @@ class AccountMove(models.Model): record.l10n_ch_isr_optical_line = left + '>' + record.l10n_ch_isr_number + '+ ' + record.l10n_ch_isr_subscription + '>' @api.depends( - 'type', 'name', 'currency_id.name', + 'move_type', 'name', 'currency_id.name', 'invoice_partner_bank_id.l10n_ch_postal', 'invoice_partner_bank_id.l10n_ch_isr_subscription_eur', 'invoice_partner_bank_id.l10n_ch_isr_subscription_chf') def _compute_l10n_ch_isr_valid(self): """Returns True if all the data required to generate the ISR are present""" for record in self: - record.l10n_ch_isr_valid = record.type == 'out_invoice' and\ + record.l10n_ch_isr_valid = record.move_type == 'out_invoice' and\ record.name and \ record.l10n_ch_isr_subscription and \ record.invoice_partner_bank_id.l10n_ch_postal and \ diff --git a/addons/l10n_ch/tests/test_l10n_ch_isr.py b/addons/l10n_ch/tests/test_l10n_ch_isr.py index dbd73bac1a0..1316613313e 100644 --- a/addons/l10n_ch/tests/test_l10n_ch_isr.py +++ b/addons/l10n_ch/tests/test_l10n_ch_isr.py @@ -13,8 +13,8 @@ class ISRTest(AccountTestCommon): def create_invoice(self, currency_to_use='base.CHF'): """ Generates a test invoice """ - invoice = self.env['account.move'].with_context(default_type='out_invoice').create({ - 'type': 'out_invoice', + invoice = self.env['account.move'].with_context(default_move_type='out_invoice').create({ + 'move_type': 'out_invoice', 'partner_id': self.env.ref("base.res_partner_2").id, 'currency_id': self.env.ref(currency_to_use).id, 'invoice_date': time.strftime('%Y') + '-12-22', diff --git a/addons/l10n_ch/views/account_invoice_view.xml b/addons/l10n_ch/views/account_invoice_view.xml index 115a546fd98..a5d56df6b99 100644 --- a/addons/l10n_ch/views/account_invoice_view.xml +++ b/addons/l10n_ch/views/account_invoice_view.xml @@ -17,7 +17,7 @@ string="Print ISR" type="object" attrs="{'invisible':['|', '|', '|', '|', - ('type', 'not in', ('out_invoice', 'out_refund')), + ('move_type', 'not in', ('out_invoice', 'out_refund')), ('l10n_ch_isr_sent', '=', True), ('state', '!=', 'posted'), ('payment_state', 'not in', ('not_paid', 'partial')), @@ -33,7 +33,7 @@ string="Print ISR" type="object" attrs="{'invisible':['|', '|', '|', '|', - ('type', 'not in', ('out_invoice', 'out_refund')), + ('move_type', 'not in', ('out_invoice', 'out_refund')), ('l10n_ch_isr_sent', '=', False), ('state', '!=', 'posted'), ('payment_state', 'not in', ('not_paid', 'partial')), diff --git a/addons/l10n_cl/models/account_move.py b/addons/l10n_cl/models/account_move.py index 215395c8036..5f3895dcb4c 100644 --- a/addons/l10n_cl/models/account_move.py +++ b/addons/l10n_cl/models/account_move.py @@ -18,7 +18,7 @@ class AccountMove(models.Model): domain = super()._get_l10n_latam_documents_domain() if (self.journal_id.l10n_latam_use_documents and self.journal_id.company_id.country_id == self.env.ref('base.cl')): - if self.type in ['in_invoice', 'in_refund']: + if self.move_type in ['in_invoice', 'in_refund']: if self.partner_id.l10n_cl_sii_taxpayer_type == '2': domain += [('code', '=', '71')] return domain @@ -28,7 +28,7 @@ class AccountMove(models.Model): domain += [('code', 'in', ['35', '38', '39', '41', '56', '61'])] return domain - @api.constrains('type', 'l10n_latam_document_type_id') + @api.constrains('move_type', 'l10n_latam_document_type_id') def _check_invoice_type_document_type(self): super()._check_invoice_type_document_type() for rec in self.filtered(lambda r: r.company_id.country_id == self.env.ref( diff --git a/addons/l10n_cl/views/account_move_view.xml b/addons/l10n_cl/views/account_move_view.xml index ecf9c7f8589..d1a7b745a51 100644 --- a/addons/l10n_cl/views/account_move_view.xml +++ b/addons/l10n_cl/views/account_move_view.xml @@ -10,7 +10,7 @@ <field name="l10n_latam_internal_type" invisible="1"/> </form> <field name="ref" position="attributes"> - <attribute name="attrs">{'invisible': [('type', '=', 'out_invoice'), ('l10n_latam_internal_type', '!=', 'debit_note')], 'required': [('l10n_latam_internal_type', '=', 'debit_note')]}</attribute> + <attribute name="attrs">{'invisible': [('move_type', '=', 'out_invoice'), ('l10n_latam_internal_type', '!=', 'debit_note')], 'required': [('l10n_latam_internal_type', '=', 'debit_note')]}</attribute> </field> </field> </record> @@ -27,7 +27,7 @@ <field name="invoice_date_due" optional="show"/> <field name="date" string="Accounting Date" optional="show"/> <field name="invoice_payment_ref" optional="hide"/> - <field name="invoice_user_id" optional="show" invisible="context.get('default_type') not in ('out_invoice', 'out_refund','out_receipt')" string="Sales Person"/> + <field name="invoice_user_id" optional="show" invisible="context.get('default_move_type') not in ('out_invoice', 'out_refund','out_receipt')" string="Sales Person"/> <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" optional="show"/> <field name="invoice_origin" optional="show" string="Source Document"/> <field name="amount_untaxed_signed" string="Amount Untaxed" sum="Total" optional="show"/> @@ -38,7 +38,7 @@ <field name="company_currency_id" invisible="1"/> <field name="state" optional="show"/> <field name="payment_state" optional="hide"/> - <field name="type" invisible="context.get('default_type', True)"/> + <field name="move_type" invisible="context.get('default_move_type', True)"/> </tree> </field> </record> @@ -47,8 +47,8 @@ <field name="name">Sale Invoices and Credit Notes</field> <field name="view_id" ref="view_complete_invoice_refund_tree"/> <field name="res_model">account.move</field> - <field name="domain">[('type', 'in', ['out_invoice', 'out_refund'])]</field> - <field name="context">{'default_type': 'out_invoice'}</field> + <field name="domain">[('move_type', 'in', ['out_invoice', 'out_refund'])]</field> + <field name="context">{'default_move_type': 'out_invoice'}</field> <field name="target">current</field> <field name="view_mode">tree,form</field> </record> @@ -57,8 +57,8 @@ <field name="name">Vendor Bills and Refunds</field> <field name="view_id" ref="view_complete_invoice_refund_tree"/> <field name="res_model">account.move</field> - <field name="domain">[('type', 'in', ['in_invoice', 'in_refund'])]</field> - <field name="context">{'default_type': 'in_invoice'}</field> + <field name="domain">[('move_type', 'in', ['in_invoice', 'in_refund'])]</field> + <field name="context">{'default_move_type': 'in_invoice'}</field> <field name="target">current</field> <field name="view_mode">tree,form</field> </record> diff --git a/addons/l10n_generic_coa/demo/account_invoice_demo.xml b/addons/l10n_generic_coa/demo/account_invoice_demo.xml index 91058a50536..bc908db210c 100644 --- a/addons/l10n_generic_coa/demo/account_invoice_demo.xml +++ b/addons/l10n_generic_coa/demo/account_invoice_demo.xml @@ -3,7 +3,7 @@ <data noupdate="1"> <!-- ==== Invoice Demo 1 with attachment ==== --> <record id="demo_invoice_1" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="base.res_partner_12"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> @@ -16,18 +16,18 @@ <!-- ==== Invoice Demo 2 ==== --> <record id="demo_invoice_2" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="base.res_partner_2"/> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-08'"/> <field name="invoice_line_ids" eval="[ (0, 0, {'product_id': ref('product.consu_delivery_03'), 'price_unit': 50.0, 'quantity': 5}), - (0, 0, {'product_id': ref('product.consu_delivery_01'), 'price_unit': 25.0, 'quantity': 20}), + ]"/> </record> <!-- ==== Invoice Demo 3 ==== --> <record id="demo_invoice_3" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="base.res_partner_2"/> <field name="invoice_date" eval="time.strftime('%Y-%m')+'-08'"/> <field name="invoice_line_ids" eval="[ @@ -38,10 +38,11 @@ <!-- ==== Invoice Demo 4 - Create an invoice that will generate a followup ==== --> <record id="demo_invoice_followup" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="base.res_partner_2"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_immediate"/> + <field name="invoice_date" eval="(datetime.today() + timedelta(days=-15)).strftime('%Y-%m-%d')"/> <field name="invoice_line_ids" eval="[ (0, 0, {'product_id': ref('product.consu_delivery_02'), 'price_unit': 642.0, 'quantity': 5}), @@ -51,7 +52,7 @@ <!-- ==== Invoice Demo 5 - Draft Vendor Bill ==== --> <record id="demo_invoice_5" model="account.move"> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="partner_id" ref="base.res_partner_12"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> @@ -64,14 +65,14 @@ <!-- ==== Invoice Demo 6 - Draft Vendor Bill for OCR ==== --> - <record id="demo_invoice_extract" model="account.move" context="{'default_type': 'in_invoice'}"> - <field name="type">in_invoice</field> + <record id="demo_invoice_extract" model="account.move" context="{'default_move_type': 'in_invoice'}"> + <field name="move_type">in_invoice</field> <field name="invoice_user_id" ref="base.user_demo"/> </record> <!-- ==== Invoice Demo 7 - Posted vendor bill ==== --> <record id="demo_invoice_equipment_purchase" model="account.move"> - <field name="type">in_invoice</field> + <field name="move_type">in_invoice</field> <field name="ref">INV/2018/0057</field> <field name="partner_id" ref="base.res_partner_12"/> <field name="invoice_date">2018-09-17</field> diff --git a/addons/l10n_in/data/account_invoice_demo.xml b/addons/l10n_in/data/account_invoice_demo.xml index cbe683333fa..f4607661fd2 100644 --- a/addons/l10n_in/data/account_invoice_demo.xml +++ b/addons/l10n_in/data/account_invoice_demo.xml @@ -3,7 +3,7 @@ <!-- Demo of B2B (business-to-business) Taxable supplies made to other registered person.--> <record id="demo_invoice_b2b" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="l10n_in.res_partner_registered_customer"/> <field name="l10n_in_reseller_partner_id" ref="l10n_in.res_partner_reseller"/> <field name="invoice_user_id" ref="base.user_demo"/> @@ -48,7 +48,7 @@ <!-- Demo of B2CS (business to consumer small) Taxable supplies made to other unregistered Person and below INR 2.5 lakhs invoice value.--> <record id="demo_invoice_b2cs" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="l10n_in.res_partner_unregistered_customer"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> @@ -95,7 +95,7 @@ <!-- Demo of B2CL (business to consumer - Large) Taxable supplies made to other unregistered Person and invoice value is more than INR 2.5 lakhs.--> <record id="demo_invoice_b2cl" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="l10n_in.res_partner_unregistered_customer_out_state"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> @@ -115,7 +115,7 @@ <!-- Demo of EXP(Export) supplies including supplies to SEZ/SEZ Developer or deemed exports.--> <record id="demo_invoice_exp" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="base.res_partner_3"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> @@ -145,7 +145,7 @@ <!-- Demo of exemp(Nil Rated, Exempted and Non GST supplies). Set Nill rated and Exempted tax in line.--> <record id="demo_invoice_nill" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="l10n_in.res_partner_registered_customer"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> @@ -172,7 +172,7 @@ <!-- Demo of cdnr(Credit/ Debit Note for registered person). Create credit note for demo b2b invoice.--> <record id="demo_invoice_cdnr" model="account.move"> - <field name="type">out_refund</field> + <field name="move_type">out_refund</field> <field name="partner_id" ref="l10n_in.res_partner_registered_customer"/> <field name="l10n_in_reseller_partner_id" ref="l10n_in.res_partner_reseller"/> <field name="invoice_user_id" ref="base.user_demo"/> @@ -218,7 +218,7 @@ <!-- Demo of cdnr(Credit/ Debit Note for unregistered person). Create credit note for demo b2cl invoice.--> <record id="demo_invoice_cdnur" model="account.move"> - <field name="type">out_refund</field> + <field name="move_type">out_refund</field> <field name="partner_id" ref="l10n_in.res_partner_unregistered_customer"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> @@ -240,7 +240,7 @@ <!-- Demo of atadj(Advance adjustments). When invoice is reconcile against Advance payment. Reconciled invoice consideration for which payment have been received in the past months.--> <record id="demo_invoice_atadj" model="account.move"> - <field name="type">out_invoice</field> + <field name="move_type">out_invoice</field> <field name="partner_id" ref="l10n_in.res_partner_registered_customer"/> <field name="invoice_user_id" ref="base.user_demo"/> <field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/> diff --git a/addons/l10n_in/report/account_invoice_report.py b/addons/l10n_in/report/account_invoice_report.py index 65a98083b4b..fc8de7c7cfa 100644 --- a/addons/l10n_in/report/account_invoice_report.py +++ b/addons/l10n_in/report/account_invoice_report.py @@ -126,7 +126,7 @@ class L10nInAccountInvoiceReport(models.Model): am.amount_total AS total, am.journal_id, aj.company_id, - am.type AS move_type, + am.move_type AS move_type, am.reversed_entry_id AS reversed_entry_id, p.vat AS partner_vat, CASE WHEN rp.vat IS NULL THEN '' ELSE rp.vat END AS ecommerce_vat, @@ -140,7 +140,7 @@ class L10nInAccountInvoiceReport(models.Model): THEN concat(cps.l10n_in_tin,'-',cps.name) ELSE '' END) AS place_of_supply, - (CASE WHEN am.type in ('out_refund', 'in_refund') and refund_am.date <= to_date('2017-07-01', 'YYYY-MM-DD') + (CASE WHEN am.move_type in ('out_refund', 'in_refund') and refund_am.date <= to_date('2017-07-01', 'YYYY-MM-DD') THEN 'Y' ELSE 'N' END) as is_pre_gst, @@ -187,9 +187,9 @@ class L10nInAccountInvoiceReport(models.Model): WHEN am.l10n_in_export_type = 'sez_without_igst' THEN 'SEZ without IGST payment' END) AS b2b_type, - (CASE WHEN am.type = 'out_refund' + (CASE WHEN am.move_type = 'out_refund' THEN 'C' - WHEN am.type = 'in_refund' + WHEN am.move_type = 'in_refund' THEN 'D' ELSE '' END) as refund_invoice_type, @@ -232,7 +232,7 @@ class L10nInAccountInvoiceReport(models.Model): THEN NULL ELSE (CASE WHEN aml.tax_base_amount <> 0 THEN aml.tax_base_amount ELSE NULL END) END AS price_total, - (CASE WHEN aj.type = 'sale' AND (am.type IS NULL OR am.type != 'out_refund') THEN -1 ELSE 1 END) AS amount_sign, + (CASE WHEN aj.type = 'sale' AND (am.move_type IS NULL OR am.move_type != 'out_refund') THEN -1 ELSE 1 END) AS amount_sign, (CASE WHEN atr.parent_tax IS NOT NULL THEN atr.parent_tax ELSE at.id END) AS tax_id, (CASE WHEN atr.parent_tax IS NOT NULL THEN parent_at.amount diff --git a/addons/l10n_in/views/account_invoice_views.xml b/addons/l10n_in/views/account_invoice_views.xml index 41549a72267..676159126a0 100644 --- a/addons/l10n_in/views/account_invoice_views.xml +++ b/addons/l10n_in/views/account_invoice_views.xml @@ -9,19 +9,19 @@ <group string="Import/Export India"> <field name="l10n_in_import_export" invisible="1"/> <field name="l10n_in_export_type" - attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('type', 'not in', ('out_invoice', 'out_refund'))]}"/> + attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/> <field name="l10n_in_shipping_bill_number" - attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('type', 'not in', ('out_invoice', 'out_refund'))]}"/> + attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/> <field name="l10n_in_shipping_bill_date" - attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('type', 'not in', ('out_invoice', 'out_refund'))]}"/> + attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/> <field name="l10n_in_shipping_port_code_id" - attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('type', 'not in', ('out_invoice', 'out_refund'))]}"/> + attrs="{'invisible': [('l10n_in_import_export', '!=', True), ('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/> </group> </xpath> <xpath expr="//field[@name='partner_id']" position="after"> <field name="l10n_in_reseller_partner_id" groups="l10n_in.group_l10n_in_reseller" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}" + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}" /> </xpath> </field> diff --git a/addons/l10n_in/views/report_invoice.xml b/addons/l10n_in/views/report_invoice.xml index 80a58ee145e..0856519ad66 100644 --- a/addons/l10n_in/views/report_invoice.xml +++ b/addons/l10n_in/views/report_invoice.xml @@ -26,12 +26,12 @@ <xpath expr="//h2" position="replace"> <h2> - <span t-if="o.type == 'out_invoice' and o.state in ('open', 'in_payment', 'paid')" t-field="o.journal_id.name"/> - <span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft <span t-field="o.journal_id.name"/></span> - <span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled <span t-field="o.journal_id.name"/></span> - <span t-if="o.type == 'out_refund'">Credit Note</span> - <span t-if="o.type == 'in_refund'">Vendor Credit Note</span> - <span t-if="o.type == 'in_invoice'">Vendor Bill</span> + <span t-if="o.move_type == 'out_invoice' and o.state in ('open', 'in_payment', 'paid')" t-field="o.journal_id.name"/> + <span t-if="o.move_type == 'out_invoice' and o.state == 'draft'">Draft <span t-field="o.journal_id.name"/></span> + <span t-if="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled <span t-field="o.journal_id.name"/></span> + <span t-if="o.move_type == 'out_refund'">Credit Note</span> + <span t-if="o.move_type == 'in_refund'">Vendor Credit Note</span> + <span t-if="o.move_type == 'in_invoice'">Vendor Bill</span> <span t-field="o.name"/> </h2> </xpath> diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py index 387e6655289..b09bf002b96 100644 --- a/addons/l10n_it_edi/models/account_invoice.py +++ b/addons/l10n_it_edi/models/account_invoice.py @@ -161,7 +161,7 @@ class AccountMove(models.Model): invoice.l10n_it_einvoice_name = report_name data = b"<?xml version='1.0' encoding='UTF-8'?>" + invoice._export_as_xml() - description = _('Italian invoice: %s') % invoice.type + description = _('Italian invoice: %s') % invoice.move_type invoice.l10n_it_einvoice_id = self.env['ir.attachment'].create({ 'name': report_name, 'res_id': invoice.id, @@ -226,9 +226,9 @@ class AccountMove(models.Model): if len(self.commercial_partner_id.l10n_it_pa_index or '1') == 6: formato_trasmissione = "FPA12" - if self.type == 'out_invoice': + if self.move_type == 'out_invoice': document_type = 'TD01' - elif self.type == 'out_refund': + elif self.move_type == 'out_refund': document_type = 'TD04' else: document_type = 'TD0X' @@ -320,9 +320,9 @@ class AccountMove(models.Model): elements = tree.xpath('//DatiGeneraliDocumento/TipoDocumento', namespaces=tree.nsmap) if elements and elements[0].text and elements[0].text == 'TD01': - self_ctx = self.with_context(default_type='in_invoice') + self_ctx = self.with_context(default_move_type='in_invoice') elif elements and elements[0].text and elements[0].text == 'TD04': - self_ctx = self.with_context(default_type='in_refund') + self_ctx = self.with_context(default_move_type='in_refund') else: _logger.info(_('Document type not managed: %s.') % (elements[0].text)) @@ -361,7 +361,7 @@ class AccountMove(models.Model): elif elements and elements[0].text and elements[0].text == 'TD04': type = 'in_refund' # self could be a single record (editing) or be empty (new). - with Form(self.with_context(default_type=type)) as invoice_form: + with Form(self.with_context(default_move_type=type)) as invoice_form: message_to_log = [] # Partner (first step to avoid warning 'Warning! You must first select a partner.'). <1.2> diff --git a/addons/l10n_it_edi/views/l10n_it_view.xml b/addons/l10n_it_edi/views/l10n_it_view.xml index 7f3a1f51297..fb4aedb7cd0 100644 --- a/addons/l10n_it_edi/views/l10n_it_view.xml +++ b/addons/l10n_it_edi/views/l10n_it_view.xml @@ -153,31 +153,31 @@ <data> <xpath expr="//button[@name='preview_invoice']" position="after"> <button name="post" type="object" icon="fa-envelope-o" class="btn btn-primary" string="Resend" - attrs="{'invisible': ['|', ('type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', '!=', 'invalid')]}"/> + attrs="{'invisible': ['|', ('move_type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', '!=', 'invalid')]}"/> </xpath> - <xpath expr="//field[@name='type']" position="before"> + <xpath expr="//field[@name='move_type']" position="before"> <div class="alert alert-success" role="alert" - attrs="{'invisible': ['|', ('type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', 'not in', ['delivered', 'delivered_accepted', 'delivered_refused', 'delivered_expired', 'failed_delivery'])]}"> + attrs="{'invisible': ['|', ('move_type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', 'not in', ['delivered', 'delivered_accepted', 'delivered_refused', 'delivered_expired', 'failed_delivery'])]}"> <i class="fa fa-check" aria-label="Delivered" title="Delivered"></i> <field name="l10n_it_send_state" readonly="1"/> </div> <div class="alert alert-warning" role="alert" - attrs="{'invisible': ['|', ('type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', '!=', 'sent')]}"> + attrs="{'invisible': ['|', ('move_type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', '!=', 'sent')]}"> <i class="fa fa-paper-plane-o"/> E-Invoice sent, waiting for a response </div> <div class="alert alert-danger" role="alert" - attrs="{'invisible': ['|', ('type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', '!=', 'invalid')]}"> + attrs="{'invisible': ['|', ('move_type', 'not in', ('out_invoice', 'out_refund')), ('l10n_it_send_state', '!=', 'invalid')]}"> <i class="fa fa-exclamation-triangle"/> E-Invoice check failed. You can modify the invoice, and resend it. </div> </xpath> <xpath expr="//page[@name='other_info']" position="after"> <page string="Electronic Invoicing" name="electronic_invoicing" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"> <group> <group> <field name="l10n_it_stamp_duty"/> <field name="l10n_it_ddt_id" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}"/> </group> </group> </page> diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index 71b2fbf305d..4b93a7e5764 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -64,7 +64,7 @@ class AccountMove(models.Model): def post(self): for rec in self.filtered(lambda x: x.l10n_latam_use_documents and (not x.name or x.name == '/')): - if rec.type in ('in_receipt', 'out_receipt'): + if rec.move_type in ('in_receipt', 'out_receipt'): raise UserError(_('We do not accept the usage of document types on receipts yet. ')) return super().post() @@ -94,11 +94,11 @@ class AccountMove(models.Model): raise ValidationError(_('The document number on the following invoices is not correct %s.' % ( without_number.ids))) - @api.constrains('type', 'l10n_latam_document_type_id') + @api.constrains('move_type', 'l10n_latam_document_type_id') def _check_invoice_type_document_type(self): for rec in self.filtered('l10n_latam_document_type_id.internal_type'): internal_type = rec.l10n_latam_document_type_id.internal_type - invoice_type = rec.type + invoice_type = rec.tmove_ype if internal_type in ['debit_note', 'invoice'] and invoice_type in ['out_refund', 'in_refund']: raise ValidationError(_('You can not use a %s document type with a refund invoice') % internal_type) elif internal_type == 'credit_note' and invoice_type in ['out_invoice', 'in_invoice']: @@ -106,13 +106,13 @@ class AccountMove(models.Model): def _get_l10n_latam_documents_domain(self): self.ensure_one() - if self.type in ['out_refund', 'in_refund']: + if self.move_type in ['out_refund', 'in_refund']: internal_types = ['credit_note'] else: internal_types = ['invoice', 'debit_note'] return [('internal_type', 'in', internal_types), ('country_id', '=', self.company_id.country_id.id)] - @api.depends('journal_id', 'partner_id', 'company_id', 'type') + @api.depends('journal_id', 'partner_id', 'company_id', 'move_type') def _compute_l10n_latam_available_document_types(self): self.l10n_latam_available_document_type_ids = False for rec in self.filtered(lambda x: x.journal_id and x.l10n_latam_use_documents and x.partner_id): @@ -165,7 +165,7 @@ class AccountMove(models.Model): bills because the uniqueness must be per partner """ for rec in self.filtered(lambda x: x.is_purchase_document() and x.l10n_latam_use_documents): domain = [ - ('type', '=', rec.type), + ('move_type', '=', rec.move_type), # by validating name we validate l10n_latam_document_type_id ('name', '=', rec.name), ('company_id', '=', rec.company_id.id), diff --git a/addons/l10n_latam_invoice_document/models/l10n_latam_document_type.py b/addons/l10n_latam_invoice_document/models/l10n_latam_document_type.py index a21eafcf8f8..72de31e5ebc 100644 --- a/addons/l10n_latam_invoice_document/models/l10n_latam_document_type.py +++ b/addons/l10n_latam_invoice_document/models/l10n_latam_document_type.py @@ -23,7 +23,7 @@ class L10nLatamDocumentType(models.Model): report_name = fields.Char('Name on Reports', help='Name that will be printed in reports, for example "CREDIT NOTE"') internal_type = fields.Selection( [('invoice', 'Invoices'), ('debit_note', 'Debit Notes'), ('credit_note', 'Credit Notes')], index=True, - help='Analog to odoo account.move.type but with more options allowing to identify the kind of document we are' + help='Analog to odoo account.move.move_type but with more options allowing to identify the kind of document we are' ' working with. (not only related to account.move, could be for documents of other models like stock.picking)') def _format_document_number(self, document_number): diff --git a/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py b/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py index d7b202af62a..e962a0c6a5d 100644 --- a/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py +++ b/addons/l10n_latam_invoice_document/wizards/account_move_reversal.py @@ -38,7 +38,7 @@ class AccountMoveReversal(models.TransientModel): if record.l10n_latam_use_documents: refund = record.env['account.move'].new({ - 'type': record._reverse_type_map(record.move_ids.type), + 'move_type': record._reverse_type_map(record.move_ids.move_type), 'journal_id': record.move_ids.journal_id.id, 'partner_id': record.move_ids.partner_id.id, 'company_id': record.move_ids.company_id.id, diff --git a/addons/mass_mailing_sale/models/mailing_mailing.py b/addons/mass_mailing_sale/models/mailing_mailing.py index 4d4081da489..36009ecc594 100644 --- a/addons/mass_mailing_sale/models/mailing_mailing.py +++ b/addons/mass_mailing_sale/models/mailing_mailing.py @@ -44,7 +44,7 @@ class MassMailing(models.Model): } action['domain'] = [ ('id', 'in', moves.ids), - ('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), + ('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), ('state', 'not in', ['draft', 'cancel']) ] action['context'] = {'create': False} diff --git a/addons/membership/models/account_move.py b/addons/membership/models/account_move.py index 1db7edd8bf5..83f1a4f7a86 100644 --- a/addons/membership/models/account_move.py +++ b/addons/membership/models/account_move.py @@ -13,7 +13,7 @@ class AccountMove(models.Model): # OVERRIDE to update the cancel date. res = super(AccountMove, self).button_draft() for move in self: - if move.type == 'out_invoice': + if move.move_type == 'out_invoice': self.env['membership.membership_line'].search([ ('account_invoice_line', 'in', move.mapped('invoice_line_ids').ids) ]).write({'date_cancel': False}) @@ -23,7 +23,7 @@ class AccountMove(models.Model): # OVERRIDE to update the cancel date. res = super(AccountMove, self).button_cancel() for move in self: - if move.type == 'out_invoice': + if move.move_type == 'out_invoice': self.env['membership.membership_line'].search([ ('account_invoice_line', 'in', move.mapped('invoice_line_ids').ids) ]).write({'date_cancel': fields.Date.today()}) @@ -46,7 +46,7 @@ class AccountMoveLine(models.Model): # OVERRIDE res = super(AccountMoveLine, self).write(vals) - to_process = self.filtered(lambda line: line.move_id.type == 'out_invoice' and line.product_id.membership) + to_process = self.filtered(lambda line: line.move_id.move_type == 'out_invoice' and line.product_id.membership) # Nothing to process, break. if not to_process: @@ -82,7 +82,7 @@ class AccountMoveLine(models.Model): def create(self, vals_list): # OVERRIDE lines = super(AccountMoveLine, self).create(vals_list) - to_process = lines.filtered(lambda line: line.move_id.type == 'out_invoice' and line.product_id.membership) + to_process = lines.filtered(lambda line: line.move_id.move_type == 'out_invoice' and line.product_id.membership) # Nothing to process, break. if not to_process: diff --git a/addons/membership/models/partner.py b/addons/membership/models/partner.py index d8dd059a0b1..d720fd5ec02 100644 --- a/addons/membership/models/partner.py +++ b/addons/membership/models/partner.py @@ -125,7 +125,7 @@ class Partner(models.Model): raise UserError(_("Partner doesn't have an address to make the invoice.")) invoice_vals_list.append({ - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': partner.id, 'invoice_line_ids': [ (0, None, {'product_id': product.id, 'quantity': 1, 'price_unit': amount, 'tax_ids': [(6, 0, product.taxes_id.ids)]}) diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 80192008613..ae90f89fa92 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -625,7 +625,7 @@ class PaymentTransaction(models.Model): payment_id = fields.Many2one('account.payment', string='Payment', readonly=True) invoice_ids = fields.Many2many('account.move', 'account_invoice_transaction_rel', 'transaction_id', 'invoice_id', string='Invoices', copy=False, readonly=True, - domain=[('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]) + domain=[('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]) invoice_ids_nbr = fields.Integer(compute='_compute_invoice_ids_nbr', string='# of Invoices') _sql_constraints = [ diff --git a/addons/payment/views/account_invoice_views.xml b/addons/payment/views/account_invoice_views.xml index 1253e0382a7..8e57cda00a6 100644 --- a/addons/payment/views/account_invoice_views.xml +++ b/addons/payment/views/account_invoice_views.xml @@ -10,17 +10,17 @@ The user must capture/void the authorized transactions before registering a new payment. --> <xpath expr="//button[@id='account_invoice_payment_btn']" position="attributes"> - <attribute name="attrs">{'invisible': ['|', '|', '|', ('state', '!=', 'posted'), ('payment_state', 'not in', ('partial', 'not_paid')), ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), ('authorized_transaction_ids', '!=', [])]}</attribute> + <attribute name="attrs">{'invisible': ['|', '|', '|', ('state', '!=', 'posted'), ('payment_state', 'not in', ('partial', 'not_paid')), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), ('authorized_transaction_ids', '!=', [])]}</attribute> </xpath> <xpath expr="//button[@id='account_invoice_payment_btn']" position="after"> <field name="authorized_transaction_ids" invisible="1"/> <button name="payment_action_capture" type="object" string="Capture Transaction" class="oe_highlight" - attrs="{'invisible': ['|', '|', ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('state', '!=', 'posted'), ('authorized_transaction_ids', '=', [])]}"/> + attrs="{'invisible': ['|', '|', ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('state', '!=', 'posted'), ('authorized_transaction_ids', '=', [])]}"/> <button name="payment_action_void" type="object" string="Void Transaction" confirm="Are you sure you want to void the authorized transaction? This action can't be undone." - attrs="{'invisible': ['|', '|', ('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('state', '!=', 'posted'), ('authorized_transaction_ids', '=', [])]}"/> + attrs="{'invisible': ['|', '|', ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), ('state', '!=', 'posted'), ('authorized_transaction_ids', '=', [])]}"/> </xpath> </field> </record> diff --git a/addons/point_of_sale/models/account_move.py b/addons/point_of_sale/models/account_move.py index b218dfa5b79..0874ab2ea7f 100644 --- a/addons/point_of_sale/models/account_move.py +++ b/addons/point_of_sale/models/account_move.py @@ -11,15 +11,15 @@ class AccountMove(models.Model): def _stock_account_get_last_step_stock_moves(self): stock_moves = super(AccountMove, self)._stock_account_get_last_step_stock_moves() - for invoice in self.filtered(lambda x: x.type == 'out_invoice'): + for invoice in self.filtered(lambda x: x.move_type == 'out_invoice'): stock_moves += invoice.sudo().mapped('pos_order_ids.picking_ids.move_lines').filtered(lambda x: x.state == 'done' and x.location_dest_id.usage == 'customer') - for invoice in self.filtered(lambda x: x.type == 'out_refund'): + for invoice in self.filtered(lambda x: x.move_type == 'out_refund'): stock_moves += invoice.sudo().mapped('pos_order_ids.picking_ids.move_lines').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'customer') return stock_moves def _compute_amount(self): super(AccountMove, self)._compute_amount() - pos_invoices = self.filtered(lambda i: i.type in ['out_invoice', 'out_refund'] and i.pos_order_ids) + pos_invoices = self.filtered(lambda i: i.move_type in ['out_invoice', 'out_refund'] and i.pos_order_ids) for invoice in pos_invoices: invoice.payment_state = 'paid' diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 69c92b4f761..42a304f9d76 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -351,7 +351,7 @@ class PosOrder(models.Model): 'view_mode': 'form', 'view_id': self.env.ref('account.view_move_form').id, 'res_model': 'account.move', - 'context': "{'type':'out_invoice'}", + 'context': "{'move_type':'out_invoice'}", 'type': 'ir.actions.act_window', 'res_id': self.account_move.id, } @@ -387,7 +387,7 @@ class PosOrder(models.Model): 'invoice_payment_ref': order.name, 'invoice_origin': order.name, 'journal_id': order.session_id.config_id.invoice_journal_id.id, - 'type': 'out_invoice' if order.amount_total >= 0 else 'out_refund', + 'move_type': 'out_invoice' if order.amount_total >= 0 else 'out_refund', 'ref': order.name, 'partner_id': order.partner_id.id, 'narration': order.note or '', @@ -401,7 +401,7 @@ class PosOrder(models.Model): } new_move = moves.sudo()\ .with_company(order.company_id)\ - .with_context(default_type=move_vals['type'])\ + .with_context(default_move_type=move_vals['move_type'])\ .create(move_vals) message = _("This invoice has been created from the point of sale session: <a href=# data-oe-model=pos.order data-oe-id=%d>%s</a>") % (order.id, order.name) new_move.message_post(body=message) @@ -417,7 +417,7 @@ class PosOrder(models.Model): 'view_mode': 'form', 'view_id': self.env.ref('account.view_move_form').id, 'res_model': 'account.move', - 'context': "{'type':'out_invoice'}", + 'context': "{'move_type':'out_invoice'}", 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'current', diff --git a/addons/product_email_template/models/account_move.py b/addons/product_email_template/models/account_move.py index 62c2eab7b6c..f663df4d333 100644 --- a/addons/product_email_template/models/account_move.py +++ b/addons/product_email_template/models/account_move.py @@ -7,7 +7,7 @@ class AccountMove(models.Model): _inherit = 'account.move' def invoice_validate_send_email(self): - for invoice in self.filtered(lambda x: x.type == 'out_invoice'): + for invoice in self.filtered(lambda x: x.move_type == 'out_invoice'): # send template only on customer invoice # subscribe the partner to the invoice if invoice.partner_id not in invoice.message_partner_ids: diff --git a/addons/product_margin/models/product_product.py b/addons/product_margin/models/product_product.py index 79a81009217..c43ff4f925b 100644 --- a/addons/product_margin/models/product_product.py +++ b/addons/product_margin/models/product_product.py @@ -104,7 +104,7 @@ class ProductProduct(models.Model): #Cost price is calculated afterwards as it is a property self.env['account.move.line'].flush(['price_unit', 'quantity', 'balance', 'product_id', 'display_type']) - self.env['account.move'].flush(['state', 'payment_state', 'type', 'invoice_date', 'company_id']) + self.env['account.move'].flush(['state', 'payment_state', 'move_type', 'invoice_date', 'company_id']) self.env['product.template'].flush(['list_price']) sqlstr = """ WITH currency_rate AS ({}) @@ -125,7 +125,7 @@ class ProductProduct(models.Model): WHERE l.product_id = %s AND i.state IN %s AND i.payment_state IN %s - AND i.type IN %s + AND i.move_type IN %s AND i.invoice_date BETWEEN %s AND %s AND i.company_id = %s AND l.display_type IS NULL diff --git a/addons/product_margin/tests/test_product_margin.py b/addons/product_margin/tests/test_product_margin.py index 6bcca596b4a..b6eb005ab65 100644 --- a/addons/product_margin/tests/test_product_margin.py +++ b/addons/product_margin/tests/test_product_margin.py @@ -12,7 +12,7 @@ class TestProductMargin(AccountTestCommon): def create_account_invoice(self, invoice_type, partner, product, quantity=0.0, price_unit=0.0): """ Create an invoice as in a view by triggering its onchange methods""" - invoice_form = Form(self.env['account.move'].with_context(default_type=invoice_type)) + invoice_form = Form(self.env['account.move'].with_context(default_move_type=invoice_type)) invoice_form.partner_id = partner with invoice_form.invoice_line_ids.new() as line: line.product_id = product diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 2b1acb20bd6..82ead2bdf0b 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -409,7 +409,7 @@ class PurchaseOrder(models.Model): create_bill = self.env.context.get('create_bill', False) # override the context to get rid of the default filtering result['context'] = { - 'default_type': 'in_invoice', + 'default_move_type': 'in_invoice', 'default_company_id': self.company_id.id, 'default_purchase_id': self.id, } @@ -532,9 +532,9 @@ class PurchaseOrderLine(models.Model): qty = 0.0 for inv_line in line.invoice_lines: if inv_line.move_id.state not in ['cancel']: - if inv_line.move_id.type == 'in_invoice': + if inv_line.move_id.move_type == 'in_invoice': qty += inv_line.product_uom_id._compute_quantity(inv_line.quantity, line.product_uom) - elif inv_line.move_id.type == 'in_refund': + elif inv_line.move_id.move_type == 'in_refund': qty -= inv_line.product_uom_id._compute_quantity(inv_line.quantity, line.product_uom) line.qty_invoiced = qty diff --git a/addons/purchase/models/res_partner.py b/addons/purchase/models/res_partner.py index 9e9f391c95a..a65bc899944 100644 --- a/addons/purchase/models/res_partner.py +++ b/addons/purchase/models/res_partner.py @@ -35,7 +35,7 @@ class res_partner(models.Model): supplier_invoice_groups = self.env['account.move'].read_group( domain=[('partner_id', 'in', all_partners.ids), - ('type', 'in', ('in_invoice', 'in_refund'))], + ('move_type', 'in', ('in_invoice', 'in_refund'))], fields=['partner_id'], groupby=['partner_id'] ) partners = self.browse() diff --git a/addons/purchase/report/purchase_bill.py b/addons/purchase/report/purchase_bill.py index 8517cc6ad5b..dc03d320582 100644 --- a/addons/purchase/report/purchase_bill.py +++ b/addons/purchase/report/purchase_bill.py @@ -29,7 +29,7 @@ class PurchaseBillUnion(models.Model): id as vendor_bill_id, NULL as purchase_order_id FROM account_move WHERE - type='in_invoice' and state = 'posted' + move_type='in_invoice' and state = 'posted' UNION SELECT -id, name, partner_ref as reference, partner_id, date_order::date as date, amount_untaxed as amount, currency_id, company_id, diff --git a/addons/purchase/tests/test_purchase_order_report.py b/addons/purchase/tests/test_purchase_order_report.py index 53b76e16155..4d0dec1d34b 100644 --- a/addons/purchase/tests/test_purchase_order_report.py +++ b/addons/purchase/tests/test_purchase_order_report.py @@ -55,7 +55,7 @@ class TestPurchaseOrderReport(AccountTestCommon): }) po.button_confirm() - f = Form(self.env['account.move'].with_context(default_type='in_invoice')) + f = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) f.partner_id = po.partner_id f.purchase_id = po invoice = f.save() diff --git a/addons/purchase/views/account_move_views.xml b/addons/purchase/views/account_move_views.xml index f60fe6490b1..0577779faaa 100644 --- a/addons/purchase/views/account_move_views.xml +++ b/addons/purchase/views/account_move_views.xml @@ -10,7 +10,7 @@ <field name="invoice_vendor_bill_id" position="after"> <field name="purchase_id" invisible="1"/> <field name="purchase_vendor_bill_id" - attrs="{'invisible': ['|', '|', ('state','not in',['draft']), ('state', '=', 'purchase'), ('type', '!=', 'in_invoice')]}" + attrs="{'invisible': ['|', '|', ('state','not in',['draft']), ('state', '=', 'purchase'), ('move_type', '!=', 'in_invoice')]}" class="oe_edit_only" domain="[('company_id', '=', company_id), ('partner_id','child_of', [partner_id])]" placeholder="Select a purchase order or an old bill" diff --git a/addons/purchase/views/res_partner_views.xml b/addons/purchase/views/res_partner_views.xml index 1415c783e71..14265d174a0 100644 --- a/addons/purchase/views/res_partner_views.xml +++ b/addons/purchase/views/res_partner_views.xml @@ -50,8 +50,8 @@ <field name="name">Vendor Bills</field> <field name="res_model">account.move</field> <field name="view_mode">tree,form,graph</field> - <field name="domain">[('type','in',('in_invoice', 'in_refund'))]</field> - <field name="context">{'search_default_partner_id': active_id, 'default_type': 'in_invoice', 'default_partner_id': active_id}</field> + <field name="domain">[('move_type','in',('in_invoice', 'in_refund'))]</field> + <field name="context">{'search_default_partner_id': active_id, 'default_move_type': 'in_invoice', 'default_partner_id': active_id}</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Record a new vendor bill diff --git a/addons/purchase_stock/models/account_invoice.py b/addons/purchase_stock/models/account_invoice.py index 81154f1d394..1d9d9c72788 100644 --- a/addons/purchase_stock/models/account_invoice.py +++ b/addons/purchase_stock/models/account_invoice.py @@ -37,7 +37,7 @@ class AccountMove(models.Model): lines_vals_list = [] for move in self: - if move.type not in ('in_invoice', 'in_refund', 'in_receipt') or not move.company_id.anglo_saxon_accounting: + if move.move_type not in ('in_invoice', 'in_refund', 'in_receipt') or not move.company_id.anglo_saxon_accounting: continue for line in move.invoice_line_ids.filtered(lambda line: line.product_id.type == 'product' and line.product_id.valuation == 'real_time'): @@ -61,7 +61,7 @@ class AccountMove(models.Model): ('state', '=', 'done'), ('product_qty', '!=', 0.0), ]) - if move.type == 'in_refund': + if move.move_type == 'in_refund': valuation_stock_moves = valuation_stock_moves.filtered(lambda stock_move: stock_move._is_out()) else: valuation_stock_moves = valuation_stock_moves.filtered(lambda stock_move: stock_move._is_in()) @@ -110,7 +110,7 @@ class AccountMove(models.Model): price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0) if line.tax_ids: price_unit = line.tax_ids.compute_all( - price_unit, currency=move.currency_id, quantity=1.0, is_refund=move.type == 'in_refund')['total_excluded'] + price_unit, currency=move.currency_id, quantity=1.0, is_refund=move.move_type == 'in_refund')['total_excluded'] if float_compare(valuation_price_unit, price_unit, precision_digits=invoice_cur_prec) != 0 \ and float_compare(line['price_unit'], line.price_unit, precision_digits=invoice_cur_prec) == 0: @@ -169,8 +169,8 @@ class AccountMove(models.Model): """ Overridden from stock_account. Returns the stock moves associated to this invoice.""" rslt = super(AccountMove, self)._stock_account_get_last_step_stock_moves() - for invoice in self.filtered(lambda x: x.type == 'in_invoice'): + for invoice in self.filtered(lambda x: x.move_type == 'in_invoice'): rslt += invoice.mapped('invoice_line_ids.purchase_line_id.move_ids').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'supplier') - for invoice in self.filtered(lambda x: x.type == 'in_refund'): + for invoice in self.filtered(lambda x: x.move_type == 'in_refund'): rslt += invoice.mapped('invoice_line_ids.purchase_line_id.move_ids').filtered(lambda x: x.state == 'done' and x.location_dest_id.usage == 'supplier') return rslt diff --git a/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py b/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py index 114f8d9a5e1..08ba1cabc25 100644 --- a/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py +++ b/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py @@ -44,7 +44,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon): return rslt def _create_invoice_for_po(self, purchase_order, date): - 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.invoice_date = date move_form.partner_id = self.test_partner move_form.currency_id = self.currency_two diff --git a/addons/purchase_stock/tests/test_purchase_order.py b/addons/purchase_stock/tests/test_purchase_order.py index 09b0c934714..03b4b3035a3 100644 --- a/addons/purchase_stock/tests/test_purchase_order.py +++ b/addons/purchase_stock/tests/test_purchase_order.py @@ -76,7 +76,7 @@ class TestPurchaseOrder(AccountTestCommon): self.picking.button_validate() self.assertEqual(self.po.order_line.mapped('qty_received'), [5.0, 5.0], 'Purchase: all products should be received"') - 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_id move_form.purchase_id = self.po self.invoice = move_form.save() @@ -108,7 +108,7 @@ class TestPurchaseOrder(AccountTestCommon): self.assertEqual(self.po.order_line.mapped('qty_received'), [5.0, 5.0], 'Purchase: all products should be received"') #After Receiving all products create vendor bill. - 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_id move_form.purchase_id = self.po self.invoice = move_form.save() @@ -138,7 +138,7 @@ class TestPurchaseOrder(AccountTestCommon): # Check Received quantity self.assertEqual(self.po.order_line[0].qty_received, 3.0, 'Purchase: delivered quantity should be 3.0 instead of "%s" after picking return' % self.po.order_line[0].qty_received) #Create vendor bill for refund qty - move_form = Form(self.env['account.move'].with_context(default_type='in_refund')) + move_form = Form(self.env['account.move'].with_context(default_move_type='in_refund')) move_form.partner_id = self.partner_id move_form.purchase_id = self.po self.invoice = move_form.save() diff --git a/addons/purchase_stock/tests/test_stockvaluation.py b/addons/purchase_stock/tests/test_stockvaluation.py index 52847067d3f..4107b7f9418 100644 --- a/addons/purchase_stock/tests/test_stockvaluation.py +++ b/addons/purchase_stock/tests/test_stockvaluation.py @@ -376,7 +376,7 @@ class TestStockValuationWithCOA(AccountTestCommon): receipt_po1.move_lines.quantity_done = 10 receipt_po1.button_validate() - 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_id move_form.purchase_id = po1 invoice_po1 = move_form.save() @@ -401,7 +401,7 @@ class TestStockValuationWithCOA(AccountTestCommon): receipt_po2.move_lines.quantity_done = 10 receipt_po2.button_validate() - 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_id move_form.purchase_id = po2 invoice_po2 = move_form.save() @@ -425,7 +425,7 @@ class TestStockValuationWithCOA(AccountTestCommon): self.assertEqual(self.product1.value_svl, 200) # create a credit note for po2 - move_form = Form(self.env['account.move'].with_context(default_type='in_refund')) + move_form = Form(self.env['account.move'].with_context(default_move_type='in_refund')) move_form.partner_id = self.partner_id move_form.purchase_id = po2 with move_form.invoice_line_ids.edit(0) as line_form: @@ -460,7 +460,7 @@ class TestStockValuationWithCOA(AccountTestCommon): receipt.button_validate() # Create an invoice with a different price - 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 = order.partner_id move_form.purchase_id = order with move_form.invoice_line_ids.edit(0) as line_form: @@ -575,8 +575,8 @@ class TestStockValuationWithCOA(AccountTestCommon): }) po.button_confirm() - inv = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', + inv = self.env['account.move'].with_context(default_move_type='in_invoice').create({ + 'move_type': 'in_invoice', 'invoice_date': date_po, 'date': date_po, 'currency_id': self.eur_currency.id, @@ -708,8 +708,8 @@ class TestStockValuationWithCOA(AccountTestCommon): line_product_average = po.order_line.filtered(lambda l: l.product_id == self.product1) line_product_standard = po.order_line.filtered(lambda l: l.product_id == product_standard) - inv = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', + inv = self.env['account.move'].with_context(default_move_type='in_invoice').create({ + 'move_type': 'in_invoice', 'invoice_date': date_invoice, 'date': date_invoice, 'currency_id': self.eur_currency.id, @@ -883,8 +883,8 @@ class TestStockValuationWithCOA(AccountTestCommon): self.assertAlmostEqual(product_avg.standard_price, 42.86) today = date_invoice - inv = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', + inv = self.env['account.move'].with_context(default_move_type='in_invoice').create({ + 'move_type': 'in_invoice', 'invoice_date': date_invoice, 'date': date_invoice, 'currency_id': self.eur_currency.id, @@ -1060,8 +1060,8 @@ class TestStockValuationWithCOA(AccountTestCommon): self.assertAlmostEqual(product_avg.standard_price, 42.86) today = date_invoice - inv = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', + inv = self.env['account.move'].with_context(default_move_type='in_invoice').create({ + 'move_type': 'in_invoice', 'invoice_date': date_invoice, 'date': date_invoice, 'currency_id': self.eur_currency.id, @@ -1090,8 +1090,8 @@ class TestStockValuationWithCOA(AccountTestCommon): self.assertAlmostEqual(product_avg.standard_price, 40.18) today = date_invoice1 - inv1 = self.env['account.move'].with_context(default_type='in_invoice').create({ - 'type': 'in_invoice', + inv1 = self.env['account.move'].with_context(default_move_type='in_invoice').create({ + 'move_type': 'in_invoice', 'invoice_date': date_invoice1, 'date': date_invoice1, 'currency_id': self.eur_currency.id, @@ -1215,7 +1215,7 @@ class TestStockValuationWithCOA(AccountTestCommon): receipt.button_validate() # Create an invoice with a different price and a discount - invoice_form = Form(self.env['account.move'].with_context(default_type='in_invoice')) + invoice_form = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) invoice_form.purchase_id = order with invoice_form.invoice_line_ids.edit(0) as line_form: line_form.price_unit = 100.0 @@ -1262,7 +1262,7 @@ class TestStockValuationWithCOA(AccountTestCommon): receipt.button_validate() # Create an invoice with a different price and a discount - invoice_form = Form(self.env['account.move'].with_context(default_type='in_invoice')) + invoice_form = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) invoice_form.purchase_id = order with invoice_form.invoice_line_ids.edit(0) as line_form: line_form.tax_ids.clear() @@ -1309,7 +1309,7 @@ class TestStockValuationWithCOA(AccountTestCommon): receipt.button_validate() # Create an invoice with a different price and a discount - invoice_form = Form(self.env['account.move'].with_context(default_type='in_invoice')) + invoice_form = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) invoice_form.purchase_id = order with invoice_form.invoice_line_ids.edit(0) as line_form: line_form.price_unit = 100.0 diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 973f25fc7dd..956dfabe2f1 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -89,7 +89,7 @@ class Repair(models.Model): invoice_id = fields.Many2one( 'account.move', 'Invoice', copy=False, readonly=True, tracking=True, - domain=[('type', '=', 'out_invoice')]) + domain=[('move_type', '=', 'out_invoice')]) move_id = fields.Many2one( 'stock.move', 'Move', copy=False, readonly=True, tracking=True, check_company=True, @@ -318,7 +318,7 @@ class Repair(models.Model): if not group or len(current_invoices_list) == 0: fpos = self.env['account.fiscal.position'].get_fiscal_position(partner_invoice.id, delivery_id=repair.address_id.id) invoice_vals = { - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'partner_id': partner_invoice.id, 'currency_id': currency.id, 'narration': narration, @@ -430,7 +430,7 @@ class Repair(models.Model): for company_id, invoices_vals_list in invoices_vals_list_per_company.items(): # VFE TODO remove the default_company_id ctxt key ? # Account fallbacks on self.env.company, which is correct with with_company - self.env['account.move'].with_company(company_id).with_context(default_company_id=company_id, default_type='out_invoice').create(invoices_vals_list) + self.env['account.move'].with_company(company_id).with_context(default_company_id=company_id, default_move_type='out_invoice').create(invoices_vals_list) repairs.write({'invoiced': True}) repairs.mapped('operations').filtered(lambda op: op.type == 'add').write({'invoiced': True}) diff --git a/addons/repair/wizard/repair_make_invoice.py b/addons/repair/wizard/repair_make_invoice.py index e6942448ea4..0556257dac7 100644 --- a/addons/repair/wizard/repair_make_invoice.py +++ b/addons/repair/wizard/repair_make_invoice.py @@ -29,6 +29,6 @@ class MakeInvoice(models.TransientModel): 'res_model': 'account.move', 'view_id': False, 'views': [(self.env.ref('account.view_move_tree').id, 'tree'), (self.env.ref('account.view_move_form').id, 'form')], - 'context': "{'type':'out_invoice'}", + 'context': "{'move_type':'out_invoice'}", 'type': 'ir.actions.act_window' } diff --git a/addons/sale/models/account_invoice.py b/addons/sale/models/account_invoice.py index 57c9ef73e69..14fd5f089d1 100644 --- a/addons/sale/models/account_invoice.py +++ b/addons/sale/models/account_invoice.py @@ -52,7 +52,7 @@ class AccountMove(models.Model): res = super(AccountMove, self)._onchange_partner_id() # Recompute 'narration' based on 'company.invoice_terms'. - if self.type == 'out_invoice': + if self.move_type == 'out_invoice': self.narration = self.company_id.with_context(lang=self.partner_id.lang).invoice_terms return res diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 55a52d9d1f1..9b1a7096d6a 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -59,7 +59,7 @@ class SaleOrder(models.Model): # existing invoices. This is necessary since such a refund is not # directly linked to the SO. for order in self: - invoices = order.order_line.invoice_lines.move_id.filtered(lambda r: r.type in ('out_invoice', 'out_refund')) + invoices = order.order_line.invoice_lines.move_id.filtered(lambda r: r.move_type in ('out_invoice', 'out_refund')) order.invoice_ids = invoices order.invoice_count = len(invoices) @@ -119,7 +119,7 @@ class SaleOrder(models.Model): order.order_line._compute_tax_id() def _search_invoice_ids(self, operator, value): - return ['&', ('order_line.invoice_lines.move_id.type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)] + return ['&', ('order_line.invoice_lines.move_id.move_type', 'in', ('out_invoice', 'out_refund')), ('order_line.invoice_lines.move_id', operator, value)] name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, states={'draft': [('readonly', False)]}, index=True, default=lambda self: _('New')) origin = fields.Char(string='Source Document', help="Reference of the document that generated this sales order request.") @@ -526,13 +526,13 @@ class SaleOrder(models.Model): """ self.ensure_one() self = self.with_company(self.company_id) - journal = self.env['account.move'].with_company(self.company_id).with_context(default_type='out_invoice')._get_default_journal() + journal = self.env['account.move'].with_company(self.company_id).with_context(default_move_type='out_invoice')._get_default_journal() if not journal: raise UserError(_('Please define an accounting sales journal for the company %s (%s).') % (self.company_id.name, self.company_id.id)) invoice_vals = { 'ref': self.client_order_ref or '', - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'narration': self.note, 'currency_id': self.pricelist_id.currency_id.id, 'campaign_id': self.campaign_id.id, @@ -569,7 +569,7 @@ class SaleOrder(models.Model): action = {'type': 'ir.actions.act_window_close'} context = { - 'default_type': 'out_invoice', + 'default_move_type': 'out_invoice', } if len(self) == 1: context.update({ @@ -656,7 +656,7 @@ class SaleOrder(models.Model): # 3) Create invoices. # Manage the creation of invoices in sudo because a salesperson must be able to generate an invoice from a # sale order without "billing" access rights. However, he should not be able to create an invoice from scratch. - moves = self.env['account.move'].sudo().with_context(default_type='out_invoice').create(invoice_vals_list) + moves = self.env['account.move'].sudo().with_context(default_move_type='out_invoice').create(invoice_vals_list) # 4) Some moves might actually be refunds: convert them if the total amount is negative # We do this after the moves have been created since we need taxes, etc. to know if the total # is actually negative or not @@ -1076,9 +1076,9 @@ class SaleOrderLine(models.Model): qty_invoiced = 0.0 for invoice_line in line.invoice_lines: if invoice_line.move_id.state != 'cancel': - if invoice_line.move_id.type == 'out_invoice': + if invoice_line.move_id.move_type == 'out_invoice': qty_invoiced += invoice_line.product_uom_id._compute_quantity(invoice_line.quantity, line.product_uom) - elif invoice_line.move_id.type == 'out_refund' : + elif invoice_line.move_id.move_type == 'out_refund': if not line.is_downpayment or line.untaxed_amount_to_invoice == 0 : qty_invoiced -= invoice_line.product_uom_id._compute_quantity(invoice_line.quantity, line.product_uom) line.qty_invoiced = qty_invoiced @@ -1360,7 +1360,7 @@ class SaleOrderLine(models.Model): else: line.qty_delivered_manual = 0.0 - @api.depends('invoice_lines', 'invoice_lines.price_total', 'invoice_lines.move_id.state', 'invoice_lines.move_id.type') + @api.depends('invoice_lines', 'invoice_lines.price_total', 'invoice_lines.move_id.state', 'invoice_lines.move_id.move_type') def _compute_untaxed_amount_invoiced(self): """ Compute the untaxed amount already invoiced from the sale order line, taking the refund attached the so line into account. This amount is computed as @@ -1374,9 +1374,9 @@ class SaleOrderLine(models.Model): for invoice_line in line.invoice_lines: if invoice_line.move_id.state == 'posted': invoice_date = invoice_line.move_id.invoice_date or fields.Date.today() - if invoice_line.move_id.type == 'out_invoice': + if invoice_line.move_id.move_type == 'out_invoice': amount_invoiced += invoice_line.currency_id._convert(invoice_line.price_subtotal, line.currency_id, line.company_id, invoice_date) - elif invoice_line.move_id.type == 'out_refund': + elif invoice_line.move_id.move_type == 'out_refund': amount_invoiced -= invoice_line.currency_id._convert(invoice_line.price_subtotal, line.currency_id, line.company_id, invoice_date) line.untaxed_amount_invoiced = amount_invoiced diff --git a/addons/sale/models/sales_team.py b/addons/sale/models/sales_team.py index 8affae2f3cb..dde443f25ed 100644 --- a/addons/sale/models/sales_team.py +++ b/addons/sale/models/sales_team.py @@ -79,7 +79,7 @@ class CrmTeam(models.Model): SUM(-line.balance) AS amount_untaxed_signed FROM account_move move LEFT JOIN account_move_line line ON line.move_id = move.id - WHERE move.type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund') + WHERE move.move_type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund') AND move.payment_state IN ('in_payment', 'paid') AND move.state = 'posted' AND move.team_id IN %s diff --git a/addons/sale/models/utm.py b/addons/sale/models/utm.py index 44963d0a0e6..7e3ad525df2 100644 --- a/addons/sale/models/utm.py +++ b/addons/sale/models/utm.py @@ -22,13 +22,13 @@ class UtmCampaign(models.Model): def _compute_sale_invoiced_amount(self): self.env['account.move.line'].flush(['balance', 'move_id', 'account_id', 'exclude_from_invoice_tab']) - self.env['account.move'].flush(['state', 'campaign_id', 'type']) + self.env['account.move'].flush(['state', 'campaign_id', 'move_type']) query = """SELECT move.campaign_id, -SUM(line.balance) as price_subtotal FROM account_move_line line INNER JOIN account_move move ON line.move_id = move.id WHERE move.state not in ('draft', 'cancel') AND move.campaign_id IN %s - 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') AND line.account_id IS NOT NULL AND NOT line.exclude_from_invoice_tab GROUP BY move.campaign_id @@ -61,7 +61,7 @@ class UtmCampaign(models.Model): } action['domain'] = [ ('id', 'in', invoices.ids), - ('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), + ('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')), ('state', 'not in', ['draft', 'cancel']) ] return action diff --git a/addons/sale/security/sale_security.xml b/addons/sale/security/sale_security.xml index 942844709e1..aa82f6143fe 100644 --- a/addons/sale/security/sale_security.xml +++ b/addons/sale/security/sale_security.xml @@ -163,14 +163,14 @@ <record id="account_invoice_rule_see_personal" model="ir.rule"> <field name="name">Personal Invoices</field> <field name="model_id" ref="model_account_move"/> - <field name="domain_force">[('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), '|', ('invoice_user_id', '=', user.id), ('invoice_user_id', '=', False)]</field> + <field name="domain_force">[('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund')), '|', ('invoice_user_id', '=', user.id), ('invoice_user_id', '=', False)]</field> <field name="groups" eval="[(4, ref('sales_team.group_sale_salesman'))]"/> </record> <record id="account_invoice_rule_see_all" model="ir.rule"> <field name="name">All Invoices</field> <field name="model_id" ref="model_account_move"/> - <field name="domain_force">[('type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]</field> + <field name="domain_force">[('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]</field> <field name="groups" eval="[(4, ref('sales_team.group_sale_salesman_all_leads'))]"/> </record> diff --git a/addons/sale/tests/test_reinvoice.py b/addons/sale/tests/test_reinvoice.py index 9dc443a2b5b..7c681a1f787 100644 --- a/addons/sale/tests/test_reinvoice.py +++ b/addons/sale/tests/test_reinvoice.py @@ -29,7 +29,7 @@ class TestReInvoice(TestCommonSaleNoChart): 'analytic_account_id': cls.analytic_account.id, }) - cls.AccountMove = cls.env['account.move'].with_context(default_type='in_invoice', mail_notrack=True, mail_create_nolog=True) + cls.AccountMove = cls.env['account.move'].with_context(default_move_type='in_invoice', mail_notrack=True, mail_create_nolog=True) def test_at_cost(self): """ Test vendor bill at cost for product based on ordered and delivered quantities. """ diff --git a/addons/sale/tests/test_sale_order.py b/addons/sale/tests/test_sale_order.py index 711d1d5ff81..124a6c9fe39 100644 --- a/addons/sale/tests/test_sale_order.py +++ b/addons/sale/tests/test_sale_order.py @@ -209,7 +209,7 @@ class TestSaleOrder(TestCommonSaleNoChart): so.action_confirm() so._create_analytic_account() - inv = self.env['account.move'].with_context(default_type='in_invoice').create({ + inv = self.env['account.move'].with_context(default_move_type='in_invoice').create({ 'partner_id': self.partner_customer_usd.id, 'invoice_line_ids': [ (0, 0, { diff --git a/addons/sale/tests/test_sale_refund.py b/addons/sale/tests/test_sale_refund.py index 4e6af956bbd..7c6ae3c5520 100644 --- a/addons/sale/tests/test_sale_refund.py +++ b/addons/sale/tests/test_sale_refund.py @@ -108,11 +108,11 @@ class TestSaleToInvoice(TestCommonSaleNoChart): invoice_refund = self.sale_order.invoice_ids.sorted(key=lambda inv: inv.id, reverse=False)[-1] # the first invoice, its refund, and the new invoice # Check invoice's type and number - self.assertEqual(invoice_refund.type, 'out_refund', 'The last created invoiced should be a refund') + self.assertEqual(invoice_refund.move_type, 'out_refund', 'The last created invoiced should be a refund') self.assertEqual(invoice_refund.state, 'draft', 'Last Customer invoices should be in draft') self.assertEqual(self.sale_order.invoice_count, 2, "The SO should have 2 related invoices: the original, the new refund") - self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.type == 'out_refund')), 1, "The SO should be linked to only one refund") - self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.type == 'out_invoice')), 1, "The SO should be linked to only one customer invoices") + self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.move_type == 'out_refund')), 1, "The SO should be linked to only one refund") + self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.move_type == 'out_invoice')), 1, "The SO should be linked to only one customer invoices") # At this time, the invoice 1 is opend (validated) and its refund is in draft, so the amounts invoiced are not zero for # invoiced sale line. The amounts only take validated invoice/refund into account. @@ -198,11 +198,11 @@ class TestSaleToInvoice(TestCommonSaleNoChart): invoice_refund = self.env['account.move'].browse(credit_note_wizard.reverse_moves()['res_id']) # Check invoice's type and number - self.assertEqual(invoice_refund.type, 'out_refund', 'The last created invoiced should be a customer invoice') + self.assertEqual(invoice_refund.move_type, 'out_refund', 'The last created invoiced should be a customer invoice') self.assertEqual(invoice_refund.payment_state, 'paid', 'Last Customer creadit note should be in paid state') self.assertEqual(self.sale_order.invoice_count, 2, "The SO should have 3 related invoices: the original, the refund, and the new one") - self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.type == 'out_refund')), 1, "The SO should be linked to only one refund") - self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.type == 'out_invoice')), 1, "The SO should be linked to only one customer invoices") + self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.move_type == 'out_refund')), 1, "The SO should be linked to only one refund") + self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.move_type == 'out_invoice')), 1, "The SO should be linked to only one customer invoices") # At this time, the invoice 1 is opened (validated) and its refund validated too, so the amounts invoiced are zero for # all sale line. All invoiceable Sale lines have @@ -260,11 +260,11 @@ class TestSaleToInvoice(TestCommonSaleNoChart): invoice_refund = self.env['account.move'].browse(credit_note_wizard.reverse_moves()['res_id']) # Check invoice's type and number - self.assertEqual(invoice_refund.type, 'out_invoice', 'The last created invoiced should be a customer invoice') + self.assertEqual(invoice_refund.move_type, 'out_invoice', 'The last created invoiced should be a customer invoice') self.assertEqual(invoice_refund.state, 'draft', 'Last Customer invoices should be in draft') self.assertEqual(self.sale_order.invoice_count, 3, "The SO should have 3 related invoices: the original, the refund, and the new one") - self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.type == 'out_refund')), 1, "The SO should be linked to only one refund") - self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.type == 'out_invoice')), 2, "The SO should be linked to two customer invoices") + self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.move_type == 'out_refund')), 1, "The SO should be linked to only one refund") + self.assertEqual(len(self.sale_order.invoice_ids.filtered(lambda inv: inv.move_type == 'out_invoice')), 2, "The SO should be linked to two customer invoices") # At this time, the invoice 1 and its refund are confirmed, so the amounts invoiced are zero. The third invoice # (2nd customer inv) is in draft state. diff --git a/addons/sale/views/sale_views.xml b/addons/sale/views/sale_views.xml index b0c60de581c..80597be751e 100644 --- a/addons/sale/views/sale_views.xml +++ b/addons/sale/views/sale_views.xml @@ -1151,7 +1151,7 @@ <field name="inherit_id" ref="account.view_invoice_tree"/> <field name="arch" type="xml"> <field name="invoice_user_id" position="after"> - <field name="team_id" invisible="context.get('default_type') not in ('out_invoice', 'out_refund','out_receipt')" optional="hide"/> + <field name="team_id" invisible="context.get('default_move_type') not in ('out_invoice', 'out_refund','out_receipt')" optional="hide"/> </field> </field> </record> @@ -1166,7 +1166,7 @@ <xpath expr="//field[@name='partner_id']" position="after"> <field name="partner_shipping_id" groups="sale.group_delivery_invoice_address" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"/> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"/> </xpath> <xpath expr="//field[@name='invoice_line_ids']//field[@name='discount']" position="attributes"> <attribute name="groups">product.group_discount_per_so_line</attribute> @@ -1178,7 +1178,7 @@ <group string="Marketing" name="utm_link" groups="base.group_no_one" - attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund'))]}"> + attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund'))]}"> <field name="campaign_id"/> <field name="medium_id"/> <field name="source_id"/> @@ -1251,12 +1251,12 @@ <field name="view_id" ref="account.view_move_tree"/> <field name="domain">[ ('state', '=', 'posted'), - ('type', 'in', ['out_invoice', 'out_refund'])]</field> + ('move_type', 'in', ['out_invoice', 'out_refund'])]</field> <field name="context">{ 'search_default_team_id': [active_id], 'default_team_id': active_id, - 'default_type':'out_invoice', - 'type':'out_invoice', + 'default_move_type':'out_invoice', + 'move_type':'out_invoice', 'journal_type': 'sale', } </field> diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 12c31d743b4..933431faf04 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -72,7 +72,7 @@ class SaleAdvancePaymentInv(models.TransientModel): def _prepare_invoice_values(self, order, name, amount, so_line): invoice_vals = { - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'invoice_origin': order.name, 'invoice_user_id': order.user_id.id, 'narration': order.note, diff --git a/addons/sale_crm/models/crm_lead.py b/addons/sale_crm/models/crm_lead.py index 0c4dd37297a..56ca8677d3f 100644 --- a/addons/sale_crm/models/crm_lead.py +++ b/addons/sale_crm/models/crm_lead.py @@ -45,15 +45,15 @@ class CrmLead(models.Model): ('state', '=', 'posted'), ('invoice_user_id', '=', self.env.uid), ('invoice_date', '>=', date_today.replace(day=1) - relativedelta(months=+1)), - ('type', 'in', ['out_invoice', 'out_refund']) + ('move_type', 'in', ['out_invoice', 'out_refund']) ] - invoice_data = self.env['account.move'].search_read(account_invoice_domain, ['invoice_date', 'amount_untaxed', 'type']) + invoice_data = self.env['account.move'].search_read(account_invoice_domain, ['invoice_date', 'amount_untaxed', 'move_type']) for invoice in invoice_data: if invoice['invoice_date']: invoice_date = fields.Date.from_string(invoice['invoice_date']) - sign = 1 if invoice['type'] == 'out_invoice' else -1 + sign = 1 if invoice['move_type'] == 'out_invoice' else -1 if invoice_date <= date_today and invoice_date >= date_today.replace(day=1): res['invoiced']['this_month'] += sign * invoice['amount_untaxed'] elif invoice_date < date_today.replace(day=1) and invoice_date >= date_today.replace(day=1) - relativedelta(months=+1): diff --git a/addons/sale_crm/views/crm_lead_views.xml b/addons/sale_crm/views/crm_lead_views.xml index a1efb360f44..b3bbac55a9b 100644 --- a/addons/sale_crm/views/crm_lead_views.xml +++ b/addons/sale_crm/views/crm_lead_views.xml @@ -29,7 +29,7 @@ <!-- add needaction_menu_ref to reload quotation needaction when opportunity needaction is reloaded --> <record id="crm.crm_lead_opportunities" model="ir.actions.act_window"> - <field name="context">{'default_type': 'opportunity', 'default_user_id': uid}</field> + <field name="context">{'default_move_type': 'opportunity', 'default_user_id': uid}</field> </record> <record id="sales_team.mail_activity_type_action_config_sales" model="ir.actions.act_window"> diff --git a/addons/sale_stock/models/account_move.py b/addons/sale_stock/models/account_move.py index df486169219..1f304096e26 100644 --- a/addons/sale_stock/models/account_move.py +++ b/addons/sale_stock/models/account_move.py @@ -14,9 +14,9 @@ class AccountMove(models.Model): """ Overridden from stock_account. Returns the stock moves associated to this invoice.""" rslt = super(AccountMove, self)._stock_account_get_last_step_stock_moves() - for invoice in self.filtered(lambda x: x.type == 'out_invoice'): + for invoice in self.filtered(lambda x: x.move_type == 'out_invoice'): rslt += invoice.mapped('invoice_line_ids.sale_line_ids.order_id.picking_ids.move_lines').filtered(lambda x: x.state == 'done' and x.location_dest_id.usage == 'customer') - for invoice in self.filtered(lambda x: x.type == 'out_refund'): + for invoice in self.filtered(lambda x: x.move_type == 'out_refund'): rslt += invoice.mapped('reversed_entry_id.invoice_line_ids.sale_line_ids.order_id.picking_ids.move_lines').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'customer') return rslt @@ -73,7 +73,7 @@ class AccountMove(models.Model): # Prepare and return lot_values qties_per_lot = defaultdict(lambda: 0) - if self.type == 'out_refund': + if self.move_type == 'out_refund': for ml in outgoing_sml: qties_per_lot[ml.lot_id] -= ml.product_uom_id._compute_quantity(ml.qty_done, ml.product_id.uom_id) for ml in incoming_sml: diff --git a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py index a88ec316542..92b7249bbb5 100644 --- a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py +++ b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py @@ -51,7 +51,7 @@ class TestValuationReconciliation(ValuationReconciliationTestCommon): rslt = self.env['account.move'].create({ 'partner_id': self.test_partner.id, 'currency_id': self.currency_two.id, - 'type': 'out_invoice', + 'move_type': 'out_invoice', 'invoice_date': date, 'invoice_line_ids': [(0, 0, { 'name': 'test line', diff --git a/addons/sale_timesheet/models/account_move.py b/addons/sale_timesheet/models/account_move.py index 91e5ac99ce0..5c4d8ea925b 100644 --- a/addons/sale_timesheet/models/account_move.py +++ b/addons/sale_timesheet/models/account_move.py @@ -49,11 +49,10 @@ class AccountMove(models.Model): When we create an invoice from a sale order, we need to link the timesheets in this sale order to the invoice. Then, we can know which timesheets are invoiced in the sale order. - :param date: All timesheets on task before or equals this date in the sale order are invoiced. """ - for line in self.filtered(lambda i: i.type == 'out_invoice' and i.state == 'draft').invoice_line_ids: + for line in self.filtered(lambda i: i.move_type == 'out_invoice' and i.state == 'draft').invoice_line_ids: sale_line_delivery = line.sale_line_ids.filtered(lambda sol: sol.product_id.invoice_policy == 'delivery' and sol.product_id.service_type == 'timesheet') if sale_line_delivery: domain = line._timesheet_domain_get_invoiced_lines(sale_line_delivery) diff --git a/addons/sale_timesheet/models/project_overview.py b/addons/sale_timesheet/models/project_overview.py index e5772610e59..cb3853a44d5 100644 --- a/addons/sale_timesheet/models/project_overview.py +++ b/addons/sale_timesheet/models/project_overview.py @@ -481,7 +481,7 @@ class Project(models.Model): invoice_ids = self.env['sale.order'].search_read([('id', 'in', sale_orders.ids)], ['invoice_ids']) invoice_ids = list(itertools.chain(*[i['invoice_ids'] for i in invoice_ids])) - invoice_ids = self.env['account.move'].search_read([('id', 'in', invoice_ids), ('type', '=', 'out_invoice')], ['id']) + invoice_ids = self.env['account.move'].search_read([('id', 'in', invoice_ids), ('move_type', '=', 'out_invoice')], ['id']) invoice_ids = list(map(lambda x: x['id'], invoice_ids)) if invoice_ids: @@ -491,7 +491,7 @@ class Project(models.Model): 'icon': 'fa fa-pencil-square-o', 'action': _to_action_data( action=self.env.ref('account.action_move_out_invoice_type'), - domain=[('id', 'in', invoice_ids), ('type', '=', 'out_invoice')], + domain=[('id', 'in', invoice_ids), ('move_type', '=', 'out_invoice')], context={'create': False, 'delete': False} ) }) diff --git a/addons/sale_timesheet/tests/test_reinvoice.py b/addons/sale_timesheet/tests/test_reinvoice.py index 2f3c6677207..cd4a25fbccb 100644 --- a/addons/sale_timesheet/tests/test_reinvoice.py +++ b/addons/sale_timesheet/tests/test_reinvoice.py @@ -86,7 +86,7 @@ class TestReInvoice(TestCommonSaleTimesheetNoChart): 'employee_id': self.employee_user.id, }) - 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_customer_usd with move_form.line_ids.new() as line_form: line_form.product_id = self.product_ordered_cost @@ -121,7 +121,7 @@ class TestReInvoice(TestCommonSaleTimesheetNoChart): self.assertEqual(sale_order_line4.qty_delivered_method, 'analytic', "Delivered quantity of 'expense' SO line should be computed by analytic amount") # create second invoice lines and validate it - 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_customer_usd with move_form.line_ids.new() as line_form: line_form.product_id = self.product_ordered_cost @@ -185,7 +185,7 @@ class TestReInvoice(TestCommonSaleTimesheetNoChart): }) # create invoice lines and validate it - 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_customer_usd with move_form.line_ids.new() as line_form: line_form.product_id = self.product_deliver_sales_price @@ -220,7 +220,7 @@ class TestReInvoice(TestCommonSaleTimesheetNoChart): self.assertEqual(sale_order_line4.qty_delivered_method, 'analytic', "Delivered quantity of 'expense' SO line 4 should be computed by analytic amount") # create second invoice lines and validate it - 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_customer_usd with move_form.line_ids.new() as line_form: line_form.product_id = self.product_deliver_sales_price @@ -260,7 +260,7 @@ class TestReInvoice(TestCommonSaleTimesheetNoChart): self.sale_order.action_confirm() # create invoice lines and validate it - 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_customer_usd with move_form.line_ids.new() as line_form: line_form.product_id = self.product_no_expense diff --git a/addons/snailmail_account/tests/test_pingen_send.py b/addons/snailmail_account/tests/test_pingen_send.py index 324361785fa..71a1b4b89d3 100644 --- a/addons/snailmail_account/tests/test_pingen_send.py +++ b/addons/snailmail_account/tests/test_pingen_send.py @@ -36,8 +36,8 @@ class TestPingenSend(HttpCase): def create_invoice(self): """ Create a sample invoice """ - invoice = self.env['account.move'].with_context(default_type='out_invoice').create({ - 'type': 'out_invoice', + invoice = self.env['account.move'].with_context(default_move_type='out_invoice').create({ + 'move_type': 'out_invoice', 'partner_id': self.env.ref("base.res_partner_2").id, 'currency_id': self.env.ref('base.EUR').id, 'invoice_date': '2018-12-11', diff --git a/addons/stock_account/models/account_move.py b/addons/stock_account/models/account_move.py index 24d577dcefa..8a9dd971f33 100644 --- a/addons/stock_account/models/account_move.py +++ b/addons/stock_account/models/account_move.py @@ -110,7 +110,7 @@ class AccountMove(models.Model): continue # Compute accounting fields. - sign = -1 if move.type == 'out_refund' else 1 + sign = -1 if move.move_type == 'out_refund' else 1 price_unit = line._stock_account_get_anglo_saxon_price_unit() balance = sign * line.quantity * price_unit diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py index 3d72df9e207..50d7a11c34f 100644 --- a/addons/stock_account/models/product.py +++ b/addons/stock_account/models/product.py @@ -237,7 +237,7 @@ class ProductProduct(models.Model): 'company_id': company_id.id, 'ref': product.default_code, 'stock_valuation_layer_ids': [(6, None, [stock_valuation_layer.id])], - 'type': 'entry', + 'move_type': 'entry', 'line_ids': [(0, 0, { 'name': _('%s changed cost from %s to %s - %s') % (self.env.user.name, product.standard_price, new_price, product.display_name), 'account_id': debit_account_id, @@ -488,7 +488,7 @@ class ProductProduct(models.Model): 'credit': abs(value), 'product_id': product.id, })], - 'type': 'entry', + 'move_type': 'entry', } move_vals_list.append(move_vals) return move_vals_list @@ -524,7 +524,7 @@ class ProductProduct(models.Model): 'credit': abs(value), 'product_id': product.id, })], - 'type': 'entry', + 'move_type': 'entry', } move_vals_list.append(move_vals) return move_vals_list diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index ab6860d78f2..c6e10bf345d 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -455,7 +455,7 @@ class StockMove(models.Model): 'ref': description, 'stock_move_id': self.id, 'stock_valuation_layer_ids': [(6, None, [svl_id])], - 'type': 'entry', + 'move_type': 'entry', }) new_account_move.post() diff --git a/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py b/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py index dfc271f125e..63691b48209 100644 --- a/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py +++ b/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py @@ -26,7 +26,7 @@ class ValuationReconciliationTestCommon(StockAccountTestCommon): self.assertEqual(len(invoice_line), 1, "Only one line should have been written by invoice in stock input account") self.assertTrue(valuation_line.reconciled or invoice_line.reconciled, "The valuation and invoice line should have been reconciled together.") - if invoice.type not in ('out_refund', 'in_refund'): + if invoice.move_type not in ('out_refund', 'in_refund'): self.assertEqual(len(valuation_line), 1, "Only one line should have been written for stock valuation in stock input account") if full_reconcile: diff --git a/addons/stock_dropshipping/tests/test_stockvaluation.py b/addons/stock_dropshipping/tests/test_stockvaluation.py index a99c8f33bd2..6292cf7b88f 100644 --- a/addons/stock_dropshipping/tests/test_stockvaluation.py +++ b/addons/stock_dropshipping/tests/test_stockvaluation.py @@ -108,7 +108,7 @@ class TestStockValuation(StockAccountTestCommon): self.assertEqual(self.sale_order1.picking_ids.state, 'done') # create the vendor bill - 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 = vendor1 move_form.purchase_id = self.purchase_order1 move_form.line_ids.tax_ids = False diff --git a/addons/stock_landed_costs/models/stock_landed_cost.py b/addons/stock_landed_costs/models/stock_landed_cost.py index 35f5f69ceed..026c8e0cf75 100644 --- a/addons/stock_landed_costs/models/stock_landed_cost.py +++ b/addons/stock_landed_costs/models/stock_landed_cost.py @@ -72,7 +72,7 @@ class LandedCost(models.Model): related='account_journal_id.company_id') stock_valuation_layer_ids = fields.One2many('stock.valuation.layer', 'stock_landed_cost_id') vendor_bill_id = fields.Many2one( - 'account.move', 'Vendor Bill', copy=False, domain=[('type', '=', 'in_invoice')]) + 'account.move', 'Vendor Bill', copy=False, domain=[('move_type', '=', 'in_invoice')]) currency_id = fields.Many2one('res.currency', related='company_id.currency_id') @api.depends('cost_lines.price_unit') @@ -131,7 +131,7 @@ class LandedCost(models.Model): 'date': cost.date, 'ref': cost.name, 'line_ids': [], - 'type': 'entry', + 'move_type': 'entry', } valuation_layer_ids = [] for line in cost.valuation_adjustment_lines.filtered(lambda line: line.move_id): diff --git a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py index 99ea441db26..fa459a0f932 100644 --- a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py +++ b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py @@ -292,7 +292,7 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon): # Create a vendor bill for a landed cost product, post it and validate a landed cost # linked to this vendor bill. LC; 1@50 - lcvb = Form(self.env['account.move'].with_context(default_type='in_invoice')) + lcvb = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) lcvb.partner_id = self.vendor2 with lcvb.invoice_line_ids.new() as inv_line: inv_line.product_id = self.productlc1 @@ -434,7 +434,7 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon): # Create a vendor bill for a landed cost product, post it and validate a landed cost # linked to this vendor bill. LC; 1@50 - lcvb = Form(self.env['account.move'].with_context(default_type='in_invoice')) + lcvb = Form(self.env['account.move'].with_context(default_move_type='in_invoice')) lcvb.partner_id = self.vendor2 with lcvb.invoice_line_ids.new() as inv_line: inv_line.product_id = self.productlc1 diff --git a/addons/stock_landed_costs/views/account_move_views.xml b/addons/stock_landed_costs/views/account_move_views.xml index 1a8abca9534..dd2ae77b08c 100644 --- a/addons/stock_landed_costs/views/account_move_views.xml +++ b/addons/stock_landed_costs/views/account_move_views.xml @@ -21,7 +21,7 @@ <xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='name']" position="after"> <field name="product_type" invisible="1"/> - <field name="is_landed_costs_line" string="Landed Costs" attrs="{'readonly': [('product_type', '!=', 'service')], 'column_invisible': [('parent.type', '!=', 'in_invoice')]}" optional="show"/> + <field name="is_landed_costs_line" string="Landed Costs" attrs="{'readonly': [('product_type', '!=', 'service')], 'column_invisible': [('parent.move_type', '!=', 'in_invoice')]}" optional="show"/> </xpath> <xpath expr="//field[@name='line_ids']/tree/field[@name='name']" position="after"> diff --git a/addons/web/static/tests/core/py_utils_tests.js b/addons/web/static/tests/core/py_utils_tests.js index 40cbe5de726..833627983ed 100644 --- a/addons/web/static/tests/core/py_utils_tests.js +++ b/addons/web/static/tests/core/py_utils_tests.js @@ -893,7 +893,7 @@ QUnit.module('core', function () { var result = pyUtils.eval('contexts', [{ "__ref": "compound_context", "__contexts": [ - {"__ref": "context", "__debug": "{'type':parent.type}", + {"__ref": "context", "__debug": "{'type':parent.move_type}", "__id": "462b9dbed42f"} ], "__eval_context": { @@ -901,7 +901,7 @@ QUnit.module('core', function () { "__contexts": [{ "__ref": "compound_context", "__contexts": [ - {"__ref": "context", "__debug": "{'type': type}", + {"__ref": "context", "__debug": "{'type': move_type}", "__id": "16a04ed5a194"} ], "__eval_context": { @@ -909,10 +909,10 @@ QUnit.module('core', function () { "__contexts": [ {"lang": "en_US", "tz": false, "uid": 1, "journal_type": "sale", "section_id": false, - "default_type": "out_invoice", - "type": "out_invoice", "department_id": false}, + "default_move_type": "out_invoice", + "move_type": "out_invoice", "department_id": false}, {"id": false, "journal_id": 10, - "number": false, "type": "out_invoice", + "number": false, "move_type": "out_invoice", "currency_id": 1, "partner_id": 4, "fiscal_position_id": false, "invoice_date": false, "date": false, @@ -949,7 +949,7 @@ QUnit.module('core', function () { "active_model": "account.move.line", "parent": { "id": false, "journal_id": 10, "number": false, - "type": "out_invoice", "currency_id": 1, + "move_type": "out_invoice", "currency_id": 1, "partner_id": 4, "fiscal_position_id": false, "invoice_date": false, "date": false, "payment_term_id": false, diff --git a/addons/website_crm_partner_assign/report/crm_partner_report.py b/addons/website_crm_partner_assign/report/crm_partner_report.py index 42d48cfc674..1d7fdb67b41 100644 --- a/addons/website_crm_partner_assign/report/crm_partner_report.py +++ b/addons/website_crm_partner_assign/report/crm_partner_report.py @@ -24,7 +24,7 @@ class CrmPartnerReportAssign(models.Model): date = fields.Date('Invoice Account Date', readonly=True) _depends = { - 'account.invoice.report': ['invoice_date', 'partner_id', 'price_subtotal', 'state', 'type'], + 'account.invoice.report': ['invoice_date', 'partner_id', 'price_subtotal', 'state', 'move_type'], 'crm.lead': ['partner_assigned_id'], 'res.partner': ['activation', 'country_id', 'date_partnership', 'date_review', 'grade_id', 'parent_id', 'team_id', 'user_id'], @@ -54,5 +54,5 @@ class CrmPartnerReportAssign(models.Model): FROM res_partner p left join account_invoice_report i - on (i.partner_id=p.id and i.type in ('out_invoice','out_refund') and i.state in ('open','in_payment','paid')) + on (i.partner_id=p.id and i.move_type in ('out_invoice','out_refund') and i.state in ('open','in_payment','paid')) )""") diff --git a/addons/website_sale/views/account_views.xml b/addons/website_sale/views/account_views.xml index b728f438b78..1b03a400d95 100644 --- a/addons/website_sale/views/account_views.xml +++ b/addons/website_sale/views/account_views.xml @@ -6,7 +6,7 @@ <field name="view_mode">tree,form</field> <field name="domain">[('team_id.website_ids', '!=', False)]</field> <field name="view_id" ref="account.view_invoice_tree"/> - <field name="context">{'type':'out_invoice'}</field> + <field name="context">{'move_type':'out_invoice'}</field> <field name="search_view_id" ref="account.view_account_invoice_filter"/> </record> |
