[REM] *: calls to @api.multi

Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
This commit is contained in:
Adrian Torres
2019-07-17 14:13:12 +02:00
parent f6fdde96bd
commit 4b38cc6590
463 changed files with 4 additions and 2155 deletions
-23
View File
@@ -173,14 +173,12 @@ class AccountAccount(models.Model):
_description = "Account"
_order = "code"
@api.multi
@api.constrains('internal_type', 'reconcile')
def _check_reconcile(self):
for account in self:
if account.internal_type in ('receivable', 'payable') and account.reconcile == False:
raise ValidationError(_('You cannot have a receivable/payable account that is not reconcilable. (account code: %s)') % account.code)
@api.multi
@api.constrains('user_type_id')
def _check_user_type_id(self):
data_unaffected_earnings = self.env.ref('account.data_unaffected_earnings')
@@ -340,7 +338,6 @@ class AccountAccount(models.Model):
code_prefix = code_prefix[:-1]
self.group_id = group
@api.multi
def name_get(self):
result = []
for account in self:
@@ -348,7 +345,6 @@ class AccountAccount(models.Model):
result.append((account.id, name))
return result
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {})
@@ -421,7 +417,6 @@ class AccountAccount(models.Model):
"""
self.env.cr.execute(query, [tuple(self.ids)])
@api.multi
def write(self, vals):
# Do not allow changing the company_id when account_move_line already exist
if vals.get('company_id', False):
@@ -442,7 +437,6 @@ class AccountAccount(models.Model):
return super(AccountAccount, self).write(vals)
@api.multi
def unlink(self):
if self.env['account.move.line'].search([('account_id', 'in', self.ids)], limit=1):
raise UserError(_('You cannot perform this action on an account that contains journal items.'))
@@ -453,7 +447,6 @@ class AccountAccount(models.Model):
raise UserError(_('You cannot remove/deactivate an account which is set on a customer or vendor.'))
return super(AccountAccount, self).unlink()
@api.multi
def action_open_reconcile(self):
self.ensure_one()
# Open reconciliation view for this account
@@ -613,13 +606,11 @@ class AccountJournal(models.Model):
('code_company_uniq', 'unique (code, name, company_id)', 'The code and name of the journal must be unique per company !'),
]
@api.multi
def _compute_alias_domain(self):
alias_domain = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain")
for record in self:
record.alias_domain = alias_domain
@api.multi
# do not depend on 'sequence_id.date_range_ids', because
# sequence_id._get_current_sequence() may invalidate it!
@api.depends('sequence_id.use_date_range', 'sequence_id.number_next_actual')
@@ -634,7 +625,6 @@ class AccountJournal(models.Model):
else:
journal.sequence_number_next = 1
@api.multi
def _inverse_seq_number_next(self):
'''Inverse 'sequence_number_next' to edit the current sequence next number.
'''
@@ -643,7 +633,6 @@ class AccountJournal(models.Model):
sequence = journal.sequence_id._get_current_sequence()
sequence.sudo().number_next = journal.sequence_number_next
@api.multi
# do not depend on 'refund_sequence_id.date_range_ids', because
# refund_sequence_id._get_current_sequence() may invalidate it!
@api.depends('refund_sequence_id.use_date_range', 'refund_sequence_id.number_next_actual')
@@ -658,7 +647,6 @@ class AccountJournal(models.Model):
else:
journal.refund_sequence_number_next = 1
@api.multi
def _inverse_refund_seq_number_next(self):
'''Inverse 'refund_sequence_number_next' to edit the current sequence next number.
'''
@@ -697,7 +685,6 @@ class AccountJournal(models.Model):
if not self.default_debit_account_id:
self.default_debit_account_id = self.default_credit_account_id
@api.multi
def _get_alias_values(self, type, alias_name=None):
if not alias_name:
alias_name = self.name
@@ -709,7 +696,6 @@ class AccountJournal(models.Model):
'alias_name': re.sub(r'[^\w]+', '-', alias_name)
}
@api.multi
def unlink(self):
bank_accounts = self.env['res.partner.bank'].browse()
for bank_account in self.mapped('bank_account_id'):
@@ -721,7 +707,6 @@ class AccountJournal(models.Model):
bank_accounts.unlink()
return ret
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {})
@@ -743,7 +728,6 @@ class AccountJournal(models.Model):
# remove alias_name to avoid useless write on alias
del(vals['alias_name'])
@api.multi
def write(self, vals):
for journal in self:
company = journal.company_id
@@ -922,7 +906,6 @@ class AccountJournal(models.Model):
'partner_id': self.company_id.partner_id.id,
}).id
@api.multi
def name_get(self):
res = []
for journal in self:
@@ -943,13 +926,11 @@ class AccountJournal(models.Model):
journal_ids = self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid)
return self.browse(journal_ids).name_get()
@api.multi
@api.depends('company_id')
def _belong_to_company(self):
for journal in self:
journal.belong_to_company = (journal.company_id.id == self.env.company.id)
@api.multi
def _search_company_journals(self, operator, value):
if value:
recs = self.search([('company_id', operator, self.env.company.id)])
@@ -959,7 +940,6 @@ class AccountJournal(models.Model):
recs = self.search([('company_id', operator, self.env.company.id)])
return [('id', 'in', [x.id for x in recs])]
@api.multi
@api.depends('inbound_payment_method_ids', 'outbound_payment_method_ids')
def _methods_compute(self):
for journal in self:
@@ -1119,7 +1099,6 @@ class AccountTax(models.Model):
if not all(child.type_tax_use in ('none', tax.type_tax_use) for child in tax.children_tax_ids):
raise ValidationError(_('The application scope of taxes in a group must be either the same as the group or left empty.'))
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {}, name=_("%s (Copy)") % self.name)
@@ -1212,7 +1191,6 @@ class AccountTax(models.Model):
if self.amount_type == 'division' and price_include:
return base_amount - (base_amount * (self.amount / 100))
@api.multi
def json_friendly_compute_all(self, price_unit, currency_id=None, quantity=1.0, product_id=None, partner_id=None, is_refund=False):
""" Just converts parameters in browse records and calls for compute_all, because js widgets can't serialize browse records """
if currency_id:
@@ -1240,7 +1218,6 @@ class AccountTax(models.Model):
rep_lines = self.mapped(is_refund and 'refund_repartition_line_ids' or 'invoice_repartition_line_ids')
return rep_lines.filtered(lambda x: x.repartition_type == repartition_type).mapped('tag_ids')
@api.multi
def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None, is_refund=False, handle_price_include=True):
""" Returns all information required to apply taxes (in self + their children in case of a tax group).
We consider the sequence of the parent for group of taxes.
@@ -38,7 +38,6 @@ class AccountBankStmtCashWizard(models.Model):
cashbox_lines_ids = fields.One2many('account.cashbox.line', 'cashbox_id', string='Cashbox Lines')
@api.multi
def validate(self):
bnk_stmt_id = self.env.context.get('bank_statement_id', False) or self.env.context.get('active_id', False)
bnk_stmt = self.env['account.bank.statement'].browse(bnk_stmt_id)
@@ -61,7 +60,6 @@ class AccountBankStmtCloseCheck(models.TransientModel):
_name = 'account.bank.statement.closebalance'
_description = 'Bank Statement Closing Balance'
@api.multi
def validate(self):
bnk_stmt_id = self.env.context.get('active_id', False)
if bnk_stmt_id:
@@ -78,7 +76,6 @@ class AccountBankStatement(models.Model):
statement.balance_end = statement.balance_start + statement.total_entry_encoding
statement.difference = statement.balance_end_real - statement.balance_end
@api.multi
def _is_difference_zero(self):
for bank_stmt in self:
bank_stmt.is_difference_zero = float_is_zero(bank_stmt.difference, precision_digits=bank_stmt.currency_id.decimal_places)
@@ -112,14 +109,12 @@ class AccountBankStatement(models.Model):
return journals[0]
return self.env['account.journal']
@api.multi
def _get_opening_balance(self, journal_id):
last_bnk_stmt = self.search([('journal_id', '=', journal_id)], limit=1)
if last_bnk_stmt:
return last_bnk_stmt.balance_end
return 0
@api.multi
def _set_opening_balance(self, journal_id):
self.balance_start = self._get_opening_balance(journal_id)
@@ -169,7 +164,6 @@ class AccountBankStatement(models.Model):
def onchange_journal_id(self):
self._set_opening_balance(self.journal_id.id)
@api.multi
def _balance_check(self):
for stmt in self:
if not stmt.currency_id.is_zero(stmt.difference):
@@ -198,7 +192,6 @@ class AccountBankStatement(models.Model):
% (balance_end_real, balance_end))
return True
@api.multi
def unlink(self):
for statement in self:
if statement.state != 'open':
@@ -207,7 +200,6 @@ class AccountBankStatement(models.Model):
statement.line_ids.unlink()
return super(AccountBankStatement, self).unlink()
@api.multi
def open_cashbox_id(self):
context = dict(self.env.context or {})
if context.get('cashbox_id'):
@@ -223,7 +215,6 @@ class AccountBankStatement(models.Model):
'target': 'new'
}
@api.multi
def check_confirm_bank(self):
if self.journal_type == 'cash' and not self.currency_id.is_zero(self.difference):
action_rec = self.env['ir.model.data'].xmlid_to_object('account.action_view_account_bnk_stmt_check')
@@ -232,7 +223,6 @@ class AccountBankStatement(models.Model):
return action
return self.button_confirm_bank()
@api.multi
def button_confirm_bank(self):
self._balance_check()
statements = self.filtered(lambda r: r.state == 'open')
@@ -255,7 +245,6 @@ class AccountBankStatement(models.Model):
statement.message_post(body=_('Statement %s confirmed, journal items were created.') % (statement.name,))
statements.write({'state': 'confirm', 'date_done': time.strftime("%Y-%m-%d %H:%M:%S")})
@api.multi
def button_journal_entries(self):
context = dict(self._context or {})
context['journal_id'] = self.journal_id.id
@@ -269,7 +258,6 @@ class AccountBankStatement(models.Model):
'context': context,
}
@api.multi
def button_open(self):
""" Changes statement state to Running."""
for statement in self:
@@ -283,7 +271,6 @@ class AccountBankStatement(models.Model):
statement.name = st_number
statement.state = 'open'
@api.multi
def action_bank_reconcile_bank_statements(self):
self.ensure_one()
bank_stmt_lines = self.mapped('line_ids')
@@ -365,14 +352,12 @@ class AccountBankStatementLine(models.Model):
line.amount = line.amount
return line
@api.multi
def unlink(self):
for line in self:
if line.journal_entry_ids.ids:
raise UserError(_('In order to delete a bank statement line, you must first cancel it to delete related journal items.'))
return super(AccountBankStatementLine, self).unlink()
@api.multi
def button_cancel_reconciliation(self):
aml_to_unbind = self.env['account.move.line']
aml_to_cancel = self.env['account.move.line']
@@ -500,7 +485,6 @@ class AccountBankStatementLine(models.Model):
aml_dict['move_id'] = move.id
return aml_dict
@api.multi
def fast_counterpart_creation(self):
"""This function is called when confirming a bank statement and will allow to automatically process lines without
going in the bank reconciliation widget. By setting an account_id on bank statement lines, it will create a journal
@@ -766,7 +750,6 @@ class AccountBankStatementLine(models.Model):
counterpart_moves._check_balanced()
return counterpart_moves
@api.multi
def _prepare_move_line_for_currency(self, aml_dict, date):
self.ensure_one()
company_currency = self.journal_id.company_id.currency_id
@@ -25,7 +25,6 @@ class AccountCashRounding(models.Model):
selection=[('UP', 'UP'), ('DOWN', 'DOWN'), ('HALF-UP', 'HALF-UP')],
default='HALF-UP', help='The tie-breaking rule used for float rounding operations')
@api.multi
def round(self, amount):
"""Compute the rounding on the amount passed as parameter.
@@ -34,7 +33,6 @@ class AccountCashRounding(models.Model):
"""
return float_round(amount, precision_rounding=self.rounding, rounding_method=self.rounding_method)
@api.multi
def compute_difference(self, currency, amount):
"""Compute the difference between the base_amount and the amount after rounding.
For example, base_amount=23.91, after rounding=24.00, the result will be 0.09.
@@ -73,7 +73,6 @@ class account_journal(models.Model):
return ['', _('Bank: Balance')]
# Below method is used to get data of bank and cash statemens
@api.multi
def get_line_graph_datas(self):
"""Computes the data used to display the graph for bank and cash journals in the accounting dashboard"""
@@ -133,7 +132,6 @@ class account_journal(models.Model):
return [{'values': data, 'title': graph_title, 'key': graph_key, 'area': True, 'color': color, 'is_sample_data': is_sample_data}]
@api.multi
def get_bar_graph_datas(self):
data = []
today = fields.Datetime.now(self)
@@ -205,7 +203,6 @@ class account_journal(models.Model):
AND move.type IN ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt')
''', {'journal_id': self.id})
@api.multi
def get_journal_dashboard_datas(self):
currency = self.currency_id or self.company_id.currency_id
number_to_reconcile = number_to_check = last_balance = account_sum = 0
@@ -368,7 +365,6 @@ class account_journal(models.Model):
rslt_sum += target_currency.round(amount)
return (rslt_count, rslt_sum)
@api.multi
def action_create_new(self):
ctx = self._context.copy()
ctx['default_journal_id'] = self.id
@@ -388,7 +384,6 @@ class account_journal(models.Model):
'context': ctx,
}
@api.multi
def create_cash_statement(self):
ctx = self._context.copy()
ctx.update({'journal_id': self.id, 'default_journal_id': self.id, 'default_journal_type': 'cash'})
@@ -400,7 +395,6 @@ class account_journal(models.Model):
'context': ctx,
}
@api.multi
def action_open_reconcile(self):
if self.type in ['bank', 'cash']:
# Open reconciliation view for bank statements belonging to this journal
@@ -423,7 +417,6 @@ class account_journal(models.Model):
'context': action_context,
}
@api.multi
def action_open_to_check(self):
self.ensure_one()
ids = self.to_check_ids().ids
@@ -443,7 +436,6 @@ class account_journal(models.Model):
statement_line_ids = self.env['account.move.line'].search(domain).mapped('statement_line_id')
return statement_line_ids
@api.multi
def open_action(self):
"""return action based on type for related journals"""
action_name = self._context.get('action_name')
@@ -484,19 +476,15 @@ class account_journal(models.Model):
return action
@api.multi
def open_spend_money(self):
return self.open_payments_action('outbound')
@api.multi
def open_collect_money(self):
return self.open_payments_action('inbound')
@api.multi
def open_transfer_money(self):
return self.open_payments_action('transfer')
@api.multi
def open_payments_action(self, payment_type, mode='tree'):
if payment_type == 'outbound':
action_ref = 'account.action_account_payments_payable'
@@ -510,7 +498,6 @@ class account_journal(models.Model):
action['views'] = [[False, 'form']]
return action
@api.multi
def open_action_with_context(self):
action_name = self.env.context.get('action_name', False)
if not action_name:
@@ -528,7 +515,6 @@ class account_journal(models.Model):
action['name'] += ' for journal ' + self.name
return action
@api.multi
def create_bank_statement(self):
"""return action to create a bank statements. This button should be called only on journals with type =='bank'"""
action = self.env.ref('account.action_bank_statement_tree').read()[0]
@@ -538,17 +524,14 @@ class account_journal(models.Model):
})
return action
@api.multi
def create_customer_payment(self):
"""return action to create a customer payment"""
return self.open_payments_action('inbound', mode='form')
@api.multi
def create_supplier_payment(self):
"""return action to create a supplier payment"""
return self.open_payments_action('outbound', mode='form')
@api.multi
def create_internal_transfer(self):
"""return action to create a internal transfer"""
return self.open_payments_action('transfer', mode='form')
-75
View File
@@ -409,7 +409,6 @@ class AccountMove(models.Model):
'tag_ids': [(6, 0, tax_vals['tag_ids'])],
}
@api.multi
def _recompute_tax_lines(self):
''' Compute the dynamic tax lines of the journal entry.
@@ -554,7 +553,6 @@ class AccountMove(models.Model):
tax_line._onchange_amount_currency()
tax_line._onchange_balance()
@api.multi
def _recompute_cash_rounding_lines(self):
''' Handle the cash rounding feature on invoices.
@@ -676,7 +674,6 @@ class AccountMove(models.Model):
_apply_cash_rounding(self, diff_balance, diff_amount_currency, existing_cash_rounding_line)
@api.multi
def _recompute_payment_terms_lines(self):
''' Compute the dynamic payment term lines of the journal entry.'''
self.ensure_one()
@@ -803,7 +800,6 @@ class AccountMove(models.Model):
self.invoice_payment_ref = new_terms_lines[-1].name or ''
self.invoice_date_due = new_terms_lines[-1].date_maturity
@api.multi
def _recompute_dynamic_lines(self, recompute_all_taxes=False):
''' Recompute all lines that depend of others.
@@ -838,7 +834,6 @@ class AccountMove(models.Model):
if self != self._origin:
self.invoice_line_ids = self.line_ids.filtered(lambda line: not line.exclude_from_invoice_tab)
@api.multi
def onchange(self, values, field_name, field_onchange):
# OVERRIDE
# As the dynamic lines in this model are quite complex, we need to ensure some computations are done exactly
@@ -962,7 +957,6 @@ class AccountMove(models.Model):
else:
move.invoice_payment_state = 'not_paid'
@api.multi
def _inverse_amount_total(self):
for move in self:
if len(move.line_ids) != 2 or move.type != 'entry':
@@ -986,7 +980,6 @@ class AccountMove(models.Model):
move.write({'line_ids': to_write})
@api.multi
def _get_domain_matching_supsense_moves(self):
self.ensure_one()
domain = self.env['account.move.line']._get_suspense_moves_domain()
@@ -1063,7 +1056,6 @@ class AccountMove(models.Model):
move.invoice_sequence_number_next_prefix = prefix
move.invoice_sequence_number_next = '%%0%sd' % sequence.padding % number_next
@api.multi
def _inverse_invoice_sequence_number_next(self):
''' Set the number_next on the sequence related to the invoice/bill/refund'''
# Check user group.
@@ -1081,7 +1073,6 @@ class AccountMove(models.Model):
date_sequence = sequence._get_current_sequence()
date_sequence.number_next_actual = int(result.group(2))
@api.multi
def _compute_payments_widget_to_reconcile_info(self):
for move in self:
move.invoice_outstanding_credits_debits_widget = json.dumps(False)
@@ -1128,7 +1119,6 @@ class AccountMove(models.Model):
move.invoice_outstanding_credits_debits_widget = json.dumps(info)
move.invoice_has_outstanding = True
@api.multi
def _get_reconciled_info_JSON_values(self):
self.ensure_one()
foreign_currency = self.currency_id if self.currency_id != self.company_id.currency_id else False
@@ -1258,7 +1248,6 @@ class AccountMove(models.Model):
if self._cr.fetchone():
raise ValidationError(_('Duplicated vendor reference detected. You probably encoded twice the same vendor bill/credit note.'))
@api.multi
def _check_balanced(self):
''' Assert the move is fully balanced debit = credit.
An error is raised if it's not the case.
@@ -1287,7 +1276,6 @@ class AccountMove(models.Model):
ids = [res[0] for res in query_res]
raise UserError(_("Cannot create unbalanced journal entry. Ids: %s") % str(ids))
@api.multi
def _check_fiscalyear_lock_date(self):
for move in self:
lock_date = max(move.company_id.period_lock_date or date.min, move.company_id.fiscalyear_lock_date or date.min)
@@ -1301,7 +1289,6 @@ class AccountMove(models.Model):
raise UserError(message)
return True
@api.multi
def _check_tax_lock_date(self):
if not self:
return
@@ -1322,7 +1309,6 @@ class AccountMove(models.Model):
Please change the journal entry date or the tax lock date set in the settings (%s) to proceed
''' % query_res[1]))
@api.multi
def _check_move_consistency(self):
for move in self:
if move.line_ids:
@@ -1336,7 +1322,6 @@ class AccountMove(models.Model):
# LOW-LEVEL METHODS
# -------------------------------------------------------------------------
@api.multi
def _move_autocomplete_invoice_lines_values(self):
''' This method recomputes dynamic lines on the current journal entry that include taxes, cash rounding
and payment terms lines.
@@ -1414,7 +1399,6 @@ class AccountMove(models.Model):
new_vals_list.append(move._move_autocomplete_invoice_lines_values())
return new_vals_list
@api.multi
def _move_autocomplete_invoice_lines_write(self, vals):
''' During the write of an account.move with only 'invoice_line_ids' set and not 'line_ids', this method is called
to auto compute accounting lines of the invoice. In that case, accounts will be retrieved and taxes, cash rounding
@@ -1450,7 +1434,6 @@ class AccountMove(models.Model):
return moves
@api.multi
def write(self, vals):
not_paid_invoices = self.filtered(lambda move: move.is_invoice(include_receipts=True) and move.invoice_payment_state not in ('paid', 'in_payment'))
@@ -1470,7 +1453,6 @@ class AccountMove(models.Model):
return res
@api.multi
def unlink(self):
for move in self:
# check the lock date + check if some entries are reconciled
@@ -1478,7 +1460,6 @@ class AccountMove(models.Model):
move.line_ids.unlink()
return super(AccountMove, self).unlink()
@api.multi
@api.depends('name', 'state')
def name_get(self):
result = []
@@ -1497,7 +1478,6 @@ class AccountMove(models.Model):
result.append((move.id, name))
return result
@api.multi
def _track_subtype(self, init_values):
# OVERRIDE to add custom subtype depending of the state.
self.ensure_one()
@@ -1552,7 +1532,6 @@ class AccountMove(models.Model):
def is_outbound(self, include_receipts=True):
return self.type in self.get_outbound_types(include_receipts)
@api.multi
def _get_invoice_reference_euro_invoice(self):
""" This computes the reference based on the RF Creditor Reference.
The data of the reference is the database id number of the invoice.
@@ -1565,7 +1544,6 @@ class AccountMove(models.Model):
reference = 'RF{} {}'.format(check_digits, " ".join(["".join(x) for x in zip_longest(*[iter(str(base))]*4, fillvalue="")]))
return reference
@api.multi
def _get_invoice_reference_euro_partner(self):
""" This computes the reference based on the RF Creditor Reference.
The data of the reference is the user defined reference of the
@@ -1585,7 +1563,6 @@ class AccountMove(models.Model):
reference = 'RF{} {}'.format(check_digits, " ".join(["".join(x) for x in zip_longest(*[iter(partner_ref_nr)]*4, fillvalue="")]))
return reference
@api.multi
def _get_invoice_reference_odoo_invoice(self):
""" This computes the reference based on the Odoo format.
We simply return the number of the invoice, defined on the journal
@@ -1594,7 +1571,6 @@ class AccountMove(models.Model):
self.ensure_one()
return self.name
@api.multi
def _get_invoice_reference_odoo_partner(self):
""" This computes the reference based on the Odoo format.
The data used is the reference set on the partner or its database
@@ -1605,7 +1581,6 @@ class AccountMove(models.Model):
prefix = _('CUST')
return '%s/%s' % (prefix, ref)
@api.multi
def _get_invoice_computed_reference(self):
self.ensure_one()
if self.journal_id.invoice_reference_type == 'none':
@@ -1617,7 +1592,6 @@ class AccountMove(models.Model):
else:
raise UserError(_('The combination of reference model and reference type on the journal is not implemented'))
@api.multi
def _get_sequence(self):
''' Return the sequence to be used during the post of the current move.
:return: An ir.sequence record or False.
@@ -1631,7 +1605,6 @@ class AccountMove(models.Model):
return
return journal.refund_sequence_id
@api.multi
def _get_invoice_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.
@@ -1650,7 +1623,6 @@ class AccountMove(models.Model):
else:
return ('%s' % self.name) + (show_ref and self.ref and '(%s)' % self.ref or '')
@api.multi
def _get_invoice_delivery_partner_id(self):
''' Hook allowing to retrieve the right delivery address depending of installed modules.
:return: A res.partner record's id representing the delivery address.
@@ -1658,7 +1630,6 @@ class AccountMove(models.Model):
self.ensure_one()
return self.partner_id.address_get(['delivery'])['delivery']
@api.multi
def _get_invoice_intrastat_country_id(self):
''' Hook allowing to retrieve the intrastat country depending of installed modules.
:return: A res.country record's id.
@@ -1666,7 +1637,6 @@ class AccountMove(models.Model):
self.ensure_one()
return self.partner_id.country_id.id
@api.multi
def _get_cash_basis_matched_percentage(self):
"""Compute the percentage to apply for cash basis method. This value is relevant only for moves that
involve journal items on receivable or payable accounts.
@@ -1701,7 +1671,6 @@ class AccountMove(models.Model):
else:
return abs(total_reconciled / total_amount)
@api.multi
def _reverse_move_vals(self, default_values, cancel=True):
''' Reverse values passed as parameter being the copied values of the original journal entry.
For example, debit / credit must be switched. The tax lines must be edited in case of refunds.
@@ -1794,7 +1763,6 @@ class AccountMove(models.Model):
})
return move_vals
@api.multi
def _reverse_moves(self, default_values_list=None, cancel=False):
''' Reverse a recordset of account.move.
If cancel parameter is true, the reconcilable or liquidity lines
@@ -1844,11 +1812,9 @@ class AccountMove(models.Model):
return reverse_moves
@api.multi
def open_reconcile_view(self):
return self.line_ids.open_reconcile_view()
@api.multi
def post(self):
for move in self:
if move.auto_post and move.date > fields.Date.today():
@@ -1910,7 +1876,6 @@ class AccountMove(models.Model):
# installing Accounting- with bank statements)
move.company_id.account_bank_reconciliation_start = move.date
@api.multi
def action_reverse(self):
action = self.env.ref('account.action_view_account_move_reversal').read()[0]
@@ -1919,26 +1884,22 @@ class AccountMove(models.Model):
return action
@api.multi
def action_post(self):
if self.mapped('line_ids.payment_id') and any(self.mapped('journal_id.post_at_bank_rec')):
raise UserError(_("A payment journal entry generated in a journal configured to post entries only when payments are reconciled with a bank statement cannot be manually posted. Those will be posted automatically after performing the bank reconciliation."))
return self.post()
@api.multi
def js_assign_outstanding_line(self, line_id):
self.ensure_one()
lines = self.env['account.move.line'].browse(line_id)
lines += self.line_ids.filtered(lambda line: line.account_id == lines[0].account_id and not line.reconciled)
return lines.reconcile()
@api.multi
def button_draft(self):
if any(move.state != 'cancel' for move in self):
raise UserError(_('Only cancelled journal entries can be reset to draft.'))
self.write({'state': 'draft'})
@api.multi
def button_cancel(self):
AccountMoveLine = self.env['account.move.line']
excluded_move_ids = []
@@ -1961,7 +1922,6 @@ class AccountMove(models.Model):
self.mapped('line_ids').remove_move_reconcile()
return True
@api.multi
def action_invoice_sent(self):
""" Open a window to compose an email, with the edi invoice template
message loaded by default
@@ -1991,7 +1951,6 @@ class AccountMove(models.Model):
'context': ctx,
}
@api.multi
def action_invoice_print(self):
""" Print the invoice and mark it as sent, so that we can see more
easily the next step of the workflow
@@ -2005,12 +1964,10 @@ class AccountMove(models.Model):
else:
return self.env.ref('account.account_invoices_without_payment').report_action(self)
@api.multi
def action_invoice_paid(self):
''' Hook to be overrided called when the invoice moves to the paid state. '''
pass
@api.multi
def action_open_matching_suspense_moves(self):
self.ensure_one()
domain = self._get_domain_matching_supsense_moves()
@@ -2026,19 +1983,16 @@ class AccountMove(models.Model):
'context': action_context,
}
@api.multi
def action_invoice_register_payment(self):
return self.env['account.payment']\
.with_context(active_ids=self.ids, active_model='account.move', active_id=self.id)\
.action_register_payment()
@api.multi
def _get_report_base_filename(self):
if any(not move.is_invoice() for move in self):
raise UserError(_("Only invoices could be printed."))
return self._get_invoice_display_name()
@api.multi
def preview_invoice(self):
self.ensure_one()
return {
@@ -2047,7 +2001,6 @@ class AccountMove(models.Model):
'url': self.get_portal_url(),
}
@api.multi
def _compute_access_url(self):
super(AccountMove, self)._compute_access_url()
for move in self.filtered(lambda move: move.is_invoice()):
@@ -2058,7 +2011,6 @@ class AccountMove(models.Model):
for move in self:
move.has_reconciled_entries = len(move.line_ids._reconciled_lines()) > 1
@api.multi
def action_view_reverse_entry(self):
self.ensure_one()
@@ -2095,7 +2047,6 @@ class AccountMove(models.Model):
records.post()
# offer the possibility to duplicate thanks to a button instead of a hidden menu, which is more visible
@api.multi
def action_duplicate(self):
self.ensure_one()
action = self.env.ref('account.action_move_journal_line').read()[0]
@@ -2269,7 +2220,6 @@ class AccountMoveLine(models.Model):
account = repartition_line.account_id
return account
@api.multi
def _get_computed_name(self):
self.ensure_one()
@@ -2292,7 +2242,6 @@ class AccountMoveLine(models.Model):
values.append(product.description_purchase)
return '\n'.join(values)
@api.multi
def _get_computed_price_unit(self):
self.ensure_one()
@@ -2316,7 +2265,6 @@ class AccountMoveLine(models.Model):
price_unit, self.move_id.currency_id, company, self.move_id.date)
return price_unit
@api.multi
def _get_computed_account(self):
self.ensure_one()
@@ -2332,7 +2280,6 @@ class AccountMoveLine(models.Model):
# In invoice.
return accounts['expense']
@api.multi
def _get_computed_taxes(self):
self.ensure_one()
@@ -2369,14 +2316,12 @@ class AccountMoveLine(models.Model):
else:
return tax_ids
@api.multi
def _get_computed_uom(self):
self.ensure_one()
if self.product_id:
return self.product_id.uom_id
return False
@api.multi
def _get_price_total_and_subtotal(self, price_unit=None, quantity=None, discount=None, currency=None, product=None, partner=None, taxes=None, move_type=None):
self.ensure_one()
return self._get_price_total_and_subtotal_model(
@@ -2420,7 +2365,6 @@ class AccountMoveLine(models.Model):
res['price_total'] = res['price_subtotal'] = subtotal
return res
@api.multi
def _get_fields_onchange_subtotal(self, price_subtotal=None, move_type=None, currency=None, company=None, date=None):
self.ensure_one()
return self._get_fields_onchange_subtotal_model(
@@ -2467,7 +2411,6 @@ class AccountMoveLine(models.Model):
'credit': price_subtotal < 0.0 and -price_subtotal or 0.0,
}
@api.multi
def _get_fields_onchange_balance(self, quantity=None, discount=None, balance=None, move_type=None, currency=None, taxes=None):
self.ensure_one()
return self._get_fields_onchange_balance_model(
@@ -2584,7 +2527,6 @@ class AccountMoveLine(models.Model):
if not self.display_type in ('line_section', 'line_note'):
self.tax_ids = self._get_computed_taxes()
@api.multi
def _onchange_balance(self):
for line in self:
if line.currency_id:
@@ -2775,7 +2717,6 @@ class AccountMoveLine(models.Model):
"Please change the journal entry date or the tax lock date set in the settings ({}) to proceed").format(
line.company_id.tax_lock_date or date.min))
@api.multi
def _update_check(self):
""" Raise Warning to cause rollback if the move is posted, some entries are reconciled or the move is older than the lock date"""
move_ids = set()
@@ -2886,7 +2827,6 @@ class AccountMoveLine(models.Model):
return lines
@api.multi
def write(self, vals):
# OVERRIDE
ACCOUNTING_FIELDS = ('debit', 'credit', 'amount_currency')
@@ -2942,7 +2882,6 @@ class AccountMoveLine(models.Model):
return result
@api.multi
def unlink(self):
self._update_check()
self._check_tax_lock_date2()
@@ -2997,7 +2936,6 @@ class AccountMoveLine(models.Model):
values['account_id'] = accounts.id
return values
@api.multi
@api.depends('ref', 'move_id')
def name_get(self):
result = []
@@ -3012,7 +2950,6 @@ class AccountMoveLine(models.Model):
# RECONCILIATION
# -------------------------------------------------------------------------
@api.multi
def check_full_reconcile(self):
"""
This method check if a move is totally reconciled and if we need to create exchange rate entries for the move.
@@ -3110,7 +3047,6 @@ class AccountMoveLine(models.Model):
'exchange_move_id': exchange_move_id,
})
@api.multi
def _reconcile_lines(self, debit_moves, credit_moves, field):
""" This function loops on the 2 recordsets given as parameter as long as it
can find a debit and a credit to reconcile together. It returns the recordset of the
@@ -3188,7 +3124,6 @@ class AccountMoveLine(models.Model):
return debit_moves+credit_moves
@api.multi
def auto_reconcile_lines(self):
# Create list of debit and list of credit move ordered by date-currency
debit_moves = self.filtered(lambda r: r.debit != 0 or r.amount_currency > 0)
@@ -3223,7 +3158,6 @@ class AccountMoveLine(models.Model):
if not (all_accounts[0].reconcile or all_accounts[0].internal_type == 'liquidity'):
raise UserError(_('Account %s (%s) does not allow reconciliation. First change the configuration of this account to allow it.') % (all_accounts[0].name, all_accounts[0].code))
@api.multi
def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False):
# Empty self can happen if the user tries to reconcile entries which are already reconciled.
# The calling method might have filtered out reconciled lines.
@@ -3342,19 +3276,16 @@ class AccountMoveLine(models.Model):
# Return the writeoff move.line which is to be reconciled
return line_to_reconcile
@api.multi
def remove_move_reconcile(self):
""" Undo a reconciliation """
(self.mapped('matched_debit_ids') + self.mapped('matched_credit_ids')).unlink()
@api.multi
def _copy_data_extend_business_fields(self, values):
''' Hook allowing copying business fields under certain conditions.
E.g. The link to the sale order lines must be preserved in case of a refund.
'''
self.ensure_one()
@api.multi
def copy_data(self, default=None):
res = super(AccountMoveLine, self).copy_data(default=default)
if self._context.get('include_business_fields'):
@@ -3409,7 +3340,6 @@ class AccountMoveLine(models.Model):
self.ensure_one()
return self.analytic_tag_ids.filtered(lambda r: not r.active_analytic_distribution).ids
@api.multi
def create_analytic_lines(self):
""" Create analytic items upon validation of an account.move.line having an analytic account or an analytic distribution.
"""
@@ -3427,7 +3357,6 @@ class AccountMoveLine(models.Model):
values_list = lines_to_create_analytic_entries._prepare_analytic_line()
self.env['account.analytic.line'].create(values_list)
@api.multi
def _prepare_analytic_line(self):
""" Prepare the values used to create() an account.analytic.line upon validation of an account.move.line having
an analytic account. This method is intended to be extended in other modules.
@@ -3558,7 +3487,6 @@ class AccountMoveLine(models.Model):
ids.append(aml.id)
return ids
@api.multi
def open_reconcile_view(self):
[action] = self.env.ref('account.action_account_moves_all_a').read()
ids = self._reconciled_lines()
@@ -3591,7 +3519,6 @@ class AccountPartialReconcile(models.Model):
readonly=True, copy=False, store=True,
help='Technical field used to determine at which date this reconciliation needs to be shown on the aged receivable/payable reports.')
@api.multi
@api.depends('debit_move_id.date', 'credit_move_id.date')
def _compute_max_date(self):
for rec in self:
@@ -3794,7 +3721,6 @@ class AccountPartialReconcile(models.Model):
}
return self.env['account.move'].create(move_vals)
@api.multi
def unlink(self):
""" When removing a partial reconciliation, also unlink its full reconciliation if it exists """
full_to_unlink = self.env['account.full.reconcile']
@@ -3822,7 +3748,6 @@ class AccountFullReconcile(models.Model):
reconciled_line_ids = fields.One2many('account.move.line', 'full_reconcile_id', string='Matched Journal Items')
exchange_move_id = fields.Many2one('account.move')
@api.multi
def unlink(self):
""" When removing a full reconciliation, we need to revert the eventual journal entries we created to book the
fluctuation of the foreign currency's exchange rate.
-16
View File
@@ -145,7 +145,6 @@ class account_payment(models.Model):
payment.show_partner_bank_account = payment.payment_method_code in self._get_method_codes_using_bank_account()
payment.require_partner_bank_account = payment.payment_method_code in self._get_method_codes_needing_bank_account()
@api.multi
@api.depends('payment_type', 'journal_id')
def _compute_hide_payment_method(self):
for payment in self:
@@ -324,11 +323,9 @@ class account_payment(models.Model):
total += move_currency._convert(res['amount_residual'], currency, company, date)
return total
@api.multi
def name_get(self):
return [(payment.id, payment.name or _('Draft Payment')) for payment in self]
@api.multi
@api.depends('move_line_ids.reconciled')
def _get_move_reconciled(self):
for payment in self:
@@ -392,7 +389,6 @@ class account_payment(models.Model):
record.reconciled_invoice_ids = reconciled_moves.filtered(lambda move: move.is_invoice())
record.has_invoices = bool(record.reconciled_invoice_ids)
@api.multi
def action_register_payment(self):
active_ids = self.env.context.get('active_ids')
if not active_ids:
@@ -408,7 +404,6 @@ class account_payment(models.Model):
'type': 'ir.actions.act_window',
}
@api.multi
def button_journal_entries(self):
return {
'name': _('Journal Items'),
@@ -419,7 +414,6 @@ class account_payment(models.Model):
'domain': [('payment_id', 'in', self.ids)],
}
@api.multi
def button_invoices(self):
return {
'name': _('Paid Invoices'),
@@ -431,7 +425,6 @@ class account_payment(models.Model):
'domain': [('id', 'in', [x.id for x in self.reconciled_invoice_ids])],
}
@api.multi
def unreconcile(self):
""" Set back the payments in 'posted' or 'sent' state, without deleting the journal entries.
Called when cancelling a bank statement line linked to a pre-registered payment.
@@ -442,7 +435,6 @@ class account_payment(models.Model):
else:
payment.write({'state': 'posted'})
@api.multi
def cancel(self):
for rec in self:
for move in rec.move_line_ids.mapped('move_id'):
@@ -452,7 +444,6 @@ class account_payment(models.Model):
move.unlink()
rec.state = 'cancelled'
@api.multi
def unlink(self):
if any(bool(rec.move_line_ids) for rec in self):
raise UserError(_("You cannot delete a payment that is already posted."))
@@ -460,7 +451,6 @@ class account_payment(models.Model):
raise UserError(_('It is not allowed to delete a payment that already created a journal entry since it would create a gap in the numbering. You should create the journal entry again and cancel it thanks to a regular revert.'))
return super(account_payment, self).unlink()
@api.multi
def _prepare_payment_moves(self):
''' Prepare the creation of journal entries (account.move) by creating a list of python dictionary to be passed
to the 'create' method.
@@ -640,7 +630,6 @@ class account_payment(models.Model):
all_move_vals.append(transfer_move_vals)
return all_move_vals
@api.multi
def post(self):
""" Create the journal items for the payment and update the payment's state to 'posted'.
A journal entry is created containing an item in the source liquidity account (selected journal's default_debit or default_credit)
@@ -697,11 +686,9 @@ class account_payment(models.Model):
return True
@api.multi
def action_draft(self):
return self.write({'state': 'draft'})
@api.multi
def _get_invoice_payment_amount(self, inv):
"""
Computes the amount covered by the current payment in the given invoice.
@@ -769,7 +756,6 @@ class payment_register(models.TransientModel):
return {'domain': {'payment_method_id': domain}}
return {}
@api.multi
def _prepare_payment_vals(self, invoice):
'''Create the payment values.
@@ -792,7 +778,6 @@ class payment_register(models.TransientModel):
}
return values
@api.multi
def get_payments_vals(self):
'''Compute the values for payments.
@@ -800,7 +785,6 @@ class payment_register(models.TransientModel):
'''
return [self._prepare_payment_vals(invoice) for invoice in self.invoice_ids]
@api.multi
def create_payments(self):
'''Create payments according to the invoices.
Having invoices with different commercial_partner_id or different type
@@ -31,7 +31,6 @@ class AccountPaymentTerm(models.Model):
if len(lines) > 1:
raise ValidationError(_('A Payment Term should have only one line of type Balance.'))
@api.multi
def compute(self, value, date_ref=False, currency=None):
self.ensure_one()
date_ref = date_ref or fields.Date.today()
@@ -68,7 +67,6 @@ class AccountPaymentTerm(models.Model):
result.append((last_date, dist))
return result
@api.multi
def unlink(self):
for terms in self:
if self.env['account.move'].search([('payment_term_id', 'in', terms.ids)]):
@@ -105,7 +105,6 @@ class AccountReconcileModel(models.Model):
number_entries = fields.Integer(string='Number of entries related to this model', compute='_compute_number_entries')
@api.multi
def action_reconcile_stat(self):
self.ensure_one()
action = self.env.ref('account.action_move_journal_line').read()[0]
@@ -121,7 +120,6 @@ class AccountReconcileModel(models.Model):
})
return action
@api.multi
def _compute_number_entries(self):
data = self.env['account.move.line'].read_group([('reconcile_model_id', 'in', self.ids)], ['reconcile_model_ids'], 'reconcile_model_id')
mapped_data = dict([(d['reconcile_model_id'][0], d['reconcile_model_id_count']) for d in data])
@@ -193,7 +191,6 @@ class AccountReconcileModel(models.Model):
base_line_dict['tag_ids'] = [(6, 0, res['base_tags'])]
return new_aml_dicts
@api.multi
def _get_write_off_move_lines_dict(self, st_line, move_lines=None):
''' Get move.lines dict (to be passed to the create()) corresponding to the reconciliation model's write-off lines.
:param st_line: An account.bank.statement.line record.
@@ -265,7 +262,6 @@ class AccountReconcileModel(models.Model):
return new_aml_dicts
@api.multi
def _prepare_reconciliation(self, st_line, move_lines=None, partner=None):
''' Reconcile the statement line with some move lines using this reconciliation model.
:param st_line: An account.bank.statement.line record.
@@ -324,7 +320,6 @@ class AccountReconcileModel(models.Model):
# RECONCILIATION CRITERIA
####################################################
@api.multi
def _apply_conditions(self, query, params):
self.ensure_one()
rule = self
@@ -382,7 +377,6 @@ class AccountReconcileModel(models.Model):
return query, params
@api.multi
def _get_with_tables(self, st_lines, partner_map=None):
with_tables = '''
WITH jnl_precision AS (
@@ -403,7 +397,6 @@ class AccountReconcileModel(models.Model):
with_tables += ', partners_table AS (' + partners_table + ')'
return with_tables
@api.multi
def _get_invoice_matching_query(self, st_lines, excluded_ids=None, partner_map=None):
''' Get the query applying all rules trying to match existing entries with the given statement lines.
:param st_lines: Account.bank.statement.lines recordset.
@@ -534,7 +527,6 @@ class AccountReconcileModel(models.Model):
full_query += ' ORDER BY aml_date_maturity, aml_id'
return full_query, all_params
@api.multi
def _get_writeoff_suggestion_query(self, st_lines, excluded_ids=None, partner_map=None):
''' Get the query applying all reconciliation rules.
:param st_lines: Account.bank.statement.lines recordset.
@@ -570,7 +562,6 @@ class AccountReconcileModel(models.Model):
full_query += ' UNION ALL '.join(queries)
return full_query, all_params
@api.multi
def _check_rule_propositions(self, statement_line, candidates):
''' Check restrictions that can't be handled for each move.line separately.
/!\ Only used by models having a type equals to 'invoice_matching'.
@@ -601,7 +592,6 @@ class AccountReconcileModel(models.Model):
amount_percentage = (line_residual / total_residual) * 100 if total_residual else 0
return amount_percentage >= self.match_total_amount_param
@api.multi
def _apply_rules(self, st_lines, excluded_ids=None, partner_map=None):
''' Apply criteria to get candidates for all reconciliation models.
:param st_lines: Account.bank.statement.lines recordset.
-13
View File
@@ -78,7 +78,6 @@ class AccountAccountTemplate(models.Model):
tag_ids = fields.Many2many('account.account.tag', 'account_account_template_account_tag', string='Account tag', help="Optional tags you may want to assign for custom reporting")
group_id = fields.Many2one('account.group')
@api.multi
@api.depends('name', 'code')
def name_get(self):
res = []
@@ -346,7 +345,6 @@ class AccountChartTemplate(models.Model):
"""
return [{'acc_name': _('Cash'), 'account_type': 'cash'}, {'acc_name': _('Bank'), 'account_type': 'bank'}]
@api.multi
def open_select_template_wizard(self):
# Add action to open wizard to select between several templates
if not self.company_id.chart_template_id:
@@ -397,7 +395,6 @@ class AccountChartTemplate(models.Model):
company.write({'tax_cash_basis_journal_id': journal.id})
return True
@api.multi
def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None):
def _get_default_account(journal_vals, type='debit'):
# Get the default accounts
@@ -438,7 +435,6 @@ class AccountChartTemplate(models.Model):
journal_data.append(vals)
return journal_data
@api.multi
def generate_properties(self, acc_template_ref, company):
"""
This method used for creating properties.
@@ -490,7 +486,6 @@ class AccountChartTemplate(models.Model):
company.write({stock_property: value})
return True
@api.multi
def _install_template(self, company, code_digits=None, obj_wizard=None, acc_ref=None, taxes_ref=None):
""" Recursively load the template objects and create the real objects from them.
@@ -520,7 +515,6 @@ class AccountChartTemplate(models.Model):
taxes_ref.update(tmp2)
return acc_ref, taxes_ref
@api.multi
def _load_template(self, company, code_digits=None, account_ref=None, taxes_ref=None):
""" Generate all the objects from the templates
@@ -581,7 +575,6 @@ class AccountChartTemplate(models.Model):
return account_ref, taxes_ref
@api.multi
def create_record_with_xmlid(self, company, template, model, vals):
return self._create_records_with_xmlid(model, [(template, vals)], company).id
@@ -647,7 +640,6 @@ class AccountChartTemplate(models.Model):
}
return val
@api.multi
def generate_account(self, tax_template_ref, acc_template_ref, code_digits, company):
""" This method generates accounts from account templates.
@@ -713,7 +705,6 @@ class AccountChartTemplate(models.Model):
'second_tax_ids': [[4, tax_template_ref[tax.id], 0] for tax in account_reconcile_model.second_tax_ids],
}
@api.multi
def generate_account_reconcile_model(self, tax_template_ref, acc_template_ref, company):
""" This method creates account reconcile models
@@ -732,7 +723,6 @@ class AccountChartTemplate(models.Model):
self.create_record_with_xmlid(company, account_reconcile_model, 'account.reconcile.model', vals)
return True
@api.multi
def _get_fp_vals(self, company, position):
return {
'company_id': company.id,
@@ -748,7 +738,6 @@ class AccountChartTemplate(models.Model):
'zip_to': position.zip_to,
}
@api.multi
def generate_fiscal_position(self, tax_template_ref, acc_template_ref, company):
""" This method generates Fiscal Position, Fiscal Position Accounts
and Fiscal Position Taxes from templates.
@@ -838,7 +827,6 @@ class AccountTaxTemplate(models.Model):
('name_company_uniq', 'unique(name, type_tax_use, chart_template_id)', 'Tax names must be unique !'),
]
@api.multi
@api.depends('name', 'description')
def name_get(self):
res = []
@@ -883,7 +871,6 @@ class AccountTaxTemplate(models.Model):
val['tax_group_id'] = self.tax_group_id.id
return val
@api.multi
def _generate_tax(self, company):
""" This method generate taxes from templates.
-6
View File
@@ -145,7 +145,6 @@ Best Regards,'''))
'account_setup_coa_state',
])
@api.multi
def _check_lock_dates(self, vals):
'''Check the lock dates for the current companies. This can't be done in a api.constrains because we need
to perform some comparison between new/old values. This method forces the lock dates to be irreversible.
@@ -199,7 +198,6 @@ Best Regards,'''))
if period_lock_date < fiscalyear_lock_date:
raise ValidationError(_('You cannot define stricter conditions on advisors than on users. Please make sure that the lock date on advisor is set before the lock date for users.'))
@api.multi
def compute_fiscalyear_dates(self, current_date):
'''Computes the start and end dates of the fiscal year where the given 'date' belongs to.
@@ -266,7 +264,6 @@ Best Regards,'''))
if account.code.startswith(old_code):
account.write({'code': self.get_new_account_code(account.code, old_code, new_code)})
@api.multi
def _validate_fiscalyear_lock(self, values):
if values.get('fiscalyear_lock_date'):
nb_draft_entries = self.env['account.move'].search([
@@ -276,7 +273,6 @@ Best Regards,'''))
if nb_draft_entries:
raise ValidationError(_('There are still unposted entries in the period you want to lock. You should either post or delete them.'))
@api.multi
def write(self, values):
#restrict the closing of FY if there are still unposted entries
self._validate_fiscalyear_lock(values)
@@ -538,13 +534,11 @@ Best Regards,'''))
}
return action
@api.multi
def action_save_onboarding_invoice_layout(self):
""" Set the onboarding step as done """
if bool(self.logo) and self.logo != self._get_logo():
self.set_onboarding_step_done('account_onboarding_invoice_layout_state')
@api.multi
def action_save_onboarding_sale_tax(self):
""" Set the onboarding step as done """
self.set_onboarding_step_done('account_onboarding_sale_tax_state')
@@ -6,7 +6,6 @@ from odoo.exceptions import UserError
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
@api.multi
def retrieve_attachment(self, record):
# get the original bills through the message_main_attachment_id field of the record
if self.report_name == 'account.report_original_vendor_bill' and record.message_main_attachment_id:
@@ -15,7 +14,6 @@ class IrActionsReport(models.Model):
return record.message_main_attachment_id
return super(IrActionsReport, self).retrieve_attachment(record)
@api.multi
def _post_pdf(self, save_in_attachment, pdf_content=None, res_ids=None):
# don't include the generated dummy report
if self.report_name == 'account.report_original_vendor_bill':
@@ -25,7 +23,6 @@ class IrActionsReport(models.Model):
raise UserError(_("No original vendor bills could be found for any of the selected vendor bills."))
return super(IrActionsReport, self)._post_pdf(save_in_attachment, pdf_content=pdf_content, res_ids=res_ids)
@api.multi
def postprocess_pdf_report(self, record, buffer):
# don't save the 'account.report_original_vendor_bill' report as it's just a mean to print existing attachments
if self.report_name == 'account.report_original_vendor_bill':
-9
View File
@@ -107,7 +107,6 @@ class AccountFiscalPosition(models.Model):
vals['zip_from'], vals['zip_to'] = self._convert_zip_values(zip_from, zip_to)
return super(AccountFiscalPosition, self).create(vals)
@api.multi
def write(self, vals):
zip_from = vals.get('zip_from')
zip_to = vals.get('zip_to')
@@ -224,7 +223,6 @@ class ResPartner(models.Model):
_name = 'res.partner'
_inherit = 'res.partner'
@api.multi
def _credit_debit_get(self):
tables, where_clause, where_params = self.env['account.move.line'].with_context(company_id=self.env.company.id)._query_get()
where_params = [tuple(self.ids)] + where_params
@@ -247,7 +245,6 @@ class ResPartner(models.Model):
elif type == 'payable':
partner.debit = -val
@api.multi
def _asset_difference_search(self, account_type, operator, operand):
if operator not in ('<', '=', '>', '>=', '<='):
return []
@@ -278,7 +275,6 @@ class ResPartner(models.Model):
def _debit_search(self, operator, operand):
return self._asset_difference_search('payable', operator, operand)
@api.multi
def _invoice_total(self):
account_invoice_report = self.env['account.invoice.report']
if not self.ids:
@@ -317,13 +313,11 @@ class ResPartner(models.Model):
for partner, child_ids in all_partners_and_children.items():
partner.total_invoiced = sum(price['total'] for price in price_totals if price['partner_id'] in child_ids)
@api.multi
def _compute_journal_item_count(self):
AccountMoveLine = self.env['account.move.line']
for partner in self:
partner.journal_item_count = AccountMoveLine.search_count([('partner_id', '=', partner.id)])
@api.multi
def _compute_contracts_count(self):
AccountAnalyticAccount = self.env['account.analytic.account']
for partner in self:
@@ -380,7 +374,6 @@ class ResPartner(models.Model):
""", (partner.id,))
partner.has_unreconciled_entries = self.env.cr.rowcount == 1
@api.multi
def mark_as_reconciled(self):
self.env['account.partial.reconcile'].check_access_rights('write')
return self.sudo().with_context(company_id=self.env.company.id).write({'last_time_entries_checked': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})
@@ -438,7 +431,6 @@ class ResPartner(models.Model):
invoice_warn = fields.Selection(WARNING_MESSAGE, 'Invoice', help=WARNING_HELP, default="no-message")
invoice_warn_msg = fields.Text('Message for Invoice')
@api.multi
def _compute_bank_count(self):
bank_data = self.env['res.partner.bank'].read_group([('partner_id', 'in', self.ids)], ['partner_id'], ['partner_id'])
mapped_data = dict([(bank['partner_id'][0], bank['partner_id_count']) for bank in bank_data])
@@ -455,7 +447,6 @@ class ResPartner(models.Model):
['debit_limit', 'property_account_payable_id', 'property_account_receivable_id', 'property_account_position_id',
'property_payment_term_id', 'property_supplier_payment_term_id', 'last_time_entries_checked']
@api.multi
def action_view_partner_invoices(self):
self.ensure_one()
action = self.env.ref('account.action_move_out_invoice_type').read()[0]
-3
View File
@@ -35,21 +35,18 @@ class ProductTemplate(models.Model):
domain=[('deprecated', '=', False)],
help="Keep this field empty to use the default value from the product category. If anglo-saxon accounting with automated valuation method is configured, the expense account on the product category will be used.")
@api.multi
def _get_product_accounts(self):
return {
'income': self.property_account_income_id or self.categ_id.property_account_income_categ_id,
'expense': self.property_account_expense_id or self.categ_id.property_account_expense_categ_id
}
@api.multi
def _get_asset_accounts(self):
res = {}
res['stock_input'] = False
res['stock_output'] = False
return res
@api.multi
def get_product_accounts(self, fiscal_pos=None):
accounts = self._get_product_accounts()
if not fiscal_pos:
@@ -91,7 +91,6 @@ class ResConfigSettings(models.TransientModel):
oldname='default_use_sale_note',
config_parameter='account.use_invoice_terms')
@api.multi
def set_values(self):
super(ResConfigSettings, self).set_values()
if self.group_multi_currency:
-1
View File
@@ -8,7 +8,6 @@ from odoo.exceptions import ValidationError
class Users(models.Model):
_inherit = "res.users"
@api.multi
@api.constrains('groups_id')
def _check_one_user_type(self):
super(Users, self)._check_one_user_type()
@@ -10,18 +10,15 @@ class ImportInvoiceImportWizard(models.TransientModel):
attachment_ids = fields.Many2many('ir.attachment', string='Files')
@api.multi
def _create_invoice_from_file(self, attachment):
invoice = self.env['account.move'].create({})
attachment.write({'res_model': 'account.move', 'res_id': invoice.id})
invoice.message_post(attachment_ids=[attachment.id])
return invoice
@api.multi
def _create_invoice(self, attachment):
return self._create_invoice_from_file(attachment)
@api.multi
def create_invoices(self):
''' Create the invoices from files.
:return: A action redirecting to account.invoice tree/form view.
@@ -40,7 +40,6 @@ class AccountInvoiceSend(models.TransientModel):
})
return res
@api.multi
@api.onchange('invoice_ids')
def _compute_composition_mode(self):
for wizard in self:
@@ -68,14 +67,12 @@ class AccountInvoiceSend(models.TransientModel):
else:
wizard.invoice_without_email = False
@api.multi
def _send_email(self):
if self.is_email:
self.composer_id.send_mail()
if self.env.context.get('mark_invoice_as_sent'):
self.mapped('invoice_ids').write({'invoice_sent': True})
@api.multi
def _print_document(self):
""" to override for each type of models that will use this composer."""
self.ensure_one()
@@ -83,7 +80,6 @@ class AccountInvoiceSend(models.TransientModel):
action.update({'close_on_report_download': True})
return action
@api.multi
def send_and_print_action(self):
self.ensure_one()
self._send_email()
@@ -91,7 +87,6 @@ class AccountInvoiceSend(models.TransientModel):
return self._print_document()
return {'type': 'ir.actions.act_window_close'}
@api.multi
def save_as_template(self):
self.ensure_one()
self.composer_id.save_as_template()
@@ -43,7 +43,6 @@ class AccountMoveReversal(models.TransientModel):
currency_id = fields.Many2one(related='move_id.currency_id')
move_type = fields.Selection(related='move_id.type')
@api.multi
def reverse_moves(self):
moves = self.move_id or self.env['account.move'].browse(self._context['active_ids'])
@@ -36,7 +36,6 @@ class AccountCommonReport(models.TransientModel):
def _print_report(self, data):
raise NotImplementedError()
@api.multi
def check_report(self):
self.ensure_one()
data = {}
@@ -10,7 +10,6 @@ class AccountCommonJournalReport(models.TransientModel):
amount_currency = fields.Boolean('With Currency', help="Print Report with the currency column if the currency differs from the company currency.")
@api.multi
def pre_print_report(self, data):
data['form'].update({'amount_currency': self.amount_currency})
return data
@@ -5,7 +5,6 @@ class AccountUnreconcile(models.TransientModel):
_name = "account.unreconcile"
_description = "Account Unreconcile"
@api.multi
def trans_unrec(self):
context = dict(self._context or {})
if context.get('active_ids', False):
@@ -6,7 +6,6 @@ class ValidateAccountMove(models.TransientModel):
_name = "validate.account.move"
_description = "Validate Account Move"
@api.multi
def validate_move(self):
context = dict(self._context or {})
moves = self.env['account.move'].browse(context.get('active_ids'))
-4
View File
@@ -9,7 +9,6 @@ class CashBox(models.TransientModel):
# in the context of the action
amount = fields.Float(string='Amount', digits=0, required=True)
@api.multi
def run(self):
context = dict(self._context or {})
active_model = context.get('active_model', False)
@@ -19,7 +18,6 @@ class CashBox(models.TransientModel):
return self._run(records)
@api.multi
def _run(self, records):
for box in self:
for record in records:
@@ -44,7 +42,6 @@ class CashBoxIn(CashBox):
ref = fields.Char('Reference')
@api.multi
def _calculate_values_for_statement_line(self, record):
if not record.journal_id.company_id.transfer_account_id:
raise UserError(_("You have to define an 'Internal Transfer Account' in your cash register's journal."))
@@ -63,7 +60,6 @@ class CashBoxOut(CashBox):
_name = 'cash.box.out'
_description = 'Cash Box Out'
@api.multi
def _calculate_values_for_statement_line(self, record):
if not record.journal_id.company_id.transfer_account_id:
raise UserError(_("You have to define an 'Internal Transfer Account' in your cash register's journal."))
-2
View File
@@ -40,7 +40,6 @@ class FinancialYearOpeningWizard(models.TransientModel):
(wiz.fiscalyear_last_month, wiz.fiscalyear_last_day)
)
@api.multi
def write(self, vals):
# Amazing workaround: non-stored related fields on company are a BAD idea since the 3 fields
# must follow the constraint '_check_fiscalyear_last_day'. The thing is, in case of related
@@ -57,7 +56,6 @@ class FinancialYearOpeningWizard(models.TransientModel):
vals.pop('fiscalyear_last_month', None)
return super().write(vals)
@api.multi
def action_save_onboarding_fiscal_year(self):
self.env.company.set_onboarding_step_done('account_setup_fy_data_state')
@@ -8,7 +8,6 @@ class TaxAdjustments(models.TransientModel):
_name = 'tax.adjustments.wizard'
_description = 'Tax Adjustments Wizard'
@api.multi
def _get_default_journal(self):
return self.env['account.journal'].search([('type', '=', 'general')], limit=1).id
@@ -28,7 +28,6 @@ class AccountBankStatementImport(models.TransientModel):
data_file = fields.Binary(string='Bank Statement File', attachment=False, required=True, help='Get you bank statements in electronic format from your bank and select them here.')
filename = fields.Char()
@api.multi
def import_file(self):
""" Process the file chosen in the wizard, create bank statement(s) and go to reconciliation. """
self.ensure_one()
@@ -20,7 +20,6 @@ class AccountJournal(models.Model):
rslt.append(("file_import", _("Import") + "(" + import_formats_str + ")"))
return rslt
@api.multi
def import_statement(self):
"""return action to import bank/cash statements. This button should be called only on journals with type =='bank'"""
action_name = 'action_account_bank_statement_import'
@@ -9,7 +9,6 @@ class AccountBankStatementImportJounalCreation(models.TransientModel):
journal_id = fields.Many2one('account.journal', delegate=True, required=True, ondelete='cascade')
@api.multi
def create_journal(self):
""" Create the journal (the record is automatically created in the process of calling this method) and reprocess the statement """
statement_import_transient = self.env['account.bank.statement.import'].browse(self.env.context['statement_import_transient_id'])
@@ -8,7 +8,6 @@ from odoo.exceptions import UserError
class BankStatement(models.Model):
_inherit = 'account.bank.statement'
@api.multi
def button_draft(self):
self.state = 'open'
@@ -47,7 +47,6 @@ class AccountJournal(models.Model):
rec._create_check_sequence()
return rec
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
rec = super(AccountJournal, self).copy(default)
@@ -82,7 +81,6 @@ class AccountJournal(models.Model):
'outbound_payment_method_ids': [(4, check_printing.id, None)],
})
@api.multi
def get_journal_dashboard_datas(self):
domain_checks_to_print = [
('journal_id', '=', self.id),
@@ -94,7 +92,6 @@ class AccountJournal(models.Model):
num_checks_to_print=len(self.env['account.payment'].search(domain_checks_to_print))
)
@api.multi
def action_checks_to_print(self):
return {
'name': _('Checks to Print'),
@@ -50,7 +50,6 @@ class AccountPayment(models.Model):
if len(communication) > 60:
raise ValidationError(_("A check memo cannot exceed 60 characters."))
@api.multi
def post(self):
res = super(AccountPayment, self).post()
payment_method_check = self.env.ref('account_check_printing.account_payment_method_check')
@@ -59,7 +58,6 @@ class AccountPayment(models.Model):
payment.check_number = sequence.next_by_id()
return res
@api.multi
def print_checks(self):
""" Check that the recordset is valid, set the payments state to sent and call print_checks() """
# Since this method can be called via a client_action_multi, we need to make sure the received records are what we expect
@@ -94,11 +92,9 @@ class AccountPayment(models.Model):
self.filtered(lambda r: r.state == 'draft').post()
return self.do_print_checks()
@api.multi
def unmark_sent(self):
self.write({'state': 'posted'})
@api.multi
def do_print_checks(self):
""" This method is a hook for l10n_xx_check_printing modules to implement actual check printing capabilities """
raise UserError(_("You have to choose a check layout. For this, go in Apps, search for 'Checks layout' and install one."))
@@ -6,7 +6,6 @@ from odoo import api, models
class AccountChartTemplate(models.Model):
_inherit = 'account.chart.template'
@api.multi
def _create_bank_journals(self, company, acc_template_ref):
'''
When system automatically creates journals of bank and cash type when CoA is being installed
@@ -18,7 +18,6 @@ class PrintPreNumberedChecks(models.TransientModel):
if check.next_check_number and not re.match(r'^[0-9]+$', check.next_check_number):
raise ValidationError(_('Next Check Number should only contains numbers.'))
@api.multi
def print_checks(self):
check_number = int(self.next_check_number)
payments = self.env['account.payment'].browse(self.env.context['payment_ids'])
@@ -22,7 +22,6 @@ DEFAULT_FACTURX_DATE_FORMAT = '%Y%m%d'
class AccountMove(models.Model):
_inherit = 'account.move'
@api.multi
def _export_as_facturx_xml(self):
''' Create the Factur-x xml file content.
:return: The XML content as str.
@@ -47,7 +46,6 @@ class AccountMove(models.Model):
content = self.env.ref('account_facturx.account_invoice_facturx_export').render(template_values)
return b"<?xml version='1.0' encoding='UTF-8'?>" + content
@api.multi
def _import_facturx_invoice(self, tree):
''' Extract invoice values from the Factur-x xml tree passed as parameter.
@@ -217,7 +215,6 @@ class AccountMove(models.Model):
return invoice_form.save()
@api.multi
@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
# OVERRIDE
@@ -302,7 +299,6 @@ class AccountMove(models.Model):
# TO BE OVERWRITTEN
return []
@api.multi
def _create_invoice_from_xml(self, attachment):
decoders = self._get_xml_decoders()
@@ -10,7 +10,6 @@ import io
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
@api.multi
def _post_pdf(self, save_in_attachment, pdf_content=None, res_ids=None):
# OVERRIDE
if self.model == 'account.move' and res_ids and len(res_ids) == 1:
@@ -6,7 +6,6 @@ from odoo import models, api
class ResCompany(models.Model):
_inherit = 'res.company'
@api.multi
def write(self, vals):
# fiscalyear_lock_date can't be set to a prior date
if 'fiscalyear_lock_date' in vals or 'period_lock_date' in vals:
@@ -35,7 +35,6 @@ class AccountTaxPython(models.Model):
return localdict['result']
return super(AccountTaxPython, self)._compute_amount(base_amount, price_unit, quantity, product, partner)
@api.multi
def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None, is_refund=False, handle_price_include=True):
taxes = self.filtered(lambda r: r.amount_type != 'code')
company = self.env.company
@@ -78,7 +78,6 @@ class AccountAnalyticAccount(models.Model):
line['credit'] = sum(accounts.mapped('credit'))
return res
@api.multi
def _compute_debit_credit_balance(self):
Curr = self.env['res.currency']
analytic_line_obj = self.env['account.analytic.line']
@@ -140,7 +139,6 @@ class AccountAnalyticAccount(models.Model):
currency_id = fields.Many2one(related="company_id.currency_id", string="Currency", readonly=True)
@api.multi
def name_get(self):
res = []
for analytic in self:
@@ -190,7 +188,6 @@ class AccountAnalyticLine(models.Model):
currency_id = fields.Many2one(related="company_id.currency_id", string="Currency", readonly=True, store=True, compute_sudo=True)
group_id = fields.Many2one('account.analytic.group', related='account_id.group_id', store=True, readonly=True, compute_sudo=True)
@api.multi
@api.constrains('company_id', 'account_id')
def _check_company_id(self):
for line in self:
@@ -17,7 +17,6 @@ class ResConfigSettings(models.TransientModel):
auth_signup_template_user_id = fields.Many2one('res.users', string='Template user for new users created through signup',
config_parameter='base.template_portal_user_id')
@api.multi
def open_template_user(self):
action = self.env.ref('base.action_res_users').read()[0]
action['res_id'] = literal_eval(self.env['ir.config_parameter'].sudo().get_param('base.template_portal_user_id', 'False'))
-6
View File
@@ -30,7 +30,6 @@ class ResPartner(models.Model):
signup_valid = fields.Boolean(compute='_compute_signup_valid', string='Signup Token is Valid')
signup_url = fields.Char(compute='_compute_signup_url', string='Signup URL')
@api.multi
@api.depends('signup_token', 'signup_expiration')
def _compute_signup_valid(self):
dt = now()
@@ -38,7 +37,6 @@ class ResPartner(models.Model):
partner.signup_valid = bool(partner_sudo.signup_token) and \
(not partner_sudo.signup_expiration or dt <= partner_sudo.signup_expiration)
@api.multi
def _compute_signup_url(self):
""" proxy for function field towards actual implementation """
result = self.sudo()._get_signup_url_for_action()
@@ -47,7 +45,6 @@ class ResPartner(models.Model):
self.env['res.users'].check_access_rights('write')
partner.signup_url = result.get(partner.id, False)
@api.multi
def _get_signup_url_for_action(self, url=None, action=None, view_type=None, menu_id=None, res_id=None, model=None):
""" generate a signup url for the given partner ids and action, possibly overriding
the url state components (menu_id, id, view_type) """
@@ -101,7 +98,6 @@ class ResPartner(models.Model):
return res
@api.multi
def action_signup_prepare(self):
return self.signup_prepare()
@@ -121,11 +117,9 @@ class ResPartner(models.Model):
res[partner.id]['auth_login'] = partner.user_ids[0].login
return res
@api.multi
def signup_cancel(self):
return self.write({'signup_token': False, 'signup_type': False, 'signup_expiration': False})
@api.multi
def signup_prepare(self, signup_type="signup", expiration=False):
""" generate a new token for the partners with the given validity, if necessary
:param expiration: the expiration datetime of the token (string, optional)
-5
View File
@@ -48,7 +48,6 @@ class ResUsers(models.Model):
return expression.TRUE_DOMAIN
@api.multi
def _compute_state(self):
for user in self:
user.state = 'active' if user.login_date else 'new'
@@ -119,7 +118,6 @@ class ResUsers(models.Model):
raise SignupError(_('Signup is not allowed for uninvited users'))
return self._create_user_from_template(values)
@api.multi
def _notify_inviter(self):
for user in self:
invite_partner = user.create_uid.partner_id
@@ -165,7 +163,6 @@ class ResUsers(models.Model):
raise Exception(_('Reset password: invalid username or email'))
return users.action_reset_password()
@api.multi
def action_reset_password(self):
""" create signup token for each user, and send their signup url by email """
# prepare reset password signup
@@ -203,7 +200,6 @@ class ResUsers(models.Model):
template.with_context(lang=user.lang).send_mail(user.id, force_send=True, raise_exception=True)
_logger.info("Password reset email sent for user <%s> to <%s>", user.login, user.email)
@api.multi
def send_unregistered_user_reminder(self, after_days=5):
datetime_min = fields.Datetime.today() - relativedelta(days=after_days)
datetime_max = datetime_min + relativedelta(hours=23, minutes=59, seconds=59)
@@ -245,7 +241,6 @@ class ResUsers(models.Model):
user.partner_id.with_context(create_user=True).signup_cancel()
return user
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
@@ -42,7 +42,6 @@ class Partner(models.Model):
Overwrite this function if you want to add your own fields."""
return STREET_FIELDS
@api.multi
def _set_street(self):
"""Updates the street field.
Writes the `street` field on the partners when one of the sub-fields in STREET_FIELDS
@@ -121,7 +120,6 @@ class Partner(models.Model):
return vals
@api.multi
@api.depends('street')
def _split_street(self):
"""Splits street value into sub-fields.
@@ -102,7 +102,6 @@ class BaseAutomation(models.Model):
self._update_registry()
return base_automation
@api.multi
def write(self, vals):
res = super(BaseAutomation, self).write(vals)
if set(vals).intersection(self.CRITICAL_FIELDS):
@@ -110,7 +109,6 @@ class BaseAutomation(models.Model):
self._update_registry()
return res
@api.multi
def unlink(self):
res = super(BaseAutomation, self).unlink()
self._update_cron()
@@ -265,7 +263,6 @@ class BaseAutomation(models.Model):
# Note: we patch method _write() instead of write() in order to
# catch updates made by field recomputations.
#
@api.multi
def _write(self, vals, **kw):
# retrieve the action rules to possibly execute
actions = self.env['base.automation']._get_actions(self, ['on_write', 'on_create_or_write'])
@@ -289,7 +286,6 @@ class BaseAutomation(models.Model):
def make_unlink():
""" Instanciate an unlink method that processes action rules. """
@api.multi
def unlink(self, **kwargs):
# retrieve the action rules to possibly execute
actions = self.env['base.automation']._get_actions(self, ['on_unlink'])
@@ -54,7 +54,6 @@ class BaseGengoTranslations(models.TransientModel):
icp = self.env['ir.config_parameter'].sudo()
return icp.get_param(self.GENGO_KEY, default="Undefined")
@api.multi
def open_company(self):
self.ensure_one()
return {
@@ -92,7 +91,6 @@ class BaseGengoTranslations(models.TransientModel):
_logger.exception('Gengo connection failed')
return (False, _("Gengo connection failed with this message:\n``%s``") % e)
@api.multi
def act_update(self):
'''
Function called by the wizard.
@@ -16,7 +16,6 @@ class ResPartner(models.Model):
result = geo_obj.geo_find(search, force_country=country)
return result
@api.multi
def geo_localize(self):
# We need country names in English below
for partner in self.with_context(lang='en_US'):
@@ -77,7 +77,6 @@ class ResPartnerBank(models.Model):
pass
return super(ResPartnerBank, self).create(vals)
@api.multi
def write(self, vals):
if vals.get('acc_number'):
try:
-8
View File
@@ -223,7 +223,6 @@ class Import(models.TransientModel):
# TODO: cache on model?
return importable_fields
@api.multi
def _read_file(self, options):
""" Dispatch to specific method to read file content, according to its mimetype or file type
:param options : dict of reading options (quoting, separator, ...)
@@ -261,7 +260,6 @@ class Import(models.TransientModel):
raise ImportError(_("Unable to load \"{extension}\" file: requires Python module \"{modname}\"").format(extension=file_extension, modname=req))
raise ValueError(_("Unsupported file format \"{}\", import only supports CSV, ODS, XLS and XLSX").format(self.file_type))
@api.multi
def _read_xls(self, options):
""" Read file content, using xlrd lib """
book = xlrd.open_workbook(file_contents=self.file or b'')
@@ -307,7 +305,6 @@ class Import(models.TransientModel):
# use the same method for xlsx and xls files
_read_xlsx = _read_xls
@api.multi
def _read_ods(self, options):
""" Read file content using ODSReader custom lib """
doc = odf_ods_reader.ODSReader(file=io.BytesIO(self.file or b''))
@@ -318,7 +315,6 @@ class Import(models.TransientModel):
if any(x for x in row if x.strip())
)
@api.multi
def _read_csv(self, options):
""" Returns a CSV-parsed iterator of all non-empty lines in the file
:throws csv.Error: if an error is detected during CSV parsing
@@ -561,7 +557,6 @@ class Import(models.TransientModel):
matches[index] = match_field or None
return headers, matches
@api.multi
def parse_preview(self, options, count=10):
""" Generates a preview of the uploaded files, and performs
fields-matching between the import's file data and the model's
@@ -737,7 +732,6 @@ class Import(models.TransientModel):
decimal_separator = options.get('float_decimal_separator', '.')
return thousand_separator, decimal_separator
@api.multi
def _parse_import_data(self, data, import_fields, options):
""" Lauch first call to _parse_import_data_recursive with an
empty prefix. _parse_import_data_recursive will be run
@@ -745,7 +739,6 @@ class Import(models.TransientModel):
"""
return self._parse_import_data_recursive(self.res_model, '', data, import_fields, options)
@api.multi
def _parse_import_data_recursive(self, model, prefix, data, import_fields, options):
# Get fields of type date/datetime
all_fields = self.env[model].fields_get()
@@ -845,7 +838,6 @@ class Import(models.TransientModel):
'error': e
})
@api.multi
def do(self, fields, columns, options, dryrun=False):
""" Actual execution of the import
@@ -14,7 +14,6 @@ class BaseImportModule(models.TransientModel):
import_message = fields.Text()
force = fields.Boolean(string='Force init', help="Force init mode even if installed. (will update `noupdate='1'` records)")
@api.multi
def import_module(self):
self.ensure_one()
IrModule = self.env['ir.module.module']
@@ -35,7 +34,6 @@ class BaseImportModule(models.TransientModel):
'context': context,
}
@api.multi
def action_module_open(self):
self.ensure_one()
return {
@@ -31,7 +31,6 @@ class IrModule(models.Model):
module.installed_version = module.latest_version
super(IrModule, self - imported_modules)._get_latest_version()
@api.multi
def _import_module(self, module, path, force=False):
known_mods = self.search([])
known_mods_names = {m.name: m for m in known_mods}
@@ -53,12 +53,10 @@ class ResConfigSettings(models.TransientModel):
)
return res
@api.multi
def set_values(self):
super(ResConfigSettings, self).set_values()
self.env.ref('base.res_partner_rule').write({'active': not self.company_share_partner})
@api.multi
def open_company(self):
return {
'type': 'ir.actions.act_window',
@@ -68,7 +66,6 @@ class ResConfigSettings(models.TransientModel):
'res_id': self.env.company.id,
'target': 'current',
}
@api.multi
def open_default_user(self):
action = self.env.ref('base.action_res_users').read()[0]
action['res_id'] = self.env.ref('base.default_user').id
@@ -85,13 +82,11 @@ class ResConfigSettings(models.TransientModel):
'res_id': template_id.id,
}
@api.multi
def edit_external_header(self):
if not self.external_report_layout_id:
return False
return self._prepare_report_view_action(self.external_report_layout_id.key)
@api.multi
def change_report_template(self):
self.ensure_one()
template = self.env.ref('base.view_company_document_template_form')
@@ -15,7 +15,6 @@ class IrModelFields(models.Model):
"This cannot be changed after creation.",
)
@api.multi
def write(self, vals):
# Limitation: renaming a sparse field or changing the storing system is
# currently not allowed
-1
View File
@@ -414,7 +414,6 @@ class ResPartner(models.Model):
values['vat'] = self._fix_vat_number(values['vat'])
return super(ResPartner, self).create(values)
@api.multi
def write(self, values):
if values.get('vat'):
values['vat'] = self._fix_vat_number(values['vat'])
-1
View File
@@ -10,7 +10,6 @@ class ResPartner(models.Model):
im_status = fields.Char('IM Status', compute='_compute_im_status')
@api.multi
def _compute_im_status(self):
self.env.cr.execute("""
SELECT
-1
View File
@@ -11,7 +11,6 @@ class ResUsers(models.Model):
im_status = fields.Char('IM Status', compute='_compute_im_status')
@api.multi
def _compute_im_status(self):
""" Compute the im_status of the users """
self.env.cr.execute("""
-40
View File
@@ -154,12 +154,10 @@ class Attendee(models.Model):
values['common_name'] = values.get("common_name")
return super(Attendee, self).create(vals_list)
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
raise UserError(_('You cannot duplicate a calendar attendee.'))
@api.multi
def _send_mail_to_attendees(self, template_xmlid, force_send=False):
""" Send mail for event invitation to event attendees.
:param template_xmlid: xml id of the email template to use to send the invitation
@@ -216,12 +214,10 @@ class Attendee(models.Model):
return res
@api.multi
def do_tentative(self):
""" Makes event invitation as Tentative. """
return self.write({'state': 'tentative'})
@api.multi
def do_accept(self):
""" Marks event invitation as Accepted. """
result = self.write({'state': 'accepted'})
@@ -230,7 +226,6 @@ class Attendee(models.Model):
attendee.event_id.message_post(body=_("%s has accepted invitation") % (attendee.common_name), subtype="calendar.subtype_invitation")
return result
@api.multi
def do_decline(self):
""" Marks event invitation as Declined. """
res = self.write({'state': 'declined'})
@@ -519,13 +514,11 @@ class Alarm(models.Model):
self._update_cron()
return result
@api.multi
def write(self, values):
result = super(Alarm, self).write(values)
self._update_cron()
return result
@api.multi
def unlink(self):
result = super(Alarm, self).unlink()
self._update_cron()
@@ -588,14 +581,12 @@ class Meeting(models.Model):
partners |= self.env['res.partner'].browse(active_id)
return partners
@api.multi
def _get_recurrent_dates_by_event(self):
""" Get recurrent start and stop dates based on Rule string"""
start_dates = self._get_recurrent_date_by_event(date_field='start')
stop_dates = self._get_recurrent_date_by_event(date_field='stop')
return list(zip(start_dates, stop_dates))
@api.multi
def _get_recurrent_date_by_event(self, date_field='start'):
""" Get recurrent dates based on Rule string and all event where recurrent_id is child
@@ -648,7 +639,6 @@ class Meeting(models.Model):
return timezone.localize(d.replace(tzinfo=None), is_dst=True).astimezone(pytz.UTC)
return [naive_tz_to_utc(d) if not use_naive_datetime else d for d in rset1 if d.year < MAXYEAR]
@api.multi
def _get_recurrency_end_date(self):
""" Return the last date a recurring event happens, according to its end_type. """
self.ensure_one()
@@ -678,7 +668,6 @@ class Meeting(models.Model):
return computed_final_date or deadline
return final_date
@api.multi
def _find_my_attendee(self):
""" Return the first attendee where the user connected has been invited
from all the meeting_ids in parameters.
@@ -860,25 +849,21 @@ class Meeting(models.Model):
alarm_ids = fields.Many2many('calendar.alarm', 'calendar_alarm_calendar_event_rel', string='Reminders', ondelete="restrict", copy=False)
is_highlighted = fields.Boolean(compute='_compute_is_highlighted', string='Is the Event Highlighted')
@api.multi
def _compute_attendee(self):
for meeting in self:
attendee = meeting._find_my_attendee()
meeting.is_attendee = bool(attendee)
meeting.attendee_status = attendee.state if attendee else 'needsAction'
@api.multi
def _compute_display_time(self):
for meeting in self:
meeting.display_time = self._get_display_time(meeting.start, meeting.stop, meeting.duration, meeting.allday)
@api.multi
@api.depends('allday', 'start_date', 'start_datetime')
def _compute_display_start(self):
for meeting in self:
meeting.display_start = meeting.start_date if meeting.allday else meeting.start_datetime
@api.multi
@api.depends('allday', 'start', 'stop')
def _compute_dates(self):
""" Adapt the value of start_date(time)/stop_date(time) according to start/stop fields and allday. Also, compute
@@ -900,7 +885,6 @@ class Meeting(models.Model):
meeting.duration = self._get_duration(meeting.start, meeting.stop)
@api.multi
def _inverse_dates(self):
for meeting in self:
if meeting.allday:
@@ -935,7 +919,6 @@ class Meeting(models.Model):
else:
meeting.rrule = ''
@api.multi
def _inverse_rrule(self):
for meeting in self:
if meeting.rrule:
@@ -983,7 +966,6 @@ class Meeting(models.Model):
# Calendar Business, Reccurency, ...
####################################################
@api.multi
def _get_ics_file(self):
""" Returns iCalendar file for the event invitation.
:returns a dict of .ics file content for each meeting
@@ -1044,7 +1026,6 @@ class Meeting(models.Model):
return result
@api.multi
def create_attendees(self):
current_user = self.env.user
result = {}
@@ -1095,7 +1076,6 @@ class Meeting(models.Model):
}
return result
@api.multi
def get_search_fields(self, order_fields, r_date=None):
sort_fields = {}
for field in order_fields:
@@ -1113,7 +1093,6 @@ class Meeting(models.Model):
sort_fields['sort_start'] = display_start.replace(' ', '').replace('-', '') if display_start else False
return sort_fields
@api.multi
def get_recurrent_ids(self, domain, order=None):
""" Gives virtual event ids for recurring events. This method gives ids of dates
that comes between start date and end date of calendar views
@@ -1240,7 +1219,6 @@ class Meeting(models.Model):
]
return [r['id'] for r in sorted(result_data, key=key)]
@api.multi
def _rrule_serialize(self):
""" Compute rule string according to value type RECUR of iCalendar
:return: string containing recurring rule (empty if no rule)
@@ -1351,7 +1329,6 @@ class Meeting(models.Model):
data['end_type'] = 'end_date'
return data
@api.multi
def get_interval(self, interval, tz=None):
""" Format and localize some dates to be used in email templates
:param string interval: Among 'day', 'month', 'dayname' and 'time' indicating the desired formatting
@@ -1385,7 +1362,6 @@ class Meeting(models.Model):
return result
@api.multi
def get_display_time_tz(self, tz=False):
""" get the display_time of the meeting, forcing the timezone. This method is called from email template, to not use sudo(). """
self.ensure_one()
@@ -1393,7 +1369,6 @@ class Meeting(models.Model):
self = self.with_context(tz=tz)
return self._get_display_time(self.start, self.stop, self.duration, self.allday)
@api.multi
def detach_recurring_event(self, values=None):
""" Detach a virtual recurring event by duplicating the original and change reccurent values
:param values : dict of value to override on the detached event
@@ -1422,7 +1397,6 @@ class Meeting(models.Model):
del data['id']
return meeting_origin.copy(default=data)
@api.multi
def action_detach_recurring_event(self):
meeting = self.detach_recurring_event()
return {
@@ -1434,13 +1408,11 @@ class Meeting(models.Model):
'flags': {'form': {'action_buttons': True, 'options': {'mode': 'edit'}}}
}
@api.multi
def action_open_calendar_event(self):
if self.res_model and self.res_id:
return self.env[self.res_model].browse(self.res_id).get_formview_action()
return False
@api.multi
def action_sendmail(self):
email = self.env.user.email
if email:
@@ -1452,7 +1424,6 @@ class Meeting(models.Model):
# Messaging
####################################################
@api.multi
def _get_message_unread(self):
id_map = {x: calendar_id2real_id(x) for x in self.ids}
real = self.browse(set(id_map.values()))
@@ -1464,7 +1435,6 @@ class Meeting(models.Model):
event.message_unread_counter = rec.message_unread_counter
event.message_unread = rec.message_unread
@api.multi
def _get_message_needaction(self):
id_map = {x: calendar_id2real_id(x) for x in self.ids}
real = self.browse(set(id_map.values()))
@@ -1476,7 +1446,6 @@ class Meeting(models.Model):
event.message_needaction_counter = rec.message_needaction_counter
event.message_needaction = rec.message_needaction
@api.multi
@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
thread_id = self.id
@@ -1488,17 +1457,14 @@ class Meeting(models.Model):
self = self.with_context(context)
return super(Meeting, self.browse(thread_id)).message_post(**kwargs)
@api.multi
def message_subscribe(self, partner_ids=None, channel_ids=None, subtype_ids=None):
records = self.browse(get_real_ids(self.ids))
return super(Meeting, records).message_subscribe(partner_ids=partner_ids, channel_ids=channel_ids, subtype_ids=subtype_ids)
@api.multi
def _message_subscribe(self, partner_ids=None, channel_ids=None, subtype_ids=None, customer_ids=None):
records = self.browse(get_real_ids(self.ids))
return super(Meeting, records)._message_subscribe(partner_ids=partner_ids, channel_ids=channel_ids, subtype_ids=subtype_ids, customer_ids=customer_ids)
@api.multi
def message_unsubscribe(self, partner_ids=None, channel_ids=None):
records = self.browse(get_real_ids(self.ids))
return super(Meeting, records).message_unsubscribe(partner_ids=partner_ids, channel_ids=channel_ids)
@@ -1507,7 +1473,6 @@ class Meeting(models.Model):
# ORM Overrides
####################################################
@api.multi
def get_metadata(self):
real = self.browse({calendar_id2real_id(x) for x in self.ids})
return super(Meeting, real).get_metadata()
@@ -1521,7 +1486,6 @@ class Meeting(models.Model):
arg[2][n] = calendar_id.split('-')[0]
return super(Meeting, self)._name_search(name=name, args=args, operator=operator, limit=limit, name_get_uid=name_get_uid)
@api.multi
def write(self, values):
# FIXME: neverending recurring events
if 'rrule' in values:
@@ -1640,7 +1604,6 @@ class Meeting(models.Model):
self.env['calendar.alarm_manager']._notify_next_alarm(meeting.partner_ids.ids)
return meeting
@api.multi
def export_data(self, fields_to_export, raw_data=False):
""" Override to convert virtual ids to ids """
records = self.browse(set(get_real_ids(self.ids)))
@@ -1652,7 +1615,6 @@ class Meeting(models.Model):
raise UserError(_('Group by date is not supported, use the calendar view instead.'))
return super(Meeting, self.with_context(virtual_id=False)).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
@api.multi
def read(self, fields=None, load='_classic_read'):
if not fields:
fields = list(self._fields)
@@ -1714,7 +1676,6 @@ class Meeting(models.Model):
del r[k]
return result
@api.multi
def unlink(self, can_be_deleted=True):
# Get concerned attendees to notify them if there is an alarm on the unlinked events,
# as it might have changed their next event notification
@@ -1784,7 +1745,6 @@ class Meeting(models.Model):
return events[offset: offset + limit].ids
return events.ids
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
-1
View File
@@ -20,7 +20,6 @@ class Attachment(models.Model):
args[index] = (args[index][0], args[index][1], get_real_ids(args[index][2]))
return super(Attachment, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
@api.multi
def write(self, vals):
""" When posting an attachment (new or not), convert the virtual ids in real ids. """
if isinstance(vals.get('res_id'), str):
-1
View File
@@ -15,7 +15,6 @@ class MailActivity(models.Model):
calendar_event_id = fields.Many2one('calendar.event', string="Calendar Meeting", ondelete='cascade')
@api.multi
def action_create_calendar_event(self):
self.ensure_one()
action = self.env.ref('calendar.action_calendar_event').read()[0]
-1
View File
@@ -13,7 +13,6 @@ class Partner(models.Model):
calendar_last_notif_ack = fields.Datetime('Last notification marked as read from base Calendar', default=fields.Datetime.now)
@api.multi
def get_attendee_detail(self, meeting_id):
""" Return a list of tuple (id, name, status)
Used by base_calendar.js : Many2ManyAttendee
-35
View File
@@ -167,7 +167,6 @@ class Lead(models.Model):
stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID)
return stages.browse(stage_ids)
@api.multi
def _compute_kanban_state(self):
today = date.today()
for lead in self:
@@ -234,7 +233,6 @@ class Lead(models.Model):
break
lead.email_state = email_state
@api.multi
def _compute_meeting_count(self):
meeting_data = self.env['calendar.event'].read_group([('opportunity_id', 'in', self.ids)], ['opportunity_id'], ['opportunity_id'])
mapped_data = {m['opportunity_id'][0]: m['opportunity_id_count'] for m in meeting_data}
@@ -335,7 +333,6 @@ class Lead(models.Model):
self._onchange_compute_probability(optional_field_name='email_state')
@api.constrains('user_id')
@api.multi
def _valid_team(self):
for lead in self:
if lead.user_id:
@@ -396,7 +393,6 @@ class Lead(models.Model):
result._write_probability(vals)
return result
@api.multi
def write(self, vals):
# stage change:
if 'stage_id' in vals:
@@ -441,7 +437,6 @@ class Lead(models.Model):
super(Lead, lead).write(proba_vals)
return
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
@@ -473,13 +468,11 @@ class Lead(models.Model):
# Actions Methods
# ----------------------------------------
@api.multi
def action_set_lost(self):
""" Lost semantic: probability = 0 or active = False """
result = self.write({'active': False, 'probability': 0})
return result
@api.multi
def action_set_won(self):
""" Won semantic: probability = 100 (active untouched) """
for lead in self:
@@ -490,7 +483,6 @@ class Lead(models.Model):
def action_set_automated_probability(self):
self.write({'probability': self.automated_probability})
@api.multi
def action_set_won_rainbowman(self):
self.ensure_one()
self.action_set_won()
@@ -542,7 +534,6 @@ class Lead(models.Model):
}
return True
@api.multi
def action_schedule_meeting(self):
""" Open meeting's calendar view to schedule meeting on current opportunity.
:return dict: dictionary value for created Meeting view
@@ -561,11 +552,9 @@ class Lead(models.Model):
}
return action
@api.multi
def close_dialog(self):
return {'type': 'ir.actions.act_window_close'}
@api.multi
def edit_dialog(self):
form_view = self.env.ref('crm.crm_case_form_view_oppor')
return {
@@ -606,7 +595,6 @@ class Lead(models.Model):
# perform search, return the first found
return self.env['crm.stage'].search(search_domain, order=order, limit=1)
@api.multi
def _merge_get_result_type(self):
""" Define the type of the result of the merge. If at least one of the
element to merge is an opp, the resulting new element will be an opp.
@@ -622,7 +610,6 @@ class Lead(models.Model):
return 'opportunity'
return 'lead'
@api.multi
def _merge_data(self, fields):
""" Prepare lead/opp data into a dictionary for merging. Different types
of fields are processed in different ways:
@@ -696,7 +683,6 @@ class Lead(models.Model):
bodies.append("<br/>".join(body + ['<br/>']))
return bodies
@api.multi
def _merge_notify(self, opportunities):
""" Create a message gathering merged leads/opps informations. Using message_post, send a
message explaining which fields has been merged and their new value. `self` is the
@@ -715,7 +701,6 @@ class Lead(models.Model):
message_body = "\n\n".join(message_bodies)
return self.message_post(body=message_body, subject=subject)
@api.multi
def _merge_opportunity_history(self, opportunities):
""" Move mail.message from the given opportunities to the current one. `self` is the
crm.lead record destination for message of `opportunities`.
@@ -730,7 +715,6 @@ class Lead(models.Model):
})
return True
@api.multi
def _merge_opportunity_attachments(self, opportunities):
""" Move attachments of given opportunities to the current one `self`, and rename
the attachments having same name than native ones.
@@ -756,7 +740,6 @@ class Lead(models.Model):
attachment.write(values)
return True
@api.multi
def merge_dependences(self, opportunities):
""" Merge dependences (messages, attachments, ...). These dependences will be
transfered to `self`, the most important lead.
@@ -768,7 +751,6 @@ class Lead(models.Model):
self._merge_opportunity_history(opportunities)
self._merge_opportunity_attachments(opportunities)
@api.multi
def merge_opportunity(self, user_id=False, team_id=False):
""" Merge opportunities in one. Different cases of merge:
- merge leads together = 1 new lead
@@ -821,7 +803,6 @@ class Lead(models.Model):
return opportunities_head
@api.multi
def get_duplicated_leads(self, partner_id, include_lost=False):
""" Search for opportunities that have the same partner and that arent done or cancelled
:param partner_id : partner to search
@@ -850,7 +831,6 @@ class Lead(models.Model):
domain += ['|', '&', ('type', '=', 'lead'), ('active', '=', True), ('type', '=', 'opportunity')]
return self.search(domain)
@api.multi
def _convert_opportunity_data(self, customer, team_id=False):
""" Extract the data from a lead to create the opportunity
:param customer : res.partner record
@@ -874,7 +854,6 @@ class Lead(models.Model):
value['stage_id'] = stage.id
return value
@api.multi
def convert_opportunity(self, partner_id, user_ids=False, team_id=False):
customer = False
if partner_id:
@@ -890,7 +869,6 @@ class Lead(models.Model):
return True
@api.multi
def _create_lead_partner_data(self, name, is_company, parent_id=False):
""" extract data from lead to create a partner
:param name : furtur name of the partner
@@ -921,7 +899,6 @@ class Lead(models.Model):
'type': 'contact'
}
@api.multi
def _create_lead_partner(self):
""" Create a partner from lead data
:returns res.partner record
@@ -945,7 +922,6 @@ class Lead(models.Model):
return partner_company
return Partner.create(self._create_lead_partner_data(self.name, False))
@api.multi
def handle_partner_assignation(self, action='create', partner_id=False):
""" Handle partner assignation during a lead conversion.
if action is 'create', create new partner with contact and assign lead to new partner_id.
@@ -970,7 +946,6 @@ class Lead(models.Model):
partner_ids[lead.id] = partner_id
return partner_ids
@api.multi
def allocate_salesman(self, user_ids=None, team_id=False):
""" Assign salesmen and salesteam to a batch of leads. If there are more
leads than salesmen, these salesmen will be assigned in round-robin.
@@ -996,7 +971,6 @@ class Lead(models.Model):
lead.write(value)
return True
@api.multi
def redirect_opportunity_view(self):
self.ensure_one()
# Get opportunity views
@@ -1020,7 +994,6 @@ class Lead(models.Model):
'context': {'default_type': 'opportunity'}
}
@api.multi
def redirect_lead_view(self):
self.ensure_one()
# Get lead views
@@ -1062,7 +1035,6 @@ class Lead(models.Model):
sub_title = _('or send an email to %s') % (email_link)
return '<p class="o_view_nocontent_smiling_face">%s</p><p class="oe_view_nocontent_alias">%s</p>' % (help_title, sub_title)
@api.multi
def log_meeting(self, meeting_subject, meeting_date, duration):
if not duration:
duration = _('unknown')
@@ -1209,7 +1181,6 @@ class Lead(models.Model):
def _creation_subtype(self):
return self.env.ref('crm.mt_lead_create')
@api.multi
def _track_subtype(self, init_values):
self.ensure_one()
if 'stage_id' in init_values and self.probability == 100 and self.stage_id:
@@ -1220,7 +1191,6 @@ class Lead(models.Model):
return self.env.ref('crm.mt_lead_stage')
return super(Lead, self)._track_subtype(init_values)
@api.multi
def _notify_get_groups(self):
""" Handle salesman recipients that can convert leads into opportunities
and set opportunities as won / lost. """
@@ -1248,7 +1218,6 @@ class Lead(models.Model):
return [new_group] + groups
@api.multi
def _notify_get_reply_to(self, default=None, records=None, company=None, doc_names=None):
""" Override to set alias of lead and opportunities to their sales team if any. """
aliases = self.mapped('team_id').sudo()._notify_get_reply_to(default=default, records=None, company=company, doc_names=None)
@@ -1258,7 +1227,6 @@ class Lead(models.Model):
res.update(super(Lead, leftover)._notify_get_reply_to(default=default, records=None, company=company, doc_names=doc_names))
return res
@api.multi
def get_formview_id(self, access_uid=None):
if self.type == 'opportunity':
view_id = self.env.ref('crm.crm_case_form_view_oppor').id
@@ -1266,7 +1234,6 @@ class Lead(models.Model):
view_id = super(Lead, self).get_formview_id()
return view_id
@api.multi
def _message_get_default_recipients(self):
return {r.id: {
'partner_ids': [],
@@ -1274,7 +1241,6 @@ class Lead(models.Model):
'email_cc': False}
for r in self}
@api.multi
def _message_get_suggested_recipients(self):
recipients = super(Lead, self)._message_get_suggested_recipients()
try:
@@ -1331,7 +1297,6 @@ class Lead(models.Model):
('stage_id.fold', '=', False)]).write({'partner_id': new_partner.id})
return super(Lead, self)._message_post_after_hook(message, msg_vals)
@api.multi
def _message_partner_info_from_emails(self, emails, link_mail=False):
result = super(Lead, self)._message_partner_info_from_emails(emails, link_mail=link_mail)
for partner_info in result:
-1
View File
@@ -44,7 +44,6 @@ class Stage(models.Model):
# This field for interface only
team_count = fields.Integer('team_count', compute='_compute_team_count')
@api.multi
def _compute_team_count(self):
for stage in self:
stage.team_count = self.env['crm.team'].search_count([])
-1
View File
@@ -93,7 +93,6 @@ class Team(models.Model):
defaults['team_id'] = self.id
return values
@api.multi
def write(self, vals):
result = super(Team, self).write(vals)
if 'alias_defaults' in vals:
-1
View File
@@ -86,7 +86,6 @@ class ResConfigSettings(models.TransientModel):
)
return res
@api.multi
def set_values(self):
super(ResConfigSettings, self).set_values()
alias = self._find_default_lead_alias_id()
-3
View File
@@ -36,13 +36,11 @@ class Partner(models.Model):
)
return rec
@api.multi
def _compute_opportunity_count(self):
for partner in self:
operator = 'child_of' if partner.is_company else '=' # the opportunity count should counts the opportunities of this company and all its contacts
partner.opportunity_count = self.env['crm.lead'].search_count([('partner_id', operator, partner.id), ('type', '=', 'opportunity')])
@api.multi
def _compute_meeting_count(self):
for partner in self:
partner.meeting_count = len(partner.meeting_ids)
@@ -59,7 +57,6 @@ class Partner(models.Model):
if self.mobile:
self.mobile = self.phone_format(self.mobile)
@api.multi
def schedule_meeting(self):
partner_ids = self.ids
partner_ids.append(self.env.user.partner_id.id)
-1
View File
@@ -9,7 +9,6 @@ class CrmLeadLost(models.TransientModel):
lost_reason_id = fields.Many2one('crm.lost.reason', 'Lost Reason')
@api.multi
def action_lost_reason_apply(self):
leads = self.env['crm.lead'].browse(self.env.context.get('active_ids'))
leads.write({'lost_reason': self.lost_reason_id.id})
@@ -87,7 +87,6 @@ class Lead2OpportunityPartner(models.TransientModel):
raise UserError(_("Closed/Dead leads cannot be converted into opportunities."))
return False
@api.multi
def _convert_opportunity(self, vals):
self.ensure_one()
@@ -110,7 +109,6 @@ class Lead2OpportunityPartner(models.TransientModel):
return res
@api.multi
def action_apply(self):
""" Convert lead to opportunity or merge lead and opportunity and open
the freshly created opportunity view.
@@ -205,7 +203,6 @@ class Lead2OpportunityMassConvert(models.TransientModel):
self.opportunity_ids = self.env['crm.lead'].browse(leads_with_duplicates)
@api.multi
def _convert_opportunity(self, vals):
""" When "massively" (more than one at a time) converting leads to
opportunities, check the salesteam_id and salesmen_ids and update
@@ -219,7 +216,6 @@ class Lead2OpportunityMassConvert(models.TransientModel):
vals.update({'user_ids': salesmen_ids, 'team_id': salesteam_id})
return super(Lead2OpportunityMassConvert, self)._convert_opportunity(vals)
@api.multi
def mass_convert(self):
self.ensure_one()
if self.name == 'convert' and self.deduplicate:
@@ -36,7 +36,6 @@ class MergeOpportunity(models.TransientModel):
user_id = fields.Many2one('res.users', 'Salesperson', index=True)
team_id = fields.Many2one('crm.team', 'Sales Team', oldname='section_id', index=True)
@api.multi
def action_merge(self):
self.ensure_one()
merge_opportunity = self.opportunity_ids.merge_opportunity(self.user_id.id, self.team_id.id)
@@ -158,7 +158,6 @@ class CRMLeadMiningRequest(models.Model):
self._cr.commit()
raise e
@api.multi
def _create_leads_from_response(self, result):
""" This method will get the response from the service and create the leads accordingly """
self.ensure_one()
@@ -188,13 +187,11 @@ class CRMLeadMiningRequest(models.Model):
sub_title = _('Generate new leads based on their country, industry, size, etc.')
return '<p class="o_view_nocontent_smiling_face">%s</p><p class="oe_view_nocontent_alias">%s</p>' % (help_title, sub_title)
@api.multi
def action_draft(self):
self.ensure_one()
self.name = _('New')
self.state = 'draft'
@api.multi
def action_submit(self):
self.ensure_one()
if self.name == _('New'):
@@ -208,7 +205,6 @@ class CRMLeadMiningRequest(models.Model):
elif self.lead_type == 'opportunity':
return self.action_get_opportunity_action()
@api.multi
def action_get_lead_action(self):
self.ensure_one()
action = self.env.ref('crm.crm_lead_all_leads').read()[0]
@@ -220,7 +216,6 @@ class CRMLeadMiningRequest(models.Model):
</p>""")
return action
@api.multi
def action_get_opportunity_action(self):
self.ensure_one()
action = self.env.ref('crm.crm_lead_opportunities').read()[0]
@@ -81,7 +81,6 @@ class DeliveryCarrier(models.Model):
for c in self:
c.debug_logging = not c.debug_logging
@api.multi
def install_more_provider(self):
return {
'name': 'New Providers',
-3
View File
@@ -37,11 +37,9 @@ class SaleOrder(models.Model):
if delivery_line:
self.recompute_delivery_price = True
@api.multi
def _remove_delivery_line(self):
self.env['sale.order.line'].search([('order_id', 'in', self.ids), ('is_delivery', '=', True)]).unlink()
@api.multi
def set_delivery_line(self, carrier, amount):
# Remove delivery products from the sales order
@@ -156,7 +154,6 @@ class SaleOrderLine(models.Model):
return 0.0
line.product_qty = line.product_uom._compute_quantity(line.product_uom_qty, line.product_id.uom_id)
@api.multi
def unlink(self):
for line in self:
if line.is_delivery:
-9
View File
@@ -112,7 +112,6 @@ class StockPicking(models.Model):
for picking in self:
picking.weight = sum(move.weight for move in picking.move_lines if move.state != 'cancel')
@api.multi
def action_done(self):
res = super(StockPicking, self).action_done()
for pick in self:
@@ -121,7 +120,6 @@ class StockPicking(models.Model):
pick.send_to_shipper()
return res
@api.multi
def _pre_put_in_pack_hook(self, move_line_ids):
res = super(StockPicking, self)._pre_put_in_pack_hook(move_line_ids)
if not res:
@@ -151,7 +149,6 @@ class StockPicking(models.Model):
),
}
@api.multi
def action_send_confirmation_email(self):
self.ensure_one()
delivery_template_id = self.env.ref('delivery.mail_template_data_delivery_confirmation').id
@@ -173,7 +170,6 @@ class StockPicking(models.Model):
'context': ctx,
}
@api.multi
def send_to_shipper(self):
self.ensure_one()
res = self.carrier_id.send_shipping(self)[0]
@@ -188,12 +184,10 @@ class StockPicking(models.Model):
self._add_delivery_cost_to_so()
@api.multi
def print_return_label(self):
self.ensure_one()
res = self.carrier_id.get_return_label(self)
@api.multi
def _add_delivery_cost_to_so(self):
self.ensure_one()
sale_order = self.sale_id
@@ -209,7 +203,6 @@ class StockPicking(models.Model):
'name': sale_order.carrier_id.with_context(lang=self.partner_id.lang).name,
})
@api.multi
def open_website_url(self):
self.ensure_one()
if not self.carrier_tracking_url:
@@ -242,7 +235,6 @@ class StockPicking(models.Model):
picking.message_post(body=msg)
picking.carrier_tracking_ref = False
@api.multi
def check_packages_are_identical(self):
'''Some shippers require identical packages in the same shipment. This utility checks it.'''
self.ensure_one()
@@ -257,7 +249,6 @@ class StockPicking(models.Model):
class StockReturnPicking(models.TransientModel):
_inherit = 'stock.return.picking'
@api.multi
def _create_returns(self):
# Prevent copy of the carrier and carrier price when generating return picking
# (we have no integration of returns for now)
-4
View File
@@ -80,21 +80,17 @@ class Digest(models.Model):
vals['next_run_date'] = date.today() + relativedelta(days=3)
return super(Digest, self).create(vals)
@api.multi
def action_subscribe(self):
if self.env.user not in self.user_ids:
self.sudo().user_ids |= self.env.user
@api.multi
def action_unsubcribe(self):
if self.env.user in self.user_ids:
self.sudo().user_ids -= self.env.user
@api.multi
def action_activate(self):
self.state = 'activated'
@api.multi
def action_deactivate(self):
self.state = 'deactivated'
-13
View File
@@ -182,7 +182,6 @@ class EventEvent(models.Model):
badge_innerright = fields.Html(string='Badge Inner Right')
event_logo = fields.Html(string='Event Logo')
@api.multi
@api.depends('seats_max', 'registration_ids.state')
def _compute_seats(self):
""" Determine reserved, available, reserved but unconfirmed and used seats. """
@@ -281,7 +280,6 @@ class EventEvent(models.Model):
if event.date_end < event.date_begin:
raise ValidationError(_('The closing date cannot be earlier than the beginning date.'))
@api.multi
@api.depends('name', 'date_begin', 'date_end')
def name_get(self):
result = []
@@ -302,14 +300,12 @@ class EventEvent(models.Model):
res.button_confirm()
return res
@api.multi
def write(self, vals):
res = super(EventEvent, self).write(vals)
if vals.get('organizer_id'):
self.message_subscribe([vals['organizer_id']])
return res
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
@@ -319,7 +315,6 @@ class EventEvent(models.Model):
def button_draft(self):
self.write({'state': 'draft'})
@api.multi
def button_cancel(self):
if any('done' in event.mapped('registration_ids.state') for event in self):
raise UserError(_("There are already attendees who attended this event. Please reset it to draft if you want to cancel this event."))
@@ -337,11 +332,9 @@ class EventEvent(models.Model):
for attendee in event.registration_ids.filtered(filter_func):
self.env['mail.template'].browse(template_id).send_mail(attendee.id, force_send=force_send)
@api.multi
def _is_event_registrable(self):
return self.date_end > fields.Datetime.now()
@api.multi
def _get_ics_file(self):
""" Returns iCalendar file for the event invitation.
:returns a dict of .ics file content for each event
@@ -401,7 +394,6 @@ class EventRegistration(models.Model):
if registration.event_id.seats_availability == 'limited' and registration.event_id.seats_max and registration.event_id.seats_available < (1 if registration.state == 'draft' else 0):
raise ValidationError(_('No more seats available for this event.'))
@api.multi
def _check_auto_confirmation(self):
if self._context.get('registration_force_draft'):
return False
@@ -471,7 +463,6 @@ class EventRegistration(models.Model):
self.email = contact.email or self.email
self.phone = contact.phone or self.phone
@api.multi
def _message_get_suggested_recipients(self):
recipients = super(EventRegistration, self)._message_get_suggested_recipients()
public_users = self.env['res.users'].sudo()
@@ -489,7 +480,6 @@ class EventRegistration(models.Model):
pass
return recipients
@api.multi
def _message_get_default_recipients(self):
# Prioritize registration email over partner_id, which may be shared when a single
# partner booked multiple seats
@@ -513,7 +503,6 @@ class EventRegistration(models.Model):
]).write({'partner_id': new_partner.id})
return super(EventRegistration, self)._message_post_after_hook(message, msg_vals)
@api.multi
def action_send_badge_email(self):
""" Open a window to compose an email, with the template - 'event_badge'
message loaded by default
@@ -540,7 +529,6 @@ class EventRegistration(models.Model):
'context': ctx,
}
@api.multi
def get_date_range_str(self):
self.ensure_one()
today = fields.Datetime.now()
@@ -559,7 +547,6 @@ class EventRegistration(models.Model):
else:
return _('on ') + format_datetime(self.env, self.event_begin_date, tz=self.event_id.date_tz, dt_format='medium')
@api.multi
def summary(self):
self.ensure_one()
return {'information': []}
-1
View File
@@ -14,7 +14,6 @@ class ResPartner(models.Model):
for partner in self:
partner.event_count = self.env['event.event'].search_count([('registration_ids.partner_id', 'child_of', partner.ids)])
@api.multi
def action_event_view(self):
action = self.env.ref('event.action_event_view').read()[0]
action['context'] = {}
-1
View File
@@ -9,7 +9,6 @@ class event_confirm(models.TransientModel):
_name = "event.confirm"
_description = 'Event Confirmation'
@api.multi
def confirm(self):
events = self.env['event.event'].browse(self._context.get('event_ids', []))
events.do_confirm()
@@ -7,7 +7,6 @@ from odoo import api, models
class AccountMove(models.Model):
_inherit = 'account.move'
@api.multi
def action_invoice_paid(self):
""" When an invoice linked to a sales order selling registrations is
paid confirm attendees. Attendees should indeed not be confirmed before
-8
View File
@@ -53,7 +53,6 @@ class Event(models.Model):
})
for ticket in self.event_type_id.event_ticket_ids]
@api.multi
def _is_event_registrable(self):
if super(Event, self)._is_event_registrable():
self.ensure_one()
@@ -93,7 +92,6 @@ class EventTicket(models.Model):
seats_unconfirmed = fields.Integer(string='Unconfirmed Seat Reservations', compute='_compute_seats', store=True)
seats_used = fields.Integer(compute='_compute_seats', store=True)
@api.multi
def _compute_is_expired(self):
for record in self:
if record.deadline:
@@ -102,7 +100,6 @@ class EventTicket(models.Model):
else:
record.is_expired = False
@api.multi
def _compute_price_reduce(self):
for record in self:
product = record.product_id
@@ -116,7 +113,6 @@ class EventTicket(models.Model):
taxes = tax_ids.compute_all(record.price_reduce, record.event_id.company_id.currency_id, 1.0, product=record.product_id)
record.price_reduce_taxinc = taxes['total_included']
@api.multi
@api.depends('seats_max', 'registration_ids.state')
def _compute_seats(self):
""" Determine reserved, available, reserved but unconfirmed and used seats. """
@@ -145,7 +141,6 @@ class EventTicket(models.Model):
if ticket.seats_max > 0:
ticket.seats_available = ticket.seats_max - (ticket.seats_reserved + ticket.seats_used)
@api.multi
@api.constrains('registration_ids', 'seats_max')
def _check_seats_limit(self):
for record in self:
@@ -201,14 +196,12 @@ class EventRegistration(models.Model):
if self.event_ticket_id and (not self.event_id or self.event_id != self.event_ticket_id.event_id):
self.event_ticket_id = None
@api.multi
@api.constrains('event_ticket_id', 'state')
def _check_ticket_seats_limit(self):
for record in self:
if record.event_ticket_id.seats_max and record.event_ticket_id.seats_available < 0:
raise ValidationError(_('No more available seats for this ticket'))
@api.multi
def _check_auto_confirmation(self):
res = super(EventRegistration, self)._check_auto_confirmation()
if res:
@@ -244,7 +237,6 @@ class EventRegistration(models.Model):
})
return att_data
@api.multi
def summary(self):
res = super(EventRegistration, self).summary()
if self.event_ticket_id.product_id.image_medium:
-3
View File
@@ -6,7 +6,6 @@ from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = "sale.order"
@api.multi
def _action_confirm(self):
res = super(SaleOrder, self)._action_confirm()
for so in self:
@@ -14,7 +13,6 @@ class SaleOrder(models.Model):
so.order_line._update_registrations(confirm=so.amount_total == 0, cancel_to_draft=False)
return res
@api.multi
def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
for so in self:
@@ -35,7 +33,6 @@ class SaleOrderLine(models.Model):
"an event ticket and it will automatically create a registration for this event ticket.")
event_ok = fields.Boolean(related='product_id.event_ok', readonly=True)
@api.multi
def _update_registrations(self, confirm=True, cancel_to_draft=False, registration_data=None):
""" Create or update registrations linked to a sales order line. A sale
order line has a product_uom_qty attribute that will be the number of
@@ -45,7 +45,6 @@ class RegistrationEditor(models.TransientModel):
res = self._convert_to_write(res)
return res
@api.multi
def action_make_registration(self):
self.ensure_one()
for registration_line in self.event_registration_ids:
@@ -74,7 +73,6 @@ class RegistrationEditorLine(models.TransientModel):
phone = fields.Char(string='Phone')
name = fields.Char(string='Name', index=True)
@api.multi
def get_registration_data(self):
self.ensure_one()
return {
-6
View File
@@ -84,24 +84,20 @@ odoo_mailgate: "|/path/to/odoo-mailgate.py --host=localhost -u %(uid)d -p PASSWO
self._update_cron()
return res
@api.multi
def write(self, values):
res = super(FetchmailServer, self).write(values)
self._update_cron()
return res
@api.multi
def unlink(self):
res = super(FetchmailServer, self).unlink()
self._update_cron()
return res
@api.multi
def set_draft(self):
self.write({'state': 'draft'})
return True
@api.multi
def connect(self):
self.ensure_one()
if self.server_type == 'imap':
@@ -123,7 +119,6 @@ odoo_mailgate: "|/path/to/odoo-mailgate.py --host=localhost -u %(uid)d -p PASSWO
connection.sock.settimeout(MAIL_TIMEOUT)
return connection
@api.multi
def button_confirm_login(self):
for server in self:
try:
@@ -149,7 +144,6 @@ odoo_mailgate: "|/path/to/odoo-mailgate.py --host=localhost -u %(uid)d -p PASSWO
""" Method called by cron to fetch mails from servers """
return self.search([('state', '=', 'done'), ('server_type', 'in', ['pop', 'imap'])]).fetch_mail()
@api.multi
def fetch_mail(self):
""" WARNING: meant for cron usage only - will commit() after each email! """
additionnal_context = {
-4
View File
@@ -220,7 +220,6 @@ class FleetVehicle(models.Model):
future_driver.write({'plan_to_change_car': True})
return res
@api.multi
def write(self, vals):
if 'driver_id' in vals and vals['driver_id']:
driver_id = vals['driver_id']
@@ -276,7 +275,6 @@ class FleetVehicle(models.Model):
rec = self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid)
return self.browse(rec).name_get()
@api.multi
def return_action_to_open(self):
""" This opens the xml view specified in xml_id for the current vehicle """
self.ensure_one()
@@ -290,7 +288,6 @@ class FleetVehicle(models.Model):
return res
return False
@api.multi
def act_show_log_cost(self):
""" This opens log view to view and add new log for this vehicle, groupby default to only show effective costs
@return: the costs log view
@@ -305,7 +302,6 @@ class FleetVehicle(models.Model):
)
return res
@api.multi
def _track_subtype(self, init_values):
self.ensure_one()
if 'driver_id' in init_values:
@@ -176,24 +176,20 @@ class FleetVehicleLogContract(models.Model):
if self.vehicle_id:
self.odometer_unit = self.vehicle_id.odometer_unit
@api.multi
def write(self, vals):
res = super(FleetVehicleLogContract, self).write(vals)
if vals.get('expiration_date') or vals.get('user_id'):
self.activity_reschedule(['fleet.mail_act_fleet_contract_to_renew'], date_deadline=vals.get('expiration_date'), new_user_id=vals.get('user_id'))
return res
@api.multi
def contract_close(self):
for record in self:
record.state = 'closed'
@api.multi
def contract_open(self):
for record in self:
record.state = 'open'
@api.multi
def act_renew_contract(self):
assert len(self.ids) == 1, "This operation should only be done for 1 single contract at a time, as it it suppose to open a window as result"
for element in self:
@@ -18,7 +18,6 @@ class FleetVehicleModel(models.Model):
image_medium = fields.Binary(related='brand_id.image_medium', string="Logo (medium)", readonly=False)
image_small = fields.Binary(related='brand_id.image_small', string="Logo (small)", readonly=False)
@api.multi
@api.depends('name', 'brand_id')
def name_get(self):
res = []
@@ -60,7 +59,6 @@ class FleetVehicleModelBrand(models.Model):
tools.image_resize_images(vals)
return super(FleetVehicleModelBrand, self).create(vals_list)
@api.multi
def write(self, vals):
tools.image_resize_images(vals)
return super(FleetVehicleModelBrand, self).write(vals)
-1
View File
@@ -143,7 +143,6 @@ class GamificationBadge(models.Model):
tools.image_resize_images(vals)
return super(GamificationBadge, self).create(values_list)
@api.multi
def write(self, vals):
tools.image_resize_images(vals)
return super(GamificationBadge, self).write(vals)
-6
View File
@@ -167,7 +167,6 @@ class Challenge(models.Model):
return super(Challenge, self).create(vals)
@api.multi
def write(self, vals):
if vals.get('user_domain'):
users = self._get_challenger_users(ustr(vals.get('user_domain')))
@@ -299,12 +298,10 @@ class Challenge(models.Model):
return True
@api.multi
def action_start(self):
"""Start a challenge"""
return self.write({'state': 'inprogress'})
@api.multi
def action_check(self):
"""Check a challenge
@@ -317,7 +314,6 @@ class Challenge(models.Model):
return self._update_all()
@api.multi
def action_report_progress(self):
"""Manual report of a goal, does not influence automatic report frequency"""
for challenge in self:
@@ -602,7 +598,6 @@ class Challenge(models.Model):
return challenge.write({'last_report_date': fields.Date.today()})
##### Challenges #####
@api.multi
def accept_challenge(self):
user = self.env.user
sudoed = self.sudo()
@@ -610,7 +605,6 @@ class Challenge(models.Model):
sudoed.write({'invited_user_ids': [(3, user.id)], 'user_ids': [(4, user.id)]})
return sudoed._generate_goals_from_challenge()
@api.multi
def discard_challenge(self):
"""The user discard the suggested challenge"""
user = self.env.user
@@ -54,7 +54,6 @@ class KarmaRank(models.Model):
users._recompute_rank()
return res
@api.multi
def write(self, vals):
tools.image_resize_images(vals)
res = super(KarmaRank, self).write(vals)
-8
View File
@@ -117,7 +117,6 @@ class GoalDefinition(models.Model):
definition._check_model_validity()
return definition
@api.multi
def write(self, vals):
res = super(GoalDefinition, self).write(vals)
if vals.get('computation_mode', 'count') in ('count', 'sum') and (vals.get('domain') or vals.get('model_id')):
@@ -250,7 +249,6 @@ class Goal(models.Model):
return {self: result}
@api.multi
def update_goal(self):
"""Update the goals to recomputes values and change of states
@@ -362,7 +360,6 @@ class Goal(models.Model):
self.env.cr.commit()
return True
@api.multi
def action_start(self):
"""Mark a goal as started.
@@ -370,7 +367,6 @@ class Goal(models.Model):
self.write({'state': 'inprogress'})
return self.update_goal()
@api.multi
def action_reach(self):
"""Mark a goal as reached.
@@ -378,14 +374,12 @@ class Goal(models.Model):
Progress at the next goal update until the end date."""
return self.write({'state': 'reached'})
@api.multi
def action_fail(self):
"""Set the state of the goal to failed.
A failed goal will be ignored in future checks."""
return self.write({'state': 'failed'})
@api.multi
def action_cancel(self):
"""Reset the completion after setting a goal as reached or failed.
@@ -398,7 +392,6 @@ class Goal(models.Model):
def create(self, vals):
return super(Goal, self.with_context(no_remind_goal=True)).create(vals)
@api.multi
def write(self, vals):
"""Overwrite the write method to update the last_update field to today
@@ -417,7 +410,6 @@ class Goal(models.Model):
goal.challenge_id.sudo().report_progress(users=goal.user_id)
return result
@api.multi
def get_action(self):
"""Get the ir.action related to update the goal
-3
View File
@@ -25,7 +25,6 @@ class Users(models.Model):
for user in self:
user.karma_position = 0
@api.multi
@api.depends('badge_ids')
def _get_user_badge_level(self):
""" Return total badge per level of users
@@ -55,14 +54,12 @@ class Users(models.Model):
res._recompute_rank()
return res
@api.multi
def write(self, vals):
result = super(Users, self).write(vals)
if 'karma' in vals:
self._recompute_rank()
return result
@api.multi
def add_karma(self, karma):
for user in self:
user.karma += karma
@@ -13,7 +13,6 @@ class grant_badge_wizard(models.TransientModel):
badge_id = fields.Many2one("gamification.badge", string='Badge', required=True)
comment = fields.Text('Comment')
@api.multi
def action_grant_badge(self):
"""Wizard action for sending a badge to a chosen user"""
@@ -11,7 +11,6 @@ class goal_manual_wizard(models.TransientModel):
goal_id = fields.Many2one("gamification.goal", string='Goal', required=True)
current = fields.Float('Current')
@api.multi
def action_update_current(self):
"""Wizard action for updating the current value"""
for wiz in self:
@@ -17,14 +17,12 @@ class Meeting(models.Model):
'attendee_ids', 'alarm_ids', 'location', 'privacy', 'active',
'start_date', 'start_datetime', 'stop_date', 'stop_datetime']
@api.multi
def write(self, values):
sync_fields = set(self.get_fields_need_update_google())
if (set(values) and sync_fields) and 'oe_update_date' not in values and 'NewMeeting' not in self._context:
values['oe_update_date'] = fields.Datetime.now()
return super(Meeting, self).write(values)
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = default or {}
@@ -36,7 +34,6 @@ class Meeting(models.Model):
default['oe_update_date'] = False
return super(Meeting, self).copy(default)
@api.multi
def unlink(self, can_be_deleted=False):
return super(Meeting, self).unlink(can_be_deleted=can_be_deleted)
@@ -52,7 +49,6 @@ class Attendee(models.Model):
('google_id_uniq', 'unique(google_internal_event_id,partner_id,event_id)', 'Google ID should be unique!')
]
@api.multi
def write(self, values):
for attendee in self:
meeting_id_to_update = values.get('event_id', attendee.event_id.id)
@@ -22,7 +22,6 @@ class GoogleDrive(models.Model):
_name = 'google.drive.config'
_description = "Google Drive templates config"
@api.multi
def get_google_drive_url(self, res_id, template_id):
self.ensure_one()
self = self.sudo()
@@ -191,7 +190,6 @@ class GoogleDrive(models.Model):
return word.group(2)
return None
@api.multi
def _compute_ressource_id(self):
result = {}
for record in self:
@@ -202,7 +200,6 @@ class GoogleDrive(models.Model):
raise UserError(_("Please enter a valid Google Document URL."))
return result
@api.multi
def _compute_client_id(self):
google_drive_client_id = self.env['ir.config_parameter'].sudo().get_param('google_drive_client_id')
for record in self:
@@ -23,7 +23,6 @@ class ResConfigSettings(models.TransientModel):
res.update(is_google_drive_token_generated=bool(refresh_token))
return res
@api.multi
def confirm_setup_token(self):
params = self.env['ir.config_parameter'].sudo()
authorization_code_before = params.get_param('google_drive_authorization_code')
@@ -33,7 +32,6 @@ class ResConfigSettings(models.TransientModel):
refresh_token = self.env['google.service'].generate_refresh_token('drive', authorization_code)
params.set_param('google_drive_refresh_token', refresh_token)
@api.multi
def action_setup_token(self):
self.ensure_one()
template = self.env.ref('google_drive.google_drive_auth_code_wizard')
-2
View File
@@ -24,7 +24,6 @@ class Department(models.Model):
note = fields.Text('Note')
color = fields.Integer('Color Index')
@api.multi
def name_get(self):
if not self.env.context.get('hierarchical_naming', True):
return [(record.id, record.name) for record in self]
@@ -54,7 +53,6 @@ class Department(models.Model):
department.message_subscribe(partner_ids=manager.user_id.partner_id.ids)
return department
@api.multi
def write(self, vals):
""" If updating manager of a department, we need to update all the employees
of department hierarchy, and subscribe the new manager.
-8
View File
@@ -128,13 +128,11 @@ class HrEmployeePrivate(models.Model):
('user_uniq', 'unique (user_id, company_id)', "A user cannot be linked to multiple employees in the same company.")
]
@api.multi
def name_get(self):
if self.check_access_rights('read', raise_exception=False):
return super(HrEmployeePrivate, self).name_get()
return self.env['hr.employee.public'].browse(self.ids).name_get()
@api.multi
def read(self, fields, load='_classic_read'):
if self.check_access_rights('read', raise_exception=False):
return super(HrEmployeePrivate, self).read(fields, load=load)
@@ -163,7 +161,6 @@ class HrEmployeePrivate(models.Model):
return super(HrEmployeePrivate, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
return self.env['hr.employee.public']._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
@api.multi
def get_formview_id(self, access_uid=None):
""" Override this method in order to redirect many2one towards the right model depending on access_uid """
if access_uid:
@@ -176,7 +173,6 @@ class HrEmployeePrivate(models.Model):
# Hardcode the form view for public employee
return self.env.ref('hr.hr_employee_public_view_form').id
@api.multi
def get_formview_action(self, access_uid=None):
""" Override this method in order to redirect many2one towards the right model depending on access_uid """
res = super(HrEmployeePrivate, self).get_formview_action(access_uid=access_uid)
@@ -259,7 +255,6 @@ class HrEmployeePrivate(models.Model):
])._subscribe_users()
return employee
@api.multi
def write(self, vals):
if 'address_home_id' in vals:
account_id = vals.get('bank_account_id') or self.bank_account_id.id
@@ -277,7 +272,6 @@ class HrEmployeePrivate(models.Model):
])._subscribe_users()
return res
@api.multi
def unlink(self):
resources = self.mapped('resource_id')
super(HrEmployeePrivate, self).unlink()
@@ -301,7 +295,6 @@ class HrEmployeePrivate(models.Model):
}
return res
@api.multi
def generate_random_barcode(self):
for employee in self:
employee.barcode = "".join(choice(digits) for i in range(8))
@@ -392,7 +385,6 @@ class HrEmployeePrivate(models.Model):
def _message_log(self, **kwargs):
return super(HrEmployeePrivate, self._post_author())._message_log(**kwargs)
@api.multi
@api.returns('mail.message', lambda value: value.id)
def message_post(self, *args, **kwargs):
return super(HrEmployeePrivate, self._post_author()).message_post(*args, **kwargs)
-3
View File
@@ -46,7 +46,6 @@ class Job(models.Model):
""" We don't want the current user to be follower of all created job """
return super(Job, self.with_context(mail_create_nosubscribe=True)).create(values)
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
@@ -55,14 +54,12 @@ class Job(models.Model):
default['name'] = _("%s (copy)") % (self.name)
return super(Job, self).copy(default=default)
@api.multi
def set_recruit(self):
for record in self:
no_of_recruitment = 1 if record.no_of_recruitment == 0 else record.no_of_recruitment
record.write({'state': 'recruit', 'no_of_recruitment': no_of_recruitment})
return True
@api.multi
def set_open(self):
return self.write({
'state': 'open',
-1
View File
@@ -22,7 +22,6 @@ class Partner(models.Model):
except AccessError:
return suggestions
@api.multi
def name_get(self):
""" Override to allow an employee to see its private address in his profile.
This avoids to relax access rules on `res.parter` and to add an `ir.rule`.
-2
View File
@@ -139,7 +139,6 @@ class User(models.Model):
self = self.sudo()
return super(User, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
@api.multi
def write(self, vals):
"""
Synchronize user and its related employee
@@ -178,7 +177,6 @@ class User(models.Model):
for user in self:
user.employee_id = self.env['hr.employee'].search([('id', 'in', user.employee_ids.ids), ('company_id', '=', user.company_id.id)], limit=1)
@api.multi
def action_create_employee(self):
self.ensure_one()
self.env['hr.employee'].create(dict(
-1
View File
@@ -19,7 +19,6 @@ class HrPlanWizard(models.TransientModel):
plan_id = fields.Many2one('hr.plan', default=lambda self: self.env['hr.plan'].search([], limit=1))
employee_id = fields.Many2one('hr.employee', string='Employee', required=True)
@api.multi
def action_launch(self):
for activity_type in self.plan_id.plan_activity_type_ids:
self.env['mail.activity'].create({
@@ -19,7 +19,6 @@ class HrAttendance(models.Model):
check_out = fields.Datetime(string="Check Out")
worked_hours = fields.Float(string='Worked Hours', compute='_compute_worked_hours', store=True, readonly=True)
@api.multi
def name_get(self):
result = []
for attendance in self:
@@ -97,7 +96,6 @@ class HrAttendance(models.Model):
'datetime': fields.Datetime.to_string(fields.Datetime.context_timestamp(self, fields.Datetime.from_string(last_attendance_before_check_out.check_in))),
})
@api.multi
@api.returns('self', lambda value: value.id)
def copy(self):
raise exceptions.UserError(_('You cannot duplicate an attendance.'))
@@ -88,7 +88,6 @@ class HrEmployeeBase(models.AbstractModel):
return employee._attendance_action('hr_attendance.hr_attendance_action_kiosk_mode')
return {'warning': _('No employee corresponding to barcode %(barcode)s') % {'barcode': barcode}}
@api.multi
def attendance_manual(self, next_action, entered_pin=None):
self.ensure_one()
can_check_without_pin = not self.env.user.has_group('hr_attendance.group_hr_attendance_use_pin') or (self.user_id == self.env.user and entered_pin is None)
@@ -96,7 +95,6 @@ class HrEmployeeBase(models.AbstractModel):
return self._attendance_action(next_action)
return {'warning': _('Wrong PIN')}
@api.multi
def _attendance_action(self, next_action):
""" Changes the attendance of the employee.
Returns an action to the check in/out message,
@@ -117,7 +115,6 @@ class HrEmployeeBase(models.AbstractModel):
action_message['attendance'] = modified_attendance.read()[0]
return {'action': action_message}
@api.multi
def _attendance_action_change(self):
""" Check In/Check Out action
Check In: create a new attendance record

Some files were not shown because too many files have changed in this diff Show More