Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

convert function from odoo14 to odoo 16 with custom updates

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
upgradeodoo16features
3103 Visualizações
Avatar
Asmaa

I am trying to upgrade custom module in odoo14 to odoo16
the code in custom 14 override  _prepare_move_line_default_vals function an d made changes in it this is the code:


def _prepare_move_line_default_vals(self, write_off_line_vals=None):
''' Prepare the dictionary to create the default account.move.lines for the current payment.
:param write_off_line_vals: Optional dictionary to create a write-off account.move.line easily containing:
* amount: The amount to be added to the counterpart amount.
* name: The label to set on the line.
* account_id: The account on which create the write-off.
:return: A list of python dictionary to be passed to the account.move.line's 'create' method.
'''
self
.ensure_one()
write_off_line_vals = write_off_line_vals or {}

if not self.journal_id.payment_debit_account_id or not self.journal_id.payment_credit_account_id:
raise UserError(_(
"You can't create a new payment without an outstanding payments/receipts account set on the %s journal.",
self
.journal_id.display_name))

# Compute amounts.
write_off_amount = write_off_line_vals.get('amount', 0.0)

if self.payment_type == 'inbound':
# Receive money.
counterpart_amount = -self.amount
write_off_amount *= -1
elif self
.payment_type == 'outbound':
# Send money.
counterpart_amount = self.amount
else:
counterpart_amount = 0.0
write_off_amount = 0.0

balance = counterpart_amount / self.currency_rate
counterpart_amount_currency = counterpart_amount
write_off_balance = self.currency_id._convert(write_off_amount, self.company_id.currency_id, self.company_id, self.date)
write_off_amount_currency = write_off_amount
currency_id = self.currency_id.id

if self.is_internal_transfer:
if self.payment_type == 'inbound':
liquidity_line_name = _('Transfer to %s', self.journal_id.name)
else: # payment.payment_type == 'outbound':
liquidity_line_name = _('Transfer from %s', self.journal_id.name)
else:
liquidity_line_name = self.payment_reference

# Compute a default label to set on the journal items.

payment_display_name = {
'outbound-customer': _("Customer Reimbursement"),
'inbound-customer'
: _("Customer Payment"),
'outbound-supplier'
: _("Vendor Payment"),
'inbound-supplier'
: _("Vendor Reimbursement"),
}

default_line_name = self.env['account.move.line']._get_default_line_name(
_("Internal Transfer") if self.is_internal_transfer else payment_display_name['%s-%s' % (self.payment_type, self.partner_type)],
self
.amount,
self
.currency_id,
self
.date,
partner
=self.partner_id,
)

line_vals_list = [
# Liquidity line.
{
'name': liquidity_line_name or default_line_name,
'date_maturity'
: self.date,
'amount_currency'
: -counterpart_amount_currency,
'currency_id'
: currency_id,
'debit'
: balance < 0.0 and -balance or 0.0,
'credit'
: balance > 0.0 and balance or 0.0,
'partner_id'
: self.partner_id.id,
'account_id'
: self.journal_id.payment_debit_account_id.id if balance < 0.0 else self.journal_id.payment_credit_account_id.id,
},
# Receivable / Payable.
{
'name': self.payment_reference or default_line_name,
'date_maturity'
: self.date,
'amount_currency'
: counterpart_amount_currency + write_off_amount_currency if currency_id else 0.0,
'currency_id'
: currency_id,
'debit'
: balance + write_off_balance > 0.0 and balance + write_off_balance or 0.0,
'credit'
: balance + write_off_balance < 0.0 and -balance - write_off_balance or 0.0,
'partner_id'
: self.partner_id.id,
'account_id'
: self.destination_account_id.id,
},
]
if write_off_balance:
# Write-off line.
line_vals_list.append({
'name': write_off_line_vals.get('name') or default_line_name,
'amount_currency'
: -write_off_amount_currency,
'currency_id'
: currency_id,
'debit'
: write_off_balance < 0.0 and -write_off_balance or 0.0,
'credit'
: write_off_balance > 0.0 and write_off_balance or 0.0,
'partner_id'
: self.partner_id.id,
'account_id'
: write_off_line_vals.get('account_id'),
})
return line_vals_list




