Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

convert function from odoo14 to odoo 16 with custom updates

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
upgradeodoo16features
3100 Vistas
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
Descartar
Axel Mendoza

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

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Running into two big problems migrating from v15 to v16
upgrade v15 odoo16features
Avatar
Avatar
1
jul 25
3152
upgrade database (One App Free) to the new version Resuelto
upgrade odoo16features ONEappfree
Avatar
Avatar
1
jun 23
3694
FileNotFoundError after v17 to v18 upgrade
upgrade
Avatar
Avatar
1
sept 25
1233
Upgrade v18->v19 on-premise
upgrade
Avatar
Avatar
Avatar
2
sept 25
4702
DeprecationWarning: The longpolling-port is a deprecated alias to the gevent-port option, please use the latter Resuelto
odoo16features
Avatar
Avatar
Avatar
Avatar
Avatar
5
sept 25
24325
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

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