Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

convert function from odoo14 to odoo 16 with custom updates

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
upgradeodoo16features
3101 Vues
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
Ignorer
Axel Mendoza

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

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Running into two big problems migrating from v15 to v16
upgrade v15 odoo16features
Avatar
Avatar
1
juil. 25
3152
upgrade database (One App Free) to the new version Résolu
upgrade odoo16features ONEappfree
Avatar
Avatar
1
juin 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 Résolu
odoo16features
Avatar
Avatar
Avatar
Avatar
Avatar
5
sept. 25
24325
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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