Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

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

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

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

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
typeError
1 ตอบกลับ
6584 มุมมอง
อวตาร
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
อวตาร
ละทิ้ง
อวตาร
Mohit Ghodasara (mgh)
คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
Koffi KPONOUGLO
ผู้เขียน

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
ผู้เขียน

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
ผู้เขียน

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
ผู้เขียน

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
ผู้เขียน

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
ผู้เขียน

Thanks dear Mohit. It is working now.

สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
Database Manager unresponsive แก้ไขแล้ว
typeError JS
อวตาร
อวตาร
อวตาร
2
ก.พ. 25
2063
TypeError: can't access property "classList"
typeError v15
อวตาร
0
มี.ค. 23
3734
TypeError: <lambda>() takes exactly 4 arguments (1 given)
lambda typeError
อวตาร
อวตาร
1
มิ.ย. 22
7374
Odoo12 TypeError like loop but i have not it any yet
typeError odooV12
อวตาร
อวตาร
2
เม.ย. 19
3258
Uncaught TypeError: Cannot read properties of null (reading 'CodeMirror') แก้ไขแล้ว
chrome error typeError
อวตาร
1
ก.พ. 23
7648
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة 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 เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

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