Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

TypeError: populate_statement() takes at least 4 arguments (2 given)

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
typeError
1 Răspunde
6590 Vizualizări
Imagine profil
Koffi KPONOUGLO

Hi, Please can you help me to correct this error

class account_voucher_populate_statement(models.TransientModel):
_name = "account.voucher.populate.statement"
_description = "Account Voucher Populate Statement"

journal_id = fields.Many2one(
'account.journal',
'Journal',
required=True
)
line_ids = fields.Many2many(
'account.payment',
'account_payment_line_rel',
'payment_id', 'line_id',
'Payment',
domain="[('journal_id', '=', journal_id), ('state', '=', 'posted'), ('bank_statement_line_ids', '=', False)]"
)

def get_statement_line_new(self, cr, uid, payment, statement, context=None):
# Override thi method to modifiy the new statement line to create
ctx = context.copy()
ctx['date'] = payment.date
amount = self.pool.get('res.currency').compute(cr, uid, payment.currency_id.id,
statement.currency.id, payment.amount, context=ctx)

sign = payment.type == 'payment' and -1.0 or 1.0
type = payment.type == 'payment' and 'supplier' or 'customer'
account_id = payment.type == 'payment' and payment.partner_id.property_account_payable.id or payment.partner_id.property_account_receivable.id
return {
'name': payment.reference or payment.number or '?',
'amount': sign * amount,
'type': type,
'partner_id': payment.partner_id.id,
'account_id': account_id,
'statement_id': statement.id,
'ref': payment.name,
'payment_id': payment.id,
'journal_entry_id': payment.move_id.id,
}

def populate_statement(self, cr, uid, ids, context=None):
statement_obj = self.env['account.bank.statement']
statement_line_obj = self.env['account.bank.statement.line']
payment_obj = self.env['account.payment']

if context is None:
context = {}
data = self.read(cr, uid, ids, [], context=context)[0]
payments_ids = data['line_ids']
if not payments_ids:
return {'type': 'ir.actions.act_window_close'}
statement = statement_obj.browse(
cr, uid, context['active_id'], context=context)
for payment in payment_obj.browse(cr, uid, payment_ids, context=context):
statement_line_obj.create(cr, uid,
self.get_statement_line_new(cr, uid, payment, statement, context=context), context=context)
payment_obj.write(
cr, uid, payment_ids, {'is_bank_voucher': True}, context=context)
return {'type': 'ir.actions.act_window_close'}

0
Imagine profil
Abandonează
Imagine profil
Mohit Ghodasara (mgh)
Cel mai bun răspuns

looks like You are only passing two parameters and the method expects at least 4.
where is the call of this method? populate_statement()
try to give the same parameters calling time 


ok try to do some change like this

def populate_statement(self):
        cr = self._cr
        uid = self._uid
        ids = self._ids
        context = self._context

or

read directly without cr ids etc.

self.read()[0]

do the same with browse, create

you won't get an error

0
Imagine profil
Abandonează
Koffi KPONOUGLO
Autor

I am calling it in the view like this.

<button name="populate_statement" string="ADD" type="object" class="oe_highlight"/>

How can i do it?

Mohit Ghodasara (mgh)

ok, I think you won't get cr uid etc from the button click.

you can pass parameters in context also but it's not useful in your scenario

what exactly you want to do? maybe you need to find another way

Koffi KPONOUGLO
Autor

I want to get invoice payments directly in the bank.statement line as transaction. Another way is welcome. It is so urgent for me. Please.

Mohit Ghodasara (mgh)

ok I've updated my answer try if it is helpful

Koffi KPONOUGLO
Autor

Thanks. I try it and i get this error

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\account_bank_voucher\wizard\bank_statement_populate.py", line 60, in populate_statement

TypeError: read() takes at most 3 arguments (6 given)

Mohit Ghodasara (mgh)

oh you are using v10

read directly without cr ids etc.

self.read()[0]

do the same with browse, create

Koffi KPONOUGLO
Autor

I did it is working. Thanks a lot. but now i have a new error with the first function

def get_statement_line_new(self, cr, uid, payment, statement, context=None)

-------------------------------------------Error Details ----------------------------

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\account_bank_voucher\wizard\bank_statement_populate.py", line 31, in get_statement_line_new

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\addons\base\res\res_currency.py", line 160, in compute

AttributeError: 'int' object has no attribute 'round'

Mohit Ghodasara (mgh)

don't use type, a type is a keyword in python.

remove that three variable and give direct value and try. something mess over there

and don't forget to tick right mark if the first question is helpful thanks

Koffi KPONOUGLO
Autor

Thanks Mohit. Your help is so great. I am not developper that why i have more difficult do fix bug.

I try what you said by doing this :

typee = payment.type == 'payment' and 'supplier' or 'customer'

but i still get the same error (AttributeError: 'int' object has no attribute 'round).

I don't know if i do exactly what so ask me. Thanks in advance.

Mohit Ghodasara (mgh)

just give direct value to the directory like this 'type': 'payment',

for all sign, type, account_id, and name. make it static first then you could do dynamic

Koffi KPONOUGLO
Autor

Thanks dear Mohit. It is working now.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Database Manager unresponsive Rezolvat
typeError JS
Imagine profil
Imagine profil
Imagine profil
2
feb. 25
2070
TypeError: can't access property "classList"
typeError v15
Imagine profil
0
mar. 23
3734
TypeError: <lambda>() takes exactly 4 arguments (1 given)
lambda typeError
Imagine profil
Imagine profil
1
iun. 22
7385
Odoo12 TypeError like loop but i have not it any yet
typeError odooV12
Imagine profil
Imagine profil
2
apr. 19
3261
Uncaught TypeError: Cannot read properties of null (reading 'CodeMirror') Rezolvat
chrome error typeError
Imagine profil
1
feb. 23
7658
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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