Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
10146 มุมมอง
I have searched that there is "action_invoice_create" method to create invoice from SO in OLD version odoo. 
Can I do it in odoo13?
The old style code like that
o_so_id = 3   #sale order id
o_invoice = models.execute_kw(odoo_config['db'],
odoo_config['uid'],
odoo_config['password'],
'sale.order',
'action_invoice_create',
[[3]], {'context': {'active_ids': 3}})

But it generate error in odoo 13
​xmlrpc.client.Fault: <Fault 1: 'Traceback (most recent call last):\n File "/opt/odoo13/odoo/odoo/addons/base/controllers/rpc.py", line 63, in xmlrpc_2\n response = self._xmlrpc(service)\n File "/opt/odoo13/odoo/odoo/addons/base/controllers/rpc.py", line 43, in _xmlrpc\n result = dispatch_rpc(service, method, params)\n File "/opt/odoo13/odoo/odoo/http.py", line 138, in dispatch_rpc\n result = dispatch(method, params)\n File "/opt/odoo13/odoo/odoo/service/model.py", line 40, in dispatch\n res = fn(db, uid, *params)\n File "/opt/odoo13/odoo/odoo/service/model.py", line 168, in execute_kw\n return execute(db, uid, obj, method, *args, **kw or {})\n File "/opt/odoo13/odoo/odoo/service/model.py", line 93, in wrapper\n return f(dbname, *args, **kwargs)\n File "/opt/odoo13/odoo/odoo/service/model.py", line 175, in execute\n res = execute_cr(cr, uid, obj, method, *args, **kw)\n File "/opt/odoo13/odoo/odoo/service/model.py", line 164, in execute_cr\n return odoo.api.call_kw(recs, method, args, kw)\n File "/opt/odoo13/odoo/odoo/api.py", line 388, in call_kw\n method = getattr(type(model), name)\nAttributeError: type object \'sale.order\' has no attribute \'action_invoice_create\'\n'>

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You could create a method which will have the sale_id as parameter

def create_invoice(self, sale_id):
    payment = self.env ["sale.advance.payment.inv"].
create ({})
    payment.with_context (active_ids = sale_id) .create_invoices ()

Similiar functionality is used in OCA's Sales automatic workflow
https://github.com/OCA/sale-workflow/blob/13.0/sale_automatic_workflow/models/automatic_workflow_job.py#L63-L65

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

HI, Somebody, same issue here, did you find a workaround????

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi there,

Did you ever get an answer for this? We are struggling with the same thing?

Regards,
Rayno

อวตาร
ละทิ้ง
ผู้เขียน

No solution from my side. I just created invoice from each Sale Order manually.

คำตอบที่ดีที่สุด

In V13 API has been changed. Now there is no method action_invoice_create on sale.order.
it has been converted to private method https://github.com/odoo/odoo/blob/13.0/addons/sale/models/sale.py#L552
so create a public hook method and call it.

อวตาร
ละทิ้ง
ผู้เขียน

Hi Ravi,

I am newbie for odoo. Can you give me a simple code sample for reference? Thank you!

Or alternatively call the sale.advance.payment.inv wizard & trigger the function "create_invoices" from there by setting the order(s) in the context.

Related Posts ตอบกลับ มุมมอง กิจกรรม
4
พ.ค. 24
12753
1
เม.ย. 24
3363
0
พ.ย. 23
2063
Blank White Page After log in to Odoo13 แก้ไขแล้ว
1
ก.ย. 23
2175
2
ส.ค. 23
4592