i need to convert it to odoo16 with the same changes in custom 14 how can i do that?
this the code of this function in odoo 16:
def _prepare_move_line_default_vals(self, write_off_line_vals=None):
''' Prepare the dictionary to create the default account.move.lines for the current payment.
:param write_off_line_vals: Optional list of dictionaries to create a write-off account.move.line easily containing:
* amount: The amount to be added to the counterpart amount.
* name: The label to set on the line.
* account_id: The account on which create the write-off.
:return: A list of python dictionary to be passed to the account.move.line's 'create' method.
'''
self
.ensure_one()
write_off_line_vals = write_off_line_vals or {}

if not self.outstanding_account_id:
raise UserError(_(
"You can't create a new payment without an outstanding payments/receipts account set either on the company or the %s payment method in the %s journal.",
self
.payment_method_line_id.name, self.journal_id.display_name))

# Compute amounts.
write_off_line_vals_list = write_off_line_vals or []
write_off_amount_currency = sum(x['amount_currency'] for x in write_off_line_vals_list)
write_off_balance = sum(x['balance'] for x in write_off_line_vals_list)

if self.payment_type == 'inbound':
# Receive money.
liquidity_amount_currency = self.amount
elif self.payment_type == 'outbound':
# Send money.
liquidity_amount_currency = -self.amount
else:
liquidity_amount_currency = 0.0

liquidity_balance = self.currency_id._convert(
liquidity_amount_currency,
self
.company_id.currency_id,
self
.company_id,
self
.date,
)
counterpart_amount_currency = -liquidity_amount_currency - write_off_amount_currency
counterpart_balance = -liquidity_balance - write_off_balance
currency_id = self.currency_id.id

# Compute a default label to set on the journal items.
liquidity_line_name = ''.join(x[1] for x in self._get_liquidity_aml_display_name_list())
counterpart_line_name = ''.join(x[1] for x in self._get_counterpart_aml_display_name_list())

line_vals_list = [
# Liquidity line.
{
'name': liquidity_line_name,
'date_maturity'
: self.date,
'amount_currency'
: liquidity_amount_currency,
'currency_id'
: currency_id,
'debit'
: liquidity_balance if liquidity_balance > 0.0 else 0.0,
'credit'
: -liquidity_balance if liquidity_balance < 0.0 else 0.0,
'partner_id'
: self.partner_id.id,
'account_id'
: self.outstanding_account_id.id,
},
# Receivable / Payable.
{
'name': counterpart_line_name,
'date_maturity'
: self.date,
'amount_currency'
: counterpart_amount_currency,
'currency_id'
: currency_id,
'debit'
: counterpart_balance if counterpart_balance > 0.0 else 0.0,
'credit'
: -counterpart_balance if counterpart_balance < 0.0 else 0.0,
'partner_id'
: self.partner_id.id,
'account_id'
: self.destination_account_id.id,
},
]
return line_vals_list + write_off_line_vals_list

0
Avatar
Cancelar
Axel Mendoza

you are having and issue or something with your code update?

Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
Running into two big problems migrating from v15 to v16
upgrade v15 odoo16features
Avatar
Avatar
1
jul. 25
3153
upgrade database (One App Free) to the new version Resolvido
upgrade odoo16features ONEappfree
Avatar
Avatar
1
jun. 23
3694
FileNotFoundError after v17 to v18 upgrade
upgrade
Avatar
Avatar
1
set. 25
1233
Upgrade v18->v19 on-premise
upgrade
Avatar
Avatar
Avatar
2
set. 25
4705
DeprecationWarning: The longpolling-port is a deprecated alias to the gevent-port option, please use the latter Resolvido
odoo16features
Avatar
Avatar
Avatar
Avatar
Avatar
5
set. 25
24335
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now